KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWListBoxToListBoxSelectionEditor.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 vtkKWListBoxToListBoxSelectionEditor - a composite dual-listbox selection editor 00015 // .SECTION Description 00016 // This composite widget is used to manage a selection of text entries between 00017 // two listboxes. The source listbox lists the available elements that can 00018 // be add/removed/sorted to form a selection inside a target/final listbox. 00019 00020 #ifndef __vtkKWListBoxToListBoxSelectionEditor_h 00021 #define __vtkKWListBoxToListBoxSelectionEditor_h 00022 00023 #include "vtkKWCompositeWidget.h" 00024 00025 class vtkKWListBoxWithScrollbarsWithLabel; 00026 class vtkKWPushButton; 00027 class vtkKWListBox; 00028 class vtkKWFrame; 00029 00030 class KWWidgets_EXPORT vtkKWListBoxToListBoxSelectionEditor : public vtkKWCompositeWidget 00031 { 00032 public: 00033 static vtkKWListBoxToListBoxSelectionEditor* New(); 00034 vtkTypeRevisionMacro(vtkKWListBoxToListBoxSelectionEditor,vtkKWCompositeWidget); 00035 void PrintSelf(ostream& os, vtkIndent indent); 00036 00037 // Description: 00038 // Add/Remove a string element to the source list if it is not already 00039 // there or on the final list. The optional argument force will make sure 00040 // the item is added to the source list and removed from final if it is 00041 // already there. 00042 virtual void AddSourceElement(const char*, int force = 0); 00043 virtual void RemoveSourceElement(int indx); 00044 00045 // Description: 00046 // Add/remove a string element to the final list if it is not already there 00047 // or on the final list. The optional argument force will make sure the item 00048 // is added to the final list and removed from source if it is already there. 00049 virtual void AddFinalElement(const char*, int force = 0); 00050 virtual void RemoveFinalElement(int index); 00051 00052 // Description: 00053 // Get the number of elements on the final list. 00054 virtual int GetNumberOfElementsOnSourceList(); 00055 virtual int GetNumberOfElementsOnFinalList(); 00056 00057 // Description: 00058 // Get the element from the list. 00059 virtual const char* GetElementFromSourceList(int idx); 00060 virtual const char* GetElementFromFinalList(int idx); 00061 00062 // Description: 00063 // Get the index of the item. 00064 virtual int GetElementIndexFromSourceList(const char* element); 00065 virtual int GetElementIndexFromFinalList(const char* element); 00066 00067 // Description: 00068 // Remove items from the list. 00069 virtual void RemoveItemsFromSourceList(); 00070 virtual void RemoveItemsFromFinalList(); 00071 00072 // Description: 00073 // Get the listbox objects. 00074 vtkGetObjectMacro(SourceList, vtkKWListBoxWithScrollbarsWithLabel); 00075 vtkGetObjectMacro(FinalList, vtkKWListBoxWithScrollbarsWithLabel); 00076 00077 // Description: 00078 // Specifies a command to associate with the widget. This command is 00079 // typically invoked when the ellipsis button is pressed. 00080 // The 'object' argument is the object that will have the method called on 00081 // it. The 'method' argument is the name of the method to be called and any 00082 // arguments in string form. If the object is NULL, the method is still 00083 // evaluated as a simple command. 00084 virtual void SetEllipsisCommand(vtkObject *obj, const char *method); 00085 00086 // Description: 00087 // Specifies a command to associate with the widget. This command is 00088 // typically invoked when the values in the FinalList are changed. 00089 // The 'object' argument is the object that will have the method called on 00090 // it. The 'method' argument is the name of the method to be called and any 00091 // arguments in string form. If the object is NULL, the method is still 00092 // evaluated as a simple command. 00093 virtual void SetFinalListChangedCommand(vtkObject *obj, const char *method); 00094 00095 // Description: 00096 // Events. The FinalListChangedEvent is triggered when the values in the 00097 // FinalList are changed. 00098 //BTX 00099 enum 00100 { 00101 FinalListChangedEvent = 10000 00102 }; 00103 //ETX 00104 00105 // Description: 00106 // Update the "enable" state of the object and its internal parts. 00107 // Depending on different Ivars (this->Enabled, the application's 00108 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00109 // and propagated to its internal parts/subwidgets. This will, for example, 00110 // enable/disable parts of the widget UI, enable/disable the visibility 00111 // of 3D widgets, etc. 00112 virtual void UpdateEnableState(); 00113 virtual void Update(); 00114 00115 // Descrition: 00116 // Set/Get whether the widget should allow reordering 00117 // or the final list with the Up/Down buttons. 00118 //BTX 00119 virtual void SetAllowReordering(int); 00120 vtkBooleanMacro(AllowReordering, int); 00121 vtkGetMacro(AllowReordering, int); 00122 //ETX 00123 00124 // Description: 00125 // Callbacks. Internal, do not use. 00126 virtual void AddCallback(); 00127 virtual void AddAllCallback(); 00128 virtual void RemoveCallback(); 00129 virtual void RemoveAllCallback(); 00130 virtual void UpCallback(); 00131 virtual void DownCallback(); 00132 virtual void EllipsisCallback(); 00133 virtual void SourceSelectionChangedCallback(); 00134 virtual void FinalSelectionChangedCallback(); 00135 00136 protected: 00137 vtkKWListBoxToListBoxSelectionEditor(); 00138 ~vtkKWListBoxToListBoxSelectionEditor(); 00139 00140 // Description: 00141 // Create the widget. 00142 virtual void CreateWidget(); 00143 00144 // Description: 00145 // Pack the widget 00146 virtual void Pack(); 00147 00148 vtkKWListBoxWithScrollbarsWithLabel* SourceList; 00149 vtkKWListBoxWithScrollbarsWithLabel* FinalList; 00150 00151 vtkKWPushButton* AddButton; 00152 vtkKWPushButton* AddAllButton; 00153 vtkKWPushButton* RemoveButton; 00154 vtkKWPushButton* RemoveAllButton; 00155 vtkKWPushButton* UpButton; 00156 vtkKWPushButton* DownButton; 00157 vtkKWFrame* ButtonFrame; 00158 00159 virtual void MoveWholeList(vtkKWListBox* l1, vtkKWListBox* l2); 00160 virtual void MoveSelectedList(vtkKWListBox* l1, vtkKWListBox* l2); 00161 virtual void MoveList(vtkKWListBox* l1, vtkKWListBox* l2, const char* list); 00162 virtual void ShiftItems(vtkKWListBox* l1, int down); 00163 virtual void AddElement( 00164 vtkKWListBox* l1, vtkKWListBox* l2, const char* element, int force); 00165 00166 char* EllipsisCommand; 00167 char* FinalListChangedCommand; 00168 virtual void InvokeEllipsisCommand(); 00169 virtual void InvokeFinalListChangedCommand(); 00170 00171 int EllipsisDisplayed; 00172 int AllowReordering; 00173 00174 virtual void DisplayEllipsis(); 00175 virtual void RemoveEllipsis(); 00176 00177 private: 00178 vtkKWListBoxToListBoxSelectionEditor(const vtkKWListBoxToListBoxSelectionEditor&); // Not implemented 00179 void operator=(const vtkKWListBoxToListBoxSelectionEditor&); // Not Implemented 00180 }; 00181 00182 00183 #endif 00184 00185 00186