KWWidgets
vtkKWStartupPageWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: vtkKWStartupPageWidget.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 vtkKWStartupPageWidget - an HSV color selector
15 // Open file
16 // Double click
17 // Drag and drop
18 // Recent files
19 // .SECTION Description
20 // A widget that allows the user choose a HSV color interactively
21 
22 #ifndef __vtkKWStartupPageWidget_h
23 #define __vtkKWStartupPageWidget_h
24 
25 #include "vtkKWCompositeWidget.h"
26 
27 class vtkKWCanvas;
28 class vtkKWLabel;
29 class vtkKWIcon;
30 class vtkKWStartupPageWidgetInternals;
32 
34 {
35 public:
36  static vtkKWStartupPageWidget* New();
38  void PrintSelf(ostream& os, vtkIndent indent);
39 
40  // Description:
41  // Set/Get the gradient colors (in RGB space)
42  vtkGetVector3Macro(GradientColor1, double);
43  virtual void SetGradientColor1(double r, double g, double b);
44  virtual void SetGradientColor1(double rgb[3])
45  { this->SetGradientColor1(rgb[0], rgb[1], rgb[2]); };
46  vtkGetVector3Macro(GradientColor2, double);
47  virtual void SetGradientColor2(double r, double g, double b);
48  virtual void SetGradientColor2(double rgb[3])
49  { this->SetGradientColor2(rgb[0], rgb[1], rgb[2]); };
50 
51  // Description:
52  // Set/Get the text color (in RGB space)
53  vtkGetVector3Macro(TextColor, double);
54  virtual void SetTextColor(double r, double g, double b);
55  virtual void SetTextColor(double rgb[3])
56  { this->SetTextColor(rgb[0], rgb[1], rgb[2]); };
57 
58  // Description:
59  // Set/Get the text size
60  vtkGetMacro(TextSize, int);
61  virtual void SetTextSize(int);
62 
63  // Description:
64  // Set/Get the text color (in RGB space) when it is selected (hovered on)
65  vtkGetVector3Macro(SelectedTextColor, double);
66  virtual void SetSelectedTextColor(double r, double g, double b);
67  virtual void SetSelectedTextColor(double rgb[3])
68  { this->SetSelectedTextColor(rgb[0], rgb[1], rgb[2]); };
69 
70  // Description:
71  // Set/Get the hint color (in RGB space)
72  vtkGetVector3Macro(HintColor, double);
73  virtual void SetHintColor(double r, double g, double b);
74  virtual void SetHintColor(double rgb[3])
75  { this->SetHintColor(rgb[0], rgb[1], rgb[2]); };
76 
77  // Description:
78  // Set/Get the hint size
79  vtkGetMacro(HintSize, int);
80  virtual void SetHintSize(int);
81 
82  // Description:
83  // Set/Get if the hints should have a shadow.
84  virtual void SetAddShadowToHint(int);
85  vtkGetMacro(AddShadowToHint, int);
86  vtkBooleanMacro(AddShadowToHint, int);
87 
88  // Description:
89  // Set/Get if the Open section is supported/shown.
90  virtual void SetSupportOpen(int);
91  vtkGetMacro(SupportOpen, int);
92  vtkBooleanMacro(SupportOpen, int);
93 
94  // Description:
95  // Set/Get the Open section icon using an icon, or the index to a
96  // predefined icon found in vtkKWIcon.
97  // Note that the Set method does *not* keep a reference to the icon
98  // passed as parameter: it copies the whole icon contents internally.
99  vtkGetObjectMacro(OpenIcon, vtkKWIcon);
100  virtual void SetOpenIcon(vtkKWIcon*);
101  virtual void SetOpenIconToPredefinedIcon(int icon_index);
102 
103  // Description:
104  // Set/Get if the Double Click section is supported/shown.
105  virtual void SetSupportDoubleClick(int);
106  vtkGetMacro(SupportDoubleClick, int);
107  vtkBooleanMacro(SupportDoubleClick, int);
108 
109  // Description:
110  // Set/Get the Double Click section icon using an icon, or the index to a
111  // predefined icon found in vtkKWIcon.
112  // Note that the Set method does *not* keep a reference to the icon
113  // passed as parameter: it copies the whole icon contents internally.
114  vtkGetObjectMacro(DoubleClickIcon, vtkKWIcon);
115  virtual void SetDoubleClickIcon(vtkKWIcon*);
116  virtual void SetDoubleClickIconToPredefinedIcon(int icon_index);
117 
118  // Description:
119  // Set/Get if the Drag & Drop section is supported/shown.
120  virtual void SetSupportDrop(int);
121  vtkGetMacro(SupportDrop, int);
122  vtkBooleanMacro(SupportDrop, int);
123 
124  // Description:
125  // Set/Get the Drag & Drop section icon using an icon, or the index to a
126  // predefined icon found in vtkKWIcon.
127  // Note that the Set method does *not* keep a reference to the icon
128  // passed as parameter: it copies the whole icon contents internally.
129  vtkGetObjectMacro(DropIcon, vtkKWIcon);
130  virtual void SetDropIcon(vtkKWIcon*);
131  virtual void SetDropIconToPredefinedIcon(int icon_index);
132 
133  // Description:
134  // Set/Get if the Most Recent Files section is supported/shown.
135  virtual void SetSupportMostRecentFiles(int);
136  vtkGetMacro(SupportMostRecentFiles, int);
137  vtkBooleanMacro(SupportMostRecentFiles, int);
138 
139  // Description:
140  // Set/Get the Most Recent Files section icon using an icon, or the index to
141  // a predefined icon found in vtkKWIcon.
142  // Note that the Set method does *not* keep a reference to the icon
143  // passed as parameter: it copies the whole icon contents internally.
144  vtkGetObjectMacro(MostRecentFilesIcon, vtkKWIcon);
145  virtual void SetMostRecentFilesIcon(vtkKWIcon*);
146  virtual void SetMostRecentFilesIconToPredefinedIcon(int icon_index);
147 
148  // Description:
149  // Set/Get the Most Recent File icon (i.e. the icon used for a single
150  // most recent file, not the section itself) using an icon, or the index to
151  // a predefined icon found in vtkKWIcon.
152  // Note that the Set method does *not* keep a reference to the icon
153  // passed as parameter: it copies the whole icon contents internally.
154  vtkGetObjectMacro(MostRecentFileIcon, vtkKWIcon);
155  virtual void SetMostRecentFileIcon(vtkKWIcon*);
156  virtual void SetMostRecentFileIconToPredefinedIcon(int icon_index);
157 
158  // Description:
159  // Set/Get the text size of recent file items
160  vtkGetMacro(MostRecentFileSize, int);
161  virtual void SetMostRecentFileSize(int);
162 
163  // Description:
164  // Set/Get the most recent files manager this page should listen to.
165  vtkGetObjectMacro(MostRecentFilesManager, vtkKWMostRecentFilesManager);
166  virtual void SetMostRecentFilesManager(vtkKWMostRecentFilesManager *mgr);
167 
168  // Description:
169  // Set/Get the maximum number of most recent files to display.
170  vtkGetMacro(MaximumNumberOfMostRecentFiles, int);
171  virtual void SetMaximumNumberOfMostRecentFiles(int);
172 
173  // Description:
174  // Specifies commands to associate with the widget.
175  // 'OpenCommand' is invoked when the user click on the Open section.
176  // The 'object' argument is the object that will have the method called on
177  // it. The 'method' argument is the name of the method to be called and any
178  // arguments in string form. If the object is NULL, the method is still
179  // evaluated as a simple command.
180  virtual void SetOpenCommand(
181  vtkObject *object, const char *method);
182 
183  // Description:
184  // Specifies commands to associate with the widget.
185  // 'DropCommand' is invoked when the user drop a file on the widget.
186  // The 'object' argument is the object that will have the method called on
187  // it. The 'method' argument is the name of the method to be called and any
188  // arguments in string form. If the object is NULL, the method is still
189  // evaluated as a simple command.
190  // The following parameters are also passed to the command:
191  // - filename(s): list of filenames
192  virtual void SetDropCommand(
193  vtkObject *object, const char *method);
194 
195  // Description:
196  // Specifies commands to associate with the widget.
197  // 'DoubleClickCommand' is invoked when the user double-click anywhere
198  // in the page widget.
199  // The 'object' argument is the object that will have the method called on
200  // it. The 'method' argument is the name of the method to be called and any
201  // arguments in string form. If the object is NULL, the method is still
202  // evaluated as a simple command.
203  virtual void SetDoubleClickCommand(
204  vtkObject *object, const char *method);
205 
206  // Description:
207  // Access to the canvas and internal elements
208  vtkGetObjectMacro(StartupPageCanvas, vtkKWCanvas);
209 
210  // Description:
211  // Update the whole UI depending on the value of the Ivars
212  virtual void Update();
213 
214  // Description:
215  // Update the "enable" state of the object and its internal parts.
216  // Depending on different Ivars (this->Enabled, the application's
217  // Limited Edition Mode, etc.), the "enable" state of the object is updated
218  // and propagated to its internal parts/subwidgets. This will, for example,
219  // enable/disable parts of the widget UI, enable/disable the visibility
220  // of 3D widgets, etc.
221  virtual void UpdateEnableState();
222 
223  // Description:
224  // Callbacks. Internal, do not use.
225  virtual void ConfigureCallback();
226  virtual void RedrawCallback();
227  virtual void HighlightSectionCallback(const char *tag, int flag);
228  virtual void OpenCallback();
229  virtual void DoubleClickCallback();
230 
231  // Description:
232  // Add all the default observers needed by that object, or remove
233  // all the observers that were added through AddCallbackCommandObserver.
234  // Subclasses can override these methods to add/remove their own default
235  // observers, but should call the superclass too.
236  virtual void AddCallbackCommandObservers();
237  virtual void RemoveCallbackCommandObservers();
238 
239 protected:
242 
243  // Description:
244  // Create the widget.
245  virtual void CreateWidget();
246 
247  double GradientColor1[3];
248  double GradientColor2[3];
249  double TextColor[3];
250  double SelectedTextColor[3];
251  double HintColor[3];
252 
253  int TextSize;
254  int HintSize;
255  int MostRecentFileSize;
256 
257  int SupportOpen;
258  int SupportDoubleClick;
259  int SupportDrop;
260  int SupportMostRecentFiles;
261 
262  int MaximumNumberOfMostRecentFiles;
263  int AddShadowToHint;
264 
265  vtkKWIcon *OpenIcon;
266  vtkKWIcon *DoubleClickIcon;
267  vtkKWIcon *DropIcon;
268  vtkKWIcon *MostRecentFilesIcon;
269  vtkKWIcon *MostRecentFileIcon;
270 
271  // Recent files manager
272 
273  vtkKWMostRecentFilesManager *MostRecentFilesManager;
274 
275  // Commands
276 
277  char *OpenCommand;
278  char *DropCommand;
279  char *DoubleClickCommand;
280 
281  // GUI
282 
283  vtkKWCanvas *StartupPageCanvas;
284 
285  // Description:
286  // Bind/Unbind all components.
287  virtual void Bind();
288  virtual void UnBind();
289 
290  // Description:
291  // Redraw or update canvas elements
292  virtual void Redraw();
293  virtual void ScheduleRedraw();
294 
295  // Description:
296  // Update bindings, fonts, colors, icons
297  virtual void UpdateInternalCanvasBindings();
298  virtual void UpdateInternalCanvasColors();
299  virtual void UpdateInternalCanvasFonts();
300  virtual void UpdateInternalCanvasIcons();
301 
302  // Description:
303  // Draw section
304  virtual void AddSectionToCanvas(
305  ostream &tk_cmd,
306  int x, int y,
307  vtkKWIcon *icon,
308  const char *text, const char *text_font,
309  const char *hint, const char *hint_font,
310  vtkObject *object, const char *method,
311  const char *tag, const char *extra_tag = NULL);
312 
313  virtual void AddMostRecentFilesSectionToCanvas(
314  ostream &tk_cmd,
315  int x, int y);
316 
317  // Description:
318  // Invoke the commands
319  virtual void InvokeOpenCommand();
320  virtual void InvokeDoubleClickCommand();
321 
322  // PIMPL Encapsulation for STL containers
323  //BTX
324  vtkKWStartupPageWidgetInternals *Internals;
325  //ETX
326 
327  // Description:
328  // Processes the events that are passed through CallbackCommand (or others).
329  // Subclasses can oberride this method to process their own events, but
330  // should call the superclass too.
331  virtual void ProcessCallbackCommandEvents(
332  vtkObject *caller, unsigned long event, void *calldata);
333 
334  // Description:
335  // Helpers
336  virtual int GetHorizontalIncrementFromIcon(vtkKWIcon *icon);
337 
338 private:
339  vtkKWStartupPageWidget(const vtkKWStartupPageWidget&); // Not implemented
340  void operator=(const vtkKWStartupPageWidget&); // Not implemented
341 };
342 
343 #endif
344