1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
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
421 self.fuzzy_icon_choice.SetItems(choices)
422 self.locked_icon_choice.SetItems(choices)
423 self.hyperlink_icon_choice.SetItems(choices)
424
426 self._setIcon(self.fuzzy_icon_choice, icon_name)
427
429 self._setIcon(self.locked_icon_choice, icon_name)
430
432 self._setIcon(self.hyperlink_icon_choice, icon_name)
433
436
437 - def _setIcon(self, icon_ctrl, icon_name):
438 if not icon_ctrl.SetStringSelection(icon_name):
439 icon_ctrl.Select(0)
440
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
450
453
456
459
462
464 self.text_below_icon.SetValue(value)
465
468
470 self.center_text_checkbox.SetValue(value)
471
473 self.display_checkmark_on_events_done_checkbox.SetValue(value)
474
477
480
483
486
489
492
495
497 return self.txt_default_year.GetValue()
498
500 return self.txt_default_month.GetValue()
501
503 return self.txt_default_day.GetValue()
504
506 return self.never_use_time_checkbox.GetValue()
507
509 return self.use_second_checkbox.GetValue()
510
512 return self.use_date_default_values_checkbox.GetValue()
513
523
528
533
536
538 return self.minor_strip_colorpicker.GetValue()
539
541 self.minor_strip_colorpicker.SetValue(new_color)
542
544 return self.major_strip_colorpicker.GetValue()
545
547 self.major_strip_colorpicker.SetValue(new_color)
548
550 return self.now_line_colorpicker.GetValue()
551
553 self.now_line_colorpicker.SetValue(new_color)
554
556 return self.bg_colorpicker.GetValue()
557
559 self.bg_colorpicker.SetValue(new_color)
560
562 return self.weekend_colorpicker.GetValue()
563
565 self.weekend_colorpicker.SetValue(new_color)
566
569
571 return self.vertical_space_between_events.GetValue()
572
575
577 return self.use_bold_nowline.IsChecked()
578
581
583 return self.colorize_weekends.IsChecked()
584
585 - def SetSkipSInDecadeText(self, value):
586 return self.skip_s_in_decade_text.SetValue(value)
587
589 return self.skip_s_in_decade_text.IsChecked()
590
592 self._SetFont(self.major_strip_font_sample, font)
593
595 self._SetFont(self.minor_strip_font_sample, font)
596
598 self._SetFont(self.legend_font_sample, font)
599
601 self._SetFont(self.balloon_font_sample, font)
602
605
608
611
614
619