LibreOffice Module vcl (master) 1
ivctrl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23#error "don't use this in new code"
24#endif
25
26#include <memory>
27#include <vcl/dllapi.h>
28#include <vcl/ctrl.hxx>
29#include <tools/link.hxx>
30#include <vcl/image.hxx>
31#include <o3tl/deleter.hxx>
33
35
37{
38 NONE = 0x0000,
39 POS_LOCKED = 0x0001,
40 SELECTED = 0x0002,
41 FOCUSED = 0x0004,
42 POS_MOVED = 0x0008, // Moved by Drag and Drop, but not logged
43};
44namespace o3tl
45{
46 template<> struct typed_flags<SvxIconViewFlags> : is_typed_flags<SvxIconViewFlags, 0x000f> {};
47}
48
50{
51 Full = 1, // Enlarge BoundRect southwards
52 Short // Shorten with "..."
53};
54
56{
57 Free, // Free pixel-perfect positioning
58 AutoArrange, // Auto arrange
59};
60
62{
64
65 OUString aText;
67
69 friend class IcnCursor_Impl;
70 friend class EntryList_Impl;
71 friend class IcnGridMap_Impl;
72
73 tools::Rectangle aRect; // Bounding-Rectangle of the entry
74 tools::Rectangle aGridRect; // Only valid in Grid-mode
75 sal_Int32 nPos;
76
77 /*
78 The insert position in the Insertlist is equal to the (sort) order stated at the Insert
79 (-> Order of the anchors in the anchors-list!). In "AutoArrange" mode the visible order
80 can differ. The entries will be linked because of this.
81 */
82 SvxIconChoiceCtrlEntry* pblink; // backward (linker neighbour)
83 SvxIconChoiceCtrlEntry* pflink; // forward (rechter neighbour)
84
86 sal_uInt16 nX,nY; // for keyboard control
88
89 void ClearFlags( SvxIconViewFlags nMask ) { nFlags &= ~nMask; }
90 void SetFlags( SvxIconViewFlags nMask ) { nFlags |= nMask; }
91 void AssignFlags( SvxIconViewFlags _nFlags ) { nFlags = _nFlags; }
92
93 // set left neighbour (A <-> B ==> A <-> this <-> B)
95 {
96 pA->pflink->pblink = this; // X <- B
97 this->pflink = pA->pflink; // X -> B
98 this->pblink = pA; // A <- X
99 pA->pflink = this; // A -> X
100 }
101 // Unlink (A <-> this <-> B ==> A <-> B)
102 void Unlink()
103 {
104 this->pblink->pflink = this->pflink;
105 this->pflink->pblink = this->pblink;
106 this->pflink = nullptr;
107 this->pblink = nullptr;
108 }
109
110public:
112
113 const Image& GetImage () const { return aImage; }
114 void SetText ( const OUString& rText ) { aText = rText; }
115 const OUString& GetText () const { return aText; }
116 OUString VCL_DLLPUBLIC GetDisplayText() const;
117 void SetQuickHelpText( const OUString& rText ) { aQuickHelpText = rText; }
118 const OUString& GetQuickHelpText() const { return aQuickHelpText; }
119
121 SvxIconViewFlags GetFlags() const { return nFlags; }
122 bool IsSelected() const { return bool(nFlags & SvxIconViewFlags::SELECTED); }
123 bool IsFocused() const { return bool(nFlags & SvxIconViewFlags::FOCUSED); }
124 bool IsPosLocked() const { return bool(nFlags & SvxIconViewFlags::POS_LOCKED); }
125};
126
128{
130
131public:
133 nWidth( 100 ) {}
135
136 void SetWidth( tools::Long nWd ) { nWidth = nWd; }
137 tools::Long GetWidth() const { return nWidth; }
138};
139
140
141/*
142 Window-Bits:
143 WB_ICON // Text beneath the icon
144 WB_SMALL_ICON // Text right to the icon, position does not mind
145 WB_DETAILS // Text right to the icon, limited positioning
146 WB_BORDER
147 WB_NOHIDESELECTION // Draw selection inactively, if not focused.
148 WB_NOHSCROLL
149 WB_NOVSCROLL
150 WB_NOSELECTION
151 WB_SMART_ARRANGE // Keep Visible-Area at arrange
152 WB_ALIGN_TOP // Align line vy line LTR
153 WB_ALIGN_LEFT // Align columns from top to bottom
154 WB_NODRAGSELECTION // No selection with tracking rectangle
155 WB_NOCOLUMNHEADER // No Headerbar in Details view (Headerbar not implemented)
156 WB_NOPOINTERFOCUS // No GrabFocus at MouseButtonDown
157 WB_HIGHLIGHTFRAME // The entry beneath the mouse will be highlighted
158 WB_NOASYNCSELECTHDL // Do not collect events -> Selection handlers will be called synchronously
159*/
160
161#define WB_ICON WB_RECTSTYLE
162#define WB_SMALLICON WB_SMALLSTYLE
163#define WB_DETAILS WB_VCENTER
164#define WB_NOHSCROLL WB_SPIN
165#define WB_NOVSCROLL WB_DRAG
166#define WB_NOSELECTION WB_REPEAT
167#define WB_NODRAGSELECTION WB_PATHELLIPSIS
168#define WB_SMART_ARRANGE 0x01000000 // used to be WB_PASSWORD
169#define WB_ALIGN_TOP WB_TOP
170#define WB_ALIGN_LEFT WB_LEFT
171#define WB_NOCOLUMNHEADER WB_CENTER
172#define WB_HIGHLIGHTFRAME WB_IGNORETAB
173#define WB_NOASYNCSELECTHDL WB_NOLABEL
174
176
178{
180
182 std::unique_ptr<SvxIconChoiceCtrl_Impl, o3tl::default_delete<SvxIconChoiceCtrl_Impl>> _pImpl;
183
184 virtual void KeyInput( const KeyEvent& rKEvt ) override;
185 virtual void Command( const CommandEvent& rCEvt ) override;
186 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
187 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
188 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
189 virtual void MouseMove( const MouseEvent& rMEvt ) override;
190 virtual void Resize() override;
191 virtual void GetFocus() override;
192 virtual void LoseFocus() override;
193 void ClickIcon();
194 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
195 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
196 static void DrawEntryImage(
197 SvxIconChoiceCtrlEntry const * pEntry,
198 const Point& rPos,
199 OutputDevice& rDev );
200
201 static OUString GetEntryText( SvxIconChoiceCtrlEntry const * pEntry );
202
203 virtual void FillLayoutData() const override;
204
205 void CallImplEventListeners(VclEventId nEvent, void* pData);
206
207public:
208
209 SvtIconChoiceCtrl( vcl::Window* pParent, WinBits nWinStyle );
210 virtual ~SvtIconChoiceCtrl() override;
211 virtual void dispose() override;
212
213 WinBits GetStyle() const;
215
216 void SetFont( const vcl::Font& rFont );
217 void SetPointFont( const vcl::Font& rFont );
218
219 void SetClickHdl( const Link<SvtIconChoiceCtrl*,void>& rLink ) { _aClickIconHdl = rLink; }
220
221 using Window::SetBackground;
222 void SetBackground( const Wallpaper& rWallpaper );
223
224 void ArrangeIcons();
225
226
227 SvxIconChoiceCtrlEntry* InsertEntry( const OUString& rText,
228 const Image& rImage);
229
230 void RemoveEntry(sal_Int32 nEntryListPos);
231
232 bool DoKeyInput( const KeyEvent& rKEvt );
233
234 sal_Int32 GetEntryCount() const;
235 SvxIconChoiceCtrlEntry* GetEntry( sal_Int32 nPos ) const;
236 sal_Int32 GetEntryListPos( SvxIconChoiceCtrlEntry const * pEntry ) const;
237 using Window::SetCursor;
238 void SetCursor( SvxIconChoiceCtrlEntry* pEntry );
240
241 // sal_uLong is the position of the selected element in the list
242 SvxIconChoiceCtrlEntry* GetSelectedEntry() const;
243
244#ifdef DBG_UTIL
246#endif
247
248 tools::Rectangle GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const;
249 tools::Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const;
250
251 void SetNoSelection();
252
253 // ACCESSIBILITY ==========================================================
254
256 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
257};
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: ctrl.hxx:82
virtual void FillLayoutData() const
Definition: ctrl.cxx:81
virtual void Resize() override
Definition: ctrl.cxx:75
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:59
Definition: image.hxx:40
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
std::unique_ptr< SvxIconChoiceCtrl_Impl, o3tl::default_delete< SvxIconChoiceCtrl_Impl > > _pImpl
Definition: ivctrl.hxx:182
Link< SvtIconChoiceCtrl *, void > _aClickIconHdl
Definition: ivctrl.hxx:181
void SetClickHdl(const Link< SvtIconChoiceCtrl *, void > &rLink)
Definition: ivctrl.hxx:219
void SetWidth(tools::Long nWd)
Definition: ivctrl.hxx:136
tools::Long GetWidth() const
Definition: ivctrl.hxx:137
void SetText(const OUString &rText)
Definition: ivctrl.hxx:114
void ClearFlags(SvxIconViewFlags nMask)
Definition: ivctrl.hxx:89
void SetBacklink(SvxIconChoiceCtrlEntry *pA)
Definition: ivctrl.hxx:94
bool IsSelected() const
Definition: ivctrl.hxx:122
const OUString & GetText() const
Definition: ivctrl.hxx:115
SvxIconViewFlags GetFlags() const
Definition: ivctrl.hxx:121
SvxIconChoiceCtrlEntry * pblink
Definition: ivctrl.hxx:82
SvxIconChoiceCtrlTextMode eTextMode
Definition: ivctrl.hxx:85
bool IsFocused() const
Definition: ivctrl.hxx:123
SvxIconViewFlags nFlags
Definition: ivctrl.hxx:87
OUString aQuickHelpText
Definition: ivctrl.hxx:66
const OUString & GetQuickHelpText() const
Definition: ivctrl.hxx:118
SvxIconChoiceCtrlTextMode GetTextMode() const
Definition: ivctrl.hxx:120
void AssignFlags(SvxIconViewFlags _nFlags)
Definition: ivctrl.hxx:91
friend class EntryList_Impl
Definition: ivctrl.hxx:70
bool IsPosLocked() const
Definition: ivctrl.hxx:124
const Image & GetImage() const
Definition: ivctrl.hxx:113
void SetQuickHelpText(const OUString &rText)
Definition: ivctrl.hxx:117
tools::Rectangle aRect
Definition: ivctrl.hxx:73
SvxIconChoiceCtrlEntry * pflink
Definition: ivctrl.hxx:83
OUString VCL_DLLPUBLIC GetDisplayText() const
Definition: ivctrl.cxx:71
void SetFlags(SvxIconViewFlags nMask)
Definition: ivctrl.hxx:90
SvxIconChoiceCtrlEntry(OUString aText, Image aImage)
Definition: ivctrl.cxx:57
tools::Rectangle aGridRect
Definition: ivctrl.hxx:74
void SetEntryTextMode(SvxIconChoiceCtrlTextMode, SvxIconChoiceCtrlEntry *pEntry)
Definition: imivctl1.cxx:2432
void RemoveEntry(size_t nPos)
Definition: imivctl1.cxx:224
size_t GetEntryCount() const
Definition: imivctl.hxx:385
void InsertEntry(std::unique_ptr< SvxIconChoiceCtrlEntry >, size_t nPos)
Definition: imivctl1.cxx:186
SvxIconChoiceCtrlEntry * GetEntry(const Point &rDocPos, bool bHit=false)
Definition: imivctl1.cxx:1516
void SetSelectionMode(SelectionMode eMode)
Definition: imivctl.hxx:259
sal_Int32 GetEntryListPos(SvxIconChoiceCtrlEntry const *) const
Definition: imivctl1.cxx:2598
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
virtual void GetFocus()
Definition: window.cxx:1843
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1871
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1925
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3018
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
vcl::Cursor * GetCursor() const
Definition: window2.cxx:1227
WinBits GetStyle() const
Definition: window2.cxx:977
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:427
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1807
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual void LoseFocus()
Definition: window.cxx:1857
void SetPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
Definition: window.cxx:2175
void SetBackground()
Definition: window3.cxx:100
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
SvxIconChoiceCtrlPositionMode
Definition: ivctrl.hxx:56
SvxIconViewFlags
Definition: ivctrl.hxx:37
SvxIconChoiceCtrlTextMode
Definition: ivctrl.hxx:50
NONE
long Long
SelectionMode
Definition: vclenum.hxx:26
VclEventId
Definition: vclevent.hxx:38
sal_Int64 WinBits
Definition: wintypes.hxx:109