KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWWindowBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWWindowBase.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 vtkKWWindowBase - a window superclass
15 // .SECTION Description
16 // This class represents a top level window with a menu bar, a status
17 // line and a main central frame.
18 
19 #ifndef __vtkKWWindowBase_h
20 #define __vtkKWWindowBase_h
21 
22 #include "vtkKWTopLevel.h"
23 
24 class vtkKWFrame;
25 class vtkKWLabel;
26 class vtkKWMenu;
29 class vtkKWProgressGauge;
30 class vtkKWSeparator;
31 class vtkKWToolbar;
32 class vtkKWToolbarSet;
33 
35 {
36 public:
37  static vtkKWWindowBase* New();
38  vtkTypeRevisionMacro(vtkKWWindowBase,vtkKWTopLevel);
39  void PrintSelf(ostream& os, vtkIndent indent);
40 
41  // Description:
42  // Close this window, possibly prompting the user.
43  // Note that the current vtkKWApplication implementation will
44  // exit the application if no more windows are open.
45  // Return 1 if the window closed successfully, 0 otherwise (for example,
46  // if some dialogs are still up, or the user did not confirm, etc).
47  virtual int Close();
48 
49  // Description:
50  // Set/Get if a confirmation dialog should be displayed before a
51  // window is closed. Default to false.
52  vtkSetMacro(PromptBeforeClose, int);
53  vtkGetMacro(PromptBeforeClose, int);
54  vtkBooleanMacro(PromptBeforeClose, int);
55 
56  // Description:
57  // Load and evaluate a Tcl based script.
58  // If called without an argument it will open a file dialog.
59  // This implementation basically forwards the call to
60  // vtkKWApplication::LoadScript.
61  virtual void LoadScript();
62  virtual void LoadScript(const char *filename);
63 
64  // Description:
65  // The extension used in LoadScript. Default is .tcl.
66  vtkSetStringMacro(ScriptExtension);
67  vtkGetStringMacro(ScriptExtension);
68 
69  // Description:
70  // The type name used in LoadScript. Default is Tcl.
71  vtkSetStringMacro(ScriptType);
72  vtkGetStringMacro(ScriptType);
73 
74  // Description:
75  // Set the text for the status bar of this window.
76  virtual void SetStatusText(const char *);
77  virtual const char *GetStatusText();
78 
79  // Description:
80  // Set the error/warning icon in the tray.
81  // Note that if StatusFrameVisibility is Off, you may want to move the
82  // tray frame to a different position (say, in a toolbar), using
83  // the SetTrayFramePosition() method.
84  //BTX
85  enum
86  {
87  ErrorIconNone = 0,
89  ErrorIconRed
90  };
91  //ETX
92  virtual void SetErrorIcon(int);
93  virtual void SetErrorIconToNone()
94  { this->SetErrorIcon(vtkKWWindowBase::ErrorIconNone); };
95  virtual void SetErrorIconToBlack()
96  { this->SetErrorIcon(vtkKWWindowBase::ErrorIconBlack); };
97  virtual void SetErrorIconToRed()
98  { this->SetErrorIcon(vtkKWWindowBase::ErrorIconRed); };
99 
100  // Description:
101  // The window is made of a menu bar (methods are available to access each
102  // menus), a separator, a toolbar placeholder, a large main frame called
103  // the "view frame", and a status frame (inside which the a progress
104  // gauge and some other UI elements can be found).
105  // Note that this large frame is likely to be re-allocated by subclasses
106  // into a different UI structure involving panels, notebooks, interface
107  // managers, etc. therefore GetViewFrame() will be overriden in order to
108  // return the most convenient viewing frame.
109  // The rational here is that GetViewFrame() always return the frame that
110  // can be used by users or developpers to add more "viewing" element (say,
111  // renderwidgets, 3D scenes), without knowing about the current layout.
112  virtual vtkKWFrame* GetViewFrame();
113 
114  // Description:
115  // Get the main toolbar set.
116  vtkGetObjectMacro(MainToolbarSet, vtkKWToolbarSet);
117 
118  // Description:
119  // Get the status frame object.
120  vtkGetObjectMacro(StatusFrame, vtkKWFrame);
121 
122  // Description:
123  // Set/Get the visibility of the status frame. If set to Off, the status
124  // text, as set by SetStatusText(), will not be displayed anymore. Neither
125  // will the progress gauge, the application icon, the tray frame and status
126  // icons. Both the progress gauge and tray frame position can be changed
127  // independently though (see SetProgressGaugePosition and
128  // SetTrayFramePosition).
129  virtual void SetStatusFrameVisibility(int flag);
130  vtkGetMacro(StatusFrameVisibility, int);
131  vtkBooleanMacro(StatusFrameVisibility, int);
132 
133  // Description:
134  // Get the progress gauge widget. The progress gauge is displayed
135  // in the Status frame on the bottom right corner of the window.
136  vtkGetObjectMacro(ProgressGauge, vtkKWProgressGauge);
137 
138  // Description:
139  // Set the progress gauge position. The default position is in the
140  // status frame, but this object can also be displayed in a toolbar, on
141  // top of the window. This is useful when StatusFrameVisibility is set
142  // to Off.
143  //BTX
144  enum
145  {
146  ProgressGaugePositionStatusFrame = 0,
147  ProgressGaugePositionToolbar
148  };
149  //ETX
150  virtual void SetProgressGaugePosition(int);
151  virtual void SetProgressGaugePositionToStatusFrame()
152  { this->SetProgressGaugePosition(
154  virtual void SetProgressGaugePositionToToolbar()
155  { this->SetProgressGaugePosition(
157 
158  // Description:
159  // Get the tray frame object. A default status icon is already packed
160  // in this frame and modified by SetErrorIcon, but other icons can
161  // probably fit there.
162  vtkGetObjectMacro(TrayFrame, vtkKWFrame);
163 
164  // Description:
165  // Set the tray frame position. The default position is in the
166  // status frame, but this object can also be displayed in a toolbar, on
167  // top of the window. This is useful when StatusFrameVisibility is set
168  // to Off.
169  //BTX
170  enum
171  {
172  TrayFramePositionStatusFrame = 0,
173  TrayFramePositionToolbar
174  };
175  //ETX
176  vtkGetMacro(TrayFramePosition, int);
177  virtual void SetTrayFramePosition(int);
178  virtual void SetTrayFramePositionToStatusFrame()
179  { this->SetTrayFramePosition(
181  virtual void SetTrayFramePositionToToolbar()
182  { this->SetTrayFramePosition(
184 
185  // Description:
186  // Get the menu objects. This will allocate and create them on the fly.
187  // Several convenience functions are also available to get the position
188  // where to safely insert entries in those menus without interferring with
189  // entries that should stay at the end of the menus.
190  // Note: if you need to enable/disable a menu item conditionally in a
191  // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
192  // call the parent class's UpdateMenuState() from the subclass as well.
193  vtkKWMenu *GetFileMenu();
194  vtkKWMenu *GetEditMenu();
195  vtkKWMenu *GetViewMenu();
196  vtkKWMenu *GetWindowMenu();
197  vtkKWMenu *GetHelpMenu();
198  vtkKWMenu *GetToolbarsVisibilityMenu();
199  vtkGetObjectMacro(MenuBarSeparator, vtkKWSeparator);
200 
201  // Description:
202  // Convenience method that return the position where to safely insert
203  // entries in the corresponding menu without interferring with entries
204  // that should stay at the end of the menu.
205  // At the moment, GetFileMenuInsertPosition() checks for the 'close',
206  // 'exit' or 'print setup' commands, GetHelpMenuInsertPosition() checks for
207  // the 'about' commands, GetViewMenuInsertPosition() is available for
208  // subclasses to be redefined.
209  virtual int GetFileMenuInsertPosition();
210  virtual int GetHelpMenuInsertPosition();
211  virtual int GetViewMenuInsertPosition();
212 
213  // Description:
214  // Set/Get a hint about help support. Disabled by default.
215  // If set to true (programmatically or by a superclass), it will hint the
216  // instance about populating the help menu with common entries.
217  // For example, an entry invoking the application's DisplayHelpDialog or
218  // DisplayTutorial.
219  vtkSetClampMacro(SupportHelp, int, 0, 1);
220  vtkGetMacro(SupportHelp, int);
221  vtkBooleanMacro(SupportHelp, int);
222 
223  // Description:
224  // Add a file to the Recent File list, and save the whole list to
225  // the registry.
226  // If the "Recent files" sub-menu has been inserted at that point (see
227  // the InsertRecentFilesMenu method), it will be updated as well.
228  virtual void AddRecentFile(
229  const char *filename, vtkObject *target, const char *command);
230 
231  // Description:
232  // Insert a "Recent Files" sub-menu to the File menu at position 'pos'
233  // and fill it with the most recent files stored in the registry.
234  // The 'target' parameter is the object against which the command
235  // associated to a most recent file will be executed (usually the instance).
236  virtual void InsertRecentFilesMenu(int pos, vtkObject *target);
237 
238  // Description:
239  // Set/Get a hint about print support. Disabled by default.
240  // If set to true (programmatically or by a superclass), it will hint the
241  // instance about populating some menus with common print-related entries.
242  // For example, an entry in the file menu to set up print options like
243  // the application's PrintTargetDPI.
244  vtkSetClampMacro(SupportPrint, int, 0, 1);
245  vtkGetMacro(SupportPrint, int);
246  vtkBooleanMacro(SupportPrint, int);
247 
248  // Description:
249  // Get the key bindings manager.
250  vtkGetObjectMacro(KeyBindingsManager, vtkKWKeyBindingsManager);
251 
252  // Description:
253  // Get title of window.
254  // Override the superclass to use app name if the title was not set
255  virtual char* GetTitle();
256 
257  // Description:
258  // Update the UI. This will call:
259  // UpdateToolbarState
260  // UpdateEnableState
261  // UpdateMenuState
262  // Update on all panels belonging to the UserInterfaceManager, if any
263  virtual void Update();
264 
265  // Description:
266  // Update the toolbar state
267  virtual void UpdateToolbarState();
268 
269  // Description:
270  // Update the "enable" state of the object and its internal parts.
271  // Depending on different Ivars (this->Enabled, the application's
272  // Limited Edition Mode, etc.), the "enable" state of the object is updated
273  // and propagated to its internal parts/subwidgets. This will, for example,
274  // enable/disable parts of the widget UI, enable/disable the visibility
275  // of 3D widgets, etc.
276  // Note: if you need to enable/disable a menu item conditionally in a
277  // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
278  // call the parent class's UpdateMenuState() from the subclass as well.
279  virtual void UpdateEnableState();
280  virtual void UpdateMenuState();
281 
282  // Description:
283  // Deallocate/delete/reparent some internal objects in order to solve
284  // reference loops that would prevent this instance from being deleted.
285  virtual void PrepareForDelete();
286 
287  // Description:
288  // Some constants
289  vtkGetStringMacro(PrintOptionsMenuLabel);
290  vtkGetStringMacro(FileMenuLabel);
291  vtkGetStringMacro(FileCloseMenuLabel);
292  vtkGetStringMacro(FileExitMenuLabel);
293  vtkGetStringMacro(OpenRecentFileMenuLabel);
294  vtkGetStringMacro(EditMenuLabel);
295  vtkGetStringMacro(ViewMenuLabel);
296  vtkGetStringMacro(WindowMenuLabel);
297  vtkGetStringMacro(HelpMenuLabel);
298  vtkGetStringMacro(HelpAboutMenuLabel);
299  vtkGetStringMacro(HelpTopicsMenuLabel);
300  vtkGetStringMacro(HelpTutorialMenuLabel);
301  vtkGetStringMacro(HelpKeyBindingsMenuLabel);
302  vtkGetStringMacro(HelpCheckForUpdatesMenuLabel);
303  vtkGetStringMacro(ToolbarsVisibilityMenuLabel);
304  vtkGetStringMacro(WindowGeometryRegKey);
305  vtkGetStringMacro(DefaultGeometry);
306 
307  // Description:
308  // Events.
309  // WindowClosedEvent is called when the window is closing. It is triggered
310  // right before requesting the application to remove the window instance
311  // from its window pool (vtkKWApplication::RemoveWindow).
312  //BTX
313  enum
314  {
315  WindowClosingEvent = 10000
316  };
317  //ETX
318 
319  // Description:
320  // Add all the default observers needed by that object, or remove
321  // all the observers that were added through AddCallbackCommandObserver.
322  // Subclasses can override these methods to add/remove their own default
323  // observers, but should call the superclass too.
324  virtual void AddCallbackCommandObservers();
325  virtual void RemoveCallbackCommandObservers();
326 
327  // Description:
328  // Add observers required to propagate error messages. Note that they
329  // were not put in AddCallbackCommandObservers on purpose, so that they
330  // do not get accidentally removed by RemoveCallbackCommandObservers:
331  // propagation of error messages, after all, should never be disabled.
332  virtual void AddErrorCallbackCommandObservers();
333  virtual void RemoveErrorCallbackCommandObservers();
334 
335  // Description:
336  // Callbacks. Internal, do not use.
337  virtual void ErrorIconCallback();
338  virtual void PrintSettingsCallback() {};
339  virtual void ToolbarVisibilityChangedCallback(vtkKWToolbar*);
340  virtual void NumberOfToolbarsChangedCallback();
341  virtual void DisplayKeyBindingsCallback();
342 
343 protected:
344  vtkKWWindowBase();
345  ~vtkKWWindowBase();
346 
347  // Description:
348  // Create the widget.
349  virtual void CreateWidget();
350 
351  // Description:
352  // Display the close dialog.
353  // Return 1 if the user wants to close the window, 0 otherwise
354  virtual int DisplayCloseDialog();
355 
356  // Description:
357  // Update the image in the status frame. Usually a logo of some sort.
358  // Override this function to include your own application logo
359  virtual void UpdateStatusImage();
360  virtual vtkKWLabel *GetStatusImage();
361 
362  // Description:
363  // Recent files manager
365 
366  // Description:
367  // Key bindings manager
369 
370  // Description:
371  // Save/Restore window geometry
372  virtual void SaveWindowGeometryToRegistry();
373  virtual void RestoreWindowGeometryFromRegistry();
374 
375  // Description:
376  // Pack/repack the UI
377  virtual void Pack();
378 
381 
386 
389 
393 
396 
398  char *ScriptType;
403 
404  // Allocated and created when queried
405 
412 
413  // Description:
414  // Populate the menus.
415  // Note: if you need to enable/disable a menu item conditionally in a
416  // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
417  // call the parent class's UpdateMenuState() from the subclass as well.
418  virtual void PopulateFileMenu();
419  virtual void PopulateEditMenu();
420  virtual void PopulateViewMenu();
421  virtual void PopulateWindowMenu();
422  virtual void PopulateHelpMenu();
423 
425 
426  // Description:
427  // Some constants
428  vtkSetStringMacro(PrintOptionsMenuLabel);
429  vtkSetStringMacro(FileMenuLabel);
430  vtkSetStringMacro(FileCloseMenuLabel);
431  vtkSetStringMacro(FileExitMenuLabel);
432  vtkSetStringMacro(OpenRecentFileMenuLabel);
433  vtkSetStringMacro(EditMenuLabel);
434  vtkSetStringMacro(ViewMenuLabel);
435  vtkSetStringMacro(WindowMenuLabel);
436  vtkSetStringMacro(HelpMenuLabel);
437  vtkSetStringMacro(HelpTopicsMenuLabel);
438  vtkSetStringMacro(HelpTutorialMenuLabel);
439  vtkSetStringMacro(HelpKeyBindingsMenuLabel);
440  vtkSetStringMacro(HelpAboutMenuLabel);
441  vtkSetStringMacro(HelpCheckForUpdatesMenuLabel);
442  vtkSetStringMacro(ToolbarsVisibilityMenuLabel);
443  vtkSetStringMacro(WindowGeometryRegKey);
444  vtkSetStringMacro(DefaultGeometry);
445 
446  // Description:
447  // Processes the events that are passed through CallbackCommand (or others).
448  // Subclasses can oberride this method to process their own events, but
449  // should call the superclass too.
450  virtual void ProcessCallbackCommandEvents(
451  vtkObject *caller, unsigned long event, void *calldata);
452 
453 private:
454 
455  // Description:
456  // Some constants
457  char *PrintOptionsMenuLabel;
458  char *FileMenuLabel;
459  char *FileCloseMenuLabel;
460  char *FileExitMenuLabel;
461  char *OpenRecentFileMenuLabel;
462  char *EditMenuLabel;
463  char *ViewMenuLabel;
464  char *WindowMenuLabel;
465  char *HelpMenuLabel;
466  char *HelpTopicsMenuLabel;
467  char *HelpTutorialMenuLabel;
468  char *HelpKeyBindingsMenuLabel;
469  char *HelpAboutMenuLabel;
470  char *HelpCheckForUpdatesMenuLabel;
471  char *ToolbarsVisibilityMenuLabel;
472  char *WindowGeometryRegKey;
473  char *DefaultGeometry;
474 
475  vtkKWWindowBase(const vtkKWWindowBase&); // Not implemented
476  void operator=(const vtkKWWindowBase&); // Not implemented
477 };
478 
479 #endif