1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_ILSTBOX_HXX 29 #define _SV_ILSTBOX_HXX 30 31 #include <vcl/sv.h> 32 #include <vcl/image.hxx> 33 #include <vcl/ctrl.hxx> 34 #include <vcl/button.hxx> 35 #include <vcl/floatwin.hxx> 36 #include <vcl/lstbox.h> 37 #include <vcl/timer.hxx> 38 39 #include "vcl/quickselectionengine.hxx" 40 41 class ScrollBar; 42 class ScrollBarBox; 43 44 // ----------------- 45 // - ListBox-Types - 46 // ----------------- 47 48 #define HORZ_SCROLL 4 49 #define IMG_TXT_DISTANCE 6 50 51 enum LB_EVENT_TYPE 52 { 53 LET_MBDOWN, 54 LET_TRACKING, 55 LET_TRACKING_END, 56 LET_KEYMOVE, 57 LET_KEYSPACE 58 }; 59 60 // ----------------- 61 // - ImplEntryType - 62 // ----------------- 63 64 struct ImplEntryType 65 { 66 XubString maStr; 67 Image maImage; 68 void* mpUserData; 69 sal_Bool mbIsSelected; 70 long mnFlags; 71 long mnHeight; 72 73 ImplEntryType( const XubString& rStr, const Image& rImage ) : 74 maStr( rStr ), 75 maImage( rImage ), 76 mnFlags( 0 ), 77 mnHeight( 0 ) 78 { 79 mbIsSelected = sal_False; 80 mpUserData = NULL; 81 } 82 83 ImplEntryType( const XubString& rStr ) : 84 maStr( rStr ), 85 mnFlags( 0 ), 86 mnHeight( 0 ) 87 { 88 mbIsSelected = sal_False; 89 mpUserData = NULL; 90 } 91 92 ImplEntryType( const Image& rImage ) : 93 maImage( rImage ), 94 mnFlags( 0 ), 95 mnHeight( 0 ) 96 { 97 mbIsSelected = sal_False; 98 mpUserData = NULL; 99 } 100 }; 101 102 // ----------------- 103 // - ImplEntryList - 104 // ----------------- 105 106 class ImplEntryList : private List 107 { 108 private: 109 Window* mpWindow; // For getting the current locale when matching strings 110 sal_uInt16 mnLastSelected; 111 sal_uInt16 mnSelectionAnchor; 112 sal_uInt16 mnImages; 113 114 sal_uInt16 mnMRUCount; 115 sal_uInt16 mnMaxMRUCount; 116 117 Link maSelectionChangedHdl; 118 sal_Bool mbCallSelectionChangedHdl; 119 120 ImplEntryType* GetEntry( sal_uInt16 nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); } 121 122 public: 123 ImplEntryList( Window* pWindow ); 124 ~ImplEntryList(); 125 126 sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort ); 127 void RemoveEntry( sal_uInt16 nPos ); 128 const ImplEntryType* GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetObject( nPos ); } 129 ImplEntryType* GetMutableEntryPtr( sal_uInt16 nPos ) const { return (ImplEntryType*) GetObject( nPos ); } 130 void Clear(); 131 132 sal_uInt16 FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart = 0, sal_Bool bForward = sal_True, sal_Bool bLazy = sal_True ) const; 133 sal_uInt16 FindEntry( const XubString& rStr, sal_Bool bSearchMRUArea = sal_False ) const; 134 sal_uInt16 FindEntry( const void* pData ) const; 135 136 // helper: add up heights up to index nEndIndex. 137 // GetAddedHeight( 0 ) returns 0 138 // GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) returns 0 139 // GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i ) 140 long GetAddedHeight( sal_uInt16 nEndIndex, sal_uInt16 nBeginIndex = 0, long nBeginHeight = 0 ) const; 141 long GetEntryHeight( sal_uInt16 nPos ) const; 142 143 sal_uInt16 GetEntryCount() const { return (sal_uInt16)List::Count(); } 144 sal_Bool HasImages() const { return mnImages ? sal_True : sal_False; } 145 146 XubString GetEntryText( sal_uInt16 nPos ) const; 147 148 sal_Bool HasEntryImage( sal_uInt16 nPos ) const; 149 Image GetEntryImage( sal_uInt16 nPos ) const; 150 151 void SetEntryData( sal_uInt16 nPos, void* pNewData ); 152 void* GetEntryData( sal_uInt16 nPos ) const; 153 154 void SetEntryFlags( sal_uInt16 nPos, long nFlags ); 155 long GetEntryFlags( sal_uInt16 nPos ) const; 156 157 void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); 158 159 sal_uInt16 GetSelectEntryCount() const; 160 XubString GetSelectEntry( sal_uInt16 nIndex ) const; 161 sal_uInt16 GetSelectEntryPos( sal_uInt16 nIndex ) const; 162 sal_Bool IsEntrySelected( const XubString& rStr ) const; 163 sal_Bool IsEntryPosSelected( sal_uInt16 nIndex ) const; 164 165 void SetLastSelected( sal_uInt16 nPos ) { mnLastSelected = nPos; } 166 sal_uInt16 GetLastSelected() const { return mnLastSelected; } 167 168 void SetSelectionAnchor( sal_uInt16 nPos ) { mnSelectionAnchor = nPos; } 169 sal_uInt16 GetSelectionAnchor() const { return mnSelectionAnchor; } 170 171 172 void SetSelectionChangedHdl( const Link& rLnk ) { maSelectionChangedHdl = rLnk; } 173 void SetCallSelectionChangedHdl( sal_Bool bCall ) { mbCallSelectionChangedHdl = bCall; } 174 175 void SetMRUCount( sal_uInt16 n ) { mnMRUCount = n; } 176 sal_uInt16 GetMRUCount() const { return mnMRUCount; } 177 178 void SetMaxMRUCount( sal_uInt16 n ) { mnMaxMRUCount = n; } 179 sal_uInt16 GetMaxMRUCount() const { return mnMaxMRUCount; } 180 181 /** An Entry is selectable if its mnFlags does not have the 182 LISTBOX_ENTRY_FLAG_DISABLE_SELECTION flag set. */ 183 bool IsEntrySelectable( sal_uInt16 nPos ) const; 184 185 /** returns the first entry found from the given position nPos that is selectable 186 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable, 187 it returns the first selectable entry after nPos if bForward is true and the 188 first selectable entry after nPos is bForward is false. 189 */ 190 sal_uInt16 FindFirstSelectable( sal_uInt16 nPos, bool bForward = true ); 191 }; 192 193 // --------------------- 194 // - ImplListBoxWindow - 195 // --------------------- 196 197 class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList 198 { 199 private: 200 ImplEntryList* mpEntryList; // EntryListe 201 Rectangle maFocusRect; 202 203 Size maUserItemSize; 204 205 long mnMaxTxtHeight; // Maximale Hoehe eines Text-Items 206 long mnMaxTxtWidth; // Maximale Breite eines Text-Items 207 // Entry ohne Image 208 long mnMaxImgTxtWidth;// Maximale Breite eines Text-Items 209 // Entry UND Image 210 long mnMaxImgWidth; // Maximale Breite eines Image-Items 211 long mnMaxImgHeight; // Maximale Hoehe eines Image-Items 212 long mnMaxWidth; // Maximale Breite eines Eintrags 213 long mnMaxHeight; // Maximale Hoehe eines Eintrags 214 215 sal_uInt16 mnCurrentPos; // Position (Focus) 216 sal_uInt16 mnTrackingSaveSelection; // Selektion vor Tracking(); 217 218 sal_uInt16 mnSeparatorPos; // Separator 219 220 sal_uInt16 mnUserDrawEntry; 221 222 sal_uInt16 mnTop; // Ausgabe ab Zeile 223 long mnLeft; // Ausgabe ab Spalte 224 long mnBorder; // Abstand Rahmen - Text 225 long mnTextHeight; // Texthoehe 226 ProminentEntry meProminentType; // where is the "prominent" entry 227 228 sal_uInt16 mnSelectModifier; // Modifiers 229 230 sal_Bool mbHasFocusRect: 1, 231 mbSort: 1, // ListBox sortiert 232 mbTrack: 1, // Tracking 233 mbMulti: 1, // MultiListBox 234 mbStackMode: 1, // StackSelection 235 mbSimpleMode: 1, // SimpleMode fuer MultiListBox 236 mbImgsDiffSz: 1, // Images haben verschiedene Groessen 237 mbTravelSelect: 1, // TravelSelect 238 mbTrackingSelect: 1, // Selektiert bei MouseMove 239 mbSelectionChanged: 1, // Select() nicht zu oft rufen... 240 mbMouseMoveSelect: 1, // Selektieren bei MouseMove 241 mbGrabFocus: 1, // Focus bei MBDown grabben 242 mbUserDrawEnabled: 1, // UserDraw possible 243 mbInUserDraw: 1, // In UserDraw 244 mbReadOnly: 1, // ReadOnly 245 mbMirroring: 1, // pb: #106948# explicit mirroring for calc 246 mbRight: 1, // right align Text output 247 mbCenter: 1; // center Text output 248 249 Link maScrollHdl; 250 Link maSelectHdl; 251 Link maCancelHdl; 252 Link maDoubleClickHdl; 253 Link maUserDrawHdl; 254 Link maMRUChangedHdl; 255 256 ::vcl::QuickSelectionEngine 257 maQuickSelectionEngine; 258 259 protected: 260 virtual void KeyInput( const KeyEvent& rKEvt ); 261 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 262 virtual void MouseMove( const MouseEvent& rMEvt ); 263 virtual void Tracking( const TrackingEvent& rTEvt ); 264 virtual void Paint( const Rectangle& rRect ); 265 virtual void Resize(); 266 virtual void GetFocus(); 267 virtual void LoseFocus(); 268 269 sal_Bool SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = 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 289 ImplEntryList* GetEntryList() const { return mpEntryList; } 290 291 sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry ); 292 void RemoveEntry( sal_uInt16 nPos ); 293 void Clear(); 294 void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; } 295 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 ); 309 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 ); 313 void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; } 314 ProminentEntry GetProminentEntryType() const { return meProminentType; } 315 using Window::IsVisible; 316 sal_Bool IsVisible( sal_uInt16 nEntry ) const; 317 318 long GetLeftIndent() const { return mnLeft; } 319 void SetLeftIndent( long n ); 320 void ScrollHorz( long nDiff ); 321 322 void AllowGrabFocus( sal_Bool b ) { mbGrabFocus = b; } 323 sal_Bool IsGrabFocusAllowed() const { return mbGrabFocus; } 324 325 void SetSeparatorPos( sal_uInt16 n ) { mnSeparatorPos = n; } 326 sal_uInt16 GetSeparatorPos() const { return mnSeparatorPos; } 327 328 void SetTravelSelect( sal_Bool bTravelSelect ) { mbTravelSelect = bTravelSelect; } 329 sal_Bool IsTravelSelect() const { return mbTravelSelect; } 330 sal_Bool IsTrackingSelect() const { return mbTrackingSelect; } 331 332 void SetUserItemSize( const Size& rSz ); 333 const Size& GetUserItemSize() const { return maUserItemSize; } 334 335 void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } 336 sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } 337 338 void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; } 339 sal_Bool IsMultiSelectionEnabled() const { return mbMulti; } 340 341 void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { mbSimpleMode = bSimple; } 342 sal_Bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; } 343 344 void EnableMouseMoveSelect( sal_Bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; } 345 sal_Bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; } 346 sal_Bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; } 347 348 Size CalcSize( sal_uInt16 nMaxLines ) const; 349 Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; 350 351 long GetEntryHeight() const { return mnMaxHeight; } 352 long GetMaxEntryWidth() const { return mnMaxWidth; } 353 354 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } 355 const Link& GetScrollHdl() const { return maScrollHdl; } 356 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } 357 const Link& GetSelectHdl() const { return maSelectHdl; } 358 void SetCancelHdl( const Link& rLink ) { maCancelHdl = rLink; } 359 const Link& GetCancelHdl() const { return maCancelHdl; } 360 void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } 361 const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } 362 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } 363 const Link& GetUserDrawHdl() const { return maUserDrawHdl; } 364 void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; } 365 const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; } 366 367 sal_Bool IsSelectionChanged() const { return mbSelectionChanged; } 368 sal_uInt16 GetSelectModifier() const { return mnSelectModifier; } 369 370 void EnableSort( sal_Bool b ) { mbSort = b; } 371 372 void SetReadOnly( sal_Bool bReadOnly ) { mbReadOnly = bReadOnly; } 373 sal_Bool IsReadOnly() const { return mbReadOnly; } 374 375 using Control::ImplInitSettings; 376 void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); 377 sal_uInt16 ImplGetTextStyle() const; 378 379 // pb: #106948# explicit mirroring for calc 380 inline void EnableMirroring() { mbMirroring = sal_True; } 381 inline sal_Bool IsMirroring() const { return mbMirroring; } 382 383 protected: 384 // ISearchableStringList 385 virtual ::vcl::StringEntryIdentifier CurrentEntry( String& _out_entryText ) const; 386 virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const; 387 virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry ); 388 }; 389 390 // --------------- 391 // - ImplListBox - 392 // --------------- 393 394 class ImplListBox : public Control 395 { 396 private: 397 ImplListBoxWindow maLBWindow; 398 ScrollBar* mpHScrollBar; 399 ScrollBar* mpVScrollBar; 400 ScrollBarBox* mpScrollBarBox; 401 sal_Bool mbVScroll : 1, // VScroll an oder aus 402 mbHScroll : 1, // HScroll an oder aus 403 mbAutoHScroll : 1; // AutoHScroll an oder aus 404 Link maScrollHdl; // Weil der vom ImplListBoxWindow selbst benoetigt wird. 405 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; 406 407 protected: 408 virtual void GetFocus(); 409 virtual void StateChanged( StateChangedType nType ); 410 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 411 412 long Notify( NotifyEvent& rNEvt ); 413 414 void ImplResizeControls(); 415 void ImplCheckScrollBars(); 416 void ImplInitScrollBars(); 417 418 DECL_LINK( ScrollBarHdl, ScrollBar* ); 419 DECL_LINK( LBWindowScrolled, void* ); 420 DECL_LINK( MRUChanged, void* ); 421 422 public: 423 ImplListBox( Window* pParent, WinBits nWinStyle ); 424 ~ImplListBox(); 425 426 const ImplEntryList* GetEntryList() const { return maLBWindow.GetEntryList(); } 427 ImplListBoxWindow* GetMainWindow() { return &maLBWindow; } 428 429 virtual void Resize(); 430 virtual const Wallpaper& GetDisplayBackground() const; 431 virtual Window* GetPreferredKeyInputWindow(); 432 433 sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr ); 434 sal_uInt16 InsertEntry( sal_uInt16 nPos, const Image& rImage ); 435 sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr, const Image& rImage ); 436 void RemoveEntry( sal_uInt16 nPos ); 437 void SetEntryData( sal_uInt16 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); } 438 void Clear(); 439 440 void SetEntryFlags( sal_uInt16 nPos, long nFlags ); 441 long GetEntryFlags( sal_uInt16 nPos ) const; 442 443 void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); 444 void SetNoSelection(); 445 void ResetCurrentPos() { maLBWindow.ResetCurrentPos(); } 446 sal_uInt16 GetCurrentPos() const { return maLBWindow.GetCurrentPos(); } 447 448 sal_Bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow.ProcessKeyInput( rKEvt ); } 449 sal_Bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt ); 450 451 void SetSeparatorPos( sal_uInt16 n ) { maLBWindow.SetSeparatorPos( n ); } 452 sal_uInt16 GetSeparatorPos() const { return maLBWindow.GetSeparatorPos(); } 453 454 void SetTopEntry( sal_uInt16 nTop ) { maLBWindow.SetTopEntry( nTop ); } 455 sal_uInt16 GetTopEntry() const { return maLBWindow.GetTopEntry(); } 456 void ShowProminentEntry( sal_uInt16 nPos ) { maLBWindow.ShowProminentEntry( nPos ); } 457 using Window::IsVisible; 458 sal_Bool IsVisible( sal_uInt16 nEntry ) const { return maLBWindow.IsVisible( nEntry ); } 459 460 void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); } 461 ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); } 462 463 long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); } 464 void SetLeftIndent( sal_uInt16 n ) { maLBWindow.SetLeftIndent( n ); } 465 void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); } 466 467 void SetTravelSelect( sal_Bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); } 468 sal_Bool IsTravelSelect() const { return maLBWindow.IsTravelSelect(); } 469 sal_Bool IsTrackingSelect() const { return maLBWindow.IsTrackingSelect(); } 470 471 void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); } 472 sal_Bool IsMultiSelectionEnabled() const { return maLBWindow.IsMultiSelectionEnabled(); } 473 474 void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); } 475 sal_Bool IsMultiSelectionSimpleMode() const { return maLBWindow.IsMultiSelectionSimpleMode(); } 476 477 void SetReadOnly( sal_Bool b ) { maLBWindow.SetReadOnly( b ); } 478 sal_Bool IsReadOnly() const { return maLBWindow.IsReadOnly(); } 479 480 481 Size CalcSize( sal_uInt16 nMaxLines ) const { return maLBWindow.CalcSize( nMaxLines ); } 482 long GetEntryHeight() const { return maLBWindow.GetEntryHeight(); } 483 long GetMaxEntryWidth() const { return maLBWindow.GetMaxEntryWidth(); } 484 485 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } 486 const Link& GetScrollHdl() const { return maScrollHdl; } 487 void SetSelectHdl( const Link& rLink ) { maLBWindow.SetSelectHdl( rLink ); } 488 const Link& GetSelectHdl() const { return maLBWindow.GetSelectHdl(); } 489 void SetCancelHdl( const Link& rLink ) { maLBWindow.SetCancelHdl( rLink ); } 490 const Link& GetCancelHdl() const { return maLBWindow.GetCancelHdl(); } 491 void SetDoubleClickHdl( const Link& rLink ) { maLBWindow.SetDoubleClickHdl( rLink ); } 492 const Link& GetDoubleClickHdl() const { return maLBWindow.GetDoubleClickHdl(); } 493 void SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); } 494 const Link& GetUserDrawHdl() const { return maLBWindow.GetUserDrawHdl(); } 495 496 void SetSelectionChangedHdl( const Link& rLnk ) { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); } 497 void SetCallSelectionChangedHdl( sal_Bool bCall ) { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); } 498 sal_Bool IsSelectionChanged() const { return maLBWindow.IsSelectionChanged(); } 499 sal_uInt16 GetSelectModifier() const { return maLBWindow.GetSelectModifier(); } 500 501 void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep ); 502 XubString GetMRUEntries( xub_Unicode cSep ) const; 503 void SetMaxMRUCount( sal_uInt16 n ) { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); } 504 sal_uInt16 GetMaxMRUCount() const { return maLBWindow.GetEntryList()->GetMaxMRUCount(); } 505 sal_uInt16 GetDisplayLineCount() const 506 { return maLBWindow.GetDisplayLineCount(); } 507 508 // pb: #106948# explicit mirroring for calc 509 inline void EnableMirroring() { maLBWindow.EnableMirroring(); } 510 inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; } 511 }; 512 513 // ----------------------------- 514 // - ImplListBoxFloatingWindow - 515 // ----------------------------- 516 517 class ImplListBoxFloatingWindow : public FloatingWindow 518 { 519 private: 520 ImplListBox* mpImplLB; 521 Size maPrefSz; 522 sal_uInt16 mnDDLineCount; 523 sal_uInt16 mnPopupModeStartSaveSelection; 524 sal_Bool mbAutoWidth; 525 526 protected: 527 long PreNotify( NotifyEvent& rNEvt ); 528 529 public: 530 ImplListBoxFloatingWindow( Window* pParent ); 531 532 void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; } 533 534 void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; } 535 const Size& GetPrefSize() const { return maPrefSz; } 536 537 void SetAutoWidth( sal_Bool b ) { mbAutoWidth = b; } 538 sal_Bool IsAutoWidth() const { return mbAutoWidth; } 539 540 Size CalcFloatSize(); 541 void StartFloat( sal_Bool bStartTracking ); 542 543 virtual void SetPosSizePixel( long nX, long nY, 544 long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); 545 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) 546 { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); } 547 548 void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; } 549 sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; } 550 551 sal_uInt16 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; } 552 553 virtual void Resize(); 554 }; 555 556 // ----------- 557 // - ImplWin - 558 // ----------- 559 560 class ImplWin : public Control 561 { 562 private: 563 564 sal_uInt16 mnItemPos; // wegen UserDraw muss ich wissen, welches Item ich darstelle. 565 XubString maString; 566 Image maImage; 567 Image maImageHC; 568 569 Rectangle maFocusRect; 570 Size maUserItemSize; 571 572 Link maMBDownHdl; 573 Link maUserDrawHdl; 574 575 sal_Bool mbUserDrawEnabled : 1, 576 mbInUserDraw : 1; 577 578 579 void ImplDraw( bool bLayout = false ); 580 protected: 581 virtual void FillLayoutData() const; 582 public: 583 584 ImplWin( Window* pParent, WinBits nWinStyle = 0 ); 585 ~ImplWin() {}; 586 587 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 588 virtual void Paint( const Rectangle& rRect ); 589 virtual void Resize(); 590 virtual void GetFocus(); 591 virtual void LoseFocus(); 592 virtual long PreNotify( NotifyEvent& rNEvt ); 593 594 sal_uInt16 GetItemPos() const { return mnItemPos; } 595 void SetItemPos( sal_uInt16 n ) { mnItemPos = n; } 596 597 const XubString& GetString() const { return maString; } 598 void SetString( const XubString& rStr ) { maString = rStr; } 599 600 const Image& GetImage() const { return maImage; } 601 void SetImage( const Image& rImg ) { maImage = rImg; } 602 603 sal_Bool SetModeImage( const Image& rImage, BmpColorMode eMode = BMP_COLOR_NORMAL ); 604 const Image& GetModeImage( BmpColorMode eMode = BMP_COLOR_NORMAL ) const; 605 606 607 virtual void MBDown(); 608 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } 609 const Link& GetMBDownHdl() const { return maMBDownHdl; } 610 611 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } 612 const Link& GetUserDrawHdl() const { return maUserDrawHdl; } 613 614 void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; } 615 const Size& GetUserItemSize() const { return maUserItemSize; } 616 617 void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } 618 sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } 619 620 void DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); 621 }; 622 623 // ----------- 624 // - ImplBtn - 625 // ----------- 626 627 class ImplBtn : public PushButton 628 { 629 private: 630 sal_Bool mbDown; 631 632 Link maMBDownHdl; 633 634 public: 635 ImplBtn( Window* pParent, WinBits nWinStyle = 0 ); 636 ~ImplBtn() {}; 637 638 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 639 640 virtual void MBDown(); 641 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } 642 const Link& GetMBDownHdl() const { return maMBDownHdl; } 643 }; 644 645 646 void ImplInitFieldSettings( Window* pWin, sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); 647 void ImplInitDropDownButton( PushButton* pButton ); 648 649 #endif // _SV_ILSTBOX_HXX 650