• Main Page
  • Classes
  • Files
  • Directories
  • File List
  • File Members

vtkKWWindowBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWWindowBase.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 // .NAME vtkKWWindowBase - a window superclass
00015 // .SECTION Description
00016 // This class represents a top level window with a menu bar, a status
00017 // line and a main central frame.
00018 
00019 #ifndef __vtkKWWindowBase_h
00020 #define __vtkKWWindowBase_h
00021 
00022 #include "vtkKWTopLevel.h"
00023 
00024 class vtkKWFrame;
00025 class vtkKWLabel;
00026 class vtkKWMenu;
00027 class vtkKWMostRecentFilesManager;
00028 class vtkKWKeyBindingsManager;
00029 class vtkKWProgressGauge;
00030 class vtkKWSeparator;
00031 class vtkKWToolbar;
00032 class vtkKWToolbarSet;
00033 
00034 class KWWidgets_EXPORT vtkKWWindowBase : public vtkKWTopLevel
00035 {
00036 public:
00037   static vtkKWWindowBase* New();
00038   vtkTypeRevisionMacro(vtkKWWindowBase,vtkKWTopLevel);
00039   void PrintSelf(ostream& os, vtkIndent indent);
00040 
00041   // Description:
00042   // Close this window, possibly prompting the user.
00043   // Note that the current vtkKWApplication implementation will
00044   // exit the application if no more windows are open.
00045   // Return 1 if the window closed successfully, 0 otherwise (for example,
00046   // if some dialogs are still up, or the user did not confirm, etc).
00047   virtual int Close();
00048 
00049   // Description:
00050   // Set/Get if a confirmation dialog should be displayed before a
00051   // window is closed. Default to false.
00052   vtkSetMacro(PromptBeforeClose, int);
00053   vtkGetMacro(PromptBeforeClose, int);
00054   vtkBooleanMacro(PromptBeforeClose, int);
00055 
00056   // Description:
00057   // Load and evaluate a Tcl based script. 
00058   // If called without an argument it will open a file dialog.
00059   // This implementation basically forwards the call to 
00060   // vtkKWApplication::LoadScript.
00061   virtual void LoadScript();
00062   virtual void LoadScript(const char *filename);
00063 
00064   // Description:
00065   // The extension used in LoadScript. Default is .tcl.
00066   vtkSetStringMacro(ScriptExtension);
00067   vtkGetStringMacro(ScriptExtension);
00068 
00069   // Description:
00070   // The type name used in LoadScript. Default is Tcl.
00071   vtkSetStringMacro(ScriptType);
00072   vtkGetStringMacro(ScriptType);
00073 
00074   // Description:
00075   // Set the text for the status bar of this window.
00076   virtual void SetStatusText(const char *);
00077   virtual const char *GetStatusText();
00078   
00079   // Description:
00080   // Set the error/warning icon in the tray.
00081   // Note that if StatusFrameVisibility is Off, you may want to move the
00082   // tray frame to a different position (say, in a toolbar), using
00083   // the SetTrayFramePosition() method.
00084   //BTX
00085   enum 
00086   {
00087     ErrorIconNone = 0,
00088     ErrorIconBlack,
00089     ErrorIconRed
00090   };
00091   //ETX
00092   virtual void SetErrorIcon(int);
00093   virtual void SetErrorIconToNone()
00094     { this->SetErrorIcon(vtkKWWindowBase::ErrorIconNone); };
00095   virtual void SetErrorIconToBlack()
00096     { this->SetErrorIcon(vtkKWWindowBase::ErrorIconBlack); };
00097   virtual void SetErrorIconToRed()
00098     { this->SetErrorIcon(vtkKWWindowBase::ErrorIconRed); };
00099 
00100   // Description:
00101   // The window is made of a menu bar (methods are available to access each
00102   // menus), a separator, a toolbar placeholder, a large main frame called
00103   // the "view frame", and a status frame (inside which the a progress
00104   // gauge and some other UI elements can be found).
00105   // Note that this large frame is likely to be re-allocated by subclasses
00106   // into a different UI structure involving panels, notebooks, interface 
00107   // managers, etc. therefore GetViewFrame() will be overriden in order to
00108   // return the most convenient viewing frame. 
00109   // The rational here is that GetViewFrame() always return the frame that
00110   // can be used by users or developpers to add more "viewing" element (say,
00111   // renderwidgets, 3D scenes), without knowing about the current layout.
00112   virtual vtkKWFrame* GetViewFrame();
00113 
00114   // Description:
00115   // Get the main toolbar set.
00116   vtkGetObjectMacro(MainToolbarSet, vtkKWToolbarSet);
00117 
00118   // Description:
00119   // Get the status frame object.
00120   vtkGetObjectMacro(StatusFrame, vtkKWFrame);
00121 
00122   // Description:
00123   // Set/Get the visibility of the status frame. If set to Off, the status
00124   // text, as set by SetStatusText(), will not be displayed anymore. Neither
00125   // will the progress gauge, the application icon, the tray frame and status
00126   // icons. Both the progress gauge and tray frame position can be changed 
00127   // independently though (see SetProgressGaugePosition and 
00128   // SetTrayFramePosition).
00129   virtual void SetStatusFrameVisibility(int flag);
00130   vtkGetMacro(StatusFrameVisibility, int);
00131   vtkBooleanMacro(StatusFrameVisibility, int);  
00132 
00133   // Description:
00134   // Get the progress gauge widget.  The progress gauge is displayed
00135   // in the Status frame on the bottom right corner of the window.
00136   vtkGetObjectMacro(ProgressGauge, vtkKWProgressGauge);
00137 
00138   // Description:
00139   // Set the progress gauge position. The default position is in the
00140   // status frame, but this object can also be displayed in a toolbar, on
00141   // top of the window. This is useful when StatusFrameVisibility is set
00142   // to Off.
00143   //BTX
00144   enum 
00145   {
00146     ProgressGaugePositionStatusFrame = 0,
00147     ProgressGaugePositionToolbar
00148   };
00149   //ETX
00150   virtual void SetProgressGaugePosition(int);
00151   virtual void SetProgressGaugePositionToStatusFrame()
00152     { this->SetProgressGaugePosition(
00153       vtkKWWindowBase::ProgressGaugePositionStatusFrame); };
00154   virtual void SetProgressGaugePositionToToolbar()
00155     { this->SetProgressGaugePosition(
00156       vtkKWWindowBase::ProgressGaugePositionToolbar); };
00157 
00158   // Description:
00159   // Get the tray frame object. A default status icon is already packed
00160   // in this frame and modified by SetErrorIcon, but other icons can
00161   // probably fit there.
00162   vtkGetObjectMacro(TrayFrame, vtkKWFrame);
00163 
00164   // Description:
00165   // Set the tray frame position. The default position is in the
00166   // status frame, but this object can also be displayed in a toolbar, on
00167   // top of the window. This is useful when StatusFrameVisibility is set
00168   // to Off.
00169   //BTX
00170   enum 
00171   {
00172     TrayFramePositionStatusFrame = 0,
00173     TrayFramePositionToolbar
00174   };
00175   //ETX
00176   vtkGetMacro(TrayFramePosition, int);
00177   virtual void SetTrayFramePosition(int);
00178   virtual void SetTrayFramePositionToStatusFrame()
00179     { this->SetTrayFramePosition(
00180       vtkKWWindowBase::TrayFramePositionStatusFrame); };
00181   virtual void SetTrayFramePositionToToolbar()
00182     { this->SetTrayFramePosition(
00183       vtkKWWindowBase::TrayFramePositionToolbar); };
00184 
00185   // Description:
00186   // Get the menu objects. This will allocate and create them on the fly.
00187   // Several convenience functions are also available to get the position
00188   // where to safely insert entries in those menus without interferring with
00189   // entries that should stay at the end of the menus.
00190   // Note: if you need to enable/disable a menu item conditionally in a 
00191   // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
00192   // call the parent class's UpdateMenuState() from the subclass as well.
00193   vtkKWMenu *GetFileMenu();
00194   vtkKWMenu *GetEditMenu();
00195   vtkKWMenu *GetViewMenu();
00196   vtkKWMenu *GetWindowMenu();
00197   vtkKWMenu *GetHelpMenu();
00198   vtkKWMenu *GetToolbarsVisibilityMenu();
00199   vtkGetObjectMacro(MenuBarSeparator, vtkKWSeparator);
00200 
00201   // Description:
00202   // Convenience method that return the position where to safely insert 
00203   // entries in the corresponding menu without interferring with entries
00204   // that should stay at the end of the menu.
00205   // At the moment, GetFileMenuInsertPosition() checks for the 'close',
00206   // 'exit' or 'print setup' commands, GetHelpMenuInsertPosition() checks for
00207   // the 'about' commands, GetViewMenuInsertPosition() is available for
00208   // subclasses to be redefined. 
00209   virtual int GetFileMenuInsertPosition();
00210   virtual int GetHelpMenuInsertPosition();
00211   virtual int GetViewMenuInsertPosition();
00212 
00213   // Description:
00214   // Set/Get a hint about help support. Disabled by default.
00215   // If set to true (programmatically or by a superclass), it will hint the
00216   // instance about populating the help menu with common entries. 
00217   // For example, an entry invoking the application's DisplayHelpDialog.
00218   vtkSetClampMacro(SupportHelp, int, 0, 1);
00219   vtkGetMacro(SupportHelp, int);
00220   vtkBooleanMacro(SupportHelp, int);
00221 
00222   // Description:
00223   // Add a file to the Recent File list, and save the whole list to
00224   // the registry.
00225   // If the "Recent files" sub-menu has been inserted at that point (see
00226   // the InsertRecentFilesMenu method), it will be updated as well.
00227   virtual void AddRecentFile(
00228     const char *filename, vtkObject *target, const char *command);
00229 
00230   // Description:
00231   // Insert a "Recent Files" sub-menu to the File menu at position 'pos'
00232   // and fill it with the most recent files stored in the registry.
00233   // The 'target' parameter is the object against which the command
00234   // associated to a most recent file will be executed (usually the instance).
00235   virtual void InsertRecentFilesMenu(int pos, vtkObject *target);
00236  
00237   // Description:
00238   // Set/Get a hint about print support. Disabled by default.
00239   // If set to true (programmatically or by a superclass), it will hint the
00240   // instance about populating some menus with common print-related entries. 
00241   // For example, an entry in the file menu to set up print options like
00242   // the application's PrintTargetDPI.
00243   vtkSetClampMacro(SupportPrint, int, 0, 1);
00244   vtkGetMacro(SupportPrint, int);
00245   vtkBooleanMacro(SupportPrint, int);
00246 
00247   // Description:
00248   // Get the key bindings manager.
00249   vtkGetObjectMacro(KeyBindingsManager, vtkKWKeyBindingsManager);
00250 
00251   // Description:
00252   // Get title of window.
00253   // Override the superclass to use app name if the title was not set
00254   virtual char* GetTitle();
00255 
00256   // Description:
00257   // Update the UI. This will call:
00258   //   UpdateToolbarState
00259   //   UpdateEnableState 
00260   //   UpdateMenuState
00261   //   Update on all panels belonging to the UserInterfaceManager, if any
00262   virtual void Update();
00263 
00264   // Description:
00265   // Update the toolbar state
00266   virtual void UpdateToolbarState();
00267 
00268   // Description:
00269   // Update the "enable" state of the object and its internal parts.
00270   // Depending on different Ivars (this->Enabled, the application's 
00271   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00272   // and propagated to its internal parts/subwidgets. This will, for example,
00273   // enable/disable parts of the widget UI, enable/disable the visibility
00274   // of 3D widgets, etc.
00275   // Note: if you need to enable/disable a menu item conditionally in a 
00276   // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
00277   // call the parent class's UpdateMenuState() from the subclass as well.
00278   virtual void UpdateEnableState();
00279   virtual void UpdateMenuState();
00280 
00281   // Description:
00282   // Deallocate/delete/reparent some internal objects in order to solve
00283   // reference loops that would prevent this instance from being deleted.
00284   virtual void PrepareForDelete();
00285 
00286   // Description:
00287   // Some constants
00288   vtkGetStringMacro(PrintOptionsMenuLabel);
00289   vtkGetStringMacro(FileMenuLabel);
00290   vtkGetStringMacro(FileCloseMenuLabel);
00291   vtkGetStringMacro(FileExitMenuLabel);
00292   vtkGetStringMacro(OpenRecentFileMenuLabel);
00293   vtkGetStringMacro(EditMenuLabel);
00294   vtkGetStringMacro(ViewMenuLabel);
00295   vtkGetStringMacro(WindowMenuLabel);
00296   vtkGetStringMacro(HelpMenuLabel);
00297   vtkGetStringMacro(HelpAboutMenuLabel);
00298   vtkGetStringMacro(HelpTopicsMenuLabel);
00299   vtkGetStringMacro(HelpKeyBindingsMenuLabel);
00300   vtkGetStringMacro(HelpCheckForUpdatesMenuLabel);
00301   vtkGetStringMacro(ToolbarsVisibilityMenuLabel);
00302   vtkGetStringMacro(WindowGeometryRegKey);
00303   vtkGetStringMacro(DefaultGeometry);
00304 
00305   // Description:
00306   // Events. 
00307   // WindowClosedEvent is called when the window is closing. It is triggered
00308   // right before requesting the application to remove the window instance
00309   // from its window pool (vtkKWApplication::RemoveWindow).
00310   //BTX
00311   enum
00312   {
00313     WindowClosingEvent = 10000
00314   };
00315   //ETX
00316 
00317   // Description:
00318   // Add all the default observers needed by that object, or remove
00319   // all the observers that were added through AddCallbackCommandObserver.
00320   // Subclasses can override these methods to add/remove their own default
00321   // observers, but should call the superclass too.
00322   virtual void AddCallbackCommandObservers();
00323   virtual void RemoveCallbackCommandObservers();
00324 
00325   // Description:
00326   // Add observers required to propagate error messages. Note that they
00327   // were not put in AddCallbackCommandObservers on purpose, so that they
00328   // do not get accidentally removed by RemoveCallbackCommandObservers: 
00329   // propagation of error messages, after all, should never be disabled.
00330   virtual void AddErrorCallbackCommandObservers();
00331   virtual void RemoveErrorCallbackCommandObservers();
00332 
00333   // Description:
00334   // Callbacks. Internal, do not use.
00335   virtual void ErrorIconCallback();
00336   virtual void PrintSettingsCallback() {};
00337   virtual void ToolbarVisibilityChangedCallback(vtkKWToolbar*);
00338   virtual void NumberOfToolbarsChangedCallback();
00339   virtual void DisplayKeyBindingsCallback();
00340 
00341 protected:
00342   vtkKWWindowBase();
00343   ~vtkKWWindowBase();
00344 
00345   // Description:
00346   // Create the widget.
00347   virtual void CreateWidget();
00348 
00349   // Description:
00350   // Display the close dialog.
00351   // Return 1 if the user wants to close the window, 0 otherwise
00352   virtual int DisplayCloseDialog();
00353 
00354   // Description:
00355   // Update the image in the status frame. Usually a logo of some sort.
00356   // Override this function to include your own application logo
00357   virtual void UpdateStatusImage();
00358   virtual vtkKWLabel *GetStatusImage();
00359 
00360   // Description:
00361   // Recent files manager
00362   vtkKWMostRecentFilesManager *MostRecentFilesManager;
00363 
00364   // Description:
00365   // Key bindings manager
00366   vtkKWKeyBindingsManager *KeyBindingsManager;
00367 
00368   // Description:
00369   // Save/Restore window geometry
00370   virtual void SaveWindowGeometryToRegistry();
00371   virtual void RestoreWindowGeometryFromRegistry();
00372 
00373   // Description:
00374   // Pack/repack the UI
00375   virtual void Pack();
00376 
00377   vtkKWSeparator *MenuBarSeparator;
00378   vtkKWFrame *MainFrame;
00379 
00380   vtkKWSeparator *StatusFrameSeparator;
00381   vtkKWFrame *StatusFrame;
00382   vtkKWLabel *StatusImage;
00383   vtkKWLabel *StatusLabel;
00384 
00385   vtkKWProgressGauge *ProgressGauge;
00386   int                ProgressGaugePosition;
00387 
00388   vtkKWFrame      *TrayFrame;
00389   vtkKWLabel      *TrayImageError;
00390   int             TrayFramePosition;
00391 
00392   vtkKWToolbarSet *MainToolbarSet;
00393   vtkKWToolbar    *StatusToolbar;
00394 
00395   char *ScriptExtension;
00396   char *ScriptType;
00397   int  SupportHelp;
00398   int  SupportPrint;
00399   int  PromptBeforeClose;
00400   int  StatusFrameVisibility;
00401 
00402   // Allocated and created when queried
00403 
00404   vtkKWMenu *FileMenu;
00405   vtkKWMenu *EditMenu;
00406   vtkKWMenu *ViewMenu;
00407   vtkKWMenu *WindowMenu;
00408   vtkKWMenu *HelpMenu;
00409   vtkKWMenu *ToolbarsVisibilityMenu;
00410 
00411   // Description:
00412   // Populate the menus.
00413   // Note: if you need to enable/disable a menu item conditionally in a 
00414   // subclass, do it so by reimplementing UpdateMenuState(); do not forget to
00415   // call the parent class's UpdateMenuState() from the subclass as well.
00416   virtual void PopulateFileMenu();
00417   virtual void PopulateEditMenu();
00418   virtual void PopulateViewMenu();
00419   virtual void PopulateWindowMenu();
00420   virtual void PopulateHelpMenu();
00421 
00422   vtkKWTclInteractor *TclInteractor;
00423 
00424   // Description:
00425   // Some constants
00426   vtkSetStringMacro(PrintOptionsMenuLabel);
00427   vtkSetStringMacro(FileMenuLabel);
00428   vtkSetStringMacro(FileCloseMenuLabel);
00429   vtkSetStringMacro(FileExitMenuLabel);
00430   vtkSetStringMacro(OpenRecentFileMenuLabel);
00431   vtkSetStringMacro(EditMenuLabel);
00432   vtkSetStringMacro(ViewMenuLabel);
00433   vtkSetStringMacro(WindowMenuLabel);
00434   vtkSetStringMacro(HelpMenuLabel);
00435   vtkSetStringMacro(HelpTopicsMenuLabel);
00436   vtkSetStringMacro(HelpKeyBindingsMenuLabel);
00437   vtkSetStringMacro(HelpAboutMenuLabel);
00438   vtkSetStringMacro(HelpCheckForUpdatesMenuLabel);
00439   vtkSetStringMacro(ToolbarsVisibilityMenuLabel);
00440   vtkSetStringMacro(WindowGeometryRegKey);
00441   vtkSetStringMacro(DefaultGeometry);
00442 
00443   // Description:
00444   // Processes the events that are passed through CallbackCommand (or others).
00445   // Subclasses can oberride this method to process their own events, but
00446   // should call the superclass too.
00447   virtual void ProcessCallbackCommandEvents(
00448     vtkObject *caller, unsigned long event, void *calldata);
00449   
00450 private:
00451 
00452   // Description:
00453   // Some constants
00454   char *PrintOptionsMenuLabel;
00455   char *FileMenuLabel;
00456   char *FileCloseMenuLabel;
00457   char *FileExitMenuLabel;
00458   char *OpenRecentFileMenuLabel;
00459   char *EditMenuLabel;
00460   char *ViewMenuLabel;
00461   char *WindowMenuLabel;
00462   char *HelpMenuLabel;
00463   char *HelpTopicsMenuLabel;
00464   char *HelpKeyBindingsMenuLabel;
00465   char *HelpAboutMenuLabel;
00466   char *HelpCheckForUpdatesMenuLabel;
00467   char *ToolbarsVisibilityMenuLabel;
00468   char *WindowGeometryRegKey;
00469   char *DefaultGeometry;
00470 
00471   vtkKWWindowBase(const vtkKWWindowBase&); // Not implemented
00472   void operator=(const vtkKWWindowBase&); // Not implemented
00473 };
00474 
00475 #endif

Generated on Sat Dec 11 2010 02:08:01 for KWWidgets by  doxygen 1.7.2