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 INCLUDED_VCL_COMBOBOX_HXX
21 #define INCLUDED_VCL_COMBOBOX_HXX
23 #include <boost/signals2/connection.hpp>
24 #include <vcl/dllapi.h>
25 #include <vcl/ctrl.hxx>
26 #include <vcl/combobox.h>
27 #include <vcl/edit.hxx>
31 class ImplListBoxFloatingWindow
;
35 class VCL_DLLPUBLIC ComboBox
: public Edit
38 VclPtr
<Edit
> mpSubEdit
;
39 VclPtr
<ImplListBox
> mpImplLB
;
40 VclPtr
<ImplBtn
> mpBtn
;
41 VclPtr
<ImplListBoxFloatingWindow
> mpFloatWin
;
42 sal_uInt16 mnDDHeight
;
43 sal_Unicode mcMultiSep
;
44 bool mbDDAutoSize
: 1;
45 bool mbSyntheticModify
: 1;
47 sal_Int32 m_nMaxWidthChars
;
49 Link
<> maDoubleClickHdl
;
50 boost::signals2::scoped_connection mAutocompleteConnection
;
62 SAL_DLLPRIVATE
void ImplInitComboBoxData();
63 SAL_DLLPRIVATE
void ImplUpdateFloatSelection();
64 SAL_DLLPRIVATE ComboBoxBounds
calcComboBoxDropDownComponentBounds(
65 const Size
&rOutSize
, const Size
&rBorderOutSize
) const;
67 DECL_DLLPRIVATE_LINK( ImplSelectHdl
, void* );
68 DECL_DLLPRIVATE_LINK( ImplCancelHdl
, void* );
69 DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl
, void* );
70 DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl
, void* );
71 DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl
, void* );
72 DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl
, void* );
74 SAL_DLLPRIVATE
void ImplClickButtonHandler( ImplBtn
* );
75 SAL_DLLPRIVATE
void ImplUserDrawHandler( UserDrawEvent
* );
76 SAL_DLLPRIVATE
void ImplAutocompleteHandler( Edit
* );
79 using Window::ImplInit
;
80 SAL_DLLPRIVATE
void ImplInit( vcl::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 bool IsDropDownBox() const { return mpFloatWin
!= nullptr; }
89 virtual void FillLayoutData() const SAL_OVERRIDE
;
92 explicit ComboBox( vcl::Window
* pParent
, WinBits nStyle
= 0 );
93 explicit ComboBox( vcl::Window
* pParent
, const ResId
& );
95 virtual void dispose() SAL_OVERRIDE
;
97 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, sal_uLong nFlags
) SAL_OVERRIDE
;
98 virtual void Resize() SAL_OVERRIDE
;
99 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
100 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
101 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
102 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
104 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
105 virtual void Select();
106 virtual void DoubleClick();
108 virtual void Modify() SAL_OVERRIDE
;
110 virtual const Wallpaper
& GetDisplayBackground() const SAL_OVERRIDE
;
112 virtual void setPosSizePixel( long nX
, long nY
, long nWidth
, long nHeight
, PosSizeFlags nFlags
= PosSizeFlags::All
) SAL_OVERRIDE
;
113 void SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
) SAL_OVERRIDE
114 { Edit::SetPosSizePixel( rNewPos
, rNewSize
); }
116 Rectangle
GetDropDownPosSizePixel() const;
118 void AdaptDropDownLineCountToMaximum();
119 void SetDropDownLineCount( sal_uInt16 nLines
);
120 sal_uInt16
GetDropDownLineCount() const;
122 void EnableAutoSize( bool bAuto
);
123 bool IsAutoSizeEnabled() const { return mbDDAutoSize
; }
125 void EnableDDAutoWidth( bool b
);
127 virtual void SetText( const OUString
& rStr
) SAL_OVERRIDE
;
128 virtual void SetText( const OUString
& rStr
, const Selection
& rNewSelection
) SAL_OVERRIDE
;
130 virtual sal_Int32
InsertEntry(const OUString
& rStr
, sal_Int32 nPos
= COMBOBOX_APPEND
);
131 sal_Int32
InsertEntryWithImage( const OUString
& rStr
, const Image
& rImage
, sal_Int32 nPos
= COMBOBOX_APPEND
);
133 void RemoveEntry( const OUString
& rStr
);
134 virtual void RemoveEntryAt(sal_Int32 nPos
);
138 sal_Int32
GetEntryPos( const OUString
& rStr
) const;
139 sal_Int32
GetEntryPos( const void* pData
) const;
140 Image
GetEntryImage( sal_Int32 nPos
) const;
141 OUString
GetEntry( sal_Int32 nPos
) const;
142 sal_Int32
GetEntryCount() const;
144 bool IsTravelSelect() const;
145 bool IsInDropDown() const;
146 void ToggleDropDown();
148 long CalcWindowSizePixel( sal_uInt16 nLines
) const;
150 void SetUserItemSize( const Size
& rSz
);
151 void EnableUserDraw( bool bUserDraw
);
153 void DrawEntry( const UserDrawEvent
& rEvt
, bool bDrawImage
, bool bDrawText
, bool bDrawTextAtImagePos
= false );
154 void SetBorderStyle( WindowBorderStyle nBorderStyle
);
156 void SetSeparatorPos( sal_Int32 n
= COMBOBOX_ENTRY_NOTFOUND
);
158 void EnableAutocomplete( bool bEnable
, bool bMatchCase
= false );
159 bool IsAutocompleteEnabled() const;
161 void EnableMultiSelection( bool bMulti
);
162 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 SAL_OVERRIDE
;
172 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
173 Size
CalcAdjustedSize( const Size
& rPrefSize
) const;
174 Size
CalcBlockSize( sal_uInt16 nColumns
, sal_uInt16 nLines
) const;
175 void GetMaxVisColumnsAndLines( sal_uInt16
& rnCols
, sal_uInt16
& rnLines
) const;
177 void SetMRUEntries( const OUString
& rEntries
, sal_Unicode cSep
= ';' );
178 OUString
GetMRUEntries( sal_Unicode cSep
= ';' ) const;
179 void SetMaxMRUCount( sal_Int32 n
);
180 sal_Int32
GetMaxMRUCount() const;
181 void SetEntryData( sal_Int32 nPos
, void* pNewData
);
182 void* GetEntryData( sal_Int32 nPos
) const;
184 sal_Int32
GetTopEntry() const;
186 void SetProminentEntryType( ProminentEntry eType
);
188 sal_uInt16
GetDisplayLineCount() const;
190 sal_Int32
GetSelectEntryCount() const;
191 sal_Int32
GetSelectEntryPos( sal_Int32 nSelIndex
= 0 ) const;
192 OUString
GetSelectEntry() const { return GetEntry( GetSelectEntryPos() ); }
193 bool IsEntryPosSelected( sal_Int32 nPos
) const;
194 void SelectEntryPos( sal_Int32 nPos
, bool bSelect
= true );
195 void SetNoSelection();
196 Rectangle
GetBoundingRectangle( sal_Int32 nItem
) const;
198 /** checks whether a certain point lies within the bounds of
199 a list item and returns the item as well as the character position
202 <p>If the point is inside an item the item pos is put into <code>rPos</code> and
203 the item-relative character index is returned. If the point is not inside
204 an item -1 is returned and rPos is unchanged.</p>
207 tells the point for which an item is requested.
210 gets the item at the specified point <code>rPoint</code>
213 the item-relative character index at point <code>rPos</code> or -1
214 if no item is at that point.
216 using Control::GetIndexForPoint
;
217 long GetIndexForPoint( const Point
& rPoint
, sal_Int32
& rPos
) const;
219 sal_Int32
getMaxWidthChars() const { return m_nMaxWidthChars
; }
220 void setMaxWidthChars(sal_Int32 nWidth
);
222 virtual bool set_property(const OString
&rKey
, const OString
&rValue
) SAL_OVERRIDE
;
225 #endif // _COMBOBOX_HXX
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */