KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWFileBrowserWidget.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 vtkKWFileBrowserWidget - a file browser widget 00015 // .SECTION Description 00016 // The class assembles vtkKWFavoriteDirectoriesFrame, vtkKWDirectoryExploer, 00017 // and vtkKWFileListTable widgets together and give user options to turn 00018 // on/off (visible/invisible) each individual widget. 00019 // .SECTION Thanks 00020 // This work is part of the National Alliance for Medical Image 00021 // Computing (NAMIC), funded by the National Institutes of Health 00022 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00023 // Information on the National Centers for Biomedical Computing 00024 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00025 // .SECTION See Also 00026 // vtkKWFileBrowserDialog vtkKWDirectoryExplorer vtkKWFileListTable 00027 // vtkKWFavoriteDirectoriesFrame 00028 00029 #ifndef __vtkKWFileBrowserWidget_h 00030 #define __vtkKWFileBrowserWidget_h 00031 00032 #include "vtkKWCompositeWidget.h" 00033 00034 class vtkKWFavoriteDirectoriesFrame; 00035 class vtkKWDirectoryExplorer; 00036 class vtkKWFileListTable; 00037 class vtkKWFrame; 00038 class vtkKWSplitFrame; 00039 class vtkKWFileBrowserWidgetInternals; 00040 00041 class KWWidgets_EXPORT vtkKWFileBrowserWidget : public vtkKWCompositeWidget 00042 { 00043 public: 00044 static vtkKWFileBrowserWidget* New(); 00045 vtkTypeRevisionMacro(vtkKWFileBrowserWidget,vtkKWCompositeWidget); 00046 void PrintSelf(ostream& os, vtkIndent indent); 00047 00048 // Description: 00049 // Open a directory. 00050 // Return 1 on success, 0 otherwise 00051 virtual int OpenDirectory(const char* path); 00052 00053 // Description: 00054 // Filter the files of the file list table by file extensions 00055 // The argument is NOT a Tk format, just a simple string of extensions 00056 // with space between them. 00057 // Example: ".txt .text .jpg .jpeg" 00058 virtual void FilterFilesByExtensions(const char* fileextensions); 00059 00060 // Description: 00061 // Accessor for DirectoryExplorer and FileListTable 00062 vtkGetObjectMacro(DirectoryExplorer, vtkKWDirectoryExplorer); 00063 vtkGetObjectMacro(FileListTable, vtkKWFileListTable); 00064 vtkGetObjectMacro(FavoriteDirectoriesFrame, vtkKWFavoriteDirectoriesFrame); 00065 vtkGetObjectMacro(MainFrame, vtkKWSplitFrame); 00066 vtkGetObjectMacro(DirFileFrame, vtkKWSplitFrame); 00067 00068 // Description: 00069 // Set/Get the visibility of the directory explorer 00070 virtual void SetDirectoryExplorerVisibility(int); 00071 vtkBooleanMacro(DirectoryExplorerVisibility, int); 00072 vtkGetMacro(DirectoryExplorerVisibility, int); 00073 00074 // Description: 00075 // Set/Get the visibility of the favorite directories frame 00076 virtual void SetFavoriteDirectoriesFrameVisibility(int); 00077 vtkBooleanMacro(FavoriteDirectoriesFrameVisibility, int); 00078 vtkGetMacro(FavoriteDirectoriesFrameVisibility, int); 00079 00080 // Description: 00081 // Set/Get the visibility of the file list table 00082 virtual void SetFileListTableVisibility(int); 00083 vtkBooleanMacro(FileListTableVisibility, int); 00084 vtkGetMacro(FileListTableVisibility, int); 00085 00086 // Description: 00087 // Set/Get if multiple selection are allowed. 00088 virtual void SetMultipleSelection(int); 00089 vtkBooleanMacro(MultipleSelection, int); 00090 vtkGetMacro(MultipleSelection, int); 00091 00092 // Description: 00093 // Set/Get the foreground/background color of selected items, when 00094 // in focus or out of focus. 00095 vtkGetVector3Macro(SelectionForegroundColor, double); 00096 virtual void SetSelectionForegroundColor(double r, double g, double b); 00097 virtual void SetSelectionForegroundColor(double rgb[3]) 00098 { this->SetSelectionForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00099 vtkGetVector3Macro(SelectionBackgroundColor, double); 00100 virtual void SetSelectionBackgroundColor(double r, double g, double b); 00101 virtual void SetSelectionBackgroundColor(double rgb[3]) 00102 { this->SetSelectionBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00103 vtkGetVector3Macro(OutOfFocusSelectionForegroundColor, double); 00104 virtual void SetOutOfFocusSelectionForegroundColor( 00105 double r, double g, double b); 00106 virtual void SetOutOfFocusSelectionForegroundColor(double rgb[3]) 00107 { this->SetOutOfFocusSelectionForegroundColor(rgb[0], rgb[1], rgb[2]); }; 00108 vtkGetVector3Macro(OutOfFocusSelectionBackgroundColor, double); 00109 virtual void SetOutOfFocusSelectionBackgroundColor( 00110 double r, double g, double b); 00111 virtual void SetOutOfFocusSelectionBackgroundColor(double rgb[3]) 00112 { this->SetOutOfFocusSelectionBackgroundColor(rgb[0], rgb[1], rgb[2]); }; 00113 00114 // Description: 00115 // Set focus to directory explorer or file list table. 00116 virtual void SetFocusToDirectoryExplorer(); 00117 virtual void SetFocusToFileListTable(); 00118 00119 // Description: 00120 // Callback, do NOT use 00121 // When the "Add Favorites" button is clicked in the favorite directories 00122 // frame, this function will be called and a dialog will popup prompting 00123 // for a name of the directory that is going to be added to the favorite 00124 // directory frame. 00125 virtual void AddFavoriteDirectoryCallback(); 00126 00127 // Description: 00128 // Callback, do NOT use 00129 // When a favorite button in the favorite directory frame is clicked on, 00130 // navigate to the corresponding favorite directory (path is a pointer to 00131 // the absolute directory path, text a pointer to the favorite button label) 00132 virtual void FavoriteDirectorySelectedCallback( 00133 const char* path, 00134 const char* text); 00135 00136 // Description: 00137 // Callbacks, do NOT use 00138 // Callback for the vtkKWDirectoryExplorer widget. 00139 virtual void DirectoryCreatedCallback(const char* fullname); 00140 virtual void DirectorySelectedCallback(const char* fullname); 00141 virtual void DirectoryOpenedCallback(const char* fullname); 00142 virtual void DirectoryClosedCallback(const char* fullname); 00143 virtual void DirectoryDeletedCallback(const char* fullname); 00144 virtual void DirectoryRenamedCallback( 00145 const char* oldname, 00146 const char* newname); 00147 00148 // Description: 00149 // Callbacks, do NOT use 00150 // Callback for the vtkKWFileListTable widget. 00151 virtual void FileSelectionChangedCallback(const char* fullname); 00152 virtual void FileDoubleClickedCallback(const char* fullname); 00153 virtual void FileRenamedCallback( 00154 const char* oldname, 00155 const char* newname); 00156 virtual void FolderCreatedCallback(const char* filename); 00157 virtual void FileDeletedCallback(const char* fullname, int isDir); 00158 00159 // Description: 00160 // Callback, do NOT use. 00161 virtual void DirectoryTreeFocusInCallback(); 00162 virtual void FileTableFocusInCallback(); 00163 virtual void DirectoryTreeFocusOutCallback(); 00164 virtual void FileTableFocusOutCallback(); 00165 00166 // Description: 00167 // Update the "enable" state of the object and its internal parts. 00168 // Depending on different Ivars (this->Enabled, the application's 00169 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00170 // and propagated to its internal parts/subwidgets. This will, for example, 00171 // enable/disable parts of the widget UI, enable/disable the visibility 00172 // of 3D widgets, etc. 00173 virtual void UpdateEnableState(); 00174 00175 // Description: 00176 // Request the width/height of the widget. 00177 virtual void SetWidth(int); 00178 virtual int GetWidth(); 00179 virtual void SetHeight(int); 00180 virtual int GetHeight(); 00181 00182 protected: 00183 vtkKWFileBrowserWidget(); 00184 ~vtkKWFileBrowserWidget(); 00185 00186 // Description: 00187 // Create the widget. 00188 virtual void CreateWidget(); 00189 00190 // Description: 00191 // Pack all the widgets according to their visibility 00192 virtual void Pack(); 00193 00194 // Description: 00195 // Setup all the frames with widgets. 00196 virtual void CreateFavoriteDirectoriesFrame(); 00197 virtual void CreateDirectoryExplorerAndFileListTableFrame(); 00198 virtual void CreateDirectoryExplorer(); 00199 virtual void CreateFileListTable(); 00200 00201 // Description: 00202 // Function to update the selected Background/Foreground. 00203 virtual void UpdateDirectorySelectionColor(int infocus = 0); 00204 virtual void UpdateFileSelectionColor(int infocus = 0); 00205 00206 virtual void UpdateForCurrentDirectory(); 00207 virtual void PropagateMultipleSelection(); 00208 00209 // Description: 00210 // Member variable 00211 // PIMPL for STL stuff. 00212 vtkKWFileBrowserWidgetInternals *Internals; 00213 00214 // Description: 00215 // Member variable 00216 // A split frame holding the favorite frame, directory frame, and 00217 // file list table. 00218 // Both directory frame and file list table will be in DirFileFrame, which 00219 // is parented to MainFrame->Frame2. 00220 vtkKWSplitFrame *MainFrame; 00221 vtkKWSplitFrame *DirFileFrame; 00222 00223 // Description: 00224 // GUI members. 00225 vtkKWFavoriteDirectoriesFrame *FavoriteDirectoriesFrame; 00226 vtkKWDirectoryExplorer *DirectoryExplorer; 00227 vtkKWFileListTable *FileListTable; 00228 00229 // Description: 00230 // Member variables 00231 int DirectoryExplorerVisibility; 00232 int FavoriteDirectoriesFrameVisibility; 00233 int FileListTableVisibility; 00234 int MultipleSelection; 00235 00236 // Description: 00237 // Colors 00238 double SelectionForegroundColor[3]; 00239 double SelectionBackgroundColor[3]; 00240 double OutOfFocusSelectionForegroundColor[3]; 00241 double OutOfFocusSelectionBackgroundColor[3]; 00242 00243 private: 00244 vtkKWFileBrowserWidget(const vtkKWFileBrowserWidget&); // Not implemented 00245 void operator=(const vtkKWFileBrowserWidget&); // Not implemented 00246 }; 00247 00248 #endif