KWWidgets
vtkKWWidgetWithLabel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWWidgetWithLabel.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 vtkKWWidgetWithLabel - an abstract class widget with a label
15 // .SECTION Description
16 // This class implements a superclass for composite widgets that need
17 // to associate a label (vtkKWLabel) to a widget (say, a
18 // vtkKWEntry for example). This superclass provides a GetLabel() method
19 // to retrieve the internal vtkKWLabel. Each subclass provides a GetWidget()
20 // method that can be used to retrieve the internal widget associated to
21 // to this label in the composite (say, a vtkKWEntry).
22 //
23 // Be aware that most subclasses of vtkKWWidgetWithLabel are
24 // generated automatically out of the vtkKWWidgetWithLabelSubclass template
25 // located in the Templates directory. Therefore, even though the source code
26 // for those vtkKWWidgetWithLabel subclasses does not exist in the KWWidgets
27 // repository, they are still generated automatically and documented in the
28 // API online; check the vtkKWWidgetWithLabel API online for its subclasses,
29 // as well as the \subpage kwwidgets_autogenerated_page page.
30 // Classes related to the same template can be
31 // found in the \ref kwwidgets_autogenerated_widget_with_label_group section.
32 // .SECTION See Also
33 // vtkKWCheckButtonWithLabel vtkKWEntryWithLabel vtkKWComboBoxWithLabel vtkKWMenuButtonWithLabel vtkKWMessageWithLabel vtkKWPushButtonWithLabel vtkKWScaleWithLabel vtkKWSpinBoxWithLabel
34 
35 #ifndef __vtkKWWidgetWithLabel_h
36 #define __vtkKWWidgetWithLabel_h
37 
38 #include "vtkKWCompositeWidget.h"
39 
40 class vtkKWLabel;
41 
43 {
44 public:
45  static vtkKWWidgetWithLabel* New();
47  void PrintSelf(ostream& os, vtkIndent indent);
48 
49  // Description:
50  // Set/Get the internal label visibility (On by default).
51  // IMPORTANT: if you know you may not show the label, try to
52  // set that flag as early as possible (ideally, before calling Create())
53  // in order to lower the footprint of the widget: the label will not be
54  // allocated and created if there is no need to show it.
55  // Later on, you can still use that option to show the label: it will be
56  // allocated and created on the fly.
57  virtual void SetLabelVisibility(int);
58  vtkBooleanMacro(LabelVisibility, int);
59  vtkGetMacro(LabelVisibility, int);
60 
61  // Description:
62  // Get the internal label.
63  // IMPORTANT: the internal label is "lazy created", i.e. it is neither
64  // allocated nor created until GetLabel() is called. This allows
65  // for a lower footprint and faster UI startup. Therefore, do *not* use
66  // GetLabel() to check if the label exists, as it will automatically
67  // allocate the label. Use HasLabel() instead.
68  virtual vtkKWLabel* GetLabel();
69  virtual int HasLabel();
70 
71  // Description:
72  // Set/Get the contents label.
73  // IMPORTANT: SetLabelText will create the label on the fly, use it only if
74  // you are confident that you will indeed display the label.
75  virtual void SetLabelText(const char *);
76  const char* GetLabelText();
77 
78  // Description:
79  // Set/Get the label width.
80  // IMPORTANT: this method will create the label on the fly, use it only if
81  // you are confident that you will indeed display the label.
82  virtual void SetLabelWidth(int width);
83  virtual int GetLabelWidth();
84 
85  // Description:
86  // If supported, set the label position in regards to the rest of
87  // the composite widget. Check the subclass for more information about
88  // what the Default position is, and if specific positions are supported.
89  //BTX
90  enum
91  {
92  LabelPositionDefault = 0,
93  LabelPositionTop,
94  LabelPositionBottom,
95  LabelPositionLeft,
96  LabelPositionRight
97  };
98  //ETX
99  virtual void SetLabelPosition(int);
100  vtkGetMacro(LabelPosition, int);
101  virtual void SetLabelPositionToDefault()
102  { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionDefault); };
103  virtual void SetLabelPositionToTop()
104  { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionTop); };
105  virtual void SetLabelPositionToBottom()
106  { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionBottom); };
107  virtual void SetLabelPositionToLeft()
108  { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionLeft); };
109  virtual void SetLabelPositionToRight()
110  { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionRight); };
111 
112  // Description:
113  // Set the string that enables balloon help for this widget.
114  // Override to pass down to children.
115  virtual void SetBalloonHelpString(const char *str);
116 
117  // Description:
118  // Update the "enable" state of the object and its internal parts.
119  // Depending on different Ivars (this->Enabled, the application's
120  // Limited Edition Mode, etc.), the "enable" state of the object is updated
121  // and propagated to its internal parts/subwidgets. This will, for example,
122  // enable/disable parts of the widget UI, enable/disable the visibility
123  // of 3D widgets, etc.
124  virtual void UpdateEnableState();
125 
126 protected:
129 
130  // Description:
131  // Create the widget.
132  virtual void CreateWidget();
133 
134  // Description:
135  // Label visibility
136  int LabelVisibility;
137 
138  // Description:
139  // Label position
140  int LabelPosition;
141 
142  // Description:
143  // Create the label
144  virtual void CreateLabel();
145 
146  // Description:
147  // Pack or repack the widget. To be implemented by subclasses.
148  virtual void Pack() {};
149 
150 private:
151 
152  // Description:
153  // Internal label
154  // In 'private:' to allow lazy evaluation. GetLabel() will create the
155  // label if it does not exist. This allow the object to remain lightweight.
156  vtkKWLabel *Label;
157 
158  vtkKWWidgetWithLabel(const vtkKWWidgetWithLabel&); // Not implemented
159  void operator=(const vtkKWWidgetWithLabel&); // Not implemented
160 };
161 
162 #endif