KWWidgets
vtkKWToolbar.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWToolbar.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 vtkKWToolbar - a frame that holds tool buttons
15 // .SECTION Description
16 // Simply a frame to hold a bunch of tools. It uses bindings to control
17 // the height of the frame.
18 // In the future we could use the object to move toolbars groups around.
19 
20 #ifndef __vtkKWToolbar_h
21 #define __vtkKWToolbar_h
22 
23 #include "vtkKWCompositeWidget.h"
24 
25 class vtkKWFrame;
26 class vtkKWRadioButton;
27 class vtkKWToolbarInternals;
28 
30 {
31 public:
32  static vtkKWToolbar* New();
33  vtkTypeRevisionMacro(vtkKWToolbar, vtkKWCompositeWidget);
34  void PrintSelf(ostream& os, vtkIndent indent);
35 
36  // Description:
37  // Returns the main frame of the toolbar.
38  // This should be used as the parent of all the widgets in the toolbar.
39  vtkGetObjectMacro(Frame, vtkKWFrame);
40 
41  // Description:
42  // Determines whether the toolbar is resizable.
43  virtual void SetResizable(int);
44  vtkGetMacro(Resizable, int);
45  vtkBooleanMacro(Resizable, int);
46 
47  // Description:
48  // Set/Get the name of the toolbar. This is optional but certainly
49  // useful if this toolbar is meant to be added to a vtkKWToolbarSet
50  vtkGetStringMacro(Name);
51  vtkSetStringMacro(Name);
52 
53  // Description:
54  // Add a widget to the toolbar, insert a widget before 'location' (or at
55  // beginning of list if 'location' is not found)
56  virtual void AddWidget(vtkKWWidget* widget);
57  virtual void InsertWidget(vtkKWWidget* location, vtkKWWidget* widget);
58 
59  // Description:
60  // Add a separator to the toolbar, insert a separator before 'location' (or at
61  // beginning of list if 'location' is not found)
62  virtual void AddSeparator();
63  virtual void InsertSeparator(vtkKWWidget* location);
64 
65  // Description:
66  // Query widgets
67  virtual int HasWidget(vtkKWWidget* widget);
68  virtual int GetNumberOfWidgets();
69 
70  // Description:
71  // Remove a widget (or all) from the toolbar
72  virtual void RemoveWidget(vtkKWWidget* widget);
73  virtual void RemoveAllWidgets();
74 
75  // Description:
76  // Retrieve a widget given its name. The name is looked up in common Tk
77  // options like -label, -text, -image, -selectimage
78  virtual vtkKWWidget* GetWidget(const char *name);
79 
80  // Description:
81  // Retrieve the nth- widget
82  virtual vtkKWWidget* GetNthWidget(int rank);
83 
84  // Description:
85  // Set/Get widget visibility
86  virtual void SetWidgetVisibility(vtkKWWidget *widget, int val);
87  virtual int GetWidgetVisibility(vtkKWWidget *widget);
88 
89  // Description:
90  // Create and add a specific type of widget.
91  // Note: for radiobutton, the variable_name should be the same for
92  // each radiobutton in the set of radiobuttons.
93  // for checkbutton, this is only optional (can be NULL)
94  vtkKWWidget* AddRadioButtonImage(int value,
95  const char *image_name,
96  const char *select_image_name,
97  const char *variable_name,
98  vtkObject *object,
99  const char *method,
100  const char *help = 0);
101  vtkKWWidget* AddCheckButtonImage(const char *image_name,
102  const char *select_image_name,
103  const char *variable_name,
104  vtkObject *object,
105  const char *method,
106  const char *help = 0);
107 
108  // Description:
109  // Update/refresh the widgets layout/aspect
110  virtual void UpdateWidgets();
111 
112  // Description:
113  // Update/refresh the toolbar layout/aspect (does not include the widgets)
114  virtual void Update();
115 
116  // Description:
117  // Set/Get the aspect of the toolbar (flat or 3D GUI style, or unchanged)
118  // The static GlobalToolbarAspect member can be set so that all toolbars
119  // are rendered using the same aspect.
120  //BTX
121  enum
122  {
123  ToolbarAspectRelief = 0,
124  ToolbarAspectFlat = 1,
125  ToolbarAspectUnChanged
126  };
127  //ETX
128  vtkGetMacro(ToolbarAspect, int);
129  virtual void SetToolbarAspect(int);
130  virtual void SetToolbarAspectToFlat();
131  virtual void SetToolbarAspectToRelief();
132  virtual void SetToolbarAspectToUnChanged();
133  static int GetGlobalToolbarAspect();
134  static void SetGlobalToolbarAspect(int val);
135  static void SetGlobalToolbarAspectToFlat();
136  static void SetGlobalToolbarAspectToRelief();
137  static void SetGlobalToolbarAspectToUnChanged();
138 
139  // Description:
140  // Set/Get the aspect of the widgets (flat, 3D GUI style, or unchanged)
141  // The static GlobalWidgetsAspect member can be set so that all widgets
142  // are rendered using the same aspect.
143  //BTX
144  enum
145  {
146  WidgetsAspectRelief = 0,
147  WidgetsAspectFlat = 1,
148  WidgetsAspectUnChanged
149  };
150  //ETX
151  vtkGetMacro(WidgetsAspect, int);
152  virtual void SetWidgetsAspect(int);
153  virtual void SetWidgetsAspectToFlat();
154  virtual void SetWidgetsAspectToRelief();
155  virtual void SetWidgetsAspectToUnChanged();
156  static int GetGlobalWidgetsAspect();
157  static void SetGlobalWidgetsAspect(int val);
158  static void SetGlobalWidgetsAspectToFlat();
159  static void SetGlobalWidgetsAspectToRelief();
160  static void SetGlobalWidgetsAspectToUnChanged();
161 
162  // Description:
163  // Set/Get the padding that will be applied around each widget.
164  // (default to 0 on Windows, 1 otherwise).
165  virtual void SetWidgetsPadX(int);
166  vtkGetMacro(WidgetsPadX, int);
167  virtual void SetWidgetsPadY(int);
168  vtkGetMacro(WidgetsPadY, int);
169 
170  // Description:
171  // Set/Get the padding that will be applied inside each widget.
172  // (default to 0 on Windows, 1 otherwise).
173  virtual void SetWidgetsInternalPadX(int);
174  vtkGetMacro(WidgetsInternalPadX, int);
175  virtual void SetWidgetsInternalPadY(int);
176  vtkGetMacro(WidgetsInternalPadY, int);
177 
178  // Description:
179  // Set/Get the additional internal padding that will be applied around
180  // each widget when WidgetsAspect is On (default to 1).
181  virtual void SetWidgetsFlatAdditionalPadX(int);
182  vtkGetMacro(WidgetsFlatAdditionalPadX, int);
183  virtual void SetWidgetsFlatAdditionalPadY(int);
184  vtkGetMacro(WidgetsFlatAdditionalPadY, int);
185 
186  // Description:
187  // Set/Get the additional internal padding that will be applied inside
188  // each widget when WidgetsAspect is On (default to 1).
189  virtual void SetWidgetsFlatAdditionalInternalPadX(int);
190  vtkGetMacro(WidgetsFlatAdditionalInternalPadX, int);
191  virtual void SetWidgetsFlatAdditionalInternalPadY(int);
192  vtkGetMacro(WidgetsFlatAdditionalInternalPadY, int);
193 
194  // Description:
195  // Schedule the widget to resize itself, or resize it right away
196  virtual void ScheduleResize();
197  virtual void Resize();
198 
199  // Description:
200  // Update the "enable" state of the object and its internal parts.
201  // Depending on different Ivars (Enabled, the application's
202  // Limited Edition Mode, etc.), the "enable" state of the object is updated
203  // and propagated to its internal parts subwidgets. This will, for example,
204  // enable disable parts of the widget UI, enable disable the visibility
205  // of 3D widgets, etc.
206  virtual void UpdateEnableState();
207 
208  // Description:
209  // Some constants
210  //BTX
211  static const char *ToolbarAspectRegKey;
212  static const char *WidgetsAspectRegKey;
213  //ETX
214 
215 protected:
216  vtkKWToolbar();
217  ~vtkKWToolbar();
218 
219  // Description:
220  // Create the widget.
221  virtual void CreateWidget();
222 
223  int Expanding;
224 
225  vtkKWFrame *Frame;
226  vtkKWFrame *Handle;
227 
228  void ConstrainWidgetsLayout();
229  void UpdateWidgetsLayout();
230  void UpdateWidgetsAspect();
231  void UpdateToolbarFrameAspect();
232 
233  //BTX
234 
235  // PIMPL Encapsulation for STL containers
236 
237  vtkKWToolbarInternals *Internals;
238 
239  //ETX
240 
241  int WidgetsPadX;
242  int WidgetsPadY;
243  int WidgetsFlatAdditionalPadX;
244  int WidgetsFlatAdditionalPadY;
245 
246  int WidgetsInternalPadX;
247  int WidgetsInternalPadY;
248  int WidgetsFlatAdditionalInternalPadX;
249  int WidgetsFlatAdditionalInternalPadY;
250 
251  int ToolbarAspect;
252  int WidgetsAspect;
253  int Resizable;
254 
255  vtkKWRadioButton *DefaultOptionsWidget;
256 
257  char *Name;
258 
259  // Description:
260  // Bind/Unbind events.
261  virtual void Bind();
262  virtual void UnBind();
263 
264 private:
265  vtkKWToolbar(const vtkKWToolbar&); // Not implemented
266  void operator=(const vtkKWToolbar&); // Not implemented
267 };
268 
269 
270 #endif
271 
272 
273