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 .
21 #ifndef _SVLBOXITM_HXX
22 #define _SVLBOXITM_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
50 SvLBoxButtonData_Impl
* pImpl
;
54 SVT_DLLPRIVATE
void SetWidthAndHeight();
55 SVT_DLLPRIVATE
void InitData( sal_Bool bImagesFromDefault
,
56 bool _bRadioBtn
, const Control
* pControlForSettings
= NULL
);
58 // include creating default images (CheckBox or RadioButton)
59 SvLBoxButtonData( const Control
* pControlForSettings
);
60 SvLBoxButtonData( const Control
* pControlForSettings
, bool _bRadioBtn
);
64 sal_uInt16
GetIndex( sal_uInt16 nItemState
);
67 void SetLink( const Link
& rLink
) { aLink
=rLink
; }
68 const Link
& GetLink() const { return aLink
; }
70 // weil Buttons nicht von LinkHdl abgeleitet sind
73 void StoreButtonState( SvTreeListEntry
* pEntry
, sal_uInt16 nItemFlags
);
74 SvButtonState
ConvertToButtonState( sal_uInt16 nItemFlags
) const;
76 SvButtonState
GetActButtonState() const
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
98 SvLBoxString(SvTreeListEntry
*, sal_uInt16 nFlags
, const OUString
& rStr
);
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
; }
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
118 virtual ~SvLBoxBmp();
119 virtual sal_uInt16
GetType() const;
120 virtual void InitViewData( SvTreeListBox
*,SvTreeListEntry
*,SvViewDataItem
* );
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 SvLBoxButtonData
* pData
;
137 SvLBoxButtonKind eKind
;
138 sal_uInt16 nItemFlags
;
139 sal_uInt16 nBaseOffs
;
141 void ImplAdjustBoxSize( Size
& io_rCtrlSize
, ControlType i_eType
, Window
* pParent
);
143 // An SvLBoxButton can be of three different kinds: an
144 // enabled checkbox (the normal kind), a disabled checkbox
145 // (which cannot be modified via UI), or a static image
146 // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored
148 SvLBoxButton( SvTreeListEntry
* pEntry
,
149 SvLBoxButtonKind eTheKind
, sal_uInt16 nFlags
,
150 SvLBoxButtonData
* pBData
);
152 virtual ~SvLBoxButton();
153 virtual void InitViewData( SvTreeListBox
*,SvTreeListEntry
*,SvViewDataItem
* );
154 virtual sal_uInt16
GetType() const;
155 virtual sal_Bool
ClickHdl(SvTreeListBox
* pView
, SvTreeListEntry
* );
157 const Point
& rPos
, SvTreeListBox
& rOutDev
, const SvViewDataEntry
* pView
, const SvTreeListEntry
* pEntry
);
158 virtual SvLBoxItem
* Create() const;
159 virtual void Clone( SvLBoxItem
* pSource
);
160 sal_uInt16
GetButtonFlags() const { return nItemFlags
; }
161 sal_Bool
IsStateChecked() const { return (sal_Bool
)(nItemFlags
& SV_ITEMSTATE_CHECKED
)!=0; }
162 sal_Bool
IsStateUnchecked() const { return (sal_Bool
)(nItemFlags
& SV_ITEMSTATE_UNCHECKED
)!=0; }
163 sal_Bool
IsStateTristate() const { return (sal_Bool
)(nItemFlags
& SV_ITEMSTATE_TRISTATE
)!=0; }
164 sal_Bool
IsStateHilighted() const { return (sal_Bool
)(nItemFlags
& SV_ITEMSTATE_HILIGHTED
)!=0; }
165 void SetStateChecked();
166 void SetStateUnchecked();
167 void SetStateTristate();
168 void SetStateHilighted( sal_Bool bHilight
);
170 SvLBoxButtonKind
GetKind() const { return eKind
; }
172 void SetBaseOffs( sal_uInt16 nOffs
) { nBaseOffs
= nOffs
; }
173 sal_uInt16
GetBaseOffs() const { return nBaseOffs
; }
175 // Check whether this button can be modified via UI
176 bool CheckModification() const;
179 inline void SvLBoxButton::SetStateChecked()
181 nItemFlags
&= SV_STATE_MASK
;
182 nItemFlags
|= SV_ITEMSTATE_CHECKED
;
184 inline void SvLBoxButton::SetStateUnchecked()
186 nItemFlags
&= SV_STATE_MASK
;
187 nItemFlags
|= SV_ITEMSTATE_UNCHECKED
;
189 inline void SvLBoxButton::SetStateTristate()
191 nItemFlags
&= SV_STATE_MASK
;
192 nItemFlags
|= SV_ITEMSTATE_TRISTATE
;
194 inline void SvLBoxButton::SetStateHilighted( sal_Bool bHilight
)
197 nItemFlags
|= SV_ITEMSTATE_HILIGHTED
;
199 nItemFlags
&= ~SV_ITEMSTATE_HILIGHTED
;
203 struct SvLBoxContextBmp_Impl
;
204 class SVT_DLLPUBLIC SvLBoxContextBmp
: public SvLBoxItem
206 SvLBoxContextBmp_Impl
* m_pImpl
;
209 SvTreeListEntry
* pEntry
, sal_uInt16 nItemFlags
, Image aBmp1
, Image aBmp2
, bool bExpanded
);
212 virtual ~SvLBoxContextBmp();
213 virtual sal_uInt16
GetType() const;
214 virtual void InitViewData( SvTreeListBox
*,SvTreeListEntry
*,SvViewDataItem
* );
216 const Point
& rPos
, SvTreeListBox
& rOutDev
, const SvViewDataEntry
* pView
, const SvTreeListEntry
* pEntry
);
217 virtual SvLBoxItem
* Create() const;
218 virtual void Clone( SvLBoxItem
* pSource
);
221 sal_Bool
SetModeImages( const Image
& _rBitmap1
, const Image
& _rBitmap2
);
222 void GetModeImages( Image
& _rBitmap1
, Image
& _rBitmap2
) const;
224 inline void SetBitmap1( const Image
& _rImage
);
225 inline void SetBitmap2( const Image
& _rImage
);
226 inline const Image
& GetBitmap1( ) const;
227 inline const Image
& GetBitmap2( ) const;
230 Image
& implGetImageStore( sal_Bool _bFirst
);
233 inline void SvLBoxContextBmp::SetBitmap1( const Image
& _rImage
)
235 implGetImageStore( sal_True
) = _rImage
;
238 inline void SvLBoxContextBmp::SetBitmap2( const Image
& _rImage
)
240 implGetImageStore( sal_False
) = _rImage
;
243 inline const Image
& SvLBoxContextBmp::GetBitmap1( ) const
245 Image
& rImage
= const_cast< SvLBoxContextBmp
* >( this )->implGetImageStore( sal_True
);
249 inline const Image
& SvLBoxContextBmp::GetBitmap2( ) const
251 Image
& rImage
= const_cast< SvLBoxContextBmp
* >( this )->implGetImageStore( sal_False
);
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */