source: sasview/src/sas/sasgui/guiframe/panel_base.py @ 3835dbd

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 3835dbd was d85c194, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 9 years ago

Remaining modules refactored

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