source: sasview/guiframe/panel_base.py @ b0e8beb

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 b0e8beb was ecc85443, checked in by Gervaise Alina <gervyh@…>, 14 years ago

update toolbar

  • Property mode set to 100644
File size: 11.1 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
[df22224]28    uid = None
[b5ca223]29   
[a45037aa]30    def __init__(self, parent=None):
[b5ca223]31        """
32        Initialize some flag that Viewerframe used
33        """
[52725d6]34        #panel manager
35        self._manager = None
[03314e7]36        self.parent = parent
[b5ca223]37        self._print_flag = False
38        self._undo_flag = False
39        self._redo_flag = False
40        self._preview_flag = False
41        self._bookmark_flag = False
42        self._zoom_in_flag = False
43        self._zoom_out_flag = False
44        self._zoom_flag = False
45        self._save_flag = False
46        self._drag_flag = False
47        self._reset_flag = False
[03314e7]48        self._has_changed = False
[c70eb7c]49        self.group_id = None
[03314e7]50       
[a45037aa]51        self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus)
52        self.Bind(wx.EVT_TEXT_ENTER, self.on_set_focus)
53        self.Bind(wx.EVT_MIDDLE_DOWN, self.on_set_focus)
54        self.Bind(wx.EVT_RIGHT_DOWN, self.on_set_focus)
[03314e7]55       
56    def has_changed(self):
57        """
58        """
59        return self._has_changed
60           
[f036c692]61    def _set_print_flag(self, flag=True):
[b5ca223]62        """
63        The derivative class sets the print flag value to indicate that it can
64        be printed
65        """
[03314e7]66        if flag == self._print_flag:
67            self._has_changed = False
68            return
69        self._has_changed = True
[b5ca223]70        self._print_flag = flag
[03314e7]71        if self._manager is not None and self._manager.parent is not None:
[ecc85443]72            self._manager.parent.panel_on_focus = self
[03314e7]73            self._manager.parent.enable_print()
74     
[b5ca223]75    def get_print_flag(self):
76        """
77        Get the print flag to update appropriately the tool bar
78        """
79        return self._print_flag
80   
[f036c692]81    def _set_undo_flag(self, flag=True):
[b5ca223]82        """
83        The derivative class sets the undo flag value to indicate that the
84        current action done can be canceled
85        """
[03314e7]86        if flag == self._undo_flag:
87            self._has_changed = False
88            return
89        self._has_changed = True
[b5ca223]90        self._undo_flag = flag
[03314e7]91        if self._manager is not None and self._manager.parent is not None:
[ecc85443]92            self._manager.parent.panel_on_focus = self
[03314e7]93            self._manager.parent.enable_undo()
94     
[b5ca223]95    def get_undo_flag(self):
96        """
97        Get the undo flag to update appropriately the tool bar
98        """
99        return self._undo_flag
100   
[f036c692]101    def _set_redo_flag(self, flag=True):
[b5ca223]102        """
103        The derivative class sets the redo flag value to indicate that the
104        action done can be recovered
105        """
[03314e7]106        if flag == self._redo_flag:
107            self._has_changed = False
108            return
109        self._has_changed = True
[b5ca223]110        self._redo_flag = flag
[03314e7]111        if self._manager is not None and self._manager.parent is not None:
[ecc85443]112            self._manager.parent.panel_on_focus = self
[03314e7]113            self._manager.parent.enable_redo()
114     
[b5ca223]115    def get_redo_flag(self):
116        """
117        Get the redo flag to update appropriately the tool bar
118        """
119        return self._redo_flag
120   
[f036c692]121    def _set_zoomed_in_flag(self, flag=True):
[b5ca223]122        """
123        The derivative class sets the zoom in flag value to indicate that it
124        can be zoomed in
125        """
[03314e7]126        if self._zoom_in_flag == flag:
127            self._has_changed = False
128            return
129        self._has_changed = True
[b5ca223]130        self._zoom_in_flag = flag
[03314e7]131        if self._manager is not None and self._manager.parent is not None:
[ecc85443]132            self._manager.parent.panel_on_focus = self
[03314e7]133            self._manager.parent.enable_zoom_in()
134       
[b5ca223]135    def get_zoom_in_flag(self):
136        """
137        Get the zoom in flag to update appropriately the tool bar
138        """
139        return self._zoom_in_flag
140   
[f036c692]141    def _set_zoomed_out_flag(self, flag=True):
[b5ca223]142        """
143        The derivative class sets the zoom out flag value to indicate that it
144        can be zoomed out
145        """
[03314e7]146        if self._zoom_out_flag == flag:
147            self._has_changed = False
148            return
149        self._has_changed = True
[b5ca223]150        self._zoom_out_flag = flag
[03314e7]151        if self._manager is not None and self._manager.parent is not None:
[ecc85443]152            self._manager.parent.panel_on_focus = self
[03314e7]153            self._manager.parent.enable_zoom_out()
[b5ca223]154       
155    def get_zoom_out_flag(self):
156        """
157        Get the zoom out flag to update appropriately the tool bar
158        """
159        return self._zoom_out_flag
160   
[f036c692]161    def _set_zoom_flag(self, flag=True):
[b5ca223]162        """
163        The derivative class sets the zoom flag value to indicate that it
164        can be zoomed
165        """
[03314e7]166        if flag == self._zoom_flag:
167            self._has_changed = False
168            return
169        self._has_changed = True
[b5ca223]170        self._zoom_flag = flag
[03314e7]171        if self._manager is not None and self._manager.parent is not None:
[ecc85443]172            self._manager.parent.panel_on_focus = self
[03314e7]173            self._manager.parent.enable_zoom()
174     
[b5ca223]175    def get_zoom_flag(self):
176        """
177        Get the zoom flag to update appropriately the tool bar
178        """
179        return self._zoom_flag
180   
[f036c692]181    def _set_bookmark_flag(self, flag=True):
[b5ca223]182        """
183        The derivative class sets the bookmark flag value to indicate that it
184        can be bookmarked
185        """
[03314e7]186        if flag == self._bookmark_flag:
187            self._has_changed = False
188            return
189        self._has_changed = True
[b5ca223]190        self._bookmark_flag = flag
[03314e7]191        if self._manager is not None and self._manager.parent is not None:
[ecc85443]192            self._manager.parent.panel_on_focus = self
[03314e7]193            self._manager.parent.enable_bookmark()
[a45037aa]194       
[b5ca223]195    def get_bookmark_flag(self):
196        """
197        Get the bookmark flag to update appropriately the tool bar
198        """
199        return self._bookmark_flag
200   
[f036c692]201    def _set_preview_flag(self, flag=True):
[b5ca223]202        """
203        The derivative class sets the preview flag value to indicate that it
204        can be previewed
205        """
[03314e7]206        if flag == self._preview_flag:
207            self._has_changed = False
208            return
209        self._has_changed = True
[b5ca223]210        self._preview_flag = flag
[03314e7]211        if self._manager is not None and self._manager.parent is not None:
[ecc85443]212            self._manager.parent.panel_on_focus = self
[03314e7]213            self._manager.parent.enable_preview()
214       
[b5ca223]215    def get_preview_flag(self):
216        """
217        Get the preview flag to update appropriately the tool bar
218        """
219        return self._preview_flag
220   
[f036c692]221    def _set_save_flag(self, flag=True):
[b5ca223]222        """
223        The derivative class sets the drag flag value to indicate that it
224        can be saved
225        """
[03314e7]226        if flag == self._save_flag:
227            self._has_changed = False
228            return
229        self._has_changed = True
[b5ca223]230        self._save_flag = flag
[03314e7]231        if self._manager is not None and self._manager.parent is not None:
[ecc85443]232            self._manager.parent.panel_on_focus = self
[03314e7]233            self._manager.parent.enable_save()
[a45037aa]234
[b5ca223]235    def get_save_flag(self):
236        """
237        Get the save flag to update appropriately the tool bar
238        """
239        return self._save_flag
240   
[f036c692]241    def _set_drag_flag(self, flag=True):
[b5ca223]242        """
243        The derivative class sets the drag flag value to indicate that
244        dragging motion is possible
245        """
[03314e7]246        if self._drag_flag == flag:
247            self._has_changed = False
248            return
249        self._has_changed = True
[b5ca223]250        self._drag_flag = flag
[03314e7]251        if self._manager is not None and self._manager.parent is not None:
[ecc85443]252            self._manager.parent.panel_on_focus = self
[03314e7]253            self._manager.parent.enable_drag()
[a45037aa]254       
[b5ca223]255    def get_drag_flag(self):
256        """
257        Get the drag flag to update appropriately the tool bar
258        """
259        return self._drag_flag
260   
[f036c692]261    def _set_reset_flag(self, flag=True):
[b5ca223]262        """
263        The derivative class sets the reset flag value to indicate that it
264        can be reset
265        """
[03314e7]266        if self._reset_flag == flag:
267            self._has_changed = False
268            return
269        self._has_changed = True
[b5ca223]270        self._reset_flag = flag
[03314e7]271        if self._manager is not None and self._manager.parent is not None:
[ecc85443]272            self._manager.parent.panel_on_focus = self
[03314e7]273            self._manager.parent.enable_reset()
[a45037aa]274     
[b5ca223]275    def get_reset_flag(self):
276        """
277        Get the reset flag to update appropriately the tool bar
278        """
279        return self._reset_flag
280
281    def on_reset(self, event):
282        """
283        The derivative class state is restored
284        """
285    def on_drag(self, event):
286        """
287        The derivative class allows dragging motion if implemented
288        """
289    def on_preview(self, event):
290        """
291        Display a printable version of the class derivative
292        """
293    def on_save(self, event):
294        """
295        The state of the derivative class is restored
296        """
297    def on_redo(self, event):
298        """
299        The previous action is restored if possible
300        """
301    def on_undo(self, event):
302        """
303        The current action is canceled
304        """
305    def on_bookmark(self, event):
306        """
307        The derivative class is on bookmark mode if implemented
308        """
309    def on_zoom_in(self, event):
310        """
311        The derivative class is on zoom in mode if implemented
312        """
313    def on_zoom_out(self, event):
314        """
315        The derivative class is on zoom out mode if implemented
316        """
317    def on_zoom(self, event):
318        """
319        The derivative class is on zoom mode (using pane)
320        if zoom mode is implemented
321        """
[a45037aa]322    def on_set_focus(self, event=None):
[b5ca223]323        """
324        The  derivative class is on focus if implemented
325        """
[a45037aa]326        if self.parent is not None:
327            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
[b5ca223]328       
[52725d6]329    def get_data(self):
330        """
331        return list of current data
332        """
333        return
334   
335    def get_state(self):
336        """
337         return the current state
338        """
339        return
340
341    def set_manager(self, manager):
342        """
343        """
344        self._manager = manager
345       
346    def get_manager(self):
347        """
348        """
349        return self._manager
Note: See TracBrowser for help on using the repository browser.