Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <sal/main.h>
21 :
22 : #include <cppuhelper/bootstrap.hxx>
23 : #include <comphelper/processfactory.hxx>
24 :
25 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 : #include <com/sun/star/uno/XComponentContext.hpp>
27 :
28 : #include <vcl/event.hxx>
29 : #include <vcl/svapp.hxx>
30 : #include <vcl/wrkwin.hxx>
31 : #include <tools/extendapplicationenvironment.hxx>
32 :
33 : #include <svx/dlgctrl.hxx>
34 :
35 : #include <rtl/strbuf.hxx>
36 : #include <rtl/ustrbuf.hxx>
37 :
38 : #include <math.h>
39 :
40 : using namespace ::com::sun::star::uno;
41 : using namespace ::com::sun::star::lang;
42 : using namespace cppu;
43 :
44 : // Forward declaration
45 : void Main();
46 :
47 0 : SAL_IMPLEMENT_MAIN()
48 : {
49 : try
50 : {
51 0 : tools::extendApplicationEnvironment();
52 :
53 : // create the global service-manager
54 0 : Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
55 0 : Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
56 :
57 0 : if( !xServiceManager.is() )
58 0 : Application::Abort( "Failed to bootstrap" );
59 :
60 0 : comphelper::setProcessServiceFactory( xServiceManager );
61 :
62 0 : InitVCL();
63 0 : ::Main();
64 0 : DeInitVCL();
65 : }
66 0 : catch (const Exception& e)
67 : {
68 : SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
69 0 : return 1;
70 : }
71 0 : catch (const std::exception& e)
72 : {
73 : SAL_WARN("vcl.app", "Fatal exception: " << e.what());
74 0 : return 1;
75 : }
76 :
77 0 : return 0;
78 : }
79 :
80 : class MyWin : public WorkWindow
81 : {
82 : VclPtr<SvxPixelCtl> maPixelCtl;
83 :
84 : public:
85 : MyWin(vcl::Window* pParent, WinBits nWinStyle);
86 0 : virtual ~MyWin()
87 0 : {
88 0 : disposeOnce();
89 0 : }
90 : virtual void dispose() SAL_OVERRIDE;
91 : void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
92 : void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
93 : void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
94 : void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
95 : void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
96 : void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
97 : void Resize() SAL_OVERRIDE;
98 : bool Close() SAL_OVERRIDE;
99 : };
100 :
101 0 : void Main()
102 : {
103 0 : ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_STDWORK );
104 0 : aMainWin->SetText( OUString( "SvxPixelCtl" ) );
105 0 : aMainWin->Show();
106 :
107 0 : Application::Execute();
108 0 : }
109 :
110 0 : MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
111 : WorkWindow( pParent, nWinStyle ),
112 0 : maPixelCtl( VclPtr<SvxPixelCtl>::Create(this) )
113 : {
114 0 : maPixelCtl->SetPosSizePixel( Point( 10, 10 ), Size( 200, 200 ) );
115 0 : maPixelCtl->Show();
116 :
117 0 : }
118 :
119 0 : void MyWin::dispose()
120 : {
121 0 : maPixelCtl.disposeAndClear();
122 0 : WorkWindow::dispose();
123 0 : }
124 :
125 0 : bool MyWin::Close()
126 : {
127 0 : bool bRet = WorkWindow::Close();
128 0 : if( bRet )
129 0 : Application::Quit();
130 0 : return bRet;
131 : }
132 :
133 0 : void MyWin::MouseMove( const MouseEvent& rMEvt )
134 : {
135 0 : WorkWindow::MouseMove( rMEvt );
136 0 : }
137 :
138 0 : void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
139 : {
140 0 : WorkWindow::MouseButtonDown( rMEvt );
141 0 : }
142 :
143 0 : void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
144 : {
145 0 : WorkWindow::MouseButtonUp( rMEvt );
146 0 : }
147 :
148 0 : void MyWin::KeyInput( const KeyEvent& rKEvt )
149 : {
150 0 : WorkWindow::KeyInput( rKEvt );
151 0 : }
152 :
153 0 : void MyWin::KeyUp( const KeyEvent& rKEvt )
154 : {
155 0 : WorkWindow::KeyUp( rKEvt );
156 0 : }
157 :
158 0 : void MyWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
159 : {
160 0 : WorkWindow::Paint(rRenderContext, rRect);
161 0 : }
162 :
163 0 : void MyWin::Resize()
164 : {
165 0 : WorkWindow::Resize();
166 0 : }
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|