KWWidgets
vtkKWSplashScreen.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWSplashScreen.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWSplashScreen - a splash dialog.
15 // .SECTION Description
16 // A class for displaying splash screen.
17 
18 #ifndef __vtkKWSplashScreen_h
19 #define __vtkKWSplashScreen_h
20 
21 #include "vtkKWTopLevel.h"
22 
23 class vtkKWCanvas;
24 class vtkKWIcon;
25 
27 {
28 public:
29  static vtkKWSplashScreen* New();
30  vtkTypeRevisionMacro(vtkKWSplashScreen, vtkKWTopLevel);
31  void PrintSelf(ostream& os, vtkIndent indent);
32 
33  // Description:
34  // Set the text of the progress message
35  void SetProgressMessage(const char *);
36 
37  // Description:
38  // Set/Get the offset of the progress message (negative value means
39  // offset from the bottom of the splash, positive value from the top)
40  virtual void SetProgressMessageVerticalOffset(int);
41  vtkGetMacro(ProgressMessageVerticalOffset, int);
42 
43  // Description:
44  // Specifies an image to display in the splashscreen.
45  // The SetImageToPredefinedIcon method accepts an index to one of the
46  // predefined icon listed in vtkKWIcon.
47  // The SetImageToPixels method sets the image using pixel data. It expects
48  // a pointer to the pixels and the structure of the image, i.e. its width,
49  // height and the pixel_size (how many bytes per pixel, say 3 for RGB, or
50  // 1 for grayscale). If buffer_length = 0, it is computed automatically
51  // from the previous parameters. If it is not, it will most likely indicate
52  // that the buffer has been encoded using base64 and/or zlib.
53  // If pixel_size > 3 (i.e. RGBA), the image is blend the with background
54  // color of the widget.
55  // The SetImageName method can be used to specify a pre-existing Tk image.
56  virtual void SetImageToIcon(vtkKWIcon *icon);
57  virtual void SetImageToPredefinedIcon(int icon_index);
58  virtual void SetImageToPixels(
59  const unsigned char *pixels, int width, int height, int pixel_size,
60  unsigned long buffer_length = 0);
61 
62  // Description:
63  // Read an image and use it as the splash image.
64  // Check vtkKWResourceUtilities::ReadImage for the list of supported
65  // image format
66  // Return 1 on success, 0 otherwise
67  virtual int ReadImage(const char *filename);
68 
69  // Description:
70  // Set/Get the name of the splashscreen image, as a Tk image name.
71  // This method is kept for backward compatibility only, as it exposes
72  // our dependency to Tk internal data structures. Use ReadImage,
73  // SetImageToIcon or SetImageToPixels instead.
74  vtkGetStringMacro(ImageName);
75  virtual void SetImageName(const char*);
76 
77  // Description:
78  // Update the "enable" state of the object and its internal parts.
79  // Depending on different Ivars (this->Enabled, the application's
80  // Limited Edition Mode, etc.), the "enable" state of the object is updated
81  // and propagated to its internal parts/subwidgets. This will, for example,
82  // enable/disable parts of the widget UI, enable/disable the visibility
83  // of 3D widgets, etc.
84  virtual void UpdateEnableState();
85 
86  // Description:
87  // Display the toplevel. Hide it with the Withdraw() method.
88  virtual void Display();
89 
90  // Description:
91  // Callbacks.
92  virtual void ButtonPressCallback();
93 
94 protected:
97 
98  // Description:
99  // Create the widget.
100  virtual void CreateWidget();
101 
102  vtkKWCanvas *Canvas;
103  char *ImageName;
104  int ProgressMessageVerticalOffset;
105  int Discard;
106 
107  virtual void UpdateImageInCanvas();
108  virtual void UpdateCanvasSize();
109  virtual void UpdateProgressMessagePosition();
110 
111  // Description:
112  // Get the width/height of the toplevel as requested
113  // by the window manager. Not exposed in public since it is so Tk
114  // related. Is is usually used to get the geometry of a window before
115  // it is mapped to screen, as requested by the geometry manager.
116  // Override to prevent the splashscreen from flickering at startup.
117  // Return the size of the image itself, without explicitly calling
118  // 'update' to let the geometry manager figure things out (= flicker)
119  virtual int GetRequestedWidth();
120  virtual int GetRequestedHeight();
121 
122 private:
123  vtkKWSplashScreen(const vtkKWSplashScreen&); // Not implemented
124  void operator=(const vtkKWSplashScreen&); // Not implemented
125 };
126 
127 
128 #endif
129 
130 
131