[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 2 commits - vcl/Executable_vcldemo.mk vcl/workben
Michael Meeks
michael.meeks at collabora.com
Fri Nov 7 02:41:53 PST 2014
vcl/Executable_vcldemo.mk | 4
vcl/workben/vcldemo.cxx | 267 ++++++++++++++++++++++++++--------------------
2 files changed, 160 insertions(+), 111 deletions(-)
New commits:
commit d4d9483d7d3b20a23c238502a989f72da6ec2e09
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri Nov 7 10:42:12 2014 +0000
vcldemo: kill all the legacy cruft.
Change-Id: I60d7d30ff20a01e375d9851afd8bd8ce12835752
diff --git a/vcl/Executable_vcldemo.mk b/vcl/Executable_vcldemo.mk
index fb29b9a..561f7d6 100644
--- a/vcl/Executable_vcldemo.mk
+++ b/vcl/Executable_vcldemo.mk
@@ -36,4 +36,8 @@ $(eval $(call gb_Executable_add_exception_objects,vcldemo,\
vcl/workben/vcldemo \
))
+$(eval $(call gb_Executable_use_static_libraries,vcldemo,\
+ vclmain \
+))
+
# vim: set noet sw=4 ts=4:
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 2f910ea..a8eccd0 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -5,73 +5,30 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sal/main.h>
-#include <tools/extendapplicationenvironment.hxx>
-
-#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
-
+#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+
+#include <vcl/vclmain.hxx>
-#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
-#include <vcl/msgbox.hxx>
-
-#include <unistd.h>
-#include <stdio.h>
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace cppu;
+using namespace css;
-// Forward declaration
-void Main();
-
-SAL_IMPLEMENT_MAIN()
-{
- tools::extendApplicationEnvironment();
-
- Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
- Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
-
- if( !xServiceManager.is() )
- Application::Abort( "Failed to bootstrap" );
-
- comphelper::setProcessServiceFactory( xServiceManager );
-
- InitVCL();
- ::Main();
- DeInitVCL();
-
- return 0;
-}
-
-class MyWin : public WorkWindow
+class DemoWin : public WorkWindow
{
public:
- MyWin( vcl::Window* pParent, WinBits nWinStyle );
+ DemoWin() : WorkWindow( NULL, WB_APP | WB_STDWORK)
+ {
+ }
- virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
- virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
- virtual void Resize() SAL_OVERRIDE;
std::vector<Rectangle> partitionAndClear(int nX, int nY);
@@ -134,49 +91,7 @@ public:
}
};
-void Main()
-{
- MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
- aMainWin.SetText( OUString( "VCLDemo - VCL Workbench" ) );
- aMainWin.Show();
-
- Application::Execute();
-}
-
-MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
- WorkWindow( pParent, nWinStyle )
-{
-}
-
-void MyWin::MouseMove( const MouseEvent& rMEvt )
-{
- WorkWindow::MouseMove( rMEvt );
-}
-
-void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
-{
- Rectangle aRect(0,0,4,4);
- aRect.SetPos( rMEvt.GetPosPixel() );
- SetFillColor(Color(COL_RED));
- DrawRect( aRect );
-}
-
-void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
-{
- WorkWindow::MouseButtonUp( rMEvt );
-}
-
-void MyWin::KeyInput( const KeyEvent& rKEvt )
-{
- WorkWindow::KeyInput( rKEvt );
-}
-
-void MyWin::KeyUp( const KeyEvent& rKEvt )
-{
- WorkWindow::KeyUp( rKEvt );
-}
-
-std::vector<Rectangle> MyWin::partitionAndClear(int nX, int nY)
+std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
{
Rectangle r;
std::vector<Rectangle> aRegions;
@@ -211,9 +126,9 @@ std::vector<Rectangle> MyWin::partitionAndClear(int nX, int nY)
return aRegions;
}
-void MyWin::Paint( const Rectangle& rRect )
+void DemoWin::Paint( const Rectangle& rRect )
{
- fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
+ fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
drawBackground();
@@ -228,9 +143,51 @@ void MyWin::Paint( const Rectangle& rRect )
drawGradient(aRegions[i++]);
}
-void MyWin::Resize()
+class DemoApp : public Application
+{
+public:
+ DemoApp() {}
+
+ virtual int Main() SAL_OVERRIDE
+ {
+ DemoWin aMainWin;
+ aMainWin.SetText( "Interactive VCL demo" );
+ aMainWin.Show();
+ Application::Execute();
+ }
+
+protected:
+ uno::Reference<lang::XMultiServiceFactory> xMSF;
+ void Init() SAL_OVERRIDE
+ {
+ try
+ {
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ xMSF = uno::Reference<lang::XMultiServiceFactory>
+ ( xComponentContext->getServiceManager(), uno::UNO_QUERY );
+ if( !xMSF.is() )
+ Application::Abort("Bootstrap failure - no service manager");
+
+ ::comphelper::setProcessServiceFactory( xMSF );
+ }
+ catch (const uno::Exception &e)
+ {
+ Application::Abort("Bootstrap exception " + e.Message);
+ }
+ }
+ void DeInit() SAL_OVERRIDE
+ {
+ uno::Reference< lang::XComponent >(
+ comphelper::getProcessComponentContext(),
+ uno::UNO_QUERY_THROW )-> dispose();
+ ::comphelper::setProcessServiceFactory( NULL );
+ }
+};
+
+void vclmain::createApplication()
{
- WorkWindow::Resize();
+ static DemoApp aApp;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0e72d9fc50e70c619b6d0638308ab55d5a98585b
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri Nov 7 10:25:13 2014 +0000
vcldemo - substantially extend the demo.
Change-Id: I02b9375efe17f1aad32d8e2dfcd073a680c51e4c
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index f793401..2f910ea 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -72,6 +72,66 @@ public:
virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
+
+ std::vector<Rectangle> partitionAndClear(int nX, int nY);
+
+ void drawBackground()
+ {
+ Rectangle r(Point(0,0), GetSizePixel());
+ Gradient aGradient;
+ aGradient.SetStartColor(COL_BLUE);
+ aGradient.SetEndColor(COL_GREEN);
+ aGradient.SetStyle(GradientStyle_LINEAR);
+// aGradient.SetBorder(r.GetSize().Width()/20);
+ DrawGradient(r, aGradient);
+ }
+
+ void drawRadialLines(Rectangle r)
+ {
+ SetFillColor(Color(COL_LIGHTRED));
+ SetLineColor(Color(COL_LIGHTGREEN));
+ DrawRect( r );
+
+ for(int i=0; i<r.GetHeight(); i+=15)
+ DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) );
+ for(int i=0; i<r.GetWidth(); i+=15)
+ DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) );
+ }
+
+ void drawText(Rectangle r)
+ {
+ SetTextColor( Color( COL_BLACK ) );
+ vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) );
+ SetFont( aFont );
+ DrawText( r, OUString( "Just a simple text" ) );
+ }
+
+ void drawPoly(Rectangle r) // pretty
+ {
+ Polygon aPoly(r, r.TopLeft(), r.TopRight());
+ SetLineColor(Color(COL_RED));
+// DrawPolyLine(aPoly);
+ }
+
+ void drawPolyPoly(Rectangle r)
+ {
+ (void)r;
+ }
+
+ void drawCheckered(Rectangle r)
+ {
+ DrawCheckered(r.TopLeft(), r.GetSize());
+ }
+ void drawGradient(Rectangle r)
+ {
+ Gradient aGradient;
+ aGradient.SetStartColor(COL_BLUE);
+ aGradient.SetEndColor(COL_GREEN);
+// aGradient.SetAngle(45);
+ aGradient.SetStyle(GradientStyle_LINEAR);
+ aGradient.SetBorder(r.GetSize().Width()/20);
+ DrawGradient(r, aGradient);
+ }
};
void Main()
@@ -116,28 +176,56 @@ void MyWin::KeyUp( const KeyEvent& rKEvt )
WorkWindow::KeyUp( rKEvt );
}
+std::vector<Rectangle> MyWin::partitionAndClear(int nX, int nY)
+{
+ Rectangle r;
+ std::vector<Rectangle> aRegions;
+
+ // Make small cleared area for these guys
+ Size aSize(GetSizePixel());
+ long nBorderSize = aSize.Width() / 32;
+ long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX;
+ long nBoxHeight = (aSize.Height() - nBorderSize*(nX+1)) / nY;
+// SL_DEBUG("Size " << aSize << " boxes " << nBoxWidth << "x" << nBoxHeight << " border " << nBorderSize);
+ for (int y = 0; y < nY; y++ )
+ {
+ for (int x = 0; x < nX; x++ )
+ {
+ r.SetPos(Point(nBorderSize + (nBorderSize + nBoxWidth) * x,
+ nBorderSize + (nBorderSize + nBoxHeight) * y));
+ r.SetSize(Size(nBoxWidth, nBoxHeight));
+
+ // knock up a nice little border
+ SetLineColor(COL_GRAY);
+ SetFillColor(COL_LIGHTGRAY);
+ if ((x + y) % 2)
+ DrawRect(r);
+ else
+ DrawRect(r);
+// DrawRect(r, nBorderSize, nBorderSize); FIXME - lfrb
+
+ aRegions.push_back(r);
+ }
+ }
+
+ return aRegions;
+}
+
void MyWin::Paint( const Rectangle& rRect )
{
fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
- Size aSz(GetSizePixel());
- Point aPt;
- Rectangle r(aPt, aSz);
-
- SetFillColor(Color(COL_BLUE));
- SetLineColor(Color(COL_YELLOW));
-
- DrawRect( r );
+ drawBackground();
- for(int i=0; i<aSz.Height(); i+=15)
- DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) );
- for(int i=0; i<aSz.Width(); i+=15)
- DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) );
+ std::vector<Rectangle> aRegions(partitionAndClear(4,3));
- SetTextColor( Color( COL_WHITE ) );
- vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) );
- SetFont( aFont );
- DrawText( Point( 20, 30 ), OUString( "Just a simple test text" ) );
+ int i = 0;
+ drawRadialLines(aRegions[i++]);
+ drawText(aRegions[i++]);
+ drawPoly(aRegions[i++]);
+ drawPolyPoly(aRegions[i++]);
+ drawCheckered(aRegions[i++]);
+ drawGradient(aRegions[i++]);
}
void MyWin::Resize()
More information about the Libreoffice-commits
mailing list