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