KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWWidgetWithLabel.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 vtkKWWidgetWithLabel - an abstract class widget with a label 00015 // .SECTION Description 00016 // This class implements a superclass for composite widgets that need 00017 // to associate a label (vtkKWLabel) to a widget (say, a 00018 // vtkKWEntry for example). This superclass provides a GetLabel() method 00019 // to retrieve the internal vtkKWLabel. Each subclass provides a GetWidget() 00020 // method that can be used to retrieve the internal widget associated to 00021 // to this label in the composite (say, a vtkKWEntry). 00022 // 00023 // Be aware that most subclasses of vtkKWWidgetWithLabel are 00024 // generated automatically out of the vtkKWWidgetWithLabelSubclass template 00025 // located in the Templates directory. Therefore, even though the source code 00026 // for those vtkKWWidgetWithLabel subclasses does not exist in the KWWidgets 00027 // repository, they are still generated automatically and documented in the 00028 // API online; check the vtkKWWidgetWithLabel API online for its subclasses, 00029 // as well as the \subpage kwwidgets_autogenerated_page page. 00030 // Classes related to the same template can be 00031 // found in the \ref kwwidgets_autogenerated_widget_with_label_group section. 00032 // .SECTION See Also 00033 // vtkKWCheckButtonWithLabel vtkKWEntryWithLabel vtkKWComboBoxWithLabel vtkKWMenuButtonWithLabel vtkKWMessageWithLabel vtkKWPushButtonWithLabel vtkKWScaleWithLabel vtkKWSpinBoxWithLabel 00034 00035 #ifndef __vtkKWWidgetWithLabel_h 00036 #define __vtkKWWidgetWithLabel_h 00037 00038 #include "vtkKWCompositeWidget.h" 00039 00040 class vtkKWLabel; 00041 00042 class KWWidgets_EXPORT vtkKWWidgetWithLabel : public vtkKWCompositeWidget 00043 { 00044 public: 00045 static vtkKWWidgetWithLabel* New(); 00046 vtkTypeRevisionMacro(vtkKWWidgetWithLabel, vtkKWCompositeWidget); 00047 void PrintSelf(ostream& os, vtkIndent indent); 00048 00049 // Description: 00050 // Set/Get the internal label visibility (On by default). 00051 // IMPORTANT: if you know you may not show the label, try to 00052 // set that flag as early as possible (ideally, before calling Create()) 00053 // in order to lower the footprint of the widget: the label will not be 00054 // allocated and created if there is no need to show it. 00055 // Later on, you can still use that option to show the label: it will be 00056 // allocated and created on the fly. 00057 virtual void SetLabelVisibility(int); 00058 vtkBooleanMacro(LabelVisibility, int); 00059 vtkGetMacro(LabelVisibility, int); 00060 00061 // Description: 00062 // Get the internal label. 00063 // IMPORTANT: the internal label is "lazy created", i.e. it is neither 00064 // allocated nor created until GetLabel() is called. This allows 00065 // for a lower footprint and faster UI startup. Therefore, do *not* use 00066 // GetLabel() to check if the label exists, as it will automatically 00067 // allocate the label. Use HasLabel() instead. 00068 virtual vtkKWLabel* GetLabel(); 00069 virtual int HasLabel(); 00070 00071 // Description: 00072 // Set/Get the contents label. 00073 // IMPORTANT: SetLabelText will create the label on the fly, use it only if 00074 // you are confident that you will indeed display the label. 00075 virtual void SetLabelText(const char *); 00076 const char* GetLabelText(); 00077 00078 // Description: 00079 // Set/Get the label width. 00080 // IMPORTANT: this method will create the label on the fly, use it only if 00081 // you are confident that you will indeed display the label. 00082 virtual void SetLabelWidth(int width); 00083 virtual int GetLabelWidth(); 00084 00085 // Description: 00086 // If supported, set the label position in regards to the rest of 00087 // the composite widget. Check the subclass for more information about 00088 // what the Default position is, and if specific positions are supported. 00089 //BTX 00090 enum 00091 { 00092 LabelPositionDefault = 0, 00093 LabelPositionTop, 00094 LabelPositionBottom, 00095 LabelPositionLeft, 00096 LabelPositionRight 00097 }; 00098 //ETX 00099 virtual void SetLabelPosition(int); 00100 vtkGetMacro(LabelPosition, int); 00101 virtual void SetLabelPositionToDefault() 00102 { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionDefault); }; 00103 virtual void SetLabelPositionToTop() 00104 { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionTop); }; 00105 virtual void SetLabelPositionToBottom() 00106 { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionBottom); }; 00107 virtual void SetLabelPositionToLeft() 00108 { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionLeft); }; 00109 virtual void SetLabelPositionToRight() 00110 { this->SetLabelPosition(vtkKWWidgetWithLabel::LabelPositionRight); }; 00111 00112 // Description: 00113 // Set the string that enables balloon help for this widget. 00114 // Override to pass down to children. 00115 virtual void SetBalloonHelpString(const char *str); 00116 00117 // Description: 00118 // Update the "enable" state of the object and its internal parts. 00119 // Depending on different Ivars (this->Enabled, the application's 00120 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00121 // and propagated to its internal parts/subwidgets. This will, for example, 00122 // enable/disable parts of the widget UI, enable/disable the visibility 00123 // of 3D widgets, etc. 00124 virtual void UpdateEnableState(); 00125 00126 protected: 00127 vtkKWWidgetWithLabel(); 00128 ~vtkKWWidgetWithLabel(); 00129 00130 // Description: 00131 // Create the widget. 00132 virtual void CreateWidget(); 00133 00134 // Description: 00135 // Label visibility 00136 int LabelVisibility; 00137 00138 // Description: 00139 // Label position 00140 int LabelPosition; 00141 00142 // Description: 00143 // Create the label 00144 virtual void CreateLabel(); 00145 00146 // Description: 00147 // Pack or repack the widget. To be implemented by subclasses. 00148 virtual void Pack() {}; 00149 00150 private: 00151 00152 // Description: 00153 // Internal label 00154 // In 'private:' to allow lazy evaluation. GetLabel() will create the 00155 // label if it does not exist. This allow the object to remain lightweight. 00156 vtkKWLabel *Label; 00157 00158 vtkKWWidgetWithLabel(const vtkKWWidgetWithLabel&); // Not implemented 00159 void operator=(const vtkKWWidgetWithLabel&); // Not implemented 00160 }; 00161 00162 #endif