Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / combobox.hxx
blobfd9306d2e8c4ac60ada042496384bfba6cf1b62e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
24 #include <vcl/dllapi.h>
25 #include <vcl/edit.hxx>
27 #define COMBOBOX_APPEND (SAL_MAX_INT32)
28 #define COMBOBOX_ENTRY_NOTFOUND (SAL_MAX_INT32)
29 #define COMBOBOX_MAX_ENTRIES (SAL_MAX_INT32 - 1)
31 class UserDrawEvent;
33 class VCL_DLLPUBLIC ComboBox : public Edit
35 private:
36 struct Impl;
37 std::unique_ptr<Impl> m_pImpl;
39 protected:
40 using Window::ImplInit;
41 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
42 SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
43 SAL_DLLPRIVATE void ImplCalcEditHeight();
44 SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const;
46 protected:
47 bool IsDropDownBox() const;
49 virtual void FillLayoutData() const override;
51 public:
52 explicit ComboBox( vcl::Window* pParent, WinBits nStyle = 0 );
53 virtual ~ComboBox() override;
54 virtual void dispose() override;
56 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
57 virtual void Resize() override;
58 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
59 virtual void StateChanged( StateChangedType nType ) override;
60 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
62 virtual void UserDraw( const UserDrawEvent& rUDEvt );
63 virtual void Select();
64 void DoubleClick();
66 virtual void Modify() override;
68 virtual const Wallpaper& GetDisplayBackground() const override;
70 virtual void setPosSizePixel( long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) override;
72 tools::Rectangle GetDropDownPosSizePixel() const;
74 void AdaptDropDownLineCountToMaximum();
75 void SetDropDownLineCount( sal_uInt16 nLines );
76 sal_uInt16 GetDropDownLineCount() const;
78 void EnableAutoSize( bool bAuto );
79 bool IsAutoSizeEnabled() const;
81 void EnableDDAutoWidth( bool b );
83 virtual void SetText( const OUString& rStr ) override;
84 virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override;
86 virtual sal_Int32 InsertEntry(const OUString& rStr, sal_Int32 nPos = COMBOBOX_APPEND);
87 sal_Int32 InsertEntryWithImage( const OUString& rStr, const Image& rImage, sal_Int32 nPos = COMBOBOX_APPEND );
89 void RemoveEntry( const OUString& rStr );
90 virtual void RemoveEntryAt(sal_Int32 nPos);
92 void Clear();
94 sal_Int32 GetEntryPos( const OUString& rStr ) const;
95 sal_Int32 GetEntryPos( const void* pData ) const;
96 Image GetEntryImage( sal_Int32 nPos ) const;
97 OUString GetEntry( sal_Int32 nPos ) const;
98 sal_Int32 GetEntryCount() const;
100 bool IsTravelSelect() const;
101 bool IsInDropDown() const;
102 void ToggleDropDown();
104 long CalcWindowSizePixel( sal_uInt16 nLines ) const;
106 void SetUserItemSize( const Size& rSz );
107 void EnableUserDraw( bool bUserDraw );
109 void DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false );
110 void SetBorderStyle( WindowBorderStyle nBorderStyle );
112 void SetSeparatorPos( sal_Int32 n );
114 void EnableAutocomplete( bool bEnable, bool bMatchCase = false );
115 bool IsAutocompleteEnabled() const;
117 void EnableMultiSelection( bool bMulti );
118 bool IsMultiSelectionEnabled() const;
120 void SetSelectHdl(const Link<ComboBox&,void>& rLink);
121 const Link<ComboBox&,void>& GetSelectHdl() const;
122 void SetDoubleClickHdl(const Link<ComboBox&,void>& rLink);
123 const Link<ComboBox&,void>& GetDoubleClickHdl() const;
125 Size CalcMinimumSize() const override;
126 virtual Size GetOptimalSize() const override;
127 Size CalcAdjustedSize( const Size& rPrefSize ) const;
128 Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
129 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
131 void SetMRUEntries( const OUString& rEntries );
132 OUString GetMRUEntries() const;
133 void SetMaxMRUCount( sal_Int32 n );
134 sal_Int32 GetMaxMRUCount() const;
135 void SetEntryData( sal_Int32 nPos, void* pNewData );
136 void* GetEntryData( sal_Int32 nPos ) const;
138 sal_Int32 GetTopEntry() const;
140 void SetProminentEntryType( ProminentEntry eType );
142 sal_uInt16 GetDisplayLineCount() const;
144 sal_Int32 GetSelectEntryCount() const;
145 sal_Int32 GetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const;
146 OUString GetSelectEntry() const { return GetEntry( GetSelectEntryPos() ); }
147 bool IsEntryPosSelected( sal_Int32 nPos ) const;
148 void SelectEntryPos( sal_Int32 nPos, bool bSelect = true );
149 void SetNoSelection();
150 tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
152 /** checks whether a certain point lies within the bounds of
153 a list item and returns the item as well as the character position
154 the point is at.
156 <p>If the point is inside an item the item pos is put into <code>rPos</code> and
157 the item-relative character index is returned. If the point is not inside
158 an item -1 is returned and rPos is unchanged.</p>
160 @param rPoint
161 tells the point for which an item is requested.
163 @param rPos
164 gets the item at the specified point <code>rPoint</code>
166 @returns
167 the item-relative character index at point <code>rPos</code> or -1
168 if no item is at that point.
170 using Control::GetIndexForPoint;
171 long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const;
173 void setMaxWidthChars(sal_Int32 nWidth);
175 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
177 virtual FactoryFunction GetUITestFactory() const override;
180 #endif // _COMBOBOX_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */