2019-03-04 11:31:24 -06:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2020-02-18 06:09:27 -06:00
|
|
|
#include <vcl/toolkit/svtabbx.hxx>
|
2019-10-29 08:01:57 -05:00
|
|
|
#include "svimpbox.hxx"
|
2019-03-04 11:31:24 -06:00
|
|
|
|
|
|
|
//the default NotifyStartDrag is weird to me, and defaults to enabling all
|
|
|
|
//possibilities when drag starts, while restricting it to some subset of
|
|
|
|
//the configured drag drop mode would make more sense to me, but I'm not
|
|
|
|
//going to change the baseclass
|
|
|
|
|
2019-11-27 10:53:47 -06:00
|
|
|
class LclHeaderTabListBox final : public SvHeaderTabListBox
|
2019-03-04 11:31:24 -06:00
|
|
|
{
|
2019-10-21 08:20:12 -05:00
|
|
|
private:
|
|
|
|
Link<SvTreeListEntry*, bool> m_aEditingEntryHdl;
|
|
|
|
Link<std::pair<SvTreeListEntry*, OUString>, bool> m_aEditedEntryHdl;
|
|
|
|
|
2019-03-04 11:31:24 -06:00
|
|
|
public:
|
|
|
|
LclHeaderTabListBox(vcl::Window* pParent, WinBits nWinStyle)
|
|
|
|
: SvHeaderTabListBox(pParent, nWinStyle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-10-21 08:20:12 -05:00
|
|
|
void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink)
|
|
|
|
{
|
|
|
|
m_aEditingEntryHdl = rLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink)
|
|
|
|
{
|
|
|
|
m_aEditedEntryHdl = rLink;
|
|
|
|
}
|
|
|
|
|
2019-03-04 11:31:24 -06:00
|
|
|
virtual DragDropMode NotifyStartDrag(TransferDataContainer&, SvTreeListEntry*) override
|
|
|
|
{
|
|
|
|
return GetDragDropMode();
|
|
|
|
}
|
2019-10-21 08:20:12 -05:00
|
|
|
|
|
|
|
virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override
|
|
|
|
{
|
|
|
|
return m_aEditingEntryHdl.Call(pEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
|
|
|
|
{
|
|
|
|
return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
|
|
|
|
}
|
2019-03-04 11:31:24 -06:00
|
|
|
};
|
|
|
|
|
2019-11-27 10:53:47 -06:00
|
|
|
class LclTabListBox final : public SvTabListBox
|
2019-03-04 11:31:24 -06:00
|
|
|
{
|
|
|
|
Link<SvTreeListBox*, void> m_aModelChangedHdl;
|
2019-11-29 04:21:11 -06:00
|
|
|
Link<SvTreeListBox*, bool> m_aStartDragHdl;
|
2019-04-29 07:13:23 -05:00
|
|
|
Link<SvTreeListBox*, void> m_aEndDragHdl;
|
2019-06-07 09:42:52 -05:00
|
|
|
Link<SvTreeListEntry*, bool> m_aEditingEntryHdl;
|
|
|
|
Link<std::pair<SvTreeListEntry*, OUString>, bool> m_aEditedEntryHdl;
|
2019-03-04 11:31:24 -06:00
|
|
|
|
|
|
|
public:
|
|
|
|
LclTabListBox(vcl::Window* pParent, WinBits nWinStyle)
|
|
|
|
: SvTabListBox(pParent, nWinStyle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetModelChangedHdl(const Link<SvTreeListBox*, void>& rLink) { m_aModelChangedHdl = rLink; }
|
2019-11-29 04:21:11 -06:00
|
|
|
void SetStartDragHdl(const Link<SvTreeListBox*, bool>& rLink) { m_aStartDragHdl = rLink; }
|
2019-04-29 07:13:23 -05:00
|
|
|
void SetEndDragHdl(const Link<SvTreeListBox*, void>& rLink) { m_aEndDragHdl = rLink; }
|
2019-06-07 09:42:52 -05:00
|
|
|
void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink)
|
|
|
|
{
|
|
|
|
m_aEditingEntryHdl = rLink;
|
|
|
|
}
|
|
|
|
void SetEditedEntryHdl(const Link<std::pair<SvTreeListEntry*, OUString>, bool>& rLink)
|
|
|
|
{
|
|
|
|
m_aEditedEntryHdl = rLink;
|
|
|
|
}
|
2019-03-04 11:31:24 -06:00
|
|
|
|
|
|
|
virtual DragDropMode NotifyStartDrag(TransferDataContainer&, SvTreeListEntry*) override
|
|
|
|
{
|
|
|
|
return GetDragDropMode();
|
|
|
|
}
|
|
|
|
|
2019-04-29 07:13:23 -05:00
|
|
|
virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override
|
|
|
|
{
|
2019-11-29 04:21:11 -06:00
|
|
|
if (m_aStartDragHdl.Call(this))
|
|
|
|
return;
|
2019-04-29 07:13:23 -05:00
|
|
|
SvTabListBox::StartDrag(nAction, rPosPixel);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DragFinished(sal_Int8 nDropAction) override
|
|
|
|
{
|
|
|
|
SvTabListBox::DragFinished(nDropAction);
|
2020-03-18 15:11:28 -05:00
|
|
|
m_aEndDragHdl.Call(this);
|
2019-04-29 07:13:23 -05:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:31:24 -06:00
|
|
|
virtual void ModelHasCleared() override
|
|
|
|
{
|
|
|
|
SvTabListBox::ModelHasCleared();
|
|
|
|
m_aModelChangedHdl.Call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ModelHasInserted(SvTreeListEntry* pEntry) override
|
|
|
|
{
|
|
|
|
SvTabListBox::ModelHasInserted(pEntry);
|
|
|
|
m_aModelChangedHdl.Call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override
|
|
|
|
{
|
|
|
|
SvTabListBox::ModelHasInsertedTree(pEntry);
|
|
|
|
m_aModelChangedHdl.Call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ModelHasMoved(SvTreeListEntry* pSource) override
|
|
|
|
{
|
|
|
|
SvTabListBox::ModelHasMoved(pSource);
|
|
|
|
m_aModelChangedHdl.Call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override
|
|
|
|
{
|
|
|
|
SvTabListBox::ModelHasRemoved(pEntry);
|
|
|
|
m_aModelChangedHdl.Call(this);
|
|
|
|
}
|
2019-04-29 07:13:23 -05:00
|
|
|
|
2020-05-26 10:37:48 -05:00
|
|
|
SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget)
|
2019-04-29 07:13:23 -05:00
|
|
|
{
|
2020-02-25 04:41:12 -06:00
|
|
|
SvTreeListEntry* pOldTargetEntry = pTargetEntry;
|
2020-06-17 10:47:15 -05:00
|
|
|
pTargetEntry = PosOverBody(rPos) ? pImpl->GetEntry(rPos) : nullptr;
|
2020-02-25 04:41:12 -06:00
|
|
|
if (pOldTargetEntry != pTargetEntry)
|
|
|
|
ImplShowTargetEmphasis(pOldTargetEntry, false);
|
2019-04-29 07:13:23 -05:00
|
|
|
|
|
|
|
// scroll
|
|
|
|
if (rPos.Y() < 12)
|
|
|
|
{
|
|
|
|
ImplShowTargetEmphasis(pTargetEntry, false);
|
|
|
|
ScrollOutputArea(+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Size aSize(pImpl->GetOutputSize());
|
|
|
|
if (rPos.Y() > aSize.Height() - 12)
|
|
|
|
{
|
|
|
|
ImplShowTargetEmphasis(pTargetEntry, false);
|
|
|
|
ScrollOutputArea(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 10:37:48 -05:00
|
|
|
if (pTargetEntry && bHighLightTarget)
|
2020-03-20 15:47:19 -05:00
|
|
|
ImplShowTargetEmphasis(pTargetEntry, true);
|
2019-04-29 07:13:23 -05:00
|
|
|
return pTargetEntry;
|
|
|
|
}
|
2019-06-07 09:42:52 -05:00
|
|
|
|
2020-05-26 10:37:48 -05:00
|
|
|
virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
|
|
|
|
{
|
|
|
|
return GetTargetAtPoint(rPos, true);
|
|
|
|
}
|
|
|
|
|
2019-06-07 09:42:52 -05:00
|
|
|
virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override
|
|
|
|
{
|
|
|
|
return m_aEditingEntryHdl.Call(pEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override
|
|
|
|
{
|
|
|
|
return m_aEditedEntryHdl.Call(std::pair<SvTreeListEntry*, OUString>(pEntry, rNewText));
|
|
|
|
}
|
2019-03-04 11:31:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|