1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <tools/extendapplicationenvironment.hxx>
23 #include <cppuhelper/bootstrap.hxx>
24 #include <comphelper/processfactory.hxx>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <vcl/event.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/wrkwin.hxx>
32 #include <vcl/msgbox.hxx>
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
41 // Forward declaration
46 tools::extendApplicationEnvironment();
48 Reference
< XComponentContext
> xContext
= defaultBootstrap_InitialComponentContext();
49 Reference
< XMultiServiceFactory
> xServiceManager( xContext
->getServiceManager(), UNO_QUERY
);
51 if( !xServiceManager
.is() )
52 Application::Abort( "Failed to bootstrap" );
54 comphelper::setProcessServiceFactory( xServiceManager
);
63 class MyWin
: public WorkWindow
66 MyWin( Window
* pParent
, WinBits nWinStyle
);
68 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
69 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
70 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
71 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
72 virtual void KeyUp( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
73 virtual void Paint( const Rectangle
& rRect
) SAL_OVERRIDE
;
74 virtual void Resize() SAL_OVERRIDE
;
79 MyWin
aMainWin( NULL
, WB_APP
| WB_STDWORK
);
80 aMainWin
.SetText( OUString( "VCLDemo - VCL Workbench" ) );
83 Application::Execute();
86 MyWin::MyWin( Window
* pParent
, WinBits nWinStyle
) :
87 WorkWindow( pParent
, nWinStyle
)
91 void MyWin::MouseMove( const MouseEvent
& rMEvt
)
93 WorkWindow::MouseMove( rMEvt
);
96 void MyWin::MouseButtonDown( const MouseEvent
& rMEvt
)
98 Rectangle
aRect(0,0,4,4);
99 aRect
.SetPos( rMEvt
.GetPosPixel() );
100 SetFillColor(Color(COL_RED
));
104 void MyWin::MouseButtonUp( const MouseEvent
& rMEvt
)
106 WorkWindow::MouseButtonUp( rMEvt
);
109 void MyWin::KeyInput( const KeyEvent
& rKEvt
)
111 WorkWindow::KeyInput( rKEvt
);
114 void MyWin::KeyUp( const KeyEvent
& rKEvt
)
116 WorkWindow::KeyUp( rKEvt
);
119 void MyWin::Paint( const Rectangle
& rRect
)
121 fprintf(stderr
, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect
.getX(), rRect
.getY(), rRect
.getWidth(), rRect
.getHeight());
123 Size
aSz(GetSizePixel());
125 Rectangle
r(aPt
, aSz
);
127 SetFillColor(Color(COL_BLUE
));
128 SetLineColor(Color(COL_YELLOW
));
132 for(int i
=0; i
<aSz
.Height(); i
+=15)
133 DrawLine( Point(r
.Left(), r
.Top()+i
), Point(r
.Right(), r
.Bottom()-i
) );
134 for(int i
=0; i
<aSz
.Width(); i
+=15)
135 DrawLine( Point(r
.Left()+i
, r
.Bottom()), Point(r
.Right()-i
, r
.Top()) );
137 SetTextColor( Color( COL_WHITE
) );
138 Font
aFont( OUString( "Times" ), Size( 0, 25 ) );
140 DrawText( Point( 20, 30 ), OUString( "Just a simple test text" ) );
145 WorkWindow::Resize();
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */