xref: /aoo4110/main/vcl/workben/vcldemo.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include <sal/main.h>
28 #include <tools/extendapplicationenvironment.hxx>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 
31 #include <vcl/event.hxx>
32 #include <vcl/svapp.hxx>
33 #include <vcl/wrkwin.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <vcl/introwin.hxx>
36 #include <vcl/msgbox.hxx>
37 
38 #include <comphelper/processfactory.hxx>
39 #include <cppuhelper/servicefactory.hxx>
40 #include <cppuhelper/bootstrap.hxx>
41 
42 #include <unistd.h>
43 #include <stdio.h>
44 
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::lang;
47 // -----------------------------------------------------------------------
48 
49 // Forward declaration
50 void Main();
51 
52 // -----------------------------------------------------------------------
53 
SAL_IMPLEMENT_MAIN()54 SAL_IMPLEMENT_MAIN()
55 {
56     tools::extendApplicationEnvironment();
57 
58     Reference< XMultiServiceFactory > xMS;
59     xMS = cppu::createRegistryServiceFactory( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "types.rdb" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
60 
61     InitVCL( xMS );
62     ::Main();
63     DeInitVCL();
64 
65     return 0;
66 }
67 
68 // -----------------------------------------------------------------------
69 
70 class MyWin : public WorkWindow
71 {
72 public:
73 				MyWin( Window* pParent, WinBits nWinStyle );
74 
75 	void		MouseMove( const MouseEvent& rMEvt );
76 	void		MouseButtonDown( const MouseEvent& rMEvt );
77 	void		MouseButtonUp( const MouseEvent& rMEvt );
78 	void		KeyInput( const KeyEvent& rKEvt );
79 	void		KeyUp( const KeyEvent& rKEvt );
80 	void		Paint( const Rectangle& rRect );
81 	void		Resize();
82 };
83 
84 // -----------------------------------------------------------------------
85 
Main()86 void Main()
87 {
88     /*
89     IntroWindow splash;
90     splash.Show();
91     sleep(5);
92     splash.Hide();
93     */
94 
95 	MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
96 	aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCLDemo - VCL Workbench" ) ) );
97 	aMainWin.Show();
98 
99     /*
100     InfoBox ib(NULL, String((sal_Char*)"Test", sizeof("Test")));
101     ib.Execute();
102     */
103 
104 	Application::Execute();
105 }
106 
107 // -----------------------------------------------------------------------
108 
MyWin(Window * pParent,WinBits nWinStyle)109 MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
110 	WorkWindow( pParent, nWinStyle )
111 {
112 }
113 
114 // -----------------------------------------------------------------------
115 
MouseMove(const MouseEvent & rMEvt)116 void MyWin::MouseMove( const MouseEvent& rMEvt )
117 {
118 	WorkWindow::MouseMove( rMEvt );
119 }
120 
121 // -----------------------------------------------------------------------
122 
MouseButtonDown(const MouseEvent & rMEvt)123 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
124 {
125     Rectangle aRect(0,0,4,4);
126 	aRect.SetPos( rMEvt.GetPosPixel() );
127 	SetFillColor(Color(COL_RED));
128 	DrawRect( aRect );
129 }
130 
131 // -----------------------------------------------------------------------
132 
MouseButtonUp(const MouseEvent & rMEvt)133 void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
134 {
135     WorkWindow::MouseButtonUp( rMEvt );
136 }
137 
138 // -----------------------------------------------------------------------
139 
KeyInput(const KeyEvent & rKEvt)140 void MyWin::KeyInput( const KeyEvent& rKEvt )
141 {
142 	WorkWindow::KeyInput( rKEvt );
143 }
144 
145 // -----------------------------------------------------------------------
146 
KeyUp(const KeyEvent & rKEvt)147 void MyWin::KeyUp( const KeyEvent& rKEvt )
148 {
149 	WorkWindow::KeyUp( rKEvt );
150 }
151 
152 // -----------------------------------------------------------------------
153 
Paint(const Rectangle & rRect)154 void MyWin::Paint( const Rectangle& rRect )
155 {
156 	fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
157 
158     Size aSz(GetSizePixel());
159     Point aPt;
160     Rectangle r(aPt, aSz);
161 
162 	SetFillColor(Color(COL_BLUE));
163     SetLineColor(Color(COL_YELLOW));
164 
165 	DrawRect( r );
166 
167     for(int i=0; i<aSz.Height(); i+=15)
168         DrawLine( Point(r.nLeft, r.nTop+i), Point(r.nRight, r.nBottom-i) );
169     for(int i=0; i<aSz.Width(); i+=15)
170         DrawLine( Point(r.nLeft+i, r.nBottom), Point(r.nRight-i, r.nTop) );
171 
172     SetTextColor( Color( COL_WHITE ) );
173     Font aFont( String( RTL_CONSTASCII_USTRINGPARAM( "Times" ) ), Size( 0, 25 ) );
174     SetFont( aFont );
175     DrawText( Point( 20, 30 ), String( RTL_CONSTASCII_USTRINGPARAM( "Just a simple test text" ) ) );
176 }
177 
178 // -----------------------------------------------------------------------
179 
Resize()180 void MyWin::Resize()
181 {
182 	WorkWindow::Resize();
183 }
184