LibreOffice Module vcl (master) 1
treeglue.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
11#include "svimpbox.hxx"
12
13//the default NotifyStartDrag is weird to me, and defaults to enabling all
14//possibilities when drag starts, while restricting it to some subset of
15//the configured drag drop mode would make more sense to me, but I'm not
16//going to change the baseclass
17
19{
20private:
23
24public:
26 : SvHeaderTabListBox(pParent, nWinStyle)
27 {
28 }
29
31 {
32 m_aEditingEntryHdl = rLink;
33 }
34
35 void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink)
36 {
37 m_aEditedEntryHdl = rLink;
38 }
39
40 virtual DragDropMode NotifyStartDrag() override { return GetDragDropMode(); }
41
42 virtual bool EditingEntry(SvTreeListEntry* pEntry) override
43 {
44 return m_aEditingEntryHdl.Call(pEntry);
45 }
46
47 virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
48 {
49 return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
50 }
51};
52
53class LclTabListBox final : public SvTabListBox
54{
60
61public:
62 LclTabListBox(vcl::Window* pParent, WinBits nWinStyle)
63 : SvTabListBox(pParent, nWinStyle)
64 {
65 }
66
71 {
72 m_aEditingEntryHdl = rLink;
73 }
74 void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink)
75 {
76 m_aEditedEntryHdl = rLink;
77 }
78
79 virtual DragDropMode NotifyStartDrag() override { return GetDragDropMode(); }
80
81 virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override
82 {
83 if (m_aStartDragHdl.Call(this))
84 return;
85 SvTabListBox::StartDrag(nAction, rPosPixel);
86 }
87
88 virtual void DragFinished(sal_Int8 nDropAction) override
89 {
90 SvTabListBox::DragFinished(nDropAction);
91 m_aEndDragHdl.Call(this);
92 }
93
94 virtual void ModelHasCleared() override
95 {
98 }
99
100 virtual void ModelHasInserted(SvTreeListEntry* pEntry) override
101 {
104 }
105
106 virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override
107 {
110 }
111
112 virtual void ModelHasMoved(SvTreeListEntry* pSource) override
113 {
116 }
117
118 virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override
119 {
122 }
123
124 SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget, bool bScroll = true)
125 {
126 SvTreeListEntry* pOldTargetEntry = pTargetEntry;
127 pTargetEntry = PosOverBody(rPos) ? pImpl->GetEntry(rPos) : nullptr;
128 if (pOldTargetEntry != pTargetEntry)
129 ImplShowTargetEmphasis(pOldTargetEntry, false);
130
131 if (bScroll)
132 {
133 // scroll
134 if (rPos.Y() < 12)
135 {
138 }
139 else
140 {
141 Size aSize(pImpl->GetOutputSize());
142 if (rPos.Y() > aSize.Height() - 12)
143 {
146 }
147 }
148 }
149
150 if (pTargetEntry && bHighLightTarget)
152 return pTargetEntry;
153 }
154
155 virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
156 {
157 return GetTargetAtPoint(rPos, true);
158 }
159
160 virtual bool EditingEntry(SvTreeListEntry* pEntry) override
161 {
162 return m_aEditingEntryHdl.Call(pEntry);
163 }
164
165 virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
166 {
167 return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
168 }
169};
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
void SetEditedEntryHdl(const Link< std::pair< SvTreeListEntry *, OUString >, bool > &rLink)
Definition: treeglue.hxx:35
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:30
virtual DragDropMode NotifyStartDrag() override
Definition: treeglue.hxx:40
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:47
virtual bool EditingEntry(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:42
LclHeaderTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:25
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:21
Link< std::pair< SvTreeListEntry *, OUString >, bool > m_aEditedEntryHdl
Definition: treeglue.hxx:22
virtual void ModelHasCleared() override
Definition: treeglue.hxx:94
Link< SvTreeListBox *, bool > m_aStartDragHdl
Definition: treeglue.hxx:56
void SetEndDragHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:69
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: treeglue.hxx:88
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
Definition: treeglue.hxx:112
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:106
virtual SvTreeListEntry * GetDropTarget(const Point &rPos) override
Definition: treeglue.hxx:155
SvTreeListEntry * GetTargetAtPoint(const Point &rPos, bool bHighLightTarget, bool bScroll=true)
Definition: treeglue.hxx:124
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:118
Link< std::pair< SvTreeListEntry *, OUString >, bool > m_aEditedEntryHdl
Definition: treeglue.hxx:59
void SetEditedEntryHdl(const Link< std::pair< SvTreeListEntry *, OUString >, bool > &rLink)
Definition: treeglue.hxx:74
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:70
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:58
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:100
LclTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:62
virtual bool EditingEntry(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:160
void SetStartDragHdl(const Link< SvTreeListBox *, bool > &rLink)
Definition: treeglue.hxx:68
virtual DragDropMode NotifyStartDrag() override
Definition: treeglue.hxx:79
Link< SvTreeListBox *, void > m_aEndDragHdl
Definition: treeglue.hxx:57
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: treeglue.hxx:81
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:165
void SetModelChangedHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:67
Link< SvTreeListBox *, void > m_aModelChangedHdl
Definition: treeglue.hxx:55
constexpr tools::Long Y() const
constexpr tools::Long Height() const
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
SvTreeListEntry * pTargetEntry
virtual void DragFinished(sal_Int8 nDropAction)
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
void ImplShowTargetEmphasis(SvTreeListEntry *pEntry, bool bShow)
VCL_DLLPRIVATE bool PosOverBody(const Point &rPos) const
DragDropMode GetDragDropMode() const
virtual void ModelHasCleared() override
void ScrollOutputArea(short nDeltaEntries)
std::unique_ptr< SvImpLBox > pImpl
DragDropMode
signed char sal_Int8
sal_Int64 WinBits
Definition: wintypes.hxx:109