/src/libreoffice/svtools/source/brwbox/ebbcontrols.cxx
Line | Count | Source |
1 | | /* |
2 | | * This file is part of the LibreOffice project. |
3 | | * |
4 | | * This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
7 | | * |
8 | | * This file incorporates work covered by the following license notice: |
9 | | * |
10 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
11 | | * contributor license agreements. See the NOTICE file distributed |
12 | | * with this work for additional information regarding copyright |
13 | | * ownership. The ASF licenses this file to you under the Apache |
14 | | * License, Version 2.0 (the "License"); you may not use this file |
15 | | * except in compliance with the License. You may obtain a copy of |
16 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
17 | | */ |
18 | | |
19 | | #include "accessibleeditbrowseboxcell.hxx" |
20 | | |
21 | | #include <tools/date.hxx> |
22 | | #include <svtools/editbrowsebox.hxx> |
23 | | #include <vcl/svapp.hxx> |
24 | | #include <vcl/weld/Builder.hxx> |
25 | | #include <vcl/weld/DateFormatter.hxx> |
26 | | #include <vcl/weld/DoubleNumericFormatter.hxx> |
27 | | #include <vcl/weld/LongCurrencyFormatter.hxx> |
28 | | #include <vcl/weld/TimeFormatter.hxx> |
29 | | |
30 | | namespace svt |
31 | | { |
32 | | //= ComboBoxControl |
33 | | ComboBoxControl::ComboBoxControl(BrowserDataWin* pParent) |
34 | 0 | : ControlBase(pParent, u"svt/ui/combocontrol.ui"_ustr, u"ComboControl"_ustr) |
35 | 0 | , m_xWidget(m_xBuilder->weld_combo_box(u"combobox"_ustr)) |
36 | 0 | { |
37 | 0 | InitControlBase(m_xWidget.get()); |
38 | 0 | m_xWidget->set_entry_width_chars(1); // so a smaller than default width can be used |
39 | 0 | m_xWidget->connect_changed(LINK(this, ComboBoxControl, SelectHdl)); |
40 | 0 | m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); |
41 | 0 | m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); |
42 | 0 | m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); |
43 | 0 | m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); |
44 | 0 | m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); |
45 | 0 | m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); |
46 | 0 | m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); |
47 | 0 | } Unexecuted instantiation: svt::ComboBoxControl::ComboBoxControl(BrowserDataWin*) Unexecuted instantiation: svt::ComboBoxControl::ComboBoxControl(BrowserDataWin*) |
48 | | |
49 | | void ComboBoxControl::SetPointFont(const vcl::Font& rFont) |
50 | 0 | { |
51 | 0 | m_xWidget->set_entry_font(rFont); |
52 | 0 | } |
53 | | |
54 | | void ComboBoxControl::dispose() |
55 | 0 | { |
56 | 0 | m_xWidget.reset(); |
57 | 0 | ControlBase::dispose(); |
58 | 0 | } |
59 | | |
60 | | IMPL_LINK_NOARG(ComboBoxControl, SelectHdl, weld::ComboBox&, void) |
61 | 0 | { |
62 | 0 | CallModifyHdls(); |
63 | 0 | } |
64 | | |
65 | | //= ComboBoxCellController |
66 | | ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin) |
67 | 0 | :CellController(pWin) |
68 | 0 | { |
69 | 0 | static_cast<ComboBoxControl&>(GetWindow()).SetModifyHdl(LINK(this, ComboBoxCellController, ModifyHdl)); |
70 | 0 | } |
71 | | |
72 | | IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, LinkParamNone*, void) |
73 | 0 | { |
74 | 0 | callModifyHdl(); |
75 | 0 | } |
76 | | |
77 | | bool ComboBoxCellController::MoveAllowed(const KeyEvent& rEvt) const |
78 | 0 | { |
79 | 0 | weld::ComboBox& rBox = GetComboBox(); |
80 | 0 | switch (rEvt.GetKeyCode().GetCode()) |
81 | 0 | { |
82 | 0 | case KEY_END: |
83 | 0 | case KEY_RIGHT: |
84 | 0 | { |
85 | 0 | int nStartPos, nEndPos; |
86 | 0 | bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos); |
87 | 0 | return bNoSelection && nEndPos == rBox.get_active_text().getLength(); |
88 | 0 | } |
89 | 0 | case KEY_HOME: |
90 | 0 | case KEY_LEFT: |
91 | 0 | { |
92 | 0 | int nStartPos, nEndPos; |
93 | 0 | bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos); |
94 | 0 | return bNoSelection && nStartPos == 0; |
95 | 0 | } |
96 | 0 | case KEY_UP: |
97 | 0 | case KEY_DOWN: |
98 | 0 | if (rBox.get_popup_shown()) |
99 | 0 | return false; |
100 | 0 | if (!rEvt.GetKeyCode().IsShift() && |
101 | 0 | rEvt.GetKeyCode().IsMod1()) |
102 | 0 | return false; |
103 | | // drop down the list box |
104 | 0 | else if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN) |
105 | 0 | return false; |
106 | 0 | [[fallthrough]]; |
107 | 0 | case KEY_PAGEUP: |
108 | 0 | case KEY_PAGEDOWN: |
109 | 0 | case KEY_RETURN: |
110 | 0 | if (rBox.get_popup_shown()) |
111 | 0 | return false; |
112 | 0 | [[fallthrough]]; |
113 | 0 | default: |
114 | 0 | return true; |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | | bool ComboBoxCellController::IsValueChangedFromSaved() const |
119 | 0 | { |
120 | 0 | return GetComboBox().get_value_changed_from_saved(); |
121 | 0 | } |
122 | | |
123 | | void ComboBoxCellController::SaveValue() |
124 | 0 | { |
125 | 0 | GetComboBox().save_value(); |
126 | 0 | } |
127 | | |
128 | | //= ListBoxControl |
129 | | ListBoxControl::ListBoxControl(BrowserDataWin* pParent) |
130 | 0 | : ControlBase(pParent, u"svt/ui/listcontrol.ui"_ustr, u"ListControl"_ustr) |
131 | 0 | , m_xWidget(m_xBuilder->weld_combo_box(u"listbox"_ustr)) |
132 | 0 | { |
133 | 0 | InitControlBase(m_xWidget.get()); |
134 | 0 | m_xWidget->set_size_request(42, -1); // so a later narrow size request can stick |
135 | 0 | m_xWidget->connect_changed(LINK(this, ListBoxControl, SelectHdl)); |
136 | 0 | m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); |
137 | 0 | m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); |
138 | 0 | m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); |
139 | 0 | m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); |
140 | 0 | m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); |
141 | 0 | m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); |
142 | 0 | m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); |
143 | 0 | } Unexecuted instantiation: svt::ListBoxControl::ListBoxControl(BrowserDataWin*) Unexecuted instantiation: svt::ListBoxControl::ListBoxControl(BrowserDataWin*) |
144 | | |
145 | | void ListBoxControl::SetPointFont(const vcl::Font& rFont) |
146 | 0 | { |
147 | 0 | m_xWidget->set_font(rFont); |
148 | 0 | } |
149 | | |
150 | | void ListBoxControl::dispose() |
151 | 0 | { |
152 | 0 | m_xWidget.reset(); |
153 | 0 | ControlBase::dispose(); |
154 | 0 | } |
155 | | |
156 | | IMPL_LINK_NOARG(ListBoxControl, SelectHdl, weld::ComboBox&, void) |
157 | 0 | { |
158 | 0 | CallModifyHdls(); |
159 | 0 | } |
160 | | |
161 | | //= ListBoxCellController |
162 | | ListBoxCellController::ListBoxCellController(ListBoxControl* pWin) |
163 | 0 | :CellController(pWin) |
164 | 0 | { |
165 | 0 | static_cast<ListBoxControl&>(GetWindow()).SetModifyHdl(LINK(this, ListBoxCellController, ListBoxSelectHdl)); |
166 | 0 | } |
167 | | |
168 | | bool ListBoxCellController::MoveAllowed(const KeyEvent& rEvt) const |
169 | 0 | { |
170 | 0 | const weld::ComboBox& rBox = GetListBox(); |
171 | 0 | switch (rEvt.GetKeyCode().GetCode()) |
172 | 0 | { |
173 | 0 | case KEY_UP: |
174 | 0 | case KEY_DOWN: |
175 | 0 | if (!rEvt.GetKeyCode().IsShift() && |
176 | 0 | rEvt.GetKeyCode().IsMod1()) |
177 | 0 | return false; |
178 | | // drop down the list box |
179 | 0 | else |
180 | 0 | if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN) |
181 | 0 | return false; |
182 | 0 | [[fallthrough]]; |
183 | 0 | case KEY_PAGEUP: |
184 | 0 | case KEY_PAGEDOWN: |
185 | 0 | if (rBox.get_popup_shown()) |
186 | 0 | return false; |
187 | 0 | [[fallthrough]]; |
188 | 0 | default: |
189 | 0 | return true; |
190 | 0 | } |
191 | 0 | } |
192 | | |
193 | | bool ListBoxCellController::IsValueChangedFromSaved() const |
194 | 0 | { |
195 | 0 | return GetListBox().get_value_changed_from_saved(); |
196 | 0 | } |
197 | | |
198 | | void ListBoxCellController::SaveValue() |
199 | 0 | { |
200 | 0 | GetListBox().save_value(); |
201 | 0 | } |
202 | | |
203 | | IMPL_LINK_NOARG(ListBoxCellController, ListBoxSelectHdl, LinkParamNone*, void) |
204 | 0 | { |
205 | 0 | callModifyHdl(); |
206 | 0 | } |
207 | | |
208 | | //= CheckBoxControl |
209 | | CheckBoxControl::CheckBoxControl(BrowserDataWin* pParent) |
210 | 0 | : ControlBase(pParent, u"svt/ui/checkboxcontrol.ui"_ustr, u"CheckBoxControl"_ustr) |
211 | 0 | , m_xBox(m_xBuilder->weld_check_button(u"checkbox"_ustr)) |
212 | 0 | { |
213 | 0 | m_aModeState.bTriStateEnabled = true; |
214 | 0 | InitControlBase(m_xBox.get()); |
215 | 0 | m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); |
216 | 0 | m_xBox->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); |
217 | 0 | m_xBox->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); |
218 | 0 | m_xBox->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); |
219 | 0 | m_xBox->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); |
220 | 0 | m_xBox->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); |
221 | 0 | m_xBox->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); |
222 | 0 | m_xBox->connect_toggled(LINK(this, CheckBoxControl, OnToggle)); |
223 | 0 | } Unexecuted instantiation: svt::CheckBoxControl::CheckBoxControl(BrowserDataWin*) Unexecuted instantiation: svt::CheckBoxControl::CheckBoxControl(BrowserDataWin*) |
224 | | |
225 | | void CheckBoxControl::SetPointFont(const vcl::Font& /*rFont*/) |
226 | 0 | { |
227 | 0 | } |
228 | | |
229 | | void CheckBoxControl::EnableTriState( bool bTriState ) |
230 | 0 | { |
231 | 0 | if (m_aModeState.bTriStateEnabled != bTriState) |
232 | 0 | { |
233 | 0 | m_aModeState.bTriStateEnabled = bTriState; |
234 | |
|
235 | 0 | if (!m_aModeState.bTriStateEnabled && GetState() == TRISTATE_INDET) |
236 | 0 | SetState(TRISTATE_FALSE); |
237 | 0 | } |
238 | 0 | } |
239 | | |
240 | | void CheckBoxControl::SetState(TriState eState) |
241 | 0 | { |
242 | 0 | if (!m_aModeState.bTriStateEnabled && (eState == TRISTATE_INDET)) |
243 | 0 | eState = TRISTATE_FALSE; |
244 | 0 | m_aModeState.eState = eState; |
245 | 0 | m_xBox->set_state(eState); |
246 | 0 | } |
247 | | |
248 | | CheckBoxControl::~CheckBoxControl() |
249 | 0 | { |
250 | 0 | disposeOnce(); |
251 | 0 | } |
252 | | |
253 | | void CheckBoxControl::dispose() |
254 | 0 | { |
255 | 0 | m_xBox.reset(); |
256 | 0 | ControlBase::dispose(); |
257 | 0 | } |
258 | | |
259 | | void CheckBoxControl::Clicked() |
260 | 0 | { |
261 | | // if tristate is enabled, m_aModeState will take care of setting the |
262 | | // next state in the sequence via TriStateEnabled::ButtonToggled |
263 | 0 | if (!m_aModeState.bTriStateEnabled) |
264 | 0 | m_xBox->set_active(!m_xBox->get_active()); |
265 | 0 | OnToggle(*m_xBox); |
266 | 0 | } |
267 | | |
268 | | IMPL_LINK_NOARG(CheckBoxControl, OnToggle, weld::Toggleable&, void) |
269 | 0 | { |
270 | 0 | m_aModeState.CheckButtonToggled(*m_xBox); |
271 | 0 | m_aToggleLink.Call(*m_xBox); |
272 | 0 | CallModifyHdls(); |
273 | 0 | } |
274 | | |
275 | | //= CheckBoxCellController |
276 | | CheckBoxCellController::CheckBoxCellController(CheckBoxControl* pWin) |
277 | 0 | : CellController(pWin) |
278 | 0 | { |
279 | 0 | static_cast<CheckBoxControl &>(GetWindow()).SetModifyHdl( LINK(this, CheckBoxCellController, ModifyHdl) ); |
280 | 0 | } |
281 | | |
282 | | void CheckBoxCellController::ActivatingMouseEvent(const BrowserMouseEvent& rEvt, bool /*bUp*/) |
283 | 0 | { |
284 | 0 | CheckBoxControl& rControl = static_cast<CheckBoxControl&>(GetWindow()); |
285 | 0 | rControl.GrabFocus(); |
286 | | |
287 | | // we have to adjust the position of the event relative to the controller's window |
288 | 0 | Point aPos = rEvt.GetPosPixel() - rEvt.GetRect().TopLeft(); |
289 | |
|
290 | 0 | Size aControlSize = rControl.GetSizePixel(); |
291 | 0 | Size aBoxSize = rControl.GetBox().get_preferred_size(); |
292 | 0 | tools::Rectangle aHotRect(Point((aControlSize.Width() - aBoxSize.Width()) / 2, |
293 | 0 | (aControlSize.Height() - aBoxSize.Height()) / 2), |
294 | 0 | aBoxSize); |
295 | | |
296 | | // we want the initial mouse event to act as if it was performed on the checkbox |
297 | 0 | if (aHotRect.Contains(aPos)) |
298 | 0 | rControl.Clicked(); |
299 | 0 | } |
300 | | |
301 | | weld::CheckButton& CheckBoxCellController::GetCheckBox() const |
302 | 0 | { |
303 | 0 | return static_cast<CheckBoxControl &>(GetWindow()).GetBox(); |
304 | 0 | } |
305 | | |
306 | | bool CheckBoxCellController::IsValueChangedFromSaved() const |
307 | 0 | { |
308 | 0 | return GetCheckBox().get_state_changed_from_saved(); |
309 | 0 | } |
310 | | |
311 | | void CheckBoxCellController::SaveValue() |
312 | 0 | { |
313 | 0 | GetCheckBox().save_state(); |
314 | 0 | } |
315 | | |
316 | | IMPL_LINK_NOARG(CheckBoxCellController, ModifyHdl, LinkParamNone*, void) |
317 | 0 | { |
318 | 0 | callModifyHdl(); |
319 | 0 | } |
320 | | |
321 | | //= MultiLineEditImplementation |
322 | | OUString MultiLineEditImplementation::GetText(LineEnd eSeparator) const |
323 | 0 | { |
324 | 0 | weld::TextView& rEntry = m_rEdit.get_widget(); |
325 | 0 | return convertLineEnd(rEntry.get_text(), eSeparator); |
326 | 0 | } |
327 | | |
328 | | OUString MultiLineEditImplementation::GetSelected(LineEnd eSeparator) const |
329 | 0 | { |
330 | 0 | int nStartPos, nEndPos; |
331 | 0 | weld::TextView& rEntry = m_rEdit.get_widget(); |
332 | 0 | rEntry.get_selection_bounds(nStartPos, nEndPos); |
333 | 0 | return convertLineEnd(rEntry.get_text().copy(nStartPos, nEndPos - nStartPos), eSeparator); |
334 | 0 | } |
335 | | |
336 | | IMPL_LINK_NOARG(MultiLineEditImplementation, ModifyHdl, weld::TextWidget&, void) |
337 | 0 | { |
338 | 0 | CallModifyHdls(); |
339 | 0 | } |
340 | | |
341 | | EditCellController::EditCellController( IEditImplementation* _pImplementation ) |
342 | 0 | :CellController( &_pImplementation->GetControl() ) |
343 | 0 | ,m_pEditImplementation( _pImplementation ) |
344 | 0 | ,m_bOwnImplementation( false ) |
345 | 0 | { |
346 | 0 | m_pEditImplementation->SetModifyHdl( LINK(this, EditCellController, ModifyHdl) ); |
347 | 0 | } |
348 | | |
349 | | IMPL_LINK_NOARG(EntryImplementation, ModifyHdl, weld::TextWidget&, void) |
350 | 0 | { |
351 | 0 | CallModifyHdls(); |
352 | 0 | } |
353 | | |
354 | | ControlBase::ControlBase(BrowserDataWin* pParent, const OUString& rUIXMLDescription, const OUString& rID) |
355 | 0 | : InterimItemWindow(pParent, rUIXMLDescription, rID) |
356 | 0 | { |
357 | 0 | } |
358 | | |
359 | | void ControlBase::SetEditableReadOnly(bool /*bReadOnly*/) |
360 | 0 | { |
361 | | // expected to be overridden for Entry, TextView or the editable entry part of a ComboBox |
362 | 0 | } |
363 | | |
364 | | EditControlBase::EditControlBase(BrowserDataWin* pParent) |
365 | 0 | : ControlBase(pParent, u"svt/ui/thineditcontrol.ui"_ustr, u"EditControl"_ustr) // *thin*editcontrol has no frame/border |
366 | 0 | , m_pEntry(nullptr) // inheritors are expected to call InitEditControlBase |
367 | 0 | { |
368 | 0 | } |
369 | | |
370 | | void EditControlBase::InitEditControlBase(weld::Entry* pEntry) |
371 | 0 | { |
372 | 0 | InitControlBase(pEntry); |
373 | 0 | m_pEntry = pEntry; |
374 | 0 | m_pEntry->show(); |
375 | 0 | m_pEntry->set_width_chars(1); // so a smaller than default width can be used |
376 | 0 | connect_focus_in(LINK(this, ControlBase, FocusInHdl)); // need to chain with pattern handler |
377 | 0 | connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); // need to chain with pattern handler |
378 | 0 | connect_key_press(LINK(this, ControlBase, KeyInputHdl)); // need to chain with pattern handler |
379 | 0 | m_pEntry->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); |
380 | 0 | m_pEntry->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); |
381 | 0 | m_pEntry->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); |
382 | 0 | m_pEntry->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); |
383 | 0 | } |
384 | | |
385 | | bool ControlBase::ProcessKey(const KeyEvent& rKEvt) |
386 | 0 | { |
387 | 0 | return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ProcessKey(rKEvt); |
388 | 0 | } |
389 | | |
390 | | rtl::Reference<comphelper::OAccessible> ControlBase::CreateAccessible() |
391 | 0 | { |
392 | 0 | return new EditBrowseBoxTableCell(this); |
393 | 0 | } |
394 | | |
395 | | IMPL_LINK(ControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool) |
396 | 0 | { |
397 | 0 | m_aKeyInputHdl.Call(rKEvt); |
398 | 0 | return ProcessKey(rKEvt); |
399 | 0 | } |
400 | | |
401 | | IMPL_LINK(ControlBase, KeyReleaseHdl, const KeyEvent&, rKEvt, bool) |
402 | 0 | { |
403 | 0 | m_aKeyReleaseHdl.Call(rKEvt); |
404 | 0 | return false; |
405 | 0 | } |
406 | | |
407 | | IMPL_LINK_NOARG(ControlBase, FocusInHdl, weld::Widget&, void) |
408 | 0 | { |
409 | 0 | m_aFocusInHdl.Call(nullptr); |
410 | 0 | static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusIn(); |
411 | 0 | } |
412 | | |
413 | | IMPL_LINK_NOARG(ControlBase, FocusOutHdl, weld::Widget&, void) |
414 | 0 | { |
415 | 0 | m_aFocusOutHdl.Call(nullptr); |
416 | 0 | static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusOut(); |
417 | 0 | } |
418 | | |
419 | | IMPL_LINK(ControlBase, MousePressHdl, const MouseEvent&, rEvent, bool) |
420 | 0 | { |
421 | 0 | m_aMousePressHdl.Call(rEvent); |
422 | 0 | return false; |
423 | 0 | } |
424 | | |
425 | | IMPL_LINK(ControlBase, MouseReleaseHdl, const MouseEvent&, rEvent, bool) |
426 | 0 | { |
427 | 0 | m_aMouseReleaseHdl.Call(rEvent); |
428 | 0 | return false; |
429 | 0 | } |
430 | | |
431 | | IMPL_LINK(ControlBase, MouseMoveHdl, const MouseEvent&, rEvent, bool) |
432 | 0 | { |
433 | 0 | m_aMouseMoveHdl.Call(rEvent); |
434 | 0 | return false; |
435 | 0 | } |
436 | | |
437 | | void EditControlBase::dispose() |
438 | 0 | { |
439 | 0 | m_pEntry = nullptr; |
440 | 0 | ControlBase::dispose(); |
441 | 0 | } |
442 | | |
443 | | EditControl::EditControl(BrowserDataWin* pParent) |
444 | 0 | : EditControlBase(pParent) |
445 | 0 | , m_xWidget(m_xBuilder->weld_entry(u"entry"_ustr)) |
446 | 0 | { |
447 | 0 | InitEditControlBase(m_xWidget.get()); |
448 | 0 | } Unexecuted instantiation: svt::EditControl::EditControl(BrowserDataWin*) Unexecuted instantiation: svt::EditControl::EditControl(BrowserDataWin*) |
449 | | |
450 | | void EditControl::dispose() |
451 | 0 | { |
452 | 0 | m_xWidget.reset(); |
453 | 0 | EditControlBase::dispose(); |
454 | 0 | } |
455 | | |
456 | | FormattedControlBase::FormattedControlBase(BrowserDataWin* pParent, bool bSpinVariant) |
457 | 0 | : EditControlBase(pParent) |
458 | 0 | , m_bSpinVariant(bSpinVariant) |
459 | 0 | , m_xEntry(m_xBuilder->weld_entry(u"entry"_ustr)) |
460 | 0 | , m_xSpinButton(m_xBuilder->weld_formatted_spin_button(u"spinbutton"_ustr)) |
461 | 0 | { |
462 | 0 | } Unexecuted instantiation: svt::FormattedControlBase::FormattedControlBase(BrowserDataWin*, bool) Unexecuted instantiation: svt::FormattedControlBase::FormattedControlBase(BrowserDataWin*, bool) |
463 | | |
464 | | void FormattedControlBase::InitFormattedControlBase() |
465 | 0 | { |
466 | 0 | InitEditControlBase(m_bSpinVariant ? m_xSpinButton.get() : m_xEntry.get()); |
467 | 0 | } |
468 | | |
469 | | void FormattedControlBase::connect_changed(const Link<weld::TextWidget&, void>& rLink) |
470 | 0 | { |
471 | 0 | get_formatter().connect_changed(rLink); |
472 | 0 | } |
473 | | |
474 | | void FormattedControlBase::connect_focus_in(const Link<weld::Widget&, void>& rLink) |
475 | 0 | { |
476 | 0 | get_widget().connect_focus_in(rLink); |
477 | 0 | } |
478 | | |
479 | | void FormattedControlBase::connect_focus_out(const Link<weld::Widget&, void>& rLink) |
480 | 0 | { |
481 | 0 | get_formatter().connect_focus_out(rLink); |
482 | 0 | } |
483 | | |
484 | | void FormattedControlBase::connect_key_press(const Link<const KeyEvent&, bool>& rLink) |
485 | 0 | { |
486 | 0 | get_widget().connect_key_press(rLink); |
487 | 0 | } |
488 | | |
489 | | weld::EntryFormatter& FormattedControlBase::get_formatter() |
490 | 0 | { |
491 | 0 | return *m_xEntryFormatter; |
492 | 0 | } |
493 | | |
494 | | void FormattedControlBase::dispose() |
495 | 0 | { |
496 | 0 | m_xEntryFormatter.reset(); |
497 | 0 | m_xSpinButton.reset(); |
498 | 0 | m_xEntry.reset(); |
499 | 0 | EditControlBase::dispose(); |
500 | 0 | } |
501 | | |
502 | | FormattedControl::FormattedControl(BrowserDataWin* pParent, bool bSpinVariant) |
503 | 0 | : FormattedControlBase(pParent, bSpinVariant) |
504 | 0 | { |
505 | 0 | if (bSpinVariant) |
506 | 0 | m_xEntryFormatter.reset(new weld::EntryFormatter(*m_xSpinButton)); |
507 | 0 | else |
508 | 0 | m_xEntryFormatter.reset(new weld::EntryFormatter(*m_xEntry)); |
509 | 0 | InitFormattedControlBase(); |
510 | 0 | } Unexecuted instantiation: svt::FormattedControl::FormattedControl(BrowserDataWin*, bool) Unexecuted instantiation: svt::FormattedControl::FormattedControl(BrowserDataWin*, bool) |
511 | | |
512 | | DoubleNumericControl::DoubleNumericControl(BrowserDataWin* pParent, bool bSpinVariant) |
513 | 0 | : FormattedControlBase(pParent, bSpinVariant) |
514 | 0 | { |
515 | 0 | if (bSpinVariant) |
516 | 0 | m_xEntryFormatter.reset(new weld::DoubleNumericFormatter(*m_xSpinButton)); |
517 | 0 | else |
518 | 0 | m_xEntryFormatter.reset(new weld::DoubleNumericFormatter(*m_xEntry)); |
519 | 0 | InitFormattedControlBase(); |
520 | 0 | } Unexecuted instantiation: svt::DoubleNumericControl::DoubleNumericControl(BrowserDataWin*, bool) Unexecuted instantiation: svt::DoubleNumericControl::DoubleNumericControl(BrowserDataWin*, bool) |
521 | | |
522 | | LongCurrencyControl::LongCurrencyControl(BrowserDataWin* pParent, bool bSpinVariant) |
523 | 0 | : FormattedControlBase(pParent, bSpinVariant) |
524 | 0 | { |
525 | 0 | if (bSpinVariant) |
526 | 0 | m_xEntryFormatter.reset(new weld::LongCurrencyFormatter(*m_xSpinButton)); |
527 | 0 | else |
528 | 0 | m_xEntryFormatter.reset(new weld::LongCurrencyFormatter(*m_xEntry)); |
529 | 0 | InitFormattedControlBase(); |
530 | 0 | } Unexecuted instantiation: svt::LongCurrencyControl::LongCurrencyControl(BrowserDataWin*, bool) Unexecuted instantiation: svt::LongCurrencyControl::LongCurrencyControl(BrowserDataWin*, bool) |
531 | | |
532 | | TimeControl::TimeControl(BrowserDataWin* pParent, bool bSpinVariant) |
533 | 0 | : FormattedControlBase(pParent, bSpinVariant) |
534 | 0 | { |
535 | 0 | if (bSpinVariant) |
536 | 0 | m_xEntryFormatter.reset(new weld::TimeFormatter(*m_xSpinButton)); |
537 | 0 | else |
538 | 0 | m_xEntryFormatter.reset(new weld::TimeFormatter(*m_xEntry)); |
539 | 0 | InitFormattedControlBase(); |
540 | 0 | } Unexecuted instantiation: svt::TimeControl::TimeControl(BrowserDataWin*, bool) Unexecuted instantiation: svt::TimeControl::TimeControl(BrowserDataWin*, bool) |
541 | | |
542 | | DateControl::DateControl(BrowserDataWin* pParent, bool bDropDown) |
543 | 0 | : FormattedControlBase(pParent, false) |
544 | 0 | , m_xMenuButton(m_xBuilder->weld_menu_button(u"button"_ustr)) |
545 | 0 | , m_xCalendarBuilder(Application::CreateBuilder(m_xMenuButton.get(), u"svt/ui/datewindow.ui"_ustr)) |
546 | 0 | , m_xTopLevel(m_xCalendarBuilder->weld_widget(u"date_popup_window"_ustr)) |
547 | 0 | , m_xCalendar(m_xCalendarBuilder->weld_calendar(u"date_picker"_ustr)) |
548 | 0 | , m_xExtras(m_xCalendarBuilder->weld_widget(u"extras"_ustr)) |
549 | 0 | , m_xTodayBtn(m_xCalendarBuilder->weld_button(u"today"_ustr)) |
550 | 0 | , m_xNoneBtn(m_xCalendarBuilder->weld_button(u"none"_ustr)) |
551 | 0 | { |
552 | 0 | m_xEntryFormatter.reset(new weld::DateFormatter(*m_xEntry)); |
553 | 0 | InitFormattedControlBase(); |
554 | |
|
555 | 0 | m_xMenuButton->set_popover(m_xTopLevel.get()); |
556 | 0 | m_xMenuButton->set_visible(bDropDown); |
557 | 0 | m_xMenuButton->connect_toggled(LINK(this, DateControl, ToggleHdl)); |
558 | |
|
559 | 0 | m_xExtras->show(); |
560 | |
|
561 | 0 | m_xTodayBtn->connect_clicked(LINK(this, DateControl, ImplClickHdl)); |
562 | 0 | m_xNoneBtn->connect_clicked(LINK(this, DateControl, ImplClickHdl)); |
563 | |
|
564 | 0 | m_xCalendar->connect_activated(LINK(this, DateControl, ActivateHdl)); |
565 | 0 | } Unexecuted instantiation: svt::DateControl::DateControl(BrowserDataWin*, bool) Unexecuted instantiation: svt::DateControl::DateControl(BrowserDataWin*, bool) |
566 | | |
567 | | IMPL_LINK(DateControl, ImplClickHdl, weld::Button&, rBtn, void) |
568 | 0 | { |
569 | 0 | m_xMenuButton->set_active(false); |
570 | 0 | get_widget().grab_focus(); |
571 | |
|
572 | 0 | if (&rBtn == m_xTodayBtn.get()) |
573 | 0 | { |
574 | 0 | Date aToday(Date::SYSTEM); |
575 | 0 | SetDate(aToday); |
576 | 0 | } |
577 | 0 | else if (&rBtn == m_xNoneBtn.get()) |
578 | 0 | { |
579 | 0 | get_widget().set_text(OUString()); |
580 | 0 | } |
581 | 0 | } |
582 | | |
583 | | IMPL_LINK(DateControl, ToggleHdl, weld::Toggleable&, rButton, void) |
584 | 0 | { |
585 | 0 | if (rButton.get_active()) |
586 | 0 | m_xCalendar->set_date(static_cast<weld::DateFormatter&>(get_formatter()).GetDate()); |
587 | 0 | } |
588 | | |
589 | | IMPL_LINK_NOARG(DateControl, ActivateHdl, weld::Calendar&, void) |
590 | 0 | { |
591 | 0 | if (m_xMenuButton->get_active()) |
592 | 0 | m_xMenuButton->set_active(false); |
593 | 0 | static_cast<weld::DateFormatter&>(get_formatter()).SetDate(m_xCalendar->get_date()); |
594 | 0 | } |
595 | | |
596 | | void DateControl::SetDate(const Date& rDate) |
597 | 0 | { |
598 | 0 | static_cast<weld::DateFormatter&>(get_formatter()).SetDate(rDate); |
599 | 0 | m_xCalendar->set_date(rDate); |
600 | 0 | } |
601 | | |
602 | | void DateControl::SetEditableReadOnly(bool bReadOnly) |
603 | 0 | { |
604 | 0 | FormattedControlBase::SetEditableReadOnly(bReadOnly); |
605 | 0 | m_xMenuButton->set_sensitive(!bReadOnly); |
606 | 0 | } |
607 | | |
608 | | void DateControl::dispose() |
609 | 0 | { |
610 | 0 | m_xTodayBtn.reset(); |
611 | 0 | m_xNoneBtn.reset(); |
612 | 0 | m_xExtras.reset(); |
613 | 0 | m_xCalendar.reset(); |
614 | 0 | m_xTopLevel.reset(); |
615 | 0 | m_xCalendarBuilder.reset(); |
616 | 0 | m_xMenuButton.reset(); |
617 | 0 | FormattedControlBase::dispose(); |
618 | 0 | } |
619 | | |
620 | | PatternControl::PatternControl(BrowserDataWin* pParent) |
621 | 0 | : EditControlBase(pParent) |
622 | 0 | , m_xWidget(m_xBuilder->weld_entry(u"entry"_ustr)) |
623 | 0 | { |
624 | 0 | m_xEntryFormatter.reset(new weld::PatternFormatter(*m_xWidget)); |
625 | 0 | InitEditControlBase(m_xWidget.get()); |
626 | 0 | } Unexecuted instantiation: svt::PatternControl::PatternControl(BrowserDataWin*) Unexecuted instantiation: svt::PatternControl::PatternControl(BrowserDataWin*) |
627 | | |
628 | | void PatternControl::connect_changed(const Link<weld::TextWidget&, void>& rLink) |
629 | 0 | { |
630 | 0 | m_xEntryFormatter->connect_changed(rLink); |
631 | 0 | } |
632 | | |
633 | | void PatternControl::connect_focus_in(const Link<weld::Widget&, void>& rLink) |
634 | 0 | { |
635 | 0 | m_xEntryFormatter->connect_focus_in(rLink); |
636 | 0 | } |
637 | | |
638 | | void PatternControl::connect_focus_out(const Link<weld::Widget&, void>& rLink) |
639 | 0 | { |
640 | 0 | m_xEntryFormatter->connect_focus_out(rLink); |
641 | 0 | } |
642 | | |
643 | | void PatternControl::connect_key_press(const Link<const KeyEvent&, bool>& rLink) |
644 | 0 | { |
645 | 0 | m_xEntryFormatter->connect_key_press(rLink); |
646 | 0 | } |
647 | | |
648 | | void PatternControl::dispose() |
649 | 0 | { |
650 | 0 | m_xEntryFormatter.reset(); |
651 | 0 | m_xWidget.reset(); |
652 | 0 | EditControlBase::dispose(); |
653 | 0 | } |
654 | | |
655 | | EditCellController::EditCellController(EditControlBase* pEdit) |
656 | 0 | : CellController(pEdit) |
657 | 0 | , m_pEditImplementation(new EntryImplementation(*pEdit)) |
658 | 0 | , m_bOwnImplementation(true) |
659 | 0 | { |
660 | 0 | m_pEditImplementation->SetModifyHdl( LINK(this, EditCellController, ModifyHdl) ); |
661 | 0 | } |
662 | | |
663 | | EditCellController::~EditCellController( ) |
664 | 0 | { |
665 | 0 | if ( m_bOwnImplementation ) |
666 | 0 | delete m_pEditImplementation; |
667 | 0 | } |
668 | | |
669 | | void EditCellController::SaveValue() |
670 | 0 | { |
671 | 0 | m_pEditImplementation->SaveValue(); |
672 | 0 | } |
673 | | |
674 | | bool EditCellController::MoveAllowed(const KeyEvent& rEvt) const |
675 | 0 | { |
676 | 0 | bool bResult; |
677 | 0 | switch (rEvt.GetKeyCode().GetCode()) |
678 | 0 | { |
679 | 0 | case KEY_END: |
680 | 0 | case KEY_RIGHT: |
681 | 0 | { |
682 | 0 | Selection aSel = m_pEditImplementation->GetSelection(); |
683 | 0 | bResult = !aSel && aSel.Max() == m_pEditImplementation->GetText( LINEEND_LF ).getLength(); |
684 | 0 | break; |
685 | 0 | } |
686 | 0 | case KEY_HOME: |
687 | 0 | case KEY_LEFT: |
688 | 0 | { |
689 | 0 | Selection aSel = m_pEditImplementation->GetSelection(); |
690 | 0 | bResult = !aSel && aSel.Min() == 0; |
691 | 0 | break; |
692 | 0 | } |
693 | 0 | case KEY_DOWN: |
694 | 0 | { |
695 | 0 | bResult = !m_pEditImplementation->CanDown(); |
696 | 0 | break; |
697 | 0 | } |
698 | 0 | case KEY_UP: |
699 | 0 | { |
700 | 0 | bResult = !m_pEditImplementation->CanUp(); |
701 | 0 | break; |
702 | 0 | } |
703 | 0 | default: |
704 | 0 | bResult = true; |
705 | 0 | } |
706 | 0 | return bResult; |
707 | 0 | } |
708 | | |
709 | | bool EditCellController::IsValueChangedFromSaved() const |
710 | 0 | { |
711 | 0 | return m_pEditImplementation->IsValueChangedFromSaved(); |
712 | 0 | } |
713 | | |
714 | | IMPL_LINK_NOARG(EditCellController, ModifyHdl, LinkParamNone*, void) |
715 | 0 | { |
716 | 0 | callModifyHdl(); |
717 | 0 | } |
718 | | |
719 | | //= FormattedFieldCellController |
720 | | FormattedFieldCellController::FormattedFieldCellController( FormattedControlBase* _pFormatted ) |
721 | 0 | : EditCellController(_pFormatted) |
722 | 0 | { |
723 | 0 | } |
724 | | |
725 | | void FormattedFieldCellController::CommitModifications() |
726 | 0 | { |
727 | 0 | static_cast<FormattedControl&>(GetWindow()).get_formatter().Commit(); |
728 | 0 | } |
729 | | |
730 | | MultiLineTextCell::MultiLineTextCell(BrowserDataWin* pParent) |
731 | 0 | : ControlBase(pParent, u"svt/ui/textviewcontrol.ui"_ustr, u"TextViewControl"_ustr) |
732 | 0 | , m_xWidget(m_xBuilder->weld_text_view(u"textview"_ustr)) |
733 | 0 | { |
734 | 0 | InitControlBase(m_xWidget.get()); |
735 | 0 | m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); |
736 | 0 | m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); |
737 | 0 | m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); |
738 | 0 | m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); |
739 | 0 | m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); |
740 | 0 | m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); |
741 | 0 | m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); |
742 | | // so any the natural size doesn't have an effect |
743 | 0 | m_xWidget->set_size_request(1, 1); |
744 | 0 | } Unexecuted instantiation: svt::MultiLineTextCell::MultiLineTextCell(BrowserDataWin*) Unexecuted instantiation: svt::MultiLineTextCell::MultiLineTextCell(BrowserDataWin*) |
745 | | |
746 | | void MultiLineTextCell::GetFocus() |
747 | 0 | { |
748 | 0 | if (m_xWidget) |
749 | 0 | m_xWidget->select_region(-1, 0); |
750 | 0 | ControlBase::GetFocus(); |
751 | 0 | } |
752 | | |
753 | | void MultiLineTextCell::dispose() |
754 | 0 | { |
755 | 0 | m_xWidget.reset(); |
756 | 0 | ControlBase::dispose(); |
757 | 0 | } |
758 | | |
759 | | bool MultiLineTextCell::ProcessKey(const KeyEvent& rKEvt) |
760 | 0 | { |
761 | 0 | bool bSendToDataWindow = true; |
762 | |
|
763 | 0 | sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); |
764 | 0 | bool bShift = rKEvt.GetKeyCode().IsShift(); |
765 | 0 | bool bCtrl = rKEvt.GetKeyCode().IsMod1(); |
766 | 0 | bool bAlt = rKEvt.GetKeyCode().IsMod2(); |
767 | |
|
768 | 0 | if (!bAlt && !bCtrl && !bShift) |
769 | 0 | { |
770 | 0 | switch (nCode) |
771 | 0 | { |
772 | 0 | case KEY_DOWN: |
773 | 0 | bSendToDataWindow = !m_xWidget->can_move_cursor_with_down(); |
774 | 0 | break; |
775 | 0 | case KEY_UP: |
776 | 0 | bSendToDataWindow = !m_xWidget->can_move_cursor_with_up(); |
777 | 0 | break; |
778 | 0 | } |
779 | 0 | } |
780 | | |
781 | 0 | if (bSendToDataWindow) |
782 | 0 | return ControlBase::ProcessKey(rKEvt); |
783 | 0 | return false; |
784 | 0 | } |
785 | | } // namespace svt |
786 | | |
787 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |