diff options
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/icontest.cxx | 9 | ||||
-rw-r--r-- | vcl/workben/mtfdemo.cxx | 4 | ||||
-rw-r--r-- | vcl/workben/outdevgrind.cxx | 5 | ||||
-rw-r--r-- | vcl/workben/svdem.cxx | 6 | ||||
-rw-r--r-- | vcl/workben/svpclient.cxx | 77 | ||||
-rw-r--r-- | vcl/workben/svptest.cxx | 7 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 97 |
7 files changed, 112 insertions, 93 deletions
diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx index 3710a16ce152..cef8ac6755c8 100644 --- a/vcl/workben/icontest.cxx +++ b/vcl/workben/icontest.cxx @@ -71,10 +71,11 @@ protected: public: Graphic maGraphic; Bitmap *mpBitmap; - FixedBitmap *mpFixedBitmap; + VclPtr<FixedBitmap> mpFixedBitmap; MyWorkWindow( vcl::Window* pParent, WinBits nWinStyle ); - + virtual ~MyWorkWindow() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE { mpFixedBitmap.clear(); WorkWindow::dispose(); } void LoadGraphic( const OUString& sImageFile ); virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE; @@ -185,12 +186,12 @@ void IconTestApp::DoItWithVcl( const OUString& sImageFile) { try { - MyWorkWindow *pWindow = new MyWorkWindow( NULL, WB_APP | WB_STDWORK | WB_SIZEABLE | WB_CLOSEABLE | WB_CLIPCHILDREN ); + VclPtrInstance<MyWorkWindow> pWindow( nullptr, WB_APP | WB_STDWORK | WB_SIZEABLE | WB_CLOSEABLE | WB_CLIPCHILDREN ); pWindow->SetText(OUString("VCL Image Test")); pWindow->LoadGraphic( sImageFile ); - pWindow->mpFixedBitmap = new FixedBitmap( pWindow ); + pWindow->mpFixedBitmap = VclPtr<FixedBitmap>::Create( pWindow ); pWindow->mpFixedBitmap->SetPosPixel( Point( 0, 0 ) ); pWindow->mpFixedBitmap->Show(); diff --git a/vcl/workben/mtfdemo.cxx b/vcl/workben/mtfdemo.cxx index 4f65b0ff12ce..05ab64430972 100644 --- a/vcl/workben/mtfdemo.cxx +++ b/vcl/workben/mtfdemo.cxx @@ -67,7 +67,7 @@ void DemoMtfWin::Paint( const Rectangle& rRect ) class DemoMtfApp : public Application { - DemoMtfWin *mpWin; + VclPtr<DemoMtfWin> mpWin; OUString maFileName; void showHelp() @@ -88,7 +88,7 @@ public: { try { - mpWin = new DemoMtfWin(maFileName); + mpWin = VclPtr<DemoMtfWin>::Create(maFileName); mpWin->SetText(OUString("Display metafile")); mpWin->Show(); diff --git a/vcl/workben/outdevgrind.cxx b/vcl/workben/outdevgrind.cxx index 528eae381abb..da14e1aac673 100644 --- a/vcl/workben/outdevgrind.cxx +++ b/vcl/workben/outdevgrind.cxx @@ -72,7 +72,6 @@ class TestWindow : public Dialog Show(); } - virtual ~TestWindow() {} virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE; }; @@ -899,8 +898,8 @@ sal_uInt16 GrindApp::Exception( sal_uInt16 nError ) int GrindApp::Main() { - TestWindow aWindow; - aWindow.Execute(); + ScopedVclPtrInstance<TestWindow> aWindow; + aWindow->Execute(); return 0; } diff --git a/vcl/workben/svdem.cxx b/vcl/workben/svdem.cxx index a06bf5cc13d7..e349934a5af1 100644 --- a/vcl/workben/svdem.cxx +++ b/vcl/workben/svdem.cxx @@ -81,9 +81,9 @@ public: void Main() { - MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); - aMainWin.SetText(OUString("VCL - Workbench")); - aMainWin.Show(); + ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK ); + aMainWin->SetText(OUString("VCL - Workbench")); + aMainWin->Show(); Application::Execute(); } diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx index 2ed9ac302368..01ad3e9d5f08 100644 --- a/vcl/workben/svpclient.cxx +++ b/vcl/workben/svpclient.cxx @@ -92,10 +92,10 @@ SAL_IMPLEMENT_MAIN() class MyWin : public WorkWindow { - PushButton m_aListButton; - ListBox m_aSvpBitmaps; - ImageControl m_aImage; - PushButton m_aQuitButton; + VclPtr<PushButton> m_aListButton; + VclPtr<ListBox> m_aSvpBitmaps; + VclPtr<ImageControl> m_aImage; + VclPtr<PushButton> m_aQuitButton; public: MyWin( vcl::Window* pParent, WinBits nWinStyle ); @@ -108,6 +108,8 @@ public: virtual void Resize() SAL_OVERRIDE; virtual bool Close() SAL_OVERRIDE; + virtual ~MyWin() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; void parseList( const OString& rList ); OString processCommand( const OString& rCommand ); @@ -119,37 +121,37 @@ public: void Main() { - MyWin aMainWin( NULL, WB_STDWORK ); - aMainWin.SetText( OUString( "SvpClient" ) ); - aMainWin.Show(); + ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_STDWORK ); + aMainWin->SetText( OUString( "SvpClient" ) ); + aMainWin->Show(); Application::Execute(); } MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) : WorkWindow( pParent, nWinStyle ), - m_aListButton( this, 0 ), - m_aSvpBitmaps( this, WB_BORDER ), - m_aImage( this, WB_BORDER ), - m_aQuitButton( this, 0 ) + m_aListButton(VclPtr<PushButton>::Create(this, 0)), + m_aSvpBitmaps(VclPtr<ListBox>::Create(this, WB_BORDER)), + m_aImage(VclPtr<ImageControl>::Create(this, WB_BORDER)), + m_aQuitButton(VclPtr<PushButton>::Create(this, 0)) { - m_aListButton.SetPosSizePixel( Point( 10, 10 ), Size( 120, 25 ) ); - m_aListButton.SetText( OUString( "List Elements" ) ); - m_aListButton.SetClickHdl( LINK( this, MyWin, ListHdl ) ); - m_aListButton.Show(); - - m_aSvpBitmaps.SetPosSizePixel( Point( 10, 40 ), Size( 150, 150 ) ); - m_aSvpBitmaps.SetSelectHdl( LINK( this, MyWin, SelectHdl ) ); - m_aSvpBitmaps.Show(); - - m_aImage.SetPosSizePixel( Point( 170, 10 ), Size( 400, 400 ) ); - m_aImage.SetScaleMode( com::sun::star::awt::ImageScaleMode::NONE ); - m_aImage.Show(); - - m_aQuitButton.SetPosSizePixel( Point( 10, 300 ), Size( 120,25 ) ); - m_aQuitButton.SetText( OUString( "Quit SVP server" ) ); - m_aQuitButton.SetClickHdl( LINK( this, MyWin, QuitHdl ) ); - m_aQuitButton.Show(); + m_aListButton->SetPosSizePixel( Point( 10, 10 ), Size( 120, 25 ) ); + m_aListButton->SetText( OUString( "List Elements" ) ); + m_aListButton->SetClickHdl( LINK( this, MyWin, ListHdl ) ); + m_aListButton->Show(); + + m_aSvpBitmaps->SetPosSizePixel( Point( 10, 40 ), Size( 150, 150 ) ); + m_aSvpBitmaps->SetSelectHdl( LINK( this, MyWin, SelectHdl ) ); + m_aSvpBitmaps->Show(); + + m_aImage->SetPosSizePixel( Point( 170, 10 ), Size( 400, 400 ) ); + m_aImage->SetScaleMode( com::sun::star::awt::ImageScaleMode::NONE ); + m_aImage->Show(); + + m_aQuitButton->SetPosSizePixel( Point( 10, 300 ), Size( 120,25 ) ); + m_aQuitButton->SetText( OUString( "Quit SVP server" ) ); + m_aQuitButton->SetClickHdl( LINK( this, MyWin, QuitHdl ) ); + m_aQuitButton->Show(); } bool MyWin::Close() @@ -160,11 +162,20 @@ bool MyWin::Close() return bRet; } +void MyWin::dispose() +{ + m_aListButton.disposeAndClear(); + m_aSvpBitmaps.disposeAndClear(); + m_aImage.disposeAndClear(); + m_aQuitButton.disposeAndClear(); + WorkWindow::dispose(); +} + void MyWin::parseList( const OString& rList ) { sal_Int32 nTokenPos = 0; OUString aElementType; - m_aSvpBitmaps.Clear(); + m_aSvpBitmaps->Clear(); while( nTokenPos >= 0 ) { OString aLine = rList.getToken( 0, '\n', nTokenPos ); @@ -179,7 +190,7 @@ void MyWin::parseList( const OString& rList ) aNewElement.append( aElementType ); aNewElement.appendAscii( ": " ); aNewElement.append( OStringToOUString( aLine, RTL_TEXTENCODING_ASCII_US ) ); - m_aSvpBitmaps.InsertEntry( aNewElement.makeStringAndClear() ); + m_aSvpBitmaps->InsertEntry( aNewElement.makeStringAndClear() ); } } } @@ -235,7 +246,7 @@ IMPL_LINK( MyWin, QuitHdl, Button*, ) IMPL_LINK( MyWin, SelectHdl, ListBox*, ) { - OUString aEntry = m_aSvpBitmaps.GetSelectEntry(); + OUString aEntry = m_aSvpBitmaps->GetSelectEntry(); sal_Int32 nPos = aEntry.indexOf( ": " ); if( nPos != -1 ) { @@ -259,8 +270,8 @@ IMPL_LINK( MyWin, SelectHdl, ListBox*, ) Size aFixedSize( aBitmap.GetSizePixel() ); aFixedSize.Width() += 10; aFixedSize.Height() += 10; - m_aImage.SetSizePixel( aFixedSize ); - m_aImage.SetImage( Image( BitmapEx( aBitmap ) ) ); + m_aImage->SetSizePixel( aFixedSize ); + m_aImage->SetImage( Image( BitmapEx( aBitmap ) ) ); } return 0; } diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx index ebf716c3abd1..ac2c5527a8e0 100644 --- a/vcl/workben/svptest.cxx +++ b/vcl/workben/svptest.cxx @@ -34,6 +34,7 @@ #include <vcl/bitmap.hxx> #include <vcl/bmpacc.hxx> #include <vcl/metric.hxx> +#include <vcl/vclptr.hxx> #include <rtl/ustrbuf.hxx> @@ -90,9 +91,9 @@ public: void Main() { - MyWin aMainWin( NULL, WB_APP | WB_STDWORK ); - aMainWin.SetText( OUString( "VCL - Workbench" ) ); - aMainWin.Show(); + ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK ); + aMainWin->SetText( OUString( "VCL - Workbench" ) ); + aMainWin->Show(); Application::Execute(); } diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index f272ccbb88c4..4f42f9353445 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -774,12 +774,12 @@ public: void SizeAndRender(OutputDevice &rDev, const Rectangle& r, RenderType eType, const RenderContext &rCtx) { - VirtualDevice *pNested; + ScopedVclPtr<VirtualDevice> pNested; if ((int)eType < RENDER_AS_BITMAPEX) - pNested = new VirtualDevice(rDev); + pNested = VclPtr<VirtualDevice>::Create(rDev).get(); else - pNested = new VirtualDevice(rDev,0,0); + pNested = VclPtr<VirtualDevice>::Create(rDev,0,0).get(); pNested->SetOutputSizePixel(r.GetSize()); Rectangle aWhole(Point(0,0), r.GetSize()); @@ -804,7 +804,6 @@ public: aWhole.TopLeft(), aWhole.GetSize(), *pNested); } - delete pNested; } virtual void RenderRegion(OutputDevice &rDev, Rectangle r, const RenderContext &rCtx) SAL_OVERRIDE @@ -945,19 +944,20 @@ public: BitmapEx AlphaRecovery(OutputDevice &rDev, Point aPt, BitmapEx &aSrc) { // Compositing onto 2x colors beyond our control - VirtualDevice aWhite, aBlack; - aWhite.SetOutputSizePixel(aSrc.GetSizePixel()); - aWhite.SetBackground(Wallpaper(COL_WHITE)); - aWhite.Erase(); - aBlack.SetOutputSizePixel(aSrc.GetSizePixel()); - aBlack.SetBackground(Wallpaper(COL_BLACK)); - aBlack.Erase(); - aWhite.DrawBitmapEx(Point(), aSrc); - aBlack.DrawBitmapEx(Point(), aSrc); + ScopedVclPtrInstance< VirtualDevice > aWhite; + ScopedVclPtrInstance< VirtualDevice > aBlack; + aWhite->SetOutputSizePixel(aSrc.GetSizePixel()); + aWhite->SetBackground(Wallpaper(COL_WHITE)); + aWhite->Erase(); + aBlack->SetOutputSizePixel(aSrc.GetSizePixel()); + aBlack->SetBackground(Wallpaper(COL_BLACK)); + aBlack->Erase(); + aWhite->DrawBitmapEx(Point(), aSrc); + aBlack->DrawBitmapEx(Point(), aSrc); // Now recover that alpha... - Bitmap aWhiteBmp = aWhite.GetBitmap(Point(),aSrc.GetSizePixel()); - Bitmap aBlackBmp = aBlack.GetBitmap(Point(),aSrc.GetSizePixel()); + Bitmap aWhiteBmp = aWhite->GetBitmap(Point(),aSrc.GetSizePixel()); + Bitmap aBlackBmp = aBlack->GetBitmap(Point(),aSrc.GetSizePixel()); AlphaMask aMask(aSrc.GetSizePixel()); Bitmap aRecovered(aSrc.GetSizePixel(), 24); { @@ -1133,12 +1133,11 @@ public: } } } - std::vector<vcl::Window *> maInvalidates; + std::vector<VclPtr<vcl::Window> > maInvalidates; void addInvalidate(vcl::Window *pWindow) { maInvalidates.push_back(pWindow); }; void removeInvalidate(vcl::Window *pWindow) { - std::vector<vcl::Window *>::iterator aIt; - for (aIt = maInvalidates.begin(); aIt != maInvalidates.end(); ++aIt) + for (auto aIt = maInvalidates.begin(); aIt != maInvalidates.end(); ++aIt) { if (*aIt == pWindow) { @@ -1231,8 +1230,8 @@ bool DemoRenderer::MouseButtonDown(const MouseEvent& rMEvt) // otherwise bounce floating windows if (!mpButton) { - mpButtonWin = new FloatingWindow(this); - mpButton = new PushButton(mpButtonWin); + mpButtonWin = VclPtr<FloatingWindow>::Create(this); + mpButton = VclPtr<PushButton>::Create(mpButtonWin); mpButton->SetSymbol(SymbolType::HELP); mpButton->SetText("PushButton demo"); mpButton->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize()); @@ -1385,8 +1384,13 @@ public: } virtual ~DemoWin() { + disposeOnce(); + } + virtual void dispose() SAL_OVERRIDE + { mxThread.clear(); mrRenderer.removeInvalidate(this); + WorkWindow::dispose(); } virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE { @@ -1402,7 +1406,7 @@ public: } else { // spawn another window - DemoWin *pNewWin = new DemoWin(mrRenderer, testThreads); + VclPtrInstance<DemoWin> pNewWin(mrRenderer, testThreads); pNewWin->SetText("Another interactive VCL demo window"); pNewWin->Show(); } @@ -1445,16 +1449,16 @@ public: class DemoWidgets : public WorkWindow { - VclBox *mpBox; - ToolBox *mpToolbox; - PushButton *mpButton; + VclPtr<VclBox> mpBox; + VclPtr<ToolBox> mpToolbox; + VclPtr<PushButton> mpButton; public: DemoWidgets() : WorkWindow(NULL, WB_STDWORK), - mpBox(new VclVBox(this, false, 3)), - mpToolbox(new ToolBox(mpBox)), - mpButton(new PushButton(mpBox)) + mpBox(VclPtrInstance<VclVBox>(this, false, 3)), + mpToolbox(VclPtrInstance<ToolBox>(mpBox.get())), + mpButton(VclPtrInstance<PushButton>(mpBox.get())) { SetText("VCL widget demo"); @@ -1477,14 +1481,14 @@ public: Show(); } - - virtual ~DemoWidgets() + virtual ~DemoWidgets() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE { - delete mpButton; - delete mpToolbox; - delete mpBox; + mpBox.disposeAndClear(); + mpToolbox.disposeAndClear(); + mpButton.disposeAndClear(); + WorkWindow::dispose(); } - virtual void Paint(const Rectangle&) SAL_OVERRIDE { Rectangle aWholeSize(Point(0, 0),GetOutputSizePixel()); @@ -1499,16 +1503,16 @@ public: DrawWallpaper(aWholeSize, aWallpaper); Pop(); - VirtualDevice aDev(*this); - aDev.EnableRTL(IsRTLEnabled()); - aDev.SetOutputSizePixel(aExclude.GetSize()); + ScopedVclPtrInstance< VirtualDevice > pDev(*this); + pDev->EnableRTL(IsRTLEnabled()); + pDev->SetOutputSizePixel(aExclude.GetSize()); Rectangle aSubRect(aWholeSize); aSubRect.Move(-aExclude.Left(), -aExclude.Top()); - aDev.DrawWallpaper(aSubRect, aWallpaper ); + pDev->DrawWallpaper(aSubRect, aWallpaper ); DrawOutDev(aExclude.TopLeft(), aExclude.GetSize(), - Point( 0, 0 ), aExclude.GetSize(), aDev ); + Point( 0, 0 ), aExclude.GetSize(), *pDev.get() ); } }; @@ -1612,20 +1616,23 @@ public: } } - DemoWin aMainWin(aRenderer, bThreads); - std::unique_ptr<DemoWidgets> xWidgets; - std::unique_ptr<DemoPopup> xPopup; + ScopedVclPtrInstance<DemoWin> aMainWin(aRenderer, bThreads); + VclPtr<DemoWidgets> xWidgets; + VclPtr<DemoPopup> xPopup; - aMainWin.SetText("Interactive VCL demo #1"); + aMainWin->SetText("Interactive VCL demo #1"); if (bWidgets) - xWidgets.reset(new DemoWidgets()); + xWidgets = VclPtr< DemoWidgets >::Create (); else if (bPopup) - xPopup.reset(new DemoPopup()); + xPopup = VclPtrInstance< DemoPopup> (); else - aMainWin.Show(); + aMainWin->Show(); Application::Execute(); + + xWidgets.disposeAndClear(); + xPopup.disposeAndClear(); } catch (const css::uno::Exception& e) { |