source: sasview/guiframe/panel_base.py @ 053c769

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 053c769 was 03314e7, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working save state

  • Property mode set to 100644
File size: 10.5 KB
RevLine 
[b5ca223]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
[03314e7]13
[a45037aa]14from sans.guiframe.events import PanelOnFocusEvent
15import wx
[b5ca223]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
[691643c]23    #window_name = "default"
[b5ca223]24    ## Name to appear on the window title bar
[691643c]25    #window_caption = "Welcome panel"
[b5ca223]26    ## Flag to tell the AUI manager to put this panel in the center pane
[75fbd17]27    group_id = None
[b5ca223]28   
[a45037aa]29    def __init__(self, parent=None):
[b5ca223]30        """
31        Initialize some flag that Viewerframe used
32        """
[52725d6]33        #panel manager
34        self._manager = None
[03314e7]35        self.parent = parent
[b5ca223]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
[03314e7]47        self._has_changed = False
48       
[a45037aa]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)
[03314e7]53       
54    def has_changed(self):
55        """
56        """
57        return self._has_changed
58           
[f036c692]59    def _set_print_flag(self, flag=True):
[b5ca223]60        """
61        The derivative class sets the print flag value to indicate that it can
62        be printed
63        """
[03314e7]64        if flag == self._print_flag:
65            self._has_changed = False
66            return
67        self._has_changed = True
[b5ca223]68        self._print_flag = flag
[03314e7]69        if self._manager is not None and self._manager.parent is not None:
70            self._manager.parent.enable_print()
71     
[b5ca223]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   
[f036c692]78    def _set_undo_flag(self, flag=True):
[b5ca223]79        """
80        The derivative class sets the undo flag value to indicate that the
81        current action done can be canceled
82        """
[03314e7]83        if flag == self._undo_flag:
84            self._has_changed = False
85            return
86        self._has_changed = True
[b5ca223]87        self._undo_flag = flag
[03314e7]88        if self._manager is not None and self._manager.parent is not None:
89            self._manager.parent.enable_undo()
90     
[b5ca223]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   
[f036c692]97    def _set_redo_flag(self, flag=True):
[b5ca223]98        """
99        The derivative class sets the redo flag value to indicate that the
100        action done can be recovered
101        """
[03314e7]102        if flag == self._redo_flag:
103            self._has_changed = False
104            return
105        self._has_changed = True
[b5ca223]106        self._redo_flag = flag
[03314e7]107        if self._manager is not None and self._manager.parent is not None:
108            self._manager.parent.enable_redo()
109     
[b5ca223]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   
[f036c692]116    def _set_zoomed_in_flag(self, flag=True):
[b5ca223]117        """
118        The derivative class sets the zoom in flag value to indicate that it
119        can be zoomed in
120        """
[03314e7]121        if self._zoom_in_flag == flag:
122            self._has_changed = False
123            return
124        self._has_changed = True
[b5ca223]125        self._zoom_in_flag = flag
[03314e7]126        if self._manager is not None and self._manager.parent is not None:
127            self._manager.parent.enable_zoom_in()
128       
[b5ca223]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   
[f036c692]135    def _set_zoomed_out_flag(self, flag=True):
[b5ca223]136        """
137        The derivative class sets the zoom out flag value to indicate that it
138        can be zoomed out
139        """
[03314e7]140        if self._zoom_out_flag == flag:
141            self._has_changed = False
142            return
143        self._has_changed = True
[b5ca223]144        self._zoom_out_flag = flag
[03314e7]145        if self._manager is not None and self._manager.parent is not None:
146            self._manager.parent.enable_zoom_out()
[b5ca223]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   
[f036c692]154    def _set_zoom_flag(self, flag=True):
[b5ca223]155        """
156        The derivative class sets the zoom flag value to indicate that it
157        can be zoomed
158        """
[03314e7]159        if flag == self._zoom_flag:
160            self._has_changed = False
161            return
162        self._has_changed = True
[b5ca223]163        self._zoom_flag = flag
[03314e7]164        if self._manager is not None and self._manager.parent is not None:
165            self._manager.parent.enable_zoom()
166     
[b5ca223]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   
[f036c692]173    def _set_bookmark_flag(self, flag=True):
[b5ca223]174        """
175        The derivative class sets the bookmark flag value to indicate that it
176        can be bookmarked
177        """
[03314e7]178        if flag == self._bookmark_flag:
179            self._has_changed = False
180            return
181        self._has_changed = True
[b5ca223]182        self._bookmark_flag = flag
[03314e7]183        if self._manager is not None and self._manager.parent is not None:
184            self._manager.parent.enable_bookmark()
[a45037aa]185       
[b5ca223]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   
[f036c692]192    def _set_preview_flag(self, flag=True):
[b5ca223]193        """
194        The derivative class sets the preview flag value to indicate that it
195        can be previewed
196        """
[03314e7]197        if flag == self._preview_flag:
198            self._has_changed = False
199            return
200        self._has_changed = True
[b5ca223]201        self._preview_flag = flag
[03314e7]202        if self._manager is not None and self._manager.parent is not None:
203            self._manager.parent.enable_preview()
204       
[b5ca223]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   
[f036c692]211    def _set_save_flag(self, flag=True):
[b5ca223]212        """
213        The derivative class sets the drag flag value to indicate that it
214        can be saved
215        """
[03314e7]216        if flag == self._save_flag:
217            self._has_changed = False
218            return
219        self._has_changed = True
[b5ca223]220        self._save_flag = flag
[03314e7]221        if self._manager is not None and self._manager.parent is not None:
222            self._manager.parent.enable_save()
[a45037aa]223
[b5ca223]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   
[f036c692]230    def _set_drag_flag(self, flag=True):
[b5ca223]231        """
232        The derivative class sets the drag flag value to indicate that
233        dragging motion is possible
234        """
[03314e7]235        if self._drag_flag == flag:
236            self._has_changed = False
237            return
238        self._has_changed = True
[b5ca223]239        self._drag_flag = flag
[03314e7]240        if self._manager is not None and self._manager.parent is not None:
241            self._manager.parent.enable_drag()
[a45037aa]242       
[b5ca223]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   
[f036c692]249    def _set_reset_flag(self, flag=True):
[b5ca223]250        """
251        The derivative class sets the reset flag value to indicate that it
252        can be reset
253        """
[03314e7]254        if self._reset_flag == flag:
255            self._has_changed = False
256            return
257        self._has_changed = True
[b5ca223]258        self._reset_flag = flag
[03314e7]259        if self._manager is not None and self._manager.parent is not None:
260            self._manager.parent.enable_reset()
[a45037aa]261     
[b5ca223]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        """
[a45037aa]309    def on_set_focus(self, event=None):
[b5ca223]310        """
311        The  derivative class is on focus if implemented
312        """
[a45037aa]313        if self.parent is not None:
314            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
[b5ca223]315       
[52725d6]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.