KWWidgets
vtkKWLoadSaveButton.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWLoadSaveButton.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWLoadSaveButton - a button that triggers a load/save dialog
15 // .SECTION Description
16 // The vtkKWLoadSaveButton class creates a push button that
17 // will popup a vtkKWLoadSaveDialog and display the chosen filename as
18 // the button label. Note that if the dialog is cancelled, the button
19 // will not be reset to an empty string, therefore reflecting the
20 // previously selected file, if any (which is the more logical behavior).
21 // .SECTION See Also
22 // vtkKWLoadSaveButtonWithLabel
23 
24 #ifndef __vtkKWLoadSaveButton_h
25 #define __vtkKWLoadSaveButton_h
26 
27 #include "vtkKWPushButton.h"
28 
30 
32 {
33 public:
34  static vtkKWLoadSaveButton* New();
35  vtkTypeRevisionMacro(vtkKWLoadSaveButton, vtkKWPushButton);
36  void PrintSelf(ostream& os, vtkIndent indent);
37 
38  // Description:
39  // Access to sub-widgets.
40  // Important: the LoadSaveDialog is created automatically the first time
41  // the button is pressed, for efficiency reasons.
42  // While you can still use the dialog object and invoke methods on it before
43  // the button is invoked, some methods may require the LoadSaveDialog
44  // to be created already; if that is the case, just call Create() on
45  // the dialog object manually.
46  vtkGetObjectMacro(LoadSaveDialog, vtkKWLoadSaveDialog);
47 
48  // Description:
49  // Retrieve the filename. This method only query the GetFileName method
50  // on the LoadSaveDialog member.
51  virtual const char* GetFileName();
52 
53  // Description:
54  // Set up the initial file name for the button, and the last path and
55  // initial file name (for the file name entry) of the internal File Brower dialog
56  virtual void SetInitialFileName(const char* path);
57 
58  // Description:
59  // Set/Get the length of the filename when displayed in the button.
60  // If set to 0, do not shorten the filename.
61  virtual void SetMaximumFileNameLength(int);
62  vtkGetMacro(MaximumFileNameLength, int);
63 
64  // Description:
65  // Set/Get if the path of the filename should be trimmed when displayed in
66  // the button.
67  virtual void SetTrimPathFromFileName(int);
68  vtkBooleanMacro(TrimPathFromFileName, int);
69  vtkGetMacro(TrimPathFromFileName, int);
70 
71  // Description:
72  // Update the "enable" state of the object and its internal parts.
73  // Depending on different Ivars (this->Enabled, the application's
74  // Limited Edition Mode, etc.), the "enable" state of the object is updated
75  // and propagated to its internal parts/subwidgets. This will, for example,
76  // enable/disable parts of the widget UI, enable/disable the visibility
77  // of 3D widgets, etc.
78  virtual void UpdateEnableState();
79 
80  // Description:
81  // Add all the default observers needed by that object, or remove
82  // all the observers that were added through AddCallbackCommandObserver.
83  // Subclasses can override these methods to add/remove their own default
84  // observers, but should call the superclass too.
85  virtual void AddCallbackCommandObservers();
86  virtual void RemoveCallbackCommandObservers();
87 
88 protected:
91 
92  // Description:
93  // Create the widget.
94  virtual void CreateWidget();
95 
96  vtkKWLoadSaveDialog *LoadSaveDialog;
97 
98  int TrimPathFromFileName;
99  int MaximumFileNameLength;
100  virtual void UpdateTextFromFileName();
101 
102  virtual void InvokeCommand();
103 
104  // Description:
105  // Processes the events that are passed through CallbackCommand (or others).
106  // Subclasses can oberride this method to process their own events, but
107  // should call the superclass too.
108  virtual void ProcessCallbackCommandEvents(
109  vtkObject *caller, unsigned long event, void *calldata);
110 
111 private:
112  vtkKWLoadSaveButton(const vtkKWLoadSaveButton&); // Not implemented
113  void operator=(const vtkKWLoadSaveButton&); // Not implemented
114 };
115 
116 #endif
117