LibreOffice Module vcl (master) 1
svlbitm.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 <tools/link.hxx>
29#include <vcl/image.hxx>
32
33class SvTreeListEntry;
34class SvLBoxButton;
35
36
37enum class SvBmp
38{
39 UNCHECKED = 0,
40 CHECKED = 1,
41 TRISTATE = 2,
42 HIUNCHECKED = 3,
43 HICHECKED = 4,
44 HITRISTATE = 5
45};
46
48{
49 NONE = 0x00,
50 UNCHECKED = 0x01,
51 CHECKED = 0x02,
52 TRISTATE = 0x04,
53 HIGHLIGHTED = 0x08
54};
55namespace o3tl
56{
57 template<> struct typed_flags<SvItemStateFlags> : is_typed_flags<SvItemStateFlags, 0x0f> {};
58}
59
61
63{
64private:
68 std::unique_ptr<SvLBoxButtonData_Impl> pImpl;
69 bool bDataOk;
70 std::vector<Image> aBmps; // indices s. constants BMP_...
71
72 void SetWidthAndHeight();
73 void InitData( bool _bRadioBtn, const Control* pControlForSettings );
74public:
75 // include creating default images (CheckBox or RadioButton)
76 SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn );
77
79
80 static SvBmp GetIndex( SvItemStateFlags nItemState );
83 void SetLink( const Link<SvLBoxButtonData*,void>& rLink) { aLink=rLink; }
84 bool IsRadio() const;
85 // as buttons are not derived from LinkHdl
86 void CallLink();
87
88 void StoreButtonState(SvTreeListEntry* pActEntry, SvLBoxButton* pActBox);
90
92 SvLBoxButton* GetActBox() const;
93
94 void SetImage(SvBmp nIndex, const Image& aImage) { aBmps[static_cast<int>(nIndex)] = aImage; }
95 Image& GetImage(SvBmp nIndex) { return aBmps[static_cast<int>(nIndex)]; }
96
97 void SetDefaultImages( const Control* pControlForSettings );
98 // set images according to the color scheme of the Control
99 // pControlForSettings == NULL: settings are taken from Application
100 bool HasDefaultImages() const;
101};
102
103// **********************************************************************
104
106{
107private:
110 double mfAlign;
111protected:
112 OUString maText;
113
114public:
115 SvLBoxString(OUString aText);
116 SvLBoxString();
117 virtual ~SvLBoxString() override;
118
119 virtual SvLBoxItemType GetType() const override;
120 virtual void InitViewData(SvTreeListBox* pView,
121 SvTreeListEntry* pEntry,
122 SvViewDataItem* pViewData = nullptr) override;
123
124 virtual int CalcWidth(const SvTreeListBox* pView) const override;
125
126 void Align(double fAlign) { mfAlign = fAlign; }
127
128 void Emphasize(bool bEmphasize) { mbEmphasized = bEmphasize; }
129 bool IsEmphasized() const { return mbEmphasized; }
130
131 void SetCustomRender() { mbCustom = true; }
132
133 const OUString& GetText() const
134 {
135 return maText;
136 }
137 void SetText(const OUString& rText)
138 {
139 maText = rText;
140 }
141
142 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev,
143 vcl::RenderContext& rRenderContext,
144 const SvViewDataEntry* pView,
145 const SvTreeListEntry& rEntry) override;
146
147 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override;
148};
149
150class SvLBoxButton final : public SvLBoxItem
151{
152 bool isVis;
155
156 static void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::RenderContext const & pRenderContext);
157public:
158 // An SvLBoxButton can be of two different kinds: an
159 // enabled checkbox (the normal kind), or a static image
160 // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored
161 // for that kind).
163 SvLBoxButton();
164 virtual ~SvLBoxButton() override;
165 virtual void InitViewData(SvTreeListBox* pView,
166 SvTreeListEntry* pEntry,
167 SvViewDataItem* pViewData = nullptr) override;
168
169 virtual SvLBoxItemType GetType() const override;
170 void ClickHdl( SvTreeListEntry* );
171
172 virtual void Paint(const Point& rPos,
173 SvTreeListBox& rOutDev,
174 vcl::RenderContext& rRenderContext,
175 const SvViewDataEntry* pView,
176 const SvTreeListEntry& rEntry) override;
177
178 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override;
179
181 {
182 return nItemFlags;
183 }
184 bool IsStateChecked() const
185 {
187 }
188 bool IsStateUnchecked() const
189 {
191 }
192 bool IsStateTristate() const
193 {
195 }
196 bool IsStateHilighted() const
197 {
199 }
200 void SetStateChecked();
201 void SetStateUnchecked();
202 void SetStateTristate();
203 void SetStateHilighted(bool bHilight);
204};
205
207{
210}
211
213{
216}
218{
221}
222inline void SvLBoxButton::SetStateHilighted( bool bHilight )
223{
224 if ( bHilight )
226 else
228}
229
231
233{
234 std::unique_ptr<SvLBoxContextBmp_Impl> m_pImpl;
235public:
236 SvLBoxContextBmp(const Image& aBmp1,
237 const Image& aBmp2,
238 bool bExpanded);
240 virtual ~SvLBoxContextBmp() override;
241
242 virtual SvLBoxItemType GetType() const override;
243 virtual void InitViewData(SvTreeListBox* pView,
244 SvTreeListEntry* pEntry,
245 SvViewDataItem* pViewData = nullptr) override;
246 virtual void Paint(const Point& rPos,
247 SvTreeListBox& rOutDev,
248 vcl::RenderContext& rRenderContext,
249 const SvViewDataEntry* pView,
250 const SvTreeListEntry& rEntry) override;
251
252 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override;
253
254 void SetModeImages(const Image& rBitmap1, const Image& rBitmap2);
255
256 inline void SetBitmap1(const Image& rImage);
257 inline void SetBitmap2(const Image& rImage);
258 inline const Image& GetBitmap1() const;
259 inline const Image& GetBitmap2() const;
260
261private:
262 Image& implGetImageStore(bool bFirst);
263};
264
265inline void SvLBoxContextBmp::SetBitmap1(const Image& _rImage)
266{
267 implGetImageStore(true) = _rImage;
268}
269
270inline void SvLBoxContextBmp::SetBitmap2(const Image& _rImage)
271{
272 implGetImageStore(false) = _rImage;
273}
274
276{
277 Image& rImage = const_cast<SvLBoxContextBmp*>(this)->implGetImageStore(true);
278 return rImage;
279}
280
282{
283 Image& rImage = const_cast<SvLBoxContextBmp*>(this)->implGetImageStore(false);
284 return rImage;
285}
286
287/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Text maText
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
Definition: ctrl.hxx:82
Definition: image.hxx:40
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:171
SvLBoxButtonData(const Control *pControlForSettings, bool _bRadioBtn)
Definition: svlbitm.cxx:54
static SvButtonState ConvertToButtonState(SvItemStateFlags nItemFlags)
Definition: svlbitm.cxx:103
void InitData(bool _bRadioBtn, const Control *pControlForSettings)
Definition: svlbitm.cxx:41
void SetWidthAndHeight()
Definition: svlbitm.cxx:89
tools::Long Width()
Definition: svlbitm.cxx:537
SvLBoxButton * GetActBox() const
Definition: svlbitm.cxx:127
bool HasDefaultImages() const
Definition: svlbitm.cxx:157
SvTreeListEntry * GetActEntry() const
Definition: svlbitm.cxx:121
std::vector< Image > aBmps
Definition: svlbitm.hxx:70
void SetDefaultImages(const Control *pControlForSettings)
Definition: svlbitm.cxx:133
void SetImage(SvBmp nIndex, const Image &aImage)
Definition: svlbitm.hxx:94
Link< SvLBoxButtonData *, void > aLink
Definition: svlbitm.hxx:65
void StoreButtonState(SvTreeListEntry *pActEntry, SvLBoxButton *pActBox)
Definition: svlbitm.cxx:97
static SvBmp GetIndex(SvItemStateFlags nItemState)
Definition: svlbitm.cxx:69
void SetLink(const Link< SvLBoxButtonData *, void > &rLink)
Definition: svlbitm.hxx:83
tools::Long nWidth
Definition: svlbitm.hxx:66
tools::Long nHeight
Definition: svlbitm.hxx:67
tools::Long Height()
Definition: svlbitm.cxx:544
void CallLink()
Definition: svlbitm.cxx:64
Image & GetImage(SvBmp nIndex)
Definition: svlbitm.hxx:95
std::unique_ptr< SvLBoxButtonData_Impl > pImpl
Definition: svlbitm.hxx:68
bool IsRadio() const
Definition: svlbitm.cxx:162
void ClickHdl(SvTreeListEntry *)
Definition: svlbitm.cxx:353
void SetStateHilighted(bool bHilight)
Definition: svlbitm.hxx:222
bool IsStateChecked() const
Definition: svlbitm.hxx:184
virtual ~SvLBoxButton() override
Definition: svlbitm.cxx:344
bool IsStateTristate() const
Definition: svlbitm.hxx:192
bool IsStateHilighted() const
Definition: svlbitm.hxx:196
virtual void InitViewData(SvTreeListBox *pView, SvTreeListEntry *pEntry, SvViewDataItem *pViewData=nullptr) override
Definition: svlbitm.cxx:438
virtual SvLBoxItemType GetType() const override
Definition: svlbitm.cxx:348
SvItemStateFlags nItemFlags
Definition: svlbitm.hxx:154
SvLBoxButtonData * pData
Definition: svlbitm.hxx:153
void SetStateChecked()
Definition: svlbitm.hxx:206
bool IsStateUnchecked() const
Definition: svlbitm.hxx:188
void SetStateUnchecked()
Definition: svlbitm.hxx:212
virtual void Paint(const Point &rPos, SvTreeListBox &rOutDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry) override
Definition: svlbitm.cxx:363
static void ImplAdjustBoxSize(Size &io_rCtrlSize, ControlType i_eType, vcl::RenderContext const &pRenderContext)
Definition: svlbitm.cxx:409
SvItemStateFlags GetButtonFlags() const
Definition: svlbitm.hxx:180
void SetStateTristate()
Definition: svlbitm.hxx:217
virtual std::unique_ptr< SvLBoxItem > Clone(SvLBoxItem const *pSource) const override
Definition: svlbitm.cxx:402
std::unique_ptr< SvLBoxContextBmp_Impl > m_pImpl
Definition: svlbitm.hxx:234
const Image & GetBitmap2() const
Definition: svlbitm.hxx:281
void SetBitmap2(const Image &rImage)
Definition: svlbitm.hxx:270
Image & implGetImageStore(bool bFirst)
Definition: svlbitm.cxx:495
void SetBitmap1(const Image &rImage)
Definition: svlbitm.hxx:265
const Image & GetBitmap1() const
Definition: svlbitm.hxx:275
virtual void InitViewData(SvTreeListBox *pView, SvTreeListEntry *pEntry, SvViewDataItem *pViewData=nullptr)=0
virtual std::unique_ptr< SvLBoxItem > Clone(SvLBoxItem const *pSource) const =0
virtual SvLBoxItemType GetType() const =0
virtual void Paint(const Point &rPos, SvTreeListBox &rOutDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry)=0
virtual int CalcWidth(const SvTreeListBox *pView) const
const OUString & GetText() const
Definition: svlbitm.hxx:133
double mfAlign
Definition: svlbitm.hxx:110
bool mbEmphasized
Definition: svlbitm.hxx:108
void Align(double fAlign)
Definition: svlbitm.hxx:126
void SetText(const OUString &rText)
Definition: svlbitm.hxx:137
void Emphasize(bool bEmphasize)
Definition: svlbitm.hxx:128
bool IsEmphasized() const
Definition: svlbitm.hxx:129
OUString maText
Definition: svlbitm.hxx:112
bool mbCustom
Definition: svlbitm.hxx:109
void SetCustomRender()
Definition: svlbitm.hxx:131
View-dependent data for a tree list entry created in the virtual function SvTreeListBox::CreateViewDa...
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_Int32 nIndex
NONE
long Long
SvItemStateFlags
Definition: svlbitm.hxx:48
SvBmp
Definition: svlbitm.hxx:38
@ HICHECKED
@ TRISTATE
@ UNCHECKED
@ HITRISTATE
@ HIUNCHECKED
SvButtonState
Definition: treelistbox.hxx:52
SvLBoxItemType
Definition: treelistbox.hxx:96