KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWColorSwatchesWidget.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 vtkKWColorSwatchesWidget - a color swatches widget. 00015 // .SECTION Description 00016 // This class displays a list of color swatches. 00017 // Different color swatches collections can be created independently. 00018 // .SECTION See Also 00019 // vtkKWColorPickerWidget 00020 00021 #ifndef __vtkKWColorSwatchesWidget_h 00022 #define __vtkKWColorSwatchesWidget_h 00023 00024 #include "vtkKWCompositeWidget.h" 00025 00026 class vtkKWColorSwatchesWidgetInternals; 00027 class vtkKWFrameSet; 00028 class vtkKWColorPresetSelector; 00029 00030 class KWWidgets_EXPORT vtkKWColorSwatchesWidget : public vtkKWCompositeWidget 00031 { 00032 public: 00033 static vtkKWColorSwatchesWidget* New(); 00034 vtkTypeRevisionMacro(vtkKWColorSwatchesWidget,vtkKWCompositeWidget); 00035 void PrintSelf(ostream& os, vtkIndent indent); 00036 00037 // Description: 00038 // Add a swatches collection (the name can not be empty) 00039 // Return unique ID (>= 0) of the collection, or -1 on error. 00040 virtual int AddCollection(const char *name); 00041 00042 // Description: 00043 // Remove a swatches collection given its ID, or all collections 00044 // Return 1 on success, 0 otherwise 00045 virtual int RemoveCollection(int collection_id); 00046 virtual void RemoveAllCollections(); 00047 00048 // Description: 00049 // Get the unique ID of a swatches collection given its name 00050 // Return -1 on error. 00051 virtual int GetCollectionId(const char *name); 00052 00053 // Description: 00054 // Add a swatch to a collection, given the unique ID of the collection, 00055 // the name of the swatch (can be empty) and its RGB value. 00056 // Return 1 on success, 0 on error. 00057 virtual int AddRGBSwatch( 00058 int collection_id, const char *name, double rgb[3]); 00059 virtual int AddRGBSwatch( 00060 int collection_id, const char *name, double r, double g, double b); 00061 00062 // Description: 00063 // Set/Get the swatches representation. 00064 //BTX 00065 enum 00066 { 00067 RepresentationFrames = 0, 00068 RepresentationList = 1 00069 }; 00070 //ETX 00071 virtual void SetSwatchesRepresentation(int); 00072 vtkGetMacro(SwatchesRepresentation, int); 00073 virtual void SetSwatchesRepresentationToFrames(); 00074 virtual void SetSwatchesRepresentationToList(); 00075 00076 // Description: 00077 // Set/Get the swatch size in pixels. 00078 // Only relevant if SwatchesRepresentation is RepresentationFrames. 00079 vtkGetMacro(SwatchSize, int); 00080 virtual void SetSwatchSize(int); 00081 00082 // Description: 00083 // Set/Get the maximum number of swatches packed horizontally (per row). 00084 // Only relevant if SwatchesRepresentation is RepresentationFrames. 00085 virtual void SetMaximumNumberOfSwatchesPerRow(int); 00086 virtual int GetMaximumNumberOfSwatchesPerRow(); 00087 00088 // Description: 00089 // Set/Get the padding between each swatch. 00090 // Only relevant if SwatchesRepresentation is RepresentationFrames. 00091 virtual void SetSwatchesPadding(int); 00092 virtual int GetSwatchesPadding(); 00093 00094 // Description: 00095 // Get the internal color swatches preset list 00096 virtual vtkKWColorPresetSelector* GetSwatchesColorPresetSelector(); 00097 00098 // Description: 00099 // Create the default collections 00100 virtual void AddDefaultCollections(); 00101 00102 // Description: 00103 // Specifies a command to associate with the widget. This command is 00104 // invoked when a swatch is selected. 00105 // The 'object' argument is the object that will have the method called on 00106 // it. The 'method' argument is the name of the method to be called and any 00107 // arguments in string form. If the object is NULL, the method is still 00108 // evaluated as a simple command. 00109 // The following parameters are also passed to the command: 00110 // - swatch rgb value: double r, double g, double b 00111 virtual void SetSwatchSelectedCommand(vtkObject *object, const char *method); 00112 00113 // Description: 00114 // Callbacks. Internal, do not use. 00115 virtual void SwatchSelectedCallback(double r, double g, double b); 00116 virtual void CollectionSelectedCallback(const char*); 00117 virtual void PopulateCollectionsCallback(); 00118 virtual void PopulateSwatchesCallback(); 00119 virtual void SwatchesColorPresetApplyCallback(int id); 00120 00121 // Description: 00122 // Update the "enable" state of the object and its internal parts. 00123 // Depending on different Ivars (this->Enabled, the application's 00124 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00125 // and propagated to its internal parts/subwidgets. This will, for example, 00126 // enable/disable parts of the widget UI, enable/disable the visibility 00127 // of 3D widgets, etc. 00128 virtual void UpdateEnableState(); 00129 00130 protected: 00131 vtkKWColorSwatchesWidget(); 00132 ~vtkKWColorSwatchesWidget(); 00133 00134 // Description: 00135 // Create the widget. 00136 virtual void CreateWidget(); 00137 00138 // Description: 00139 // Callbacks. Internal, do not use. 00140 char *SwatchSelectedCommand; 00141 virtual void InvokeSwatchSelectedCommand(double r, double g, double b); 00142 00143 // Description: 00144 // Populate the swatches frame and collectio combo 00145 virtual void PopulateCollections(); 00146 virtual void PopulateSwatches(); 00147 virtual void PopulateSwatchesAsFrames(); 00148 virtual void PopulateSwatchesAsList(); 00149 virtual void SchedulePopulateCollections(); 00150 virtual void SchedulePopulateSwatches(); 00151 00152 // Description: 00153 // Pack 00154 virtual void Pack(); 00155 00156 int SwatchSize; 00157 int SwatchesRepresentation; 00158 vtkKWColorSwatchesWidgetInternals *Internals; 00159 00160 private: 00161 vtkKWColorSwatchesWidget(const vtkKWColorSwatchesWidget&); // Not implemented 00162 void operator=(const vtkKWColorSwatchesWidget&); // Not Implemented 00163 }; 00164 00165 #endif 00166