KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWDirectoryPresetSelector.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
4 Clifton Park, NY, 12065, USA.
5 
6 All rights reserved. No part of this software may be reproduced, distributed,
7 or modified, in any form or by any means, without permission in writing from
8 Kitware Inc.
9 
10 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
11 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
12 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
13 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 
15 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
16 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
17 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
18 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
19 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
20 
21 =========================================================================*/
22 // .NAME vtkKWDirectoryPresetSelector - a directory preset selector.
23 // .SECTION Description
24 // This class is a widget that can be used to pick and list of set of directories.
25 // presets.
26 // .SECTION Thanks
27 // This work is part of the National Alliance for Medical Image
28 // Computing (NAMIC), funded by the National Institutes of Health
29 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
30 // Information on the National Centers for Biomedical Computing
31 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
32 // .SECTION See Also
33 // vtkKWPresetSelector
34 
35 #ifndef __vtkKWDirectoryPresetSelector_h
36 #define __vtkKWDirectoryPresetSelector_h
37 
38 #include "vtkKWPresetSelector.h"
39 
41 
43 {
44 public:
47  void PrintSelf(ostream& os, vtkIndent indent);
48 
49  // Description:
50  // Set/Get the directory for a given preset.
51  // Return 1 on success, 0 otherwise
52  virtual int SetPresetDirectory(int id, const char *directory);
53  virtual const char* GetPresetDirectory(int id);
54 
55  // Description:
56  // Query if the pool has a given directory preset
57  virtual int HasPresetWithDirectory(const char *directory);
58 
59  // Description:
60  // Set/Get the directory enabled flag for a given preset.
61  // Return 1 on success, 0 otherwise
62  virtual int GetPresetDirectoryEnabled(int id);
63  virtual int SetPresetDirectoryEnabled(int id, int flag);
64 
65  // Description:
66  // Set/Get the visibility of the directory enabled flag column.
67  // Hidden by default.
68  // No effect if called before Create().
69  virtual void SetDirectoryEnabledColumnVisibility(int);
70  virtual int GetDirectoryEnabledColumnVisibility();
71  vtkBooleanMacro(DirectoryEnabledColumnVisibility, int);
72 
73  // Description:
74  // Set/Get the maximum length of the directory paths, in characters.
75  // If set to 0 (default), do not shorten the paths automatically.
76  virtual void SetMaximumDirectoryLength(int);
77  vtkGetMacro(MaximumDirectoryLength, int);
78 
79  // Description:
80  // Set/Get if unique directories are enforced..
81  virtual void SetUniqueDirectories(int);
82  vtkGetMacro(UniqueDirectories,int);
83  vtkBooleanMacro(UniqueDirectories,int);
84 
85 
86  // Description:
87  // Add/retrieve the whole list of enabled directories from/to a string. Each
88  // directory in this list is separated by a given delimiter (ex: ':' or ';').
89  // Presets are added in an "enabled" state (see GetPresetDirectoryEnabled)
90  // to the end of the preset list.
91  // Only presets that were enabled are retrieved and stored into a string
92  // (note that said string will be allocated to the proper size with 'new' and
93  // should therefore be de-allocated by the called with 'delete []').
94  // Return the number of enabled directories added, or retrieved.
95  virtual int AddEnabledPresetDirectoriesFromDelimitedString(
96  const char *from_str, const char from_delim);
97  virtual int GetEnabledPresetDirectoriesToDelimitedString(
98  char **to_str, const char to_delim);
99 
100  // Description:
101  // Add/retrieve the whole list of directories *and* their enabled flag
102  // from/to a string representation.
103  // Each item in this list is a directory and a boolean flag (0 or 1)
104  // specifying if that directory is actually enabled or not in the UI.
105  // Each element is separated by a given delimiter (ex: with '|' as delim,
106  // "c:/temp|0|d:/foo/bar|1|c:/windows|1" refers to "c:/temp" as disabled and
107  // both "d:/foo/bar" and "c:/windows" enabled; at this point, the string
108  // returned by AddEnabledPresetDirectoriesFromDelimitedString would be
109  // "d:/foo/bar;c:/windows" with a ';' delimiter).
110  // Presets are added to the end of the preset list.
111  // (note that said string will be allocated to the proper size with 'new' and
112  // should therefore be de-allocated by the caller with 'delete []').
113  // Return the number of directories added, or retrieved.
114  virtual int AddPresetDirectoriesFromDelimitedString(
115  const char *from_str, const char from_delim);
116  virtual int GetPresetDirectoriesToDelimitedString(
117  char **to_str, const char to_delim);
118 
119  // Description:
120  // Static helper method.
121  // This method extracts the list of enabled directories (to a string) from
122  // the list of directories + flag (as a string, as it was returned by
123  // GetPresetDirectoriesToDelimitedString for example).
124  // Each list can be separated by different delimiters (ex: with '|' as
125  // from_delim, "c:/temp|0|d:/foo/bar|1|c:/windows|1" as from_str will be
126  // output to to_str as "d:/foo/bar;c:/windows" if to_delim is ';').
127  // (note that said string will be allocated to the proper size with 'new' and
128  // should therefore be de-allocated by the caller with 'delete []').
129  // Return the number of enabled directories retrieved.
130  static int GetEnabledPresetDirectoriesFromPresetDirectories(
131  char **to_str, const char to_delim,
132  const char *from_str, const char from_delim);
133 
134  // Description:
135  // Static helper method.
136  // This method *updates* the list of directories + flag (to a string) from
137  // a list of enabled directories (as a string, as it was returned by
138  // Duplicated directories are not supported here.
139  // Each list can be separated by different delimiters (ex: with ';' as
140  // from_delim, "c:/temp;d:/bill" as from_str, '|' as to_delim and
141  // "c:/temp|0|d:/foo/bar|0|c:/windows|1" as to_str, to_str will be updated
142  // (i.e. potentially re-allocated) to a new string
143  // "c:/temp|1|d:/foo/bar|0|d:/bill|1", where the already
144  // existing "c:/temp" was updated/enabled, ""d:/foo/bar" was ignored,
145  // "c:/windows" was removed (since considered not enabled) and "d:/bill" was
146  // added.
147  // (note that said string will be allocated to the proper size with 'new' and
148  // should therefore be de-allocated by the caller with 'delete []').
149  // Return the number of directories updated (i.e. removed, updated or added).
150  static int UpdatePresetDirectoriesFromEnabledPresetDirectories(
151  char **update_str, const char update_delim,
152  const char *from_str, const char from_delim);
153 
154  // Description:
155  // Some constants
156  //BTX
157  static const char *DirectoryColumnName;
158  static const char *DirectoryEnabledColumnName;
159  //ETX
160 
161  // Description:
162  // Callback invoked when the user starts editing a specific preset field
163  // located at cell ('row', 'col'), which current contents is 'text'.
164  // This method returns the value that is to become the initial
165  // contents of the temporary embedded widget used for editing: most of the
166  // time, this is the same value as 'text'.
167  // The next step (validation) is handled by PresetCellEditEndCallback
168  virtual const char* PresetCellEditStartCallback(
169  int row, int col, const char *text);
170 
171  // Description:
172  // Callback invoked when the user ends editing a specific preset field
173  // located at cell ('row', 'col').
174  // The main purpose of this method is to perform a final validation of
175  // the edit window's contents 'text'.
176  // This method returns the value that is to become the new contents
177  // for that cell.
178  // The next step (updating) is handled by PresetCellUpdateCallback
179  virtual const char* PresetCellEditEndCallback(
180  int row, int col, const char *text);
181 
182  // Description:
183  // Callback invoked when the user successfully updated the preset field
184  // located at ('row', 'col') with the new contents 'text', as a result
185  // of editing the corresponding cell interactively.
186  virtual void PresetCellUpdatedCallback(int row, int col, const char *text);
187 
188  // Description:
189  // Callback invoked when the user press the "Add" button
190  virtual int AddDirectoryCallback();
191 
192  // Description:
193  // Access to sub-widgets.
194  vtkGetObjectMacro(FileBrowserDialog, vtkKWFileBrowserDialog);
195 
196 protected:
199 
202 
203  // Description:
204  // Create the widget.
205  virtual void CreateWidget();
206 
207  // Description:
208  // Create the columns.
209  // Subclasses should override this method to add their own columns and
210  // display their own preset fields (do not forget to call the superclass
211  // first).
212  virtual void CreateColumns();
213 
214  // Description:
215  // Update the preset row, i.e. add a row for that preset if it is not
216  // displayed already, hide it if it does not match GroupFilter, and
217  // update the table columns with the corresponding preset fields.
218  // Subclass should override this method to display their own fields.
219  // Return 1 on success, 0 if the row was not (or can not be) updated.
220  // Subclasses should call the parent's UpdatePresetRow, and abort
221  // if the result is not 1.
222  virtual int UpdatePresetRow(int id);
223 
224  // Description:
225  // Get the index of a given column
226  virtual int GetDirectoryColumnIndex();
227  virtual int GetDirectoryEnabledColumnIndex();
228 
230 
231 private:
232 
234  void operator=(const vtkKWDirectoryPresetSelector&); // Not implemented
235 };
236 
237 #endif