-
Notifications
You must be signed in to change notification settings - Fork 3
/
vtkKWCheckButton.h
355 lines (312 loc) · 14.9 KB
/
vtkKWCheckButton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*=========================================================================
Module: $RCSfile: vtkKWCheckButton.h,v $
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkKWCheckButton - check button widget
// .SECTION Description
// A simple widget that represents a check button. It can be modified
// and queried using the GetSelectedState and SetSelectedState methods.
#ifndef __vtkKWCheckButton_h
#define __vtkKWCheckButton_h
#include "vtkKWCoreWidget.h"
class vtkKWIcon;
class KWWidgets_EXPORT vtkKWCheckButton : public vtkKWCoreWidget
{
public:
static vtkKWCheckButton* New();
vtkTypeRevisionMacro(vtkKWCheckButton,vtkKWCoreWidget);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get/Toggle the selected state of the check button 0 = off 1 = on
virtual void SetSelectedState(int );
virtual int GetSelectedState();
vtkBooleanMacro(SelectedState, int);
virtual void ToggleSelectedState();
virtual void Select() { this->SetSelectedState(1); };
virtual void Deselect() { this->SetSelectedState(0); };
// Description:
// Tell the widget whether it should use an indicator (check box)
virtual void SetIndicatorVisibility(int ind);
vtkGetMacro(IndicatorVisibility, int);
vtkBooleanMacro(IndicatorVisibility, int);
// Description:
// Set the text.
virtual void SetText(const char* txt);
virtual const char* GetText();
// Description:
// Set the variable name.
// Important: note that this will *not* copy over the previous variable
// value to the new one.
vtkGetStringMacro(VariableName);
virtual void SetVariableName(const char *);
// Description:
// Specifies a command to associate with the widget. This command is
// typically invoked when the button is selected or deselected.
// The 'object' argument is the object that will have the method called on
// it. The 'method' argument is the name of the method to be called and any
// arguments in string form. If the object is NULL, the method is still
// evaluated as a simple command.
// The following parameters are also passed to the command:
// - current selected state: int
virtual void SetCommand(vtkObject *object, const char *method);
// Description:
// Events. The SelectedStateChangedEvent is triggered when the button
// is selected or deselected.
// The following parameters are also passed as client data:
// - the current selected state: int
//BTX
enum
{
SelectedStateChangedEvent = 10000
};
//ETX
// Description:
// Set/Get the background color of the widget.
virtual void GetBackgroundColor(double *r, double *g, double *b);
virtual double* GetBackgroundColor();
virtual void SetBackgroundColor(double r, double g, double b);
virtual void SetBackgroundColor(double rgb[3])
{ this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the foreground color of the widget.
virtual void GetForegroundColor(double *r, double *g, double *b);
virtual double* GetForegroundColor();
virtual void SetForegroundColor(double r, double g, double b);
virtual void SetForegroundColor(double rgb[3])
{ this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the highlight thickness, a non-negative value indicating the
// width of the highlight rectangle to draw around the outside of the
// widget when it has the input focus.
virtual void SetHighlightThickness(int);
virtual int GetHighlightThickness();
// Description:
// Set/Get the active background color of the widget. An element
// (a widget or portion of a widget) is active if the mouse cursor is
// positioned over the element and pressing a mouse button will cause some
// action to occur.
virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
virtual double* GetActiveBackgroundColor();
virtual void SetActiveBackgroundColor(double r, double g, double b);
virtual void SetActiveBackgroundColor(double rgb[3])
{ this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the active foreground color of the widget. An element
// (a widget or portion of a widget) is active if the mouse cursor is
// positioned over the element and pressing a mouse button will cause some
// action to occur.
virtual void GetActiveForegroundColor(double *r, double *g, double *b);
virtual double* GetActiveForegroundColor();
virtual void SetActiveForegroundColor(double r, double g, double b);
virtual void SetActiveForegroundColor(double rgb[3])
{ this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the foreground color of the widget when it is disabled.
virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
virtual double* GetDisabledForegroundColor();
virtual void SetDisabledForegroundColor(double r, double g, double b);
virtual void SetDisabledForegroundColor(double rgb[3])
{ this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the border width, a non-negative value indicating the width of
// the 3-D border to draw around the outside of the widget (if such a border
// is being drawn; the Relief option typically determines this).
virtual void SetBorderWidth(int);
virtual int GetBorderWidth();
// Description:
// Set/Get the 3-D effect desired for the widget.
// The value indicates how the interior of the widget should appear
// relative to its exterior.
// Valid constants can be found in vtkKWOptions::ReliefType.
virtual void SetRelief(int);
virtual int GetRelief();
virtual void SetReliefToRaised();
virtual void SetReliefToSunken();
virtual void SetReliefToFlat();
virtual void SetReliefToRidge();
virtual void SetReliefToSolid();
virtual void SetReliefToGroove();
// Description:
// Set/Get the padding that will be applied around each widget (in pixels).
// Specifies a non-negative value indicating how much extra space to request
// for the widget in the X and Y-direction. When computing how large a
// window it needs, the widget will add this amount to the width it would
// normally need (as determined by the width of the things displayed
// in the widget); if the geometry manager can satisfy this request, the
// widget will end up with extra internal space around what it displays
// inside.
virtual void SetPadX(int);
virtual int GetPadX();
virtual void SetPadY(int);
virtual int GetPadY();
// Description:
// Set/Get the anchoring.
// Specifies how the information in a widget (e.g. text or a bitmap) is to
// be displayed in the widget.
// Valid constants can be found in vtkKWOptions::AnchorType.
virtual void SetAnchor(int);
virtual int GetAnchor();
virtual void SetAnchorToNorth();
virtual void SetAnchorToNorthEast();
virtual void SetAnchorToEast();
virtual void SetAnchorToSouthEast();
virtual void SetAnchorToSouth();
virtual void SetAnchorToSouthWest();
virtual void SetAnchorToWest();
virtual void SetAnchorToNorthWest();
virtual void SetAnchorToCenter();
// Description:
// Set/Get the 3-D effect desired for the widget.
// Specifies the relief for the button when the indicator is not drawn
// (i.e. IndicatorVisibility is Off) and the button is not selected.
// The default value is Raised. By setting this option to Flat and setting
// IndicatorVisibility to Off and OverRelief to Raised or Flat, the effect
// is achieved of having a flat button that raises on mouse-over and which
// is depressed when activated. This is the behavior typically exhibited by
// the Bold, Italic, and Underline checkbuttons on the toolbar of a
// word-processor, for example.
// Valid constants can be found in vtkKWOptions::ReliefType.
virtual void SetOffRelief(int);
virtual int GetOffRelief();
virtual void SetOffReliefToRaised();
virtual void SetOffReliefToSunken();
virtual void SetOffReliefToFlat();
virtual void SetOffReliefToRidge();
virtual void SetOffReliefToSolid();
virtual void SetOffReliefToGroove();
// Description:
// Set/Get the 3-D effect desired for the widget.
// Specifies an alternative relief for the button, to be used when the mouse
// cursor is over the widget. This option can be used to make toolbar
// buttons, by configuring SetRelief to Flat and OverRelief to Raised.
// Valid constants can be found in vtkKWOptions::ReliefType.
// If the value of this option is None, then no alternative relief is used
// when the mouse cursor is over the checkbutton.
virtual void SetOverRelief(int);
virtual int GetOverRelief();
virtual void SetOverReliefToRaised();
virtual void SetOverReliefToSunken();
virtual void SetOverReliefToFlat();
virtual void SetOverReliefToRidge();
virtual void SetOverReliefToSolid();
virtual void SetOverReliefToGroove();
virtual void SetOverReliefToNone();
// Description:
// Specifies the font to use when drawing text inside the widget.
// You can use predefined font names (e.g. 'system'), or you can specify
// a set of font attributes with a platform-independent name, for example,
// 'times 12 bold'. In this example, the font is specified with a three
// element list: the first element is the font family, the second is the
// size, the third is a list of style parameters (normal, bold, roman,
// italic, underline, overstrike). Example: 'times 12 {bold italic}'.
// The Times, Courier and Helvetica font families are guaranteed to exist
// and will be matched to the corresponding (closest) font on your system.
// If you are familiar with the X font names specification, you can also
// describe the font that way (say, '*times-medium-r-*-*-12*').
virtual void SetFont(const char *font);
virtual const char* GetFont();
// Description:
// Specifies an image to display in the widget. Typically, if the image
// is specified then it overrides other options that specify a bitmap or
// textual value to display in the widget. Invoke vtkKWWidget's
// SetConfigurationOption("-image", imagename) to use a specific
// pre-existing Tk image, or call one of the following functions:
// The SetImageToPredefinedIcon method accepts an index to one of the
// predefined icon listed in vtkKWIcon.
// The SetImageToPixels method sets the image using pixel data. It expects
// a pointer to the pixels and the structure of the image, i.e. its width,
// height and the pixel_size (how many bytes per pixel, say 3 for RGB, or
// 1 for grayscale). If buffer_length = 0, it is computed automatically
// from the previous parameters. If it is not, it will most likely indicate
// that the buffer has been encoded using base64 and/or zlib.
// If pixel_size > 3 (i.e. RGBA), the image is blend the with background
// color of the widget.
// Check the SetCompoundMode method if you want to display both the
// image and the label at the same time.
virtual void SetImageToIcon(vtkKWIcon *icon);
virtual void SetImageToPredefinedIcon(int icon_index);
virtual void SetImageToPixels(
const unsigned char *pixels, int width, int height, int pixel_size,
unsigned long buffer_length = 0);
// Description:
// Specifies an image to display in the widget when the button is selected.
// This option is ignored unless an image has been set for the unselected
// state of the button already (see SetImageToIcon).
// Typically, if the image is specified then it overrides other options that
// specify a bitmap or textual value to display in the widget.
// Invoke vtkKWWidget's SetConfigurationOption("-selectimage", imagename)
// to use a specific pre-existing Tk image, or call one of the following
// functions:
// The SetSelectImageToPredefinedIcon method accepts an index to one of the
// predefined icon listed in vtkKWIcon.
// The SetSelectImageToPixels method sets the image using pixel data. It
// expects a pointer to the pixels and the structure of the image, i.e. its
// width, height and the pixel_size (how many bytes per pixel, say 3 for RGB,
// or 1 for grayscale). If buffer_length = 0, it is computed automatically
// from the previous parameters. If it is not, it will most likely indicate
// that the buffer has been encoded using base64 and/or zlib.
// If pixel_size > 3 (i.e. RGBA), the image is blend the with background
// color of the widget.
// Check the SetCompoundMode method if you want to display both the
// image and the label at the same time.
virtual void SetSelectImageToIcon(vtkKWIcon *icon);
virtual void SetSelectImageToPredefinedIcon(int icon_index);
virtual void SetSelectImageToPixels(
const unsigned char *pixels, int width, int height, int pixel_size,
unsigned long buffer_length = 0);
// Description:
// Specifies if the widget should display text and bitmaps/images at the
// same time, and if so, where the bitmap/image should be placed relative
// to the text.
// Valid constants can be found in vtkKWOptions::CompoundModeType.
// The (default) value CompoundModeNone specifies that the bitmap or image
// should (if defined) be displayed instead of the text.
virtual void SetCompoundMode(int);
virtual int GetCompoundMode();
virtual void SetCompoundModeToNone();
virtual void SetCompoundModeToLeft();
virtual void SetCompoundModeToCenter();
virtual void SetCompoundModeToRight();
virtual void SetCompoundModeToTop();
virtual void SetCompoundModeToBottom();
// Description:
// Set/Get the background color to use when the widget is selected.
virtual void GetSelectColor(double *r, double *g, double *b);
virtual double* GetSelectColor();
virtual void SetSelectColor(double r, double g, double b);
virtual void SetSelectColor(double rgb[3])
{ this->SetSelectColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Update the "enable" state of the object and its internal parts.
// Depending on different Ivars (this->Enabled, the application's
// Limited Edition Mode, etc.), the "enable" state of the object is updated
// and propagated to its internal parts/subwidgets. This will, for example,
// enable/disable parts of the widget UI, enable/disable the visibility
// of 3D widgets, etc.
virtual void UpdateEnableState();
// Description:
// Callbacks. Internal, do not use.
virtual void CommandCallback();
protected:
// Description:
// Create the widget.
virtual void CreateWidget();
vtkSetStringMacro(InternalText);
vtkKWCheckButton();
~vtkKWCheckButton();
int IndicatorVisibility;
char *InternalText;
char *VariableName;
virtual void Configure();
char *Command;
virtual void InvokeCommand(int state);
private:
vtkKWCheckButton(const vtkKWCheckButton&); // Not implemented
void operator=(const vtkKWCheckButton&); // Not Implemented
};
#endif