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/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 
41  {
42  return GetDragDropMode();
43  }
44 
45  virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override
46  {
47  return m_aEditingEntryHdl.Call(pEntry);
48  }
49 
50  virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
51  {
52  return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
53  }
54 };
55 
56 class LclTabListBox final : public SvTabListBox
57 {
63 
64 public:
65  LclTabListBox(vcl::Window* pParent, WinBits nWinStyle)
66  : SvTabListBox(pParent, nWinStyle)
67  {
68  }
69 
70  void SetModelChangedHdl(const Link<SvTreeListBox*, void>& rLink) { m_aModelChangedHdl = rLink; }
71  void SetStartDragHdl(const Link<SvTreeListBox*, bool>& rLink) { m_aStartDragHdl = rLink; }
72  void SetEndDragHdl(const Link<SvTreeListBox*, void>& rLink) { m_aEndDragHdl = rLink; }
74  {
75  m_aEditingEntryHdl = rLink;
76  }
77  void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink)
78  {
79  m_aEditedEntryHdl = rLink;
80  }
81 
83  {
84  return GetDragDropMode();
85  }
86 
87  virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override
88  {
89  if (m_aStartDragHdl.Call(this))
90  return;
91  SvTabListBox::StartDrag(nAction, rPosPixel);
92  }
93 
94  virtual void DragFinished(sal_Int8 nDropAction) override
95  {
96  m_aEndDragHdl.Call(this);
97  SvTabListBox::DragFinished(nDropAction);
98  }
99 
100  virtual void ModelHasCleared() override
101  {
103  m_aModelChangedHdl.Call(this);
104  }
105 
106  virtual void ModelHasInserted(SvTreeListEntry* pEntry) override
107  {
109  m_aModelChangedHdl.Call(this);
110  }
111 
112  virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override
113  {
115  m_aModelChangedHdl.Call(this);
116  }
117 
118  virtual void ModelHasMoved(SvTreeListEntry* pSource) override
119  {
121  m_aModelChangedHdl.Call(this);
122  }
123 
124  virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override
125  {
127  m_aModelChangedHdl.Call(this);
128  }
129 
130  virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
131  {
132  pTargetEntry = pImpl->GetEntry(rPos);
133 
134  // scroll
135  if (rPos.Y() < 12)
136  {
138  ScrollOutputArea(+1);
139  }
140  else
141  {
142  Size aSize(pImpl->GetOutputSize());
143  if (rPos.Y() > aSize.Height() - 12)
144  {
146  ScrollOutputArea(-1);
147  }
148  }
149 
150  return pTargetEntry;
151  }
152 
153  virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override
154  {
155  return m_aEditingEntryHdl.Call(pEntry);
156  }
157 
158  virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
159  {
160  return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
161  }
162 };
163 
164 /* 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:71
signed char sal_Int8
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:61
Link< SvTreeListBox *, bool > m_aStartDragHdl
Definition: treeglue.hxx:59
Link< SvTreeListBox *, void > m_aEndDragHdl
Definition: treeglue.hxx:60
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
virtual SvTreeListEntry * GetDropTarget(const Point &rPos) override
Definition: treeglue.hxx:130
sal_Int64 WinBits
virtual DragDropMode NotifyStartDrag(TransferDataContainer &, SvTreeListEntry *) override
Definition: treeglue.hxx:82
void ScrollOutputArea(short nDeltaEntries)
DragDropMode
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:50
virtual bool EditingEntry(SvTreeListEntry *pEntry, Selection &) override
Definition: treeglue.hxx:45
SvTreeListEntry * pTargetEntry
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:73
LclTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:65
Link< SvTreeListBox *, void > m_aModelChangedHdl
Definition: treeglue.hxx:58
void SetEditedEntryHdl(const Link< std::pair< SvTreeListEntry *, OUString >, bool > &rLink)
Definition: treeglue.hxx:77
Link< SvTreeListEntry *, bool > m_aEditingEntryHdl
Definition: treeglue.hxx:21
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:112
std::unique_ptr< SvImpLBox > pImpl
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
DragDropMode GetDragDropMode() const
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
Definition: treeglue.hxx:118
void SetEndDragHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:72
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText) override
Definition: treeglue.hxx:158
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:106
virtual void ModelHasCleared() override
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: treeglue.hxx:94
Link< std::pair< SvTreeListEntry *, OUString >, bool > m_aEditedEntryHdl
Definition: treeglue.hxx:62
void SetEditingEntryHdl(const Link< SvTreeListEntry *, bool > &rLink)
Definition: treeglue.hxx:30
virtual void ModelHasCleared() override
Definition: treeglue.hxx:100
virtual DragDropMode NotifyStartDrag(TransferDataContainer &, SvTreeListEntry *) override
Definition: treeglue.hxx:40
virtual bool EditingEntry(SvTreeListEntry *pEntry, Selection &) override
Definition: treeglue.hxx:153
void SetModelChangedHdl(const Link< SvTreeListBox *, void > &rLink)
Definition: treeglue.hxx:70
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:87
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
Definition: treeglue.hxx:124
long Y() const
LclHeaderTabListBox(vcl::Window *pParent, WinBits nWinStyle)
Definition: treeglue.hxx:25