1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20
21 from timelinelib.db.utils import safe_locking
22 from timelinelib.repositories.dbwrapper import DbWrapperEventRepository
23 from timelinelib.wxgui.dialogs.editcontainer.view import EditContainerDialog
24 from timelinelib.wxgui.dialogs.editevent.controller import EditEventDialogController
25 from timelinelib.wxgui.framework import Dialog
26 from timelinelib.wxgui.utils import _set_focus_and_select
27 from timelinelib.wxgui.dialogs.duplicateevent.view import DuplicateEventDialog
28
29
31
32 """
33 <BoxSizerVertical>
34 <StaticBoxSizerVertical label="$(properties_label)" border="ALL" proportion="1">
35 <FlexGridSizer name="grid_sizer" columns="2" growableColumns="1" border="ALL" proportion="1">
36 %s
37 </FlexGridSizer>
38 </StaticBoxSizerVertical>
39 <CheckBox
40 name="add_more_checkbox"
41 label="$(add_more_label)"
42 border="LEFT|RIGHT|BOTTOM"
43 />
44 <BoxSizerHorizontal border="LEFT|RIGHT|BOTTOM">
45 <TwoStateButton
46 initial_state_label="$(enlarge)"
47 second_state_label="$(reduce)"
48 event_EVT_INITIAL_STATE_CLICKED="on_enlarge_click"
49 event_EVT_SECOND_STATE_CLICKED="on_reduce_click"
50 />
51 <Spacer />
52 <Button
53 name="duplicate"
54 label="$(duplicate_label)"
55 event_EVT_BUTTON="on_duplicate"
56 />
57 <StretchSpacer />
58 <DialogButtonsOkCancelSizer
59 event_EVT_BUTTON__ID_OK="on_ok_clicked"
60 />
61 </BoxSizerHorizontal>
62 </BoxSizerVertical>
63 """
64
65 TIME_DETAILS_ROW = """
66 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(when_label)" />
67 <BoxSizerHorizontal>
68 <PeriodPicker
69 name="period_picker"
70 time_type="$(time_type)"
71 config="$(config)"
72 />
73 </BoxSizerHorizontal>
74 """
75
76 CHECKBOX_ROW = """
77 <Spacer />
78 <FlexGridSizer rows="1">
79 <CheckBox
80 name="fuzzy_checkbox"
81 label="$(fuzzy_checkbox_text)"
82 />
83 <CheckBox
84 name="locked_checkbox"
85 event_EVT_CHECKBOX="on_locked_checkbox_changed"
86 label="$(locked_checkbox_text)"
87 />
88 <CheckBox
89 name="ends_today_checkbox"
90 label="$(ends_today_checkbox_text)"
91 />
92 </FlexGridSizer>
93 """
94
95 TEXT_FIELD_ROW = """
96 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(text_label)" />
97 <TextCtrl name="name" />
98 """
99
100 CATEGORY_LISTBOX_ROW = """
101 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(category_label)" />
102 <CategoryChoice
103 name="category_choice"
104 allow_add="True"
105 timeline="$(db)"
106 align="ALIGN_LEFT"
107 />
108 """
109
110 CONTAINER_LISTBOX_ROW = """
111 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(container_label)" />
112 <ContainerChoice
113 name="container_choice"
114 event_EVT_CONTAINER_CHANGED="on_container_changed"
115 db="$(db)"
116 align="ALIGN_LEFT"
117 />
118 """
119
120 NOTEBOOK_ROW = """
121 <Spacer />
122 <Notebook name="notebook" style="BK_DEFAULT">
123 <DescriptionEditor
124 name="description"
125 notebookLabel="$(page_description)"
126 editor="$(self)"
127 proportion="1"
128 />
129 <IconEditor
130 name="icon"
131 notebookLabel="$(page_icon)"
132 editor="$(self)"
133 proportion="1"
134 />
135 <AlertEditor
136 name="alert"
137 notebookLabel="$(page_alert)"
138 editor="$(self)"
139 proportion="1"
140 />
141 <HyperlinkEditor
142 name="hyperlink"
143 notebookLabel="$(page_hyperlink)"
144 editor="$(self)"
145 proportion="1"
146 />
147 <ProgressEditor
148 name="progress"
149 notebookLabel="$(page_progress)"
150 editor="$(self)"
151 proportion="1"
152 />
153 <ColorEditor
154 name="default_color"
155 notebookLabel="$(color)"
156 editor="$(self)"
157 proportion="1"
158 />
159 </Notebook>
160 """
161
162 - def __init__(self, parent, config, title, db, start=None, end=None, event=None):
163 self.parent = parent
164 self.timeline = db
165 self.config = config
166 self.start = start
167 self.event = event
168 self._insert_rows_in_correct_order_in_xml()
169 Dialog.__init__(self, EditEventDialogController, parent, {
170 "self": self,
171 "db": db,
172 "time_type": db.get_time_type(),
173 "config": config,
174 "properties_label": _("Event Properties"),
175 "when_label": _("When:"),
176 "fuzzy_checkbox_text": _("Fuzzy"),
177 "locked_checkbox_text": _("Locked"),
178 "ends_today_checkbox_text": _("Ends today"),
179 "text_label": _("Text:"),
180 "category_label": _("Category:"),
181 "container_label": _("Container:"),
182 "page_description": _("Description"),
183 "page_icon": _("Icon"),
184 "page_alert": _("Alert"),
185 "page_hyperlink": _("Hyperlink"),
186 "page_progress": _("Progress"),
187 "color": _("Default color"),
188 "add_more_label": _("Add more events after this one"),
189 "enlarge": _("&Enlarge"),
190 "reduce": _("&Reduce"),
191 "duplicate_label": _("Save and Duplicate"),
192 }, title=title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
193 self.controller.on_init(
194 config,
195 db.get_time_type(),
196 DbWrapperEventRepository(db),
197 db,
198 start,
199 end,
200 event)
201 self._make_row_with_notebook_growable()
202 self.SetMinSize((800, -1))
203 self.Fit()
204 self.SetMinSize(self.GetSize())
205
208
210 return self.period_picker.GetValue()
211
214
217
220
223
226
229
231 return self.fuzzy_checkbox.GetValue()
232
235
237 return self.locked_checkbox.GetValue()
238
241
244
246 return self.ends_today_checkbox.GetValue()
247
250
253
256
259
262
265
268
271
273 event_data = {}
274 for data_id, editor in self._get_event_data():
275 data = editor.get_data()
276 if data is not None:
277 event_data[data_id] = editor.get_data()
278 return event_data
279
281 for data_id, editor in self._get_event_data():
282 if data_id in event_data:
283 data = event_data[data_id]
284 if data is not None:
285 editor.set_data(data)
286
288 for _, editor in self._get_event_data():
289 editor.clear_data()
290
292 return self.add_more_checkbox.GetValue()
293
295 self.add_more_checkbox.Show(value)
296 self.add_more_checkbox.SetValue(False)
297 self.SetSizerAndFit(self.GetSizer())
298
300 control = {
301 "0": self.period_picker,
302 "1": self.fuzzy_checkbox,
303 "2": self.name,
304 "3": self.category_choice,
305 "4": self.container_choice,
306 ":": self.notebook,
307 }[self.config.event_editor_tab_order[0]]
308 _set_focus_and_select(control)
309
311 self._display_invalid_input(message, self.period_picker)
312
316
318 return [
319 ("description", self.description),
320 ("alert", self.alert),
321 ("icon", self.icon),
322 ("hyperlink", self.hyperlink),
323 ("progress", self.progress),
324 ("default_color", self.default_color)
325 ]
326
338
340 self.grid_sizer.AddGrowableRow(self.config.event_editor_tab_order.index(":"))
341
342
351
352 def edit_function():
353 dialog = create_event_editor()
354 dialog.ShowModal()
355 dialog.Destroy()
356 safe_locking(edit_controller, edit_function)
357
358
363
364 def edit_function():
365 dialog = create_event_editor()
366 dialog.ShowModal()
367 dialog.Destroy()
368 safe_locking(edit_controller, edit_function)
369