1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_INC_SVDIBROW_HXX
21 #define INCLUDED_SVX_INC_SVDIBROW_HXX
23 #include <svtools/brwbox.hxx>
24 #include <vcl/edit.hxx>
25 #include <vcl/floatwin.hxx>
26 #include <vcl/idle.hxx>
31 class BrowserMouseEvent
;
33 class SdrItemBrowserControl final
: public BrowseBox
35 friend class ImpItemEdit
;
36 std::vector
<std::unique_ptr
<ImpItemListRow
>> aList
;
37 long nCurrentPaintRow
;
38 VclPtr
<Edit
> pEditControl
;
39 OUString aWNameMemorized
;
40 Link
<SdrItemBrowserControl
&,void> aEntryChangedHdl
;
41 Link
<SdrItemBrowserControl
&,void> aSetDirtyHdl
;
42 std::unique_ptr
<ImpItemListRow
> pCurrentChangeEntry
;
44 sal_uInt16 nLastWhich
;
45 bool bWhichesButNames
;
46 bool bDontHideIneffectiveItems
;
50 void ImpSetEntry(const ImpItemListRow
& rEntry
, std::size_t nEntryNum
);
52 void ImpRestoreWhich();
53 std::size_t GetCurrentPos() const;
54 bool BeginChangeEntry(std::size_t nPos
);
56 virtual long GetRowCount() const override
;
57 virtual bool SeekRow(long nRow
) override
;
58 virtual void PaintField(vcl::RenderContext
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
) const override
;
59 virtual void DoubleClick(const BrowserMouseEvent
&) override
;
60 virtual void KeyInput(const KeyEvent
& rEvt
) override
;
61 virtual void Select() override
;
62 void SetDirty(); // is called for example in mode switches
63 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
64 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
67 SdrItemBrowserControl(vcl::Window
* pParent
);
68 virtual ~SdrItemBrowserControl() override
;
69 virtual void dispose() override
;
71 void SetAttributes(const SfxItemSet
* pAttr
, const SfxItemSet
* p2ndSet
);
72 sal_uInt16
GetCurrentWhich() const;
73 void EndChangeEntry();
74 void BreakChangeEntry();
76 /** GetCellText returns the text at the given position
82 the text out of the cell
84 virtual OUString
GetCellText(long _nRow
, sal_uInt16 _nColId
) const override
;
86 const ImpItemListRow
* GetCurrentChangeEntry() const { return pCurrentChangeEntry
.get(); }
87 OUString
GetNewEntryValue() const { return pEditControl
->GetText(); }
88 void SetEntryChangedHdl(const Link
<SdrItemBrowserControl
&,void>& rLink
) { aEntryChangedHdl
=rLink
; }
89 void SetSetDirtyHdl(const Link
<SdrItemBrowserControl
&,void>& rLink
) { aSetDirtyHdl
=rLink
; }
94 class SdrItemBrowser
: public FloatingWindow
{
95 VclPtr
<SdrItemBrowserControl
> aBrowse
;
99 static vcl::Window
* ImpGetViewWin(SdrView
const & rView
);
100 DECL_LINK(IdleHdl
, Timer
*, void);
101 DECL_LINK(ChangedHdl
, SdrItemBrowserControl
&, void);
102 DECL_LINK(SetDirtyHdl
, SdrItemBrowserControl
&, void);
104 SdrItemBrowser(SdrView
& rView
);
105 virtual ~SdrItemBrowser() override
;
109 virtual void dispose() override
;
110 virtual void Resize() override
;
111 virtual void GetFocus() override
;
112 void SetAttributes(const SfxItemSet
* pAttr
, const SfxItemSet
* p2ndSet
) { aBrowse
->SetAttributes(pAttr
,p2ndSet
); }
113 SdrItemBrowserControl
*GetBrowserControl() { return aBrowse
.get(); }
116 #endif // INCLUDED_SVX_INC_SVDIBROW_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */