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 
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 
19 {
20 private:
23 
24 public:
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 
53 class LclTabListBox final : public SvTabListBox
54 {
60 
61 public:
62  LclTabListBox(vcl::Window* pParent, WinBits nWinStyle)
63  : SvTabListBox(pParent, nWinStyle)
64  {
65  }
66 
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; }
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  {
97  m_aModelChangedHdl.Call(this);
98  }
99 
100  virtual void ModelHasInserted(SvTreeListEntry* pEntry) override
101  {
103  m_aModelChangedHdl.Call(this);
104  }
105 
106  virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override
107  {
109  m_aModelChangedHdl.Call(this);
110  }
111 
112  virtual void ModelHasMoved(SvTreeListEntry* pSource) override
113  {
115  m_aModelChangedHdl.Call(this);
116  }
117 
118  virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override
119  {
121  m_aModelChangedHdl.Call(this);
122  }
123 
124  SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget)
125  {
126  SvTreeListEntry* pOldTargetEntry = pTargetEntry;
127  pTargetEntry = PosOverBody(rPos) ? pImpl->GetEntry(rPos) : nullptr;
128  if (pOldTargetEntry != pTargetEntry)
129  ImplShowTargetEmphasis(pOldTargetEntry, false);
130 
131  // scroll
132  if (rPos.Y() < 12)
133  {
135  ScrollOutputArea(+1);
136  }
137  else
138  {
139  Size aSize(pImpl->GetOutputSize());
140  if (rPos.Y() > aSize.Height() - 12)
141  {
143  ScrollOutputArea(-1);
144  }
145  }
146 
147  if (pTargetEntry && bHighLightTarget)
149  return pTargetEntry;
150  }
151 
152  virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
153  {
154  return GetTargetAtPoint(rPos, true);
155  }
156 
157  virtual bool EditingEntry(SvTreeListEntry* pEntry) override
158  {
159  return m_aEditingEntryHdl.Call(pEntry);
160  }
161 
162  virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
163  {
164  return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
165  }
166 };
167 
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
virtual void DragFinished(sal_Int8 nDropAction)
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
void SetStartDragHdl(const Link< SvTreeListBox *, bool > &rLink)
Definition: treeglue.hxx:68
signed char sal_Int8
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:58
virtual DragDropMode NotifyStartDrag() override
Definition: treeglue.hxx:40
Link< SvTreeListBox *, bool > m_aStartDragHdl
Definition: treeglue.hxx:56
Link< SvTreeListBox *, void > m_aEndDragHdl
Definition: treeglue.hxx:57
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
SvTreeListEntry * GetTargetAtPoint(const Point &rPos, bool bHighLightTarget)
Definition: treeglue.hxx:124
virtual SvTreeListEntry * GetDropTarget(const Point &rPos) override
Definition: treeglue.hxx:152
sal_Int64 WinBits
void ScrollOutputArea(short nDeltaEntries)
DragDropMode
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:47
VCL_DLLPRIVATE bool PosOverBody(const Point &rPos) const
SvTreeListEntry * pTargetEntry
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:70
LclTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:62
Link< SvTreeListBox *, void > m_aModelChangedHdl
Definition: treeglue.hxx:55
void SetEditedEntryHdl(const Link< std::pair< SvTreeListEntry *, OUString >, bool > &rLink)
Definition: treeglue.hxx:74
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:21
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:106
std::unique_ptr< SvImpLBox > pImpl
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
virtual DragDropMode NotifyStartDrag() override
Definition: treeglue.hxx:79
DragDropMode GetDragDropMode() const
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
Definition: treeglue.hxx:112
void SetEndDragHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:69
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:162
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:100
virtual void ModelHasCleared() override
virtual bool EditingEntry(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:157
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: treeglue.hxx:88
Link< std::pair< SvTreeListEntry *, OUString >, bool > m_aEditedEntryHdl
Definition: treeglue.hxx:59
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:30
virtual bool EditingEntry(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:42
virtual void ModelHasCleared() override
Definition: treeglue.hxx:94
void SetModelChangedHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:67
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
void ImplShowTargetEmphasis(SvTreeListEntry *pEntry, bool bShow)
Link< std::pair< SvTreeListEntry *, OUString >, bool > m_aEditedEntryHdl
Definition: treeglue.hxx:22
void SetEditedEntryHdl(const Link< std::pair< SvTreeListEntry *, OUString >, bool > &rLink)
Definition: treeglue.hxx:35
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: treeglue.hxx:81
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:118
LclHeaderTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:25