bump product version to 4.2.0.1
[LibreOffice.git] / include / svtools / svlbitm.hxx
blobcdc461375e246472b0da9c540f2d812f94b23467
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #ifndef INCLUDED_SVTOOLS_SVLBITM_HXX
22 #define INCLUDED_SVTOOLS_SVLBITM_HXX
24 #include <svtools/svtdllapi.h>
26 #include <tools/link.hxx>
28 #include <vcl/image.hxx>
29 #include <svtools/treelistbox.hxx>
31 class SvTreeListEntry;
34 #define SV_BMP_UNCHECKED 0
35 #define SV_BMP_CHECKED 1
36 #define SV_BMP_TRISTATE 2
37 #define SV_BMP_HIUNCHECKED 3
38 #define SV_BMP_HICHECKED 4
39 #define SV_BMP_HITRISTATE 5
40 #define SV_BMP_STATICIMAGE 6
42 struct SvLBoxButtonData_Impl;
44 class SVT_DLLPUBLIC SvLBoxButtonData
46 private:
47 Link aLink;
48 long nWidth;
49 long nHeight;
50 SvLBoxButtonData_Impl* pImpl;
51 sal_Bool bDataOk;
52 SvButtonState eState;
54 SVT_DLLPRIVATE void SetWidthAndHeight();
55 SVT_DLLPRIVATE void InitData( sal_Bool bImagesFromDefault,
56 bool _bRadioBtn, const Control* pControlForSettings = NULL );
57 public:
58 // include creating default images (CheckBox or RadioButton)
59 SvLBoxButtonData( const Control* pControlForSettings );
60 SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn );
62 ~SvLBoxButtonData();
64 sal_uInt16 GetIndex( sal_uInt16 nItemState );
65 long Width();
66 long Height();
67 void SetLink( const Link& rLink) { aLink=rLink; }
68 const Link& GetLink() const { return aLink; }
69 sal_Bool IsRadio();
70 // weil Buttons nicht von LinkHdl abgeleitet sind
71 void CallLink();
73 void StoreButtonState( SvTreeListEntry* pEntry, sal_uInt16 nItemFlags );
74 SvButtonState ConvertToButtonState( sal_uInt16 nItemFlags ) const;
76 SvButtonState GetActButtonState() const
78 return eState;
81 SvTreeListEntry* GetActEntry() const;
83 Image aBmps[24]; // Indizes siehe Konstanten BMP_ ....
85 void SetDefaultImages( const Control* pControlForSettings = NULL );
86 // set images acording to the color scheeme of the Control
87 // pControlForSettings == NULL: settings are taken from Application
88 sal_Bool HasDefaultImages( void ) const;
91 // **********************************************************************
93 class SVT_DLLPUBLIC SvLBoxString : public SvLBoxItem
95 protected:
96 OUString maText;
97 public:
98 SvLBoxString(SvTreeListEntry*, sal_uInt16 nFlags, const OUString& rStr);
99 SvLBoxString();
100 virtual ~SvLBoxString();
101 virtual sal_uInt16 GetType() const;
102 virtual void InitViewData(SvTreeListBox*, SvTreeListEntry*, SvViewDataItem*);
103 OUString GetText() const { return maText; }
104 void SetText( const OUString& rText ) { maText = rText; }
106 virtual void Paint(
107 const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
109 virtual SvLBoxItem* Create() const;
110 virtual void Clone( SvLBoxItem* pSource );
113 class SvLBoxBmp : public SvLBoxItem
115 Image aBmp;
116 public:
117 SvLBoxBmp();
118 virtual ~SvLBoxBmp();
119 virtual sal_uInt16 GetType() const;
120 virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* );
121 virtual void Paint(
122 const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
123 virtual SvLBoxItem* Create() const;
124 virtual void Clone( SvLBoxItem* pSource );
128 #define SV_ITEMSTATE_UNCHECKED 0x0001
129 #define SV_ITEMSTATE_CHECKED 0x0002
130 #define SV_ITEMSTATE_TRISTATE 0x0004
131 #define SV_ITEMSTATE_HILIGHTED 0x0008
132 #define SV_STATE_MASK 0xFFF8 // zum Loeschen von UNCHECKED,CHECKED,TRISTATE
134 class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
136 bool isVis;
137 SvLBoxButtonData* pData;
138 SvLBoxButtonKind eKind;
139 sal_uInt16 nItemFlags;
140 sal_uInt16 nBaseOffs;
142 void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, Window* pParent );
143 public:
144 // An SvLBoxButton can be of three different kinds: an
145 // enabled checkbox (the normal kind), a disabled checkbox
146 // (which cannot be modified via UI), or a static image
147 // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored
148 // for that kind).
149 SvLBoxButton( SvTreeListEntry* pEntry,
150 SvLBoxButtonKind eTheKind, sal_uInt16 nFlags,
151 SvLBoxButtonData* pBData );
152 SvLBoxButton();
153 virtual ~SvLBoxButton();
154 virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* );
155 virtual sal_uInt16 GetType() const;
156 virtual sal_Bool ClickHdl(SvTreeListBox* pView, SvTreeListEntry* );
157 virtual void Paint(
158 const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
159 virtual SvLBoxItem* Create() const;
160 virtual void Clone( SvLBoxItem* pSource );
161 sal_uInt16 GetButtonFlags() const { return nItemFlags; }
162 sal_Bool IsStateChecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_CHECKED)!=0; }
163 sal_Bool IsStateUnchecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_UNCHECKED)!=0; }
164 sal_Bool IsStateTristate() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_TRISTATE)!=0; }
165 sal_Bool IsStateHilighted() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_HILIGHTED)!=0; }
166 void SetStateChecked();
167 void SetStateUnchecked();
168 void SetStateTristate();
169 void SetStateHilighted( sal_Bool bHilight );
170 void SetStateInvisible();
172 SvLBoxButtonKind GetKind() const { return eKind; }
174 void SetBaseOffs( sal_uInt16 nOffs ) { nBaseOffs = nOffs; }
175 sal_uInt16 GetBaseOffs() const { return nBaseOffs; }
177 // Check whether this button can be modified via UI
178 bool CheckModification() const;
181 inline void SvLBoxButton::SetStateChecked()
183 nItemFlags &= SV_STATE_MASK;
184 nItemFlags |= SV_ITEMSTATE_CHECKED;
186 inline void SvLBoxButton::SetStateUnchecked()
188 nItemFlags &= SV_STATE_MASK;
189 nItemFlags |= SV_ITEMSTATE_UNCHECKED;
191 inline void SvLBoxButton::SetStateTristate()
193 nItemFlags &= SV_STATE_MASK;
194 nItemFlags |= SV_ITEMSTATE_TRISTATE;
196 inline void SvLBoxButton::SetStateHilighted( sal_Bool bHilight )
198 if ( bHilight )
199 nItemFlags |= SV_ITEMSTATE_HILIGHTED;
200 else
201 nItemFlags &= ~SV_ITEMSTATE_HILIGHTED;
205 struct SvLBoxContextBmp_Impl;
206 class SVT_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem
208 SvLBoxContextBmp_Impl* m_pImpl;
209 public:
210 SvLBoxContextBmp(
211 SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2, bool bExpanded);
212 SvLBoxContextBmp();
214 virtual ~SvLBoxContextBmp();
215 virtual sal_uInt16 GetType() const;
216 virtual void InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* );
217 virtual void Paint(
218 const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
219 virtual SvLBoxItem* Create() const;
220 virtual void Clone( SvLBoxItem* pSource );
223 sal_Bool SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 );
224 void GetModeImages( Image& _rBitmap1, Image& _rBitmap2 ) const;
226 inline void SetBitmap1( const Image& _rImage );
227 inline void SetBitmap2( const Image& _rImage );
228 inline const Image& GetBitmap1( ) const;
229 inline const Image& GetBitmap2( ) const;
231 private:
232 Image& implGetImageStore( sal_Bool _bFirst );
235 inline void SvLBoxContextBmp::SetBitmap1( const Image& _rImage )
237 implGetImageStore( sal_True ) = _rImage;
240 inline void SvLBoxContextBmp::SetBitmap2( const Image& _rImage )
242 implGetImageStore( sal_False ) = _rImage;
245 inline const Image& SvLBoxContextBmp::GetBitmap1( ) const
247 Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_True );
248 return rImage;
251 inline const Image& SvLBoxContextBmp::GetBitmap2( ) const
253 Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_False );
254 return rImage;
257 #endif
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */