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 .
20 #ifndef _SV_COMBOBOX_HXX
21 #define _SV_COMBOBOX_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/combobox.h>
26 #include <vcl/edit.hxx>
30 class ImplListBoxFloatingWindow
;
38 class VCL_DLLPUBLIC ComboBox
: public Edit
42 ImplListBox
* mpImplLB
;
44 ImplListBoxFloatingWindow
* mpFloatWin
;
45 sal_uInt16 mnDDHeight
;
46 sal_Unicode mcMultiSep
;
47 sal_Bool mbDDAutoSize
: 1;
48 sal_Bool mbSyntheticModify
: 1;
49 sal_Bool mbMatchCase
: 1;
50 sal_Int32 m_nMaxWidthChars
;
52 Link maDoubleClickHdl
;
64 SAL_DLLPRIVATE
void ImplInitComboBoxData();
65 SAL_DLLPRIVATE
void ImplUpdateFloatSelection();
66 SAL_DLLPRIVATE ComboBoxBounds
calcComboBoxDropDownComponentBounds(
67 const Size
&rOutSize
, const Size
&rBorderOutSize
) const;
69 DECL_DLLPRIVATE_LINK( ImplSelectHdl
, void* );
70 DECL_DLLPRIVATE_LINK( ImplCancelHdl
, void* );
71 DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl
, void* );
72 DECL_DLLPRIVATE_LINK( ImplClickBtnHdl
, void* );
73 DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl
, void* );
74 DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl
, void* );
75 DECL_DLLPRIVATE_LINK( ImplUserDrawHdl
, UserDrawEvent
* );
76 DECL_DLLPRIVATE_LINK( ImplAutocompleteHdl
, Edit
* );
79 using Window::ImplInit
;
80 SAL_DLLPRIVATE
void ImplInit( Window
* pParent
, WinBits nStyle
);
81 SAL_DLLPRIVATE WinBits
ImplInitStyle( WinBits nStyle
);
82 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
83 SAL_DLLPRIVATE
void ImplCalcEditHeight();
84 SAL_DLLPRIVATE
long getMaxWidthScrollBarAndDownButton() const;
87 explicit ComboBox( WindowType nType
);
88 sal_Bool
IsDropDownBox() const { return mpFloatWin
? sal_True
: sal_False
; }
90 virtual void FillLayoutData() const;
92 explicit ComboBox( Window
* pParent
, WinBits nStyle
= 0 );
93 explicit ComboBox( Window
* pParent
, const ResId
& );
96 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, sal_uLong nFlags
);
97 virtual void Resize();
98 virtual long PreNotify( NotifyEvent
& rNEvt
);
99 virtual long Notify( NotifyEvent
& rNEvt
);
100 virtual void StateChanged( StateChangedType nType
);
101 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
103 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
104 virtual void Select();
105 virtual void DoubleClick();
107 virtual void Modify();
109 virtual const Wallpaper
& GetDisplayBackground() const;
111 virtual void setPosSizePixel( long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
= WINDOW_POSSIZE_ALL
);
112 void SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
)
113 { Edit::SetPosSizePixel( rNewPos
, rNewSize
); }
114 void SetDropDownSizePixel( const Size
& rNewSize
)
115 { if( IsDropDownBox() ) setPosSizePixel( 0, 0, rNewSize
.Width(), rNewSize
.Height(), WINDOW_POSSIZE_SIZE
| WINDOW_POSSIZE_DROPDOWN
); }
117 Rectangle
GetDropDownPosSizePixel() const;
119 void AdaptDropDownLineCountToMaximum();
120 void SetDropDownLineCount( sal_uInt16 nLines
);
121 sal_uInt16
GetDropDownLineCount() const;
123 void EnableAutoSize( bool bAuto
);
124 sal_Bool
IsAutoSizeEnabled() const { return mbDDAutoSize
; }
126 void EnableDDAutoWidth( sal_Bool b
);
128 virtual void SetText( const OUString
& rStr
);
129 virtual void SetText( const OUString
& rStr
, const Selection
& rNewSelection
);
131 sal_uInt16
InsertEntry( const OUString
& rStr
, sal_uInt16 nPos
= COMBOBOX_APPEND
);
132 sal_uInt16
InsertEntry( const OUString
& rStr
, const Image
& rImage
, sal_uInt16 nPos
= COMBOBOX_APPEND
);
134 void RemoveEntry( const OUString
& rStr
);
135 void RemoveEntry( sal_uInt16 nPos
);
139 sal_uInt16
GetEntryPos( const OUString
& rStr
) const;
140 Image
GetEntryImage( sal_uInt16 nPos
) const;
141 OUString
GetEntry( sal_uInt16 nPos
) const;
142 sal_uInt16
GetEntryCount() const;
144 sal_Bool
IsTravelSelect() const;
145 sal_Bool
IsInDropDown() const;
146 void ToggleDropDown();
148 long CalcWindowSizePixel( sal_uInt16 nLines
) const;
150 void SetUserItemSize( const Size
& rSz
);
151 void EnableUserDraw( sal_Bool bUserDraw
);
153 void DrawEntry( const UserDrawEvent
& rEvt
, sal_Bool bDrawImage
, sal_Bool bDrawText
, sal_Bool bDrawTextAtImagePos
= sal_False
);
154 void SetBorderStyle( sal_uInt16 nBorderStyle
);
156 void SetSeparatorPos( sal_uInt16 n
= LISTBOX_ENTRY_NOTFOUND
);
158 void EnableAutocomplete( sal_Bool bEnable
, sal_Bool bMatchCase
= sal_False
);
159 sal_Bool
IsAutocompleteEnabled() const;
161 void EnableMultiSelection( sal_Bool bMulti
);
162 sal_Bool
IsMultiSelectionEnabled() const;
163 void SetMultiSelectionSeparator( sal_Unicode cSep
) { mcMultiSep
= cSep
; }
164 sal_Unicode
GetMultiSelectionSeparator() const { return mcMultiSep
; }
166 void SetSelectHdl( const Link
& rLink
) { maSelectHdl
= rLink
; }
167 const Link
& GetSelectHdl() const { return maSelectHdl
; }
168 void SetDoubleClickHdl( const Link
& rLink
) { maDoubleClickHdl
= rLink
; }
169 const Link
& GetDoubleClickHdl() const { return maDoubleClickHdl
; }
171 Size
CalcMinimumSize() const;
172 virtual Size
GetOptimalSize() const;
173 Size
CalcAdjustedSize( const Size
& rPrefSize
) const;
174 using Edit::CalcSize
;
175 Size
CalcSize( sal_uInt16 nColumns
, sal_uInt16 nLines
) const;
176 void GetMaxVisColumnsAndLines( sal_uInt16
& rnCols
, sal_uInt16
& rnLines
) const;
178 void SetMRUEntries( const OUString
& rEntries
, sal_Unicode cSep
= ';' );
179 OUString
GetMRUEntries( sal_Unicode cSep
= ';' ) const;
180 void SetMaxMRUCount( sal_uInt16 n
);
181 sal_uInt16
GetMaxMRUCount() const;
183 void SetEntryData( sal_uInt16 nPos
, void* pNewData
);
184 void* GetEntryData( sal_uInt16 nPos
) const;
186 sal_uInt16
GetTopEntry() const;
188 void SetProminentEntryType( ProminentEntry eType
);
190 sal_uInt16
GetDisplayLineCount() const;
192 sal_uInt16
GetSelectEntryCount() const;
193 sal_uInt16
GetSelectEntryPos( sal_uInt16 nSelIndex
= 0 ) const;
194 sal_Bool
IsEntryPosSelected( sal_uInt16 nPos
) const;
195 void SelectEntryPos( sal_uInt16 nPos
, sal_Bool bSelect
= sal_True
);
196 void SetNoSelection();
197 Rectangle
GetBoundingRectangle( sal_uInt16 nItem
) const;
199 /** checks whether a certain point lies within the bounds of
200 a list item and returns the item as well as the character position
203 <p>If the point is inside an item the item pos is put into <code>rPos</code> and
204 the item-relative character index is returned. If the point is not inside
205 an item -1 is returned and rPos is unchanged.</p>
208 tells the point for which an item is requested.
211 gets the item at the specified point <code>rPoint</code>
214 the item-relative character index at point <code>rPos</code> or -1
215 if no item is at that point.
217 using Control::GetIndexForPoint
;
218 long GetIndexForPoint( const Point
& rPoint
, sal_uInt16
& rPos
) const;
220 sal_Int32
getMaxWidthChars() const { return m_nMaxWidthChars
; }
221 void setMaxWidthChars(sal_Int32 nWidth
);
223 virtual bool set_property(const OString
&rKey
, const OString
&rValue
);
226 #endif // _COMBOBOX_HXX
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */