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 <CheckBox 141 name="use_second_checkbox" 142 event_EVT_CHECKBOX="on_use_second_change" 143 label="$(use_second_text)" 144 /> 145 <Spacer /> 146 <CheckBox 147 name="use_date_default_values_checkbox" 148 event_EVT_CHECKBOX="on_use_date_default_values" 149 label="$(use_date_default_values)" 150 /> 151 <Spacer /> 152 <StaticText 153 label="$(default_year)" 154 align="ALIGN_CENTER_VERTICAL" 155 /> 156 <TextCtrl 157 name="txt_default_year" 158 fit_text="MMMM" 159 /> 160 <StaticText 161 label="$(default_month)" 162 align="ALIGN_CENTER_VERTICAL" 163 /> 164 <TextCtrl 165 name="txt_default_month" 166 fit_text="MM" 167 /> 168 <StaticText 169 label="$(default_day)" 170 align="ALIGN_CENTER_VERTICAL" 171 /> 172 <TextCtrl 173 name="txt_default_day" 174 fit_text="MM" 175 /> 176 <RadioBox 177 name="time_scale_positions" 178 choices="$(time_scale_positions)" 179 label="$(time_scale_positions_text)" 180 /> 181 </FlexGridSizer> 182 </BoxSizerVertical> 183 </Panel> 184 <Panel notebookLabel="$(fonts_text)"> 185 <BoxSizerVertical name="font_sizer"> 186 <FlexGridSizer columns="3" border="ALL"> 187 <StaticText 188 label="$(major_strip_text)" 189 align="ALIGN_CENTER_VERTICAL" 190 /> 191 <Button 192 name="select_major_strip" 193 event_EVT_BUTTON="on_major_strip_click" 194 label="$(edit_text)" 195 /> 196 <StaticText 197 name="major_strip_font_sample" 198 label="Timeline" 199 /> 200 <StaticText 201 label="$(minor_strip_text)" 202 align="ALIGN_CENTER_VERTICAL" 203 /> 204 <Button 205 name="select_minor_strip" 206 event_EVT_BUTTON="on_minor_strip_click" 207 label="$(edit_text)" 208 /> 209 <StaticText 210 name="minor_strip_font_sample" 211 label="Timeline" 212 align="ALIGN_CENTER_VERTICAL" 213 /> 214 <StaticText 215 label="$(legends_text)" 216 align="ALIGN_CENTER_VERTICAL" 217 /> 218 <Button 219 name="select_legend" 220 event_EVT_BUTTON="on_legend_click" 221 label="$(edit_text)" 222 /> 223 <StaticText 224 name="legend_font_sample" 225 label="Timeline" 226 align="ALIGN_CENTER_VERTICAL" 227 /> 228 <StaticText 229 label="$(balloon_text)" 230 align="ALIGN_CENTER_VERTICAL" 231 /> 232 <Button 233 name="select_balloon" 234 event_EVT_BUTTON="on_balloon_click" 235 label="$(edit_text)" 236 /> 237 <StaticText 238 name="balloon_font_sample" 239 label="Timeline" 240 /> 241 </FlexGridSizer> 242 </BoxSizerVertical> 243 </Panel> 244 <Panel notebookLabel="$(colours_text)"> 245 <BoxSizerVertical> 246 <FlexGridSizer columns="2" border="ALL"> 247 <StaticText 248 label="$(bg_colour_text)" 249 align="ALIGN_CENTER_VERTICAL" 250 /> 251 <ColourSelect 252 name="bg_colorpicker" 253 align="ALIGN_CENTER_VERTICAL" 254 width="60" 255 height="30" 256 /> 257 <StaticText 258 label="$(minor_strip_colour_text)" 259 align="ALIGN_CENTER_VERTICAL" 260 /> 261 <ColourSelect 262 name="minor_strip_colorpicker" 263 align="ALIGN_CENTER_VERTICAL" 264 width="60" 265 height="30" 266 /> 267 <StaticText 268 label="$(major_strip_colour_text)" 269 align="ALIGN_CENTER_VERTICAL" 270 /> 271 <ColourSelect 272 name="major_strip_colorpicker" 273 align="ALIGN_CENTER_VERTICAL" 274 width="60" 275 height="30" 276 /> 277 <StaticText 278 label="$(now_line_colour_text)" 279 align="ALIGN_CENTER_VERTICAL" 280 /> 281 <BoxSizerHorizontal> 282 <ColourSelect 283 name="now_line_colorpicker" 284 align="ALIGN_CENTER_VERTICAL" 285 width="60" 286 height="30" 287 /> 288 <Spacer /> 289 <CheckBox 290 name="use_bold_nowline" 291 event_EVT_CHECKBOX="on_use_bold_nowline" 292 label="$(use_bold_nowline_text)" 293 /> 294 </BoxSizerHorizontal> 295 <StaticText 296 label="$(weekend_colour_text)" 297 align="ALIGN_CENTER_VERTICAL" 298 /> 299 <BoxSizerHorizontal> 300 <ColourSelect 301 name="weekend_colorpicker" 302 align="ALIGN_CENTER_VERTICAL" 303 width="60" 304 height="30" 305 /> 306 <Spacer /> 307 <CheckBox 308 name="colorize_weekends" 309 event_EVT_CHECKBOX="on_colorize_weekends" 310 label="$(colorize_weekends_text)" 311 /> 312 </BoxSizerHorizontal> 313 </FlexGridSizer> 314 </BoxSizerVertical> 315 </Panel> 316 <Panel notebookLabel="$(icons_text)"> 317 <BoxSizerVertical name="x"> 318 <FlexGridSizer columns="3" border="ALL"> 319 <StaticText 320 label="$(fuzzy_icon_text)" 321 align="ALIGN_CENTER_VERTICAL" 322 /> 323 <Choice 324 name="fuzzy_icon_choice" 325 event_EVT_CHOICE="on_fuzzy_icon_changed" 326 /> 327 <StaticBitmap 328 name="fuzzy_icon" 329 /> 330 <StaticText 331 label="$(locked_icon_text)" 332 align="ALIGN_CENTER_VERTICAL" 333 /> 334 <Choice 335 name="locked_icon_choice" 336 event_EVT_CHOICE="on_locked_icon_changed" 337 /> 338 <StaticBitmap 339 name="locked_icon" 340 /> 341 <StaticText 342 label="$(hyperlink_icon_text)" 343 align="ALIGN_CENTER_VERTICAL" 344 /> 345 <Choice 346 name="hyperlink_icon_choice" 347 event_EVT_CHOICE="on_hyperlink_icon_changed" 348 /> 349 <StaticBitmap 350 name="hyperlink_icon" 351 /> 352 </FlexGridSizer> 353 </BoxSizerVertical> 354 </Panel> 355 <Panel name="experimental_panel" notebookLabel="$(experimental_text)"> 356 <BoxSizerVertical> 357 <FlexGridSizer 358 name="experimental_panel_sizer" 359 columns="1" 360 border="ALL" 361 /> 362 </BoxSizerVertical> 363 </Panel> 364 </Notebook> 365 <DialogButtonsCloseSizer border="LEFT|BOTTOM|RIGHT" /> 366 </BoxSizerVertical> 367 """ 368
369 - def __init__(self, parent, config):
370 Dialog.__init__(self, PreferencesDialogController, parent, { 371 "general_text": _("General"), 372 "open_recent_text": _("Open most recent timeline on startup"), 373 "inertial_scrolling_text": _("Use inertial scrolling"), 374 "never_period_point_text": _("Never show period Events as point Events"), 375 "center_text_text": _("Center Event texts"), 376 "uncheck_time_for_new_events_text": _("Uncheck time checkbox for new events"), 377 "text_below_icon_text": _("Balloon text below icon"), 378 "text_filtered_listbox_export": _("Filter items in listbox export, on categories"), 379 "tab_order_text": _("Select Event Editor Tab Order"), 380 "date_formatter_text": _("Select Date format"), 381 "date_time_text": _("Date && Time"), 382 "week_start_text": _("Week start on:"), 383 "week_start_choices": [_("Monday"), _("Sunday")], 384 "fonts_text": _("Fonts"), 385 "colours_text": _("Colours"), 386 "major_strip_text": _("Major Strips:"), 387 "minor_strip_text": _("Minor Strips:"), 388 "balloon_text": _("Balloons:"), 389 "icons_text": _("Icons"), 390 "fuzzy_icon_text": _("Fuzzy icon"), 391 "locked_icon_text": _("Locked icon"), 392 "hyperlink_icon_text": _("Hyperlink icon"), 393 "legends_text": _("Legends:"), 394 "edit_text": _("Edit"), 395 "experimental_text": _("Experimental Features"), 396 "minor_strip_colour_text": _("Minor strip divider line:"), 397 "major_strip_colour_text": _("Major strip divider line:"), 398 "now_line_colour_text": _("Now line:"), 399 "weekend_colour_text": _("Weekends:"), 400 "use_bold_nowline_text": _("Use bold line"), 401 "bg_colour_text": _("Background"), 402 "vertical_space_between_events_text": _("Vertical space between Events (px)"), 403 "colorize_weekends_text": _("Colorize weekends"), 404 "skip_s_in_decade_text_text": _("Skip s in decade text"), 405 "display_checkmark_on_events_done_text": _("Display checkmark when events are done"), 406 "never_use_time_text": _("Never use time precision for events"), 407 "use_second_text": _("Use second precision for time"), 408 "legend_positions_text": _("Legend Position"), 409 "legend_positions": [_("Bottom-Left"), _("Top-Left"), _("Top-Right"), _("Bottom-Right")], 410 "time_scale_positions": [_("Top"), _("Center"), _("Bottom")], 411 "time_scale_positions_text": _("Time scale position"), 412 "default_year": _("Default Year"), 413 "default_month": _("Default Month"), 414 "default_day": _("Default Day"), 415 "use_date_default_values": _("Use date default values"), 416 }, title=_("Preferences")) 417 self.controller.on_init(config, ExperimentalFeatures()) 418 self.font_sizer.Layout()
419
420 - def SetIconsChoices(self, choices):
421 self.fuzzy_icon_choice.SetItems(choices) 422 self.locked_icon_choice.SetItems(choices) 423 self.hyperlink_icon_choice.SetItems(choices)
424
425 - def SetFuzzyIcon(self, icon_name):
426 self._setIcon(self.fuzzy_icon_choice, icon_name)
427
428 - def SetLockedIcon(self, icon_name):
429 self._setIcon(self.locked_icon_choice, icon_name)
430
431 - def SetHyperlinkIcon(self, icon_name):
432 self._setIcon(self.hyperlink_icon_choice, icon_name)
433
434 - def SetCurrentDateFormat(self, current_date_format):
435 self.current_date_format.SetLabel(current_date_format)
436
437 - def _setIcon(self, icon_ctrl, icon_name):
438 if not icon_ctrl.SetStringSelection(icon_name): 439 icon_ctrl.Select(0)
440
441 - def DisplayIcons(self):
442 self.fuzzy_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.fuzzy_icon_choice.GetStringSelection()))) 443 self.locked_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.locked_icon_choice.GetStringSelection()))) 444 self.hyperlink_icon.SetBitmap(wx.Bitmap(os.path.join(EVENT_ICONS_DIR, self.hyperlink_icon_choice.GetStringSelection()))) 445 self.Refresh()
446
447 - def Destroy(self):
448 self.controller.on_close() 449 super(PreferencesDialog, self).Destroy()
450
451 - def SetOpenRecentCheckboxValue(self, value):
452 self.open_recent_checkbox.SetValue(value)
453
454 - def SetInertialScrollingCheckboxValue(self, value):
455 self.inertial_scrolling_checkbox.SetValue(value)
456
457 - def SetNeverPeriodPointCheckboxValue(self, value):
458 self.never_period_point_checkbox.SetValue(value)
459
461 self.uncheck_time_for_new_events.SetValue(value)
462
463 - def SetTextBelowIconCheckboxValue(self, value):
464 self.text_below_icon.SetValue(value)
465
466 - def SetFilteredListboxExport(self, value):
467 self.filtered_listbox_export.SetValue(value)
468
469 - def SetCenterTextCheckboxValue(self, value):
470 self.center_text_checkbox.SetValue(value)
471
472 - def SetDisplayCheckmarkOnEventsDone(self, value):
473 self.display_checkmark_on_events_done_checkbox.SetValue(value)
474
475 - def SetWeekStartSelection(self, value):
476 self.week_start_choice.Select(value)
477
478 - def SetNeverUseTime(self, value):
479 self.never_use_time_checkbox.SetValue(value)
480
481 - def SetUseSecond(self, value):
482 self.use_second_checkbox.SetValue(value)
483
484 - def SetUseDateDefaultValues(self, value):
485 self.use_date_default_values_checkbox.SetValue(value)
486
487 - def SetDefaultYear(self, value):
488 self.txt_default_year.SetValue(value)
489
490 - def SetDefaultMonth(self, value):
491 self.txt_default_month.SetValue(value)
492
493 - def SetDefaultDay(self, value):
494 self.txt_default_day.SetValue(value)
495
496 - def GetDefaultYear(self):
497 return self.txt_default_year.GetValue()
498
499 - def GetDefaultMonth(self):
500 return self.txt_default_month.GetValue()
501
502 - def GetDefaultDay(self):
503 return self.txt_default_day.GetValue()
504
505 - def GetNeverUseTime(self):
506 return self.never_use_time_checkbox.GetValue()
507
508 - def GetUseSecond(self):
509 return self.use_second_checkbox.GetValue()
510
511 - def GetUseDateDefaultValues(self):
512 return self.use_date_default_values_checkbox.GetValue()
513
514 - def AddExperimentalFeatures(self, features):
515 for feature in features: 516 name = feature.get_display_name() 517 cb = wx.CheckBox(self.experimental_panel, label=name, name=name) 518 cb.SetValue(feature.enabled()) 519 self.experimental_panel_sizer.Add(cb) 520 self.Bind(wx.EVT_CHECKBOX, self.controller.on_experimental_changed, cb) 521 self.experimental_panel_sizer.Fit(self) 522 self.Fit()
523
524 - def ShowSelectTabOrderDialog(self, config):
525 dialog = EventEditorTabSelectionDialog(self, config) 526 dialog.ShowModal() 527 dialog.Destroy()
528
529 - def ShowSelectDateFormatDialog(self, config):
530 dialog = DateFormatDialog(self, config) 531 dialog.ShowModal() 532 dialog.Destroy()
533
534 - def ShowEditFontDialog(self, font):
535 return edit_font_data(self, font)
536
537 - def GetMinorStripColor(self):
538 return self.minor_strip_colorpicker.GetValue()
539
540 - def SetMinorStripColor(self, new_color):
541 self.minor_strip_colorpicker.SetValue(new_color)
542
543 - def GetMajorStripColor(self):
544 return self.major_strip_colorpicker.GetValue()
545
546 - def SetMajorStripColor(self, new_color):
547 self.major_strip_colorpicker.SetValue(new_color)
548
549 - def GetNowLineColor(self):
550 return self.now_line_colorpicker.GetValue()
551
552 - def SetNowLineColor(self, new_color):
553 self.now_line_colorpicker.SetValue(new_color)
554
555 - def GetBgColor(self):
556 return self.bg_colorpicker.GetValue()
557
558 - def SetBgColor(self, new_color):
559 self.bg_colorpicker.SetValue(new_color)
560
561 - def GetWeekendColor(self):
562 return self.weekend_colorpicker.GetValue()
563
564 - def SetWeekendColor(self, new_color):
565 self.weekend_colorpicker.SetValue(new_color)
566
567 - def SetVerticalSpaceBetweenEvents(self, value):
568 self.vertical_space_between_events.SetValue(value)
569
571 return self.vertical_space_between_events.GetValue()
572
573 - def SetColorizeWeekends(self, value):
574 return self.colorize_weekends.SetValue(value)
575
576 - def GetUseBoldNowline(self):
577 return self.use_bold_nowline.IsChecked()
578
579 - def SetUseBoldNowline(self, value):
580 return self.use_bold_nowline.SetValue(value)
581
582 - def GetColorizeWeekends(self):
583 return self.colorize_weekends.IsChecked()
584
585 - def SetSkipSInDecadeText(self, value):
586 return self.skip_s_in_decade_text.SetValue(value)
587
588 - def GetSkipSInDecadeText(self):
589 return self.skip_s_in_decade_text.IsChecked()
590
591 - def SetMajorStripFont(self, font):
592 self._SetFont(self.major_strip_font_sample, font)
593
594 - def SetMinorStripFont(self, font):
595 self._SetFont(self.minor_strip_font_sample, font)
596
597 - def SetLegendFont(self, font):
598 self._SetFont(self.legend_font_sample, font)
599
600 - def SetBalloonFont(self, font):
601 self._SetFont(self.balloon_font_sample, font)
602
603 - def GetLegendPos(self):
604 return self.legend_positions.GetSelection()
605
606 - def SetLegendPos(self, pos):
607 self.legend_positions.SetSelection(pos)
608
609 - def GetTimeScalePos(self):
610 return self.time_scale_positions.GetSelection()
611
612 - def SetTimeScalePos(self, pos):
613 self.time_scale_positions.SetSelection(pos)
614
615 - def _SetFont(self, control, font):
616 control.SetFont(font) 617 control.SetForegroundColour(font.WxColor) 618 self.font_sizer.Layout()
619