KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWToolbar.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 vtkKWToolbar - a frame that holds tool buttons 00015 // .SECTION Description 00016 // Simply a frame to hold a bunch of tools. It uses bindings to control 00017 // the height of the frame. 00018 // In the future we could use the object to move toolbars groups around. 00019 00020 #ifndef __vtkKWToolbar_h 00021 #define __vtkKWToolbar_h 00022 00023 #include "vtkKWCompositeWidget.h" 00024 00025 class vtkKWFrame; 00026 class vtkKWRadioButton; 00027 class vtkKWToolbarInternals; 00028 00029 class KWWidgets_EXPORT vtkKWToolbar : public vtkKWCompositeWidget 00030 { 00031 public: 00032 static vtkKWToolbar* New(); 00033 vtkTypeRevisionMacro(vtkKWToolbar, vtkKWCompositeWidget); 00034 void PrintSelf(ostream& os, vtkIndent indent); 00035 00036 // Description: 00037 // Returns the main frame of the toolbar. 00038 // This should be used as the parent of all the widgets in the toolbar. 00039 vtkGetObjectMacro(Frame, vtkKWFrame); 00040 00041 // Description: 00042 // Determines whether the toolbar is resizable. 00043 virtual void SetResizable(int); 00044 vtkGetMacro(Resizable, int); 00045 vtkBooleanMacro(Resizable, int); 00046 00047 // Description: 00048 // Set/Get the name of the toolbar. This is optional but certainly 00049 // useful if this toolbar is meant to be added to a vtkKWToolbarSet 00050 vtkGetStringMacro(Name); 00051 vtkSetStringMacro(Name); 00052 00053 // Description: 00054 // Add a widget to the toolbar, insert a widget before 'location' (or at 00055 // beginning of list if 'location' is not found) 00056 virtual void AddWidget(vtkKWWidget* widget); 00057 virtual void InsertWidget(vtkKWWidget* location, vtkKWWidget* widget); 00058 00059 // Description: 00060 // Add a separator to the toolbar, insert a separator before 'location' (or at 00061 // beginning of list if 'location' is not found) 00062 virtual void AddSeparator(); 00063 virtual void InsertSeparator(vtkKWWidget* location); 00064 00065 // Description: 00066 // Query widgets 00067 virtual int HasWidget(vtkKWWidget* widget); 00068 virtual int GetNumberOfWidgets(); 00069 00070 // Description: 00071 // Remove a widget (or all) from the toolbar 00072 virtual void RemoveWidget(vtkKWWidget* widget); 00073 virtual void RemoveAllWidgets(); 00074 00075 // Description: 00076 // Retrieve a widget given its name. The name is looked up in common Tk 00077 // options like -label, -text, -image, -selectimage 00078 virtual vtkKWWidget* GetWidget(const char *name); 00079 00080 // Description: 00081 // Retrieve the nth- widget 00082 virtual vtkKWWidget* GetNthWidget(int rank); 00083 00084 // Description: 00085 // Set/Get widget visibility 00086 virtual void SetWidgetVisibility(vtkKWWidget *widget, int val); 00087 virtual int GetWidgetVisibility(vtkKWWidget *widget); 00088 00089 // Description: 00090 // Create and add a specific type of widget. 00091 // Note: for radiobutton, the variable_name should be the same for 00092 // each radiobutton in the set of radiobuttons. 00093 // for checkbutton, this is only optional (can be NULL) 00094 vtkKWWidget* AddRadioButtonImage(int value, 00095 const char *image_name, 00096 const char *select_image_name, 00097 const char *variable_name, 00098 vtkObject *object, 00099 const char *method, 00100 const char *help = 0); 00101 vtkKWWidget* AddCheckButtonImage(const char *image_name, 00102 const char *select_image_name, 00103 const char *variable_name, 00104 vtkObject *object, 00105 const char *method, 00106 const char *help = 0); 00107 00108 // Description: 00109 // Update/refresh the widgets layout/aspect 00110 virtual void UpdateWidgets(); 00111 00112 // Description: 00113 // Update/refresh the toolbar layout/aspect (does not include the widgets) 00114 virtual void Update(); 00115 00116 // Description: 00117 // Set/Get the aspect of the toolbar (flat or 3D GUI style, or unchanged) 00118 // The static GlobalToolbarAspect member can be set so that all toolbars 00119 // are rendered using the same aspect. 00120 //BTX 00121 enum 00122 { 00123 ToolbarAspectRelief = 0, 00124 ToolbarAspectFlat = 1, 00125 ToolbarAspectUnChanged 00126 }; 00127 //ETX 00128 vtkGetMacro(ToolbarAspect, int); 00129 virtual void SetToolbarAspect(int); 00130 virtual void SetToolbarAspectToFlat(); 00131 virtual void SetToolbarAspectToRelief(); 00132 virtual void SetToolbarAspectToUnChanged(); 00133 static int GetGlobalToolbarAspect(); 00134 static void SetGlobalToolbarAspect(int val); 00135 static void SetGlobalToolbarAspectToFlat(); 00136 static void SetGlobalToolbarAspectToRelief(); 00137 static void SetGlobalToolbarAspectToUnChanged(); 00138 00139 // Description: 00140 // Set/Get the aspect of the widgets (flat, 3D GUI style, or unchanged) 00141 // The static GlobalWidgetsAspect member can be set so that all widgets 00142 // are rendered using the same aspect. 00143 //BTX 00144 enum 00145 { 00146 WidgetsAspectRelief = 0, 00147 WidgetsAspectFlat = 1, 00148 WidgetsAspectUnChanged 00149 }; 00150 //ETX 00151 vtkGetMacro(WidgetsAspect, int); 00152 virtual void SetWidgetsAspect(int); 00153 virtual void SetWidgetsAspectToFlat(); 00154 virtual void SetWidgetsAspectToRelief(); 00155 virtual void SetWidgetsAspectToUnChanged(); 00156 static int GetGlobalWidgetsAspect(); 00157 static void SetGlobalWidgetsAspect(int val); 00158 static void SetGlobalWidgetsAspectToFlat(); 00159 static void SetGlobalWidgetsAspectToRelief(); 00160 static void SetGlobalWidgetsAspectToUnChanged(); 00161 00162 // Description: 00163 // Set/Get the padding that will be applied around each widget. 00164 // (default to 0 on Windows, 1 otherwise). 00165 virtual void SetWidgetsPadX(int); 00166 vtkGetMacro(WidgetsPadX, int); 00167 virtual void SetWidgetsPadY(int); 00168 vtkGetMacro(WidgetsPadY, int); 00169 00170 // Description: 00171 // Set/Get the padding that will be applied inside each widget. 00172 // (default to 0 on Windows, 1 otherwise). 00173 virtual void SetWidgetsInternalPadX(int); 00174 vtkGetMacro(WidgetsInternalPadX, int); 00175 virtual void SetWidgetsInternalPadY(int); 00176 vtkGetMacro(WidgetsInternalPadY, int); 00177 00178 // Description: 00179 // Set/Get the additional internal padding that will be applied around 00180 // each widget when WidgetsAspect is On (default to 1). 00181 virtual void SetWidgetsFlatAdditionalPadX(int); 00182 vtkGetMacro(WidgetsFlatAdditionalPadX, int); 00183 virtual void SetWidgetsFlatAdditionalPadY(int); 00184 vtkGetMacro(WidgetsFlatAdditionalPadY, int); 00185 00186 // Description: 00187 // Set/Get the additional internal padding that will be applied inside 00188 // each widget when WidgetsAspect is On (default to 1). 00189 virtual void SetWidgetsFlatAdditionalInternalPadX(int); 00190 vtkGetMacro(WidgetsFlatAdditionalInternalPadX, int); 00191 virtual void SetWidgetsFlatAdditionalInternalPadY(int); 00192 vtkGetMacro(WidgetsFlatAdditionalInternalPadY, int); 00193 00194 // Description: 00195 // Schedule the widget to resize itself, or resize it right away 00196 virtual void ScheduleResize(); 00197 virtual void Resize(); 00198 00199 // Description: 00200 // Update the "enable" state of the object and its internal parts. 00201 // Depending on different Ivars (Enabled, the application's 00202 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00203 // and propagated to its internal parts subwidgets. This will, for example, 00204 // enable disable parts of the widget UI, enable disable the visibility 00205 // of 3D widgets, etc. 00206 virtual void UpdateEnableState(); 00207 00208 // Description: 00209 // Some constants 00210 //BTX 00211 static const char *ToolbarAspectRegKey; 00212 static const char *WidgetsAspectRegKey; 00213 //ETX 00214 00215 protected: 00216 vtkKWToolbar(); 00217 ~vtkKWToolbar(); 00218 00219 // Description: 00220 // Create the widget. 00221 virtual void CreateWidget(); 00222 00223 int Expanding; 00224 00225 vtkKWFrame *Frame; 00226 vtkKWFrame *Handle; 00227 00228 void ConstrainWidgetsLayout(); 00229 void UpdateWidgetsLayout(); 00230 void UpdateWidgetsAspect(); 00231 void UpdateToolbarFrameAspect(); 00232 00233 //BTX 00234 00235 // PIMPL Encapsulation for STL containers 00236 00237 vtkKWToolbarInternals *Internals; 00238 00239 //ETX 00240 00241 int WidgetsPadX; 00242 int WidgetsPadY; 00243 int WidgetsFlatAdditionalPadX; 00244 int WidgetsFlatAdditionalPadY; 00245 00246 int WidgetsInternalPadX; 00247 int WidgetsInternalPadY; 00248 int WidgetsFlatAdditionalInternalPadX; 00249 int WidgetsFlatAdditionalInternalPadY; 00250 00251 int ToolbarAspect; 00252 int WidgetsAspect; 00253 int Resizable; 00254 00255 vtkKWRadioButton *DefaultOptionsWidget; 00256 00257 char *Name; 00258 00259 // Description: 00260 // Bind/Unbind events. 00261 virtual void Bind(); 00262 virtual void UnBind(); 00263 00264 private: 00265 vtkKWToolbar(const vtkKWToolbar&); // Not implemented 00266 void operator=(const vtkKWToolbar&); // Not implemented 00267 }; 00268 00269 00270 #endif 00271 00272 00273