1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <vcl/toolkit/svtabbx.hxx>
11 #include "svimpbox.hxx"
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
18 class LclHeaderTabListBox final
: public SvHeaderTabListBox
21 Link
<SvTreeListEntry
*, bool> m_aEditingEntryHdl
;
22 Link
<std::pair
<SvTreeListEntry
*, OUString
>, bool> m_aEditedEntryHdl
;
25 LclHeaderTabListBox(vcl::Window
* pParent
, WinBits nWinStyle
)
26 : SvHeaderTabListBox(pParent
, nWinStyle
)
30 void SetEditingEntryHdl(const Link
<SvTreeListEntry
*, bool>& rLink
)
32 m_aEditingEntryHdl
= rLink
;
35 void SetEditedEntryHdl(const Link
<std::pair
<SvTreeListEntry
*, OUString
>, bool>& rLink
)
37 m_aEditedEntryHdl
= rLink
;
40 virtual DragDropMode
NotifyStartDrag() override
{ return GetDragDropMode(); }
42 virtual bool EditingEntry(SvTreeListEntry
* pEntry
) override
44 return m_aEditingEntryHdl
.Call(pEntry
);
47 virtual bool EditedEntry(SvTreeListEntry
* pEntry
, const OUString
& rNewText
) override
49 return m_aEditedEntryHdl
.Call(std::pair
<SvTreeListEntry
*, OUString
>(pEntry
, rNewText
));
53 class LclTabListBox final
: public SvTabListBox
55 Link
<SvTreeListBox
*, void> m_aModelChangedHdl
;
56 Link
<SvTreeListBox
*, bool> m_aStartDragHdl
;
57 Link
<SvTreeListBox
*, void> m_aEndDragHdl
;
58 Link
<SvTreeListEntry
*, bool> m_aEditingEntryHdl
;
59 Link
<std::pair
<SvTreeListEntry
*, OUString
>, bool> m_aEditedEntryHdl
;
62 LclTabListBox(vcl::Window
* pParent
, WinBits nWinStyle
)
63 : SvTabListBox(pParent
, nWinStyle
)
67 void SetModelChangedHdl(const Link
<SvTreeListBox
*, void>& rLink
) { m_aModelChangedHdl
= rLink
; }
68 void SetStartDragHdl(const Link
<SvTreeListBox
*, bool>& rLink
) { m_aStartDragHdl
= rLink
; }
69 void SetEndDragHdl(const Link
<SvTreeListBox
*, void>& rLink
) { m_aEndDragHdl
= rLink
; }
70 void SetEditingEntryHdl(const Link
<SvTreeListEntry
*, bool>& rLink
)
72 m_aEditingEntryHdl
= rLink
;
74 void SetEditedEntryHdl(const Link
<std::pair
<SvTreeListEntry
*, OUString
>, bool>& rLink
)
76 m_aEditedEntryHdl
= rLink
;
79 virtual DragDropMode
NotifyStartDrag() override
{ return GetDragDropMode(); }
81 virtual void StartDrag(sal_Int8 nAction
, const Point
& rPosPixel
) override
83 if (m_aStartDragHdl
.Call(this))
85 SvTabListBox::StartDrag(nAction
, rPosPixel
);
88 virtual void DragFinished(sal_Int8 nDropAction
) override
90 SvTabListBox::DragFinished(nDropAction
);
91 m_aEndDragHdl
.Call(this);
94 virtual void ModelHasCleared() override
96 SvTabListBox::ModelHasCleared();
97 m_aModelChangedHdl
.Call(this);
100 virtual void ModelHasInserted(SvTreeListEntry
* pEntry
) override
102 SvTabListBox::ModelHasInserted(pEntry
);
103 m_aModelChangedHdl
.Call(this);
106 virtual void ModelHasInsertedTree(SvTreeListEntry
* pEntry
) override
108 SvTabListBox::ModelHasInsertedTree(pEntry
);
109 m_aModelChangedHdl
.Call(this);
112 virtual void ModelHasMoved(SvTreeListEntry
* pSource
) override
114 SvTabListBox::ModelHasMoved(pSource
);
115 m_aModelChangedHdl
.Call(this);
118 virtual void ModelHasRemoved(SvTreeListEntry
* pEntry
) override
120 SvTabListBox::ModelHasRemoved(pEntry
);
121 m_aModelChangedHdl
.Call(this);
124 SvTreeListEntry
* GetTargetAtPoint(const Point
& rPos
, bool bHighLightTarget
)
126 SvTreeListEntry
* pOldTargetEntry
= pTargetEntry
;
127 pTargetEntry
= PosOverBody(rPos
) ? pImpl
->GetEntry(rPos
) : nullptr;
128 if (pOldTargetEntry
!= pTargetEntry
)
129 ImplShowTargetEmphasis(pOldTargetEntry
, false);
134 ImplShowTargetEmphasis(pTargetEntry
, false);
135 ScrollOutputArea(+1);
139 Size
aSize(pImpl
->GetOutputSize());
140 if (rPos
.Y() > aSize
.Height() - 12)
142 ImplShowTargetEmphasis(pTargetEntry
, false);
143 ScrollOutputArea(-1);
147 if (pTargetEntry
&& bHighLightTarget
)
148 ImplShowTargetEmphasis(pTargetEntry
, true);
152 virtual SvTreeListEntry
* GetDropTarget(const Point
& rPos
) override
154 return GetTargetAtPoint(rPos
, true);
157 virtual bool EditingEntry(SvTreeListEntry
* pEntry
) override
159 return m_aEditingEntryHdl
.Call(pEntry
);
162 virtual bool EditedEntry(SvTreeListEntry
* pEntry
, const OUString
& rNewText
) override
164 return m_aEditedEntryHdl
.Call(std::pair
<SvTreeListEntry
*, OUString
>(pEntry
, rNewText
));
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */