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

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 ebbc421 was 46cec6c, checked in by Jae Cho <jhjcho@…>, 13 years ago

put on tap focus function for all the c_panels

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