1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_COMBOBOX_HXX 25 #define _SV_COMBOBOX_HXX 26 27 #include <vcl/dllapi.h> 28 #include <vcl/ctrl.hxx> 29 #include <vcl/combobox.h> 30 #include <vcl/edit.hxx> 31 32 class UserDrawEvent; 33 34 class ImplListBoxFloatingWindow; 35 class ImplListBox; 36 class ImplBtn; 37 38 // ------------ 39 // - ComboBox - 40 // ------------ 41 42 class VCL_DLLPUBLIC ComboBox : public Edit 43 { 44 private: 45 Edit* mpSubEdit; 46 ImplListBox* mpImplLB; 47 ImplBtn* mpBtn; 48 ImplListBoxFloatingWindow* mpFloatWin; 49 sal_uInt16 mnDDHeight; 50 xub_Unicode mcMultiSep; 51 sal_Bool mbDDAutoSize : 1; 52 sal_Bool mbSyntheticModify : 1; 53 sal_Bool mbMatchCase : 1; 54 Link maSelectHdl; 55 Link maDoubleClickHdl; 56 57 //#if 0 // _SOLAR__PRIVATE 58 private: 59 SAL_DLLPRIVATE void ImplInitComboBoxData(); 60 SAL_DLLPRIVATE void ImplUpdateFloatSelection(); 61 62 DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); 63 DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* ); 64 DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* ); 65 DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* ); 66 DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* ); 67 DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* ); 68 DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* ); 69 DECL_DLLPRIVATE_LINK( ImplAutocompleteHdl, Edit* ); 70 DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl , void* ); 71 72 protected: 73 using Window::ImplInit; 74 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); 75 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); 76 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 77 SAL_DLLPRIVATE void ImplCalcEditHeight(); 78 //#endif 79 80 protected: 81 explicit ComboBox( WindowType nType ); IsDropDownBox() const82 sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; } 83 84 virtual void FillLayoutData() const; 85 public: 86 explicit ComboBox( Window* pParent, WinBits nStyle = 0 ); 87 explicit ComboBox( Window* pParent, const ResId& ); 88 virtual ~ComboBox(); 89 90 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); 91 virtual void Resize(); 92 virtual long PreNotify( NotifyEvent& rNEvt ); 93 virtual long Notify( NotifyEvent& rNEvt ); 94 virtual void StateChanged( StateChangedType nType ); 95 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 96 97 virtual void UserDraw( const UserDrawEvent& rUDEvt ); 98 virtual void Select(); 99 virtual void DoubleClick(); 100 101 virtual void Modify(); 102 103 virtual const Wallpaper& GetDisplayBackground() const; 104 105 virtual void SetPosSizePixel( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); SetPosSizePixel(const Point & rNewPos,const Size & rNewSize)106 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) 107 { Edit::SetPosSizePixel( rNewPos, rNewSize ); } SetDropDownSizePixel(const Size & rNewSize)108 void SetDropDownSizePixel( const Size& rNewSize ) 109 { if( IsDropDownBox() ) SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); } 110 111 Rectangle GetDropDownPosSizePixel() const; 112 Rectangle GetListPosSizePixel() const; 113 // returns empty rectangle in DropDown mode, 114 // else it returns the PosSize of the ListBox 115 116 void AdaptDropDownLineCountToMaximum(); 117 void SetDropDownLineCount( sal_uInt16 nLines ); 118 sal_uInt16 GetDropDownLineCount() const; 119 120 void EnableAutoSize( sal_Bool bAuto ); IsAutoSizeEnabled() const121 sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; } 122 123 void EnableDDAutoWidth( sal_Bool b ); 124 sal_Bool IsDDAutoWidthEnabled() const; 125 126 void SetText( const XubString& rStr ); 127 void SetText( const XubString& rStr, const Selection& rNewSelection ); 128 129 sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND ); 130 sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND ); 131 132 void RemoveEntry( const XubString& rStr ); 133 void RemoveEntry( sal_uInt16 nPos ); 134 135 void Clear(); 136 137 sal_uInt16 GetEntryPos( const XubString& rStr ) const; 138 sal_uInt16 GetEntryPos( const void* pData ) const; 139 Image GetEntryImage( sal_uInt16 nPos ) const; 140 XubString GetEntry( sal_uInt16 nPos ) const; 141 sal_uInt16 GetEntryCount() const; 142 143 sal_Bool IsTravelSelect() const; 144 sal_Bool IsInDropDown() const; 145 void ToggleDropDown(); 146 147 long CalcWindowSizePixel( sal_uInt16 nLines ) const; 148 149 void SetUserItemSize( const Size& rSz ); 150 const Size& GetUserItemSize() const; 151 152 void EnableUserDraw( sal_Bool bUserDraw ); 153 sal_Bool IsUserDrawEnabled() const; 154 155 void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False ); 156 void SetBorderStyle( sal_uInt16 nBorderStyle ); 157 158 void SetSeparatorPos( sal_uInt16 n ); 159 void SetSeparatorPos(); 160 sal_uInt16 GetSeparatorPos() const; 161 162 void EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False ); 163 sal_Bool IsAutocompleteEnabled() const; 164 165 void EnableMultiSelection( sal_Bool bMulti ); 166 sal_Bool IsMultiSelectionEnabled() const; SetMultiSelectionSeparator(xub_Unicode cSep)167 void SetMultiSelectionSeparator( xub_Unicode cSep ) { mcMultiSep = cSep; } GetMultiSelectionSeparator() const168 xub_Unicode GetMultiSelectionSeparator() const { return mcMultiSep; } 169 SetSelectHdl(const Link & rLink)170 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } GetSelectHdl() const171 const Link& GetSelectHdl() const { return maSelectHdl; } SetDoubleClickHdl(const Link & rLink)172 void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } GetDoubleClickHdl() const173 const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } 174 175 Size CalcMinimumSize() const; 176 virtual Size GetOptimalSize(WindowSizeType eType) const; 177 Size CalcAdjustedSize( const Size& rPrefSize ) const; 178 using Edit::CalcSize; 179 Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; 180 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; 181 182 void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep = ';' ); 183 XubString GetMRUEntries( xub_Unicode cSep = ';' ) const; 184 void SetMaxMRUCount( sal_uInt16 n ); 185 sal_uInt16 GetMaxMRUCount() const; 186 sal_uInt16 GetMRUCount() const; 187 void SetEntryData( sal_uInt16 nPos, void* pNewData ); 188 void* GetEntryData( sal_uInt16 nPos ) const; 189 190 void SetTopEntry( sal_uInt16 nPos ); 191 void ShowProminentEntry( sal_uInt16 nPos ); 192 sal_uInt16 GetTopEntry() const; 193 194 void SetProminentEntryType( ProminentEntry eType ); 195 ProminentEntry GetProminentEntryType() const; 196 197 sal_uInt16 GetDisplayLineCount() const; 198 199 sal_uInt16 GetSelectEntryCount() const; 200 sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const; 201 sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const; 202 void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True ); 203 void SetNoSelection(); 204 Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; 205 206 /** checks whether a certain point lies within the bounds of 207 a list item and returns the item as well as the character position 208 the point is at. 209 210 <p>If the point is inside an item the item pos is put into <code>rPos</code> and 211 the item-relative character index is returned. If the point is not inside 212 an item -1 is returned and rPos is unchanged.</p> 213 214 @param rPoint 215 tells the point for which an item is requested. 216 217 @param rPos 218 gets the item at the specified point <code>rPoint</code> 219 220 @returns 221 the item-relative character index at point <code>rPos</code> or -1 222 if no item is at that point. 223 */ 224 using Control::GetIndexForPoint; 225 long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const; 226 void SetMpSubEditAccessibleName(String &aName); 227 }; 228 229 #endif // _COMBOBOX_HXX 230 231