/src/libreoffice/vcl/inc/treeglue.hxx
Line | Count | Source |
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 | | |
10 | | #include <vcl/toolkit/svtabbx.hxx> |
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 | | |
18 | | class LclTabListBox final : public SvTabListBox |
19 | | { |
20 | | Link<SvTreeListBox*, void> m_aModelChangedHdl; |
21 | | Link<SvTreeListBox*, bool> m_aStartDragHdl; |
22 | | Link<SvTreeListBox*, void> m_aEndDragHdl; |
23 | | Link<SvTreeListEntry*, bool> m_aEditingEntryHdl; |
24 | | Link<const IterString&, bool> m_aEditedEntryHdl; |
25 | | |
26 | | public: |
27 | | LclTabListBox(vcl::Window* pParent, WinBits nWinStyle) |
28 | 0 | : SvTabListBox(pParent, nWinStyle) |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | 0 | void SetModelChangedHdl(const Link<SvTreeListBox*, void>& rLink) { m_aModelChangedHdl = rLink; } |
33 | 0 | void SetStartDragHdl(const Link<SvTreeListBox*, bool>& rLink) { m_aStartDragHdl = rLink; } |
34 | 0 | void SetEndDragHdl(const Link<SvTreeListBox*, void>& rLink) { m_aEndDragHdl = rLink; } |
35 | | void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink) |
36 | 0 | { |
37 | 0 | m_aEditingEntryHdl = rLink; |
38 | 0 | } |
39 | | void SetEditedEntryHdl(const Link<const IterString&, bool>& rLink) |
40 | 0 | { |
41 | 0 | m_aEditedEntryHdl = rLink; |
42 | 0 | } |
43 | | |
44 | 0 | virtual DragDropMode NotifyStartDrag() override { return GetDragDropMode(); } |
45 | | |
46 | | virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override |
47 | 0 | { |
48 | 0 | if (m_aStartDragHdl.Call(this)) |
49 | 0 | return; |
50 | 0 | SvTabListBox::StartDrag(nAction, rPosPixel); |
51 | 0 | } |
52 | | |
53 | | virtual void DragFinished(sal_Int8 nDropAction) override |
54 | 0 | { |
55 | 0 | SvTabListBox::DragFinished(nDropAction); |
56 | 0 | m_aEndDragHdl.Call(this); |
57 | 0 | } |
58 | | |
59 | | virtual void ModelHasCleared() override |
60 | 0 | { |
61 | 0 | SvTabListBox::ModelHasCleared(); |
62 | 0 | m_aModelChangedHdl.Call(this); |
63 | 0 | } |
64 | | |
65 | | virtual void ModelHasInserted(SvTreeListEntry* pEntry) override |
66 | 0 | { |
67 | 0 | SvTabListBox::ModelHasInserted(pEntry); |
68 | 0 | m_aModelChangedHdl.Call(this); |
69 | 0 | } |
70 | | |
71 | | virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override |
72 | 0 | { |
73 | 0 | SvTabListBox::ModelHasInsertedTree(pEntry); |
74 | 0 | m_aModelChangedHdl.Call(this); |
75 | 0 | } |
76 | | |
77 | | virtual void ModelHasMoved(SvTreeListEntry* pSource) override |
78 | 0 | { |
79 | 0 | SvTabListBox::ModelHasMoved(pSource); |
80 | 0 | m_aModelChangedHdl.Call(this); |
81 | 0 | } |
82 | | |
83 | | virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override |
84 | 0 | { |
85 | 0 | SvTabListBox::ModelHasRemoved(pEntry); |
86 | 0 | m_aModelChangedHdl.Call(this); |
87 | 0 | } |
88 | | |
89 | | SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget, bool bScroll = true) |
90 | 0 | { |
91 | 0 | SvTreeListEntry* pOldTargetEntry = m_pTargetEntry; |
92 | 0 | m_pTargetEntry = PosOverBody(rPos) ? m_pImpl->GetEntry(rPos) : nullptr; |
93 | 0 | if (pOldTargetEntry != m_pTargetEntry) |
94 | 0 | ImplShowTargetEmphasis(pOldTargetEntry, false); |
95 | |
|
96 | 0 | if (bScroll) |
97 | 0 | { |
98 | | // scroll |
99 | 0 | if (rPos.Y() < 12) |
100 | 0 | { |
101 | 0 | ImplShowTargetEmphasis(m_pTargetEntry, false); |
102 | 0 | ScrollOutputArea(+1); |
103 | 0 | } |
104 | 0 | else |
105 | 0 | { |
106 | 0 | Size aSize(m_pImpl->GetOutputSize()); |
107 | 0 | if (rPos.Y() > aSize.Height() - 12) |
108 | 0 | { |
109 | 0 | ImplShowTargetEmphasis(m_pTargetEntry, false); |
110 | 0 | ScrollOutputArea(-1); |
111 | 0 | } |
112 | 0 | } |
113 | 0 | } |
114 | |
|
115 | 0 | if (m_pTargetEntry && bHighLightTarget) |
116 | 0 | ImplShowTargetEmphasis(m_pTargetEntry, true); |
117 | 0 | return m_pTargetEntry; |
118 | 0 | } |
119 | | |
120 | | virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override |
121 | 0 | { |
122 | 0 | return GetTargetAtPoint(rPos, true); |
123 | 0 | } |
124 | | |
125 | | virtual bool EditingEntry(SvTreeListEntry* pEntry) override |
126 | 0 | { |
127 | 0 | return m_aEditingEntryHdl.Call(pEntry); |
128 | 0 | } |
129 | | |
130 | | virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override |
131 | 0 | { |
132 | 0 | return m_aEditedEntryHdl.Call(IterString(pEntry, rNewText)); |
133 | 0 | } |
134 | | }; |
135 | | |
136 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |