update dev300-m58
[ooovba.git] / vcl / workben / vcldemo.cxx
blob169873e63d35503ed359baf9e94bec2c5637fef0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vcldemo.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <sal/main.h>
35 #include <tools/extendapplicationenvironment.hxx>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <vcl/event.hxx>
39 #include <vcl/svapp.hxx>
40 #include <vcl/wrkwin.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <vcl/introwin.hxx>
43 #include <vcl/msgbox.hxx>
45 #include <comphelper/processfactory.hxx>
46 #include <cppuhelper/servicefactory.hxx>
47 #include <cppuhelper/bootstrap.hxx>
49 #include <unistd.h>
50 #include <stdio.h>
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::lang;
54 // -----------------------------------------------------------------------
56 // Forward declaration
57 void Main();
59 // -----------------------------------------------------------------------
61 SAL_IMPLEMENT_MAIN()
63 tools::extendApplicationEnvironment();
65 Reference< XMultiServiceFactory > xMS;
66 xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
68 InitVCL( xMS );
69 ::Main();
70 DeInitVCL();
72 return 0;
75 // -----------------------------------------------------------------------
77 class MyWin : public WorkWindow
79 public:
80 MyWin( Window* pParent, WinBits nWinStyle );
82 void MouseMove( const MouseEvent& rMEvt );
83 void MouseButtonDown( const MouseEvent& rMEvt );
84 void MouseButtonUp( const MouseEvent& rMEvt );
85 void KeyInput( const KeyEvent& rKEvt );
86 void KeyUp( const KeyEvent& rKEvt );
87 void Paint( const Rectangle& rRect );
88 void Resize();
91 // -----------------------------------------------------------------------
93 void Main()
96 IntroWindow splash;
97 splash.Show();
98 sleep(5);
99 splash.Hide();
102 MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
103 aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCLDemo - VCL Workbench" ) ) );
104 aMainWin.Show();
107 InfoBox ib(NULL, String((sal_Char*)"Test", sizeof("Test")));
108 ib.Execute();
111 Application::Execute();
114 // -----------------------------------------------------------------------
116 MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
117 WorkWindow( pParent, nWinStyle )
121 // -----------------------------------------------------------------------
123 void MyWin::MouseMove( const MouseEvent& rMEvt )
125 WorkWindow::MouseMove( rMEvt );
128 // -----------------------------------------------------------------------
130 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
132 Rectangle aRect(0,0,4,4);
133 aRect.SetPos( rMEvt.GetPosPixel() );
134 SetFillColor(Color(COL_RED));
135 DrawRect( aRect );
138 // -----------------------------------------------------------------------
140 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
142 WorkWindow::MouseButtonUp( rMEvt );
145 // -----------------------------------------------------------------------
147 void MyWin::KeyInput( const KeyEvent& rKEvt )
149 WorkWindow::KeyInput( rKEvt );
152 // -----------------------------------------------------------------------
154 void MyWin::KeyUp( const KeyEvent& rKEvt )
156 WorkWindow::KeyUp( rKEvt );
159 // -----------------------------------------------------------------------
161 void MyWin::Paint( const Rectangle& rRect )
163 fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
165 Size aSz(GetSizePixel());
166 Point aPt;
167 Rectangle r(aPt, aSz);
169 SetFillColor(Color(COL_BLUE));
170 SetLineColor(Color(COL_YELLOW));
172 DrawRect( r );
174 for(int i=0; i<aSz.Height(); i+=15)
175 DrawLine( Point(r.nLeft, r.nTop+i), Point(r.nRight, r.nBottom-i) );
176 for(int i=0; i<aSz.Width(); i+=15)
177 DrawLine( Point(r.nLeft+i, r.nBottom), Point(r.nRight-i, r.nTop) );
179 SetTextColor( Color( COL_WHITE ) );
180 Font aFont( String( RTL_CONSTASCII_USTRINGPARAM( "Times" ) ), Size( 0, 25 ) );
181 SetFont( aFont );
182 DrawText( Point( 20, 30 ), String( RTL_CONSTASCII_USTRINGPARAM( "Just a simple test text" ) ) );
185 // -----------------------------------------------------------------------
187 void MyWin::Resize()
189 WorkWindow::Resize();