source: sasview/guiframe/panel_base.py @ 5342eb8

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 5342eb8 was 0a2fdca, checked in by Jae Cho <jhjcho@…>, 13 years ago

fixing plot panel and control panels focusing problems

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