00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWChangeColorButton.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 vtkKWChangeColorButton - a button for selecting colors 00015 // .SECTION Description 00016 // A button that can be pressed to select a color. 00017 // Note: As a subclass of vtkKWWidgetWithLabel, it inherits a label and methods 00018 // to set its position and visibility. Note that the default label position 00019 // implemented in this class is on the left of the color label. Only a subset 00020 // of the specific positions listed in vtkKWWidgetWithLabel is supported: on 00021 // Left, and on Right of the color label. 00022 // .SECTION See Also 00023 // vtkKWWidgetWithLabel 00024 00025 #ifndef __vtkKWChangeColorButton_h 00026 #define __vtkKWChangeColorButton_h 00027 00028 #include "vtkKWWidgetWithLabel.h" 00029 00030 class vtkKWFrame; 00031 00032 class KWWidgets_EXPORT vtkKWChangeColorButton : public vtkKWWidgetWithLabel 00033 { 00034 public: 00035 static vtkKWChangeColorButton* New(); 00036 vtkTypeRevisionMacro(vtkKWChangeColorButton,vtkKWWidgetWithLabel); 00037 void PrintSelf(ostream& os, vtkIndent indent); 00038 00039 // Description: 00040 // Set/Get the current color (RGB space) 00041 virtual void SetColor(double c[3]) {this->SetColor(c[0], c[1], c[2]);}; 00042 virtual void SetColor(double r, double g, double b); 00043 virtual double *GetColor() {return this->Color;}; 00044 00045 // Description: 00046 // Set the text that will be used on the title of the color selection dialog. 00047 vtkSetStringMacro(DialogTitle); 00048 vtkGetStringMacro(DialogTitle); 00049 00050 // Description: 00051 // Set the command that is called when the color is changed. 00052 // The 'object' argument is the object that will have the method called on 00053 // it. The 'method' argument is the name of the method to be called and any 00054 // arguments in string form. If the object is NULL, the method is still 00055 // evaluated as a simple command. 00056 // The following parameters are also passed to the command: 00057 // - selected RGB color: double, double, double 00058 virtual void SetCommand(vtkObject *object, const char *method); 00059 00060 // Description: 00061 // Events. The ColorChangedEvent is triggered when the color of the button 00062 // is changed. It is similar in concept to the 'Command' callback but can be 00063 // used by multiple listeners/observers at a time. 00064 // The following parameters are also passed as client data: 00065 // - the current RGB color value: double[3] 00066 //BTX 00067 enum 00068 { 00069 ColorChangedEvent = 1000 00070 }; 00071 //ETX 00072 00073 // Description: 00074 // Set the string that enables balloon help for this widget. 00075 // Override to pass down to children. 00076 virtual void SetBalloonHelpString(const char *str); 00077 00078 // Description: 00079 // Set the label to be outside the color button. Default is inside. 00080 virtual void SetLabelOutsideButton(int); 00081 vtkGetMacro(LabelOutsideButton, int); 00082 vtkBooleanMacro(LabelOutsideButton, int); 00083 00084 // Description: 00085 // Update the "enable" state of the object and its internal parts. 00086 // Depending on different Ivars (this->Enabled, the application's 00087 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00088 // and propagated to its internal parts/subwidgets. This will, for example, 00089 // enable/disable parts of the widget UI, enable/disable the visibility 00090 // of 3D widgets, etc. 00091 virtual void UpdateEnableState(); 00092 00093 // Description: 00094 // Callbacks. Internal, do not use. 00095 virtual void ButtonPressCallback(); 00096 virtual void ButtonReleaseCallback(); 00097 00098 protected: 00099 vtkKWChangeColorButton(); 00100 ~vtkKWChangeColorButton(); 00101 00102 // Description: 00103 // Create the widget. 00104 virtual void CreateWidget(); 00105 00106 vtkKWLabel *ColorButton; 00107 vtkKWFrame *ButtonFrame; 00108 00109 virtual void InvokeCommand(double r, double g, double b); 00110 char *Command; 00111 00112 char *DialogTitle; 00113 double Color[3]; 00114 int LabelOutsideButton; 00115 00116 // Description: 00117 // Add/Remove interaction bindings 00118 virtual void Bind(); 00119 virtual void UnBind(); 00120 00121 // Description: 00122 // Update the color of the button given the current color, or use 00123 // a 'disabled' color if the object is disabled. 00124 virtual void UpdateColorButton(); 00125 00126 // Description: 00127 // Query user for color 00128 virtual void QueryUserForColor(); 00129 00130 // Description: 00131 // Pack or repack the widget 00132 virtual void Pack(); 00133 00134 // Description: 00135 // Create the label (override the superclass) 00136 virtual void CreateLabel(); 00137 00138 // Description: 00139 // Create the button frame 00140 virtual void CreateButtonFrame(); 00141 00142 private: 00143 00144 int ButtonDown; 00145 00146 vtkKWChangeColorButton(const vtkKWChangeColorButton&); // Not implemented 00147 void operator=(const vtkKWChangeColorButton&); // Not implemented 00148 }; 00149 00150 #endif 00151