Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_LSTBOX_HXX
30 : : #define _SV_LSTBOX_HXX
31 : :
32 : : #include <vcl/dllapi.h>
33 : : #include <vcl/ctrl.hxx>
34 : : #include <vcl/lstbox.h>
35 : :
36 : : class Image;
37 : : class ImplListBox;
38 : : class ImplListBoxFloatingWindow;
39 : : class ImplBtn;
40 : : class ImplWin;
41 : :
42 : : // --------------------------------------------------------------------
43 : : // - ListBox -
44 : : // --------------------------------------------------------------------
45 : :
46 : : class VCL_DLLPUBLIC ListBox : public Control
47 : : {
48 : : private:
49 : : ImplListBox* mpImplLB;
50 : : ImplListBoxFloatingWindow* mpFloatWin;
51 : : ImplWin* mpImplWin;
52 : : ImplBtn* mpBtn;
53 : : sal_uInt16 mnDDHeight;
54 : : sal_uInt16 mnSaveValue;
55 : : sal_Bool mbDDAutoSize;
56 : : Link maSelectHdl;
57 : : Link maDoubleClickHdl;
58 : : sal_uInt16 mnLineCount;
59 : :
60 : : private:
61 : : SAL_DLLPRIVATE void ImplInitListBoxData();
62 : :
63 : : DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
64 : : DECL_DLLPRIVATE_LINK( ImplScrollHdl, void* );
65 : : DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
66 : : DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* );
67 : : DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* );
68 : : DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* );
69 : : DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* );
70 : : DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* );
71 : :
72 : : protected:
73 : : using Window::ImplInit;
74 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
75 : : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
76 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
77 [ + + ]: 7261 : sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; }
78 : :
79 : : protected:
80 : : ListBox( WindowType nType );
81 : :
82 : : virtual void FillLayoutData() const;
83 : :
84 : : public:
85 : : ListBox( Window* pParent, WinBits nStyle = WB_BORDER );
86 : : ListBox( Window* pParent, const ResId& rResId );
87 : : ~ListBox();
88 : :
89 : : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
90 : : virtual void Resize();
91 : : virtual long PreNotify( NotifyEvent& rNEvt );
92 : : virtual void StateChanged( StateChangedType nType );
93 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
94 : : virtual void UserDraw( const UserDrawEvent& rUDEvt );
95 : :
96 : : virtual void Select();
97 : : virtual void DoubleClick();
98 : : virtual void GetFocus();
99 : : virtual void LoseFocus();
100 : : virtual Window* GetPreferredKeyInputWindow();
101 : :
102 : : virtual const Wallpaper& GetDisplayBackground() const;
103 : :
104 : : virtual void SetPosSizePixel( long nX, long nY,
105 : : long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
106 : 167 : void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
107 : 167 : { Control::SetPosSizePixel( rNewPos, rNewSize ); }
108 : 0 : void SetDropDownSizePixel( const Size& rNewSize )
109 [ # # ]: 0 : { if( IsDropDownBox() ) SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); }
110 : :
111 : : Rectangle GetDropDownPosSizePixel() const;
112 : :
113 : : void SetDropDownLineCount( sal_uInt16 nLines );
114 : : sal_uInt16 GetDropDownLineCount() const;
115 : :
116 : : void EnableAutoSize( sal_Bool bAuto );
117 : 1331 : sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
118 : :
119 : : void EnableDDAutoWidth( sal_Bool b );
120 : :
121 : : virtual sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
122 : : virtual sal_uInt16 InsertEntry( const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
123 : : virtual sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
124 : : virtual void RemoveEntry( const XubString& rStr );
125 : : virtual void RemoveEntry( sal_uInt16 nPos );
126 : :
127 : : virtual void Clear();
128 : :
129 : : virtual sal_uInt16 GetEntryPos( const XubString& rStr ) const;
130 : : virtual sal_uInt16 GetEntryPos( const void* pData ) const;
131 : : Image GetEntryImage( sal_uInt16 nPos ) const;
132 : : virtual XubString GetEntry( sal_uInt16 nPos ) const;
133 : : virtual sal_uInt16 GetEntryCount() const;
134 : :
135 : : virtual void SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True );
136 : : virtual void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True );
137 : :
138 : : virtual sal_uInt16 GetSelectEntryCount() const;
139 : : virtual XubString GetSelectEntry( sal_uInt16 nSelIndex = 0 ) const;
140 : : virtual sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const;
141 : :
142 : : virtual sal_Bool IsEntrySelected( const XubString& rStr ) const;
143 : : virtual sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const;
144 : : virtual void SetNoSelection();
145 : :
146 : : void SetEntryData( sal_uInt16 nPos, void* pNewData );
147 : : void* GetEntryData( sal_uInt16 nPos ) const;
148 : :
149 : : /** this methods stores a combination of flags from the
150 : : LISTBOX_ENTRY_FLAG_* defines at the given entry.
151 : : See description of the possible LISTBOX_ENTRY_FLAG_* flags
152 : : for details.
153 : : Do not use these flags for user data as they are reserved
154 : : to change the internal behaviour of the ListBox implementation
155 : : for specific entries.
156 : : */
157 : : void SetEntryFlags( sal_uInt16 nPos, long nFlags );
158 : :
159 : : /** this methods gets the current combination of flags from the
160 : : LISTBOX_ENTRY_FLAG_* defines from the given entry.
161 : : See description of the possible LISTBOX_ENTRY_FLAG_* flags
162 : : for details.
163 : : */
164 : : long GetEntryFlags( sal_uInt16 nPos ) const;
165 : :
166 : : void SetTopEntry( sal_uInt16 nPos );
167 : : void SetTopEntryStr( const XubString& rStr );
168 : : sal_uInt16 GetTopEntry() const;
169 : :
170 : 2271 : void SaveValue() { mnSaveValue = GetSelectEntryPos(); }
171 : 0 : sal_uInt16 GetSavedValue() const { return mnSaveValue; }
172 : :
173 : : void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
174 : : sal_uInt16 GetSeparatorPos() const;
175 : :
176 : : sal_Bool IsTravelSelect() const;
177 : : sal_Bool IsInDropDown() const;
178 : : void ToggleDropDown();
179 : :
180 : : void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackSelection );
181 : : void EnableMultiSelection( sal_Bool bMulti );
182 : : sal_Bool IsMultiSelectionEnabled() const;
183 : :
184 : : void SetReadOnly( sal_Bool bReadOnly = sal_True );
185 : : sal_Bool IsReadOnly() const;
186 : :
187 : : Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const;
188 : :
189 : : void SetUserItemSize( const Size& rSz );
190 : :
191 : : void EnableUserDraw( sal_Bool bUserDraw );
192 : :
193 : : void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False );
194 : :
195 : 378 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
196 : 0 : const Link& GetSelectHdl() const { return maSelectHdl; }
197 : 0 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
198 : 0 : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
199 : :
200 : : Size CalcMinimumSize() const;
201 : : virtual Size GetOptimalSize(WindowSizeType eType) const;
202 : : Size CalcAdjustedSize( const Size& rPrefSize ) const;
203 : : Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
204 : : void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
205 : :
206 : : sal_uInt16 GetDisplayLineCount() const;
207 : :
208 : : void EnableMirroring();
209 : :
210 : : /** checks whether a certain point lies within the bounds of
211 : : a listbox item and returns the item as well as the character position
212 : : the point is at.
213 : :
214 : : <p>If the point is inside an item the item pos is put into <code>rPos</code> and
215 : : the item-relative character index is returned. If the point is not inside
216 : : an item -1 is returned and rPos is unchanged.</p>
217 : :
218 : : @param rPoint
219 : : tells the point for which an item is requested.
220 : :
221 : : @param rPos
222 : : gets the item at the specified point <code>rPoint</code>
223 : :
224 : : @returns
225 : : the item-relative character index at point <code>rPos</code> or -1
226 : : if no item is at that point.
227 : : */
228 : : using Control::GetIndexForPoint;
229 : : long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const;
230 : : };
231 : :
232 : : // ----------------
233 : : // - MultiListBox -
234 : : // ----------------
235 : :
236 [ # # ]: 0 : class VCL_DLLPUBLIC MultiListBox : public ListBox
237 : : {
238 : : public:
239 : : using ListBox::SaveValue;
240 : : using ListBox::GetSavedValue;
241 : : private:
242 : : // Bei MultiListBox nicht erlaubt...
243 : : void SaveValue();
244 : : sal_uInt16 GetSavedValue();
245 : :
246 : : public:
247 : : MultiListBox( Window* pParent, WinBits nStyle = 0 );
248 : : MultiListBox( Window* pParent, const ResId& rResId );
249 : : };
250 : :
251 : : #endif // _SV_LSTBOX_HXX
252 : :
253 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|