00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWListBox.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 vtkKWListBox - List Box 00015 // .SECTION Description 00016 // A widget that can have a list of items. 00017 // Use vtkKWListBoxWithScrollbars if you need scrollbars. 00018 // .SECTION See Also 00019 // vtkKWListBoxWithScrollbars 00020 00021 #ifndef __vtkKWListBox_h 00022 #define __vtkKWListBox_h 00023 00024 #include "vtkKWCoreWidget.h" 00025 00026 class KWWidgets_EXPORT vtkKWListBox : public vtkKWCoreWidget 00027 { 00028 public: 00029 static vtkKWListBox* New(); 00030 vtkTypeRevisionMacro(vtkKWListBox,vtkKWCoreWidget); 00031 void PrintSelf(ostream& os, vtkIndent indent); 00032 00033 // Description: 00034 // Set/Get the background color of the widget. 00035 virtual void GetBackgroundColor(double *r, double *g, double *b); 00036 virtual double* GetBackgroundColor(); 00037 virtual void SetBackgroundColor(double r, double g, double b); 00038 virtual void SetBackgroundColor(double rgb[3]) 00039 { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00040 00041 // Description: 00042 // Set/Get the foreground color of the widget. 00043 virtual void GetForegroundColor(double *r, double *g, double *b); 00044 virtual double* GetForegroundColor(); 00045 virtual void SetForegroundColor(double r, double g, double b); 00046 virtual void SetForegroundColor(double rgb[3]) 00047 { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00048 00049 // Description: 00050 // Set/Get the foreground color of the widget when it is disabled. 00051 virtual void GetDisabledForegroundColor(double *r, double *g, double *b); 00052 virtual double* GetDisabledForegroundColor(); 00053 virtual void SetDisabledForegroundColor(double r, double g, double b); 00054 virtual void SetDisabledForegroundColor(double rgb[3]) 00055 { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00056 00057 // Description: 00058 // Set/Get the highlight thickness, a non-negative value indicating the 00059 // width of the highlight rectangle to draw around the outside of the 00060 // widget when it has the input focus. 00061 virtual void SetHighlightThickness(int); 00062 virtual int GetHighlightThickness(); 00063 00064 // Description: 00065 // Set/Get the border width, a non-negative value indicating the width of 00066 // the 3-D border to draw around the outside of the widget (if such a border 00067 // is being drawn; the Relief option typically determines this). 00068 virtual void SetBorderWidth(int); 00069 virtual int GetBorderWidth(); 00070 00071 // Description: 00072 // Set/Get the 3-D effect desired for the widget. 00073 // The value indicates how the interior of the widget should appear 00074 // relative to its exterior. 00075 // Valid constants can be found in vtkKWOptions::ReliefType. 00076 virtual void SetRelief(int); 00077 virtual int GetRelief(); 00078 virtual void SetReliefToRaised(); 00079 virtual void SetReliefToSunken(); 00080 virtual void SetReliefToFlat(); 00081 virtual void SetReliefToRidge(); 00082 virtual void SetReliefToSolid(); 00083 virtual void SetReliefToGroove(); 00084 00085 // Description: 00086 // Specifies the font to use when drawing text inside the widget. 00087 // You can use predefined font names (e.g. 'system'), or you can specify 00088 // a set of font attributes with a platform-independent name, for example, 00089 // 'times 12 bold'. In this example, the font is specified with a three 00090 // element list: the first element is the font family, the second is the 00091 // size, the third is a list of style parameters (normal, bold, roman, 00092 // italic, underline, overstrike). Example: 'times 12 {bold italic}'. 00093 // The Times, Courier and Helvetica font families are guaranteed to exist 00094 // and will be matched to the corresponding (closest) font on your system. 00095 // If you are familiar with the X font names specification, you can also 00096 // describe the font that way (say, '*times-medium-r-*-*-12*'). 00097 virtual void SetFont(const char *font); 00098 virtual const char* GetFont(); 00099 00100 // Description: 00101 // Set/Get the one of several styles for manipulating the selection. 00102 // Valid constants can be found in vtkKWOptions::SelectionModeType. 00103 virtual void SetSelectionMode(int); 00104 virtual int GetSelectionMode(); 00105 virtual void SetSelectionModeToSingle(); 00106 virtual void SetSelectionModeToBrowse(); 00107 virtual void SetSelectionModeToMultiple(); 00108 virtual void SetSelectionModeToExtended(); 00109 00110 // Description: 00111 // Specifies whether or not a selection in the widget should also be the X 00112 // selection. If the selection is exported, then selecting in the widget 00113 // deselects the current X selection, selecting outside the widget deselects 00114 // any widget selection, and the widget will respond to selection retrieval 00115 // requests when it has a selection. 00116 virtual void SetExportSelection(int); 00117 virtual int GetExportSelection(); 00118 vtkBooleanMacro(ExportSelection, int); 00119 00120 // Description: 00121 // Get the current selected string in the list. This is used when 00122 // Select mode is single or browse. 00123 virtual const char *GetSelection(); 00124 virtual int GetSelectionIndex(); 00125 virtual void SetSelectionIndex(int); 00126 00127 // Description: 00128 // When selectmode is multiple or extended, then these methods can 00129 // be used to set and query the selection. 00130 virtual void SetSelectState(int idx, int state); 00131 virtual int GetSelectState(int idx); 00132 00133 // Description: 00134 // Add an entry. 00135 virtual void InsertEntry(int index, const char *name); 00136 00137 // Description: 00138 // Append a unique string to the list. If the string exists, 00139 // it will not be appended 00140 virtual int AppendUnique(const char* name); 00141 00142 // Description: 00143 // Append a string to the list. This call does not check if the string 00144 // is unique. 00145 virtual int Append(const char* name); 00146 00147 // Description: 00148 // Specifies a command to be invoked when an element is selected/deselected 00149 // in the widget. Re-selecting an element will trigger this command too. 00150 // The 'object' argument is the object that will have the method called on 00151 // it. The 'method' argument is the name of the method to be called and any 00152 // arguments in string form. If the object is NULL, the method is still 00153 // evaluated as a simple command. 00154 virtual void SetSelectionCommand(vtkObject *object, const char *method); 00155 00156 // Description: 00157 // Specifies a command to be invoked when the user single-click or 00158 // double-click in the listbox. This does *not* imply the selection changed 00159 // though (use SetSelectionCommand instead). 00160 // The 'object' argument is the object that will have the method called on 00161 // it. The 'method' argument is the name of the method to be called and any 00162 // arguments in string form. If the object is NULL, the method is still 00163 // evaluated as a simple command. 00164 // Set callback for single and double click on a list item. 00165 virtual void SetDoubleClickCommand(vtkObject *obj, const char *method); 00166 virtual void SetSingleClickCommand(vtkObject *obj, const char *method); 00167 00168 // Description: 00169 // Events. The ListBoxSelectionChangedEvent is triggered when an element 00170 // is selected/deselected in the widget. Re-selecting an element will 00171 // trigger this event too. It is similar in concept as the 'SelectionCommand' 00173 //BTX 00174 enum 00175 { 00176 ListBoxSelectionChangedEvent = 10000 00177 }; 00178 //ETX 00179 00180 // Description: 00181 // Get number of items in the list. 00182 virtual int GetNumberOfItems(); 00183 00184 // Description: 00185 // Get the item at the given index. 00186 virtual const char* GetItem(int index); 00187 00188 // Description: 00189 // Returns the index of the first given item. 00190 virtual int GetItemIndex(const char* item); 00191 00192 // Description: 00193 // Delete a range of items in the list. 00194 virtual void DeleteRange(int start, int end); 00195 00196 // Description: 00197 // Delete all items from the list. 00198 virtual void DeleteAll(); 00199 00200 // Description: 00201 // Set the width of the list box. If the width is less than or equal to 0, 00202 // then the width is set to the size of the largest string. 00203 virtual void SetWidth(int); 00204 virtual int GetWidth(); 00205 00206 // Description: 00207 // Set the height of the list box. If the height is less than or equal to 0, 00208 // then the height is set to the size of the number of items in the listbox. 00209 virtual void SetHeight(int); 00210 virtual int GetHeight(); 00211 00212 // Description: 00213 // Update the "enable" state of the object and its internal parts. 00214 // Depending on different Ivars (this->Enabled, the application's 00215 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00216 // and propagated to its internal parts/subwidgets. This will, for example, 00217 // enable/disable parts of the widget UI, enable/disable the visibility 00218 // of 3D widgets, etc. 00219 virtual void UpdateEnableState(); 00220 00221 // Description: 00222 // Callbacks. Internal, do not use. 00223 virtual void SelectionCallback(); 00224 00225 protected: 00226 vtkKWListBox(); 00227 ~vtkKWListBox(); 00228 00229 // Description: 00230 // Create the widget. 00231 virtual void CreateWidget(); 00232 00233 char* CurrentSelection; // store last call of CurrentSelection 00234 char* Item; // store last call of GetItem 00235 00236 char *SelectionCommand; 00237 virtual void InvokeSelectionCommand(); 00238 00239 private: 00240 vtkKWListBox(const vtkKWListBox&); // Not implemented 00241 void operator=(const vtkKWListBox&); // Not implemented 00242 }; 00243 00244 00245 #endif 00246 00247 00248