source: sasview/sansguiframe/src/sans/guiframe/panel_base.py @ 240bdc80

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 240bdc80 was 225ed2d, checked in by Jae Cho <jhjcho@…>, 13 years ago

removed Bind event: Not a panel nor frame

  • Property mode set to 100644
File size: 13.6 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
[c958e30]15from sans.guiframe.events import EVT_NEW_BATCH
[a45037aa]16import wx
[b5ca223]17
18class PanelBase:
19    """
20    Defines the API for a panels to work with
21    the ViewerFrame toolbar and menu bar
22    """
23    ## Internal nickname for the window, used by the AUI manager
[691643c]24    #window_name = "default"
[b5ca223]25    ## Name to appear on the window title bar
[691643c]26    #window_caption = "Welcome panel"
[b5ca223]27    ## Flag to tell the AUI manager to put this panel in the center pane
[75fbd17]28    group_id = None
[df22224]29    uid = None
[b5ca223]30   
[a45037aa]31    def __init__(self, parent=None):
[b5ca223]32        """
33        Initialize some flag that Viewerframe used
34        """
[52725d6]35        #panel manager
36        self._manager = None
[03314e7]37        self.parent = parent
[7bf9a8c]38        if self.parent is not None and hasattr(self.parent, '_manager'):
39            self._manager = self.parent._manager
[b5ca223]40        self._print_flag = False
41        self._undo_flag = False
42        self._redo_flag = False
[07c8630]43        self._copy_flag = False
44        self._paste_flag = False
[b5ca223]45        self._preview_flag = False
46        self._bookmark_flag = False
47        self._zoom_in_flag = False
48        self._zoom_out_flag = False
49        self._zoom_flag = False
50        self._save_flag = False
51        self._drag_flag = False
52        self._reset_flag = False
[03314e7]53        self._has_changed = False
[c958e30]54        self.batch_on = False
[d03a356]55        if self.parent is not None and hasattr(self.parent, "batch_on"):
56            self.batch_on = self.parent.batch_on
57       
[c70eb7c]58        self.group_id = None
[225ed2d]59
[c958e30]60    def on_batch_selection(self, event):
61        """
62        :param event: contains parameter enable . when enable is set to True
63        the application is in Batch mode
64        else the application is default mode(single mode)
65        """
66        self.batch_on = event.enable
[6f28e70]67    def save_project(self, doc=None):
68        """
69        return an xml node containing state of the panel
70         that guiframe can write to file
71        """
72        return None
73   
[03314e7]74    def has_changed(self):
75        """
76        """
77        return self._has_changed
78           
[f036c692]79    def _set_print_flag(self, flag=True):
[b5ca223]80        """
81        The derivative class sets the print flag value to indicate that it can
82        be printed
83        """
[03314e7]84        if flag == self._print_flag:
85            self._has_changed = False
86            return
87        self._has_changed = True
[b5ca223]88        self._print_flag = flag
[03314e7]89        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]90            self._manager.parent.cpanel_on_focus = self
[03314e7]91            self._manager.parent.enable_print()
92     
[b5ca223]93    def get_print_flag(self):
94        """
95        Get the print flag to update appropriately the tool bar
96        """
97        return self._print_flag
98   
[f036c692]99    def _set_undo_flag(self, flag=True):
[b5ca223]100        """
101        The derivative class sets the undo flag value to indicate that the
102        current action done can be canceled
103        """
[03314e7]104        if flag == self._undo_flag:
105            self._has_changed = False
106            return
107        self._has_changed = True
[b5ca223]108        self._undo_flag = flag
[03314e7]109        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]110            self._manager.parent.cpanel_on_focus = self
[03314e7]111            self._manager.parent.enable_undo()
112     
[b5ca223]113    def get_undo_flag(self):
114        """
115        Get the undo flag to update appropriately the tool bar
116        """
117        return self._undo_flag
118   
[f036c692]119    def _set_redo_flag(self, flag=True):
[b5ca223]120        """
121        The derivative class sets the redo flag value to indicate that the
122        action done can be recovered
123        """
[03314e7]124        if flag == self._redo_flag:
125            self._has_changed = False
126            return
127        self._has_changed = True
[b5ca223]128        self._redo_flag = flag
[03314e7]129        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]130            self._manager.parent.cpanel_on_focus = self
[03314e7]131            self._manager.parent.enable_redo()
132     
[b5ca223]133    def get_redo_flag(self):
134        """
135        Get the redo flag to update appropriately the tool bar
136        """
137        return self._redo_flag
[07c8630]138
139    def _set_copy_flag(self, flag=True):
140        """
141        The derivative class sets the copy flag value to indicate that the
142        action done can be recovered
143        """
144        if flag == self._copy_flag:
145            self._has_changed = False
146            return
147        self._has_changed = True
148        self._copy_flag = flag
149        if self._manager is not None and self._manager.parent is not None:
150            self._manager.parent.cpanel_on_focus = self
151            self._manager.parent.enable_copy()
152     
153    def get_copy_flag(self):
154        """
155        Get the copy flag to update appropriately the tool bar
156        """
157        return self._copy_flag
[b5ca223]158   
[07c8630]159    def _set_paste_flag(self, flag=True):
160        """
161        The derivative class sets the paste flag value to indicate that the
162        action done can be recovered
163        """
164        if flag == self._paste_flag:
165            self._has_changed = False
166            return
167        self._has_changed = True
168        self._paste_flag = flag
169        if self._manager is not None and self._manager.parent is not None:
170            self._manager.parent.cpanel_on_focus = self
171            self._manager.parent.enable_paste()
172     
173    def get_paste_flag(self):
174        """
175        Get the copy flag to update appropriately the tool bar
176        """
177        return self._copy_flag
178       
[f036c692]179    def _set_zoomed_in_flag(self, flag=True):
[b5ca223]180        """
181        The derivative class sets the zoom in flag value to indicate that it
182        can be zoomed in
183        """
[03314e7]184        if self._zoom_in_flag == flag:
185            self._has_changed = False
186            return
187        self._has_changed = True
[b5ca223]188        self._zoom_in_flag = flag
[03314e7]189        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]190            self._manager.parent.cpanel_on_focus = self
[03314e7]191            self._manager.parent.enable_zoom_in()
192       
[b5ca223]193    def get_zoom_in_flag(self):
194        """
195        Get the zoom in flag to update appropriately the tool bar
196        """
197        return self._zoom_in_flag
198   
[f036c692]199    def _set_zoomed_out_flag(self, flag=True):
[b5ca223]200        """
201        The derivative class sets the zoom out flag value to indicate that it
202        can be zoomed out
203        """
[03314e7]204        if self._zoom_out_flag == flag:
205            self._has_changed = False
206            return
207        self._has_changed = True
[b5ca223]208        self._zoom_out_flag = flag
[03314e7]209        if self._manager is not None and self._manager.parent is not None:
[ecc85443]210            self._manager.parent.panel_on_focus = self
[03314e7]211            self._manager.parent.enable_zoom_out()
[b5ca223]212       
213    def get_zoom_out_flag(self):
214        """
215        Get the zoom out flag to update appropriately the tool bar
216        """
217        return self._zoom_out_flag
218   
[f036c692]219    def _set_zoom_flag(self, flag=True):
[b5ca223]220        """
221        The derivative class sets the zoom flag value to indicate that it
222        can be zoomed
223        """
[03314e7]224        if flag == self._zoom_flag:
225            self._has_changed = False
226            return
227        self._has_changed = True
[b5ca223]228        self._zoom_flag = flag
[03314e7]229        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]230            self._manager.parent.cpanel_on_focus = self
[03314e7]231            self._manager.parent.enable_zoom()
232     
[b5ca223]233    def get_zoom_flag(self):
234        """
235        Get the zoom flag to update appropriately the tool bar
236        """
237        return self._zoom_flag
238   
[f036c692]239    def _set_bookmark_flag(self, flag=True):
[b5ca223]240        """
241        The derivative class sets the bookmark flag value to indicate that it
242        can be bookmarked
243        """
[03314e7]244        if flag == self._bookmark_flag:
245            self._has_changed = False
246            return
247        self._has_changed = True
[b5ca223]248        self._bookmark_flag = flag
[03314e7]249        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]250            self._manager.parent.cpanel_on_focus = self
[03314e7]251            self._manager.parent.enable_bookmark()
[a45037aa]252       
[b5ca223]253    def get_bookmark_flag(self):
254        """
255        Get the bookmark flag to update appropriately the tool bar
256        """
257        return self._bookmark_flag
258   
[f036c692]259    def _set_preview_flag(self, flag=True):
[b5ca223]260        """
261        The derivative class sets the preview flag value to indicate that it
262        can be previewed
263        """
[03314e7]264        if flag == self._preview_flag:
265            self._has_changed = False
266            return
267        self._has_changed = True
[b5ca223]268        self._preview_flag = flag
[03314e7]269        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]270            self._manager.parent.cpanel_on_focus = self
[03314e7]271            self._manager.parent.enable_preview()
272       
[b5ca223]273    def get_preview_flag(self):
274        """
275        Get the preview flag to update appropriately the tool bar
276        """
277        return self._preview_flag
278   
[f036c692]279    def _set_save_flag(self, flag=True):
[b5ca223]280        """
281        The derivative class sets the drag flag value to indicate that it
282        can be saved
283        """
[03314e7]284        if flag == self._save_flag:
285            self._has_changed = False
286            return
287        self._has_changed = True
[b5ca223]288        self._save_flag = flag
[03314e7]289        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]290            self._manager.parent.cpanel_on_focus = self
[03314e7]291            self._manager.parent.enable_save()
[a45037aa]292
[b5ca223]293    def get_save_flag(self):
294        """
295        Get the save flag to update appropriately the tool bar
296        """
297        return self._save_flag
298   
[f036c692]299    def _set_drag_flag(self, flag=True):
[b5ca223]300        """
301        The derivative class sets the drag flag value to indicate that
302        dragging motion is possible
303        """
[03314e7]304        if self._drag_flag == flag:
305            self._has_changed = False
306            return
307        self._has_changed = True
[b5ca223]308        self._drag_flag = flag
[03314e7]309        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]310            self._manager.parent.cpanel_on_focus = self
[03314e7]311            self._manager.parent.enable_drag()
[a45037aa]312       
[b5ca223]313    def get_drag_flag(self):
314        """
315        Get the drag flag to update appropriately the tool bar
316        """
317        return self._drag_flag
318   
[f036c692]319    def _set_reset_flag(self, flag=True):
[b5ca223]320        """
321        The derivative class sets the reset flag value to indicate that it
322        can be reset
323        """
[03314e7]324        if self._reset_flag == flag:
325            self._has_changed = False
326            return
327        self._has_changed = True
[b5ca223]328        self._reset_flag = flag
[03314e7]329        if self._manager is not None and self._manager.parent is not None:
[0a2fdca]330            self._manager.parent.cpanel_on_focus = self
[03314e7]331            self._manager.parent.enable_reset()
[46cec6c]332           
333    def on_tap_focus(self):
334        """
335        Update menu on clicking the panel tap
336        """
337        #Implemented only on fitting note book
338        pass
[a45037aa]339     
[b5ca223]340    def get_reset_flag(self):
341        """
342        Get the reset flag to update appropriately the tool bar
343        """
344        return self._reset_flag
345
346    def on_reset(self, event):
347        """
348        The derivative class state is restored
349        """
350    def on_drag(self, event):
351        """
352        The derivative class allows dragging motion if implemented
353        """
354    def on_preview(self, event):
355        """
356        Display a printable version of the class derivative
357        """
358    def on_save(self, event):
359        """
360        The state of the derivative class is restored
361        """
362    def on_redo(self, event):
363        """
364        The previous action is restored if possible
365        """
366    def on_undo(self, event):
367        """
368        The current action is canceled
369        """
[07c8630]370    def on_copy(self, event):
371        """
372        The copy action if possible
373        """
374    def on_paste(self, event):
375        """
376        The paste action if possible
377        """
[b5ca223]378    def on_bookmark(self, event):
379        """
380        The derivative class is on bookmark mode if implemented
381        """
382    def on_zoom_in(self, event):
383        """
384        The derivative class is on zoom in mode if implemented
385        """
386    def on_zoom_out(self, event):
387        """
388        The derivative class is on zoom out mode if implemented
389        """
390    def on_zoom(self, event):
391        """
392        The derivative class is on zoom mode (using pane)
393        if zoom mode is implemented
394        """
[a45037aa]395    def on_set_focus(self, event=None):
[b5ca223]396        """
397        The  derivative class is on focus if implemented
398        """
[a45037aa]399        if self.parent is not None:
400            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
[f69b5830]401           
402    def on_kill_focus(self, event=None):
403        """
404        The  derivative class is on unfocus if implemented
405        """
406        pass
407               
[52725d6]408    def get_data(self):
409        """
410        return list of current data
411        """
412        return
413   
414    def get_state(self):
415        """
416         return the current state
417        """
418        return
419
420    def set_manager(self, manager):
421        """
422        """
423        self._manager = manager
424       
425    def get_manager(self):
426        """
427        """
428        return self._manager
Note: See TracBrowser for help on using the repository browser.