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_ILSTBOX_HXX 25 #define _SV_ILSTBOX_HXX 26 27 #include <vcl/sv.h> 28 #include <vcl/image.hxx> 29 #include <vcl/ctrl.hxx> 30 #include <vcl/button.hxx> 31 #include <vcl/floatwin.hxx> 32 #include <vcl/lstbox.h> 33 #include <vcl/timer.hxx> 34 35 #include "vcl/quickselectionengine.hxx" 36 37 class ScrollBar; 38 class ScrollBarBox; 39 40 // ----------------- 41 // - ListBox-Types - 42 // ----------------- 43 44 #define HORZ_SCROLL 4 45 #define IMG_TXT_DISTANCE 6 46 47 enum LB_EVENT_TYPE 48 { 49 LET_MBDOWN, 50 LET_TRACKING, 51 LET_TRACKING_END, 52 LET_KEYMOVE, 53 LET_KEYSPACE 54 }; 55 56 // ----------------- 57 // - ImplEntryType - 58 // ----------------- 59 60 struct ImplEntryType 61 { 62 XubString maStr; 63 Image maImage; 64 void* mpUserData; 65 sal_Bool mbIsSelected; 66 long mnFlags; 67 long mnHeight; 68 ImplEntryTypeImplEntryType69 ImplEntryType( const XubString& rStr, const Image& rImage ) : 70 maStr( rStr ), 71 maImage( rImage ), 72 mnFlags( 0 ), 73 mnHeight( 0 ) 74 { 75 mbIsSelected = sal_False; 76 mpUserData = NULL; 77 } 78 ImplEntryTypeImplEntryType79 ImplEntryType( const XubString& rStr ) : 80 maStr( rStr ), 81 mnFlags( 0 ), 82 mnHeight( 0 ) 83 { 84 mbIsSelected = sal_False; 85 mpUserData = NULL; 86 } 87 ImplEntryTypeImplEntryType88 ImplEntryType( const Image& rImage ) : 89 maImage( rImage ), 90 mnFlags( 0 ), 91 mnHeight( 0 ) 92 { 93 mbIsSelected = sal_False; 94 mpUserData = NULL; 95 } 96 }; 97 98 // ----------------- 99 // - ImplEntryList - 100 // ----------------- 101 102 class ImplEntryList : private List 103 { 104 private: 105 Window* mpWindow; // For getting the current locale when matching strings 106 sal_uInt16 mnLastSelected; 107 sal_uInt16 mnSelectionAnchor; 108 sal_uInt16 mnImages; 109 110 sal_uInt16 mnMRUCount; 111 sal_uInt16 mnMaxMRUCount; 112 113 Link maSelectionChangedHdl; 114 sal_Bool mbCallSelectionChangedHdl; 115 GetEntry(sal_uInt16 nPos) const116 ImplEntryType* GetEntry( sal_uInt16 nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); } 117 118 public: 119 ImplEntryList( Window* pWindow ); 120 ~ImplEntryList(); 121 122 sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort ); 123 void RemoveEntry( sal_uInt16 nPos ); GetEntryPtr(sal_uInt16 nPos) const124 const ImplEntryType* GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetObject( nPos ); } GetMutableEntryPtr(sal_uInt16 nPos) const125 ImplEntryType* GetMutableEntryPtr( sal_uInt16 nPos ) const { return (ImplEntryType*) GetObject( nPos ); } 126 void Clear(); 127 128 sal_uInt16 FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart = 0, sal_Bool bForward = sal_True, sal_Bool bLazy = sal_True ) const; 129 sal_uInt16 FindEntry( const XubString& rStr, sal_Bool bSearchMRUArea = sal_False ) const; 130 sal_uInt16 FindEntry( const void* pData ) const; 131 132 // helper: add up heights up to index nEndIndex. 133 // GetAddedHeight( 0 ) returns 0 134 // GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) returns 0 135 // GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i ) 136 long GetAddedHeight( sal_uInt16 nEndIndex, sal_uInt16 nBeginIndex = 0, long nBeginHeight = 0 ) const; 137 long GetEntryHeight( sal_uInt16 nPos ) const; 138 GetEntryCount() const139 sal_uInt16 GetEntryCount() const { return (sal_uInt16)List::Count(); } HasImages() const140 sal_Bool HasImages() const { return mnImages ? sal_True : sal_False; } 141 142 XubString GetEntryText( sal_uInt16 nPos ) const; 143 144 sal_Bool HasEntryImage( sal_uInt16 nPos ) const; 145 Image GetEntryImage( sal_uInt16 nPos ) const; 146 147 void SetEntryData( sal_uInt16 nPos, void* pNewData ); 148 void* GetEntryData( sal_uInt16 nPos ) const; 149 150 void SetEntryFlags( sal_uInt16 nPos, long nFlags ); 151 long GetEntryFlags( sal_uInt16 nPos ) const; 152 153 void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); 154 155 sal_uInt16 GetSelectEntryCount() const; 156 XubString GetSelectEntry( sal_uInt16 nIndex ) const; 157 sal_uInt16 GetSelectEntryPos( sal_uInt16 nIndex ) const; 158 sal_Bool IsEntrySelected( const XubString& rStr ) const; 159 sal_Bool IsEntryPosSelected( sal_uInt16 nIndex ) const; 160 SetLastSelected(sal_uInt16 nPos)161 void SetLastSelected( sal_uInt16 nPos ) { mnLastSelected = nPos; } GetLastSelected() const162 sal_uInt16 GetLastSelected() const { return mnLastSelected; } 163 SetSelectionAnchor(sal_uInt16 nPos)164 void SetSelectionAnchor( sal_uInt16 nPos ) { mnSelectionAnchor = nPos; } GetSelectionAnchor() const165 sal_uInt16 GetSelectionAnchor() const { return mnSelectionAnchor; } 166 167 SetSelectionChangedHdl(const Link & rLnk)168 void SetSelectionChangedHdl( const Link& rLnk ) { maSelectionChangedHdl = rLnk; } SetCallSelectionChangedHdl(sal_Bool bCall)169 void SetCallSelectionChangedHdl( sal_Bool bCall ) { mbCallSelectionChangedHdl = bCall; } 170 SetMRUCount(sal_uInt16 n)171 void SetMRUCount( sal_uInt16 n ) { mnMRUCount = n; } GetMRUCount() const172 sal_uInt16 GetMRUCount() const { return mnMRUCount; } 173 SetMaxMRUCount(sal_uInt16 n)174 void SetMaxMRUCount( sal_uInt16 n ) { mnMaxMRUCount = n; } GetMaxMRUCount() const175 sal_uInt16 GetMaxMRUCount() const { return mnMaxMRUCount; } 176 177 /** An Entry is selectable if its mnFlags does not have the 178 LISTBOX_ENTRY_FLAG_DISABLE_SELECTION flag set. */ 179 bool IsEntrySelectable( sal_uInt16 nPos ) const; 180 181 /** returns the first entry found from the given position nPos that is selectable 182 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable, 183 it returns the first selectable entry after nPos if bForward is true and the 184 first selectable entry after nPos is bForward is false. 185 */ 186 sal_uInt16 FindFirstSelectable( sal_uInt16 nPos, bool bForward = true ); 187 }; 188 189 // --------------------- 190 // - ImplListBoxWindow - 191 // --------------------- 192 193 class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList 194 { 195 private: 196 ImplEntryList* mpEntryList; // EntryListe 197 Rectangle maFocusRect; 198 199 Size maUserItemSize; 200 201 long mnMaxTxtHeight; // Maximale Hoehe eines Text-Items 202 long mnMaxTxtWidth; // Maximale Breite eines Text-Items 203 // Entry ohne Image 204 long mnMaxImgTxtWidth;// Maximale Breite eines Text-Items 205 // Entry UND Image 206 long mnMaxImgWidth; // Maximale Breite eines Image-Items 207 long mnMaxImgHeight; // Maximale Hoehe eines Image-Items 208 long mnMaxWidth; // Maximale Breite eines Eintrags 209 long mnMaxHeight; // Maximale Hoehe eines Eintrags 210 211 sal_uInt16 mnCurrentPos; // Position (Focus) 212 sal_uInt16 mnTrackingSaveSelection; // Selektion vor Tracking(); 213 214 sal_uInt16 mnSeparatorPos; // Separator 215 216 sal_uInt16 mnUserDrawEntry; 217 218 sal_uInt16 mnTop; // Ausgabe ab Zeile 219 long mnLeft; // Ausgabe ab Spalte 220 long mnBorder; // Abstand Rahmen - Text 221 long mnTextHeight; // Texthoehe 222 ProminentEntry meProminentType; // where is the "prominent" entry 223 224 sal_uInt16 mnSelectModifier; // Modifiers 225 226 /// bitfield 227 bool mbHasFocusRect : 1; 228 bool mbSort : 1; // ListBox sortiert 229 bool mbTrack : 1; // Tracking 230 bool mbMulti : 1; // MultiListBox 231 bool mbStackMode : 1; // StackSelection 232 bool mbSimpleMode : 1; // SimpleMode fuer MultiListBox 233 bool mbImgsDiffSz : 1; // Images haben verschiedene Groessen 234 bool mbTravelSelect : 1; // TravelSelect 235 bool mbTrackingSelect : 1; // Selektiert bei MouseMove 236 bool mbSelectionChanged : 1; // Select() nicht zu oft rufen... 237 bool mbMouseMoveSelect : 1; // Selektieren bei MouseMove 238 bool mbGrabFocus : 1; // Focus bei MBDown grabben 239 bool mbUserDrawEnabled : 1; // UserDraw possible 240 bool mbInUserDraw : 1; // In UserDraw 241 bool mbReadOnly : 1; // ReadOnly 242 bool mbMirroring : 1; // pb: #106948# explicit mirroring for calc 243 bool mbRight : 1; // right align Text output 244 bool mbCenter : 1; // center Text output 245 bool mbEdgeBlending : 1; 246 247 Link maScrollHdl; 248 Link maSelectHdl; 249 Link maCancelHdl; 250 Link maDoubleClickHdl; 251 Link maUserDrawHdl; 252 Link maMRUChangedHdl; 253 Link maFocusHdl; 254 Link maListItemSelectHdl; 255 256 ::vcl::QuickSelectionEngine maQuickSelectionEngine; 257 258 protected: 259 virtual void KeyInput( const KeyEvent& rKEvt ); 260 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 261 virtual void MouseMove( const MouseEvent& rMEvt ); 262 virtual void Tracking( const TrackingEvent& rTEvt ); 263 virtual void Paint( const Rectangle& rRect ); 264 virtual void Resize(); 265 virtual void GetFocus(); 266 virtual void LoseFocus(); 267 268 //sal_Bool SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False ); 269 sal_Bool SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False, sal_Bool bSelectPosChange = sal_False ); 270 void ImplPaint( sal_uInt16 nPos, sal_Bool bErase = sal_False, bool bLayout = false ); 271 void ImplDoPaint( const Rectangle& rRect, bool bLayout = false ); 272 void ImplCalcMetrics(); 273 void ImplUpdateEntryMetrics( ImplEntryType& rEntry ); 274 void ImplCallSelect(); 275 276 void ImplShowFocusRect(); 277 void ImplHideFocusRect(); 278 279 280 virtual void StateChanged( StateChangedType nType ); 281 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 282 283 public: 284 virtual void FillLayoutData() const; 285 286 ImplListBoxWindow( Window* pParent, WinBits nWinStyle ); 287 ~ImplListBoxWindow(); 288 GetEntryList() const289 ImplEntryList* GetEntryList() const { return mpEntryList; } 290 291 sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry ); 292 void RemoveEntry( sal_uInt16 nPos ); 293 void Clear(); ResetCurrentPos()294 void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; } GetCurrentPos() const295 sal_uInt16 GetCurrentPos() const { return mnCurrentPos; } 296 sal_uInt16 GetDisplayLineCount() const; 297 void SetEntryFlags( sal_uInt16 nPos, long nFlags ); 298 299 void DrawEntry( sal_uInt16 nPos, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); 300 301 void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); 302 void DeselectAll(); 303 sal_uInt16 GetEntryPosForPoint( const Point& rPoint ) const; 304 sal_uInt16 GetLastVisibleEntry() const; 305 306 sal_Bool ProcessKeyInput( const KeyEvent& rKEvt ); 307 308 void SetTopEntry( sal_uInt16 nTop ); GetTopEntry() const309 sal_uInt16 GetTopEntry() const { return mnTop; } 310 // ShowProminentEntry will set the entry correspoding to nEntryPos 311 // either at top or in the middle depending on the chosen style 312 void ShowProminentEntry( sal_uInt16 nEntryPos ); SetProminentEntryType(ProminentEntry eType)313 void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; } GetProminentEntryType() const314 ProminentEntry GetProminentEntryType() const { return meProminentType; } 315 using Window::IsVisible; 316 sal_Bool IsVisible( sal_uInt16 nEntry ) const; 317 GetLeftIndent() const318 long GetLeftIndent() const { return mnLeft; } 319 void SetLeftIndent( long n ); 320 void ScrollHorz( long nDiff ); 321 AllowGrabFocus(bool b)322 void AllowGrabFocus( bool b ) { mbGrabFocus = b; } IsGrabFocusAllowed() const323 bool IsGrabFocusAllowed() const { return mbGrabFocus; } 324 SetSeparatorPos(sal_uInt16 n)325 void SetSeparatorPos( sal_uInt16 n ) { mnSeparatorPos = n; } GetSeparatorPos() const326 sal_uInt16 GetSeparatorPos() const { return mnSeparatorPos; } 327 SetTravelSelect(bool bTravelSelect)328 void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; } IsTravelSelect() const329 bool IsTravelSelect() const { return mbTravelSelect; } IsTrackingSelect() const330 bool IsTrackingSelect() const { return mbTrackingSelect; } 331 332 void SetUserItemSize( const Size& rSz ); GetUserItemSize() const333 const Size& GetUserItemSize() const { return maUserItemSize; } 334 EnableUserDraw(bool bUserDraw)335 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } IsUserDrawEnabled() const336 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } 337 EnableMultiSelection(bool bMulti,bool bStackMode)338 void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; } IsMultiSelectionEnabled() const339 bool IsMultiSelectionEnabled() const { return mbMulti; } 340 SetMultiSelectionSimpleMode(bool bSimple)341 void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; } IsMultiSelectionSimpleMode() const342 bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; } 343 EnableMouseMoveSelect(bool bMouseMoveSelect)344 void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; } IsMouseMoveSelectEnabled() const345 bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; } IsMouseMoveSelect() const346 bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; } 347 348 Size CalcSize( sal_uInt16 nMaxLines ) const; 349 Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; 350 GetEntryHeight() const351 long GetEntryHeight() const { return mnMaxHeight; } GetMaxEntryWidth() const352 long GetMaxEntryWidth() const { return mnMaxWidth; } 353 SetScrollHdl(const Link & rLink)354 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } GetScrollHdl() const355 const Link& GetScrollHdl() const { return maScrollHdl; } SetSelectHdl(const Link & rLink)356 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } GetSelectHdl() const357 const Link& GetSelectHdl() const { return maSelectHdl; } SetCancelHdl(const Link & rLink)358 void SetCancelHdl( const Link& rLink ) { maCancelHdl = rLink; } GetCancelHdl() const359 const Link& GetCancelHdl() const { return maCancelHdl; } SetDoubleClickHdl(const Link & rLink)360 void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } GetDoubleClickHdl() const361 const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } SetUserDrawHdl(const Link & rLink)362 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } GetUserDrawHdl() const363 const Link& GetUserDrawHdl() const { return maUserDrawHdl; } SetMRUChangedHdl(const Link & rLink)364 void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; } GetMRUChangedHdl() const365 const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; } SetFocusHdl(const Link & rLink)366 void SetFocusHdl( const Link& rLink ) { maFocusHdl = rLink ; } GetFocusHdl() const367 const Link& GetFocusHdl() const { return maFocusHdl; } 368 SetListItemSelectHdl(const Link & rLink)369 void SetListItemSelectHdl( const Link& rLink ) { maListItemSelectHdl = rLink ; } GetListItemSelectHdl() const370 const Link& GetListItemSelectHdl() const { return maListItemSelectHdl; } IsSelectionChanged() const371 bool IsSelectionChanged() const { return mbSelectionChanged; } GetSelectModifier() const372 sal_uInt16 GetSelectModifier() const { return mnSelectModifier; } 373 EnableSort(bool b)374 void EnableSort( bool b ) { mbSort = b; } 375 SetReadOnly(bool bReadOnly)376 void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; } IsReadOnly() const377 bool IsReadOnly() const { return mbReadOnly; } 378 379 using Control::ImplInitSettings; 380 void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); 381 sal_uInt16 ImplGetTextStyle() const; 382 383 // pb: #106948# explicit mirroring for calc EnableMirroring()384 inline void EnableMirroring() { mbMirroring = true; } IsMirroring() const385 inline bool IsMirroring() const { return mbMirroring; } 386 GetEdgeBlending() const387 bool GetEdgeBlending() const { return mbEdgeBlending; } SetEdgeBlending(bool bNew)388 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } 389 390 protected: 391 // ISearchableStringList 392 virtual ::vcl::StringEntryIdentifier CurrentEntry( String& _out_entryText ) const; 393 virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const; 394 virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry ); 395 }; 396 397 // --------------- 398 // - ImplListBox - 399 // --------------- 400 401 class ImplListBox : public Control 402 { 403 private: 404 ImplListBoxWindow maLBWindow; 405 ScrollBar* mpHScrollBar; 406 ScrollBar* mpVScrollBar; 407 ScrollBarBox* mpScrollBarBox; 408 409 /// bitfield 410 bool mbVScroll : 1; // VScroll an oder aus 411 bool mbHScroll : 1; // HScroll an oder aus 412 bool mbAutoHScroll : 1; // AutoHScroll an oder aus 413 bool mbEdgeBlending : 1; 414 415 Link maScrollHdl; // Weil der vom ImplListBoxWindow selbst benoetigt wird. 416 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; 417 418 protected: 419 virtual void GetFocus(); 420 virtual void StateChanged( StateChangedType nType ); 421 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 422 423 long Notify( NotifyEvent& rNEvt ); 424 425 void ImplResizeControls(); 426 void ImplCheckScrollBars(); 427 void ImplInitScrollBars(); 428 429 DECL_LINK( ScrollBarHdl, ScrollBar* ); 430 DECL_LINK( LBWindowScrolled, void* ); 431 DECL_LINK( MRUChanged, void* ); 432 433 public: 434 ImplListBox( Window* pParent, WinBits nWinStyle ); 435 ~ImplListBox(); 436 GetEntryList() const437 const ImplEntryList* GetEntryList() const { return maLBWindow.GetEntryList(); } GetMainWindow()438 ImplListBoxWindow* GetMainWindow() { return &maLBWindow; } 439 440 virtual void Resize(); 441 virtual const Wallpaper& GetDisplayBackground() const; 442 virtual Window* GetPreferredKeyInputWindow(); 443 444 sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr ); 445 sal_uInt16 InsertEntry( sal_uInt16 nPos, const Image& rImage ); 446 sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr, const Image& rImage ); 447 void RemoveEntry( sal_uInt16 nPos ); SetEntryData(sal_uInt16 nPos,void * pNewData)448 void SetEntryData( sal_uInt16 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); } 449 void Clear(); 450 451 void SetEntryFlags( sal_uInt16 nPos, long nFlags ); 452 long GetEntryFlags( sal_uInt16 nPos ) const; 453 454 void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); 455 void SetNoSelection(); ResetCurrentPos()456 void ResetCurrentPos() { maLBWindow.ResetCurrentPos(); } GetCurrentPos() const457 sal_uInt16 GetCurrentPos() const { return maLBWindow.GetCurrentPos(); } 458 ProcessKeyInput(const KeyEvent & rKEvt)459 sal_Bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow.ProcessKeyInput( rKEvt ); } 460 sal_Bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt ); 461 SetSeparatorPos(sal_uInt16 n)462 void SetSeparatorPos( sal_uInt16 n ) { maLBWindow.SetSeparatorPos( n ); } GetSeparatorPos() const463 sal_uInt16 GetSeparatorPos() const { return maLBWindow.GetSeparatorPos(); } 464 SetTopEntry(sal_uInt16 nTop)465 void SetTopEntry( sal_uInt16 nTop ) { maLBWindow.SetTopEntry( nTop ); } GetTopEntry() const466 sal_uInt16 GetTopEntry() const { return maLBWindow.GetTopEntry(); } ShowProminentEntry(sal_uInt16 nPos)467 void ShowProminentEntry( sal_uInt16 nPos ) { maLBWindow.ShowProminentEntry( nPos ); } 468 using Window::IsVisible; IsVisible(sal_uInt16 nEntry) const469 sal_Bool IsVisible( sal_uInt16 nEntry ) const { return maLBWindow.IsVisible( nEntry ); } 470 SetProminentEntryType(ProminentEntry eType)471 void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); } GetProminentEntryType() const472 ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); } 473 GetLeftIndent() const474 long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); } SetLeftIndent(sal_uInt16 n)475 void SetLeftIndent( sal_uInt16 n ) { maLBWindow.SetLeftIndent( n ); } ScrollHorz(short nDiff)476 void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); } 477 SetTravelSelect(sal_Bool bTravelSelect)478 void SetTravelSelect( sal_Bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); } IsTravelSelect() const479 sal_Bool IsTravelSelect() const { return maLBWindow.IsTravelSelect(); } IsTrackingSelect() const480 sal_Bool IsTrackingSelect() const { return maLBWindow.IsTrackingSelect(); } 481 EnableMultiSelection(sal_Bool bMulti,sal_Bool bStackMode)482 void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); } IsMultiSelectionEnabled() const483 sal_Bool IsMultiSelectionEnabled() const { return maLBWindow.IsMultiSelectionEnabled(); } 484 SetMultiSelectionSimpleMode(sal_Bool bSimple)485 void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); } IsMultiSelectionSimpleMode() const486 sal_Bool IsMultiSelectionSimpleMode() const { return maLBWindow.IsMultiSelectionSimpleMode(); } 487 SetReadOnly(sal_Bool b)488 void SetReadOnly( sal_Bool b ) { maLBWindow.SetReadOnly( b ); } IsReadOnly() const489 sal_Bool IsReadOnly() const { return maLBWindow.IsReadOnly(); } 490 491 CalcSize(sal_uInt16 nMaxLines) const492 Size CalcSize( sal_uInt16 nMaxLines ) const { return maLBWindow.CalcSize( nMaxLines ); } GetEntryHeight() const493 long GetEntryHeight() const { return maLBWindow.GetEntryHeight(); } GetMaxEntryWidth() const494 long GetMaxEntryWidth() const { return maLBWindow.GetMaxEntryWidth(); } 495 SetScrollHdl(const Link & rLink)496 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } GetScrollHdl() const497 const Link& GetScrollHdl() const { return maScrollHdl; } SetSelectHdl(const Link & rLink)498 void SetSelectHdl( const Link& rLink ) { maLBWindow.SetSelectHdl( rLink ); } GetSelectHdl() const499 const Link& GetSelectHdl() const { return maLBWindow.GetSelectHdl(); } SetCancelHdl(const Link & rLink)500 void SetCancelHdl( const Link& rLink ) { maLBWindow.SetCancelHdl( rLink ); } GetCancelHdl() const501 const Link& GetCancelHdl() const { return maLBWindow.GetCancelHdl(); } SetDoubleClickHdl(const Link & rLink)502 void SetDoubleClickHdl( const Link& rLink ) { maLBWindow.SetDoubleClickHdl( rLink ); } GetDoubleClickHdl() const503 const Link& GetDoubleClickHdl() const { return maLBWindow.GetDoubleClickHdl(); } SetUserDrawHdl(const Link & rLink)504 void SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); } GetUserDrawHdl() const505 const Link& GetUserDrawHdl() const { return maLBWindow.GetUserDrawHdl(); } 506 SetFocusHdl(const Link & rLink)507 void SetFocusHdl( const Link& rLink ) { maLBWindow.SetFocusHdl( rLink ); } GetFocusHdl() const508 const Link& GetFocusHdl() const { return maLBWindow.GetFocusHdl(); } SetListItemSelectHdl(const Link & rLink)509 void SetListItemSelectHdl( const Link& rLink ) { maLBWindow.SetListItemSelectHdl( rLink ); } GetListItemSelectHdl() const510 const Link& GetListItemSelectHdl() const { return maLBWindow.GetListItemSelectHdl(); } SetSelectionChangedHdl(const Link & rLnk)511 void SetSelectionChangedHdl( const Link& rLnk ) { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); } SetCallSelectionChangedHdl(sal_Bool bCall)512 void SetCallSelectionChangedHdl( sal_Bool bCall ) { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); } IsSelectionChanged() const513 sal_Bool IsSelectionChanged() const { return maLBWindow.IsSelectionChanged(); } GetSelectModifier() const514 sal_uInt16 GetSelectModifier() const { return maLBWindow.GetSelectModifier(); } 515 516 void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep ); 517 XubString GetMRUEntries( xub_Unicode cSep ) const; SetMaxMRUCount(sal_uInt16 n)518 void SetMaxMRUCount( sal_uInt16 n ) { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); } GetMaxMRUCount() const519 sal_uInt16 GetMaxMRUCount() const { return maLBWindow.GetEntryList()->GetMaxMRUCount(); } GetDisplayLineCount() const520 sal_uInt16 GetDisplayLineCount() const 521 { return maLBWindow.GetDisplayLineCount(); } 522 GetEdgeBlending() const523 bool GetEdgeBlending() const { return mbEdgeBlending; } 524 void SetEdgeBlending(bool bNew); 525 526 // pb: #106948# explicit mirroring for calc EnableMirroring()527 inline void EnableMirroring() { maLBWindow.EnableMirroring(); } SetDropTraget(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & i_xDNDListenerContainer)528 inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; } 529 }; 530 531 // ----------------------------- 532 // - ImplListBoxFloatingWindow - 533 // ----------------------------- 534 535 class ImplListBoxFloatingWindow : public FloatingWindow 536 { 537 private: 538 ImplListBox* mpImplLB; 539 Size maPrefSz; 540 sal_uInt16 mnDDLineCount; 541 sal_uInt16 mnPopupModeStartSaveSelection; 542 sal_Bool mbAutoWidth; 543 544 protected: 545 long PreNotify( NotifyEvent& rNEvt ); 546 547 public: 548 ImplListBoxFloatingWindow( Window* pParent ); 549 SetImplListBox(ImplListBox * pLB)550 void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; } 551 SetPrefSize(const Size & rSz)552 void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; } GetPrefSize() const553 const Size& GetPrefSize() const { return maPrefSz; } 554 SetAutoWidth(sal_Bool b)555 void SetAutoWidth( sal_Bool b ) { mbAutoWidth = b; } IsAutoWidth() const556 sal_Bool IsAutoWidth() const { return mbAutoWidth; } 557 558 Size CalcFloatSize(); 559 void StartFloat( sal_Bool bStartTracking ); 560 561 virtual void SetPosSizePixel( long nX, long nY, 562 long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); SetPosSizePixel(const Point & rNewPos,const Size & rNewSize)563 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) 564 { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); } 565 SetDropDownLineCount(sal_uInt16 n)566 void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; } GetDropDownLineCount() const567 sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; } 568 GetPopupModeStartSaveSelection() const569 sal_uInt16 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; } 570 571 virtual void Resize(); 572 }; 573 574 // ----------- 575 // - ImplWin - 576 // ----------- 577 578 class ImplWin : public Control 579 { 580 private: 581 582 sal_uInt16 mnItemPos; // wegen UserDraw muss ich wissen, welches Item ich darstelle. 583 XubString maString; 584 Image maImage; 585 Image maImageHC; 586 587 Rectangle maFocusRect; 588 Size maUserItemSize; 589 590 Link maMBDownHdl; 591 Link maUserDrawHdl; 592 593 /// bitfield 594 bool mbUserDrawEnabled : 1; 595 bool mbInUserDraw : 1; 596 bool mbEdgeBlending : 1; 597 598 void ImplDraw( bool bLayout = false ); 599 protected: 600 virtual void FillLayoutData() const; 601 public: 602 603 ImplWin( Window* pParent, WinBits nWinStyle = 0 ); ~ImplWin()604 ~ImplWin() {}; 605 606 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 607 virtual void Paint( const Rectangle& rRect ); 608 virtual void Resize(); 609 virtual void GetFocus(); 610 virtual void LoseFocus(); 611 virtual long PreNotify( NotifyEvent& rNEvt ); 612 GetItemPos() const613 sal_uInt16 GetItemPos() const { return mnItemPos; } SetItemPos(sal_uInt16 n)614 void SetItemPos( sal_uInt16 n ) { mnItemPos = n; } 615 GetString() const616 const XubString& GetString() const { return maString; } SetString(const XubString & rStr)617 void SetString( const XubString& rStr ) { maString = rStr; } 618 GetImage() const619 const Image& GetImage() const { return maImage; } SetImage(const Image & rImg)620 void SetImage( const Image& rImg ) { maImage = rImg; } 621 622 sal_Bool SetModeImage( const Image& rImage, BmpColorMode eMode = BMP_COLOR_NORMAL ); 623 const Image& GetModeImage( BmpColorMode eMode = BMP_COLOR_NORMAL ) const; 624 625 626 virtual void MBDown(); SetMBDownHdl(const Link & rLink)627 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } GetMBDownHdl() const628 const Link& GetMBDownHdl() const { return maMBDownHdl; } 629 SetUserDrawHdl(const Link & rLink)630 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } GetUserDrawHdl() const631 const Link& GetUserDrawHdl() const { return maUserDrawHdl; } 632 SetUserItemSize(const Size & rSz)633 void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; } GetUserItemSize() const634 const Size& GetUserItemSize() const { return maUserItemSize; } 635 EnableUserDraw(bool bUserDraw)636 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } IsUserDrawEnabled() const637 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } 638 639 void DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); 640 GetEdgeBlending() const641 bool GetEdgeBlending() const { return mbEdgeBlending; } SetEdgeBlending(bool bNew)642 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } 643 }; 644 645 // ----------- 646 // - ImplBtn - 647 // ----------- 648 649 class ImplBtn : public PushButton 650 { 651 private: 652 sal_Bool mbDown; 653 654 Link maMBDownHdl; 655 656 public: 657 ImplBtn( Window* pParent, WinBits nWinStyle = 0 ); ~ImplBtn()658 ~ImplBtn() {}; 659 660 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 661 662 virtual void MBDown(); SetMBDownHdl(const Link & rLink)663 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } GetMBDownHdl() const664 const Link& GetMBDownHdl() const { return maMBDownHdl; } 665 }; 666 667 668 void ImplInitFieldSettings( Window* pWin, sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); 669 void ImplInitDropDownButton( PushButton* pButton ); 670 671 #endif // _SV_ILSTBOX_HXX 672