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 .
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>
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
40 // Forward declaration
46 tools::extendApplicationEnvironment();
48 Reference
< XMultiServiceFactory
> xMS
;
49 xMS
= cppu::createRegistryServiceFactory( OUString( "types.rdb" ), OUString( "applicat.rdb" ), sal_True
);
51 comphelper::setProcessServiceFactory( xMS
);
61 class MyWin
: public WorkWindow
64 MyWin( Window
* pParent
, WinBits nWinStyle
);
66 void MouseMove( const MouseEvent
& rMEvt
);
67 void MouseButtonDown( const MouseEvent
& rMEvt
);
68 void MouseButtonUp( const MouseEvent
& rMEvt
);
69 void KeyInput( const KeyEvent
& rKEvt
);
70 void KeyUp( const KeyEvent
& rKEvt
);
71 void Paint( const Rectangle
& rRect
);
78 MyWin
aMainWin( NULL
, WB_APP
| WB_STDWORK
);
79 aMainWin
.SetText( OUString( "VCLDemo - VCL Workbench" ) );
82 Application::Execute();
86 MyWin::MyWin( Window
* pParent
, WinBits nWinStyle
) :
87 WorkWindow( pParent
, nWinStyle
)
92 void MyWin::MouseMove( const MouseEvent
& rMEvt
)
94 WorkWindow::MouseMove( rMEvt
);
98 void MyWin::MouseButtonDown( const MouseEvent
& rMEvt
)
100 Rectangle
aRect(0,0,4,4);
101 aRect
.SetPos( rMEvt
.GetPosPixel() );
102 SetFillColor(Color(COL_RED
));
107 void MyWin::MouseButtonUp( const MouseEvent
& rMEvt
)
109 WorkWindow::MouseButtonUp( rMEvt
);
113 void MyWin::KeyInput( const KeyEvent
& rKEvt
)
115 WorkWindow::KeyInput( rKEvt
);
119 void MyWin::KeyUp( const KeyEvent
& rKEvt
)
121 WorkWindow::KeyUp( rKEvt
);
125 void MyWin::Paint( const Rectangle
& rRect
)
127 fprintf(stderr
, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect
.getX(), rRect
.getY(), rRect
.getWidth(), rRect
.getHeight());
129 Size
aSz(GetSizePixel());
131 Rectangle
r(aPt
, aSz
);
133 SetFillColor(Color(COL_BLUE
));
134 SetLineColor(Color(COL_YELLOW
));
138 for(int i
=0; i
<aSz
.Height(); i
+=15)
139 DrawLine( Point(r
.Left(), r
.Top()+i
), Point(r
.Right(), r
.Bottom()-i
) );
140 for(int i
=0; i
<aSz
.Width(); i
+=15)
141 DrawLine( Point(r
.Left()+i
, r
.Bottom()), Point(r
.Right()-i
, r
.Top()) );
143 SetTextColor( Color( COL_WHITE
) );
144 Font
aFont( String( RTL_CONSTASCII_USTRINGPARAM( "Times" ) ), Size( 0, 25 ) );
146 DrawText( Point( 20, 30 ), String( RTL_CONSTASCII_USTRINGPARAM( "Just a simple test text" ) ) );
152 WorkWindow::Resize();
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */