Bump version to 6.4-15
[LibreOffice.git] / include / vcl / combobox.hxx
blob5484023778c7972da1a90e38536e26ab3896aaa7
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>
26 #include <boost/property_tree/ptree.hpp>
28 #define COMBOBOX_APPEND (SAL_MAX_INT32)
29 #define COMBOBOX_ENTRY_NOTFOUND (SAL_MAX_INT32)
30 #define COMBOBOX_MAX_ENTRIES (SAL_MAX_INT32 - 1)
32 class UserDrawEvent;
34 /// A widget used to choose from a list of items and which has an entry.
35 class VCL_DLLPUBLIC ComboBox : public Edit
37 private:
38 struct Impl;
39 std::unique_ptr<Impl> m_pImpl;
41 protected:
42 using Window::ImplInit;
43 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
44 SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
45 SAL_DLLPRIVATE void ImplCalcEditHeight();
46 SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const;
48 protected:
49 bool IsDropDownBox() const;
51 virtual void FillLayoutData() const override;
53 public:
54 explicit ComboBox( vcl::Window* pParent, WinBits nStyle = 0 );
55 virtual ~ComboBox() override;
56 virtual void dispose() override;
58 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
59 virtual void Resize() override;
60 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
61 virtual void StateChanged( StateChangedType nType ) override;
62 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
64 virtual void UserDraw( const UserDrawEvent& rUDEvt );
65 virtual void Select();
66 void DoubleClick();
68 virtual void Modify() override;
70 virtual const Wallpaper& GetDisplayBackground() const override;
72 virtual void setPosSizePixel( long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) override;
74 tools::Rectangle GetDropDownPosSizePixel() const;
76 void AdaptDropDownLineCountToMaximum();
77 void SetDropDownLineCount( sal_uInt16 nLines );
78 sal_uInt16 GetDropDownLineCount() const;
80 void EnableAutoSize( bool bAuto );
81 bool IsAutoSizeEnabled() const;
83 virtual void SetText( const OUString& rStr ) override;
84 virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override;
86 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 void RemoveEntryAt(sal_Int32 nPos);
92 void Clear();
93 void EnableSelectAll();
94 sal_Int32 GetEntryPos( const OUString& rStr ) const;
95 Image GetEntryImage( sal_Int32 nPos ) const;
96 OUString GetEntry( sal_Int32 nPos ) const;
97 sal_Int32 GetEntryCount() const;
99 bool IsTravelSelect() const;
100 bool IsInDropDown() const;
101 void ToggleDropDown();
103 long CalcWindowSizePixel( sal_uInt16 nLines ) const;
105 void SetUserItemSize( const Size& rSz );
106 void EnableUserDraw( bool bUserDraw );
108 void DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false );
109 void SetBorderStyle( WindowBorderStyle nBorderStyle );
111 void SetSeparatorPos( sal_Int32 n );
114 * Adds a new separator at the given position n.
116 void AddSeparator( sal_Int32 n );
118 void EnableAutocomplete( bool bEnable, bool bMatchCase = false );
119 bool IsAutocompleteEnabled() const;
121 bool IsMultiSelectionEnabled() const;
123 void SetSelectHdl(const Link<ComboBox&,void>& rLink);
124 const Link<ComboBox&,void>& GetSelectHdl() const;
125 void SetDoubleClickHdl(const Link<ComboBox&,void>& rLink);
126 const Link<ComboBox&,void>& GetDoubleClickHdl() const;
127 void SetEntryActivateHdl(const Link<Edit&,bool>& rLink);
129 Size CalcMinimumSize() const override;
130 virtual Size GetOptimalSize() const override;
131 Size CalcAdjustedSize( const Size& rPrefSize ) const;
132 Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
133 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
135 void SetMRUEntries( const OUString& rEntries );
136 OUString GetMRUEntries() const;
137 void SetMaxMRUCount( sal_Int32 n );
138 sal_Int32 GetMaxMRUCount() const;
139 void SetEntryData( sal_Int32 nPos, void* pNewData );
140 void* GetEntryData( sal_Int32 nPos ) const;
142 sal_Int32 GetTopEntry() const;
144 void SetProminentEntryType( ProminentEntry eType );
146 sal_uInt16 GetDisplayLineCount() const;
148 sal_Int32 GetSelectedEntryCount() const;
149 sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex = 0 ) const;
150 OUString GetSelectedEntry() const { return GetEntry( GetSelectedEntryPos() ); }
151 bool IsEntryPosSelected( sal_Int32 nPos ) const;
152 void SelectEntryPos( sal_Int32 nPos, bool bSelect = true );
153 void SetNoSelection();
154 tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
156 /** checks whether a certain point lies within the bounds of
157 a list item and returns the item as well as the character position
158 the point is at.
160 <p>If the point is inside an item the item pos is put into <code>rPos</code> and
161 the item-relative character index is returned. If the point is not inside
162 an item -1 is returned and rPos is unchanged.</p>
164 @param rPoint
165 tells the point for which an item is requested.
167 @param rPos
168 gets the item at the specified point <code>rPoint</code>
170 @returns
171 the item-relative character index at point <code>rPos</code> or -1
172 if no item is at that point.
174 using Control::GetIndexForPoint;
175 long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const;
177 void setMaxWidthChars(sal_Int32 nWidth);
179 void SetWidthInChars(sal_Int32 nWidthInChars);
181 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
183 virtual FactoryFunction GetUITestFactory() const override;
185 virtual boost::property_tree::ptree DumpAsPropertyTree() override;
188 #endif // _COMBOBOX_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */