00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWWindow.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 vtkKWWindow - a window superclass which holds splittable panels. 00015 // .SECTION Description 00016 // This class represents a top level window with a menu bar, a status 00017 // line (as per vtkKWWindowBase) and user interface panels that can be 00018 // resized and/or collapsed. 00019 // 00020 // Here is the layout of the whole window. Remember that the superclass 00021 // "view frame" (as returned by GetViewFrame()) was the whole usable space 00022 // between the menu bar on top (and eventually toolbars) and the status bar 00023 // at the bottom. 00024 // 00025 // This old "view frame" is now further divided horizontally into two parts 00026 // by a split frame instance. 00027 // The first part (on the left) is called the "main panel" area, and 00028 // can be hidden or shown using the SetMainPanelVisibility() method. 00029 // A convenience method GetMainPanelFrame() can be used to retrieve that 00030 // "main panel area" frame, even if it is currently entirely allocated to 00031 // the main notebook, MainNotebook. 00032 // The MainNotebook element is packed in the main panel and is used to 00033 // display interface elements organized as *pages* inside *panels*. 00034 // 00035 // Note that the proper way to do so is to create "user interface panels" 00036 // (UIP, subclasses of vtkKWUserInterfacePanel), and set their 00037 // "user interface manager" (UIM) to the main user interface manager, as 00038 // returned by GetMainUserInterfaceManager(). Since the main UIM is itself 00039 // attached to the main notebook, it will display the UIP automatically inside 00040 // the notebook and take care of showing/raising/hiding the pages properly. 00041 // The ShowMainUserInterface() method can be used to show a main interface 00042 // panel given its name. The name is typically the string returned by the 00043 // GetName() method of a vtkKWUserInterfacePanel (UIP). 00044 // The ShowMainUserInterface() method will query the main UIM to check if it 00045 // is indeed managing a panel (UIP) with that name, and show/raise that UIP 00046 // accordingly. If you do not know which user interface manager is used 00047 // by the panel, just call Show() or Raise() on the panel itself ! 00048 // 00049 // Note that by following such framework, a subclass will be free of using 00050 // a totally different type of UIM, while the UIP implementation and 00051 // manipulation will remain exactly the same. One just has to focus on creating 00052 // simple panels to pack user interface components, and the UIM will be 00053 // responsible for mapping them into a higher-level interface, like a notebook. 00054 // It will also take care of show/hiding conflicting interfaces, provide 00055 // some cross-panels features like drag and drop, serialize the UI state, etc. 00056 // 00057 // In the same way, the right part of the MainSplitFrame (i.e., not the main 00058 // panel itself, but the remaining space on the right side of the separator) 00059 // is also divided vertically into two parts by a split frame instance. 00060 // The same methods as described above are available for this secondary 00061 // subdivision, i.e. SetSecondaryPanelVisibility() can be 00062 // used to show/hide the secondary panel, GetSecondaryPanelFrame() can be 00063 // used to retrieve the secondary panel frame, a SecondaryNotebook is 00064 // packed inside the secondary panel, and GetMainUserInterfaceManager() can 00065 // be used to retrieve the corresponding UIM. 00066 // 00067 // Below the SecondarySplitFrame is a second toolbar set (SecondaryToolbarSet) 00068 // available for extra toolbars. 00069 // 00070 // The space available for "viewing", or packing 3D scenes, is returned by 00071 // GetViewFrame(). Under the hood, a third user interface manager, the 00072 // ViewUserInterfaceManager is coupled to a ViewNotebook and packed inside 00073 // the top part of the secondary split frame (i.e. the large part that is 00074 // not considered a user interface panel). A default page is added to that 00075 // notebook to provide the frame for GetViewFrame(). Since there is only 00076 // one page, the tab is not shown by default, leaving all the notebook 00077 // space available for viewing. This notebook and its user interface manager 00078 // are likely not be manipulated as often as the other panels and UIM, but 00079 // can be used to provide multiple "views" for example. 00080 // As a convenience, a GetViewPanelFrame() method returns the parent 00081 // of the notebook, i.e. the space into which the notebook was packed, so 00082 // that other elements can be packed below or before the notebook itself. 00083 // 00084 // A fourth user interface manager is used to display and group all 00085 // panels related to application settings (i.e. "Preferences"). It is not 00086 // part of the layout as it will popup as a dialog instead. Note that 00087 // the panels do not have to bother about that, the manager will parse 00088 // each panel and create the dialog accordingly. If you have more application 00089 // settings parameters, just create your own panels and set their UIM to 00090 // the ApplicationSettingsUserInterfaceManager. 00091 // 00092 // This describes the default layout so far, where the secondary panel is 00093 // located below the view frame. The PanelLayout ivar can be set 00094 // to change this layout to different configurations where: 00095 // - the secondary panel is below the main panel. 00096 // - the secondary panel is below both main and the view panel. 00097 // Note that there is no accessor to get the split frame objects, since 00098 // you should not rely on them to parent your widgets. Use the panel 00099 // frame accessors instead, they will return the correct value even if 00100 // the layout changes (i.e., GetMainPanelFrame(), GetSecondaryPanelFrame(), 00101 // GetViewPanelFrame()). 00102 // 00103 // MB: GetMenu() (see vtkKWTopLevel) 00104 // MTBS: GetMainToolbarSet() (see superclass) 00105 // MPF: GetMainPanelFrame() 00106 // MNB: MainNotebook 00107 // VNB: ViewNotebook 00108 // VPF: GetViewPanelFrame() 00109 // VF: GetViewFrame() (first page of the VNB) 00110 // SPF: GetSecondaryPanelFrame() 00111 // SNB: SecondaryNotebook 00112 // STBS: GetSecondaryToolbarSet() 00113 // SF: GetStatusFrame() (see superclass) 00114 // 00115 // @verbatim 00116 // +----------------------+ +----------------------+ +----------------------+ 00117 // | MB | | MB | | MB | 00118 // +----------------------+ +----------------------+ +----------------------+ 00119 // | MTBS | | MTBS | | MTBS | 00120 // +--------+-------------+ +--------+-------------+ +--------+-------------+ 00121 // |+--+ MPF|+--+ VPF | |+--+ MPF|+--+ VPF | |+--+ MPF|+--+ VPF | 00122 // || +---+|| +--------+| || +---+|| +--------+| || +---+|| +--------+| 00123 // || ||| || || ||| || || ||| || 00124 // || ||| VNB (VF) || || ||| || || ||| || 00125 // || ||| || || ||| || || ||| VNB (VF) || 00126 // || ||| || || MNB ||| || || MNB ||| || 00127 // || ||+-----------+| || ||| || || ||| || 00128 // || MNB |+-------------+ |+------+|| VNB (VF) || || ||| || 00129 // || ||+--+ SPF | +--------+| || || ||+-----------+| 00130 // || ||| +--------+| |+--+ SPF|| || |+------+| STBS | 00131 // || ||| || || +---+|| || +--------+-------------+ 00132 // || ||| SNB || || ||| || |+--+ SPF | 00133 // || ||| || || ||| || || +-----------------+| 00134 // || ||| || || SNB ||| || || SNB || 00135 // || ||+-----------+| || ||+-----------+| || || 00136 // |+------+| STBS | |+------+| STBS | |+--------------------+| 00137 // +--------+-------------+ +--------+-------------+ +----------------------+ 00138 // | SF | | SF | | SF | 00139 // +----------------------+ +----------------------+ +----------------------+ 00140 // Secondary below View Secondary below Main Secondary below Both 00141 // @endverbatim 00142 00143 #ifndef __vtkKWWindow_h 00144 #define __vtkKWWindow_h 00145 00146 #include "vtkKWWindowBase.h" 00147 00148 class vtkKWFrame; 00149 class vtkKWNotebook; 00150 class vtkKWSplitFrame; 00151 class vtkKWToolbar; 00152 class vtkKWUserInterfaceManager; 00153 class vtkKWUserInterfaceManagerNotebook; 00154 class vtkKWUserInterfaceManagerDialog; 00155 class vtkKWApplicationSettingsInterface; 00156 class vtkKWUserInterfacePanel; 00157 00158 class KWWidgets_EXPORT vtkKWWindow : public vtkKWWindowBase 00159 { 00160 public: 00161 00162 static vtkKWWindow* New(); 00163 vtkTypeRevisionMacro(vtkKWWindow,vtkKWWindowBase); 00164 void PrintSelf(ostream& os, vtkIndent indent); 00165 00166 // Description: 00167 // Main panel. 00168 // The whole layout of the window is described at length at the beginning 00169 // of this document. 00170 virtual vtkKWFrame* GetMainPanelFrame(); 00171 virtual int GetMainPanelVisibility(); 00172 virtual void SetMainPanelVisibility(int); 00173 vtkBooleanMacro(MainPanelVisibility, int ); 00174 virtual vtkKWNotebook* GetMainNotebook(); 00175 virtual int HasMainUserInterfaceManager(); 00176 virtual vtkKWUserInterfaceManager* GetMainUserInterfaceManager(); 00177 virtual void ShowMainUserInterface(const char *name); 00178 vtkGetObjectMacro(MainSplitFrame, vtkKWSplitFrame); 00179 00180 // Description: 00181 // Secondary panel. 00182 // The whole layout of the window is described at length at the beginning 00183 // of this document. 00184 virtual vtkKWFrame* GetSecondaryPanelFrame(); 00185 virtual int GetSecondaryPanelVisibility(); 00186 virtual void SetSecondaryPanelVisibility(int); 00187 vtkBooleanMacro(SecondaryPanelVisibility, int ); 00188 virtual vtkKWNotebook* GetSecondaryNotebook(); 00189 virtual int HasSecondaryUserInterfaceManager(); 00190 virtual vtkKWUserInterfaceManager* GetSecondaryUserInterfaceManager(); 00191 virtual void ShowSecondaryUserInterface(const char *name); 00192 vtkGetObjectMacro(SecondarySplitFrame, vtkKWSplitFrame); 00193 00194 // Description: 00195 // Set the panel layout type. 00196 // The whole layout of the window is described at length at the beginning 00197 // of this document. 00198 // IMPORTANT: this ivar has to be set before calling Create(), and can 00199 // not be changed afterwards. 00200 //BTX 00201 enum 00202 { 00203 PanelLayoutSecondaryBelowView = 0, 00204 PanelLayoutSecondaryBelowMain, 00205 PanelLayoutSecondaryBelowMainAndView 00206 }; 00207 //ETX 00208 vtkSetClampMacro(PanelLayout, int, 00209 vtkKWWindow::PanelLayoutSecondaryBelowView, 00210 vtkKWWindow::PanelLayoutSecondaryBelowMainAndView); 00211 vtkGetMacro(PanelLayout, int); 00212 virtual void SetPanelLayoutToSecondaryBelowView() 00213 { this->SetPanelLayout(vtkKWWindow::PanelLayoutSecondaryBelowView);}; 00214 virtual void SetPanelLayoutToSecondaryBelowMain() 00215 { this->SetPanelLayout(vtkKWWindow::PanelLayoutSecondaryBelowMain);}; 00216 virtual void SetPanelLayoutToSecondaryBelowMainAndView() 00217 {this->SetPanelLayout(vtkKWWindow::PanelLayoutSecondaryBelowMainAndView);}; 00218 00219 // Description: 00220 // Set the view panel position. Default is on the right of the window. 00221 // IMPORTANT: this ivar has to be set before calling Create(), and can 00222 // not be changed afterwards. 00223 //BTX 00224 enum 00225 { 00226 ViewPanelPositionLeft = 0, 00227 ViewPanelPositionRight 00228 }; 00229 //ETX 00230 virtual void SetViewPanelPosition(int); 00231 virtual int GetViewPanelPosition(); 00232 virtual void SetViewPanelPositionToLeft() 00233 { this->SetViewPanelPosition(vtkKWWindow::ViewPanelPositionLeft);}; 00234 virtual void SetViewPanelPositionToRight() 00235 { this->SetViewPanelPosition(vtkKWWindow::ViewPanelPositionRight);}; 00236 00237 // Description: 00238 // Get the frame available for "viewing". 00239 // Override the superclass to return a page in the notebook of the 00240 // view user interface manager (located in the first part of the 00241 // SecondarySplitFrame). 00242 // This method should be used instead of GetViewPanelFrame(), unless 00243 // you really need to have both multiple notebook pages and common UI 00244 // elements on top or below the notebook. 00245 // The rational here is that GetViewFrame() always return the frame that 00246 // can be used by users or developpers to add more "viewing" element (say, 00247 // renderwidgets, 3D scenes), without knowing about the current layout. 00248 virtual vtkKWFrame* GetViewFrame(); 00249 00250 // Description: 00251 // View panel. 00252 // The whole layout of the window is described at length at the beginning 00253 // of this document. 00254 // This panel is probably not going to be used much, by default it 00255 // creates a single page in the notebook, which frame is returned by 00256 // GetViewFrame(). The GetViewPanelFrame() method returns the parent of 00257 // the notebook, if one really need to pack something out of the 00258 // GetViewFrame(). 00259 virtual vtkKWNotebook* GetViewNotebook(); 00260 virtual int HasViewUserInterfaceManager(); 00261 virtual vtkKWUserInterfaceManager* GetViewUserInterfaceManager(); 00262 virtual void ShowViewUserInterface(const char *name); 00263 virtual vtkKWFrame* GetViewPanelFrame(); 00264 00265 // Description: 00266 // Get the secondary toolbar set. 00267 virtual vtkKWToolbarSet* GetSecondaryToolbarSet(); 00268 00269 // Description: 00270 // Set the status frame position. The default position is at the 00271 // bottom of the window, but this object can also be displayed 00272 // at the bottom of the main panel (MainPanel), at the bottom of 00273 // the secondary panel (SecondaryPanel) or at the bottom of the view panel 00274 // (ViewPanel). Note that if any of the above is used, the status bar 00275 // will actually be hidden if the corresponding panel visibility is changed, 00276 // since the status bar is actually packed in the panel frame itself. Set 00277 // the position to LeftOfDivider or RightOfDivider to place the status 00278 // bar out of the panel, but either of the left or the right of the 00279 // main vertical divider. 00280 //BTX 00281 enum 00282 { 00283 StatusFramePositionWindow = 0, 00284 StatusFramePositionMainPanel, 00285 StatusFramePositionSecondaryPanel, 00286 StatusFramePositionViewPanel, 00287 StatusFramePositionLeftOfDivider, 00288 StatusFramePositionRightOfDivider 00289 }; 00290 //ETX 00291 vtkGetMacro(StatusFramePosition, int); 00292 virtual void SetStatusFramePosition(int); 00293 virtual void SetStatusFramePositionToWindow() 00294 { this->SetStatusFramePosition( 00295 vtkKWWindow::StatusFramePositionWindow); }; 00296 virtual void SetStatusFramePositionToMainPanel() 00297 { this->SetStatusFramePosition( 00298 vtkKWWindow::StatusFramePositionMainPanel); }; 00299 virtual void SetStatusFramePositionToSecondaryPanel() 00300 { this->SetStatusFramePosition( 00301 vtkKWWindow::StatusFramePositionSecondaryPanel); }; 00302 virtual void SetStatusFramePositionToViewPanel() 00303 { this->SetStatusFramePosition( 00304 vtkKWWindow::StatusFramePositionViewPanel); }; 00305 virtual void SetStatusFramePositionToLeftOfDivider() 00306 { this->SetStatusFramePosition( 00307 vtkKWWindow::StatusFramePositionLeftOfDivider); }; 00308 virtual void SetStatusFramePositionToRightOfDivider() 00309 { this->SetStatusFramePosition( 00310 vtkKWWindow::StatusFramePositionRightOfDivider); }; 00311 00312 // Description: 00313 // Call render on all widgets and elements that support that functionality 00314 virtual void Render(); 00315 00316 // Description: 00317 // Get the Application Settings Interface as well as the Application 00318 // Settings User Interface Manager. 00319 virtual vtkKWUserInterfaceManager* GetApplicationSettingsUserInterfaceManager(); 00320 virtual void ShowApplicationSettingsUserInterface(const char *name); 00321 virtual vtkKWApplicationSettingsInterface *GetApplicationSettingsInterface(); 00322 00323 // Description: 00324 // Update the UI. This will call: 00325 // UpdateToolbarState 00326 // UpdateEnableState 00327 // UpdateMenuState 00328 // Update on all panels belonging to the UserInterfaceManager, if any 00329 virtual void Update(); 00330 00331 // Description: 00332 // Update the "enable" state of the object and its internal parts. 00333 // Depending on different Ivars (this->Enabled, the application's 00334 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00335 // and propagated to its internal parts/subwidgets. This will, for example, 00336 // enable/disable parts of the widget UI, enable/disable the visibility 00337 // of 3D widgets, etc. 00338 // Note: if you need to enable/disable a menu item conditionally in a 00339 // subclass, do it so by reimplementing UpdateMenuState(); do not forget to 00340 // call the parent class's UpdateMenuState() from the subclass as well. 00341 virtual void UpdateEnableState(); 00342 virtual void UpdateMenuState(); 00343 00344 // Description: 00345 // Update the toolbar state 00346 virtual void UpdateToolbarState(); 00347 00348 // Description: 00349 // Deallocate/delete/reparent some internal objects in order to solve 00350 // reference loops that would prevent this instance from being deleted. 00351 virtual void PrepareForDelete(); 00352 00353 // Description: 00354 // Callbacks. Internal, do not use. 00355 virtual void MainPanelVisibilityCallback(); 00356 virtual void SecondaryPanelVisibilityCallback(); 00357 virtual void PrintSettingsCallback(); 00358 virtual void ToolbarVisibilityChangedCallback(vtkKWToolbar*); 00359 virtual void NumberOfToolbarsChangedCallback(); 00360 00361 // Description: 00362 // Some constants 00363 vtkGetStringMacro(MainPanelSizeRegKey); 00364 vtkGetStringMacro(MainPanelVisibilityRegKey); 00365 vtkGetStringMacro(MainPanelVisibilityKeyAccelerator); 00366 vtkGetStringMacro(HideMainPanelMenuLabel); 00367 vtkGetStringMacro(ShowMainPanelMenuLabel); 00368 vtkGetStringMacro(SecondaryPanelSizeRegKey); 00369 vtkGetStringMacro(SecondaryPanelVisibilityRegKey); 00370 vtkGetStringMacro(SecondaryPanelVisibilityKeyAccelerator); 00371 vtkGetStringMacro(HideSecondaryPanelMenuLabel); 00372 vtkGetStringMacro(ShowSecondaryPanelMenuLabel); 00373 vtkGetStringMacro(DefaultViewPanelName); 00374 vtkGetStringMacro(TclInteractorMenuLabel); 00375 vtkGetStringMacro(ViewPanelPositionRegKey); 00376 vtkGetStringMacro(LogDialogMenuLabel); 00377 00378 // Description: 00379 // Add all the default observers needed by that object, or remove 00380 // all the observers that were added through AddCallbackCommandObserver. 00381 // Subclasses can override these methods to add/remove their own default 00382 // observers, but should call the superclass too. 00383 virtual void AddCallbackCommandObservers(); 00384 virtual void RemoveCallbackCommandObservers(); 00385 00386 protected: 00387 vtkKWWindow(); 00388 ~vtkKWWindow(); 00389 00390 // Description: 00391 // Create the widget. 00392 virtual void CreateWidget(); 00393 00394 // Description: 00395 // Save/Restore window geometry 00396 virtual void SaveWindowGeometryToRegistry(); 00397 virtual void RestoreWindowGeometryFromRegistry(); 00398 00399 // Description: 00400 // Show a main or secondary user interface panel. 00401 // The ShowMainUserInterface() method will 00402 // query the main UserInterfaceManager (UIM) to check if it is indeed 00403 // managing the UIP, and show/raise that UIP accordingly. 00404 // The ShowSecondaryUserInterface will do the same on the secondary UIM. 00405 // The ShowViewUserInterface will do the same on the view UIM. 00406 // The ShowApplicationSettingsUserInterface will do the same on the app 00407 // settings UIM. 00408 virtual void ShowMainUserInterface(vtkKWUserInterfacePanel *panel); 00409 virtual void ShowSecondaryUserInterface(vtkKWUserInterfacePanel *panel); 00410 virtual void ShowViewUserInterface(vtkKWUserInterfacePanel *panel); 00411 virtual void ShowApplicationSettingsUserInterface(vtkKWUserInterfacePanel *panel); 00412 00413 // Description: 00414 // Pack/repack the UI 00415 virtual void Pack(); 00416 00417 int PanelLayout; 00418 00419 vtkKWSplitFrame *MainSplitFrame; 00420 00421 vtkKWSplitFrame *SecondarySplitFrame; 00422 00423 vtkKWApplicationSettingsInterface *ApplicationSettingsInterface; 00424 00425 int StatusFramePosition; 00426 00427 // Description: 00428 // Some constants 00429 vtkSetStringMacro(MainPanelSizeRegKey); 00430 vtkSetStringMacro(MainPanelVisibilityRegKey); 00431 vtkSetStringMacro(MainPanelVisibilityKeyAccelerator); 00432 vtkSetStringMacro(HideMainPanelMenuLabel); 00433 vtkSetStringMacro(ShowMainPanelMenuLabel); 00434 vtkSetStringMacro(SecondaryPanelSizeRegKey); 00435 vtkSetStringMacro(SecondaryPanelVisibilityRegKey); 00436 vtkSetStringMacro(SecondaryPanelVisibilityKeyAccelerator); 00437 vtkSetStringMacro(HideSecondaryPanelMenuLabel); 00438 vtkSetStringMacro(ShowSecondaryPanelMenuLabel); 00439 vtkSetStringMacro(DefaultViewPanelName); 00440 vtkSetStringMacro(TclInteractorMenuLabel); 00441 vtkSetStringMacro(ViewPanelPositionRegKey); 00442 vtkSetStringMacro(LogDialogMenuLabel); 00443 00444 // Description: 00445 // Processes the events that are passed through CallbackCommand (or others). 00446 // Subclasses can oberride this method to process their own events, but 00447 // should call the superclass too. 00448 virtual void ProcessCallbackCommandEvents( 00449 vtkObject *caller, unsigned long event, void *calldata); 00450 00451 // Description: 00452 // Populate the menus. 00453 // Note: if you need to enable/disable a menu item conditionally in a 00454 // subclass, do it so by reimplementing UpdateMenuState(); do not forget to 00455 // call the parent class's UpdateMenuState() from the subclass as well. 00456 virtual void PopulateWindowMenu(); 00457 virtual void PopulateViewMenu(); 00458 00459 private: 00460 00461 vtkKWNotebook *MainNotebook; 00462 vtkKWNotebook *SecondaryNotebook; 00463 vtkKWNotebook *ViewNotebook; 00464 00465 vtkKWToolbarSet *SecondaryToolbarSet; 00466 00467 vtkKWUserInterfaceManagerNotebook *MainUserInterfaceManager; 00468 vtkKWUserInterfaceManagerNotebook *SecondaryUserInterfaceManager; 00469 vtkKWUserInterfaceManagerNotebook *ViewUserInterfaceManager; 00470 00471 vtkKWUserInterfaceManagerDialog *ApplicationSettingsUserInterfaceManager; 00472 00473 vtkKWWindow(const vtkKWWindow&); // Not implemented 00474 void operator=(const vtkKWWindow&); // Not implemented 00475 00476 // Description: 00477 // Some constants 00478 char *MainPanelSizeRegKey; 00479 char *MainPanelVisibilityRegKey; 00480 char *MainPanelVisibilityKeyAccelerator; 00481 char *HideMainPanelMenuLabel; 00482 char *ShowMainPanelMenuLabel; 00483 char *SecondaryPanelSizeRegKey; 00484 char *SecondaryPanelVisibilityRegKey; 00485 char *SecondaryPanelVisibilityKeyAccelerator; 00486 char *HideSecondaryPanelMenuLabel; 00487 char *ShowSecondaryPanelMenuLabel; 00488 char *DefaultViewPanelName; 00489 char *TclInteractorMenuLabel; 00490 char *ViewPanelPositionRegKey; 00491 char *LogDialogMenuLabel; 00492 }; 00493 00494 #endif 00495