101aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
301aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
401aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
501aa44aaSAndrew Rist * distributed with this work for additional information
601aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
701aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
801aa44aaSAndrew Rist * "License"); you may not use this file except in compliance
901aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at
1001aa44aaSAndrew Rist *
1101aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1201aa44aaSAndrew Rist *
1301aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
1401aa44aaSAndrew Rist * software distributed under the License is distributed on an
1501aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1601aa44aaSAndrew Rist * KIND, either express or implied. See the License for the
1701aa44aaSAndrew Rist * specific language governing permissions and limitations
1801aa44aaSAndrew Rist * under the License.
1901aa44aaSAndrew Rist *
2001aa44aaSAndrew Rist *************************************************************/
2101aa44aaSAndrew Rist
2201aa44aaSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweir #ifndef _SVLBOXITM_HXX
26cdf0e10cSrcweir #define _SVLBOXITM_HXX
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "svtools/svtdllapi.h"
29cdf0e10cSrcweir
30cdf0e10cSrcweir #ifndef LINK_HXX
31cdf0e10cSrcweir #include <tools/link.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _IMAGE_HXX
35cdf0e10cSrcweir #include <vcl/image.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <svtools/svlbox.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir class SvLBoxEntry;
40cdf0e10cSrcweir
41cdf0e10cSrcweir #define SV_ITEM_ID_LBOXSTRING 1
42cdf0e10cSrcweir #define SV_ITEM_ID_LBOXBMP 2
43cdf0e10cSrcweir #define SV_ITEM_ID_LBOXBUTTON 3
44cdf0e10cSrcweir #define SV_ITEM_ID_LBOXCONTEXTBMP 4
452bfcd321SSteve Yin #define SV_ITEM_ID_EXTENDRLBOXSTRING 5
46cdf0e10cSrcweir
47cdf0e10cSrcweir enum SvButtonState { SV_BUTTON_UNCHECKED, SV_BUTTON_CHECKED, SV_BUTTON_TRISTATE };
48cdf0e10cSrcweir
49cdf0e10cSrcweir #define SV_BMP_UNCHECKED 0
50cdf0e10cSrcweir #define SV_BMP_CHECKED 1
51cdf0e10cSrcweir #define SV_BMP_TRISTATE 2
52cdf0e10cSrcweir #define SV_BMP_HIUNCHECKED 3
53cdf0e10cSrcweir #define SV_BMP_HICHECKED 4
54cdf0e10cSrcweir #define SV_BMP_HITRISTATE 5
55cdf0e10cSrcweir #define SV_BMP_STATICIMAGE 6
56cdf0e10cSrcweir
57cdf0e10cSrcweir struct SvLBoxButtonData_Impl;
58cdf0e10cSrcweir
59cdf0e10cSrcweir class SVT_DLLPUBLIC SvLBoxButtonData
60cdf0e10cSrcweir {
61cdf0e10cSrcweir private:
62cdf0e10cSrcweir Link aLink;
63cdf0e10cSrcweir long nWidth;
64cdf0e10cSrcweir long nHeight;
65cdf0e10cSrcweir SvLBoxButtonData_Impl* pImpl;
66cdf0e10cSrcweir sal_Bool bDataOk;
67cdf0e10cSrcweir SvButtonState eState;
68cdf0e10cSrcweir
69cdf0e10cSrcweir SVT_DLLPRIVATE void SetWidthAndHeight();
70cdf0e10cSrcweir SVT_DLLPRIVATE void InitData( sal_Bool bImagesFromDefault,
71cdf0e10cSrcweir bool _bRadioBtn, const Control* pControlForSettings = NULL );
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir // include creating default images (CheckBox or RadioButton)
74cdf0e10cSrcweir SvLBoxButtonData( const Control* pControlForSettings );
75cdf0e10cSrcweir SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn );
76cdf0e10cSrcweir
77cdf0e10cSrcweir SvLBoxButtonData();
78cdf0e10cSrcweir ~SvLBoxButtonData();
79cdf0e10cSrcweir
80cdf0e10cSrcweir sal_uInt16 GetIndex( sal_uInt16 nItemState );
81cdf0e10cSrcweir inline long Width();
82cdf0e10cSrcweir inline long Height();
SetLink(const Link & rLink)83cdf0e10cSrcweir void SetLink( const Link& rLink) { aLink=rLink; }
GetLink() const84cdf0e10cSrcweir const Link& GetLink() const { return aLink; }
85cdf0e10cSrcweir sal_Bool IsRadio();
86cdf0e10cSrcweir // weil Buttons nicht von LinkHdl abgeleitet sind
87cdf0e10cSrcweir void CallLink();
88cdf0e10cSrcweir
89cdf0e10cSrcweir void StoreButtonState( SvLBoxEntry* pEntry, sal_uInt16 nItemFlags );
90cdf0e10cSrcweir SvButtonState ConvertToButtonState( sal_uInt16 nItemFlags ) const;
91cdf0e10cSrcweir
92cdf0e10cSrcweir inline SvButtonState GetActButtonState() const;
93cdf0e10cSrcweir SvLBoxEntry* GetActEntry() const;
94cdf0e10cSrcweir
95cdf0e10cSrcweir Image aBmps[24]; // Indizes siehe Konstanten BMP_ ....
96cdf0e10cSrcweir
97cdf0e10cSrcweir void SetDefaultImages( const Control* pControlForSettings = NULL );
98*86e1cf34SPedro Giffuni // set images according to the color scheeme of the Control
99cdf0e10cSrcweir // pControlForSettings == NULL: settings are taken from Application
100cdf0e10cSrcweir sal_Bool HasDefaultImages( void ) const;
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
Width()103cdf0e10cSrcweir inline long SvLBoxButtonData::Width()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir if ( !bDataOk )
106cdf0e10cSrcweir SetWidthAndHeight();
107cdf0e10cSrcweir return nWidth;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
Height()110cdf0e10cSrcweir inline long SvLBoxButtonData::Height()
111cdf0e10cSrcweir {
112cdf0e10cSrcweir if ( !bDataOk )
113cdf0e10cSrcweir SetWidthAndHeight();
114cdf0e10cSrcweir return nHeight;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
GetActButtonState() const117cdf0e10cSrcweir inline SvButtonState SvLBoxButtonData::GetActButtonState() const
118cdf0e10cSrcweir {
119cdf0e10cSrcweir return eState;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir // **********************************************************************
123cdf0e10cSrcweir
124cdf0e10cSrcweir class SVT_DLLPUBLIC SvLBoxString : public SvLBoxItem
125cdf0e10cSrcweir {
126cdf0e10cSrcweir XubString aStr;
127cdf0e10cSrcweir public:
128cdf0e10cSrcweir SvLBoxString( SvLBoxEntry*,sal_uInt16 nFlags,const XubString& rStr);
129cdf0e10cSrcweir SvLBoxString();
130cdf0e10cSrcweir virtual ~SvLBoxString();
131cdf0e10cSrcweir virtual sal_uInt16 IsA();
132cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
GetText() const133cdf0e10cSrcweir XubString GetText() const { return aStr; }
GetExtendText() const1342bfcd321SSteve Yin virtual XubString GetExtendText() const {return XubString();}
135cdf0e10cSrcweir void SetText( SvLBoxEntry*, const XubString& rStr );
136cdf0e10cSrcweir void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
137cdf0e10cSrcweir SvLBoxItem* Create() const;
138cdf0e10cSrcweir void Clone( SvLBoxItem* pSource );
139cdf0e10cSrcweir };
140cdf0e10cSrcweir
141cdf0e10cSrcweir class SvLBoxBmp : public SvLBoxItem
142cdf0e10cSrcweir {
143cdf0e10cSrcweir Image aBmp;
144cdf0e10cSrcweir public:
145cdf0e10cSrcweir SvLBoxBmp( SvLBoxEntry*, sal_uInt16 nFlags, Image );
146cdf0e10cSrcweir SvLBoxBmp();
147cdf0e10cSrcweir virtual ~SvLBoxBmp();
148cdf0e10cSrcweir virtual sal_uInt16 IsA();
149cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
150cdf0e10cSrcweir void SetBitmap( SvLBoxEntry*, Image );
151cdf0e10cSrcweir void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
152cdf0e10cSrcweir SvLBoxItem* Create() const;
153cdf0e10cSrcweir void Clone( SvLBoxItem* pSource );
154cdf0e10cSrcweir };
155cdf0e10cSrcweir
156cdf0e10cSrcweir
157cdf0e10cSrcweir #define SV_ITEMSTATE_UNCHECKED 0x0001
158cdf0e10cSrcweir #define SV_ITEMSTATE_CHECKED 0x0002
159cdf0e10cSrcweir #define SV_ITEMSTATE_TRISTATE 0x0004
160cdf0e10cSrcweir #define SV_ITEMSTATE_HILIGHTED 0x0008
161cdf0e10cSrcweir #define SV_STATE_MASK 0xFFF8 // zum Loeschen von UNCHECKED,CHECKED,TRISTATE
162cdf0e10cSrcweir
163cdf0e10cSrcweir enum SvLBoxButtonKind
164cdf0e10cSrcweir {
165cdf0e10cSrcweir SvLBoxButtonKind_enabledCheckbox,
166cdf0e10cSrcweir SvLBoxButtonKind_disabledCheckbox,
167cdf0e10cSrcweir SvLBoxButtonKind_staticImage
168cdf0e10cSrcweir };
169cdf0e10cSrcweir
170cdf0e10cSrcweir class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
171cdf0e10cSrcweir {
172cdf0e10cSrcweir SvLBoxButtonData* pData;
173cdf0e10cSrcweir SvLBoxButtonKind eKind;
174cdf0e10cSrcweir sal_uInt16 nItemFlags;
175cdf0e10cSrcweir sal_uInt16 nImgArrOffs;
176cdf0e10cSrcweir sal_uInt16 nBaseOffs;
177cdf0e10cSrcweir
178cdf0e10cSrcweir void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, Window* pParent );
179cdf0e10cSrcweir public:
180cdf0e10cSrcweir // An SvLBoxButton can be of three different kinds: an
181cdf0e10cSrcweir // enabled checkbox (the normal kind), a disabled checkbox
182cdf0e10cSrcweir // (which cannot be modified via UI), or a static image
183cdf0e10cSrcweir // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored
184cdf0e10cSrcweir // for that kind).
185cdf0e10cSrcweir SvLBoxButton( SvLBoxEntry* pEntry,
186cdf0e10cSrcweir SvLBoxButtonKind eTheKind, sal_uInt16 nFlags,
187cdf0e10cSrcweir SvLBoxButtonData* pBData );
188cdf0e10cSrcweir SvLBoxButton();
189cdf0e10cSrcweir virtual ~SvLBoxButton();
190cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
191cdf0e10cSrcweir virtual sal_uInt16 IsA();
192cdf0e10cSrcweir void Check( SvLBox* pView, SvLBoxEntry*, sal_Bool bCheck );
193cdf0e10cSrcweir virtual sal_Bool ClickHdl(SvLBox* pView, SvLBoxEntry* );
194cdf0e10cSrcweir void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
195cdf0e10cSrcweir SvLBoxItem* Create() const;
196cdf0e10cSrcweir void Clone( SvLBoxItem* pSource );
GetButtonFlags() const197cdf0e10cSrcweir sal_uInt16 GetButtonFlags() const { return nItemFlags; }
IsStateChecked() const198cdf0e10cSrcweir sal_Bool IsStateChecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_CHECKED)!=0; }
IsStateUnchecked() const199cdf0e10cSrcweir sal_Bool IsStateUnchecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_UNCHECKED)!=0; }
IsStateTristate() const200cdf0e10cSrcweir sal_Bool IsStateTristate() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_TRISTATE)!=0; }
IsStateHilighted() const201cdf0e10cSrcweir sal_Bool IsStateHilighted() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_HILIGHTED)!=0; }
202cdf0e10cSrcweir void SetStateChecked();
203cdf0e10cSrcweir void SetStateUnchecked();
204cdf0e10cSrcweir void SetStateTristate();
205cdf0e10cSrcweir void SetStateHilighted( sal_Bool bHilight );
206cdf0e10cSrcweir
GetKind() const207cdf0e10cSrcweir SvLBoxButtonKind GetKind() const { return eKind; }
208cdf0e10cSrcweir
SetBaseOffs(sal_uInt16 nOffs)209cdf0e10cSrcweir void SetBaseOffs( sal_uInt16 nOffs ) { nBaseOffs = nOffs; }
GetBaseOffs() const210cdf0e10cSrcweir sal_uInt16 GetBaseOffs() const { return nBaseOffs; }
211cdf0e10cSrcweir
212cdf0e10cSrcweir // Check whether this button can be modified via UI, sounding a beep if it
213cdf0e10cSrcweir // cannot be modified:
214cdf0e10cSrcweir bool CheckModification() const;
GetButtonData() const2152bfcd321SSteve Yin SvLBoxButtonData* GetButtonData() const{ return pData;}
216cdf0e10cSrcweir };
217cdf0e10cSrcweir
SetStateChecked()218cdf0e10cSrcweir inline void SvLBoxButton::SetStateChecked()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir nItemFlags &= SV_STATE_MASK;
221cdf0e10cSrcweir nItemFlags |= SV_ITEMSTATE_CHECKED;
222cdf0e10cSrcweir }
SetStateUnchecked()223cdf0e10cSrcweir inline void SvLBoxButton::SetStateUnchecked()
224cdf0e10cSrcweir {
225cdf0e10cSrcweir nItemFlags &= SV_STATE_MASK;
226cdf0e10cSrcweir nItemFlags |= SV_ITEMSTATE_UNCHECKED;
227cdf0e10cSrcweir }
SetStateTristate()228cdf0e10cSrcweir inline void SvLBoxButton::SetStateTristate()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir nItemFlags &= SV_STATE_MASK;
231cdf0e10cSrcweir nItemFlags |= SV_ITEMSTATE_TRISTATE;
232cdf0e10cSrcweir }
SetStateHilighted(sal_Bool bHilight)233cdf0e10cSrcweir inline void SvLBoxButton::SetStateHilighted( sal_Bool bHilight )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir if ( bHilight )
236cdf0e10cSrcweir nItemFlags |= SV_ITEMSTATE_HILIGHTED;
237cdf0e10cSrcweir else
238cdf0e10cSrcweir nItemFlags &= ~SV_ITEMSTATE_HILIGHTED;
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
241cdf0e10cSrcweir
242cdf0e10cSrcweir struct SvLBoxContextBmp_Impl;
243cdf0e10cSrcweir class SVT_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem
244cdf0e10cSrcweir {
245cdf0e10cSrcweir SvLBoxContextBmp_Impl* m_pImpl;
246cdf0e10cSrcweir public:
247cdf0e10cSrcweir SvLBoxContextBmp( SvLBoxEntry*,sal_uInt16 nFlags,Image,Image,
248cdf0e10cSrcweir sal_uInt16 nEntryFlagsBmp1);
249cdf0e10cSrcweir SvLBoxContextBmp();
250cdf0e10cSrcweir virtual ~SvLBoxContextBmp();
251cdf0e10cSrcweir virtual sal_uInt16 IsA();
252cdf0e10cSrcweir void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
253cdf0e10cSrcweir void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
254cdf0e10cSrcweir SvLBoxItem* Create() const;
255cdf0e10cSrcweir void Clone( SvLBoxItem* pSource );
256cdf0e10cSrcweir
257cdf0e10cSrcweir
258cdf0e10cSrcweir sal_Bool SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2, BmpColorMode _eMode = BMP_COLOR_NORMAL );
259cdf0e10cSrcweir void GetModeImages( Image& _rBitmap1, Image& _rBitmap2, BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
260cdf0e10cSrcweir
261cdf0e10cSrcweir inline void SetBitmap1( const Image& _rImage, BmpColorMode _eMode = BMP_COLOR_NORMAL );
262cdf0e10cSrcweir inline void SetBitmap2( const Image& _rImage, BmpColorMode _eMode = BMP_COLOR_NORMAL );
263cdf0e10cSrcweir inline const Image& GetBitmap1( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
264cdf0e10cSrcweir inline const Image& GetBitmap2( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
265cdf0e10cSrcweir
266cdf0e10cSrcweir private:
267cdf0e10cSrcweir Image& implGetImageStore( sal_Bool _bFirst, BmpColorMode _eMode );
268cdf0e10cSrcweir };
269cdf0e10cSrcweir
SetBitmap1(const Image & _rImage,BmpColorMode _eMode)270cdf0e10cSrcweir inline void SvLBoxContextBmp::SetBitmap1( const Image& _rImage, BmpColorMode _eMode )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir implGetImageStore( sal_True, _eMode ) = _rImage;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
SetBitmap2(const Image & _rImage,BmpColorMode _eMode)275cdf0e10cSrcweir inline void SvLBoxContextBmp::SetBitmap2( const Image& _rImage, BmpColorMode _eMode )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir implGetImageStore( sal_False, _eMode ) = _rImage;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
GetBitmap1(BmpColorMode _eMode) const280cdf0e10cSrcweir inline const Image& SvLBoxContextBmp::GetBitmap1( BmpColorMode _eMode ) const
281cdf0e10cSrcweir {
282cdf0e10cSrcweir Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_True, _eMode );
283cdf0e10cSrcweir if ( !rImage )
284cdf0e10cSrcweir // fallback to the "normal" image
285cdf0e10cSrcweir rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_True, BMP_COLOR_NORMAL );
286cdf0e10cSrcweir return rImage;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
GetBitmap2(BmpColorMode _eMode) const289cdf0e10cSrcweir inline const Image& SvLBoxContextBmp::GetBitmap2( BmpColorMode _eMode ) const
290cdf0e10cSrcweir {
291cdf0e10cSrcweir Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_False, _eMode );
292cdf0e10cSrcweir if ( !rImage )
293cdf0e10cSrcweir // fallback to the "normal" image
294cdf0e10cSrcweir rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_True, BMP_COLOR_NORMAL );
295cdf0e10cSrcweir return rImage;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
298cdf0e10cSrcweir #endif
299