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_COMBOBOX_HXX
30 : : #define _SV_COMBOBOX_HXX
31 : :
32 : : #include <vcl/dllapi.h>
33 : : #include <vcl/ctrl.hxx>
34 : : #include <vcl/combobox.h>
35 : : #include <vcl/edit.hxx>
36 : :
37 : : class UserDrawEvent;
38 : :
39 : : class ImplListBoxFloatingWindow;
40 : : class ImplListBox;
41 : : class ImplBtn;
42 : :
43 : : // ------------
44 : : // - ComboBox -
45 : : // ------------
46 : :
47 : : class VCL_DLLPUBLIC ComboBox : public Edit
48 : : {
49 : : private:
50 : : Edit* mpSubEdit;
51 : : ImplListBox* mpImplLB;
52 : : ImplBtn* mpBtn;
53 : : ImplListBoxFloatingWindow* mpFloatWin;
54 : : sal_uInt16 mnDDHeight;
55 : : xub_Unicode mcMultiSep;
56 : : sal_Bool mbDDAutoSize : 1;
57 : : sal_Bool mbSyntheticModify : 1;
58 : : sal_Bool mbMatchCase : 1;
59 : : Link maSelectHdl;
60 : : Link maDoubleClickHdl;
61 : :
62 : : private:
63 : : SAL_DLLPRIVATE void ImplInitComboBoxData();
64 : : SAL_DLLPRIVATE void ImplUpdateFloatSelection();
65 : :
66 : : DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
67 : : DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
68 : : DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* );
69 : : DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* );
70 : : DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* );
71 : : DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* );
72 : : DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* );
73 : : DECL_DLLPRIVATE_LINK( ImplAutocompleteHdl, Edit* );
74 : :
75 : : protected:
76 : : using Window::ImplInit;
77 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
78 : : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
79 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
80 : : SAL_DLLPRIVATE void ImplCalcEditHeight();
81 : : SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const;
82 : :
83 : : protected:
84 : : ComboBox( WindowType nType );
85 [ + + ]: 17208 : sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; }
86 : :
87 : : virtual void FillLayoutData() const;
88 : : public:
89 : : ComboBox( Window* pParent, WinBits nStyle = 0 );
90 : : ComboBox( Window* pParent, const ResId& rResId );
91 : : ~ComboBox();
92 : :
93 : : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
94 : : virtual void Resize();
95 : : virtual long PreNotify( NotifyEvent& rNEvt );
96 : : virtual long Notify( NotifyEvent& rNEvt );
97 : : virtual void StateChanged( StateChangedType nType );
98 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
99 : :
100 : : virtual void UserDraw( const UserDrawEvent& rUDEvt );
101 : : virtual void Select();
102 : : virtual void DoubleClick();
103 : :
104 : : virtual void Modify();
105 : :
106 : : virtual const Wallpaper& GetDisplayBackground() const;
107 : :
108 : : virtual void SetPosSizePixel( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
109 : 40 : void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
110 : 40 : { Edit::SetPosSizePixel( rNewPos, rNewSize ); }
111 : 0 : void SetDropDownSizePixel( const Size& rNewSize )
112 [ # # ]: 0 : { if( IsDropDownBox() ) SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); }
113 : :
114 : : Rectangle GetDropDownPosSizePixel() const;
115 : :
116 : : void SetDropDownLineCount( sal_uInt16 nLines );
117 : : sal_uInt16 GetDropDownLineCount() const;
118 : :
119 : : void EnableAutoSize( sal_Bool bAuto );
120 : 3136 : sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
121 : :
122 : : void EnableDDAutoWidth( sal_Bool b );
123 : :
124 : : void SetText( const XubString& rStr );
125 : : void SetText( const XubString& rStr, const Selection& rNewSelection );
126 : :
127 : : sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND );
128 : : sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND );
129 : :
130 : : void RemoveEntry( const XubString& rStr );
131 : : void RemoveEntry( sal_uInt16 nPos );
132 : :
133 : : void Clear();
134 : :
135 : : sal_uInt16 GetEntryPos( const XubString& rStr ) const;
136 : : Image GetEntryImage( sal_uInt16 nPos ) const;
137 : : XubString GetEntry( sal_uInt16 nPos ) const;
138 : : sal_uInt16 GetEntryCount() const;
139 : :
140 : : sal_Bool IsTravelSelect() const;
141 : : sal_Bool IsInDropDown() const;
142 : : void ToggleDropDown();
143 : :
144 : : long CalcWindowSizePixel( sal_uInt16 nLines ) const;
145 : :
146 : : void SetUserItemSize( const Size& rSz );
147 : : void EnableUserDraw( sal_Bool bUserDraw );
148 : :
149 : : void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False );
150 : : void SetBorderStyle( sal_uInt16 nBorderStyle );
151 : :
152 : : void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
153 : :
154 : : void EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False );
155 : : sal_Bool IsAutocompleteEnabled() const;
156 : :
157 : : void EnableMultiSelection( sal_Bool bMulti );
158 : : sal_Bool IsMultiSelectionEnabled() const;
159 : : void SetMultiSelectionSeparator( xub_Unicode cSep ) { mcMultiSep = cSep; }
160 : 0 : xub_Unicode GetMultiSelectionSeparator() const { return mcMultiSep; }
161 : :
162 : 0 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
163 : 0 : const Link& GetSelectHdl() const { return maSelectHdl; }
164 : 0 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
165 : 0 : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
166 : :
167 : : Size CalcMinimumSize() const;
168 : : virtual Size GetOptimalSize(WindowSizeType eType) const;
169 : : Size CalcAdjustedSize( const Size& rPrefSize ) const;
170 : : using Edit::CalcSize;
171 : : Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
172 : : void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
173 : :
174 : : void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep = ';' );
175 : : XubString GetMRUEntries( xub_Unicode cSep = ';' ) const;
176 : : void SetMaxMRUCount( sal_uInt16 n );
177 : : sal_uInt16 GetMaxMRUCount() const;
178 : :
179 : : void SetEntryData( sal_uInt16 nPos, void* pNewData );
180 : : void* GetEntryData( sal_uInt16 nPos ) const;
181 : :
182 : : sal_uInt16 GetTopEntry() const;
183 : :
184 : : void SetProminentEntryType( ProminentEntry eType );
185 : :
186 : : sal_uInt16 GetDisplayLineCount() const;
187 : :
188 : : sal_uInt16 GetSelectEntryCount() const;
189 : : sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const;
190 : : sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const;
191 : : void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True );
192 : : void SetNoSelection();
193 : : Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const;
194 : :
195 : : /** checks whether a certain point lies within the bounds of
196 : : a list item and returns the item as well as the character position
197 : : the point is at.
198 : :
199 : : <p>If the point is inside an item the item pos is put into <code>rPos</code> and
200 : : the item-relative character index is returned. If the point is not inside
201 : : an item -1 is returned and rPos is unchanged.</p>
202 : :
203 : : @param rPoint
204 : : tells the point for which an item is requested.
205 : :
206 : : @param rPos
207 : : gets the item at the specified point <code>rPoint</code>
208 : :
209 : : @returns
210 : : the item-relative character index at point <code>rPos</code> or -1
211 : : if no item is at that point.
212 : : */
213 : : using Control::GetIndexForPoint;
214 : : long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const;
215 : : };
216 : :
217 : : #endif // _COMBOBOX_HXX
218 : :
219 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|