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