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

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 6550b64 was 225ed2d, checked in by Jae Cho <jhjcho@…>, 12 years ago

removed Bind event: Not a panel nor frame

  • Property mode set to 100644
File size: 13.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
15from sans.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
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
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   
74    def has_changed(self):
75        """
76        """
77        return self._has_changed
78           
79    def _set_print_flag(self, flag=True):
80        """
81        The derivative class sets the print flag value to indicate that it can
82        be printed
83        """
84        if flag == self._print_flag:
85            self._has_changed = False
86            return
87        self._has_changed = True
88        self._print_flag = flag
89        if self._manager is not None and self._manager.parent is not None:
90            self._manager.parent.cpanel_on_focus = self
91            self._manager.parent.enable_print()
92     
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   
99    def _set_undo_flag(self, flag=True):
100        """
101        The derivative class sets the undo flag value to indicate that the
102        current action done can be canceled
103        """
104        if flag == self._undo_flag:
105            self._has_changed = False
106            return
107        self._has_changed = True
108        self._undo_flag = flag
109        if self._manager is not None and self._manager.parent is not None:
110            self._manager.parent.cpanel_on_focus = self
111            self._manager.parent.enable_undo()
112     
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   
119    def _set_redo_flag(self, flag=True):
120        """
121        The derivative class sets the redo flag value to indicate that the
122        action done can be recovered
123        """
124        if flag == self._redo_flag:
125            self._has_changed = False
126            return
127        self._has_changed = True
128        self._redo_flag = flag
129        if self._manager is not None and self._manager.parent is not None:
130            self._manager.parent.cpanel_on_focus = self
131            self._manager.parent.enable_redo()
132     
133    def get_redo_flag(self):
134        """
135        Get the redo flag to update appropriately the tool bar
136        """
137        return self._redo_flag
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
158   
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       
179    def _set_zoomed_in_flag(self, flag=True):
180        """
181        The derivative class sets the zoom in flag value to indicate that it
182        can be zoomed in
183        """
184        if self._zoom_in_flag == flag:
185            self._has_changed = False
186            return
187        self._has_changed = True
188        self._zoom_in_flag = flag
189        if self._manager is not None and self._manager.parent is not None:
190            self._manager.parent.cpanel_on_focus = self
191            self._manager.parent.enable_zoom_in()
192       
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   
199    def _set_zoomed_out_flag(self, flag=True):
200        """
201        The derivative class sets the zoom out flag value to indicate that it
202        can be zoomed out
203        """
204        if self._zoom_out_flag == flag:
205            self._has_changed = False
206            return
207        self._has_changed = True
208        self._zoom_out_flag = flag
209        if self._manager is not None and self._manager.parent is not None:
210            self._manager.parent.panel_on_focus = self
211            self._manager.parent.enable_zoom_out()
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   
219    def _set_zoom_flag(self, flag=True):
220        """
221        The derivative class sets the zoom flag value to indicate that it
222        can be zoomed
223        """
224        if flag == self._zoom_flag:
225            self._has_changed = False
226            return
227        self._has_changed = True
228        self._zoom_flag = flag
229        if self._manager is not None and self._manager.parent is not None:
230            self._manager.parent.cpanel_on_focus = self
231            self._manager.parent.enable_zoom()
232     
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   
239    def _set_bookmark_flag(self, flag=True):
240        """
241        The derivative class sets the bookmark flag value to indicate that it
242        can be bookmarked
243        """
244        if flag == self._bookmark_flag:
245            self._has_changed = False
246            return
247        self._has_changed = True
248        self._bookmark_flag = flag
249        if self._manager is not None and self._manager.parent is not None:
250            self._manager.parent.cpanel_on_focus = self
251            self._manager.parent.enable_bookmark()
252       
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   
259    def _set_preview_flag(self, flag=True):
260        """
261        The derivative class sets the preview flag value to indicate that it
262        can be previewed
263        """
264        if flag == self._preview_flag:
265            self._has_changed = False
266            return
267        self._has_changed = True
268        self._preview_flag = flag
269        if self._manager is not None and self._manager.parent is not None:
270            self._manager.parent.cpanel_on_focus = self
271            self._manager.parent.enable_preview()
272       
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   
279    def _set_save_flag(self, flag=True):
280        """
281        The derivative class sets the drag flag value to indicate that it
282        can be saved
283        """
284        if flag == self._save_flag:
285            self._has_changed = False
286            return
287        self._has_changed = True
288        self._save_flag = flag
289        if self._manager is not None and self._manager.parent is not None:
290            self._manager.parent.cpanel_on_focus = self
291            self._manager.parent.enable_save()
292
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   
299    def _set_drag_flag(self, flag=True):
300        """
301        The derivative class sets the drag flag value to indicate that
302        dragging motion is possible
303        """
304        if self._drag_flag == flag:
305            self._has_changed = False
306            return
307        self._has_changed = True
308        self._drag_flag = flag
309        if self._manager is not None and self._manager.parent is not None:
310            self._manager.parent.cpanel_on_focus = self
311            self._manager.parent.enable_drag()
312       
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   
319    def _set_reset_flag(self, flag=True):
320        """
321        The derivative class sets the reset flag value to indicate that it
322        can be reset
323        """
324        if self._reset_flag == flag:
325            self._has_changed = False
326            return
327        self._has_changed = True
328        self._reset_flag = flag
329        if self._manager is not None and self._manager.parent is not None:
330            self._manager.parent.cpanel_on_focus = self
331            self._manager.parent.enable_reset()
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
339     
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        """
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        """
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        """
395    def on_set_focus(self, event=None):
396        """
397        The  derivative class is on focus if implemented
398        """
399        if self.parent is not None:
400            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
401           
402    def on_kill_focus(self, event=None):
403        """
404        The  derivative class is on unfocus if implemented
405        """
406        pass
407               
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.