forked from FNNDSC/KWWidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkKWChangeColorButton.h
151 lines (119 loc) · 4.81 KB
/
vtkKWChangeColorButton.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
/*=========================================================================
Module: $RCSfile: vtkKWChangeColorButton.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 vtkKWChangeColorButton - a button for selecting colors
// .SECTION Description
// A button that can be pressed to select a color.
// Note: As a subclass of vtkKWWidgetWithLabel, it inherits a label and methods
// to set its position and visibility. Note that the default label position
// implemented in this class is on the left of the color label. Only a subset
// of the specific positions listed in vtkKWWidgetWithLabel is supported: on
// Left, and on Right of the color label.
// .SECTION See Also
// vtkKWWidgetWithLabel
#ifndef __vtkKWChangeColorButton_h
#define __vtkKWChangeColorButton_h
#include "vtkKWWidgetWithLabel.h"
class vtkKWFrame;
class KWWidgets_EXPORT vtkKWChangeColorButton : public vtkKWWidgetWithLabel
{
public:
static vtkKWChangeColorButton* New();
vtkTypeMacro(vtkKWChangeColorButton,vtkKWWidgetWithLabel);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get the current color (RGB space)
virtual void SetColor(double c[3]) {this->SetColor(c[0], c[1], c[2]);};
virtual void SetColor(double r, double g, double b);
virtual double *GetColor() {return this->Color;};
// Description:
// Set the text that will be used on the title of the color selection dialog.
vtkSetStringMacro(DialogTitle);
vtkGetStringMacro(DialogTitle);
// Description:
// Set the command that is called when the color is changed.
// 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:
// - selected RGB color: double, double, double
virtual void SetCommand(vtkObject *object, const char *method);
// Description:
// Events. The ColorChangedEvent is triggered when the color of the button
// is changed. It is similar in concept to the 'Command' callback but can be
// used by multiple listeners/observers at a time.
// The following parameters are also passed as client data:
// - the current RGB color value: double[3]
//BTX
enum
{
ColorChangedEvent = 1000
};
//ETX
// Description:
// Set the string that enables balloon help for this widget.
// Override to pass down to children.
virtual void SetBalloonHelpString(const char *str);
// Description:
// Set the label to be outside the color button. Default is inside.
virtual void SetLabelOutsideButton(int);
vtkGetMacro(LabelOutsideButton, int);
vtkBooleanMacro(LabelOutsideButton, int);
// 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 ButtonPressCallback();
virtual void ButtonReleaseCallback();
protected:
vtkKWChangeColorButton();
~vtkKWChangeColorButton();
// Description:
// Create the widget.
virtual void CreateWidget();
vtkKWLabel *ColorButton;
vtkKWFrame *ButtonFrame;
virtual void InvokeCommand(double r, double g, double b);
char *Command;
char *DialogTitle;
double Color[3];
int LabelOutsideButton;
// Description:
// Add/Remove interaction bindings
virtual void Bind();
virtual void UnBind();
// Description:
// Update the color of the button given the current color, or use
// a 'disabled' color if the object is disabled.
virtual void UpdateColorButton();
// Description:
// Query user for color
virtual void QueryUserForColor();
// Description:
// Pack or repack the widget
virtual void Pack();
// Description:
// Create the label (override the superclass)
virtual void CreateLabel();
// Description:
// Create the button frame
virtual void CreateButtonFrame();
private:
int ButtonDown;
vtkKWChangeColorButton(const vtkKWChangeColorButton&); // Not implemented
void operator=(const vtkKWChangeColorButton&); // Not implemented
};
#endif