KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWLoadSaveButton.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 vtkKWLoadSaveButton - a button that triggers a load/save dialog 00015 // .SECTION Description 00016 // The vtkKWLoadSaveButton class creates a push button that 00017 // will popup a vtkKWLoadSaveDialog and display the chosen filename as 00018 // the button label. Note that if the dialog is cancelled, the button 00019 // will not be reset to an empty string, therefore reflecting the 00020 // previously selected file, if any (which is the more logical behavior). 00021 // .SECTION See Also 00022 // vtkKWLoadSaveButtonWithLabel 00023 00024 #ifndef __vtkKWLoadSaveButton_h 00025 #define __vtkKWLoadSaveButton_h 00026 00027 #include "vtkKWPushButton.h" 00028 00029 class vtkKWLoadSaveDialog; 00030 00031 class KWWidgets_EXPORT vtkKWLoadSaveButton : public vtkKWPushButton 00032 { 00033 public: 00034 static vtkKWLoadSaveButton* New(); 00035 vtkTypeRevisionMacro(vtkKWLoadSaveButton, vtkKWPushButton); 00036 void PrintSelf(ostream& os, vtkIndent indent); 00037 00038 // Description: 00039 // Access to sub-widgets. 00040 // Important: the LoadSaveDialog is created automatically the first time 00041 // the button is pressed, for efficiency reasons. 00042 // While you can still use the dialog object and invoke methods on it before 00043 // the button is invoked, some methods may require the LoadSaveDialog 00044 // to be created already; if that is the case, just call Create() on 00045 // the dialog object manually. 00046 vtkGetObjectMacro(LoadSaveDialog, vtkKWLoadSaveDialog); 00047 00048 // Description: 00049 // Retrieve the filename. This method only query the GetFileName method 00050 // on the LoadSaveDialog member. 00051 virtual const char* GetFileName(); 00052 00053 // Description: 00054 // Set up the initial file name for the button, and the last path and 00055 // initial file name (for the file name entry) of the internal File Brower dialog 00056 virtual void SetInitialFileName(const char* path); 00057 00058 // Description: 00059 // Set/Get the length of the filename when displayed in the button. 00060 // If set to 0, do not shorten the filename. 00061 virtual void SetMaximumFileNameLength(int); 00062 vtkGetMacro(MaximumFileNameLength, int); 00063 00064 // Description: 00065 // Set/Get if the path of the filename should be trimmed when displayed in 00066 // the button. 00067 virtual void SetTrimPathFromFileName(int); 00068 vtkBooleanMacro(TrimPathFromFileName, int); 00069 vtkGetMacro(TrimPathFromFileName, int); 00070 00071 // Description: 00072 // Update the "enable" state of the object and its internal parts. 00073 // Depending on different Ivars (this->Enabled, the application's 00074 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00075 // and propagated to its internal parts/subwidgets. This will, for example, 00076 // enable/disable parts of the widget UI, enable/disable the visibility 00077 // of 3D widgets, etc. 00078 virtual void UpdateEnableState(); 00079 00080 // Description: 00081 // Add all the default observers needed by that object, or remove 00082 // all the observers that were added through AddCallbackCommandObserver. 00083 // Subclasses can override these methods to add/remove their own default 00084 // observers, but should call the superclass too. 00085 virtual void AddCallbackCommandObservers(); 00086 virtual void RemoveCallbackCommandObservers(); 00087 00088 protected: 00089 vtkKWLoadSaveButton(); 00090 ~vtkKWLoadSaveButton(); 00091 00092 // Description: 00093 // Create the widget. 00094 virtual void CreateWidget(); 00095 00096 vtkKWLoadSaveDialog *LoadSaveDialog; 00097 00098 int TrimPathFromFileName; 00099 int MaximumFileNameLength; 00100 virtual void UpdateTextFromFileName(); 00101 00102 virtual void InvokeCommand(); 00103 00104 // Description: 00105 // Processes the events that are passed through CallbackCommand (or others). 00106 // Subclasses can oberride this method to process their own events, but 00107 // should call the superclass too. 00108 virtual void ProcessCallbackCommandEvents( 00109 vtkObject *caller, unsigned long event, void *calldata); 00110 00111 private: 00112 vtkKWLoadSaveButton(const vtkKWLoadSaveButton&); // Not implemented 00113 void operator=(const vtkKWLoadSaveButton&); // Not implemented 00114 }; 00115 00116 #endif 00117