source: sasview/guiframe/panel_base.py @ 6bbeacd4

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 6bbeacd4 was 03314e7, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working save state

  • Property mode set to 100644
File size: 10.5 KB
Line 
1
2
3################################################################################
4#This software was developed by the University of Tennessee as part of the
5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#project funded by the US National Science Foundation.
7#
8#See the license text in license.txt
9#
10#copyright 2008, University of Tennessee
11################################################################################
12
13
14from sans.guiframe.events import PanelOnFocusEvent
15import wx
16
17class PanelBase:
18    """
19    Defines the API for a panels to work with
20    the ViewerFrame toolbar and menu bar
21    """
22    ## Internal nickname for the window, used by the AUI manager
23    #window_name = "default"
24    ## Name to appear on the window title bar
25    #window_caption = "Welcome panel"
26    ## Flag to tell the AUI manager to put this panel in the center pane
27    group_id = None
28   
29    def __init__(self, parent=None):
30        """
31        Initialize some flag that Viewerframe used
32        """
33        #panel manager
34        self._manager = None
35        self.parent = parent
36        self._print_flag = False
37        self._undo_flag = False
38        self._redo_flag = False
39        self._preview_flag = False
40        self._bookmark_flag = False
41        self._zoom_in_flag = False
42        self._zoom_out_flag = False
43        self._zoom_flag = False
44        self._save_flag = False
45        self._drag_flag = False
46        self._reset_flag = False
47        self._has_changed = False
48       
49        self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus)
50        self.Bind(wx.EVT_TEXT_ENTER, self.on_set_focus)
51        self.Bind(wx.EVT_MIDDLE_DOWN, self.on_set_focus)
52        self.Bind(wx.EVT_RIGHT_DOWN, self.on_set_focus)
53       
54    def has_changed(self):
55        """
56        """
57        return self._has_changed
58           
59    def _set_print_flag(self, flag=True):
60        """
61        The derivative class sets the print flag value to indicate that it can
62        be printed
63        """
64        if flag == self._print_flag:
65            self._has_changed = False
66            return
67        self._has_changed = True
68        self._print_flag = flag
69        if self._manager is not None and self._manager.parent is not None:
70            self._manager.parent.enable_print()
71     
72    def get_print_flag(self):
73        """
74        Get the print flag to update appropriately the tool bar
75        """
76        return self._print_flag
77   
78    def _set_undo_flag(self, flag=True):
79        """
80        The derivative class sets the undo flag value to indicate that the
81        current action done can be canceled
82        """
83        if flag == self._undo_flag:
84            self._has_changed = False
85            return
86        self._has_changed = True
87        self._undo_flag = flag
88        if self._manager is not None and self._manager.parent is not None:
89            self._manager.parent.enable_undo()
90     
91    def get_undo_flag(self):
92        """
93        Get the undo flag to update appropriately the tool bar
94        """
95        return self._undo_flag
96   
97    def _set_redo_flag(self, flag=True):
98        """
99        The derivative class sets the redo flag value to indicate that the
100        action done can be recovered
101        """
102        if flag == self._redo_flag:
103            self._has_changed = False
104            return
105        self._has_changed = True
106        self._redo_flag = flag
107        if self._manager is not None and self._manager.parent is not None:
108            self._manager.parent.enable_redo()
109     
110    def get_redo_flag(self):
111        """
112        Get the redo flag to update appropriately the tool bar
113        """
114        return self._redo_flag
115   
116    def _set_zoomed_in_flag(self, flag=True):
117        """
118        The derivative class sets the zoom in flag value to indicate that it
119        can be zoomed in
120        """
121        if self._zoom_in_flag == flag:
122            self._has_changed = False
123            return
124        self._has_changed = True
125        self._zoom_in_flag = flag
126        if self._manager is not None and self._manager.parent is not None:
127            self._manager.parent.enable_zoom_in()
128       
129    def get_zoom_in_flag(self):
130        """
131        Get the zoom in flag to update appropriately the tool bar
132        """
133        return self._zoom_in_flag
134   
135    def _set_zoomed_out_flag(self, flag=True):
136        """
137        The derivative class sets the zoom out flag value to indicate that it
138        can be zoomed out
139        """
140        if self._zoom_out_flag == flag:
141            self._has_changed = False
142            return
143        self._has_changed = True
144        self._zoom_out_flag = flag
145        if self._manager is not None and self._manager.parent is not None:
146            self._manager.parent.enable_zoom_out()
147       
148    def get_zoom_out_flag(self):
149        """
150        Get the zoom out flag to update appropriately the tool bar
151        """
152        return self._zoom_out_flag
153   
154    def _set_zoom_flag(self, flag=True):
155        """
156        The derivative class sets the zoom flag value to indicate that it
157        can be zoomed
158        """
159        if flag == self._zoom_flag:
160            self._has_changed = False
161            return
162        self._has_changed = True
163        self._zoom_flag = flag
164        if self._manager is not None and self._manager.parent is not None:
165            self._manager.parent.enable_zoom()
166     
167    def get_zoom_flag(self):
168        """
169        Get the zoom flag to update appropriately the tool bar
170        """
171        return self._zoom_flag
172   
173    def _set_bookmark_flag(self, flag=True):
174        """
175        The derivative class sets the bookmark flag value to indicate that it
176        can be bookmarked
177        """
178        if flag == self._bookmark_flag:
179            self._has_changed = False
180            return
181        self._has_changed = True
182        self._bookmark_flag = flag
183        if self._manager is not None and self._manager.parent is not None:
184            self._manager.parent.enable_bookmark()
185       
186    def get_bookmark_flag(self):
187        """
188        Get the bookmark flag to update appropriately the tool bar
189        """
190        return self._bookmark_flag
191   
192    def _set_preview_flag(self, flag=True):
193        """
194        The derivative class sets the preview flag value to indicate that it
195        can be previewed
196        """
197        if flag == self._preview_flag:
198            self._has_changed = False
199            return
200        self._has_changed = True
201        self._preview_flag = flag
202        if self._manager is not None and self._manager.parent is not None:
203            self._manager.parent.enable_preview()
204       
205    def get_preview_flag(self):
206        """
207        Get the preview flag to update appropriately the tool bar
208        """
209        return self._preview_flag
210   
211    def _set_save_flag(self, flag=True):
212        """
213        The derivative class sets the drag flag value to indicate that it
214        can be saved
215        """
216        if flag == self._save_flag:
217            self._has_changed = False
218            return
219        self._has_changed = True
220        self._save_flag = flag
221        if self._manager is not None and self._manager.parent is not None:
222            self._manager.parent.enable_save()
223
224    def get_save_flag(self):
225        """
226        Get the save flag to update appropriately the tool bar
227        """
228        return self._save_flag
229   
230    def _set_drag_flag(self, flag=True):
231        """
232        The derivative class sets the drag flag value to indicate that
233        dragging motion is possible
234        """
235        if self._drag_flag == flag:
236            self._has_changed = False
237            return
238        self._has_changed = True
239        self._drag_flag = flag
240        if self._manager is not None and self._manager.parent is not None:
241            self._manager.parent.enable_drag()
242       
243    def get_drag_flag(self):
244        """
245        Get the drag flag to update appropriately the tool bar
246        """
247        return self._drag_flag
248   
249    def _set_reset_flag(self, flag=True):
250        """
251        The derivative class sets the reset flag value to indicate that it
252        can be reset
253        """
254        if self._reset_flag == flag:
255            self._has_changed = False
256            return
257        self._has_changed = True
258        self._reset_flag = flag
259        if self._manager is not None and self._manager.parent is not None:
260            self._manager.parent.enable_reset()
261     
262    def get_reset_flag(self):
263        """
264        Get the reset flag to update appropriately the tool bar
265        """
266        return self._reset_flag
267
268    def on_reset(self, event):
269        """
270        The derivative class state is restored
271        """
272    def on_drag(self, event):
273        """
274        The derivative class allows dragging motion if implemented
275        """
276    def on_preview(self, event):
277        """
278        Display a printable version of the class derivative
279        """
280    def on_save(self, event):
281        """
282        The state of the derivative class is restored
283        """
284    def on_redo(self, event):
285        """
286        The previous action is restored if possible
287        """
288    def on_undo(self, event):
289        """
290        The current action is canceled
291        """
292    def on_bookmark(self, event):
293        """
294        The derivative class is on bookmark mode if implemented
295        """
296    def on_zoom_in(self, event):
297        """
298        The derivative class is on zoom in mode if implemented
299        """
300    def on_zoom_out(self, event):
301        """
302        The derivative class is on zoom out mode if implemented
303        """
304    def on_zoom(self, event):
305        """
306        The derivative class is on zoom mode (using pane)
307        if zoom mode is implemented
308        """
309    def on_set_focus(self, event=None):
310        """
311        The  derivative class is on focus if implemented
312        """
313        if self.parent is not None:
314            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
315       
316    def get_data(self):
317        """
318        return list of current data
319        """
320        return
321   
322    def get_state(self):
323        """
324         return the current state
325        """
326        return
327
328    def set_manager(self, manager):
329        """
330        """
331        self._manager = manager
332       
333    def get_manager(self):
334        """
335        """
336        return self._manager
Note: See TracBrowser for help on using the repository browser.