diff options
Diffstat (limited to 'vcl/source/control/ilstbox.cxx')
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 113 |
1 files changed, 69 insertions, 44 deletions
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 64d009ab9e34..083faf072e96 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -536,7 +536,13 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle ) ImplListBoxWindow::~ImplListBoxWindow() { + disposeOnce(); +} + +void ImplListBoxWindow::dispose() +{ delete mpEntryList; + Control::dispose(); } void ImplListBoxWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) @@ -2135,16 +2141,16 @@ sal_uInt16 ImplListBoxWindow::ImplGetTextStyle() const ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) : Control( pParent, nWinStyle ), - maLBWindow( this, nWinStyle&(~WB_BORDER) ) + maLBWindow(VclPtr<ImplListBoxWindow>::Create( this, nWinStyle&(~WB_BORDER) )) { - maLBWindow.userDrawSignal.connect( userDrawSignal ); + maLBWindow->userDrawSignal.connect( userDrawSignal ); // for native widget rendering we must be able to detect this window type SetType( WINDOW_LISTBOXWINDOW ); - mpVScrollBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG ); - mpHScrollBar = new ScrollBar( this, WB_HSCROLL | WB_DRAG ); - mpScrollBarBox = new ScrollBarBox( this ); + mpVScrollBar = VclPtr<ScrollBar>::Create( this, WB_VSCROLL | WB_DRAG ); + mpHScrollBar = VclPtr<ScrollBar>::Create( this, WB_HSCROLL | WB_DRAG ); + mpScrollBarBox = VclPtr<ScrollBarBox>::Create( this ); Link aLink( LINK( this, ImplListBox, ScrollBarHdl ) ); mpVScrollBar->SetScrollHdl( aLink ); @@ -2155,26 +2161,33 @@ ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) : mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL ); mbEdgeBlending = false; - maLBWindow.SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) ); - maLBWindow.SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) ); - maLBWindow.SetEdgeBlending(GetEdgeBlending()); - maLBWindow.Show(); + maLBWindow->SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) ); + maLBWindow->SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) ); + maLBWindow->SetEdgeBlending(GetEdgeBlending()); + maLBWindow->Show(); } ImplListBox::~ImplListBox() { - delete mpHScrollBar; - delete mpVScrollBar; - delete mpScrollBarBox; + disposeOnce(); +} + +void ImplListBox::dispose() +{ + mpHScrollBar.disposeAndClear(); + mpVScrollBar.disposeAndClear(); + mpScrollBarBox.disposeAndClear(); + maLBWindow.disposeAndClear(); + Control::dispose(); } void ImplListBox::Clear() { - maLBWindow.Clear(); + maLBWindow->Clear(); if ( GetEntryList()->GetMRUCount() ) { - maLBWindow.GetEntryList()->SetMRUCount( 0 ); - maLBWindow.SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND ); + maLBWindow->GetEntryList()->SetMRUCount( 0 ); + maLBWindow->SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND ); } mpVScrollBar->SetThumbPos( 0 ); mpHScrollBar->SetThumbPos( 0 ); @@ -2184,7 +2197,7 @@ void ImplListBox::Clear() sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr ) { ImplEntryType* pNewEntry = new ImplEntryType( rStr ); - sal_Int32 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry ); + sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry ); if (nNewPos == LISTBOX_ERROR) { delete pNewEntry; @@ -2197,7 +2210,7 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr ) sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage ) { ImplEntryType* pNewEntry = new ImplEntryType( rStr, rImage ); - sal_Int32 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry ); + sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry ); if (nNewPos == LISTBOX_ERROR) { delete pNewEntry; @@ -2209,33 +2222,33 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const void ImplListBox::RemoveEntry( sal_Int32 nPos ) { - maLBWindow.RemoveEntry( nPos ); + maLBWindow->RemoveEntry( nPos ); StateChanged( StateChangedType::DATA ); } void ImplListBox::SetEntryFlags( sal_Int32 nPos, long nFlags ) { - maLBWindow.SetEntryFlags( nPos, nFlags ); + maLBWindow->SetEntryFlags( nPos, nFlags ); } void ImplListBox::SelectEntry( sal_Int32 nPos, bool bSelect ) { - maLBWindow.SelectEntry( nPos, bSelect ); + maLBWindow->SelectEntry( nPos, bSelect ); } void ImplListBox::SetNoSelection() { - maLBWindow.DeselectAll(); + maLBWindow->DeselectAll(); } void ImplListBox::GetFocus() { - maLBWindow.GrabFocus(); + maLBWindow->GrabFocus(); } vcl::Window* ImplListBox::GetPreferredKeyInputWindow() { - return &maLBWindow; + return maLBWindow.get(); } void ImplListBox::Resize() @@ -2359,7 +2372,7 @@ void ImplListBox::ImplCheckScrollBars() void ImplListBox::ImplInitScrollBars() { - Size aOutSz = maLBWindow.GetOutputSizePixel(); + Size aOutSz = maLBWindow->GetOutputSizePixel(); if ( mbVScroll ) { @@ -2396,9 +2409,9 @@ void ImplListBox::ImplResizeControls() // pb: #106948# explicit mirroring for calc // Scrollbar on left or right side? - bool bMirroring = maLBWindow.IsMirroring(); + bool bMirroring = maLBWindow->IsMirroring(); Point aWinPos( bMirroring && mbVScroll ? nSBWidth : 0, 0 ); - maLBWindow.SetPosSizePixel( aWinPos, aInnerSz ); + maLBWindow->SetPosSizePixel( aWinPos, aInnerSz ); // ScrollBarBox if( mbVScroll && mbHScroll ) @@ -2450,7 +2463,7 @@ void ImplListBox::StateChanged( StateChangedType nType ) else if ( ( nType == StateChangedType::UPDATEMODE ) || ( nType == StateChangedType::DATA ) ) { bool bUpdate = IsUpdateMode(); - maLBWindow.SetUpdateMode( bUpdate ); + maLBWindow->SetUpdateMode( bUpdate ); if ( bUpdate && IsReallyVisible() ) ImplCheckScrollBars(); } @@ -2459,30 +2472,30 @@ void ImplListBox::StateChanged( StateChangedType nType ) mpHScrollBar->Enable( IsEnabled() ); mpVScrollBar->Enable( IsEnabled() ); mpScrollBarBox->Enable( IsEnabled() ); - maLBWindow.Enable( IsEnabled() ); + maLBWindow->Enable( IsEnabled() ); Invalidate(); } else if ( nType == StateChangedType::ZOOM ) { - maLBWindow.SetZoom( GetZoom() ); + maLBWindow->SetZoom( GetZoom() ); Resize(); } else if ( nType == StateChangedType::CONTROLFONT ) { - maLBWindow.SetControlFont( GetControlFont() ); + maLBWindow->SetControlFont( GetControlFont() ); } else if ( nType == StateChangedType::CONTROLFOREGROUND ) { - maLBWindow.SetControlForeground( GetControlForeground() ); + maLBWindow->SetControlForeground( GetControlForeground() ); } else if ( nType == StateChangedType::CONTROLBACKGROUND ) { - maLBWindow.SetControlBackground( GetControlBackground() ); + maLBWindow->SetControlBackground( GetControlBackground() ); } else if( nType == StateChangedType::MIRRORING ) { - maLBWindow.EnableRTL( IsRTLEnabled() ); + maLBWindow->EnableRTL( IsRTLEnabled() ); mpHScrollBar->EnableRTL( IsRTLEnabled() ); mpVScrollBar->EnableRTL( IsRTLEnabled() ); ImplResizeControls(); @@ -2517,7 +2530,7 @@ bool ImplListBox::Notify( NotifyEvent& rNEvt ) const Wallpaper& ImplListBox::GetDisplayBackground() const { - return maLBWindow.GetDisplayBackground(); + return maLBWindow->GetDisplayBackground(); } bool ImplListBox::HandleWheelAsCursorTravel( const CommandEvent& rCEvt ) @@ -2542,7 +2555,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep ) // Remove old MRU entries for ( sal_Int32 n = GetEntryList()->GetMRUCount();n; ) - maLBWindow.RemoveEntry( --n ); + maLBWindow->RemoveEntry( --n ); sal_Int32 nMRUCount = 0; sal_Int32 nIndex = 0; @@ -2553,7 +2566,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep ) if ( GetEntryList()->FindEntry( aEntry ) != LISTBOX_ENTRY_NOTFOUND ) { ImplEntryType* pNewEntry = new ImplEntryType( aEntry ); - maLBWindow.GetEntryList()->InsertEntry( nMRUCount++, pNewEntry, false ); + maLBWindow->GetEntryList()->InsertEntry( nMRUCount++, pNewEntry, false ); bChanges = true; } } @@ -2561,7 +2574,7 @@ void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep ) if ( bChanges ) { - maLBWindow.GetEntryList()->SetMRUCount( nMRUCount ); + maLBWindow->GetEntryList()->SetMRUCount( nMRUCount ); SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 ); StateChanged( StateChangedType::DATA ); } @@ -2584,7 +2597,7 @@ void ImplListBox::SetEdgeBlending(bool bNew) if(mbEdgeBlending != bNew) { mbEdgeBlending = bNew; - maLBWindow.SetEdgeBlending(GetEdgeBlending()); + maLBWindow->SetEdgeBlending(GetEdgeBlending()); } } @@ -2918,6 +2931,18 @@ ImplListBoxFloatingWindow::ImplListBoxFloatingWindow( vcl::Window* pParent ) : } +ImplListBoxFloatingWindow::~ImplListBoxFloatingWindow() +{ + disposeOnce(); +} + +void ImplListBoxFloatingWindow::dispose() +{ + mpImplLB.clear(); + FloatingWindow::dispose(); +} + + bool ImplListBoxFloatingWindow::PreNotify( NotifyEvent& rNEvt ) { if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS ) @@ -2959,13 +2984,13 @@ void ImplListBoxFloatingWindow::setPosSizePixel( long nX, long nY, long nWidth, // this the presence of the vertical Scrollbar has to be known. mpImplLB->SetSizePixel( GetOutputSizePixel() ); ((vcl::Window*)mpImplLB)->Resize(); - ((vcl::Window&)mpImplLB->GetMainWindow()).Resize(); + ((vcl::Window*)mpImplLB->GetMainWindow())->Resize(); } } void ImplListBoxFloatingWindow::Resize() { - mpImplLB->GetMainWindow().ImplClearLayoutData(); + mpImplLB->GetMainWindow()->ImplClearLayoutData(); FloatingWindow::Resize(); } @@ -3085,12 +3110,12 @@ void ImplListBoxFloatingWindow::StartFloat( bool bStartTracking ) mpImplLB->ShowProminentEntry( nPos ); if( bStartTracking ) - mpImplLB->GetMainWindow().EnableMouseMoveSelect( true ); + mpImplLB->GetMainWindow()->EnableMouseMoveSelect( true ); - if ( mpImplLB->GetMainWindow().IsGrabFocusAllowed() ) - mpImplLB->GetMainWindow().GrabFocus(); + if ( mpImplLB->GetMainWindow()->IsGrabFocusAllowed() ) + mpImplLB->GetMainWindow()->GrabFocus(); - mpImplLB->GetMainWindow().ImplClearLayoutData(); + mpImplLB->GetMainWindow()->ImplClearLayoutData(); } } |