LibreOffice Module svtools (master) 1
editbrowsebox.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <memory>
23#include <svtools/svtdllapi.h>
24#include <tools/ref.hxx>
25
26#include <svtools/brwbox.hxx>
27#include <svtools/brwhead.hxx>
28#include <tools/lineend.hxx>
30#include <vcl/weldutils.hxx>
32
33class BrowserDataWin;
34
35// EditBrowseBoxFlags (EBBF)
37{
38 NONE = 0x0000,
51 HANDLE_COLUMN_TEXT = 0x0004,
52
60 SMART_TAB_TRAVEL = 0x0008,
61
62};
63namespace o3tl
64{
65 template<> struct typed_flags<EditBrowseBoxFlags> : is_typed_flags<EditBrowseBoxFlags, 0x0f> {};
66}
67
68namespace svt
69{
70 class ControlBase;
71
73 {
74 friend class EditBrowseBox;
76
78 bool bSuspended; // <true> if the window is hidden and disabled
79
80 public:
81
83 virtual ~CellController() override;
84
85 ControlBase& GetWindow() const { return *const_cast<CellController*>(this)->pWindow; }
86
87 virtual void SaveValue() = 0;
88 virtual bool IsValueChangedFromSaved() const = 0;
89
90 // commit any current changes. Especially, do any reformatting you need (from input formatting
91 // to output formatting) here
92 virtual void CommitModifications();
93
94 // suspending the controller is not cumulative!
95 void suspend( );
96 void resume( );
97 bool isSuspended( ) const { return bSuspended; }
98
99 protected:
100 virtual bool MoveAllowed(const KeyEvent& rEvt) const;
101 void SetModifyHdl(const Link<LinkParamNone*,void>& rLink) { maModifyHdl = rLink; }
102 virtual void ActivatingMouseEvent(const BrowserMouseEvent& rEvt, bool bUp);
103 virtual void callModifyHdl() { maModifyHdl.Call(nullptr); }
104 };
105
107
108
109 //= IEditImplementation
110
112 {
113 public:
114 virtual ~IEditImplementation() = 0;
115
116 virtual ControlBase& GetControl() = 0;
117
118 virtual OUString GetText( LineEnd aSeparator ) const = 0;
119 virtual void SetText( const OUString& _rStr ) = 0;
120
121 virtual bool IsReadOnly() const = 0;
122 virtual void SetReadOnly( bool bReadOnly ) = 0;
123
124 virtual sal_Int32 GetMaxTextLen() const = 0;
125 virtual void SetMaxTextLen( sal_Int32 _nMaxLen ) = 0;
126
127 virtual Selection GetSelection() const = 0;
128 virtual void SetSelection( const Selection& _rSelection ) = 0;
129
130 virtual void ReplaceSelected( const OUString& _rStr ) = 0;
131 virtual OUString GetSelected( LineEnd aSeparator ) const = 0;
132
133 virtual bool IsValueChangedFromSaved() const = 0;
134 virtual void SaveValue() = 0;
135
136 virtual bool CanUp() const = 0;
137 virtual bool CanDown() const = 0;
138
139 virtual void Cut() = 0;
140 virtual void Copy() = 0;
141 virtual void Paste() = 0;
142
143 // sets a link to call when the text is changed by the user
145 {
146 m_aModify1Hdl = rLink;
147 }
148
149 // sets an additional link to call when the text is changed by the user
151 {
152 m_aModify2Hdl = rLink;
153 }
154
155 private:
158
159 protected:
161 {
162 m_aModify1Hdl.Call(nullptr);
163 m_aModify2Hdl.Call(nullptr);
164 }
165 };
166
168 {
169 public:
170 ControlBase(BrowserDataWin* pParent, const OUString& rUIXMLDescription, const OUString& rID);
171
172 virtual void SetEditableReadOnly(bool bReadOnly);
173
174 virtual bool ProcessKey(const KeyEvent& rKEvt);
175
176 virtual void SetPointFont(const vcl::Font& rFont) = 0;
177
178 // chain after the FocusInHdl
180 {
181 m_aFocusInHdl = rHdl;
182 }
183
184 // chain after the FocusOutHdl
186 {
187 m_aFocusOutHdl = rHdl;
188 }
189
191 {
192 m_aMousePressHdl = rHdl;
193 }
194
196 {
197 m_aMouseReleaseHdl = rHdl;
198 }
199
201 {
202 m_aMouseMoveHdl = rHdl;
203 }
204
206 {
207 m_aKeyInputHdl = rHdl;
208 }
209
211 {
212 m_aKeyReleaseHdl = rHdl;
213 }
214
215 protected:
216 DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
217 DECL_DLLPRIVATE_LINK(KeyReleaseHdl, const KeyEvent&, bool);
219 DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void);
220 DECL_DLLPRIVATE_LINK(MousePressHdl, const MouseEvent&, bool);
221 DECL_DLLPRIVATE_LINK(MouseReleaseHdl, const MouseEvent&, bool);
222 DECL_DLLPRIVATE_LINK(MouseMoveHdl, const MouseEvent&, bool);
223 private:
231 };
232
234 {
235 public:
237
238 virtual void SetEditableReadOnly(bool bReadOnly) override
239 {
240 m_pEntry->set_editable(!bReadOnly);
241 }
242
243 virtual void SetPointFont(const vcl::Font& rFont) override
244 {
245 m_pEntry->set_font(rFont);
246 }
247
248 virtual void dispose() override;
249
250 weld::Entry& get_widget() { return *m_pEntry; }
251
252 virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0;
253 virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) = 0;
254 virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) = 0;
255 virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) = 0;
256
257 protected:
258 void InitEditControlBase(weld::Entry* pEntry);
259
260 private:
262 };
263
265 {
266 public:
267 EditControl(BrowserDataWin* pParent);
268
269 virtual void dispose() override;
270
271 virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override
272 {
273 m_xWidget->connect_changed(rLink);
274 }
275
276 virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override
277 {
278 m_xWidget->connect_focus_in(rLink);
279 }
280
281 virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override
282 {
283 m_xWidget->connect_focus_out(rLink);
284 }
285
286 virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override
287 {
288 m_xWidget->connect_key_press(rLink);
289 }
290
291 protected:
292 std::unique_ptr<weld::Entry> m_xWidget;
293 };
294
296 {
299
300 DECL_LINK(ModifyHdl, weld::Entry&, void);
301 public:
303 : m_rEdit(rEdit)
304 , m_nMaxTextLen(0)
305 {
306 m_rEdit.connect_changed(LINK(this, EntryImplementation, ModifyHdl));
307 }
308
309 virtual ControlBase& GetControl() override
310 {
311 return m_rEdit;
312 }
313
314 virtual OUString GetText( LineEnd /*aSeparator*/ ) const override
315 {
316 // ignore the line end - this base implementation does not support it
317 return m_rEdit.get_widget().get_text();
318 }
319
320 virtual void SetText( const OUString& _rStr ) override
321 {
322 return m_rEdit.get_widget().set_text(_rStr);
323 }
324
325 virtual bool IsReadOnly() const override
326 {
327 return !m_rEdit.get_widget().get_editable();
328 }
329
330 virtual void SetReadOnly( bool bReadOnly ) override
331 {
333 }
334
335 virtual sal_Int32 GetMaxTextLen() const override
336 {
337 return m_nMaxTextLen;
338 }
339
340 virtual void SetMaxTextLen( sal_Int32 nMaxLen ) override
341 {
342 m_nMaxTextLen = nMaxLen;
343 m_rEdit.get_widget().set_max_length(m_nMaxTextLen);
344 }
345
346 virtual Selection GetSelection() const override
347 {
348 int nStartPos, nEndPos;
349 m_rEdit.get_widget().get_selection_bounds(nStartPos, nEndPos);
350 return Selection(nStartPos, nEndPos);
351 }
352
353 virtual void SetSelection( const Selection& rSelection ) override
354 {
355 auto nMin = rSelection.Min();
356 auto nMax = rSelection.Max();
357 m_rEdit.get_widget().select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax);
358 }
359
360 virtual void ReplaceSelected( const OUString& rStr ) override
361 {
362 m_rEdit.get_widget().replace_selection(rStr);
363 }
364
365 virtual OUString GetSelected( LineEnd /*aSeparator*/ ) const override
366 // ignore the line end - this base implementation does not support it
367 {
368 int nStartPos, nEndPos;
369 weld::Entry& rEntry = m_rEdit.get_widget();
370 rEntry.get_selection_bounds(nStartPos, nEndPos);
371 return rEntry.get_text().copy(nStartPos, nEndPos - nStartPos);
372 }
373
374 virtual bool IsValueChangedFromSaved() const override
375 {
376 return m_rEdit.get_widget().get_value_changed_from_saved();
377 }
378
379 virtual void SaveValue() override
380 {
381 m_rEdit.get_widget().save_value();
382 }
383
384 virtual bool CanUp() const override
385 {
386 return false;
387 }
388
389 virtual bool CanDown() const override
390 {
391 return false;
392 }
393
394 virtual void Cut() override
395 {
396 m_rEdit.get_widget().cut_clipboard();
397 }
398
399 virtual void Copy() override
400 {
401 m_rEdit.get_widget().copy_clipboard();
402 }
403
404 virtual void Paste() override
405 {
406 m_rEdit.get_widget().paste_clipboard();
407 }
408 };
409
410 //= MultiLineTextCell
411
415 {
416 public:
418
419 virtual void SetEditableReadOnly(bool bReadOnly) override
420 {
421 m_xWidget->set_editable(!bReadOnly);
422 }
423
424 virtual void SetPointFont(const vcl::Font& rFont) override
425 {
426 m_xWidget->set_font(rFont);
427 }
428
429 virtual void GetFocus() override;
430
431 virtual void dispose() override;
432
434 {
435 m_xWidget->connect_changed(rLink);
436 }
437
439
440 private:
441 std::unique_ptr<weld::TextView> m_xWidget;
442
443 virtual bool ProcessKey(const KeyEvent& rKEvt) override;
444 };
445
447 {
450
451 DECL_LINK(ModifyHdl, weld::TextView&, void);
452 public:
454 : m_rEdit(rEdit)
455 , m_nMaxTextLen(0)
456 {
457 m_rEdit.connect_changed(LINK(this, MultiLineEditImplementation, ModifyHdl));
458 }
459
460 virtual ControlBase& GetControl() override
461 {
462 return m_rEdit;
463 }
464
465 virtual OUString GetText(LineEnd aSeparator) const override;
466
467 virtual void SetText(const OUString& rStr) override
468 {
469 return m_rEdit.get_widget().set_text(rStr);
470 }
471
472 virtual bool IsReadOnly() const override
473 {
474 return !m_rEdit.get_widget().get_editable();
475 }
476
477 virtual void SetReadOnly( bool bReadOnly ) override
478 {
480 }
481
482 virtual sal_Int32 GetMaxTextLen() const override
483 {
484 return m_nMaxTextLen;
485 }
486
487 virtual void SetMaxTextLen( sal_Int32 nMaxLen ) override
488 {
489 m_nMaxTextLen = nMaxLen;
490 m_rEdit.get_widget().set_max_length(m_nMaxTextLen);
491 }
492
493 virtual Selection GetSelection() const override
494 {
495 int nStartPos, nEndPos;
496 m_rEdit.get_widget().get_selection_bounds(nStartPos, nEndPos);
497 return Selection(nStartPos, nEndPos);
498 }
499
500 virtual void SetSelection( const Selection& rSelection ) override
501 {
502 auto nMin = rSelection.Min();
503 auto nMax = rSelection.Max();
504 m_rEdit.get_widget().select_region(nMin < 0 ? 0 : nMin, nMax == SELECTION_MAX ? -1 : nMax);
505 }
506
507 virtual void ReplaceSelected( const OUString& rStr ) override
508 {
509 m_rEdit.get_widget().replace_selection(rStr);
510 }
511
512 virtual OUString GetSelected( LineEnd aSeparator ) const override;
513
514 virtual bool IsValueChangedFromSaved() const override
515 {
516 return m_rEdit.get_widget().get_value_changed_from_saved();
517 }
518
519 virtual void SaveValue() override
520 {
521 m_rEdit.get_widget().save_value();
522 }
523
524 virtual bool CanUp() const override
525 {
526 return m_rEdit.get_widget().can_move_cursor_with_up();
527 }
528
529 virtual bool CanDown() const override
530 {
531 return m_rEdit.get_widget().can_move_cursor_with_down();
532 }
533
534 virtual void Cut() override
535 {
536 m_rEdit.get_widget().cut_clipboard();
537 }
538
539 virtual void Copy() override
540 {
541 m_rEdit.get_widget().copy_clipboard();
542 }
543
544 virtual void Paste() override
545 {
546 m_rEdit.get_widget().paste_clipboard();
547 }
548 };
549
550
551 //= EditCellController
553 {
555 bool m_bOwnImplementation; // did we create m_pEditImplementation?
556
557 public:
559 EditCellController( IEditImplementation* _pImplementation );
560 virtual ~EditCellController( ) override;
561
562 const IEditImplementation* GetEditImplementation( ) const { return m_pEditImplementation; }
563 IEditImplementation* GetEditImplementation( ) { return m_pEditImplementation; }
564
565 virtual bool IsValueChangedFromSaved() const override;
566 virtual void SaveValue() override;
567
568 void Modify()
569 {
570 ModifyHdl(nullptr);
571 }
572
573 protected:
574 virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
575 private:
576 DECL_LINK(ModifyHdl, LinkParamNone*, void);
577 };
578
579 //= CheckBoxControl
581 {
582 std::unique_ptr<weld::CheckButton> m_xBox;
587
588 public:
590 virtual ~CheckBoxControl() override;
591 virtual void dispose() override;
592
593 virtual void SetPointFont(const vcl::Font& rFont) override;
594
595 void SetToggleHdl(const Link<weld::CheckButton&,void>& rHdl) {m_aToggleLink = rHdl;}
596
597 // sets a link to call when the text is changed by the user
599 {
600 m_aModify1Hdl = rHdl;
601 }
602
603 // sets an additional link to call when the text is changed by the user
605 {
606 m_aModify2Hdl = rLink;
607 }
608
609 void SetState(TriState eState);
610 TriState GetState() const { return m_xBox->get_state(); }
611
612 void EnableTriState(bool bTriState);
613
614 weld::CheckButton& GetBox() {return *m_xBox;};
615
616 // for pseudo-click when initially clicking in a cell activates
617 // the cell and performs a state change on the button as if
618 // it was clicked on
619 void Clicked();
620
621 private:
623
625 {
626 m_aModify1Hdl.Call(nullptr);
627 m_aModify2Hdl.Call(nullptr);
628 }
629 };
630
631 //= CheckBoxCellController
633 {
634 public:
635
637 weld::CheckButton& GetCheckBox() const;
638
639 virtual bool IsValueChangedFromSaved() const override;
640 virtual void SaveValue() override;
641
642 private:
643 virtual void ActivatingMouseEvent(const BrowserMouseEvent& rEvt, bool bUp) override;
645 };
646
647 //= ComboBoxControl
649 {
650 private:
651 std::unique_ptr<weld::ComboBox> m_xWidget;
654
656
657 public:
659
660 virtual void SetPointFont(const vcl::Font& rFont) override;
661
662 virtual void SetEditableReadOnly(bool bReadOnly) override
663 {
664 m_xWidget->set_entry_editable(!bReadOnly);
665 }
666
668
669 // sets a link to call when the selection is changed by the user
671 {
672 m_aModify1Hdl = rHdl;
673 }
674
675 // sets an additional link to call when the selection is changed by the user
676 // bool arg is true when triggered interactively by the user
678 {
679 m_aModify2Hdl = rLink;
680 }
681
683 {
684 m_aModify2Hdl.Call(false);
685 }
686
687 virtual void dispose() override;
688
689 private:
691
693 {
694 m_aModify1Hdl.Call(nullptr);
695 m_aModify2Hdl.Call(true);
696 }
697 };
698
699 //= ComboBoxCellController
701 {
702 public:
703
705 weld::ComboBox& GetComboBox() const { return static_cast<ComboBoxControl&>(GetWindow()).get_widget(); }
706
707 virtual bool IsValueChangedFromSaved() const override;
708 virtual void SaveValue() override;
709
710 private:
711 virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
713 };
714
715 //= ListBoxControl
717 {
718 private:
719 std::unique_ptr<weld::ComboBox> m_xWidget;
722
724
725 public:
727
728 virtual void SetPointFont(const vcl::Font& rFont) override;
729
731
732 // sets a link to call when the selection is changed by the user
734 {
735 m_aModify1Hdl = rHdl;
736 }
737
738 // sets an additional link to call when the selection is changed,
739 // bool arg is true when triggered interactively by the user
741 {
742 m_aModify2Hdl = rLink;
743 }
744
746 {
747 m_aModify2Hdl.Call(false);
748 }
749
750 virtual void dispose() override;
751 private:
753
755 {
756 m_aModify1Hdl.Call(nullptr);
757 m_aModify2Hdl.Call(true);
758 }
759 };
760
761 //= ListBoxCellController
763 {
764 public:
765
767 weld::ComboBox& GetListBox() const { return static_cast<ListBoxControl&>(GetWindow()).get_widget(); }
768
769 virtual bool IsValueChangedFromSaved() const override;
770 virtual void SaveValue() override;
771
772 protected:
773 virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
774 private:
775 DECL_DLLPRIVATE_LINK(ListBoxSelectHdl, LinkParamNone*, void);
776 };
777
779 {
780 public:
781 FormattedControlBase(BrowserDataWin* pParent, bool bSpinVariant);
782
783 virtual void dispose() override;
784
785 virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
786 virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override;
787 virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
788 virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override;
789
790 weld::EntryFormatter& get_formatter();
791
792 protected:
794 std::unique_ptr<weld::Entry> m_xEntry;
795 std::unique_ptr<weld::FormattedSpinButton> m_xSpinButton;
796 std::unique_ptr<weld::EntryFormatter> m_xEntryFormatter;
797
798 void InitFormattedControlBase();
799 };
800
802 {
803 public:
804 FormattedControl(BrowserDataWin* pParent, bool bSpinVariant);
805 };
806
808 {
809 public:
810 DoubleNumericControl(BrowserDataWin* pParent, bool bSpinVariant);
811 };
812
814 {
815 public:
816 LongCurrencyControl(BrowserDataWin* pParent, bool bSpinVariant);
817 };
818
820 {
821 public:
822 TimeControl(BrowserDataWin* pParent, bool bSpinVariant);
823 };
824
826 {
827 public:
828 DateControl(BrowserDataWin* pParent, bool bDropDown);
829
830 void SetDate(const Date& rDate);
831
832 virtual void dispose() override;
833 private:
834 std::unique_ptr<weld::MenuButton> m_xMenuButton;
835 std::unique_ptr<weld::Builder> m_xCalendarBuilder;
836 std::unique_ptr<weld::Widget> m_xTopLevel;
837 std::unique_ptr<weld::Calendar> m_xCalendar;
838 std::unique_ptr<weld::Widget> m_xExtras;
839 std::unique_ptr<weld::Button> m_xTodayBtn;
840 std::unique_ptr<weld::Button> m_xNoneBtn;
841
844 DECL_DLLPRIVATE_LINK(ImplClickHdl, weld::Button&, void);
845 };
846
848 {
849 public:
851
852 weld::PatternFormatter& get_formatter() { return *m_xEntryFormatter; }
853
854 virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
855 virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override;
856 virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
857 virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override;
858
859 virtual void dispose() override;
860 private:
861 std::unique_ptr<weld::Entry> m_xWidget;
862 std::unique_ptr<weld::PatternFormatter> m_xEntryFormatter;
863 };
864
865 //= FormattedFieldCellController
867 {
868 public:
870
871 virtual void CommitModifications() override;
872 };
873
874 //= EditBrowserHeader
876 {
877 public:
878 EditBrowserHeader( BrowseBox* pParent, WinBits nWinBits = WB_BUTTONSTYLE )
879 :BrowserHeader(pParent, nWinBits){}
880
881 protected:
882 virtual void DoubleClick() override;
883 };
884
885
886 //= EditBrowseBox
887 class EditBrowseBoxImpl;
889 {
890 friend class EditBrowserHeader;
891
893 {
894 COLSELECT = 1,
895 ROWSELECT = 2,
896 ROWCHANGE = 4,
897 COLCHANGE = 8
898 };
899
900 public:
902 {
903 CLEAN = 0,
905 CURRENTNEW = 2,
907 NEW = 4,
909 PRIMARYKEY = 6,
910 CURRENT_PRIMARYKEY = 7,
911 FILTER = 8,
912 HEADERFOOTER = 9
913 };
914
915 private:
916 EditBrowseBox(EditBrowseBox const &) = delete;
918
920 {
921 std::unique_ptr<BrowserMouseEvent> pEvent;
922 bool bDown;
923
924 public:
926 : bDown(false)
927 {
928 }
929
930 bool Is() const {return pEvent != nullptr;}
931 bool IsDown() const {return bDown;}
932 const BrowserMouseEvent* operator->() const {return pEvent.get();}
933
934 SVT_DLLPUBLIC void Clear();
935 void Set(const BrowserMouseEvent* pEvt, bool bIsDown);
936 } aMouseEvent;
937
940
941 ImplSVEvent * nStartEvent, * nEndEvent, * nCellModifiedEvent; // event ids
943 // In ActivateCell, we grab the focus asynchronously, but if between requesting activation
944 // and the asynchronous event the focus has changed, we won't grab it for ourself.
945
946 sal_Int32 nPaintRow; // row being painted
947 sal_Int32 nEditRow;
948 sal_uInt16 nEditCol;
949
950 bool bHasFocus : 1;
951 mutable bool bPaintStatus : 1; // paint a status (image) in the handle column
953
955
957 std::unique_ptr< EditBrowseBoxImpl> m_aImpl;
958
959 protected:
961
962 BrowserMouseEventPtr& getMouseEvent() { return aMouseEvent; }
963
964 protected:
965 BrowserHeader* GetHeaderBar() const {return pHeader;}
966
967 virtual VclPtr<BrowserHeader> CreateHeaderBar(BrowseBox* pParent) override;
968
969 // if you want to have an own header ...
970 virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent);
971
972 virtual void ColumnMoved(sal_uInt16 nId) override;
973 virtual void ColumnResized(sal_uInt16 nColId) override;
974 virtual void Resize() override;
975 virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY);
976 virtual bool SeekRow(sal_Int32 nRow) override;
977
978 virtual void GetFocus() override;
979 virtual void LoseFocus() override;
980 virtual void KeyInput(const KeyEvent& rEvt) override;
981 virtual void MouseButtonDown(const BrowserMouseEvent& rEvt) override;
982 virtual void MouseButtonUp(const BrowserMouseEvent& rEvt) override;
983 virtual void StateChanged( StateChangedType nType ) override;
984 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
985
988
989 virtual bool PreNotify(NotifyEvent& rNEvt ) override;
990 virtual bool EventNotify(NotifyEvent& rNEvt) override;
991
992 virtual void EndScroll() override;
993
994 // should be used instead of GetFieldRectPixel, 'cause this method here takes into account the borders
995 tools::Rectangle GetCellRect(sal_Int32 nRow, sal_uInt16 nColId, bool bRelToBrowser = true) const;
996 virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId);
997 sal_uInt32 GetAutoColumnWidth(sal_uInt16 nColId);
998
999 virtual void PaintStatusCell(OutputDevice& rDev, const tools::Rectangle& rRect) const;
1000 virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColId) const = 0;
1001
1002 virtual RowStatus GetRowStatus(sal_Int32 nRow) const;
1003
1004 virtual void RowHeightChanged() override;
1005
1006 // callbacks for the data window
1007 virtual void ImplStartTracking() override;
1008 virtual void ImplEndTracking() override;
1009
1010 // when changing a row:
1011 // CursorMoving: cursor is being moved, but GetCurRow() still provides the old row
1012 virtual bool CursorMoving(sal_Int32 nNewRow, sal_uInt16 nNewCol);
1013
1014 // cursor has been moved
1015 virtual void CursorMoved() override;
1016
1017 virtual void CellModified(); // called whenever a cell has been modified
1018 virtual bool SaveModified(); // called whenever a cell should be left, and it's content should be saved
1019 // return sal_False prevents leaving the cell
1020 virtual bool SaveRow(); // commit the current row
1021
1022 virtual bool IsModified() const {return aController.is() && aController->IsValueChangedFromSaved();}
1023
1024 virtual CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol);
1025 virtual void InitController(CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol);
1026 static void ResizeController(CellControllerRef const & rController, const tools::Rectangle&);
1027 virtual void DoubleClick(const BrowserMouseEvent&) override;
1028
1029 void ActivateCell() { ActivateCell(GetCurRow(), GetCurColumnId()); }
1030
1031 // retrieve the image for the row status
1032 Image GetImage(RowStatus) const;
1033
1034 // inserting columns
1035 // if you don't set a width, this will be calculated automatically
1036 // if the id isn't set the smallest unused will do it ...
1037 virtual sal_uInt16 AppendColumn(const OUString& rName, sal_uInt16 nWidth, sal_uInt16 nPos = HEADERBAR_APPEND, sal_uInt16 nId = sal_uInt16(-1));
1038
1039 // called whenever (Shift)Tab or Enter is pressed. If true is returned, these keys
1040 // result in traveling to the next or to th previous cell
1041 virtual bool IsTabAllowed(bool bForward) const;
1042
1043 virtual bool IsCursorMoveAllowed(sal_Int32 nNewRow, sal_uInt16 nNewColId) const override;
1044
1045 void PaintTristate(const tools::Rectangle& rRect, const TriState& eState, bool _bEnabled=true) const;
1046
1047 void AsynchGetFocus();
1048 // secure starting of StartEditHdl
1049
1050 public:
1051 EditBrowseBox(vcl::Window* pParent, EditBrowseBoxFlags nBrowserFlags, WinBits nBits, BrowserMode nMode = BrowserMode::NONE );
1052 virtual ~EditBrowseBox() override;
1053 virtual void dispose() override;
1054
1055 bool IsEditing() const {return aController.is();}
1056 void InvalidateStatusCell(sal_Int32 nRow) {RowModified(nRow, 0);}
1057 void InvalidateHandleColumn();
1058
1059 // late construction
1060 virtual void Init();
1061 virtual void RemoveRows();
1062 virtual void Dispatch(sal_uInt16 nId);
1063
1064 const CellControllerRef& Controller() const { return aController; }
1065 EditBrowseBoxFlags GetBrowserFlags() const { return m_nBrowserFlags; }
1066 void SetBrowserFlags(EditBrowseBoxFlags nFlags);
1067
1068 virtual void ActivateCell(sal_Int32 nRow, sal_uInt16 nCol, bool bSetCellFocus = true);
1069 virtual void DeactivateCell(bool bUpdate = true);
1070 // Children ---------------------------------------------------------------
1071
1073 virtual sal_Int32 GetAccessibleControlCount() const override;
1074
1080 virtual css::uno::Reference< css::accessibility::XAccessible >
1081 CreateAccessibleControl( sal_Int32 nIndex ) override;
1082
1084 virtual void GrabTableFocus() override;
1085
1086 virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override;
1087 virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
1088
1089 virtual bool ProcessKey(const KeyEvent& rEvt) override;
1090
1091 virtual void ChildFocusIn() override;
1092 virtual void ChildFocusOut() override;
1093
1094 css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCheckBoxCell(sal_Int32 _nRow, sal_uInt16 _nColumnPos,const TriState& eState);
1095 bool ControlHasFocus() const;
1096 protected:
1097 // creates the accessible which wraps the active cell
1098 void implCreateActiveAccessible( );
1099
1100 private:
1101 virtual void PaintField(vcl::RenderContext& rDev, const tools::Rectangle& rRect,
1102 sal_uInt16 nColumnId ) const override;
1104 SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
1105 SVT_DLLPRIVATE void DetermineFocus( const GetFocusFlags _nGetFocusFlags = GetFocusFlags::NONE);
1106 inline void EnableAndShow() const;
1107
1108 SVT_DLLPRIVATE void implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, bool _bUp);
1109
1111 DECL_DLLPRIVATE_LINK( StartEditHdl, void*, void );
1112 DECL_DLLPRIVATE_LINK( EndEditHdl, void*, void );
1113 DECL_DLLPRIVATE_LINK( CellModifiedHdl, void*, void );
1114 };
1115
1116
1117} // namespace svt
1118
1119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const short NEW
std::unique_ptr< weld::Image > m_xWidget
BrowserMode
Definition: brwbox.hxx:59
virtual void MouseButtonDown(const MouseEvent &rEvt) override
Definition: brwbox2.cxx:1322
virtual void MouseButtonUp(const MouseEvent &rEvt) override
Definition: brwbox2.cxx:1426
void ImplInitSettings()
tools::Long Min() const
tools::Long Max() const
ControlBase & GetWindow() const
virtual bool IsValueChangedFromSaved() const =0
Link< LinkParamNone *, void > maModifyHdl
bool isSuspended() const
virtual void SaveValue()=0
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
virtual void callModifyHdl()
VclPtr< ControlBase > pWindow
DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone *, void)
weld::TriStateEnabled m_aModeState
Link< LinkParamNone *, void > m_aModify2Hdl
TriState GetState() const
Link< LinkParamNone *, void > m_aModify1Hdl
void SetAuxModifyHdl(const Link< LinkParamNone *, void > &rLink)
weld::CheckButton & GetBox()
Link< weld::CheckButton &, void > m_aToggleLink
DECL_DLLPRIVATE_LINK(OnToggle, weld::Toggleable &, void)
std::unique_ptr< weld::CheckButton > m_xBox
void SetToggleHdl(const Link< weld::CheckButton &, void > &rHdl)
void SetModifyHdl(const Link< LinkParamNone *, void > &rHdl)
weld::ComboBox & GetComboBox() const
DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone *, void)
Link< bool, void > m_aModify2Hdl
virtual void SetEditableReadOnly(bool bReadOnly) override
DECL_DLLPRIVATE_LINK(SelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > m_xWidget
Link< LinkParamNone *, void > m_aModify1Hdl
void SetAuxModifyHdl(const Link< bool, void > &rLink)
void SetModifyHdl(const Link< LinkParamNone *, void > &rHdl)
weld::ComboBox & get_widget()
Link< const KeyEvent &, void > m_aKeyInputHdl
DECL_DLLPRIVATE_LINK(MouseReleaseHdl, const MouseEvent &, bool)
void SetMouseReleaseHdl(const Link< const MouseEvent &, void > &rHdl)
DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget &, void)
DECL_DLLPRIVATE_LINK(MousePressHdl, const MouseEvent &, bool)
Link< const MouseEvent &, void > m_aMouseReleaseHdl
void SetMouseMoveHdl(const Link< const MouseEvent &, void > &rHdl)
void SetFocusOutHdl(const Link< LinkParamNone *, void > &rHdl)
Link< LinkParamNone *, void > m_aFocusInHdl
Link< LinkParamNone *, void > m_aFocusOutHdl
void SetKeyReleaseHdl(const Link< const KeyEvent &, void > &rHdl)
Link< const KeyEvent &, void > m_aKeyReleaseHdl
DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent &, bool)
virtual void SetPointFont(const vcl::Font &rFont)=0
DECL_DLLPRIVATE_LINK(KeyReleaseHdl, const KeyEvent &, bool)
DECL_DLLPRIVATE_LINK(MouseMoveHdl, const MouseEvent &, bool)
void SetKeyInputHdl(const Link< const KeyEvent &, void > &rHdl)
DECL_DLLPRIVATE_LINK(FocusInHdl, weld::Widget &, void)
Link< const MouseEvent &, void > m_aMouseMoveHdl
void SetMousePressHdl(const Link< const MouseEvent &, void > &rHdl)
void SetFocusInHdl(const Link< LinkParamNone *, void > &rHdl)
Link< const MouseEvent &, void > m_aMousePressHdl
std::unique_ptr< weld::Builder > m_xCalendarBuilder
std::unique_ptr< weld::Widget > m_xTopLevel
std::unique_ptr< weld::MenuButton > m_xMenuButton
DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable &, void)
std::unique_ptr< weld::Button > m_xNoneBtn
DECL_DLLPRIVATE_LINK(ActivateHdl, weld::Calendar &, void)
std::unique_ptr< weld::Calendar > m_xCalendar
DECL_DLLPRIVATE_LINK(ImplClickHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xTodayBtn
std::unique_ptr< weld::Widget > m_xExtras
std::unique_ptr< BrowserMouseEvent > pEvent
const BrowserMouseEvent * operator->() const
VclPtr< CheckBoxControl > pCheckBoxPaint
EditBrowseBox(EditBrowseBox const &)=delete
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect, sal_uInt16 nColId) const =0
CellControllerRef aOldController
CellControllerRef aController
BrowserHeader * GetHeaderBar() const
std::unique_ptr< EditBrowseBoxImpl > m_aImpl
DECL_DLLPRIVATE_LINK(StartEditHdl, void *, void)
DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone *, void)
bool IsEditing() const
DECL_DLLPRIVATE_LINK(EndEditHdl, void *, void)
const CellControllerRef & Controller() const
BrowserMouseEventPtr & getMouseEvent()
EditBrowseBoxFlags GetBrowserFlags() const
void InvalidateStatusCell(sal_Int32 nRow)
EditBrowseBox & operator=(EditBrowseBox const &)=delete
ImplSVEvent * nCellModifiedEvent
EditBrowseBoxFlags m_nBrowserFlags
DECL_DLLPRIVATE_LINK(CellModifiedHdl, void *, void)
VclPtr< vcl::Window > m_pFocusWhileRequest
virtual bool IsModified() const
VclPtr< BrowserHeader > pHeader
EditBrowserHeader(BrowseBox *pParent, WinBits nWinBits=WB_BUTTONSTYLE)
IEditImplementation * m_pEditImplementation
IEditImplementation * GetEditImplementation()
const IEditImplementation * GetEditImplementation() const
DECL_LINK(ModifyHdl, LinkParamNone *, void)
virtual void SetEditableReadOnly(bool bReadOnly) override
virtual void connect_key_press(const Link< const KeyEvent &, bool > &rLink)=0
virtual void connect_focus_out(const Link< weld::Widget &, void > &rLink)=0
virtual void connect_focus_in(const Link< weld::Widget &, void > &rLink)=0
weld::Entry * m_pEntry
weld::Entry & get_widget()
virtual void SetPointFont(const vcl::Font &rFont) override
virtual void connect_changed(const Link< weld::Entry &, void > &rLink)=0
virtual void connect_focus_in(const Link< weld::Widget &, void > &rLink) override
virtual void connect_key_press(const Link< const KeyEvent &, bool > &rLink) override
virtual void connect_focus_out(const Link< weld::Widget &, void > &rLink) override
virtual void connect_changed(const Link< weld::Entry &, void > &rLink) override
std::unique_ptr< weld::Entry > m_xWidget
virtual void SetSelection(const Selection &rSelection) override
EntryImplementation(EditControlBase &rEdit)
DECL_LINK(ModifyHdl, weld::Entry &, void)
virtual bool IsValueChangedFromSaved() const override
virtual OUString GetText(LineEnd) const override
EditControlBase & m_rEdit
virtual void SetMaxTextLen(sal_Int32 nMaxLen) override
virtual bool CanDown() const override
virtual bool IsReadOnly() const override
virtual Selection GetSelection() const override
virtual ControlBase & GetControl() override
virtual OUString GetSelected(LineEnd) const override
virtual bool CanUp() const override
virtual void Paste() override
virtual sal_Int32 GetMaxTextLen() const override
virtual void Copy() override
virtual void SaveValue() override
virtual void SetText(const OUString &_rStr) override
virtual void Cut() override
virtual void SetReadOnly(bool bReadOnly) override
virtual void ReplaceSelected(const OUString &rStr) override
std::unique_ptr< weld::Entry > m_xEntry
std::unique_ptr< weld::EntryFormatter > m_xEntryFormatter
std::unique_ptr< weld::FormattedSpinButton > m_xSpinButton
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
virtual OUString GetText(LineEnd aSeparator) const =0
virtual void SetReadOnly(bool bReadOnly)=0
virtual void SetMaxTextLen(sal_Int32 _nMaxLen)=0
virtual void Cut()=0
virtual bool IsReadOnly() const =0
virtual void SetSelection(const Selection &_rSelection)=0
virtual bool IsValueChangedFromSaved() const =0
virtual void ReplaceSelected(const OUString &_rStr)=0
virtual ControlBase & GetControl()=0
virtual bool CanUp() const =0
virtual void Paste()=0
Link< LinkParamNone *, void > m_aModify2Hdl
virtual Selection GetSelection() const =0
void SetAuxModifyHdl(const Link< LinkParamNone *, void > &rLink)
virtual sal_Int32 GetMaxTextLen() const =0
virtual bool CanDown() const =0
virtual void SetText(const OUString &_rStr)=0
virtual void SaveValue()=0
virtual OUString GetSelected(LineEnd aSeparator) const =0
Link< LinkParamNone *, void > m_aModify1Hdl
virtual void Copy()=0
DECL_DLLPRIVATE_LINK(ListBoxSelectHdl, LinkParamNone *, void)
weld::ComboBox & GetListBox() const
std::unique_ptr< weld::ComboBox > m_xWidget
Link< LinkParamNone *, void > m_aModify1Hdl
weld::ComboBox & get_widget()
void SetModifyHdl(const Link< LinkParamNone *, void > &rHdl)
DECL_DLLPRIVATE_LINK(SelectHdl, weld::ComboBox &, void)
Link< bool, void > m_aModify2Hdl
void SetAuxModifyHdl(const Link< bool, void > &rLink)
virtual bool IsReadOnly() const override
virtual bool IsValueChangedFromSaved() const override
virtual bool CanUp() const override
virtual void SaveValue() override
virtual ControlBase & GetControl() override
virtual void Cut() override
virtual sal_Int32 GetMaxTextLen() const override
virtual void Copy() override
virtual void SetReadOnly(bool bReadOnly) override
virtual void SetSelection(const Selection &rSelection) override
virtual void Paste() override
virtual Selection GetSelection() const override
virtual void ReplaceSelected(const OUString &rStr) override
virtual void SetMaxTextLen(sal_Int32 nMaxLen) override
virtual bool CanDown() const override
virtual void SetText(const OUString &rStr) override
MultiLineEditImplementation(MultiLineTextCell &rEdit)
DECL_LINK(ModifyHdl, weld::TextView &, void)
a multi line edit which can be used in a cell of an EditBrowseBox
virtual void SetPointFont(const vcl::Font &rFont) override
virtual void SetEditableReadOnly(bool bReadOnly) override
weld::TextView & get_widget()
std::unique_ptr< weld::TextView > m_xWidget
void connect_changed(const Link< weld::TextView &, void > &rLink)
std::unique_ptr< weld::Entry > m_xWidget
weld::PatternFormatter & get_formatter()
std::unique_ptr< weld::PatternFormatter > m_xEntryFormatter
bool is() const
virtual bool get_editable() const=0
virtual void cut_clipboard()=0
virtual void set_max_length(int nChars)=0
virtual void select_region(int nStartPos, int nEndPos)=0
virtual void set_text(const OUString &rText)=0
void save_value()
virtual bool get_selection_bounds(int &rStartPos, int &rEndPos)=0
virtual void copy_clipboard()=0
virtual void replace_selection(const OUString &rText)=0
virtual void paste_clipboard()=0
virtual OUString get_text() const=0
bool get_value_changed_from_saved() const
virtual void set_text(const OUString &rText)=0
virtual void copy_clipboard()=0
virtual void paste_clipboard()=0
virtual bool can_move_cursor_with_up() const=0
virtual bool get_editable() const=0
virtual void set_max_length(int nChars)=0
virtual void replace_selection(const OUString &rText)=0
bool get_value_changed_from_saved() const
virtual bool get_selection_bounds(int &rStartPos, int &rEndPos)=0
virtual void cut_clipboard()=0
virtual void select_region(int nStartPos, int nEndPos)=0
virtual bool can_move_cursor_with_down() const=0
Link< ColorFieldControl &, void > maModifyHdl
void Init()
virtual std::shared_ptr< SfxDialogController > GetController() override
EditBrowseBoxFlags
@ ACTIVATE_ON_BUTTONDOWN
set this bit to activate the cell on a MouseButtonDown, not a MouseButtonUp event
@ SMART_TAB_TRAVEL
If this bit is set, tab traveling is somewhat modified If the control gets the focus because the use...
@ HANDLE_COLUMN_TEXT
if this bit is set and EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT is not set, the handle column is ...
@ NO_HANDLE_COLUMN_CONTENT
if this bit is not set, the handle column will be invalidated upon changing the row in the browse box...
bool bReadOnly
#define SELECTION_MAX
TriState
LineEnd
void Clear(EHistoryType eHistory)
NONE
DELETED
CURRENT
tools::SvRef< CellController > CellControllerRef
void dispose()
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
@ MouseButtonDown
#define SVT_DLLPUBLIC
Definition: svtdllapi.h:27
#define SVT_DLLPRIVATE
Definition: svtdllapi.h:29
GetFocusFlags
StateChangedType
sal_Int64 WinBits