KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWCheckButton.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 vtkKWCheckButton - check button widget 00015 // .SECTION Description 00016 // A simple widget that represents a check button. It can be modified 00017 // and queried using the GetSelectedState and SetSelectedState methods. 00018 00019 #ifndef __vtkKWCheckButton_h 00020 #define __vtkKWCheckButton_h 00021 00022 #include "vtkKWCoreWidget.h" 00023 00024 class vtkKWIcon; 00025 00026 class KWWidgets_EXPORT vtkKWCheckButton : public vtkKWCoreWidget 00027 { 00028 public: 00029 static vtkKWCheckButton* New(); 00030 vtkTypeRevisionMacro(vtkKWCheckButton,vtkKWCoreWidget); 00031 void PrintSelf(ostream& os, vtkIndent indent); 00032 00033 // Description: 00034 // Set/Get/Toggle the selected state of the check button 0 = off 1 = on 00035 virtual void SetSelectedState(int ); 00036 virtual int GetSelectedState(); 00037 vtkBooleanMacro(SelectedState, int); 00038 virtual void ToggleSelectedState(); 00039 virtual void Select() { this->SetSelectedState(1); }; 00040 virtual void Deselect() { this->SetSelectedState(0); }; 00041 00042 // Description: 00043 // Tell the widget whether it should use an indicator (check box) 00044 virtual void SetIndicatorVisibility(int ind); 00045 vtkGetMacro(IndicatorVisibility, int); 00046 vtkBooleanMacro(IndicatorVisibility, int); 00047 00048 // Description: 00049 // Set the text. 00050 virtual void SetText(const char* txt); 00051 virtual const char* GetText(); 00052 00053 // Description: 00054 // Set the variable name. 00055 // Important: note that this will *not* copy over the previous variable 00056 // value to the new one. 00057 vtkGetStringMacro(VariableName); 00058 virtual void SetVariableName(const char *); 00059 00060 // Description: 00061 // Specifies a command to associate with the widget. This command is 00062 // typically invoked when the button is selected or deselected. 00063 // The 'object' argument is the object that will have the method called on 00064 // it. The 'method' argument is the name of the method to be called and any 00065 // arguments in string form. If the object is NULL, the method is still 00066 // evaluated as a simple command. 00067 // The following parameters are also passed to the command: 00068 // - current selected state: int 00069 virtual void SetCommand(vtkObject *object, const char *method); 00070 00071 // Description: 00072 // Events. The SelectedStateChangedEvent is triggered when the button 00073 // is selected or deselected. 00074 // The following parameters are also passed as client data: 00075 // - the current selected state: int 00076 //BTX 00077 enum 00078 { 00079 SelectedStateChangedEvent = 10000 00080 }; 00081 //ETX 00082 00083 // Description: 00084 // Set/Get the background color of the widget. 00085 virtual void GetBackgroundColor(double *r, double *g, double *b); 00086 virtual double* GetBackgroundColor(); 00087 virtual void SetBackgroundColor(double r, double g, double b); 00088 virtual void SetBackgroundColor(double rgb[3]) 00089 { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00090 00091 // Description: 00092 // Set/Get the foreground color of the widget. 00093 virtual void GetForegroundColor(double *r, double *g, double *b); 00094 virtual double* GetForegroundColor(); 00095 virtual void SetForegroundColor(double r, double g, double b); 00096 virtual void SetForegroundColor(double rgb[3]) 00097 { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00098 00099 // Description: 00100 // Set/Get the highlight thickness, a non-negative value indicating the 00101 // width of the highlight rectangle to draw around the outside of the 00102 // widget when it has the input focus. 00103 virtual void SetHighlightThickness(int); 00104 virtual int GetHighlightThickness(); 00105 00106 // Description: 00107 // Set/Get the active background color of the widget. An element 00108 // (a widget or portion of a widget) is active if the mouse cursor is 00109 // positioned over the element and pressing a mouse button will cause some 00110 // action to occur. 00111 virtual void GetActiveBackgroundColor(double *r, double *g, double *b); 00112 virtual double* GetActiveBackgroundColor(); 00113 virtual void SetActiveBackgroundColor(double r, double g, double b); 00114 virtual void SetActiveBackgroundColor(double rgb[3]) 00115 { this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00116 00117 // Description: 00118 // Set/Get the active foreground color of the widget. An element 00119 // (a widget or portion of a widget) is active if the mouse cursor is 00120 // positioned over the element and pressing a mouse button will cause some 00121 // action to occur. 00122 virtual void GetActiveForegroundColor(double *r, double *g, double *b); 00123 virtual double* GetActiveForegroundColor(); 00124 virtual void SetActiveForegroundColor(double r, double g, double b); 00125 virtual void SetActiveForegroundColor(double rgb[3]) 00126 { this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00127 00128 // Description: 00129 // Set/Get the foreground color of the widget when it is disabled. 00130 virtual void GetDisabledForegroundColor(double *r, double *g, double *b); 00131 virtual double* GetDisabledForegroundColor(); 00132 virtual void SetDisabledForegroundColor(double r, double g, double b); 00133 virtual void SetDisabledForegroundColor(double rgb[3]) 00134 { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00135 00136 // Description: 00137 // Set/Get the border width, a non-negative value indicating the width of 00138 // the 3-D border to draw around the outside of the widget (if such a border 00139 // is being drawn; the Relief option typically determines this). 00140 virtual void SetBorderWidth(int); 00141 virtual int GetBorderWidth(); 00142 00143 // Description: 00144 // Set/Get the 3-D effect desired for the widget. 00145 // The value indicates how the interior of the widget should appear 00146 // relative to its exterior. 00147 // Valid constants can be found in vtkKWOptions::ReliefType. 00148 virtual void SetRelief(int); 00149 virtual int GetRelief(); 00150 virtual void SetReliefToRaised(); 00151 virtual void SetReliefToSunken(); 00152 virtual void SetReliefToFlat(); 00153 virtual void SetReliefToRidge(); 00154 virtual void SetReliefToSolid(); 00155 virtual void SetReliefToGroove(); 00156 00157 // Description: 00158 // Set/Get the padding that will be applied around each widget (in pixels). 00159 // Specifies a non-negative value indicating how much extra space to request 00160 // for the widget in the X and Y-direction. When computing how large a 00161 // window it needs, the widget will add this amount to the width it would 00162 // normally need (as determined by the width of the things displayed 00163 // in the widget); if the geometry manager can satisfy this request, the 00164 // widget will end up with extra internal space around what it displays 00165 // inside. 00166 virtual void SetPadX(int); 00167 virtual int GetPadX(); 00168 virtual void SetPadY(int); 00169 virtual int GetPadY(); 00170 00171 // Description: 00172 // Set/Get the anchoring. 00173 // Specifies how the information in a widget (e.g. text or a bitmap) is to 00174 // be displayed in the widget. 00175 // Valid constants can be found in vtkKWOptions::AnchorType. 00176 virtual void SetAnchor(int); 00177 virtual int GetAnchor(); 00178 virtual void SetAnchorToNorth(); 00179 virtual void SetAnchorToNorthEast(); 00180 virtual void SetAnchorToEast(); 00181 virtual void SetAnchorToSouthEast(); 00182 virtual void SetAnchorToSouth(); 00183 virtual void SetAnchorToSouthWest(); 00184 virtual void SetAnchorToWest(); 00185 virtual void SetAnchorToNorthWest(); 00186 virtual void SetAnchorToCenter(); 00187 00188 // Description: 00189 // Set/Get the 3-D effect desired for the widget. 00190 // Specifies the relief for the button when the indicator is not drawn 00191 // (i.e. IndicatorVisibility is Off) and the button is not selected. 00192 // The default value is Raised. By setting this option to Flat and setting 00193 // IndicatorVisibility to Off and OverRelief to Raised or Flat, the effect 00194 // is achieved of having a flat button that raises on mouse-over and which 00195 // is depressed when activated. This is the behavior typically exhibited by 00196 // the Bold, Italic, and Underline checkbuttons on the toolbar of a 00197 // word-processor, for example. 00198 // Valid constants can be found in vtkKWOptions::ReliefType. 00199 virtual void SetOffRelief(int); 00200 virtual int GetOffRelief(); 00201 virtual void SetOffReliefToRaised(); 00202 virtual void SetOffReliefToSunken(); 00203 virtual void SetOffReliefToFlat(); 00204 virtual void SetOffReliefToRidge(); 00205 virtual void SetOffReliefToSolid(); 00206 virtual void SetOffReliefToGroove(); 00207 00208 // Description: 00209 // Set/Get the 3-D effect desired for the widget. 00210 // Specifies an alternative relief for the button, to be used when the mouse 00211 // cursor is over the widget. This option can be used to make toolbar 00212 // buttons, by configuring SetRelief to Flat and OverRelief to Raised. 00213 // Valid constants can be found in vtkKWOptions::ReliefType. 00214 // If the value of this option is None, then no alternative relief is used 00215 // when the mouse cursor is over the checkbutton. 00216 virtual void SetOverRelief(int); 00217 virtual int GetOverRelief(); 00218 virtual void SetOverReliefToRaised(); 00219 virtual void SetOverReliefToSunken(); 00220 virtual void SetOverReliefToFlat(); 00221 virtual void SetOverReliefToRidge(); 00222 virtual void SetOverReliefToSolid(); 00223 virtual void SetOverReliefToGroove(); 00224 virtual void SetOverReliefToNone(); 00225 00226 // Description: 00227 // Specifies the font to use when drawing text inside the widget. 00228 // You can use predefined font names (e.g. 'system'), or you can specify 00229 // a set of font attributes with a platform-independent name, for example, 00230 // 'times 12 bold'. In this example, the font is specified with a three 00231 // element list: the first element is the font family, the second is the 00232 // size, the third is a list of style parameters (normal, bold, roman, 00233 // italic, underline, overstrike). Example: 'times 12 {bold italic}'. 00234 // The Times, Courier and Helvetica font families are guaranteed to exist 00235 // and will be matched to the corresponding (closest) font on your system. 00236 // If you are familiar with the X font names specification, you can also 00237 // describe the font that way (say, '*times-medium-r-*-*-12*'). 00238 virtual void SetFont(const char *font); 00239 virtual const char* GetFont(); 00240 00241 // Description: 00242 // Specifies an image to display in the widget. Typically, if the image 00243 // is specified then it overrides other options that specify a bitmap or 00244 // textual value to display in the widget. Invoke vtkKWWidget's 00245 // SetConfigurationOption("-image", imagename) to use a specific 00246 // pre-existing Tk image, or call one of the following functions: 00247 // The SetImageToPredefinedIcon method accepts an index to one of the 00248 // predefined icon listed in vtkKWIcon. 00249 // The SetImageToPixels method sets the image using pixel data. It expects 00250 // a pointer to the pixels and the structure of the image, i.e. its width, 00251 // height and the pixel_size (how many bytes per pixel, say 3 for RGB, or 00252 // 1 for grayscale). If buffer_length = 0, it is computed automatically 00253 // from the previous parameters. If it is not, it will most likely indicate 00254 // that the buffer has been encoded using base64 and/or zlib. 00255 // If pixel_size > 3 (i.e. RGBA), the image is blend the with background 00256 // color of the widget. 00257 // Check the SetCompoundMode method if you want to display both the 00258 // image and the label at the same time. 00259 virtual void SetImageToIcon(vtkKWIcon *icon); 00260 virtual void SetImageToPredefinedIcon(int icon_index); 00261 virtual void SetImageToPixels( 00262 const unsigned char *pixels, int width, int height, int pixel_size, 00263 unsigned long buffer_length = 0); 00264 00265 // Description: 00266 // Specifies an image to display in the widget when the button is selected. 00267 // This option is ignored unless an image has been set for the unselected 00268 // state of the button already (see SetImageToIcon). 00269 // Typically, if the image is specified then it overrides other options that 00270 // specify a bitmap or textual value to display in the widget. 00271 // Invoke vtkKWWidget's SetConfigurationOption("-selectimage", imagename) 00272 // to use a specific pre-existing Tk image, or call one of the following 00273 // functions: 00274 // The SetSelectImageToPredefinedIcon method accepts an index to one of the 00275 // predefined icon listed in vtkKWIcon. 00276 // The SetSelectImageToPixels method sets the image using pixel data. It 00277 // expects a pointer to the pixels and the structure of the image, i.e. its 00278 // width, height and the pixel_size (how many bytes per pixel, say 3 for RGB, 00279 // or 1 for grayscale). If buffer_length = 0, it is computed automatically 00280 // from the previous parameters. If it is not, it will most likely indicate 00281 // that the buffer has been encoded using base64 and/or zlib. 00282 // If pixel_size > 3 (i.e. RGBA), the image is blend the with background 00283 // color of the widget. 00284 // Check the SetCompoundMode method if you want to display both the 00285 // image and the label at the same time. 00286 virtual void SetSelectImageToIcon(vtkKWIcon *icon); 00287 virtual void SetSelectImageToPredefinedIcon(int icon_index); 00288 virtual void SetSelectImageToPixels( 00289 const unsigned char *pixels, int width, int height, int pixel_size, 00290 unsigned long buffer_length = 0); 00291 00292 // Description: 00293 // Specifies if the widget should display text and bitmaps/images at the 00294 // same time, and if so, where the bitmap/image should be placed relative 00295 // to the text. 00296 // Valid constants can be found in vtkKWOptions::CompoundModeType. 00297 // The (default) value CompoundModeNone specifies that the bitmap or image 00298 // should (if defined) be displayed instead of the text. 00299 virtual void SetCompoundMode(int); 00300 virtual int GetCompoundMode(); 00301 virtual void SetCompoundModeToNone(); 00302 virtual void SetCompoundModeToLeft(); 00303 virtual void SetCompoundModeToCenter(); 00304 virtual void SetCompoundModeToRight(); 00305 virtual void SetCompoundModeToTop(); 00306 virtual void SetCompoundModeToBottom(); 00307 00308 // Description: 00309 // Set/Get the background color to use when the widget is selected. 00310 virtual void GetSelectColor(double *r, double *g, double *b); 00311 virtual double* GetSelectColor(); 00312 virtual void SetSelectColor(double r, double g, double b); 00313 virtual void SetSelectColor(double rgb[3]) 00314 { this->SetSelectColor(rgb[0], rgb[1], rgb[2]); }; 00315 00316 // Description: 00317 // Update the "enable" state of the object and its internal parts. 00318 // Depending on different Ivars (this->Enabled, the application's 00319 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00320 // and propagated to its internal parts/subwidgets. This will, for example, 00321 // enable/disable parts of the widget UI, enable/disable the visibility 00322 // of 3D widgets, etc. 00323 virtual void UpdateEnableState(); 00324 00325 // Description: 00326 // Callbacks. Internal, do not use. 00327 virtual void CommandCallback(); 00328 00329 protected: 00330 00331 // Description: 00332 // Create the widget. 00333 virtual void CreateWidget(); 00334 00335 vtkSetStringMacro(InternalText); 00336 00337 vtkKWCheckButton(); 00338 ~vtkKWCheckButton(); 00339 00340 int IndicatorVisibility; 00341 00342 char *InternalText; 00343 char *VariableName; 00344 00345 virtual void Configure(); 00346 00347 char *Command; 00348 virtual void InvokeCommand(int state); 00349 00350 private: 00351 vtkKWCheckButton(const vtkKWCheckButton&); // Not implemented 00352 void operator=(const vtkKWCheckButton&); // Not Implemented 00353 }; 00354 00355 #endif