Package Gnumed :: Package timelinelib :: Package wxgui :: Package dialogs :: Package preferences :: Module view
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.dialogs.preferences.view

  1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
  2  # 
  3  # This file is part of Timeline. 
  4  # 
  5  # Timeline is free software: you can redistribute it and/or modify 
  6  # it under the terms of the GNU General Public License as published by 
  7  # the Free Software Foundation, either version 3 of the License, or 
  8  # (at your option) any later version. 
  9  # 
 10  # Timeline is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  # GNU General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU General Public License 
 16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
 17   
 18   
 19  import os 
 20  import wx 
 21   
 22  from timelinelib.features.experimental.experimentalfeatures import ExperimentalFeatures 
 23  from timelinelib.wxgui.components.font import edit_font_data 
 24  from timelinelib.wxgui.dialogs.eventeditortabselection.view import EventEditorTabSelectionDialog 
 25  from timelinelib.wxgui.dialogs.dateformat.view import DateFormatDialog 
 26  from timelinelib.wxgui.dialogs.preferences.controller import PreferencesDialogController 
 27  from timelinelib.wxgui.framework import Dialog 
 28  from timelinelib.config.paths import EVENT_ICONS_DIR 
 29   
 30   
31 -class PreferencesDialog(Dialog):
32 33 """ 34 <BoxSizerVertical> 35 <Notebook border="ALL" proportion="1" width="600"> 36 <Panel notebookLabel="$(general_text)"> 37 <BoxSizerVertical> 38 <FlexGridSizer columns="1" border="ALL"> 39 <CheckBox 40 name="open_recent_checkbox" 41 event_EVT_CHECKBOX="on_open_recent_change" 42 label="$(open_recent_text)" 43 /> 44 <CheckBox 45 name="inertial_scrolling_checkbox" 46 event_EVT_CHECKBOX="on_inertial_scrolling_changed" 47 label="$(inertial_scrolling_text)" 48 /> 49 <CheckBox 50 name="never_period_point_checkbox" 51 event_EVT_CHECKBOX="on_never_period_point_changed" 52 label="$(never_period_point_text)" 53 /> 54 <CheckBox 55 name="center_text_checkbox" 56 event_EVT_CHECKBOX="on_center_text_changed" 57 label="$(center_text_text)" 58 /> 59 <CheckBox 60 name="display_checkmark_on_events_done_checkbox" 61 event_EVT_CHECKBOX="on_display_checkmark_on_events_done_changed" 62 label="$(display_checkmark_on_events_done_text)" 63 /> 64 <CheckBox 65 name="uncheck_time_for_new_events" 66 event_EVT_CHECKBOX="on_uncheck_time_for_new_events" 67 label="$(uncheck_time_for_new_events_text)" 68 /> 69 <CheckBox 70 name="text_below_icon" 71 event_EVT_CHECKBOX="on_text_below_icon" 72 label="$(text_below_icon_text)" 73 /> 74 <CheckBox 75 name="filtered_listbox_export" 76 event_EVT_CHECKBOX="on_filtered_listbox_export" 77 label="$(text_filtered_listbox_export)" 78 /> 79 <Button 80 name="select_tab_order" 81 event_EVT_BUTTON="on_tab_order_click" 82 label="$(tab_order_text)" 83 align="ALIGN_LEFT" 84 /> 85 <BoxSizerHorizontal> 86 <StaticText 87 name="vertical_space_between_events_text" 88 label="$(vertical_space_between_events_text)" 89 align="ALIGN_CENTER_VERTICAL" 90 /> 91 <SpinCtrl 92 name="vertical_space_between_events" 93 event_EVT_SPINCTRL="on_vertical_space_between_events_click" 94 align="ALIGN_LEFT" 95 width="50" 96 /> 97 </BoxSizerHorizontal> 98 <RadioBox 99 name="legend_positions" 100 choices="$(legend_positions)" 101 label="$(legend_positions_text)" 102 /> 103 </FlexGridSizer> 104 </BoxSizerVertical> 105 </Panel> 106 <Panel notebookLabel="$(date_time_text)"> 107 <BoxSizerVertical> 108 <FlexGridSizer columns="2" border="ALL"> 109 <StaticText 110 label="$(week_start_text)" 111 align="ALIGN_CENTER_VERTICAL" 112 /> 113 <Choice 114 name="week_start_choice" 115 event_EVT_CHOICE="on_week_start_changed" 116 choices="$(week_start_choices)" 117 /> 118 <Button 119 name="select_date_formatter" 120 event_EVT_BUTTON="on_date_formatter_click" 121 label="$(date_formatter_text)" 122 align="ALIGN_LEFT" 123 /> 124 <StaticText 125 name="current_date_format" 126 align="ALIGN_CENTER_VERTICAL" 127 /> 128 <CheckBox 129 name="skip_s_in_decade_text" 130 event_EVT_CHECKBOX="on_skip_s_in_decade_text" 131 label="$(skip_s_in_decade_text_text)" 132 /> 133 <Spacer /> 134 <CheckBox 135 name="never_use_time_checkbox" 136 event_EVT_CHECKBOX="on_never_use_time_change" 137 label="$(never_use_time_text)" 138 /> 139 <Spacer /> 140 </FlexGridSizer> 141 </BoxSizerVertical> 142 </Panel> 143 <Panel notebookLabel="$(fonts_text)"> 144 <BoxSizerVertical name="font_sizer"> 145 <FlexGridSizer columns="3" border="ALL"> 146 <StaticText 147 label="$(major_strip_text)" 148 align="ALIGN_CENTER_VERTICAL" 149 /> 150 <Button 151 name="select_major_strip" 152 event_EVT_BUTTON="on_major_strip_click" 153 label="$(edit_text)" 154 /> 155 <StaticText 156 name="major_strip_font_sample" 157 label="Timeline" 158 /> 159 <StaticText 160 label="$(minor_strip_text)" 161 align="ALIGN_CENTER_VERTICAL" 162 /> 163 <Button 164 name="select_minor_strip" 165 event_EVT_BUTTON="on_minor_strip_click" 166 label="$(edit_text)" 167 /> 168 <StaticText 169 name="minor_strip_font_sample" 170 label="Timeline" 171 align="ALIGN_CENTER_VERTICAL" 172 /> 173 <StaticText 174 label="$(legends_text)" 175 align="ALIGN_CENTER_VERTICAL" 176 /> 177 <Button 178 name="select_legend" 179 event_EVT_BUTTON="on_legend_click" 180 label="$(edit_text)" 181 /> 182 <StaticText 183 name="legend_font_sample" 184 label="Timeline" 185 align="ALIGN_CENTER_VERTICAL" 186 /> 187 <StaticText 188 label="$(balloon_text)" 189 align="ALIGN_CENTER_VERTICAL" 190 /> 191 <Button 192 name="select_balloon" 193 event_EVT_BUTTON="on_balloon_click" 194 label="$(edit_text)" 195 /> 196 <StaticText 197 name="balloon_font_sample" 198 label="Timeline" 199 /> 200 </FlexGridSizer> 201 </BoxSizerVertical> 202 </Panel> 203 <Panel notebookLabel="$(colours_text)"> 204 <BoxSizerVertical> 205 <FlexGridSizer columns="2" border="ALL"> 206 <StaticText 207 label="$(bg_colour_text)" 208 align="ALIGN_CENTER_VERTICAL" 209 /> 210 <ColourSelect 211 name="bg_colorpicker" 212 align="ALIGN_CENTER_VERTICAL" 213 width="60" 214 height="30" 215 /> 216 <StaticText 217 label="$(minor_strip_colour_text)" 218 align="ALIGN_CENTER_VERTICAL" 219 /> 220 <ColourSelect 221 name="minor_strip_colorpicker" 222 align="ALIGN_CENTER_VERTICAL" 223 width="60" 224 height="30" 225 /> 226 <StaticText 227 label="$(major_strip_colour_text)" 228 align="ALIGN_CENTER_VERTICAL" 229 /> 230 <ColourSelect 231 name="major_strip_colorpicker" 232 align="ALIGN_CENTER_VERTICAL" 233 width="60" 234 height="30" 235 /> 236 <StaticText 237 label="$(now_line_colour_text)" 238 align="ALIGN_CENTER_VERTICAL" 239 /> 240 <ColourSelect 241 name="now_line_colorpicker" 242 align="ALIGN_CENTER_VERTICAL" 243 width="60" 244 height="30" 245 /> 246 <StaticText 247 label="$(weekend_colour_text)" 248 align="ALIGN_CENTER_VERTICAL" 249 /> 250 <BoxSizerHorizontal> 251 <ColourSelect 252 name="weekend_colorpicker" 253 align="ALIGN_CENTER_VERTICAL" 254 width="60" 255 height="30" 256 /> 257 <Spacer /> 258 <CheckBox 259 name="colorize_weekends" 260 event_EVT_CHECKBOX="on_colorize_weekends" 261 label="$(colorize_weekends_text)" 262 /> 263 </BoxSizerHorizontal> 264 </FlexGridSizer> 265 </BoxSizerVertical> 266 </Panel> 267 <Panel notebookLabel="$(icons_text)"> 268 <BoxSizerVertical name="x"> 269 <FlexGridSizer columns="3" border="ALL"> 270 <StaticText 271 label="$(fuzzy_icon_text)" 272 align="ALIGN_CENTER_VERTICAL" 273 /> 274 <Choice 275 name="fuzzy_icon_choice" 276 event_EVT_CHOICE="on_fuzzy_icon_changed" 277 /> 278 <StaticBitmap 279 name="fuzzy_icon" 280 /> 281 <StaticText 282 label="$(locked_icon_text)" 283 align="ALIGN_CENTER_VERTICAL" 284 /> 285 <Choice 286 name="locked_icon_choice" 287 event_EVT_CHOICE="on_locked_icon_changed" 288 /> 289 <StaticBitmap 290 name="locked_icon" 291 /> 292 <StaticText 293 label="$(hyperlink_icon_text)" 294 align="ALIGN_CENTER_VERTICAL" 295 /> 296 <Choice 297 name="hyperlink_icon_choice" 298 event_EVT_CHOICE="on_hyperlink_icon_changed" 299 /> 300 <StaticBitmap 301 name="hyperlink_icon" 302 /> 303 </FlexGridSizer> 304 </BoxSizerVertical> 305 </Panel> 306 <Panel name="experimental_panel" notebookLabel="$(experimental_text)"> 307 <BoxSizerVertical> 308 <FlexGridSizer 309 name="experimental_panel_sizer" 310 columns="1" 311 border="ALL" 312 /> 313 </BoxSizerVertical> 314 </Panel> 315 </Notebook> 316 <DialogButtonsCloseSizer border="LEFT|BOTTOM|RIGHT" /> 317 </BoxSizerVertical> 318 """ 319
320 - def __init__(self, parent, config):
321 Dialog.__init__(self, PreferencesDialogController, parent, { 322 "general_text": _("General"), 323 "open_recent_text": _("Open most recent timeline on startup"), 324 "inertial_scrolling_text": _("Use inertial scrolling"), 325 "never_period_point_text": _("Never show period Events as point Events"), 326 "center_text_text": _("Center Event texts"), 327 "uncheck_time_for_new_events_text": _("Uncheck time checkbox for new events"), 328 "text_below_icon_text": _("Balloon text below icon"), 329 "text_filtered_listbox_export": _("Filter items in listbox export, on categories"), 330 "tab_order_text": _("Select Event Editor Tab Order"), 331 "date_formatter_text": _("Select Date format"), 332 "date_time_text": _("Date && Time"), 333 "week_start_text": _("Week start on:"), 334 "week_start_choices": [_("Monday"), _("Sunday")], 335 "fonts_text": _("Fonts"), 336 "colours_text": _("Colours"), 337 "major_strip_text": _("Major Strips:"), 338 "minor_strip_text": _("Minor Strips:"), 339 "balloon_text": _("Balloons:"), 340 "icons_text": _("Icons"), 341 "fuzzy_icon_text": _("Fuzzy icon"), 342 "locked_icon_text": _("Locked icon"), 343 "hyperlink_icon_text": _("Hyperlink icon"), 344 "legends_text": _("Legends:"), 345 "edit_text": _("Edit"), 346 "experimental_text": _("Experimental Features"), 347 "minor_strip_colour_text": _("Minor strip divider line:"), 348 "major_strip_colour_text": _("Major strip divider line:"), 349 "now_line_colour_text": _("Now line:"), 350 "weekend_colour_text": _("Weekends:"), 351 "bg_colour_text": _("Background"), 352 "vertical_space_between_events_text": _("Vertical space between Events (px)"), 353 "colorize_weekends_text": _("Colorize weekends"), 354 "skip_s_in_decade_text_text": _("Skip s in decade text"), 355 "display_checkmark_on_events_done_text": _("Display checkmark when events are done"), 356 "never_use_time_text": _("Never use time precision for events"), 357 "legend_positions_text": _("Legend Position"), 358 "legend_positions": [_("Bottom-Left"), _("Top-Left"), _("Top-Right"), _("Bottom-Right")], 359 }, title=_("Preferences")) 360 self.controller.on_init(config, ExperimentalFeatures()) 361 self.font_sizer.Layout()
362
363 - def SetIconsChoices(self, choices):
364 self.fuzzy_icon_choice.SetItems(choices) 365 self.locked_icon_choice.SetItems(choices) 366 self.hyperlink_icon_choice.SetItems(choices)
367
368 - def SetFuzzyIcon(self, icon_name):
369 self._setIcon(self.fuzzy_icon_choice, icon_name)
370
371 - def SetLockedIcon(self, icon_name):
372 self._setIcon(self.locked_icon_choice, icon_name)
373
374 - def SetHyperlinkIcon(self, icon_name):
375 self._setIcon(self.hyperlink_icon_choice, icon_name)
376
377 - def SetCurrentDateFormat(self, current_date_format):
378 self.current_date_format.SetLabel(current_date_format)
379
380 - def _setIcon(self, icon_ctrl, icon_name):
381 if not icon_ctrl.SetStringSelection(icon_name): 382 icon_ctrl.Select(0)
383
384 - def DisplayIcons(self):
385 self.fuzzy_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.fuzzy_icon_choice.GetStringSelection()))) 386 self.locked_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.locked_icon_choice.GetStringSelection()))) 387 self.hyperlink_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.hyperlink_icon_choice.GetStringSelection()))) 388 self.Refresh()
389
390 - def Destroy(self):
391 self.controller.on_close() 392 super(PreferencesDialog, self).Destroy()
393
394 - def SetOpenRecentCheckboxValue(self, value):
395 self.open_recent_checkbox.SetValue(value)
396
397 - def SetInertialScrollingCheckboxValue(self, value):
398 self.inertial_scrolling_checkbox.SetValue(value)
399
400 - def SetNeverPeriodPointCheckboxValue(self, value):
401 self.never_period_point_checkbox.SetValue(value)
402
404 self.uncheck_time_for_new_events.SetValue(value)
405
406 - def SetTextBelowIconCheckboxValue(self, value):
407 self.text_below_icon.SetValue(value)
408
409 - def SetFilteredListboxExport(self, value):
410 self.filtered_listbox_export.SetValue(value)
411
412 - def SetCenterTextCheckboxValue(self, value):
413 self.center_text_checkbox.SetValue(value)
414
415 - def SetDisplayCheckmarkOnEventsDone(self, value):
416 self.display_checkmark_on_events_done_checkbox.SetValue(value)
417
418 - def SetWeekStartSelection(self, value):
419 self.week_start_choice.Select(value)
420
421 - def SetNeverUseTime(self, value):
422 self.never_use_time_checkbox.SetValue(value)
423
424 - def GetNeverUseTime(self):
425 return self.never_use_time_checkbox.GetValue()
426
427 - def AddExperimentalFeatures(self, features):
428 for feature in features: 429 name = feature.get_display_name() 430 cb = wx.CheckBox(self.experimental_panel, label=name, name=name) 431 cb.SetValue(feature.enabled()) 432 self.experimental_panel_sizer.Add(cb) 433 self.Bind(wx.EVT_CHECKBOX, self.controller.on_experimental_changed, cb) 434 self.experimental_panel_sizer.Fit(self) 435 self.Fit()
436
437 - def ShowSelectTabOrderDialog(self, config):
438 dialog = EventEditorTabSelectionDialog(self, config) 439 dialog.ShowModal() 440 dialog.Destroy()
441
442 - def ShowSelectDateFormatDialog(self, config):
443 dialog = DateFormatDialog(self, config) 444 dialog.ShowModal() 445 dialog.Destroy()
446
447 - def ShowEditFontDialog(self, font):
448 return edit_font_data(self, font)
449
450 - def GetMinorStripColor(self):
451 return self.minor_strip_colorpicker.GetValue()
452
453 - def SetMinorStripColor(self, new_color):
454 self.minor_strip_colorpicker.SetValue(new_color)
455
456 - def GetMajorStripColor(self):
457 return self.major_strip_colorpicker.GetValue()
458
459 - def SetMajorStripColor(self, new_color):
460 self.major_strip_colorpicker.SetValue(new_color)
461
462 - def GetNowLineColor(self):
463 return self.now_line_colorpicker.GetValue()
464
465 - def SetNowLineColor(self, new_color):
466 self.now_line_colorpicker.SetValue(new_color)
467
468 - def GetBgColor(self):
469 return self.bg_colorpicker.GetValue()
470
471 - def SetBgColor(self, new_color):
472 self.bg_colorpicker.SetValue(new_color)
473
474 - def GetWeekendColor(self):
475 return self.weekend_colorpicker.GetValue()
476
477 - def SetWeekendColor(self, new_color):
478 self.weekend_colorpicker.SetValue(new_color)
479
480 - def SetVerticalSpaceBetweenEvents(self, value):
481 self.vertical_space_between_events.SetValue(value)
482
484 return self.vertical_space_between_events.GetValue()
485
486 - def SetColorizeWeekends(self, value):
487 return self.colorize_weekends.SetValue(value)
488
489 - def GetColorizeWeekends(self):
490 return self.colorize_weekends.IsChecked()
491
492 - def SetSkipSInDecadeText(self, value):
493 return self.skip_s_in_decade_text.SetValue(value)
494
495 - def GetSkipSInDecadeText(self):
496 return self.skip_s_in_decade_text.IsChecked()
497
498 - def SetMajorStripFont(self, font):
499 self._SetFont(self.major_strip_font_sample, font)
500
501 - def SetMinorStripFont(self, font):
502 self._SetFont(self.minor_strip_font_sample, font)
503
504 - def SetLegendFont(self, font):
505 self._SetFont(self.legend_font_sample, font)
506
507 - def SetBalloonFont(self, font):
508 self._SetFont(self.balloon_font_sample, font)
509
510 - def GetLegendPos(self):
511 return self.legend_positions.GetSelection()
512
513 - def SetLegendPos(self, pos):
514 self.legend_positions.SetSelection(pos)
515
516 - def _SetFont(self, control, font):
517 control.SetFont(font) 518 control.SetForegroundColour(font.WxColor) 519 self.font_sizer.Layout()
520