Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / vcl / workben / vcldemo.cxx
blob34a2c9ac78d40bc18ef8eb371fb5bcf1820eac6e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sal/main.h>
22 #include <tools/extendapplicationenvironment.hxx>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <vcl/event.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/wrkwin.hxx>
28 #include <vcl/msgbox.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <cppuhelper/servicefactory.hxx>
32 #include <cppuhelper/bootstrap.hxx>
34 #include <unistd.h>
35 #include <stdio.h>
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 // -----------------------------------------------------------------------
41 // Forward declaration
42 void Main();
44 // -----------------------------------------------------------------------
46 SAL_IMPLEMENT_MAIN()
48 tools::extendApplicationEnvironment();
50 Reference< XMultiServiceFactory > xMS;
51 xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "types.rdb" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
53 comphelper::setProcessServiceFactory( xMS );
55 InitVCL();
56 ::Main();
57 DeInitVCL();
59 return 0;
62 // -----------------------------------------------------------------------
64 class MyWin : public WorkWindow
66 public:
67 MyWin( Window* pParent, WinBits nWinStyle );
69 void MouseMove( const MouseEvent& rMEvt );
70 void MouseButtonDown( const MouseEvent& rMEvt );
71 void MouseButtonUp( const MouseEvent& rMEvt );
72 void KeyInput( const KeyEvent& rKEvt );
73 void KeyUp( const KeyEvent& rKEvt );
74 void Paint( const Rectangle& rRect );
75 void Resize();
78 // -----------------------------------------------------------------------
80 void Main()
82 MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
83 aMainWin.SetText( rtl::OUString( "VCLDemo - VCL Workbench" ) );
84 aMainWin.Show();
87 InfoBox ib(NULL, String((sal_Char*)"Test", sizeof("Test")));
88 ib.Execute();
91 Application::Execute();
94 // -----------------------------------------------------------------------
96 MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
97 WorkWindow( pParent, nWinStyle )
101 // -----------------------------------------------------------------------
103 void MyWin::MouseMove( const MouseEvent& rMEvt )
105 WorkWindow::MouseMove( rMEvt );
108 // -----------------------------------------------------------------------
110 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
112 Rectangle aRect(0,0,4,4);
113 aRect.SetPos( rMEvt.GetPosPixel() );
114 SetFillColor(Color(COL_RED));
115 DrawRect( aRect );
118 // -----------------------------------------------------------------------
120 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
122 WorkWindow::MouseButtonUp( rMEvt );
125 // -----------------------------------------------------------------------
127 void MyWin::KeyInput( const KeyEvent& rKEvt )
129 WorkWindow::KeyInput( rKEvt );
132 // -----------------------------------------------------------------------
134 void MyWin::KeyUp( const KeyEvent& rKEvt )
136 WorkWindow::KeyUp( rKEvt );
139 // -----------------------------------------------------------------------
141 void MyWin::Paint( const Rectangle& rRect )
143 fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
145 Size aSz(GetSizePixel());
146 Point aPt;
147 Rectangle r(aPt, aSz);
149 SetFillColor(Color(COL_BLUE));
150 SetLineColor(Color(COL_YELLOW));
152 DrawRect( r );
154 for(int i=0; i<aSz.Height(); i+=15)
155 DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) );
156 for(int i=0; i<aSz.Width(); i+=15)
157 DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) );
159 SetTextColor( Color( COL_WHITE ) );
160 Font aFont( String( RTL_CONSTASCII_USTRINGPARAM( "Times" ) ), Size( 0, 25 ) );
161 SetFont( aFont );
162 DrawText( Point( 20, 30 ), String( RTL_CONSTASCII_USTRINGPARAM( "Just a simple test text" ) ) );
165 // -----------------------------------------------------------------------
167 void MyWin::Resize()
169 WorkWindow::Resize();
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */