source: sasview/guiframe/panel_base.py @ d75b8ec

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

save state fix for multiple panel

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