KWWidgets
vtkKWPushButton.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWPushButton.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 vtkKWPushButton - push button widget
15 // .SECTION Description
16 // A simple widget that represents a push button.
17 
18 #ifndef __vtkKWPushButton_h
19 #define __vtkKWPushButton_h
20 
21 #include "vtkKWCoreWidget.h"
22 
23 class vtkKWIcon;
24 
26 {
27 public:
28  static vtkKWPushButton* New();
29  vtkTypeRevisionMacro(vtkKWPushButton,vtkKWCoreWidget);
30  void PrintSelf(ostream& os, vtkIndent indent);
31 
32  // Description:
33  // Set the contents label.
34  virtual void SetText(const char *label);
35  virtual char *GetText();
36 
37  // Description:
38  // Set/Get the text width (in chars if the button has a text contents, or
39  // pixels if it has an image contents).
40  virtual void SetWidth(int width);
41  virtual int GetWidth();
42 
43  // Description:
44  // Set/Get the text height (in chars if the button has a text contents, or
45  // pixels if it has an image contents).
46  virtual void SetHeight(int height);
47  virtual int GetHeight();
48 
49  // Description:
50  // Specifies a command to associate with the widget. This command is
51  // typically invoked when button is pressed.
52  // The 'object' argument is the object that will have the method called on
53  // it. The 'method' argument is the name of the method to be called and any
54  // arguments in string form. If the object is NULL, the method is still
55  // evaluated as a simple command.
56  virtual void SetCommand(vtkObject *object, const char *method);
57 
58  // Description:
59  // Events. The InvokedEvent is triggered when the button is pressed.
60  //BTX
61  enum
62  {
63  InvokedEvent = 10000
64  };
65  //ETX
66 
67  // Description:
68  // Set/Get the background color of the widget
69  virtual void GetBackgroundColor(double *r, double *g, double *b);
70  virtual double* GetBackgroundColor();
71  virtual void SetBackgroundColor(double r, double g, double b);
72  virtual void SetBackgroundColor(double rgb[3])
73  { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
74 
75  // Description:
76  // Set/Get the foreground color of the widget
77  virtual void GetForegroundColor(double *r, double *g, double *b);
78  virtual double* GetForegroundColor();
79  virtual void SetForegroundColor(double r, double g, double b);
80  virtual void SetForegroundColor(double rgb[3])
81  { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
82 
83  // Description:
84  // Set/Get the highlight thickness, a non-negative value indicating the
85  // width of the highlight rectangle to draw around the outside of the
86  // widget when it has the input focus.
87  virtual void SetHighlightThickness(int);
88  virtual int GetHighlightThickness();
89 
90  // Description:
91  // Set/Get the active background color of
92  // the widget. An element (a widget or portion of a widget) is active
93  // if the mouse cursor is positioned over the element and pressing a mouse
94  // button will cause some action to occur.
95  virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
96  virtual double* GetActiveBackgroundColor();
97  virtual void SetActiveBackgroundColor(double r, double g, double b);
98  virtual void SetActiveBackgroundColor(double rgb[3])
99  { this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
100 
101  // Description:
102  // Set/Get the active foreground color of the widget. An element
103  // (a widget or portion of a widget) is active if the mouse cursor is
104  // positioned over the element and pressing a mouse button will cause some
105  // action to occur.
106  virtual void GetActiveForegroundColor(double *r, double *g, double *b);
107  virtual double* GetActiveForegroundColor();
108  virtual void SetActiveForegroundColor(double r, double g, double b);
109  virtual void SetActiveForegroundColor(double rgb[3])
110  { this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
111 
112  // Description:
113  // Set/Get the foreground color of the widget when it is disabled.
114  virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
115  virtual double* GetDisabledForegroundColor();
116  virtual void SetDisabledForegroundColor(double r, double g, double b);
117  virtual void SetDisabledForegroundColor(double rgb[3])
118  { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
119 
120  // Description:
121  // Set/Get the border width, a non-negative value indicating the width of
122  // the 3-D border to draw around the outside of the widget (if such a border
123  // is being drawn; the Relief option typically determines this).
124  virtual void SetBorderWidth(int);
125  virtual int GetBorderWidth();
126 
127  // Description:
128  // Set/Get the 3-D effect desired for the widget.
129  // The value indicates how the interior of the widget should appear
130  // relative to its exterior.
131  // Valid constants can be found in vtkKWOptions::ReliefType.
132  virtual void SetRelief(int);
133  virtual int GetRelief();
134  virtual void SetReliefToRaised();
135  virtual void SetReliefToSunken();
136  virtual void SetReliefToFlat();
137  virtual void SetReliefToRidge();
138  virtual void SetReliefToSolid();
139  virtual void SetReliefToGroove();
140 
141  // Description:
142  // Set/Get the padding that will be applied around each widget (in pixels).
143  // Specifies a non-negative value indicating how much extra space to request
144  // for the widget in the X and Y-direction. When computing how large a
145  // window it needs, the widget will add this amount to the width it would
146  // normally need (as determined by the width of the things displayed
147  // in the widget); if the geometry manager can satisfy this request, the
148  // widget will end up with extra internal space around what it displays
149  // inside.
150  virtual void SetPadX(int);
151  virtual int GetPadX();
152  virtual void SetPadY(int);
153  virtual int GetPadY();
154 
155  // Description:
156  // Set/Get the anchoring.
157  // Specifies how the information in a widget (e.g. text or a bitmap) is to
158  // be displayed in the widget.
159  // Valid constants can be found in vtkKWOptions::AnchorType.
160  virtual void SetAnchor(int);
161  virtual int GetAnchor();
162  virtual void SetAnchorToNorth();
163  virtual void SetAnchorToNorthEast();
164  virtual void SetAnchorToEast();
165  virtual void SetAnchorToSouthEast();
166  virtual void SetAnchorToSouth();
167  virtual void SetAnchorToSouthWest();
168  virtual void SetAnchorToWest();
169  virtual void SetAnchorToNorthWest();
170  virtual void SetAnchorToCenter();
171 
172  // Description:
173  // Set/Get the 3-D effect desired for the widget.
174  // Specifies an alternative relief for the button, to be used when the mouse
175  // cursor is over the widget. This option can be used to make toolbar
176  // buttons, by configuring SetRelief to Flat and OverRelief to Raised.
177  // Valid constants can be found in vtkKWOptions::ReliefType.
178  // If the value of this option is None, then no alternative relief is used
179  // when the mouse cursor is over the checkbutton.
180  virtual void SetOverRelief(int);
181  virtual int GetOverRelief();
182  virtual void SetOverReliefToRaised();
183  virtual void SetOverReliefToSunken();
184  virtual void SetOverReliefToFlat();
185  virtual void SetOverReliefToRidge();
186  virtual void SetOverReliefToSolid();
187  virtual void SetOverReliefToGroove();
188  virtual void SetOverReliefToNone();
189 
190  // Description:
191  // Specifies the font to use when drawing text inside the widget.
192  // You can use predefined font names (e.g. 'system'), or you can specify
193  // a set of font attributes with a platform-independent name, for example,
194  // 'times 12 bold'. In this example, the font is specified with a three
195  // element list: the first element is the font family, the second is the
196  // size, the third is a list of style parameters (normal, bold, roman,
197  // italic, underline, overstrike). Example: 'times 12 {bold italic}'.
198  // The Times, Courier and Helvetica font families are guaranteed to exist
199  // and will be matched to the corresponding (closest) font on your system.
200  // If you are familiar with the X font names specification, you can also
201  // describe the font that way (say, '*times-medium-r-*-*-12*').
202  virtual void SetFont(const char *font);
203  virtual const char* GetFont();
204 
205  // Description:
206  // Specifies an image to display in the widget. Typically, if the image
207  // is specified then it overrides other options that specify a bitmap or
208  // textual value to display in the widget. Invoke vtkKWWidget's
209  // SetConfigurationOption("-image", imagename) to use a specific
210  // pre-existing Tk image, or call one of the following functions:
211  // The SetImageToPredefinedIcon method accepts an index to one of the
212  // predefined icon listed in vtkKWIcon.
213  // The SetImageToPixels method sets the image using pixel data. It expects
214  // a pointer to the pixels and the structure of the image, i.e. its width,
215  // height and the pixel_size (how many bytes per pixel, say 3 for RGB, or
216  // 1 for grayscale). If buffer_length = 0, it is computed automatically
217  // from the previous parameters. If it is not, it will most likely indicate
218  // that the buffer has been encoded using base64 and/or zlib.
219  // If pixel_size > 3 (i.e. RGBA), the image is blend the with background
220  // color of the widget.
221  // Check the SetCompoundMode method if you want to display both the
222  // image and the label at the same time.
223  virtual void SetImageToIcon(vtkKWIcon *icon);
224  virtual void SetImageToPredefinedIcon(int icon_index);
225  virtual void SetImageToPixels(
226  const unsigned char *pixels, int width, int height, int pixel_size,
227  unsigned long buffer_length = 0);
228 
229  // Description:
230  // Specifies if the widget should display text and bitmaps/images at the
231  // same time, and if so, where the bitmap/image should be placed relative
232  // to the text.
233  // Valid constants can be found in vtkKWOptions::CompoundModeType.
234  // The (default) value CompoundModeNone specifies that the bitmap or image
235  // should (if defined) be displayed instead of the text.
236  virtual void SetCompoundMode(int);
237  virtual int GetCompoundMode();
238  virtual void SetCompoundModeToNone();
239  virtual void SetCompoundModeToLeft();
240  virtual void SetCompoundModeToCenter();
241  virtual void SetCompoundModeToRight();
242  virtual void SetCompoundModeToTop();
243  virtual void SetCompoundModeToBottom();
244 
245  // Description:
246  // Update the "enable" state of the object and its internal parts.
247  // Depending on different Ivars (this->Enabled, the application's
248  // Limited Edition Mode, etc.), the "enable" state of the object is updated
249  // and propagated to its internal parts/subwidgets. This will, for example,
250  // enable/disable parts of the widget UI, enable/disable the visibility
251  // of 3D widgets, etc.
252  virtual void UpdateEnableState();
253 
254  // Description:
255  // Callbacks. Internal, do not use.
256  virtual void CommandCallback();
257 
258 protected:
259  vtkKWPushButton();
260  ~vtkKWPushButton();
261 
262  // Description:
263  // Create the widget.
264  virtual void CreateWidget();
265 
266  vtkSetStringMacro(ButtonText);
267  char* ButtonText;
268 
269  char *Command;
270  virtual void InvokeCommand();
271 
272 private:
273  vtkKWPushButton(const vtkKWPushButton&); // Not implemented
274  void operator=(const vtkKWPushButton&); // Not implemented
275 };
276 
277 
278 #endif
279 
280 
281