[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 | |
---|
[a45037aa] | 13 | from sans.guiframe.events import PanelOnFocusEvent |
---|
| 14 | import wx |
---|
[b5ca223] | 15 | |
---|
| 16 | class PanelBase: |
---|
| 17 | """ |
---|
| 18 | Defines the API for a panels to work with |
---|
| 19 | the ViewerFrame toolbar and menu bar |
---|
| 20 | """ |
---|
| 21 | ## Internal nickname for the window, used by the AUI manager |
---|
[691643c] | 22 | #window_name = "default" |
---|
[b5ca223] | 23 | ## Name to appear on the window title bar |
---|
[691643c] | 24 | #window_caption = "Welcome panel" |
---|
[b5ca223] | 25 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
[691643c] | 26 | #CENTER_PANE = True |
---|
[b5ca223] | 27 | |
---|
[a45037aa] | 28 | def __init__(self, parent=None): |
---|
[b5ca223] | 29 | """ |
---|
| 30 | Initialize some flag that Viewerframe used |
---|
| 31 | """ |
---|
[52725d6] | 32 | #panel manager |
---|
| 33 | self._manager = None |
---|
| 34 | |
---|
[b5ca223] | 35 | self._print_flag = False |
---|
| 36 | self._undo_flag = False |
---|
| 37 | self._redo_flag = False |
---|
| 38 | self._preview_flag = False |
---|
| 39 | self._bookmark_flag = False |
---|
| 40 | self._zoom_in_flag = False |
---|
| 41 | self._zoom_out_flag = False |
---|
| 42 | self._zoom_flag = False |
---|
| 43 | self._save_flag = False |
---|
| 44 | self._drag_flag = False |
---|
| 45 | self._reset_flag = False |
---|
[a45037aa] | 46 | self.parent = parent |
---|
| 47 | self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus) |
---|
| 48 | self.Bind(wx.EVT_TEXT_ENTER, self.on_set_focus) |
---|
| 49 | self.Bind(wx.EVT_MIDDLE_DOWN, self.on_set_focus) |
---|
| 50 | self.Bind(wx.EVT_RIGHT_DOWN, self.on_set_focus) |
---|
| 51 | |
---|
[f036c692] | 52 | def _set_print_flag(self, flag=True): |
---|
[b5ca223] | 53 | """ |
---|
| 54 | The derivative class sets the print flag value to indicate that it can |
---|
| 55 | be printed |
---|
| 56 | """ |
---|
| 57 | self._print_flag = flag |
---|
[a45037aa] | 58 | self.on_set_focus(event=None) |
---|
[b5ca223] | 59 | |
---|
| 60 | def get_print_flag(self): |
---|
| 61 | """ |
---|
| 62 | Get the print flag to update appropriately the tool bar |
---|
| 63 | """ |
---|
| 64 | return self._print_flag |
---|
| 65 | |
---|
[f036c692] | 66 | def _set_undo_flag(self, flag=True): |
---|
[b5ca223] | 67 | """ |
---|
| 68 | The derivative class sets the undo flag value to indicate that the |
---|
| 69 | current action done can be canceled |
---|
| 70 | """ |
---|
| 71 | self._undo_flag = flag |
---|
[a45037aa] | 72 | self.on_set_focus(event=None) |
---|
| 73 | |
---|
[b5ca223] | 74 | def get_undo_flag(self): |
---|
| 75 | """ |
---|
| 76 | Get the undo flag to update appropriately the tool bar |
---|
| 77 | """ |
---|
| 78 | return self._undo_flag |
---|
| 79 | |
---|
[f036c692] | 80 | def _set_redo_flag(self, flag=True): |
---|
[b5ca223] | 81 | """ |
---|
| 82 | The derivative class sets the redo flag value to indicate that the |
---|
| 83 | action done can be recovered |
---|
| 84 | """ |
---|
| 85 | self._redo_flag = flag |
---|
[a45037aa] | 86 | self.on_set_focus(event=None) |
---|
| 87 | |
---|
[b5ca223] | 88 | def get_redo_flag(self): |
---|
| 89 | """ |
---|
| 90 | Get the redo flag to update appropriately the tool bar |
---|
| 91 | """ |
---|
| 92 | return self._redo_flag |
---|
| 93 | |
---|
[a45037aa] | 94 | |
---|
[f036c692] | 95 | def _set_zoomed_in_flag(self, flag=True): |
---|
[b5ca223] | 96 | """ |
---|
| 97 | The derivative class sets the zoom in flag value to indicate that it |
---|
| 98 | can be zoomed in |
---|
| 99 | """ |
---|
| 100 | self._zoom_in_flag = flag |
---|
[a45037aa] | 101 | self.on_set_focus(event=None) |
---|
| 102 | |
---|
[b5ca223] | 103 | |
---|
| 104 | def get_zoom_in_flag(self): |
---|
| 105 | """ |
---|
| 106 | Get the zoom in flag to update appropriately the tool bar |
---|
| 107 | """ |
---|
| 108 | return self._zoom_in_flag |
---|
| 109 | |
---|
[f036c692] | 110 | def _set_zoomed_out_flag(self, flag=True): |
---|
[b5ca223] | 111 | """ |
---|
| 112 | The derivative class sets the zoom out flag value to indicate that it |
---|
| 113 | can be zoomed out |
---|
| 114 | """ |
---|
| 115 | self._zoom_out_flag = flag |
---|
[a45037aa] | 116 | self.on_set_focus(event=None) |
---|
[b5ca223] | 117 | |
---|
| 118 | def get_zoom_out_flag(self): |
---|
| 119 | """ |
---|
| 120 | Get the zoom out flag to update appropriately the tool bar |
---|
| 121 | """ |
---|
| 122 | return self._zoom_out_flag |
---|
| 123 | |
---|
[f036c692] | 124 | def _set_zoom_flag(self, flag=True): |
---|
[b5ca223] | 125 | """ |
---|
| 126 | The derivative class sets the zoom flag value to indicate that it |
---|
| 127 | can be zoomed |
---|
| 128 | """ |
---|
| 129 | self._zoom_flag = flag |
---|
[a45037aa] | 130 | self.on_set_focus(event=None) |
---|
| 131 | |
---|
[b5ca223] | 132 | def get_zoom_flag(self): |
---|
| 133 | """ |
---|
| 134 | Get the zoom flag to update appropriately the tool bar |
---|
| 135 | """ |
---|
| 136 | return self._zoom_flag |
---|
| 137 | |
---|
[f036c692] | 138 | def _set_bookmark_flag(self, flag=True): |
---|
[b5ca223] | 139 | """ |
---|
| 140 | The derivative class sets the bookmark flag value to indicate that it |
---|
| 141 | can be bookmarked |
---|
| 142 | """ |
---|
| 143 | self._bookmark_flag = flag |
---|
[a45037aa] | 144 | self.on_set_focus(event=None) |
---|
| 145 | |
---|
[b5ca223] | 146 | def get_bookmark_flag(self): |
---|
| 147 | """ |
---|
| 148 | Get the bookmark flag to update appropriately the tool bar |
---|
| 149 | """ |
---|
| 150 | return self._bookmark_flag |
---|
| 151 | |
---|
[f036c692] | 152 | def _set_preview_flag(self, flag=True): |
---|
[b5ca223] | 153 | """ |
---|
| 154 | The derivative class sets the preview flag value to indicate that it |
---|
| 155 | can be previewed |
---|
| 156 | """ |
---|
| 157 | self._preview_flag = flag |
---|
[a45037aa] | 158 | self.on_set_focus(event=None) |
---|
[b5ca223] | 159 | |
---|
| 160 | def get_preview_flag(self): |
---|
| 161 | """ |
---|
| 162 | Get the preview flag to update appropriately the tool bar |
---|
| 163 | """ |
---|
| 164 | return self._preview_flag |
---|
| 165 | |
---|
[f036c692] | 166 | def _set_save_flag(self, flag=True): |
---|
[b5ca223] | 167 | """ |
---|
| 168 | The derivative class sets the drag flag value to indicate that it |
---|
| 169 | can be saved |
---|
| 170 | """ |
---|
| 171 | self._save_flag = flag |
---|
[a45037aa] | 172 | self.on_set_focus(event=None) |
---|
| 173 | |
---|
[b5ca223] | 174 | def get_save_flag(self): |
---|
| 175 | """ |
---|
| 176 | Get the save flag to update appropriately the tool bar |
---|
| 177 | """ |
---|
| 178 | return self._save_flag |
---|
| 179 | |
---|
[f036c692] | 180 | def _set_drag_flag(self, flag=True): |
---|
[b5ca223] | 181 | """ |
---|
| 182 | The derivative class sets the drag flag value to indicate that |
---|
| 183 | dragging motion is possible |
---|
| 184 | """ |
---|
| 185 | self._drag_flag = flag |
---|
[a45037aa] | 186 | |
---|
[b5ca223] | 187 | def get_drag_flag(self): |
---|
| 188 | """ |
---|
| 189 | Get the drag flag to update appropriately the tool bar |
---|
| 190 | """ |
---|
| 191 | return self._drag_flag |
---|
| 192 | |
---|
[f036c692] | 193 | def _set_reset_flag(self, flag=True): |
---|
[b5ca223] | 194 | """ |
---|
| 195 | The derivative class sets the reset flag value to indicate that it |
---|
| 196 | can be reset |
---|
| 197 | """ |
---|
| 198 | self._reset_flag = flag |
---|
[a45037aa] | 199 | |
---|
[b5ca223] | 200 | def get_reset_flag(self): |
---|
| 201 | """ |
---|
| 202 | Get the reset flag to update appropriately the tool bar |
---|
| 203 | """ |
---|
| 204 | return self._reset_flag |
---|
| 205 | |
---|
| 206 | def on_reset(self, event): |
---|
| 207 | """ |
---|
| 208 | The derivative class state is restored |
---|
| 209 | """ |
---|
| 210 | def on_drag(self, event): |
---|
| 211 | """ |
---|
| 212 | The derivative class allows dragging motion if implemented |
---|
| 213 | """ |
---|
| 214 | def on_preview(self, event): |
---|
| 215 | """ |
---|
| 216 | Display a printable version of the class derivative |
---|
| 217 | """ |
---|
| 218 | def on_save(self, event): |
---|
| 219 | """ |
---|
| 220 | The state of the derivative class is restored |
---|
| 221 | """ |
---|
| 222 | def on_redo(self, event): |
---|
| 223 | """ |
---|
| 224 | The previous action is restored if possible |
---|
| 225 | """ |
---|
| 226 | def on_undo(self, event): |
---|
| 227 | """ |
---|
| 228 | The current action is canceled |
---|
| 229 | """ |
---|
| 230 | def on_bookmark(self, event): |
---|
| 231 | """ |
---|
| 232 | The derivative class is on bookmark mode if implemented |
---|
| 233 | """ |
---|
| 234 | def on_zoom_in(self, event): |
---|
| 235 | """ |
---|
| 236 | The derivative class is on zoom in mode if implemented |
---|
| 237 | """ |
---|
| 238 | def on_zoom_out(self, event): |
---|
| 239 | """ |
---|
| 240 | The derivative class is on zoom out mode if implemented |
---|
| 241 | """ |
---|
| 242 | def on_zoom(self, event): |
---|
| 243 | """ |
---|
| 244 | The derivative class is on zoom mode (using pane) |
---|
| 245 | if zoom mode is implemented |
---|
| 246 | """ |
---|
[a45037aa] | 247 | def on_set_focus(self, event=None): |
---|
[b5ca223] | 248 | """ |
---|
| 249 | The derivative class is on focus if implemented |
---|
| 250 | """ |
---|
[a45037aa] | 251 | if self.parent is not None: |
---|
| 252 | print "on_set_focus", self.window_name, self.parent |
---|
| 253 | wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) |
---|
[b5ca223] | 254 | |
---|
[52725d6] | 255 | def get_data(self): |
---|
| 256 | """ |
---|
| 257 | return list of current data |
---|
| 258 | """ |
---|
| 259 | return |
---|
| 260 | |
---|
| 261 | def get_state(self): |
---|
| 262 | """ |
---|
| 263 | return the current state |
---|
| 264 | """ |
---|
| 265 | return |
---|
| 266 | |
---|
| 267 | def set_manager(self, manager): |
---|
| 268 | """ |
---|
| 269 | """ |
---|
| 270 | self._manager = manager |
---|
| 271 | |
---|
| 272 | def get_manager(self): |
---|
| 273 | """ |
---|
| 274 | """ |
---|
| 275 | return self._manager |
---|