source: sasview/guiframe/panel_base.py @ dec793e

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

update config

  • Property mode set to 100644
File size: 11.2 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 has_changed(self):
58        """
59        """
60        return self._has_changed
61           
62    def _set_print_flag(self, flag=True):
63        """
64        The derivative class sets the print flag value to indicate that it can
65        be printed
66        """
67        if flag == self._print_flag:
68            self._has_changed = False
69            return
70        self._has_changed = True
71        self._print_flag = flag
72        if self._manager is not None and self._manager.parent is not None:
73            self._manager.parent.panel_on_focus = self
74            self._manager.parent.enable_print()
75     
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   
82    def _set_undo_flag(self, flag=True):
83        """
84        The derivative class sets the undo flag value to indicate that the
85        current action done can be canceled
86        """
87        if flag == self._undo_flag:
88            self._has_changed = False
89            return
90        self._has_changed = True
91        self._undo_flag = flag
92        if self._manager is not None and self._manager.parent is not None:
93            self._manager.parent.panel_on_focus = self
94            self._manager.parent.enable_undo()
95     
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   
102    def _set_redo_flag(self, flag=True):
103        """
104        The derivative class sets the redo flag value to indicate that the
105        action done can be recovered
106        """
107        if flag == self._redo_flag:
108            self._has_changed = False
109            return
110        self._has_changed = True
111        self._redo_flag = flag
112        if self._manager is not None and self._manager.parent is not None:
113            self._manager.parent.panel_on_focus = self
114            self._manager.parent.enable_redo()
115     
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   
122    def _set_zoomed_in_flag(self, flag=True):
123        """
124        The derivative class sets the zoom in flag value to indicate that it
125        can be zoomed in
126        """
127        if self._zoom_in_flag == flag:
128            self._has_changed = False
129            return
130        self._has_changed = True
131        self._zoom_in_flag = flag
132        if self._manager is not None and self._manager.parent is not None:
133            self._manager.parent.panel_on_focus = self
134            self._manager.parent.enable_zoom_in()
135       
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   
142    def _set_zoomed_out_flag(self, flag=True):
143        """
144        The derivative class sets the zoom out flag value to indicate that it
145        can be zoomed out
146        """
147        if self._zoom_out_flag == flag:
148            self._has_changed = False
149            return
150        self._has_changed = True
151        self._zoom_out_flag = flag
152        if self._manager is not None and self._manager.parent is not None:
153            self._manager.parent.panel_on_focus = self
154            self._manager.parent.enable_zoom_out()
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   
162    def _set_zoom_flag(self, flag=True):
163        """
164        The derivative class sets the zoom flag value to indicate that it
165        can be zoomed
166        """
167        if flag == self._zoom_flag:
168            self._has_changed = False
169            return
170        self._has_changed = True
171        self._zoom_flag = flag
172        if self._manager is not None and self._manager.parent is not None:
173            self._manager.parent.panel_on_focus = self
174            self._manager.parent.enable_zoom()
175     
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   
182    def _set_bookmark_flag(self, flag=True):
183        """
184        The derivative class sets the bookmark flag value to indicate that it
185        can be bookmarked
186        """
187        if flag == self._bookmark_flag:
188            self._has_changed = False
189            return
190        self._has_changed = True
191        self._bookmark_flag = flag
192        if self._manager is not None and self._manager.parent is not None:
193            self._manager.parent.panel_on_focus = self
194            self._manager.parent.enable_bookmark()
195       
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   
202    def _set_preview_flag(self, flag=True):
203        """
204        The derivative class sets the preview flag value to indicate that it
205        can be previewed
206        """
207        if flag == self._preview_flag:
208            self._has_changed = False
209            return
210        self._has_changed = True
211        self._preview_flag = flag
212        if self._manager is not None and self._manager.parent is not None:
213            self._manager.parent.panel_on_focus = self
214            self._manager.parent.enable_preview()
215       
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   
222    def _set_save_flag(self, flag=True):
223        """
224        The derivative class sets the drag flag value to indicate that it
225        can be saved
226        """
227        if flag == self._save_flag:
228            self._has_changed = False
229            return
230        self._has_changed = True
231        self._save_flag = flag
232        if self._manager is not None and self._manager.parent is not None:
233            self._manager.parent.panel_on_focus = self
234            self._manager.parent.enable_save()
235
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   
242    def _set_drag_flag(self, flag=True):
243        """
244        The derivative class sets the drag flag value to indicate that
245        dragging motion is possible
246        """
247        if self._drag_flag == flag:
248            self._has_changed = False
249            return
250        self._has_changed = True
251        self._drag_flag = flag
252        if self._manager is not None and self._manager.parent is not None:
253            self._manager.parent.panel_on_focus = self
254            self._manager.parent.enable_drag()
255       
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   
262    def _set_reset_flag(self, flag=True):
263        """
264        The derivative class sets the reset flag value to indicate that it
265        can be reset
266        """
267        if self._reset_flag == flag:
268            self._has_changed = False
269            return
270        self._has_changed = True
271        self._reset_flag = flag
272        if self._manager is not None and self._manager.parent is not None:
273            self._manager.parent.panel_on_focus = self
274            self._manager.parent.enable_reset()
275     
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        """
323    def on_set_focus(self, event=None):
324        """
325        The  derivative class is on focus if implemented
326        """
327        if self.parent is not None:
328            wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self))
329       
330    def get_data(self):
331        """
332        return list of current data
333        """
334        return
335   
336    def get_state(self):
337        """
338         return the current state
339        """
340        return
341
342    def set_manager(self, manager):
343        """
344        """
345        self._manager = manager
346       
347    def get_manager(self):
348        """
349        """
350        return self._manager
Note: See TracBrowser for help on using the repository browser.