1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: controls.cxx,v $
* $Revision: 1.6 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_toolkit.hxx"
#include <tools/debug.hxx>
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/msgbox.hxx>
#include <stardiv/uno/awt/window.hxx>
#include <stardiv/uno/awt/vclwin.hxx>
#include <stardiv/uno/awt/printer.hxx>
#include <stardiv/uno/repos/serinfo.hxx>
#include <stardiv/uno/lang/factory.hxx>
#include <unoctrl.hxx>
// #include <unoctrl2.hxx>
#include <svtools/unoiface.hxx> // InitExtToolkit
UsrAny UsrAny_UINT16( UINT16 n )
{
UsrAny aVal;
aVal.setUINT16( n );
return aVal;
}
// -----------------------------------------------------------------------
class MyApp : public Application
{
public:
void Main();
};
MyApp aMyApp;
// -----------------------------------------------------------------------
class MyWin : public WorkWindow
{
XControlRef xCtrl;
XPropertySetRef xCtrlModel;
XControlContainerRef xCont;
XPropertySetRef xContModel;
XControlRef xDrawCtrl;
XGraphicsRef xG;
public:
MyWin( Window* pParent, WinBits nWinStyle );
~MyWin();
void MouseButtonDown( const MouseEvent& rMEvt );
void Resize();
void Paint( const Rectangle& r );
};
// -----------------------------------------------------------------------
void MyApp::Main()
{
createAndSetDefaultServiceManager();
MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
aMainWin.SetText( "Uno-Controls - Workbench" );
aMainWin.Show();
Execute();
}
// -----------------------------------------------------------------------
MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
WorkWindow( pParent, nWinStyle )
{
}
// -----------------------------------------------------------------------
MyWin::~MyWin()
{
XComponentRef xC1( xCont, USR_QUERY );
xC1->dispose();
XComponentRef xC2( xContModel, USR_QUERY );
xC2->dispose();
}
// -----------------------------------------------------------------------
void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
{
if( rMEvt.GetClicks() == 2 )
{
XViewRef xV( xDrawCtrl, USR_QUERY );
XWindowRef xC( xDrawCtrl, USR_QUERY );
xV->draw( xC->getPosSize().Left(), xC->getPosSize().Top() );
// Printer Testen...
/*
XServiceManagerRef xProv = getGlobalServiceManager();
XServiceProviderRef xSSI = xProv->queryServiceProvider( L"stardiv.vcl.PrinterServer" );
XPrinterServerRef xPrinterServer( xSSI->createInstance(), USR_QUERY );
Sequence< UString > aPrinterNames = xPrinterServer->getPrinterNames();
USHORT nPrinters = aPrinterNames.getLen();
String aInfo( "Printers: " );
aInfo += nPrinters;
if ( nPrinters )
{
for ( USHORT n = 0; n < nPrinters; n++ )
{
aInfo += '\n';
aInfo += OUStringToString( aPrinterNames.getConstArray()[n], CHARSET_SYSTEM );
}
XPrinterRef xPrinter = xPrinterServer->createPrinter( aPrinterNames.getConstArray()[0] );
xPrinter->start( L"UNOPrinterTest", 1, TRUE );
XDeviceRef xDev = xPrinter->startPage();
XGraphicsRef xGraphics = xDev->createGraphics();
xGraphics->drawText( 200, 200, L"Printed with UNO" );
xPrinter->endPage();
xPrinter->end();
}
InfoBox( this, aInfo ).Execute();
*/
}
else if( rMEvt.GetClicks() == 1 )
{
if( xContModel )
{
static INT32 nColor = 0x001788ab;
xContModel->setPropertyValue( L"BackgroundColor", UsrAny( nColor ) );
nColor += 0x00111111;
nColor &= 0xFFFFFF;
}
else
{
XServiceManagerRef xProv = getGlobalServiceManager();
XMultiServiceFactoryRef xMSF = NAMESPACE_USR( getProcessServiceManager )();
XServiceProviderRef xSSI = xProv->queryServiceProvider( L"stardiv.vcl.VclToolkit" );
XToolkitRef xToolkit( xMSF->createInstance( L"stardiv.vcl.VclToolkit" ), USR_QUERY );
DBG_ASSERT( xToolkit, "No Toolkit!" );
// Uno Container + Model erzeugen
XServiceProviderRef xModelProv; // = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.ControlContainer" );
XInterfaceRef xCMRef( xMSF->createInstance(L"stardiv.vcl.controlmodel.ControlContainer") );
xCMRef->queryInterface( XPropertySet::getSmartUik(), xContModel );
xContModel->setPropertyValue( L"Border", UsrAny_UINT16( 1 ) );
xContModel->setPropertyValue( L"BackgroundColor", UsrAny( (UINT32)0x00CCCCCC) );
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.control.ControlContainer" );
XInterfaceRef xCCRef( xModelProv->createInstance(), USR_QUERY );
xCCRef->queryInterface( XControlContainer::getSmartUik(), xCont );
XControlModelRef xCM( xContModel, USR_QUERY );
XControlRef xContControl( xCont, USR_QUERY );
xContControl->setModel( xCM );
XWindowRef xContComp( xCont, USR_QUERY );
xContComp->setPosSize( 0, 0, 500, 600, PosSize_POSSIZE );
// Zwei EditControls auf einem Model...
// xModelProv = xProv->queryServiceProvider( L"stardiv.uno.awt.UnoControlEditModel" );
XInterfaceRef xModel( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEditModel") );
DBG_ASSERT( xModel, "No Model!" );
XPropertySetRef xPSet( xModel, USR_QUERY );
xPSet->setPropertyValue( L"Text", UsrAny( UString( L"Hallo!" ) ) );
xPSet->setPropertyValue( L"FontName", UsrAny( UString( L"Times New Roman" ) ) );
// xPSet->setPropertyValue( L"FontWeight", UsrAny( 200 ) );
XServiceProviderRef xEditCtrlProv = xProv->queryServiceProvider( L"stardiv.uno.awt.UnoControlEdit" );
// Edit1
XControlRef xEdit1( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEdit"), USR_QUERY );
xModel->queryInterface( XControlModel::getSmartUik(), xCM );
xEdit1->setModel( xCM );
XWindowRef xEditCmp1( xEdit1, USR_QUERY );
xEditCmp1->setPosSize( 50, 50, 100, 60, PosSize_POSSIZE );
xCont->addControl( L"", xEdit1 );
// Edit2
XControlRef xEdit2( xMSF->createInstance(L"stardiv.uno.awt.UnoControlEdit"), USR_QUERY );
xModel->queryInterface( XControlModel::getSmartUik(), xCM );
xEdit2->setModel( xCM );
XWindowRef xEditCmp2( xEdit2, USR_QUERY );
XLayoutConstrainsRef xL( xEdit2, USR_QUERY );
if ( xL.is() )
{
Size aSz = xL->getPreferredSize();
xEditCmp2->setPosSize( 100, 180, aSz.Width(), aSz.Height(), PosSize_POSSIZE );
}
else
xEditCmp2->setPosSize( 100, 180, 100, 40, PosSize_POSSIZE );
xCont->addControl( L"", xEdit2 );
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.NumericField" );
XInterfaceRef xNumModel( xModelProv->createInstance(), USR_QUERY );
DBG_ASSERT( xNumModel, "No Model!" );
XServiceProviderRef xNumFieldProv = xProv->queryServiceProvider( L"stardiv.vcl.control.NumericField" );
XControlRef xNumField( xNumFieldProv->createInstance(), USR_QUERY );
xNumModel->queryInterface( XControlModel::getSmartUik(), xCM );
xNumField->setModel( xCM );
XWindowRef xNumFieldWin( xNumField, USR_QUERY );
xNumFieldWin->setPosSize( 50, 250, 100, 60, PosSize_POSSIZE );
xCont->addControl( L"", xNumField );
XMultiPropertySetRef xPSet2( xNumModel, USR_QUERY );
Sequence<UString> Names( 2 );
Names.getArray()[0] = L"Value";
Names.getArray()[1] = L"ValueMin";
Sequence<UsrAny> Values( 2 );
Values.getArray()[0] = UsrAny( -2000000.0 );
Values.getArray()[1] = UsrAny( -2000000.0 );
xPSet2->setPropertyValues( Names, Values );
// Button...
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.Button" );
xModelProv->createInstance()->queryInterface( XInterface::getSmartUik(), xModel );
DBG_ASSERT( xModel, "No Model!" );
xModel->queryInterface( XPropertySet::getSmartUik(), xPSet );
xPSet->setPropertyValue( L"Label", UsrAny( L"Press!" ) );
XServiceProviderRef xButtonCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.Button" );
XControlRef xButton1( xButtonCtrlProv->createInstance(), USR_QUERY );
xModel->queryInterface( XControlModel::getSmartUik(), xCM );
xButton1->setModel( xCM );
XWindowRef xButtonCmp1( xButton1, USR_QUERY );
xButtonCmp1->setPosSize( 170, 80, 80, 80, PosSize_POSSIZE );
// Unsichtbar, nur im MBDown mit DrawRoutine bei Doppel-Klick...
xButtonCmp1->setVisible( FALSE );
xDrawCtrl = xButton1;
xCont->addControl( L"", xButton1 );
/*
// ListBox...
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.ListBox" );
xModel = (XInterface*)xModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
Sequence<UString> aSeq( 7 );
aSeq.getArray()[0] = L"Item1";
aSeq.getArray()[1] = L"Item2";
aSeq.getArray()[2] = L"Item3";
aSeq.getArray()[3] = L"Item4";
aSeq.getArray()[4] = L"Item5";
aSeq.getArray()[5] = L"Item6";
aSeq.getArray()[6] = L"Item7";
xPSet->setPropertyValue( L"StringItemList", UsrAny( &aSeq, Sequence<UString>::getReflection() ) );
xPSet->setPropertyValue( L"LineCount", UsrAny_UINT16( 4 ) );
xPSet->setPropertyValue( L"Dropdown", UsrAny( (BOOL)TRUE ) );
XServiceProviderRef xListBoxCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.ListBox" );
XControlRef xListBox1 = (XControl*)xListBoxCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xListBox1->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xListBoxCmp1 = (XWindow*)xListBox1->queryInterface( XWindow::getSmartUik() );
xListBoxCmp1->setPosSize( 20, 250, 200, 20, PosSize_POSSIZE );
xCont->addControl( L"", xListBox1 );
// FixedText...
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.FixedText" );
xModel = (XInterface*)xModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
DBG_ASSERT( xModel, "No Model!" );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Label:" ) );
xPSet->setPropertyValue( L"BackgroundColor", UsrAny( (UINT32)0x00888888) );
Font_Attribs aFontAttrs;
aFontAttrs.Italic = ITALIC_NORMAL;
xPSet->setPropertyValue( L"Font_Attribs", UsrAny( &aFontAttrs, Font_Attribs_getReflection() ) );
XPropertyStateRef xState = (XPropertyState*)xPSet->queryInterface( XPropertyState::getSmartUik() );
xState->getPropertyState( L"Font_Attribs" );
xState->getPropertyState( L"Font_Size" );
XServiceProviderRef xFixedTextCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.FixedText" );
XControlRef xFixedText1 = (XControl*)xFixedTextCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
DBG_ASSERT( xFixedText1, "No FixedText!" );
xFixedText1->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xFixedTextCmp1 = (XWindow*)xFixedText1->queryInterface( XWindow::getSmartUik() );
xFixedTextCmp1->setPosSize( 20, 20, 120, 20, PosSize_POSSIZE );
xCont->addControl( L"", xFixedText1 );
// TabTest...
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.GroupBox" );
xModel = (XInterface*)xModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Radio-Test:" ) );
XServiceProviderRef xGroupBoxCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.GroupBox" );
XControlRef xGroupBox1 = (XControl*)xGroupBoxCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xGroupBox1->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xGroupBoxCmp1 = (XWindow*)xGroupBox1->queryInterface( XWindow::getSmartUik() );
xGroupBoxCmp1->setPosSize( 30, 410, 100, 130, PosSize_POSSIZE );
xCont->addControl( L"", xGroupBox1 );
XServiceProviderRef xRadioButtonModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.RadioButton" );
XServiceProviderRef xRadioButtonCtrlProv = xProv->queryServiceProvider( L"stardiv.vcl.control.RadioButton" );
xModel = (XInterface*)xRadioButtonModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
XControlRef xT1 = (XControl*)xRadioButtonCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xT1->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xTC1 = (XWindow*)xT1->queryInterface( XWindow::getSmartUik() );
xTC1->setPosSize( 40, 430, 80, 20, PosSize_POSSIZE );
xCont->addControl( L"", xT1 );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Radio1" ) );
xPSet->setPropertyValue( L"State", UsrAny_UINT16( 1 ) );
xModel = (XInterface*)xRadioButtonModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
XControlRef xT2 = (XControl*)xRadioButtonCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xT2->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xTC2 = (XWindow*)xT2->queryInterface( XWindow::getSmartUik() );
xTC2->setPosSize( 40, 470, 80, 20, PosSize_POSSIZE );
xCont->addControl( L"", xT2 );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Radio2" ) );
xModel = (XInterface*)xRadioButtonModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
XControlRef xT3 = (XControl*)xRadioButtonCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xT3->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xTC3 = (XWindow*)xT3->queryInterface( XWindow::getSmartUik() );
xTC3->setPosSize( 40, 510, 80, 20, PosSize_POSSIZE );
xCont->addControl( L"", xT3 );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Radio3" ) );
xModel = (XInterface*)xRadioButtonModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
XControlRef xT4 = (XControl*)xRadioButtonCtrlProv->createInstance()->queryInterface( XControl::getSmartUik() );
xT4->setModel( (XControlModel*)xModel->queryInterface( XControlModel::getSmartUik() ) );
XWindowRef xTC4 = (XWindow*)xT4->queryInterface( XWindow::getSmartUik() );
xTC4->setPosSize( 40, 550, 80, 20, PosSize_POSSIZE );
xCont->addControl( L"", xT4 );
xPSet = (XPropertySet*)xModel->queryInterface( XPropertySet::getSmartUik() );
xPSet->setPropertyValue( L"Label", UsrAny( L"Radio4 - no" ) );
xPSet->setPropertyValue( L"Tabstop", UsrAny( (BOOL)TRUE ) );
// TabController:
xModelProv = xProv->queryServiceProvider( L"stardiv.vcl.controlmodel.TabController" );
xModel = (XInterface*)xModelProv->createInstance()->queryInterface( XInterface::getSmartUik() );
XTabControllerModelRef xTCModel = (XTabControllerModel*)xModel->queryInterface( XTabControllerModel::getSmartUik() );
XServiceProviderRef xTCProv = xProv->queryServiceProvider( L"stardiv.vcl.control.TabController" );
XTabControllerRef xTC = (XTabController*)xTCProv->createInstance()->queryInterface( XTabController::getSmartUik() );
xTC->setModel( (XTabControllerModel*)xModel->queryInterface( XTabControllerModel::getSmartUik() ) );
XUnoControlContainerRef xUCC = (XUnoControlContainer*)xCont->queryInterface( XUnoControlContainer::getSmartUik() );
xUCC->addTabController( xTC );
Sequence<XControlModelRef> aControls( 5 );
aControls.getArray()[0] = xGroupBox1->getModel();
aControls.getArray()[1] = xT1->getModel();
aControls.getArray()[2] = xT3->getModel();
aControls.getArray()[3] = xT2->getModel();
aControls.getArray()[4] = xT4->getModel();
xTCModel->setControls( aControls );
Sequence<XControlModelRef> aGroup( 3 );
aGroup.getArray()[0] = xT1->getModel();
aGroup.getArray()[1] = xT3->getModel();
aGroup.getArray()[2] = xT2->getModel();
xTCModel->setGroup( aGroup, L"test" );
*/
// Container anzeigen...
// Als Child zu diesem Fenster
xContControl->createPeer( XToolkitRef(), GetComponentInterface( TRUE ) );
XDeviceRef xD( xContControl->getPeer(), USR_QUERY );
xG = xD->createGraphics();
XViewRef xV ( xDrawCtrl, USR_QUERY );
xV->setGraphics( xG );
// ((UnoControl*)(XControl*)xNumField))->updateFromModel();
/*
// TEST:
WindowDecriptor aDescr;
aDescr.ComponentServiceName = "window";
aDescr.Type = VCLCOMPONENTTYPE_CONTAINER;
aDescr.Parent = GetComponentInterface( TRUE );
aDescr.WindowAttributes = WA_SHOW|WA_BORDER;
aDescr.Bounds = Rectangle( Point( 500, 50 ), Size( 300, 200 ) );
XVclWindowPeerRef xSPWin = xToolkit->createComponent( aDescr );
WindowDecriptor aDescr2;
aDescr2.ComponentServiceName = "scrollbar";
aDescr2.Type = VCLCOMPONENTTYPE_SIMPLE;
aDescr2.Parent = xSPWin;
aDescr2.WindowAttributes = WA_SHOW|WA_BORDER|WA_VSCROLL;
aDescr2.Bounds = Rectangle( Point( 250, 0 ), Size( 50, 200 ) );
XVclWindowPeerRef xSB = xToolkit->createComponent( aDescr2 );
*/
}
return;
}
WorkWindow::MouseButtonDown( rMEvt );
}
// -----------------------------------------------------------------------
void MyWin::Resize()
{
WorkWindow::Resize();
}
void MyWin::Paint( const Rectangle& r )
{
// Muss ueber PaintListener geschehen...
if ( xDrawCtrl.is() )
{
XViewRef xV( xDrawCtrl, USR_QUERY );
XWindowRef xC( xDrawCtrl, USR_QUERY );
xV->draw( xC->getPosSize().Left(), xC->getPosSize().Top() );
}
}
|