KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWSelectionFrame.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWSelectionFrame.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 vtkKWSelectionFrame - Selection Frame
15 // .SECTION Description
16 // The selction frame is what contains a render widget.
17 // It is called a "selection frame" because in its title bar, you can
18 // select which render widget to display in it.
19 // .SECTION See Also
20 // vtkKWSelectionFrameLayoutManager
21 
22 #ifndef __vtkKWSelectionFrame_h
23 #define __vtkKWSelectionFrame_h
24 
25 #include "vtkKWCompositeWidget.h"
26 
27 class vtkKWFrame;
28 class vtkKWLabel;
29 class vtkKWMenuButton;
30 class vtkKWPushButton;
31 class vtkKWSelectionFrameInternals;
32 class vtkKWToolbarSet;
33 class vtkStringArray;
34 
36 {
37 public:
38  static vtkKWSelectionFrame* New();
39  vtkTypeRevisionMacro(vtkKWSelectionFrame, vtkKWCompositeWidget);
40  void PrintSelf(ostream& os, vtkIndent indent);
41 
42  // Description:
43  // Set/Get title
44  virtual void SetTitle(const char *title);
45  virtual const char* GetTitle();
46 
47  // Description:
48  // Select/Deselect the window
49  virtual void SetSelected(int);
50  vtkGetMacro(Selected, int);
51  vtkBooleanMacro(Selected, int);
52 
53  // Description:
54  // Set the selection list (array of num strings).
55  // The selection list is represented as a pull down menu, which
56  // visibility can be set. As a convenience, any entry made of two
57  // dashes "--" is used as a separator.
58  // This selection list can be used, for example, to display the titles
59  // of other selection frames that can be switched with the current
60  // selection frame.
61  virtual void SetSelectionList(int num, const char **list);
62  virtual void SetSelectionList(vtkStringArray *list);
63  vtkGetObjectMacro(SelectionListMenuButton, vtkKWMenuButton);
64 
65  // Description:
66  // Specifies a command to associate with the widget. This command is
67  // invoked when an item is picked by the user in the selection list.
68  // The 'object' argument is the object that will have the method called on
69  // it. The 'method' argument is the name of the method to be called and any
70  // arguments in string form. If the object is NULL, the method is still
71  // evaluated as a simple command.
72  // The following parameters are also passed to the command:
73  // - item selected in the list: const char *
74  // - pointer to this object: vtkKWSelectionFrame*
75  virtual void SetSelectionListCommand(vtkObject *object, const char *method);
76 
77  // Description:
78  // Set/Get the selection list visibility.
79  virtual void SetSelectionListVisibility(int);
80  vtkGetMacro(SelectionListVisibility, int);
81  vtkBooleanMacro(SelectionListVisibility, int);
82 
83  // Description:
84  // Allow the close functionality (button and menu entry)
85  // If set, a close button is added in the top right corner,
86  // and a "Close" entry is added to the end of the selection list.
87  virtual void SetAllowClose(int);
88  vtkGetMacro(AllowClose, int);
89  vtkBooleanMacro(AllowClose, int);
90  vtkGetObjectMacro(CloseButton, vtkKWPushButton);
91 
92  // Description:
93  // Specifies a command to associate with the widget. This command is
94  // typically invoked when the widget is closed (using the close button
95  // or the Close() method).
96  // The 'object' argument is the object that will have the method called on
97  // it. The 'method' argument is the name of the method to be called and any
98  // arguments in string form. If the object is NULL, the method is still
99  // evaluated as a simple command.
100  // The following parameters are also passed to the command:
101  // - pointer to this object: vtkKWSelectionFrame*
102  virtual void SetCloseCommand(vtkObject *object, const char *method);
103 
104  // Description:
105  // Close the selection frame. It can be re-implemented by
106  // subclasses to add more functionalities, release resources, etc.
107  // The current implementation invokes the CloseCommand, if any.
108  virtual void Close();
109 
110  // Description:
111  // Allow title to be changed (menu entry)
112  // If set, a "Change title" entry is added to the end of the selection list,
113  // enabling the title to be changed using the ChangeTitleCommand. There
114  // is actually no code or user interface to change the title, it is left
115  // to the ChangeTitleCommand.
116  virtual void SetAllowChangeTitle(int);
117  vtkGetMacro(AllowChangeTitle, int);
118  vtkBooleanMacro(AllowChangeTitle, int);
119 
120  // Description:
121  // Specifies a command to associate with the widget. This command is
122  // typically invoked when the "Change title" menu entry is selected.
123  // This command is usually implemented by a different class and will,
124  // for example, query the user for a new title, check that this title meet
125  // some constraints, and call SetTitle() on this object (which in turn will
126  // trigger the TitleChangedCommand).
127  // The 'object' argument is the object that will have the method called on
128  // it. The 'method' argument is the name of the method to be called and any
129  // arguments in string form. If the object is NULL, the method is still
130  // evaluated as a simple command.
131  // The following parameters are also passed to the command:
132  // - pointer to this object: vtkKWSelectionFrame*
133  virtual void SetChangeTitleCommand(vtkObject *object, const char *method);
134 
135  // Description:
136  // Specifies a command to associate with the widget. This command is
137  // typically invoked when the title is changed.
138  // This command can be used, for example, to notify a layout manager that
139  // it should refresh its list of available selection frame titles
140  // (see vtkKWSelectionFrameLayoutManager).
141  // Do not confuse this command with the ChangeTitleCommand, which is invoked
142  // when the "Change Title" menu entry is selected by the user, and is used
143  // to allow a third-party class to provide some user-dialog and change
144  // the title (given some potential constraints). This user-dialog will, in
145  // turn, most probably call SetTitle, which will trigger TitleChangedCommand.
146  // The 'object' argument is the object that will have the method called on
147  // it. The 'method' argument is the name of the method to be called and any
148  // arguments in string form. If the object is NULL, the method is still
149  // evaluated as a simple command.
150  // The following parameters are also passed to the command:
151  // - pointer to this object: vtkKWSelectionFrame*
152  virtual void SetTitleChangedCommand(vtkObject *object, const char *method);
153 
154  // Description:
155  // Specifies a command to associate with the widget. This command is
156  // typically invoked when the frame title is selected by the user
157  // (click in title bar).
158  // The 'object' argument is the object that will have the method called on
159  // it. The 'method' argument is the name of the method to be called and any
160  // arguments in string form. If the object is NULL, the method is still
161  // evaluated as a simple command.
162  // The following parameters are also passed to the command:
163  // - pointer to this object: vtkKWSelectionFrame*
164  virtual void SetSelectCommand(vtkObject *object, const char *method);
165 
166  // Description:
167  // Specifies a command to associate with the widget. This command is
168  // typically invoked when the frame title is double-clicked on.
169  // Note that this will also invoke the SelectCommand, since the first
170  // click acts as a select event.
171  // The 'object' argument is the object that will have the method called on
172  // it. The 'method' argument is the name of the method to be called and any
173  // arguments in string form. If the object is NULL, the method is still
174  // evaluated as a simple command.
175  // The following parameters are also passed to the command:
176  // - pointer to this object: vtkKWSelectionFrame*
177  virtual void SetDoubleClickCommand(vtkObject *object, const char *method);
178 
179  // Description:
180  // Set/Get the title foregroud/background color (in both normal and
181  // selected mode).
182  vtkGetVector3Macro(TitleColor, double);
183  virtual void SetTitleColor(double r, double g, double b);
184  virtual void SetTitleColor(double rgb[3])
185  { this->SetTitleColor(rgb[0], rgb[1], rgb[2]); };
186  vtkGetVector3Macro(TitleSelectedColor, double);
187  virtual void SetTitleSelectedColor(double r, double g, double b);
188  virtual void SetTitleSelectedColor(double rgb[3])
189  { this->SetTitleSelectedColor(rgb[0], rgb[1], rgb[2]); };
190  vtkGetVector3Macro(TitleBackgroundColor, double);
191  virtual void SetTitleBackgroundColor(double r, double g, double b);
192  virtual void SetTitleBackgroundColor(double rgb[3])
193  { this->SetTitleBackgroundColor(rgb[0], rgb[1], rgb[2]); };
194  vtkGetVector3Macro(TitleSelectedBackgroundColor, double);
195  virtual void SetTitleSelectedBackgroundColor(double r, double g, double b);
196  virtual void SetTitleSelectedBackgroundColor(double rgb[3])
197  { this->SetTitleSelectedBackgroundColor(rgb[0], rgb[1], rgb[2]); };
198 
199  // Description:
200  // Set/Get the title bar visibility.
201  virtual void SetTitleBarVisibility(int);
202  vtkGetMacro(TitleBarVisibility, int);
203  vtkBooleanMacro(TitleBarVisibility, int);
204 
205  // Description:
206  // Set/Get the toolbar set visibility, and retrieve the toolbar set.
207  // The toolbar set is usually displayed below the title bar
208  virtual vtkKWToolbarSet* GetToolbarSet();
209  virtual void SetToolbarSetVisibility(int);
210  vtkGetMacro(ToolbarSetVisibility, int);
211  vtkBooleanMacro(ToolbarSetVisibility, int);
212 
213  // Description:
214  // Retrieve the title bar user frame. This frame sits in the title
215  // bar, on the right side of the title itself, and be used to insert
216  // user-defined UI elements. It is not visible if TitleBarVisibility
217  // is Off.
218  virtual vtkKWFrame* GetTitleBarUserFrame();
219 
220  // Description:
221  // Retrieve the body frame. This is the main frame, below the title bar,
222  // where to pack the real contents of whatever that object is supposed
223  // to display (say, a render widget).
224  vtkGetObjectMacro(BodyFrame, vtkKWFrame);
225 
226  // Description:
227  // Set/Get the left user-frame visibility, and retrieve the frame.
228  // The left user-frame is displayed on the left side of the BodyFrame, as
229  // its name implies, can be used to put any extra UI the user wants.
230  virtual vtkKWFrame* GetLeftUserFrame();
231  virtual void SetLeftUserFrameVisibility(int);
232  vtkGetMacro(LeftUserFrameVisibility, int);
233  vtkBooleanMacro(LeftUserFrameVisibility, int);
234 
235  // Description:
236  // Set/Get the right user-frame visibility, and retrieve the frame.
237  // The right user-frame is displayed on the right side of the BodyFrame, as
238  // its name implies, can be used to put any extra UI the user wants.
239  virtual vtkKWFrame* GetRightUserFrame();
240  virtual void SetRightUserFrameVisibility(int);
241  vtkGetMacro(RightUserFrameVisibility, int);
242  vtkBooleanMacro(RightUserFrameVisibility, int);
243 
244  // Description:
245  // Set/Get the outer selection frame width and color. The outer selection
246  // frame is a thin frame around the whole widget which color is changed
247  // when the widget is selected. This is useful, for example, when the
248  // title bar is not visible (the title bar color also changes when the
249  // widget is selected). Set the width of the selection frame to 0 to
250  // discard this feature. Colors can be customized.
251  virtual void SetOuterSelectionFrameWidth(int);
252  vtkGetMacro(OuterSelectionFrameWidth, int);
253  vtkGetVector3Macro(OuterSelectionFrameColor, double);
254  virtual void SetOuterSelectionFrameColor(double r, double g, double b);
255  virtual void SetOuterSelectionFrameColor(double rgb[3])
256  { this->SetOuterSelectionFrameColor(rgb[0], rgb[1], rgb[2]); };
257  vtkGetVector3Macro(OuterSelectionFrameSelectedColor, double);
258  virtual void SetOuterSelectionFrameSelectedColor(
259  double r, double g, double b);
260  virtual void SetOuterSelectionFrameSelectedColor(double rgb[3])
261  { this->SetOuterSelectionFrameSelectedColor(rgb[0], rgb[1], rgb[2]); };
262 
263  // Description:
264  // Set/Get if the outer selection frame is blinking.
265  virtual void SetOuterSelectionFrameBlinking(int);
266  vtkGetMacro(OuterSelectionFrameBlinking, int);
267  vtkBooleanMacro(OuterSelectionFrameBlinking, int);
268 
269  // Description:
270  // Update the "enable" state of the object and its internal parts.
271  // Depending on different Ivars (this->Enabled, the application's
272  // Limited Edition Mode, etc.), the "enable" state of the object is updated
273  // and propagated to its internal parts/subwidgets. This will, for example,
274  // enable/disable parts of the widget UI, enable/disable the visibility
275  // of 3D widgets, etc.
276  virtual void UpdateEnableState();
277 
278  // Description:
279  // Callbacks. Internal, do not use.
280  virtual void CloseCallback();
281  virtual void SelectionListCallback(const char *menuItem);
282  virtual void SelectCallback();
283  virtual void DoubleClickCallback();
284  virtual void ChangeTitleCallback();
285  virtual void OuterSelectionFrameBlinkingCallback();
286 
287 protected:
290 
291  // Description:
292  // Create the widget.
293  virtual void CreateWidget();
294 
301 
302  virtual void Pack();
303  virtual void Bind();
304  virtual void UnBind();
305 
306  virtual int SetColor(double *color, double r, double g, double b);
307  virtual void UpdateSelectedAspect();
308  virtual void UpdateOuterSelectionFrameColor();
309  virtual void UpdateSelectionListMenuButton();
310 
311  double TitleColor[3];
312  double TitleSelectedColor[3];
313  double TitleBackgroundColor[3];
314  double TitleSelectedBackgroundColor[3];
315 
316  double OuterSelectionFrameColor[3];
317  double OuterSelectionFrameSelectedColor[3];
318 
325  virtual void InvokeSelectionListCommand(const char*, vtkKWSelectionFrame*);
326  virtual void InvokeCloseCommand(vtkKWSelectionFrame *obj);
327  virtual void InvokeSelectCommand(vtkKWSelectionFrame *obj);
328  virtual void InvokeDoubleClickCommand(vtkKWSelectionFrame *obj);
329  virtual void InvokeChangeTitleCommand(vtkKWSelectionFrame *obj);
330  virtual void InvokeTitleChangedCommand(vtkKWSelectionFrame *obj);
331 
332  int Selected;
342 
343  virtual void CreateOuterSelectionFrameBlinkingTimer();
344  virtual void CancelOuterSelectionFrameBlinkingTimer();
345 
346  // PIMPL Encapsulation for STL containers
347 
348  vtkKWSelectionFrameInternals *Internals;
349 
350 private:
351 
352  vtkKWToolbarSet *ToolbarSet;
353  vtkKWFrame *LeftUserFrame;
354  vtkKWFrame *RightUserFrame;
355  vtkKWFrame *TitleBarUserFrame;
356 
357  vtkKWSelectionFrame(const vtkKWSelectionFrame&); // Not implemented
358  void operator=(const vtkKWSelectionFrame&); // Not implemented
359 };
360 
361 #endif
362