KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWWidgetSet.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: vtkKWWidgetSet.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 vtkKWWidgetSet - an abstract set of a specific type of vtkKWWidget
15 // .SECTION Description
16 // This class is a composite widget that can be used to conveniently
17 // allocate, store and layout a set of widgets of the same type.
18 // Each widget is created, removed or queried based on a unique ID provided
19 // by the user (ids are *not* handled by the class since it is likely that
20 // they will be defined as enum's or #define by the user for easier retrieval).
21 // Widgets are packed (gridded) in the order they were added to the set.
22 //
23 // IMPORTANT: this is an abstract superclass, it can not be used as-is.
24 // A subclass of vtkKWWidgetSet is tailored for a *specific* type of widget
25 // (see vtkKWPushButtonSet, which is a set of vtkKWPushButton); it can not be
26 // used to store or layout a set of heterogeneous widgets.
27 //
28 // This class acts as a container of widgets of the same type; the main point
29 // of this container is not to provide a layout mechanism, but to make it a
30 // little more convenient to create and allocate a whole bunch of widgets
31 // of the same type without explicitly declaring a pointer to each and
32 // everyone of them. Say, if you need ten buttons, and you do not want to
33 // make 10 calls to vtkKWPushButton::New(), 10 calls to
34 // vtkKWPushButton::Create(), and 10 calls to vtkKWPushButton::Delete(): just
35 // create one instance of a vtkKWPushButtonSet, then call
36 // vtkKWPushButtonSet::AddWidget to automatically allocate and create an
37 // instance of a vtkKWPushButton. This widget will be packed in a grid
38 // fashion with the other widgets in the set, as a bonus. Widgets that are
39 // added, allocated and created that way are automatically de-allocated when
40 // the vtkKWWidgetSet instance is deleted.
41 //
42 // Be aware that the pretty much all subclasses of vtkKWWidgetSet are
43 // generated automatically out of the vtkKWWidgetSetSubclass template located
44 // in the Templates directory. Therefore, even though the source code for
45 // those vtkKWWidgetSet subclasses does not exist in the KWWidgets repository,
46 // they are still generated automatically and documented in the API online;
47 // check the vtkKWWidgetSet API online for its subclasses, as well as the
48 // \subpage kwwidgets_autogenerated_page page.
49 // Classes related to the same template can be found in the
50 // \ref kwwidgets_autogenerated_widget_set_group section.
51 // Subclasses need to implement AllocateAndCreateWidget
52 // .SECTION See Also
53 // vtkKWCheckButtonSet vtkKWComboBoxSet vtkKWEntrySet vtkKWLabelSet vtkKWLabelWithLabelSet vtkKWPushButtonSet vtkKWScaleSet vtkKWScaleWithEntrySet vtkKWSpinBoxSet
54 
55 #ifndef __vtkKWWidgetSet_h
56 #define __vtkKWWidgetSet_h
57 
58 #include "vtkKWCompositeWidget.h"
59 
60 class vtkKWWidget;
61 class vtkKWWidgetSetInternals;
62 
64 {
65 public:
66  vtkTypeRevisionMacro(vtkKWWidgetSet,vtkKWCompositeWidget);
67  void PrintSelf(ostream& os, vtkIndent indent);
68 
69  // Description:
70  // Get the number of widget in the set.
71  virtual int GetNumberOfWidgets();
72 
73  // Description:
74  // Retrieve the id of the n-th widget (-1 if not found)
75  virtual int GetIdOfNthWidget(int rank);
76 
77  // Description:
78  // Check if a widget is in the set, given its unique id.
79  // Return 1 if exists, 0 otherwise.
80  virtual int HasWidget(int id);
81 
82  // Description:
83  // Retrieve the position in the set the widget was inserted at.
84  // Return pos if exists, -1 otherwise
85  virtual int GetWidgetPosition(int id);
86 
87  // Description:
88  // Hide/show a widget, given its unique id.
89  // Get the number of visible widget in the set.
90  // Since the changing the widget visibility will trigger an expensive call
91  // to Pack(), one can use SetWidgetsVisibility to change the visibility of
92  // many widgets in a single call.
93  virtual void HideWidget(int id);
94  virtual void ShowWidget(int id);
95  virtual int GetWidgetVisibility(int id);
96  virtual void SetWidgetVisibility(int id, int flag);
97  virtual int GetNumberOfVisibleWidgets();
98  virtual int GetIdOfNthVisibleWidget(int rank);
99  virtual void SetWidgetsVisibility(int nb_ids, int *ids, int *flags);
100 
101  // Description:
102  // Delete all widgets.
103  virtual void DeleteAllWidgets();
104 
105  // Description:
106  // Set the packing direction to be horizontal (default is vertical).
107  virtual void SetPackHorizontally(int);
108  vtkBooleanMacro(PackHorizontally, int);
109  vtkGetMacro(PackHorizontally, int);
110 
111  // Description:
112  // Set the maximum number of widgets that will be packed in the packing
113  // direction (i.e. horizontally or vertically).
114  // For example, if set to 3 and the packing direction is horizontal,
115  // the layout ends up as 3 columns of widgets.
116  // The default is 0, i.e. all widgets are packed along the same direction.
117  virtual void SetMaximumNumberOfWidgetsInPackingDirection(int);
118  vtkGetMacro(MaximumNumberOfWidgetsInPackingDirection, int);
119 
120  // Description:
121  // Set/Get the padding that will be applied around each widget.
122  // (default to 0).
123  virtual void SetWidgetsPadX(int);
124  vtkGetMacro(WidgetsPadX, int);
125  virtual void SetWidgetsPadY(int);
126  vtkGetMacro(WidgetsPadY, int);
127 
128  // Description:
129  // Set/Get the internal padding that will be left around each widget.
130  // This space is added inside the widget border.
131  // (default to 0).
132  virtual void SetWidgetsInternalPadX(int);
133  vtkGetMacro(WidgetsInternalPadX, int);
134  virtual void SetWidgetsInternalPadY(int);
135  vtkGetMacro(WidgetsInternalPadY, int);
136 
137  // Description:
138  // Set the layout to allow the widgets to expand automatically
139  // within the set.
140  virtual void SetExpandWidgets(int);
141  vtkBooleanMacro(ExpandWidgets, int);
142  vtkGetMacro(ExpandWidgets, int);
143 
144  // Description:
145  // Set/Get if the column/row layout should be uniform (enforce same size).
146  virtual void SetUniformColumns(int);
147  vtkBooleanMacro(UniformColumns, int);
148  vtkGetMacro(UniformColumns, int);
149  virtual void SetUniformRows(int);
150  vtkBooleanMacro(UniformRows, int);
151  vtkGetMacro(UniformRows, int);
152 
153  // Description:
154  // Update the "enable" state of the object and its internal parts.
155  // Depending on different Ivars (this->Enabled, the application's
156  // Limited Edition Mode, etc.), the "enable" state of the object is updated
157  // and propagated to its internal parts/subwidgets. This will, for example,
158  // enable/disable parts of the widget UI, enable/disable the visibility
159  // of 3D widgets, etc.
160  virtual void UpdateEnableState();
161 
162 protected:
163  vtkKWWidgetSet();
164  ~vtkKWWidgetSet();
165 
166  // Description:
167  // Create the widget.
168  virtual void CreateWidget();
169 
179 
180  // Description:
181  // To be implemented by superclasses.
182  // Allocate and create a widget of the right type.
183  // Return a pointer to the superclass though.
184  virtual vtkKWWidget* AllocateAndCreateWidget() = 0;
185 
186  // BTX
187  // PIMPL Encapsulation for STL containers
188 
189  vtkKWWidgetSetInternals *Internals;
190  //ETX
191 
192  // Helper methods
193 
194  virtual vtkKWWidget* GetWidgetInternal(int id);
195  virtual vtkKWWidget* InsertWidgetInternal(int id, int pos);
196 
197  // Description:
198  // Pack the widgets
199  virtual void Pack();
200 
201 private:
202  vtkKWWidgetSet(const vtkKWWidgetSet&); // Not implemented
203  void operator=(const vtkKWWidgetSet&); // Not implemented
204 };
205 
206 #endif