1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <config_options.h>
24 #include <svtools/svtdllapi.h>
25 #include <tools/ref.hxx>
27 #include <svtools/brwbox.hxx>
28 #include <svtools/brwhead.hxx>
29 #include <tools/lineend.hxx>
30 #include <vcl/InterimItemWindow.hxx>
31 #include <vcl/weldutils.hxx>
32 #include <o3tl/typed_flags_set.hxx>
36 // EditBrowseBoxFlags (EBBF)
37 enum class EditBrowseBoxFlags
40 /** if this bit is _not_ set, the handle column will be invalidated upon
41 changing the row in the browse box. This is for forcing the row picture to
42 be repainted. If you do not have row pictures or text, you don't need this
43 invalidation, then you would specify this bit to prevent flicker
45 NO_HANDLE_COLUMN_CONTENT
= 0x0001,
46 /** set this bit to activate the cell on a MouseButtonDown, not a MouseButtonUp event
48 ACTIVATE_ON_BUTTONDOWN
= 0x0002,
49 /** if this bit is set and EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT is _not_ set, the handle
50 column is drawn with the text contained in column 0 instead of an image
52 HANDLE_COLUMN_TEXT
= 0x0004,
54 /** If this bit is set, tab traveling is somewhat modified<br/>
55 If the control gets the focus because the user pressed the TAB key, then the
56 first or last cell (depending on whether the traveling was cycling forward or backward)
58 @see Window::GetGetFocusFlags
61 SMART_TAB_TRAVEL
= 0x0008,
66 template<> struct typed_flags
<EditBrowseBoxFlags
> : is_typed_flags
<EditBrowseBoxFlags
, 0x0f> {};
71 class SVT_DLLPUBLIC CellController
: public SvRefBase
73 friend class EditBrowseBox
;
74 Link
<LinkParamNone
*, void> maModifyHdl
;
76 VclPtr
<Control
> pWindow
;
77 bool bSuspended
; // <true> if the window is hidden and disabled
81 CellController(Control
* pW
);
82 virtual ~CellController() override
;
84 Control
& GetWindow() const { return *const_cast< CellController
* >( this )->pWindow
; }
86 virtual void SaveValue() = 0;
87 virtual bool IsValueChangedFromSaved() const = 0;
89 // commit any current changes. Especially, do any reformatting you need (from input formatting
90 // to output formatting) here
91 virtual void CommitModifications();
93 // suspending the controller is not cumulative!
96 bool isSuspended( ) const { return bSuspended
; }
99 virtual bool MoveAllowed(const KeyEvent
& rEvt
) const;
100 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rLink
) { maModifyHdl
= rLink
; }
101 virtual void ActivatingMouseEvent(const BrowserMouseEvent
& rEvt
, bool bUp
);
102 virtual void callModifyHdl() { maModifyHdl
.Call(nullptr); }
105 typedef tools::SvRef
<CellController
> CellControllerRef
;
108 //= IEditImplementation
110 class UNLESS_MERGELIBS(SVT_DLLPUBLIC
) IEditImplementation
113 virtual ~IEditImplementation() = 0;
115 virtual Control
& GetControl() = 0;
117 virtual OUString
GetText( LineEnd aSeparator
) const = 0;
118 virtual void SetText( const OUString
& _rStr
) = 0;
120 virtual bool IsReadOnly() const = 0;
121 virtual void SetReadOnly( bool bReadOnly
) = 0;
123 virtual sal_Int32
GetMaxTextLen() const = 0;
124 virtual void SetMaxTextLen( sal_Int32 _nMaxLen
) = 0;
126 virtual Selection
GetSelection() const = 0;
127 virtual void SetSelection( const Selection
& _rSelection
) = 0;
129 virtual void ReplaceSelected( const OUString
& _rStr
) = 0;
130 virtual OUString
GetSelected( LineEnd aSeparator
) const = 0;
132 virtual bool IsValueChangedFromSaved() const = 0;
133 virtual void SaveValue() = 0;
135 virtual bool CanUp() const = 0;
136 virtual bool CanDown() const = 0;
138 virtual void Cut() = 0;
139 virtual void Copy() = 0;
140 virtual void Paste() = 0;
142 // sets a link to call when the text is changed by the user
143 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rLink
)
145 m_aModify1Hdl
= rLink
;
148 // sets an additional link to call when the text is changed by the user
149 void SetAuxModifyHdl(const Link
<LinkParamNone
*,void>& rLink
)
151 m_aModify2Hdl
= rLink
;
155 Link
<LinkParamNone
*,void> m_aModify1Hdl
;
156 Link
<LinkParamNone
*,void> m_aModify2Hdl
;
159 void CallModifyHdls()
161 m_aModify1Hdl
.Call(nullptr);
162 m_aModify2Hdl
.Call(nullptr);
166 class SVT_DLLPUBLIC ControlBase
: public InterimItemWindow
169 ControlBase(BrowserDataWin
* pParent
, const OUString
& rUIXMLDescription
, const OString
& rID
);
171 virtual void SetEditableReadOnly(bool bReadOnly
);
173 virtual bool ProcessKey(const KeyEvent
& rKEvt
);
175 // chain after the FocusInHdl
176 void SetFocusInHdl(const Link
<LinkParamNone
*,void>& rHdl
)
178 m_aFocusInHdl
= rHdl
;
181 // chain after the FocusOutHdl
182 void SetFocusOutHdl(const Link
<LinkParamNone
*,void>& rHdl
)
184 m_aFocusOutHdl
= rHdl
;
187 void SetMousePressHdl(const Link
<const MouseEvent
&,void>& rHdl
)
189 m_aMousePressHdl
= rHdl
;
192 void SetMouseReleaseHdl(const Link
<const MouseEvent
&,void>& rHdl
)
194 m_aMouseReleaseHdl
= rHdl
;
197 void SetMouseMoveHdl(const Link
<const MouseEvent
&,void>& rHdl
)
199 m_aMouseMoveHdl
= rHdl
;
203 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
204 DECL_LINK(FocusInHdl
, weld::Widget
&, void);
205 DECL_LINK(FocusOutHdl
, weld::Widget
&, void);
206 DECL_LINK(MousePressHdl
, const MouseEvent
&, bool);
207 DECL_LINK(MouseReleaseHdl
, const MouseEvent
&, bool);
208 DECL_LINK(MouseMoveHdl
, const MouseEvent
&, bool);
210 Link
<LinkParamNone
*,void> m_aFocusInHdl
;
211 Link
<LinkParamNone
*,void> m_aFocusOutHdl
;
212 Link
<const MouseEvent
&,void> m_aMousePressHdl
;
213 Link
<const MouseEvent
&,void> m_aMouseReleaseHdl
;
214 Link
<const MouseEvent
&,void> m_aMouseMoveHdl
;
217 class SVT_DLLPUBLIC EditControlBase
: public ControlBase
220 EditControlBase(BrowserDataWin
* pParent
);
222 virtual void SetEditableReadOnly(bool bReadOnly
) override
224 m_pEntry
->set_editable(!bReadOnly
);
227 virtual void dispose() override
;
229 weld::Entry
& get_widget() { return *m_pEntry
; }
231 virtual void connect_changed(const Link
<weld::Entry
&, void>& rLink
) = 0;
232 virtual void connect_focus_out(const Link
<weld::Widget
&, void>& rLink
) = 0;
235 void InitEditControlBase(weld::Entry
* pEntry
);
238 weld::Entry
* m_pEntry
;
241 class SVT_DLLPUBLIC EditControl
: public EditControlBase
244 EditControl(BrowserDataWin
* pParent
);
246 virtual void dispose() override
;
248 virtual void connect_changed(const Link
<weld::Entry
&, void>& rLink
) override
250 m_xWidget
->connect_changed(rLink
);
253 virtual void connect_focus_out(const Link
<weld::Widget
&, void>& rLink
) override
255 m_xWidget
->connect_focus_out(rLink
);
259 std::unique_ptr
<weld::Entry
> m_xWidget
;
262 class SVT_DLLPUBLIC EntryImplementation
: public IEditImplementation
264 EditControlBase
& m_rEdit
;
267 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
269 EntryImplementation(EditControlBase
& rEdit
)
273 m_rEdit
.connect_changed(LINK(this, EntryImplementation
, ModifyHdl
));
276 virtual Control
& GetControl() override
281 virtual OUString
GetText( LineEnd
/*aSeparator*/ ) const override
283 // ignore the line end - this base implementation does not support it
284 return m_rEdit
.get_widget().get_text();
287 virtual void SetText( const OUString
& _rStr
) override
289 return m_rEdit
.get_widget().set_text(_rStr
);
292 virtual bool IsReadOnly() const override
294 return !m_rEdit
.get_widget().get_editable();
297 virtual void SetReadOnly( bool bReadOnly
) override
299 m_rEdit
.SetEditableReadOnly(bReadOnly
);
302 virtual sal_Int32
GetMaxTextLen() const override
304 return m_nMaxTextLen
;
307 virtual void SetMaxTextLen( sal_Int32 nMaxLen
) override
309 m_nMaxTextLen
= nMaxLen
;
310 m_rEdit
.get_widget().set_max_length(m_nMaxTextLen
);
313 virtual Selection
GetSelection() const override
315 int nStartPos
, nEndPos
;
316 m_rEdit
.get_widget().get_selection_bounds(nStartPos
, nEndPos
);
317 return Selection(nStartPos
, nEndPos
);
320 virtual void SetSelection( const Selection
& rSelection
) override
322 auto nMin
= rSelection
.Min();
323 auto nMax
= rSelection
.Max();
324 m_rEdit
.get_widget().select_region(nMin
< 0 ? 0 : nMin
, nMax
== SELECTION_MAX
? -1 : nMax
);
327 virtual void ReplaceSelected( const OUString
& rStr
) override
329 m_rEdit
.get_widget().replace_selection(rStr
);
332 virtual OUString
GetSelected( LineEnd
/*aSeparator*/ ) const override
333 // ignore the line end - this base implementation does not support it
335 int nStartPos
, nEndPos
;
336 weld::Entry
& rEntry
= m_rEdit
.get_widget();
337 rEntry
.get_selection_bounds(nStartPos
, nEndPos
);
338 return rEntry
.get_text().copy(nStartPos
, nEndPos
- nStartPos
);
341 virtual bool IsValueChangedFromSaved() const override
343 return m_rEdit
.get_widget().get_value_changed_from_saved();
346 virtual void SaveValue() override
348 m_rEdit
.get_widget().save_value();
351 virtual bool CanUp() const override
356 virtual bool CanDown() const override
361 virtual void Cut() override
363 m_rEdit
.get_widget().cut_clipboard();
366 virtual void Copy() override
368 m_rEdit
.get_widget().copy_clipboard();
371 virtual void Paste() override
373 m_rEdit
.get_widget().paste_clipboard();
377 //= MultiLineTextCell
379 /** a multi line edit which can be used in a cell of an EditBrowseBox
381 class UNLESS_MERGELIBS(SVT_DLLPUBLIC
) MultiLineTextCell final
: public ControlBase
384 MultiLineTextCell(BrowserDataWin
* pParent
);
386 virtual void SetEditableReadOnly(bool bReadOnly
) override
388 m_xWidget
->set_editable(!bReadOnly
);
391 virtual void GetFocus() override
;
393 virtual void dispose() override
;
395 void connect_changed(const Link
<weld::TextView
&, void>& rLink
)
397 m_xWidget
->connect_changed(rLink
);
400 weld::TextView
& get_widget() { return *m_xWidget
; }
403 std::unique_ptr
<weld::TextView
> m_xWidget
;
405 virtual bool ProcessKey(const KeyEvent
& rKEvt
) override
;
408 class SVT_DLLPUBLIC MultiLineEditImplementation
: public IEditImplementation
410 MultiLineTextCell
& m_rEdit
;
413 DECL_LINK(ModifyHdl
, weld::TextView
&, void);
415 MultiLineEditImplementation(MultiLineTextCell
& rEdit
)
419 m_rEdit
.connect_changed(LINK(this, MultiLineEditImplementation
, ModifyHdl
));
422 virtual Control
& GetControl() override
427 virtual OUString
GetText(LineEnd aSeparator
) const override
;
429 virtual void SetText(const OUString
& rStr
) override
431 return m_rEdit
.get_widget().set_text(rStr
);
434 virtual bool IsReadOnly() const override
436 return !m_rEdit
.get_widget().get_editable();
439 virtual void SetReadOnly( bool bReadOnly
) override
441 m_rEdit
.SetEditableReadOnly(bReadOnly
);
444 virtual sal_Int32
GetMaxTextLen() const override
446 return m_nMaxTextLen
;
449 virtual void SetMaxTextLen( sal_Int32 nMaxLen
) override
451 m_nMaxTextLen
= nMaxLen
;
452 m_rEdit
.get_widget().set_max_length(m_nMaxTextLen
);
455 virtual Selection
GetSelection() const override
457 int nStartPos
, nEndPos
;
458 m_rEdit
.get_widget().get_selection_bounds(nStartPos
, nEndPos
);
459 return Selection(nStartPos
, nEndPos
);
462 virtual void SetSelection( const Selection
& rSelection
) override
464 auto nMin
= rSelection
.Min();
465 auto nMax
= rSelection
.Max();
466 m_rEdit
.get_widget().select_region(nMin
< 0 ? 0 : nMin
, nMax
== SELECTION_MAX
? -1 : nMax
);
469 virtual void ReplaceSelected( const OUString
& rStr
) override
471 m_rEdit
.get_widget().replace_selection(rStr
);
474 virtual OUString
GetSelected( LineEnd aSeparator
) const override
;
476 virtual bool IsValueChangedFromSaved() const override
478 return m_rEdit
.get_widget().get_value_changed_from_saved();
481 virtual void SaveValue() override
483 m_rEdit
.get_widget().save_value();
486 virtual bool CanUp() const override
488 return m_rEdit
.get_widget().can_move_cursor_with_up();
491 virtual bool CanDown() const override
493 return m_rEdit
.get_widget().can_move_cursor_with_down();
496 virtual void Cut() override
498 m_rEdit
.get_widget().cut_clipboard();
501 virtual void Copy() override
503 m_rEdit
.get_widget().copy_clipboard();
506 virtual void Paste() override
508 m_rEdit
.get_widget().paste_clipboard();
513 //= EditCellController
514 class SVT_DLLPUBLIC EditCellController
: public CellController
516 IEditImplementation
* m_pEditImplementation
;
517 bool m_bOwnImplementation
; // did we create m_pEditImplementation?
520 EditCellController( EditControlBase
* _pEdit
);
521 EditCellController( IEditImplementation
* _pImplementation
);
522 virtual ~EditCellController( ) override
;
524 const IEditImplementation
* GetEditImplementation( ) const { return m_pEditImplementation
; }
525 IEditImplementation
* GetEditImplementation( ) { return m_pEditImplementation
; }
527 virtual bool IsValueChangedFromSaved() const override
;
528 virtual void SaveValue() override
;
536 virtual bool MoveAllowed(const KeyEvent
& rEvt
) const override
;
538 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
542 class SVT_DLLPUBLIC CheckBoxControl final
: public ControlBase
544 std::unique_ptr
<weld::CheckButton
> m_xBox
;
545 weld::TriStateEnabled m_aModeState
;
546 Link
<weld::Button
&,void> m_aClickLink
;
547 Link
<LinkParamNone
*,void> m_aModify1Hdl
;
548 Link
<LinkParamNone
*,void> m_aModify2Hdl
;
551 CheckBoxControl(BrowserDataWin
* pParent
);
552 virtual ~CheckBoxControl() override
;
553 virtual void dispose() override
;
555 void SetClickHdl(const Link
<weld::Button
&,void>& rHdl
) {m_aClickLink
= rHdl
;}
557 // sets a link to call when the text is changed by the user
558 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rHdl
)
560 m_aModify1Hdl
= rHdl
;
563 // sets an additional link to call when the text is changed by the user
564 void SetAuxModifyHdl(const Link
<LinkParamNone
*,void>& rLink
)
566 m_aModify2Hdl
= rLink
;
569 void SetState(TriState eState
);
570 TriState
GetState() const { return m_xBox
->get_state(); }
572 void EnableTriState(bool bTriState
);
574 weld::CheckButton
& GetBox() {return *m_xBox
;};
576 // for pseudo-click when initially clicking in a cell activates
577 // the cell and performs a state change on the button as if
582 DECL_LINK(OnToggle
, weld::ToggleButton
&, void);
584 void CallModifyHdls()
586 m_aModify1Hdl
.Call(nullptr);
587 m_aModify2Hdl
.Call(nullptr);
591 //= CheckBoxCellController
592 class SVT_DLLPUBLIC CheckBoxCellController final
: public CellController
596 CheckBoxCellController(CheckBoxControl
* pWin
);
597 weld::CheckButton
& GetCheckBox() const;
599 virtual bool IsValueChangedFromSaved() const override
;
600 virtual void SaveValue() override
;
603 virtual void ActivatingMouseEvent(const BrowserMouseEvent
& rEvt
, bool bUp
) override
;
604 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
608 class SVT_DLLPUBLIC ComboBoxControl final
: public ControlBase
611 std::unique_ptr
<weld::ComboBox
> m_xWidget
;
612 Link
<LinkParamNone
*,void> m_aModify1Hdl
;
613 Link
<bool,void> m_aModify2Hdl
;
615 friend class ComboBoxCellController
;
618 ComboBoxControl(BrowserDataWin
* pParent
);
620 virtual void SetEditableReadOnly(bool bReadOnly
) override
622 m_xWidget
->set_entry_editable(!bReadOnly
);
625 weld::ComboBox
& get_widget() { return *m_xWidget
; }
627 // sets a link to call when the selection is changed by the user
628 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rHdl
)
630 m_aModify1Hdl
= rHdl
;
633 // sets an additional link to call when the selection is changed by the user
634 // bool arg is true when triggered interactively by the user
635 void SetAuxModifyHdl(const Link
<bool,void>& rLink
)
637 m_aModify2Hdl
= rLink
;
640 void TriggerAuxModify()
642 m_aModify2Hdl
.Call(false);
645 virtual void dispose() override
;
648 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
650 void CallModifyHdls()
652 m_aModify1Hdl
.Call(nullptr);
653 m_aModify2Hdl
.Call(true);
657 //= ComboBoxCellController
658 class SVT_DLLPUBLIC ComboBoxCellController
: public CellController
662 ComboBoxCellController(ComboBoxControl
* pParent
);
663 weld::ComboBox
& GetComboBox() const { return static_cast<ComboBoxControl
&>(GetWindow()).get_widget(); }
665 virtual bool IsValueChangedFromSaved() const override
;
666 virtual void SaveValue() override
;
669 virtual bool MoveAllowed(const KeyEvent
& rEvt
) const override
;
671 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
675 class SVT_DLLPUBLIC ListBoxControl final
: public ControlBase
678 std::unique_ptr
<weld::ComboBox
> m_xWidget
;
679 Link
<LinkParamNone
*,void> m_aModify1Hdl
;
680 Link
<bool,void> m_aModify2Hdl
;
682 friend class ListBoxCellController
;
685 ListBoxControl(BrowserDataWin
* pParent
);
687 weld::ComboBox
& get_widget() { return *m_xWidget
; }
689 // sets a link to call when the selection is changed by the user
690 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rHdl
)
692 m_aModify1Hdl
= rHdl
;
695 // sets an additional link to call when the selection is changed,
696 // bool arg is true when triggered interactively by the user
697 void SetAuxModifyHdl(const Link
<bool,void>& rLink
)
699 m_aModify2Hdl
= rLink
;
702 void TriggerAuxModify()
704 m_aModify2Hdl
.Call(false);
707 virtual void dispose() override
;
709 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
711 void CallModifyHdls()
713 m_aModify1Hdl
.Call(nullptr);
714 m_aModify2Hdl
.Call(true);
718 //= ListBoxCellController
719 class SVT_DLLPUBLIC ListBoxCellController
: public CellController
723 ListBoxCellController(ListBoxControl
* pParent
);
724 weld::ComboBox
& GetListBox() const { return static_cast<ListBoxControl
&>(GetWindow()).get_widget(); }
726 virtual bool IsValueChangedFromSaved() const override
;
727 virtual void SaveValue() override
;
730 virtual bool MoveAllowed(const KeyEvent
& rEvt
) const override
;
732 DECL_LINK(ListBoxSelectHdl
, LinkParamNone
*, void);
735 class SVT_DLLPUBLIC FormattedControlBase
: public EditControlBase
738 FormattedControlBase(BrowserDataWin
* pParent
, bool bSpinVariant
);
740 virtual void dispose() override
;
742 virtual void connect_changed(const Link
<weld::Entry
&, void>& rLink
) override
;
743 virtual void connect_focus_out(const Link
<weld::Widget
&, void>& rLink
) override
;
745 weld::EntryFormatter
& get_formatter();
749 std::unique_ptr
<weld::Entry
> m_xEntry
;
750 std::unique_ptr
<weld::FormattedSpinButton
> m_xSpinButton
;
751 std::unique_ptr
<weld::EntryFormatter
> m_xEntryFormatter
;
753 void InitFormattedControlBase();
756 class SVT_DLLPUBLIC FormattedControl
: public FormattedControlBase
759 FormattedControl(BrowserDataWin
* pParent
, bool bSpinVariant
);
762 class SVT_DLLPUBLIC DoubleNumericControl
: public FormattedControlBase
765 DoubleNumericControl(BrowserDataWin
* pParent
, bool bSpinVariant
);
768 class SVT_DLLPUBLIC LongCurrencyControl
: public FormattedControlBase
771 LongCurrencyControl(BrowserDataWin
* pParent
, bool bSpinVariant
);
774 class SVT_DLLPUBLIC TimeControl
: public FormattedControlBase
777 TimeControl(BrowserDataWin
* pParent
, bool bSpinVariant
);
780 class SVT_DLLPUBLIC DateControl
: public FormattedControlBase
783 DateControl(BrowserDataWin
* pParent
, bool bDropDown
);
785 void SetDate(const Date
& rDate
);
787 virtual void dispose() override
;
789 std::unique_ptr
<weld::MenuButton
> m_xMenuButton
;
790 std::unique_ptr
<weld::Builder
> m_xCalendarBuilder
;
791 std::unique_ptr
<weld::Widget
> m_xTopLevel
;
792 std::unique_ptr
<weld::Calendar
> m_xCalendar
;
793 std::unique_ptr
<weld::Widget
> m_xExtras
;
794 std::unique_ptr
<weld::Button
> m_xTodayBtn
;
795 std::unique_ptr
<weld::Button
> m_xNoneBtn
;
797 DECL_LINK(ToggleHdl
, weld::ToggleButton
&, void);
798 DECL_LINK(ActivateHdl
, weld::Calendar
&, void);
799 DECL_LINK(ImplClickHdl
, weld::Button
&, void);
802 class SVT_DLLPUBLIC PatternControl final
: public EditControl
805 PatternControl(BrowserDataWin
* pParent
);
807 weld::PatternFormatter
& get_formatter() { return *m_xEntryFormatter
; }
809 virtual void connect_changed(const Link
<weld::Entry
&, void>& rLink
) override
;
810 virtual void connect_focus_out(const Link
<weld::Widget
&, void>& rLink
) override
;
812 virtual void dispose() override
;
814 std::unique_ptr
<weld::PatternFormatter
> m_xEntryFormatter
;
817 //= FormattedFieldCellController
818 class SVT_DLLPUBLIC FormattedFieldCellController final
: public EditCellController
821 FormattedFieldCellController( FormattedControlBase
* _pFormatted
);
823 virtual void CommitModifications() override
;
826 //= EditBrowserHeader
827 class SVT_DLLPUBLIC EditBrowserHeader
: public BrowserHeader
830 EditBrowserHeader( BrowseBox
* pParent
, WinBits nWinBits
= WB_BUTTONSTYLE
)
831 :BrowserHeader(pParent
, nWinBits
){}
834 virtual void DoubleClick() override
;
839 class EditBrowseBoxImpl
;
840 class SVT_DLLPUBLIC EditBrowseBox
: public BrowseBox
842 friend class EditBrowserHeader
;
862 CURRENT_PRIMARYKEY
= 7,
868 EditBrowseBox(EditBrowseBox
const &) = delete;
869 EditBrowseBox
& operator=(EditBrowseBox
const &) = delete;
871 class BrowserMouseEventPtr
873 std::unique_ptr
<BrowserMouseEvent
> pEvent
;
877 BrowserMouseEventPtr()
882 bool Is() const {return pEvent
!= nullptr;}
883 bool IsDown() const {return bDown
;}
884 const BrowserMouseEvent
* operator->() const {return pEvent
.get();}
886 SVT_DLLPUBLIC
void Clear();
887 void Set(const BrowserMouseEvent
* pEvt
, bool bIsDown
);
890 CellControllerRef aController
,
893 ImplSVEvent
* nStartEvent
, * nEndEvent
, * nCellModifiedEvent
; // event ids
894 VclPtr
<vcl::Window
> m_pFocusWhileRequest
;
895 // In ActivateCell, we grab the focus asynchronously, but if between requesting activation
896 // and the asynchronous event the focus has changed, we won't grab it for ourself.
898 sal_Int32 nPaintRow
; // row being painted
903 mutable bool bPaintStatus
: 1; // paint a status (image) in the handle column
904 bool bActiveBeforeTracking
;
906 VclPtr
<CheckBoxControl
> pCheckBoxPaint
;
908 EditBrowseBoxFlags m_nBrowserFlags
;
909 std::unique_ptr
< EditBrowseBoxImpl
> m_aImpl
;
912 VclPtr
<BrowserHeader
> pHeader
;
914 BrowserMouseEventPtr
& getMouseEvent() { return aMouseEvent
; }
917 BrowserHeader
* GetHeaderBar() const {return pHeader
;}
919 virtual VclPtr
<BrowserHeader
> CreateHeaderBar(BrowseBox
* pParent
) override
;
921 // if you want to have an own header ...
922 virtual VclPtr
<BrowserHeader
> imp_CreateHeaderBar(BrowseBox
* pParent
);
924 virtual void ColumnMoved(sal_uInt16 nId
) override
;
925 virtual void ColumnResized(sal_uInt16 nColId
) override
;
926 virtual void Resize() override
;
927 virtual void ArrangeControls(sal_uInt16
& nX
, sal_uInt16 nY
);
928 virtual bool SeekRow(sal_Int32 nRow
) override
;
930 virtual void GetFocus() override
;
931 virtual void LoseFocus() override
;
932 virtual void KeyInput(const KeyEvent
& rEvt
) override
;
933 virtual void MouseButtonDown(const BrowserMouseEvent
& rEvt
) override
;
934 virtual void MouseButtonUp(const BrowserMouseEvent
& rEvt
) override
;
935 virtual void StateChanged( StateChangedType nType
) override
;
936 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
938 using BrowseBox::MouseButtonUp
;
939 using BrowseBox::MouseButtonDown
;
941 virtual bool PreNotify(NotifyEvent
& rNEvt
) override
;
942 virtual bool EventNotify(NotifyEvent
& rNEvt
) override
;
944 virtual void EndScroll() override
;
946 // should be used instead of GetFieldRectPixel, 'cause this method here takes into account the borders
947 tools::Rectangle
GetCellRect(sal_Int32 nRow
, sal_uInt16 nColId
, bool bRelToBrowser
= true) const;
948 virtual sal_uInt32
GetTotalCellWidth(sal_Int32 nRow
, sal_uInt16 nColId
);
949 sal_uInt32
GetAutoColumnWidth(sal_uInt16 nColId
);
951 virtual void PaintStatusCell(OutputDevice
& rDev
, const tools::Rectangle
& rRect
) const;
952 virtual void PaintCell(OutputDevice
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColId
) const = 0;
954 virtual RowStatus
GetRowStatus(sal_Int32 nRow
) const;
956 virtual void RowHeightChanged() override
;
958 // callbacks for the data window
959 virtual void ImplStartTracking() override
;
960 virtual void ImplEndTracking() override
;
962 // when changing a row:
963 // CursorMoving: cursor is being moved, but GetCurRow() still provides the old row
964 virtual bool CursorMoving(sal_Int32 nNewRow
, sal_uInt16 nNewCol
);
966 // cursor has been moved
967 virtual void CursorMoved() override
;
969 virtual void CellModified(); // called whenever a cell has been modified
970 virtual bool SaveModified(); // called whenever a cell should be left, and it's content should be saved
971 // return sal_False prevents leaving the cell
972 virtual bool SaveRow(); // commit the current row
974 virtual bool IsModified() const {return aController
.is() && aController
->IsValueChangedFromSaved();}
976 virtual CellController
* GetController(sal_Int32 nRow
, sal_uInt16 nCol
);
977 virtual void InitController(CellControllerRef
& rController
, sal_Int32 nRow
, sal_uInt16 nCol
);
978 static void ResizeController(CellControllerRef
const & rController
, const tools::Rectangle
&);
979 virtual void DoubleClick(const BrowserMouseEvent
&) override
;
981 void ActivateCell() { ActivateCell(GetCurRow(), GetCurColumnId()); }
983 // retrieve the image for the row status
984 Image
GetImage(RowStatus
) const;
987 // if you don't set a width, this will be calculated automatically
988 // if the id isn't set the smallest unused will do it ...
989 virtual sal_uInt16
AppendColumn(const OUString
& rName
, sal_uInt16 nWidth
, sal_uInt16 nPos
= HEADERBAR_APPEND
, sal_uInt16 nId
= sal_uInt16(-1));
991 // called whenever (Shift)Tab or Enter is pressed. If true is returned, these keys
992 // result in traveling to the next or to th previous cell
993 virtual bool IsTabAllowed(bool bForward
) const;
995 virtual bool IsCursorMoveAllowed(sal_Int32 nNewRow
, sal_uInt16 nNewColId
) const override
;
997 void PaintTristate(const tools::Rectangle
& rRect
, const TriState
& eState
, bool _bEnabled
=true) const;
999 void AsynchGetFocus();
1000 // secure starting of StartEditHdl
1003 EditBrowseBox(vcl::Window
* pParent
, EditBrowseBoxFlags nBrowserFlags
, WinBits nBits
, BrowserMode nMode
= BrowserMode::NONE
);
1004 virtual ~EditBrowseBox() override
;
1005 virtual void dispose() override
;
1007 bool IsEditing() const {return aController
.is();}
1008 void InvalidateStatusCell(sal_Int32 nRow
) {RowModified(nRow
, 0);}
1009 void InvalidateHandleColumn();
1011 // late construction
1012 virtual void Init();
1013 virtual void RemoveRows();
1014 virtual void Dispatch(sal_uInt16 nId
);
1016 const CellControllerRef
& Controller() const { return aController
; }
1017 EditBrowseBoxFlags
GetBrowserFlags() const { return m_nBrowserFlags
; }
1018 void SetBrowserFlags(EditBrowseBoxFlags nFlags
);
1020 virtual void ActivateCell(sal_Int32 nRow
, sal_uInt16 nCol
, bool bSetCellFocus
= true);
1021 virtual void DeactivateCell(bool bUpdate
= true);
1022 // Children ---------------------------------------------------------------
1024 /** @return The count of additional controls of the control area. */
1025 virtual sal_Int32
GetAccessibleControlCount() const override
;
1027 /** Creates the accessible object of an additional control.
1029 The 0-based index of the control.
1031 The XAccessible interface of the specified control. */
1032 virtual css::uno::Reference
< css::accessibility::XAccessible
>
1033 CreateAccessibleControl( sal_Int32 nIndex
) override
;
1035 /** Sets focus to current cell of the data table. */
1036 virtual void GrabTableFocus() override
;
1038 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
1039 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
1041 virtual bool ProcessKey(const KeyEvent
& rEvt
) override
;
1043 virtual void ChildFocusIn() override
;
1044 virtual void ChildFocusOut() override
;
1046 css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleCheckBoxCell(sal_Int32 _nRow
, sal_uInt16 _nColumnPos
,const TriState
& eState
);
1047 bool ControlHasFocus() const;
1049 // creates the accessible which wraps the active cell
1050 void implCreateActiveAccessible( );
1053 virtual void PaintField(vcl::RenderContext
& rDev
, const tools::Rectangle
& rRect
,
1054 sal_uInt16 nColumnId
) const override
;
1055 using Control::ImplInitSettings
;
1056 SVT_DLLPRIVATE
void ImplInitSettings( bool bFont
, bool bForeground
, bool bBackground
);
1057 SVT_DLLPRIVATE
void DetermineFocus( const GetFocusFlags _nGetFocusFlags
= GetFocusFlags::NONE
);
1058 inline void EnableAndShow() const;
1060 SVT_DLLPRIVATE
void implActivateCellOnMouseEvent(const BrowserMouseEvent
& _rEvt
, bool _bUp
);
1062 DECL_DLLPRIVATE_LINK( ModifyHdl
, LinkParamNone
*, void );
1063 DECL_DLLPRIVATE_LINK( StartEditHdl
, void*, void );
1064 DECL_DLLPRIVATE_LINK( EndEditHdl
, void*, void );
1065 DECL_DLLPRIVATE_LINK( CellModifiedHdl
, void*, void );
1071 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */