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