KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWChangeColorButton.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWChangeColorButton.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 vtkKWChangeColorButton - a button for selecting colors
15 // .SECTION Description
16 // A button that can be pressed to select a color.
17 // Note: As a subclass of vtkKWWidgetWithLabel, it inherits a label and methods
18 // to set its position and visibility. Note that the default label position
19 // implemented in this class is on the left of the color label. Only a subset
20 // of the specific positions listed in vtkKWWidgetWithLabel is supported: on
21 // Left, and on Right of the color label.
22 // .SECTION See Also
23 // vtkKWWidgetWithLabel
24 
25 #ifndef __vtkKWChangeColorButton_h
26 #define __vtkKWChangeColorButton_h
27 
28 #include "vtkKWWidgetWithLabel.h"
29 
30 class vtkKWFrame;
31 
33 {
34 public:
35  static vtkKWChangeColorButton* New();
37  void PrintSelf(ostream& os, vtkIndent indent);
38 
39  // Description:
40  // Set/Get the current color (RGB space)
41  virtual void SetColor(double c[3]) {this->SetColor(c[0], c[1], c[2]);};
42  virtual void SetColor(double r, double g, double b);
43  virtual double *GetColor() {return this->Color;};
44 
45  // Description:
46  // Set the text that will be used on the title of the color selection dialog.
47  vtkSetStringMacro(DialogTitle);
48  vtkGetStringMacro(DialogTitle);
49 
50  // Description:
51  // Set the command that is called when the color is changed.
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  // The following parameters are also passed to the command:
57  // - selected RGB color: double, double, double
58  virtual void SetCommand(vtkObject *object, const char *method);
59 
60  // Description:
61  // Events. The ColorChangedEvent is triggered when the color of the button
62  // is changed. It is similar in concept to the 'Command' callback but can be
63  // used by multiple listeners/observers at a time.
64  // The following parameters are also passed as client data:
65  // - the current RGB color value: double[3]
66  //BTX
67  enum
68  {
69  ColorChangedEvent = 1000
70  };
71  //ETX
72 
73  // Description:
74  // Set the string that enables balloon help for this widget.
75  // Override to pass down to children.
76  virtual void SetBalloonHelpString(const char *str);
77 
78  // Description:
79  // Set the label to be outside the color button. Default is inside.
80  virtual void SetLabelOutsideButton(int);
81  vtkGetMacro(LabelOutsideButton, int);
82  vtkBooleanMacro(LabelOutsideButton, int);
83 
84  // Description:
85  // Update the "enable" state of the object and its internal parts.
86  // Depending on different Ivars (this->Enabled, the application's
87  // Limited Edition Mode, etc.), the "enable" state of the object is updated
88  // and propagated to its internal parts/subwidgets. This will, for example,
89  // enable/disable parts of the widget UI, enable/disable the visibility
90  // of 3D widgets, etc.
91  virtual void UpdateEnableState();
92 
93  // Description:
94  // Callbacks. Internal, do not use.
95  virtual void ButtonPressCallback();
96  virtual void ButtonReleaseCallback();
97 
98 protected:
101 
102  // Description:
103  // Create the widget.
104  virtual void CreateWidget();
105 
108 
109  virtual void InvokeCommand(double r, double g, double b);
110  char *Command;
111 
112  char *DialogTitle;
113  double Color[3];
115 
116  // Description:
117  // Add/Remove interaction bindings
118  virtual void Bind();
119  virtual void UnBind();
120 
121  // Description:
122  // Update the color of the button given the current color, or use
123  // a 'disabled' color if the object is disabled.
124  virtual void UpdateColorButton();
125 
126  // Description:
127  // Query user for color
128  virtual void QueryUserForColor();
129 
130  // Description:
131  // Pack or repack the widget
132  virtual void Pack();
133 
134  // Description:
135  // Create the label (override the superclass)
136  virtual void CreateLabel();
137 
138  // Description:
139  // Create the button frame
140  virtual void CreateButtonFrame();
141 
142 private:
143 
144  int ButtonDown;
145 
146  vtkKWChangeColorButton(const vtkKWChangeColorButton&); // Not implemented
147  void operator=(const vtkKWChangeColorButton&); // Not implemented
148 };
149 
150 #endif
151