KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWUserInterfacePanel.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 vtkKWUserInterfacePanel - a user interface panel. 00015 // .SECTION Description 00016 // This class is used to abstract the way an interface "panel" can be 00017 // subdivided into "pages" (i.e. "sections"). It allows specific GUI parts of 00018 // an application to be encapsulated inside independent panels. Panels are 00019 // then associated to a user interface manager (see vtkKWUserInterfaceManager) 00020 // which is responsible for grouping them inside a widget and handling user 00021 // interaction so that panels and their pages can be selected in more or less 00022 // fancy ways. If the user interface manager uses a notebook under the hood, 00023 // then this class is likely to receive a notebook's page when it will request 00024 // for a page from the manager. If the manager chooses for a flat GUI, then 00025 // this class is likely to receive a simple frame that will be stacked by the 00026 // manager on top of other pages. 00027 // This class is not a widget, it can not be mapped, the manager is the 00028 // place where a concrete widget is set and used as the root of all panels (see 00029 // vtkKWUserInterfaceManagerNotebook for example). What you need to do 00030 // is to set the UserInterfaceManager's Ivar to a manager, and the rest should 00031 // be taken care of (i.e. the panel is automatically added to the manager, 00032 // and if the panel is not created the first time one if its pages is shown or 00033 // raised, the panel's Create() method is automatically called by the manager, 00034 // allowing the creation of the panel to be delayed until it is really needed). 00035 // You should not use the manager's API to add the panel, add or raise pages, 00036 // etc, just use this panel's API and calls will be propagated to the 00037 // right manager with the proper arguments). 00038 // .SECTION See Also 00039 // vtkKWUserInterfaceManager vtkKWUserInterfaceManagerNotebook 00040 00041 #ifndef __vtkKWUserInterfacePanel_h 00042 #define __vtkKWUserInterfacePanel_h 00043 00044 #include "vtkKWObject.h" 00045 00046 class vtkKWIcon; 00047 class vtkKWUserInterfaceManager; 00048 class vtkKWWidget; 00049 00050 class KWWidgets_EXPORT vtkKWUserInterfacePanel : public vtkKWObject 00051 { 00052 public: 00053 static vtkKWUserInterfacePanel* New(); 00054 vtkTypeRevisionMacro(vtkKWUserInterfacePanel,vtkKWObject); 00055 void PrintSelf(ostream& os, vtkIndent indent); 00056 00057 // Description: 00058 // Set the user interface manager. This automatically adds the 00059 // panel to the manager. If you want to remove this panel from the manager, 00060 // set the manager to NULL (it is done automatically by the destructor), 00061 // or call RemovePanel from the manager so that you can add it back later. 00062 // Note that ownership is transferred to the manager by incrementing 00063 // (and decrementing later on) the ref count of the panel in 00064 // vtkKWUserInterfaceManager's AddPanel and RemovePanel methods. 00065 virtual void SetUserInterfaceManager(vtkKWUserInterfaceManager*); 00066 vtkGetObjectMacro(UserInterfaceManager, vtkKWUserInterfaceManager); 00067 00068 // Description: 00069 // Set the panel name. Can be used to add the panel to a menu, etc. 00070 vtkGetStringMacro(Name); 00071 vtkSetStringMacro(Name); 00072 00073 // Description: 00074 // Create the interface objects. Note that if the panel is not created 00075 // the first time one if its pages is shown or raised, this method is 00076 // automatically called by the manager, allowing the creation of the 00077 // panel to be delayed until it is really needed. In the same way, if 00078 // the user interface manager has not been created at this point, it 00079 // is automatically created now (see vtkKWUserInterfaceManager::Create()). 00080 virtual void Create(); 00081 virtual int IsCreated(); 00082 00083 // Description: 00084 // Enable/Disable this panel. This should propagate SetEnabled() calls to the 00085 // internal widgets. 00086 virtual void SetEnabled(int); 00087 vtkBooleanMacro(Enabled, int); 00088 vtkGetMacro(Enabled, int); 00089 00090 // Description: 00091 // Add/remove a page to/from the panel (this will, in turn, instructs the 00092 // manager to reserve or remove a page for this given panel). 00093 // balloon specifies the balloon help for that page, icon is an optional 00094 // icon in case it is supported by the manager later on. 00095 // Return a unique positive ID for the page that was reserved/removed, 00096 // or < 0 on error. 00097 virtual int AddPage(const char *title, 00098 const char *balloon = 0, 00099 vtkKWIcon *icon = 0); 00100 virtual int RemovePage(const char *title); 00101 00102 // Description: 00103 // Set a page's title, balloon help and icon. 00104 virtual void SetPageTitle(int id, const char *title); 00105 virtual void SetPageBalloonHelpString(int id, const char *str); 00106 virtual void SetPageIcon(int id, vtkKWIcon *icon); 00107 virtual void SetPageIconToPredefinedIcon(int id, int icon_index); 00108 00109 // Description: 00110 // Retrieve the widget corresponding to a given page added to the panel. 00111 // This can be done through the unique page ID, or using the page title. 00112 // The user UI components should be inserted into this widget. 00113 // Return NULL on error. 00114 virtual vtkKWWidget *GetPageWidget(int id); 00115 virtual vtkKWWidget *GetPageWidget(const char *title); 00116 00117 // Description: 00118 // Retrieve the parent widget of the pages associated to the panel. It is 00119 // the unique widget that is common to all pages in the chain of parents. 00120 virtual vtkKWWidget *GetPagesParentWidget(); 00121 00122 // Description: 00123 // Raise a page added to the panel. This can be done through the unique 00124 // page ID, or using the page title. Note that if the panel has not been 00125 // created at this point, the manager will call the panel's Create() 00126 // method automatically, allowing the creation of the panel to be delayed 00127 // until it is really needed. 00128 virtual void RaisePage(int id); 00129 virtual void RaisePage(const char *title); 00130 00131 // Description: 00132 // Show a panel. It will make sure the pages added to this panel are shown. 00133 // Note that if the panel has not been created at this point, the manager 00134 // will call the panel's Create() method automatically, allowing the 00135 // creation of the panel to be delayed until it is really needed. 00136 // Raise() behaves like Show(), but it will also instruct the manager to 00137 // bring up the first page of the panel to the front. 00138 // IsVisible() will check if the pages of this panel are visible/shown. 00139 // Return 1 on success, 0 on error. 00140 virtual int Show(); 00141 virtual int Raise(); 00142 virtual int IsVisible(); 00143 00144 // Description: 00145 // Refresh the interface. 00146 virtual void Update(); 00147 00148 // Description: 00149 // Update the "enable" state of the object and its internal parts. 00150 // Depending on different Ivars (this->Enabled, the application's 00151 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00152 // and propagated to its internal parts/subwidgets. This will, for example, 00153 // enable/disable parts of the widget UI, enable/disable the visibility 00154 // of 3D widgets, etc. 00155 virtual void UpdateEnableState() {}; 00156 00157 protected: 00158 vtkKWUserInterfacePanel(); 00159 ~vtkKWUserInterfacePanel(); 00160 00161 vtkKWUserInterfaceManager *UserInterfaceManager; 00162 00163 char *Name; 00164 00165 private: 00166 00167 int Enabled; 00168 int PanelIsCreated; 00169 00170 vtkKWUserInterfacePanel(const vtkKWUserInterfacePanel&); // Not implemented 00171 void operator=(const vtkKWUserInterfacePanel&); // Not Implemented 00172 }; 00173 00174 #endif 00175