fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / vcl / lstbox.hxx
blob61f8b24b5f0d531888ef7ccf5c11b299819a6039
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 _SV_LSTBOX_HXX
21 #define _SV_LSTBOX_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/lstbox.h>
27 class Image;
28 class ImplListBox;
29 class ImplListBoxFloatingWindow;
30 class ImplBtn;
31 class ImplWin;
33 // --------------------------------------------------------------------
34 // - ListBox -
35 // --------------------------------------------------------------------
37 class VCL_DLLPUBLIC ListBox : public Control
39 private:
40 ImplListBox* mpImplLB;
41 ImplListBoxFloatingWindow* mpFloatWin;
42 ImplWin* mpImplWin;
43 ImplBtn* mpBtn;
44 sal_uInt16 mnDDHeight;
45 sal_uInt16 mnSaveValue;
46 sal_Int32 m_nMaxWidthChars;
47 Link maSelectHdl;
48 Link maDoubleClickHdl;
49 sal_uInt16 mnLineCount;
51 /// bitfield
52 bool mbDDAutoSize : 1;
53 bool mbEdgeBlending : 1;
55 private:
56 SAL_DLLPRIVATE void ImplInitListBoxData();
58 DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
59 DECL_DLLPRIVATE_LINK( ImplScrollHdl, void* );
60 DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
61 DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* );
62 DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* );
63 DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* );
64 DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* );
65 DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* );
67 protected:
68 using Window::ImplInit;
69 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
70 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
71 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
72 sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; }
74 protected:
75 explicit ListBox( WindowType nType );
77 virtual void FillLayoutData() const;
79 public:
80 explicit ListBox( Window* pParent, WinBits nStyle = WB_BORDER );
81 explicit ListBox( Window* pParent, const ResId& );
82 virtual ~ListBox();
84 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
85 virtual void Resize();
86 virtual long PreNotify( NotifyEvent& rNEvt );
87 virtual void StateChanged( StateChangedType nType );
88 virtual void DataChanged( const DataChangedEvent& rDCEvt );
89 virtual void UserDraw( const UserDrawEvent& rUDEvt );
91 virtual void Select();
92 virtual void DoubleClick();
93 virtual void GetFocus();
94 virtual void LoseFocus();
95 virtual Window* GetPreferredKeyInputWindow();
97 virtual const Wallpaper& GetDisplayBackground() const;
99 virtual void setPosSizePixel( long nX, long nY,
100 long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
101 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
102 { Control::SetPosSizePixel( rNewPos, rNewSize ); }
103 void SetDropDownSizePixel( const Size& rNewSize )
104 { if( IsDropDownBox() ) setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); }
106 Rectangle GetDropDownPosSizePixel() const;
108 void AdaptDropDownLineCountToMaximum();
109 void SetDropDownLineCount( sal_uInt16 nLines );
110 sal_uInt16 GetDropDownLineCount() const;
112 void EnableAutoSize( bool bAuto );
113 bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
115 void EnableDDAutoWidth( sal_Bool b );
117 virtual sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
118 virtual sal_uInt16 InsertEntry( const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
119 virtual sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
120 virtual void RemoveEntry( const XubString& rStr );
121 virtual void RemoveEntry( sal_uInt16 nPos );
123 virtual void Clear();
125 virtual sal_uInt16 GetEntryPos( const XubString& rStr ) const;
126 virtual sal_uInt16 GetEntryPos( const void* pData ) const;
127 Image GetEntryImage( sal_uInt16 nPos ) const;
128 virtual XubString GetEntry( sal_uInt16 nPos ) const;
129 virtual sal_uInt16 GetEntryCount() const;
131 virtual void SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True );
132 virtual void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True );
134 virtual sal_uInt16 GetSelectEntryCount() const;
135 virtual XubString GetSelectEntry( sal_uInt16 nSelIndex = 0 ) const;
136 virtual sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const;
138 virtual sal_Bool IsEntrySelected( const XubString& rStr ) const;
139 virtual sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const;
140 virtual void SetNoSelection();
142 void SetEntryData( sal_uInt16 nPos, void* pNewData );
143 void* GetEntryData( sal_uInt16 nPos ) const;
145 /** this methods stores a combination of flags from the
146 LISTBOX_ENTRY_FLAG_* defines at the given entry.
147 See description of the possible LISTBOX_ENTRY_FLAG_* flags
148 for details.
149 Do not use these flags for user data as they are reserved
150 to change the internal behaviour of the ListBox implementation
151 for specific entries.
153 void SetEntryFlags( sal_uInt16 nPos, long nFlags );
155 /** this methods gets the current combination of flags from the
156 LISTBOX_ENTRY_FLAG_* defines from the given entry.
157 See description of the possible LISTBOX_ENTRY_FLAG_* flags
158 for details.
160 long GetEntryFlags( sal_uInt16 nPos ) const;
162 void SetTopEntry( sal_uInt16 nPos );
163 sal_uInt16 GetTopEntry() const;
165 void SaveValue() { mnSaveValue = GetSelectEntryPos(); }
166 sal_uInt16 GetSavedValue() const { return mnSaveValue; }
168 void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
169 sal_uInt16 GetSeparatorPos() const;
171 sal_Bool IsTravelSelect() const;
172 sal_Bool IsInDropDown() const;
173 void ToggleDropDown();
175 void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackSelection );
176 void EnableMultiSelection( sal_Bool bMulti );
177 sal_Bool IsMultiSelectionEnabled() const;
179 void SetReadOnly( sal_Bool bReadOnly = sal_True );
180 sal_Bool IsReadOnly() const;
182 Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const;
184 void SetUserItemSize( const Size& rSz );
186 void EnableUserDraw( sal_Bool bUserDraw );
188 void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False );
190 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
191 const Link& GetSelectHdl() const { return maSelectHdl; }
192 void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
193 const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
195 Size CalcSubEditSize() const; //size of area inside lstbox, i.e. no scrollbar/dropdown
196 Size CalcMinimumSize() const; //size of lstbox area, i.e. including scrollbar/dropdown
197 virtual Size GetOptimalSize() const;
198 Size CalcAdjustedSize( const Size& rPrefSize ) const;
199 Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
200 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
202 sal_uInt16 GetDisplayLineCount() const;
204 void EnableMirroring();
206 bool GetEdgeBlending() const { return mbEdgeBlending; }
207 void SetEdgeBlending(bool bNew);
209 /** checks whether a certain point lies within the bounds of
210 a listbox item and returns the item as well as the character position
211 the point is at.
213 <p>If the point is inside an item the item pos is put into <code>rPos</code> and
214 the item-relative character index is returned. If the point is not inside
215 an item -1 is returned and rPos is unchanged.</p>
217 @param rPoint
218 tells the point for which an item is requested.
220 @param rPos
221 gets the item at the specified point <code>rPoint</code>
223 @returns
224 the item-relative character index at point <code>rPos</code> or -1
225 if no item is at that point.
227 using Control::GetIndexForPoint;
228 long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const;
230 sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
231 void setMaxWidthChars(sal_Int32 nWidth);
233 virtual bool set_property(const OString &rKey, const OString &rValue);
236 // ----------------
237 // - MultiListBox -
238 // ----------------
240 class VCL_DLLPUBLIC MultiListBox : public ListBox
242 public:
243 using ListBox::SaveValue;
244 using ListBox::GetSavedValue;
245 private:
246 // Bei MultiListBox nicht erlaubt...
247 void SaveValue();
248 sal_uInt16 GetSavedValue();
250 public:
251 explicit MultiListBox( Window* pParent, WinBits nStyle = 0 );
252 explicit MultiListBox( Window* pParent, const ResId& rResId );
255 #endif // _SV_LSTBOX_HXX
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */