xref: /trunk/main/svtools/workben/svdem.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svtools.hxx"
30 #include <stdio.h>
31 #include <cppuhelper/servicefactory.hxx>
32 #include <comphelper/processfactory.hxx>
33 
34 #include <unotools/calendarwrapper.hxx>
35 #include <unotools/localedatawrapper.hxx>
36 
37 #include <vcl/wrkwin.hxx>
38 #include <vcl/dialog.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <vcl/print.hxx>
41 #include <vcl/svapp.hxx>
42 #include <vcl/help.hxx>
43 #include <vcl/fixed.hxx>
44 #include <vcl/button.hxx>
45 #include <vcl/scrbar.hxx>
46 #include <vcl/slider.hxx>
47 #include <vcl/group.hxx>
48 #include <vcl/toolbox.hxx>
49 #include <vcl/status.hxx>
50 #include <stdmenu.hxx>
51 #include <ctrltool.hxx>
52 #include <ctrlbox.hxx>
53 #include <tabbar.hxx>
54 #include <svtools/valueset.hxx>
55 #include <svtools/headbar.hxx>
56 #include <prgsbar.hxx>
57 #include <calendar.hxx>
58 #include <svtools/prnsetup.hxx>
59 #include <svtools/printdlg.hxx>
60 
61 using namespace ::com::sun::star;
62 
63 // -----------------------------------------------------------------------
64 
65 class MyApp : public Application
66 {
67 public:
68 	void Main();
69 };
70 
71 // -----------------------------------------------------------------------
72 
73 class ShowBitmap : public WorkWindow
74 {
75 	Bitmap			aBmp;
76 
77 public:
78 					ShowBitmap( Window* pParent, const Bitmap& rBmp );
79 
80 	virtual void	Paint( const Rectangle& );
81 	virtual sal_Bool	Close();
82 };
83 
84 // -----------------------------------------------------------------------
85 
86 class ShowFont : public Control
87 {
88 public:
89 					ShowFont( Window* pParent );
90 
91 	virtual void	Paint( const Rectangle& );
92 	void			SetFont( const Font& rFont )
93 						{ Invalidate(); Control::SetFont( rFont ); }
94 };
95 
96 // --- class OrientSlider ------------------------------------------------
97 
98 class OrientSlider : public Slider
99 {
100 public:
101 				OrientSlider( Window* pParent );
102 
103 	short		GetOrientation() const { return (short)GetThumbPos(); }
104 };
105 
106 // -----------------------------------------------------------------------
107 
108 OrientSlider::OrientSlider( Window* pParent ) :
109 	Slider( pParent, WB_HORZ | WB_DRAG )
110 {
111 	SetThumbPos( 0 );
112 	SetLineSize( 10 );
113 	SetPageSize( 100 );
114 	SetRange( Range( 0, 3600 ) );
115 }
116 
117 // -----------------------------------------------------------------------
118 
119 class MyFontDialog : public ModalDialog
120 {
121 private:
122 	FontList*		pList;
123 	Font			aCurFont;
124 	Printer 		aPrinter;
125 	FontNameBox 	aFontBox;
126 	FontStyleBox	aStyleBox;
127 	FontSizeBox 	aSizeBox;
128 	ListBox 		aUnderlineBox;
129 	ListBox 		aStrikeoutBox;
130 	CheckBox		aWordLineBox;
131 	CheckBox		aShadowBox;
132 	CheckBox		aOutlineBox;
133 	ColorListBox	aColorBox;
134 	GroupBox		aEffectBox;
135 	OrientSlider	aLineOrientSlider;
136 	ShowFont		aShowFont;
137 	GroupBox		aSampleBox;
138 	FixedText		aMapText;
139 	OKButton		aOKBtn;
140 	CancelButton	aCancelBtn;
141 
142 public:
143 					MyFontDialog( Window* pParent );
144 
145 					DECL_LINK( SelectFont, ComboBox* );
146 					DECL_LINK( SelectStyle, ComboBox* );
147 					DECL_LINK( AttrHdl, Window * );
148 	void			SetAttr();
149 	short			Execute();
150 };
151 
152 // -----------------------------------------------------------------------
153 
154 class MyTabBar : public TabBar
155 {
156 public:
157 					MyTabBar( Window* pParent,
158 							  WinBits nWinStyle = WB_STDTABBAR ) :
159 						TabBar( pParent, nWinStyle ) {}
160 
161 	virtual long	DeactivatePage();
162 	virtual long	AllowRenaming();
163 	virtual void	Split();
164 };
165 
166 // -----------------------------------------------------------------------
167 
168 class MyCalendar : public WorkWindow
169 {
170 	MenuBar 	aMenuBar;
171 	PopupMenu	aWeekStartMenu;
172 	PopupMenu	aWeekCountMenu;
173 	Calendar	aCalendar;
174 	Color		aInfoColor;
175 	Color		aHolidayColor;
176 	Color		aFrameColor;
177 
178 public:
179 				MyCalendar( Window* pParent );
180 				~MyCalendar();
181 
182 				DECL_LINK( RequestDateInfoHdl, Calendar* );
183 				DECL_LINK( DoubleClickHdl, Calendar* );
184 				DECL_LINK( MenuSelectHdl, Menu* );
185 
186 	void		Resize();
187 };
188 
189 // -----------------------------------------------------------------------
190 
191 class MyWin : public WorkWindow
192 {
193 private:
194 	Printer 		aPrn;
195 	ToolBox 		aBox;
196 	StatusBar		aBar;
197 	HeaderBar		aHeadBar;
198 	ColorListBox	aColorList;
199 	LineListBox 	aLineList;
200 	ValueSet		aValueSet;
201 	CalendarField	aCalendarField;
202 	CalendarField	aCalendarField2;
203 	MyTabBar		aTabBar;
204 	ProgressBar 	aPrgsBar;
205 	PushButton		aFontBtn;
206 	PushButton		aCalendarBtn;
207 	PushButton		aPrnSetupBtn;
208 	PushButton		aPrnDlgBtn;
209 	Size			aBoxSize;
210 	MyCalendar* 	pCalendar;
211 	PopupMenu*		pMenu;
212 	FontNameMenu*	pNameMenu;
213 	FontStyleMenu*	pStyleMenu;
214 	FontSizeMenu*	pSizeMenu;
215 
216 public:
217 					MyWin( Window* pParent, WinBits aWinStyle );
218 					~MyWin();
219 
220 					DECL_LINK( Test, PushButton* );
221 					DECL_LINK( SelectHdl, Window* );
222 					DECL_LINK( CalSelectHdl, CalendarField* );
223 	void			ContextMenu( const Point& rPos );
224 
225 	void			Command( const CommandEvent& rCEvt );
226 	void			MouseButtonDown( const MouseEvent& rMEvt );
227 	void			KeyInput( const KeyEvent& rKEvt );
228 	void			Paint( const Rectangle& rRect );
229 	void			Resize();
230 };
231 
232 // -----------------------------------------------------------------------
233 
234 void MyApp::Main()
235 {
236     try
237     {
238         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
239               xMSF = cppu::createRegistryServiceFactory(
240                   rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), sal_True );
241 
242         ::comphelper::setProcessServiceFactory( xMSF );
243 
244         Help aHelp;
245         SetHelp( &aHelp );
246         Help::EnableContextHelp();
247         Help::EnableExtHelp();
248         Help::EnableBalloonHelp();
249         Help::EnableQuickHelp();
250 
251         MyWin aMainWin( NULL, WinBits( WB_APP | WB_STDWORK | WB_CLIPCHILDREN ) );
252         aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "SVTOOLS - Workbench" ) ) );
253         aMainWin.GrabFocus();
254         aMainWin.Show();
255 
256         Execute();
257     }
258     catch ( com::sun::star::uno::Exception & e )
259     {
260         fprintf( stderr, "Error during bootstrapping servicemanager: %s\n" ,
261                  rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
262     }
263 }
264 
265 // -----------------------------------------------------------------------
266 
267 ShowBitmap::ShowBitmap( Window* pParent, const Bitmap& rBmp ) :
268 	WorkWindow( pParent, WB_STDWORK ),
269 	aBmp( rBmp )
270 {
271 	SetOutputSizePixel( rBmp.GetSizePixel() );
272 	SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap-Viewer" ) ) );
273 	Show();
274 }
275 
276 // -----------------------------------------------------------------------
277 
278 void ShowBitmap::Paint( const Rectangle& )
279 {
280 	DrawBitmap( Point(), GetOutputSizePixel(), aBmp );
281 }
282 
283 // -----------------------------------------------------------------------
284 
285 sal_Bool ShowBitmap::Close()
286 {
287 	Hide();
288 	delete this;
289 	return sal_True;
290 }
291 
292 // -----------------------------------------------------------------------
293 
294 ShowFont::ShowFont( Window* pParent ) :
295 	Control( pParent, WB_BORDER )
296 {
297 	SetMapMode( MapMode( MAP_POINT, Point(),
298 						 Fraction( 1, 10 ), Fraction( 1, 10 ) ) );
299 	SetBackground( Wallpaper( Color( COL_WHITE ) ) );
300 }
301 
302 // -----------------------------------------------------------------------
303 
304 void ShowFont::Paint( const Rectangle& )
305 {
306 	const Font& rFont = GetFont();
307 	String		aText;
308 	Size		aWindowSize( GetOutputSize() );
309 	long		x,y;
310 
311 	if ( rFont.GetOrientation() )
312 	{
313 		aText.Append( String::CreateFromInt32( rFont.GetOrientation()/10 ) );
314 		aText.AppendAscii( " degree." );
315 
316 		x = aWindowSize.Width()/2;
317 		y = aWindowSize.Height()/2;
318 	}
319 	else
320 	{
321 		aText = rFont.GetName();
322 		if ( !aText.Len() )
323 			aText.AssignAscii( "Sample" );
324 
325 		x = aWindowSize.Width()/2 - GetTextWidth( aText )/2;
326 		y = aWindowSize.Height()/2 - GetTextHeight()/2;
327 	}
328 
329 	DrawText( Point( x, y ), aText );
330 }
331 
332 // -----------------------------------------------------------------------
333 
334 MyFontDialog::MyFontDialog( Window* pParent ) :
335 	ModalDialog( pParent, WB_3DLOOK | WB_STDMODAL ),
336 	aFontBox( this ),
337 	aStyleBox( this ),
338 	aSizeBox( this ),
339 	aUnderlineBox( this, WB_DROPDOWN ),
340 	aStrikeoutBox( this, WB_DROPDOWN ),
341 	aWordLineBox( this ),
342 	aShadowBox( this ),
343 	aOutlineBox( this ),
344 	aColorBox( this, WB_DROPDOWN ),
345 	aEffectBox( this ),
346 	aLineOrientSlider( this ),
347 	aShowFont( this ),
348 	aSampleBox( this ),
349 	aMapText( this, WB_LEFT | WB_WORDBREAK ),
350 	aOKBtn( this, WB_DEFBUTTON ),
351 	aCancelBtn( this )
352 {
353 	pList = NULL;
354 
355 	aFontBox.EnableWYSIWYG( sal_True );
356 	aFontBox.EnableSymbols( sal_True );
357 	aFontBox.SetPosSizePixel( Point( 10, 10 ), Size( 140, 140 ) );
358 	aFontBox.SetSelectHdl( LINK( this, MyFontDialog, SelectFont ) );
359 	aFontBox.SetLoseFocusHdl( LINK( this, MyFontDialog, SelectFont ) );
360 	aFontBox.Show();
361 
362 	aStyleBox.SetPosSizePixel( Point( 160, 10 ), Size( 100, 140 ) );
363 	aStyleBox.SetSelectHdl( LINK( this, MyFontDialog, SelectStyle ) );
364 	aStyleBox.SetLoseFocusHdl( LINK( this, MyFontDialog, SelectStyle ) );
365 	aStyleBox.Show();
366 
367 	aSizeBox.SetPosSizePixel( Point( 270, 10 ), Size( 60, 140 ) );
368 	aSizeBox.SetSelectHdl( LINK( this, MyFontDialog, AttrHdl ) );
369 	aSizeBox.SetLoseFocusHdl( LINK( this, MyFontDialog, AttrHdl ) );
370 	aSizeBox.Show();
371 
372 	aUnderlineBox.SetPosSizePixel( Point( 15, 180 ), Size( 130, 100 ) );
373 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_NONE" ) ) );
374 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_SINGLE" ) ) );
375 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DOUBLE" ) ) );
376 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DOTTED" ) ) );
377 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DONTKNOW" ) ) );
378 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DASH" ) ) );
379 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_LONGDASH" ) ) );
380 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DASHDOT" ) ) );
381 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DASHDOTDOT" ) ) );
382 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_SMALLWAVE" ) ) );
383 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_WAVE" ) ) );
384 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_DOUBLEWAVE" ) ) );
385 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLD" ) ) );
386 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDDOTTED" ) ) );
387 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDDASH" ) ) );
388 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDLONGDASH" ) ) );
389 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDDASHDOT" ) ) );
390 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDDASHDOTDOT" ) ) );
391 	aUnderlineBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "UNDERLINE_BOLDWAVE" ) ) );
392 	aUnderlineBox.SetSelectHdl( LINK( this, MyFontDialog, AttrHdl ) );
393 	aUnderlineBox.Show();
394 
395 	aStrikeoutBox.SetPosSizePixel( Point( 15, 210 ), Size( 130, 100 ) );
396 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_NONE" ) ) );
397 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_SINGLE" ) ) );
398 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_DOUBLE" ) ) );
399 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_DONTKNOW" ) ) );
400 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_BOLD" ) ) );
401 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_SLASH" ) ) );
402 	aStrikeoutBox.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "STRIKEOUT_X" ) ) );
403 	aStrikeoutBox.SetSelectHdl( LINK( this, MyFontDialog, AttrHdl ) );
404 	aStrikeoutBox.Show();
405 
406 	aWordLineBox.SetPosSizePixel( Point( 15, 240 ), Size( 130, 19 ) );
407 	aWordLineBox.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Only ~Words" ) ) );
408 	aWordLineBox.SetClickHdl( LINK( this, MyFontDialog, AttrHdl ) );
409 	aWordLineBox.Show();
410 
411 	aShadowBox.SetPosSizePixel( Point( 15, 260 ), Size( 130, 19 ) );
412 	aShadowBox.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "~Shadow" ) ) );
413 	aShadowBox.SetClickHdl( LINK( this, MyFontDialog, AttrHdl ) );
414 	aShadowBox.Show();
415 
416 	aOutlineBox.SetPosSizePixel( Point( 15, 280 ), Size( 130, 19 ) );
417 	aOutlineBox.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "~Outline" ) ) );
418 	aOutlineBox.SetClickHdl( LINK( this, MyFontDialog, AttrHdl ) );
419 	aOutlineBox.Show();
420 
421 	{
422 	aColorBox.SetPosSizePixel( Point( 15, 305 ), Size( 130, 100 ) );
423 	aColorBox.SetSelectHdl( LINK( this, MyFontDialog, AttrHdl ) );
424 	aColorBox.SetUpdateMode( sal_False );
425 	aColorBox.InsertEntry( Color( COL_BLACK ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) );
426 	aColorBox.InsertEntry( Color( COL_BLUE ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ) );
427 	aColorBox.InsertEntry( Color( COL_GREEN ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) );
428 	aColorBox.InsertEntry( Color( COL_CYAN ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Cyan" ) ) );
429 	aColorBox.InsertEntry( Color( COL_RED ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) );
430 	aColorBox.InsertEntry( Color( COL_MAGENTA ),	   XubString( RTL_CONSTASCII_USTRINGPARAM( "Magenta" ) ) );
431 	aColorBox.InsertEntry( Color( COL_BROWN ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ) );
432 	aColorBox.InsertEntry( Color( COL_GRAY ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "Gray" ) ) );
433 	aColorBox.InsertEntry( Color( COL_LIGHTGRAY ),	   XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGray" ) ) );
434 	aColorBox.InsertEntry( Color( COL_LIGHTBLUE ),	   XubString( RTL_CONSTASCII_USTRINGPARAM( "LightBlue" ) ) );
435 	aColorBox.InsertEntry( Color( COL_LIGHTGREEN ),    XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGreen" ) ) );
436 	aColorBox.InsertEntry( Color( COL_LIGHTCYAN ),	   XubString( RTL_CONSTASCII_USTRINGPARAM( "LightCyan" ) ) );
437 	aColorBox.InsertEntry( Color( COL_LIGHTRED ),	   XubString( RTL_CONSTASCII_USTRINGPARAM( "LightRed" ) ) );
438 	aColorBox.InsertEntry( Color( COL_LIGHTMAGENTA ),  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightMagenta" ) ) );
439 	aColorBox.InsertEntry( Color( COL_YELLOW ), 	   XubString( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ) );
440 	aColorBox.InsertEntry( Color( COL_WHITE ),		   XubString( RTL_CONSTASCII_USTRINGPARAM( "White" ) ) );
441 	aColorBox.SetUpdateMode( sal_True );
442 	aColorBox.Show();
443 	}
444 
445 	aEffectBox.SetPosSizePixel( Point( 10, 160 ), Size( 140, 175 ) );
446 	aEffectBox.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Effects" ) ) );
447 	aEffectBox.Show();
448 
449 	Size aSliderSize = aLineOrientSlider.GetSizePixel();
450 	aLineOrientSlider.SetPosSizePixel( Point( 160, 335-aSliderSize.Height() ),
451 									   Size( 250, aSliderSize.Height() ) );
452 	aLineOrientSlider.SetSlideHdl( LINK( this, MyFontDialog, AttrHdl ) );
453 	aLineOrientSlider.Show();
454 
455 	aShowFont.SetPosSizePixel( Point( 165, 180 ), Size( 240, 70 ) );
456 	aShowFont.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Sample" ) ) );
457 	aShowFont.Show();
458 
459 	aSampleBox.SetPosSizePixel( Point( 160, 160 ), Size( 250, 100 ) );
460 	aSampleBox.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Sample" ) ) );
461 	aSampleBox.Show();
462 
463 	aMapText.SetPosSizePixel( Point( 160, 270 ), Size( 250, 35 ) );
464 	aMapText.Show();
465 
466 	aOKBtn.SetPosSizePixel( Point( 340, 10 ), Size( 70, 25 ) );
467 	aOKBtn.Show();
468 
469 	aCancelBtn.SetPosSizePixel( Point( 340, 40 ), Size( 70, 25 ) );
470 	aCancelBtn.Show();
471 
472 	SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "FontDialog" ) ) );
473 	SetOutputSizePixel( Size( 420, 345 ) );
474 }
475 
476 // -----------------------------------------------------------------------
477 
478 IMPL_LINK( MyFontDialog, SelectFont, ComboBox*, EMPTYARG )
479 {
480 	aStyleBox.Fill( aFontBox.GetText(), pList );
481 	FontInfo aInfo = pList->Get( aFontBox.GetText(), aStyleBox.GetText() );
482 	aSizeBox.Fill( &aInfo, pList );
483 	SetAttr();
484 	return 0;
485 }
486 
487 // -----------------------------------------------------------------------
488 
489 IMPL_LINK( MyFontDialog, SelectStyle, ComboBox*, EMPTYARG )
490 {
491 	FontInfo aInfo = pList->Get( aFontBox.GetText(), aStyleBox.GetText() );
492 	aSizeBox.Fill( &aInfo, pList );
493 	SetAttr();
494 	return 0;
495 }
496 
497 // -----------------------------------------------------------------------
498 
499 IMPL_LINK( MyFontDialog, AttrHdl, Window*, EMPTYARG )
500 {
501 	SetAttr();
502 	return 0;
503 }
504 
505 // -----------------------------------------------------------------------
506 
507 void MyFontDialog::SetAttr()
508 {
509 	FontInfo aFont( pList->Get( aFontBox.GetText(), aStyleBox.GetText() ) );
510 	aFont.SetSize( Size( 0, aSizeBox.GetValue() ) );
511 	aFont.SetUnderline( (FontUnderline)aUnderlineBox.GetSelectEntryPos() );
512 	aFont.SetStrikeout( (FontStrikeout)aStrikeoutBox.GetSelectEntryPos() );
513 	aFont.SetColor( Color( (ColorData)aColorBox.GetSelectEntryPos() ) );
514 	aFont.SetWordLineMode( aWordLineBox.IsChecked() );
515 	aFont.SetShadow( aShadowBox.IsChecked() );
516 	aFont.SetOutline( aOutlineBox.IsChecked() );
517 	aFont.SetOrientation( aLineOrientSlider.GetOrientation() );
518 	aFont.SetTransparent( sal_True );
519 	aMapText.SetText( pList->GetFontMapText( aFont ) );
520 	aShowFont.SetFont( aFont );
521 }
522 
523 // -----------------------------------------------------------------------
524 
525 short MyFontDialog::Execute()
526 {
527 	pList = new FontList( &aPrinter, this );
528 	aFontBox.Fill( pList );
529 	aSizeBox.SetValue( 120 );
530 	aUnderlineBox.SelectEntryPos( 0 );
531 	aStrikeoutBox.SelectEntryPos( 0 );
532 	aColorBox.SelectEntryPos( 0 );
533 	SelectFont( &aFontBox );
534 	short nRet = ModalDialog::Execute();
535 	delete pList;
536 	return nRet;
537 }
538 
539 // -----------------------------------------------------------------------
540 
541 long MyTabBar::DeactivatePage()
542 {
543 	if ( GetCurPageId() == 6 )
544 	{
545 		QueryBox aQueryBox( this, WB_YES_NO | WB_DEF_YES,
546 							XubString( RTL_CONSTASCII_USTRINGPARAM( "Deactivate" ) ) );
547 		if ( aQueryBox.Execute() == RET_YES )
548 			return sal_True;
549 		else
550 			return sal_False;
551 	}
552 	else
553 		return sal_True;
554 }
555 
556 // -----------------------------------------------------------------------
557 
558 long MyTabBar::AllowRenaming()
559 {
560 	XubString aStr( RTL_CONSTASCII_USTRINGPARAM( "Allow renaming: " ) );
561 	aStr += GetEditText();
562 	QueryBox aQueryBox( this, WB_YES_NO_CANCEL | WB_DEF_YES, aStr );
563 	long nRet = aQueryBox.Execute();
564 	if ( nRet == RET_YES )
565 		return TAB_RENAMING_YES;
566 	else if ( nRet == RET_NO )
567 		return TAB_RENAMING_NO;
568 	else // ( nRet == RET_CANCEL )
569 		return TAB_RENAMING_CANCEL;
570 }
571 
572 // -----------------------------------------------------------------------
573 
574 void MyTabBar::Split()
575 {
576 	Size	aSize = GetSizePixel();
577 	long	nWidth = GetSplitSize();
578 	long	nMaxWidth = GetParent()->GetOutputSizePixel().Width()-50;
579 	if ( nWidth < GetMinSize() )
580 		nWidth = GetMinSize();
581 	else if ( nWidth > nMaxWidth )
582 		nWidth = nMaxWidth;
583 	SetSizePixel( Size( nWidth, aSize.Height() ) );
584 }
585 
586 // -----------------------------------------------------------------------
587 
588 MyCalendar::MyCalendar( Window* pParent ) :
589 	WorkWindow( pParent, WB_STDWORK ),
590 	aCalendar( this, WB_TABSTOP | WB_WEEKNUMBER | WB_BOLDTEXT | WB_FRAMEINFO | WB_MULTISELECT ),
591 	aInfoColor( COL_LIGHTBLUE ),
592 	aHolidayColor( COL_LIGHTRED ),
593 	aFrameColor( COL_LIGHTRED )
594 {
595     const CalendarWrapper& rCal = aCalendar.GetCalendarWrapper();
596 	aMenuBar.InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Wochen~anfang" ) ) );
597 	aMenuBar.InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "~Erste Woche" ) ) );
598 	aMenuBar.SetPopupMenu( 1, &aWeekStartMenu );
599 	aMenuBar.SetPopupMenu( 2, &aWeekCountMenu );
600     sal_Int16 nDays = rCal.getNumberOfDaysInWeek();
601     uno::Sequence< i18n::CalendarItem> xItems = rCal.getDays();
602     const i18n::CalendarItem* pArr = xItems.getArray();
603 	for ( sal_Int16 i = 0; i < nDays; i++ )
604 		aWeekStartMenu.InsertItem( 10+(sal_uInt16)i, pArr[i].FullName, MIB_AUTOCHECK | MIB_RADIOCHECK );
605 	aWeekStartMenu.CheckItem( 10+(sal_uInt16)rCal.getFirstDayOfWeek() );
606 	aWeekCountMenu.InsertItem( 20, XubString( RTL_CONSTASCII_USTRINGPARAM( "~1. Januar" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
607 	aWeekCountMenu.InsertItem( 21, XubString( RTL_CONSTASCII_USTRINGPARAM( "~2 days" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
608 	aWeekCountMenu.InsertItem( 22, XubString( RTL_CONSTASCII_USTRINGPARAM( "~3 days" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
609 	aWeekCountMenu.InsertItem( 23, XubString( RTL_CONSTASCII_USTRINGPARAM( "Erste 4 ~Tage-Woche" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
610 	aWeekCountMenu.InsertItem( 24, XubString( RTL_CONSTASCII_USTRINGPARAM( "~5 days" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
611 	aWeekCountMenu.InsertItem( 25, XubString( RTL_CONSTASCII_USTRINGPARAM( "~6 days" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
612 	aWeekCountMenu.InsertItem( 26, XubString( RTL_CONSTASCII_USTRINGPARAM( "Erste ~volle Woche" ) ), MIB_AUTOCHECK | MIB_RADIOCHECK );
613 	//was: one of 0, 1, 2;  aWeekCountMenu.CheckItem( 20+(sal_uInt16)rIntn.GetWeekCountStart() );
614 	aWeekCountMenu.CheckItem( 20+(sal_uInt16)rCal.getMinimumNumberOfDaysForFirstWeek() );
615 	aMenuBar.SetSelectHdl( LINK( this, MyCalendar, MenuSelectHdl ) );
616 	SetMenuBar( &aMenuBar );
617 
618 	Date aCurDate = aCalendar.GetCurDate();
619 	aCalendar.SetRequestDateInfoHdl( LINK( this, MyCalendar, RequestDateInfoHdl ) );
620 	aCalendar.SetDoubleClickHdl( LINK( this, MyCalendar, DoubleClickHdl ) );
621 	aCalendar.SetSaturdayColor( Color( COL_LIGHTGREEN ) );
622 	aCalendar.SetSundayColor( aHolidayColor );
623 	aCalendar.AddDateInfo( Date(  1,  1, 0 ), XubString( RTL_CONSTASCII_USTRINGPARAM( "Neujahr" ) ), &aHolidayColor, NULL );
624 	aCalendar.AddDateInfo( Date( 24, 12, 0 ), XubString( RTL_CONSTASCII_USTRINGPARAM( "Heiligabend" ) ), &aInfoColor, NULL );
625 	aCalendar.AddDateInfo( Date( 25, 12, 0 ), XubString( RTL_CONSTASCII_USTRINGPARAM( "1. Weihnachttag" ) ), &aHolidayColor, NULL );
626 	aCalendar.AddDateInfo( Date( 26, 12, 0 ), XubString( RTL_CONSTASCII_USTRINGPARAM( "2. Weihnachttag" ) ), &aHolidayColor, NULL );
627 	aCalendar.AddDateInfo( Date( 31, 12, 0 ), XubString( RTL_CONSTASCII_USTRINGPARAM( "Silvester" ) ), &aInfoColor, NULL );
628 	aCalendar.SetPosPixel( Point() );
629 	aCalendar.SetFirstDate( Date( 1, 1, aCurDate.GetYear() ) );
630 	aCalendar.Show();
631 
632 	SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Calendar" ) ) );
633 	SetOutputSizePixel( aCalendar.CalcWindowSizePixel( 3, 4 ) );
634 }
635 
636 // -----------------------------------------------------------------------
637 
638 MyCalendar::~MyCalendar()
639 {
640 	SetMenuBar( NULL );
641 	aMenuBar.SetPopupMenu( 1, NULL );
642 	aMenuBar.SetPopupMenu( 2, NULL );
643 }
644 
645 // -----------------------------------------------------------------------
646 
647 IMPL_LINK( MyCalendar, RequestDateInfoHdl, Calendar*, EMPTYARG )
648 {
649 	sal_uInt16 nRequestYear = aCalendar.GetRequestYear();
650 	if ( (nRequestYear >= 1954) && (nRequestYear <= 1989) )
651 		aCalendar.AddDateInfo( Date(  17, 6, nRequestYear ), XubString( RTL_CONSTASCII_USTRINGPARAM( "Tag der deutschen Einheit" ) ), &aHolidayColor, NULL );
652 	else if ( nRequestYear >=  1990 )
653 		aCalendar.AddDateInfo( Date(  3, 10, nRequestYear ), XubString( RTL_CONSTASCII_USTRINGPARAM( "Tag der deutschen Einheit" ) ), &aHolidayColor, NULL );
654 	return 0;
655 }
656 
657 // -----------------------------------------------------------------------
658 
659 IMPL_LINK( MyCalendar, DoubleClickHdl, Calendar*, EMPTYARG )
660 {
661 	Date aDate = aCalendar.GetCurDate();
662 	String aStr( RTL_CONSTASCII_USTRINGPARAM( "Info: " ) );
663 	aStr += Application::GetAppLocaleDataWrapper().getDate( aDate );
664 	aCalendar.AddDateInfo( aDate, aStr, NULL, &aFrameColor, DIB_BOLD );
665 	return 0;
666 }
667 
668 // -----------------------------------------------------------------------
669 
670 IMPL_LINK( MyCalendar, MenuSelectHdl, Menu*, pMenu )
671 {
672 	sal_uInt16			nItemId = pMenu->GetCurItemId();
673 
674 	if ( (nItemId >= 10) && (nItemId <= 19) )
675 		aCalendar.SetWeekStart( nItemId-10 );
676 	else if ( (nItemId >= 20) && (nItemId <= 29) )
677 		aCalendar.SetMinimumNumberOfDaysInWeek( nItemId-20 );
678 
679 	return 0;
680 }
681 
682 // -----------------------------------------------------------------------
683 
684 void MyCalendar::Resize()
685 {
686 	aCalendar.SetSizePixel( GetOutputSizePixel() );
687 }
688 
689 // -----------------------------------------------------------------------
690 
691 MyWin::MyWin( Window* pParent, WinBits aWinStyle ) :
692 	WorkWindow(pParent, aWinStyle | WB_3DLOOK ),
693 	aBox( this, WB_BORDER | WB_3DLOOK ),
694 	aBar( this, WB_BORDER | WB_3DLOOK | WB_RIGHT ),
695 	aHeadBar( this, WB_BORDER | WB_3DLOOK | WB_DRAG | WB_BUTTONSTYLE ),
696 	aColorList( this ),
697 	aLineList( this ),
698 	aValueSet( this, WB_TABSTOP | WB_NAMEFIELD | WB_NONEFIELD | WB_BORDER | WB_ITEMBORDER | WB_VSCROLL /* | WB_FLATVALUESET */ ),
699 	aCalendarField( this, WB_TABSTOP | WB_SPIN | WB_REPEAT | WB_DROPDOWN | WB_BORDER ),
700 	aCalendarField2( this, WB_TABSTOP | WB_SPIN | WB_REPEAT | WB_DROPDOWN | WB_BORDER ),
701 	aTabBar( this, WB_BORDER | WB_MULTISELECT | WB_SCROLL | WB_SIZEABLE | WB_DRAG ),
702 	aPrgsBar( this ),
703 	aFontBtn( this ),
704 	aCalendarBtn( this ),
705 	aPrnSetupBtn( this ),
706 	aPrnDlgBtn( this )
707 {
708 	SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
709 
710 	pCalendar = NULL;
711 	pMenu = NULL;
712 
713 	Bitmap aBmp;
714 	aBox.InsertItem(  1, aBmp );
715 	aBox.InsertItem(  2, aBmp );
716 	aBox.InsertItem(  3, aBmp );
717 	aBox.InsertItem(  4, aBmp );
718 	aBox.InsertSeparator();
719 	aBox.InsertItem(  5, aBmp );
720 	aBox.InsertItem(  6, aBmp );
721 	aBox.InsertItem(  7, aBmp );
722 	aBox.InsertItem(  8, aBmp );
723 	aBox.InsertSpace();
724 	aBox.InsertItem(  9, aBmp );
725 	aBox.SetPosPixel( Point( 0, 0 ) );
726 	aBoxSize = aBox.GetSizePixel();
727 	aBox.Show();
728 
729 	aBar.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Ready" ) ) );
730 	aBar.InsertItem( 1, 35 );
731 	aBar.InsertItem( 2, 55 );
732 	aBar.InsertItem( 3, 55 );
733 	aBar.SetItemText( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) );
734 	aBar.SetItemText( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "21.01.93" ) ) );
735 	aBar.SetItemText( 3, XubString( RTL_CONSTASCII_USTRINGPARAM( "12:00:00" ) ) );
736 	aBar.Show();
737 
738 	long nY = aBox.GetSizePixel().Height()+10;
739 	{
740 	aHeadBar.SetPosPixel( Point( 0, nY ) );
741 	aHeadBar.InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Sender" ) ), 150 );
742 	aHeadBar.InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Subject" ) ), 150, HIB_CENTER | HIB_VCENTER | HIB_CLICKABLE );
743 	aHeadBar.InsertItem( 3, XubString( RTL_CONSTASCII_USTRINGPARAM( "Date" ) ), 75 );
744 	aHeadBar.InsertItem( 4, XubString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), 60, HIB_RIGHT | HIB_VCENTER | HIB_CLICKABLE );
745 	aHeadBar.InsertItem( 9999, String(), HEADERBAR_FULLSIZE, HIB_RIGHT | HIB_VCENTER | HIB_FIXEDPOS );
746 	aHeadBar.SetSelectHdl( LINK( this, MyWin, SelectHdl ) );
747 	aHeadBar.Show();
748 	nY += aHeadBar.GetSizePixel().Height() += 10;
749 	}
750 
751 	{
752 	aColorList.SetPosSizePixel( Point( 10, nY ), Size( 130, 180 ) );
753 	aColorList.SetUpdateMode( sal_False );
754 	aColorList.InsertEntry( Color( COL_BLACK ), 		XubString( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) );
755 	aColorList.InsertEntry( Color( COL_BLUE ),			XubString( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ) );
756 	aColorList.InsertEntry( Color( COL_GREEN ), 		XubString( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) );
757 	aColorList.InsertEntry( Color( COL_CYAN ),			XubString( RTL_CONSTASCII_USTRINGPARAM( "Cyan" ) ) );
758 	aColorList.InsertEntry( Color( COL_RED ),			XubString( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) );
759 	aColorList.InsertEntry( Color( COL_MAGENTA ),		XubString( RTL_CONSTASCII_USTRINGPARAM( "Magenta" ) ) );
760 	aColorList.InsertEntry( Color( COL_BROWN ), 		XubString( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ) );
761 	aColorList.InsertEntry( Color( COL_GRAY ),			XubString( RTL_CONSTASCII_USTRINGPARAM( "Gray" ) ) );
762 	aColorList.InsertEntry( Color( COL_LIGHTGRAY ), 	XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGray" ) ) );
763 	aColorList.InsertEntry( Color( COL_LIGHTBLUE ), 	XubString( RTL_CONSTASCII_USTRINGPARAM( "LightBlue" ) ) );
764 	aColorList.InsertEntry( Color( COL_LIGHTGREEN ),	XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGreen" ) ) );
765 	aColorList.InsertEntry( Color( COL_LIGHTCYAN ), 	XubString( RTL_CONSTASCII_USTRINGPARAM( "LightCyan" ) ) );
766 	aColorList.InsertEntry( Color( COL_LIGHTRED ),		XubString( RTL_CONSTASCII_USTRINGPARAM( "LightRed" ) ) );
767 	aColorList.InsertEntry( Color( COL_LIGHTMAGENTA ),	XubString( RTL_CONSTASCII_USTRINGPARAM( "LightMagenta" ) ) );
768 	aColorList.InsertEntry( Color( COL_YELLOW ),		XubString( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ) );
769 	aColorList.InsertEntry( Color( COL_WHITE ), 		XubString( RTL_CONSTASCII_USTRINGPARAM( "White" ) ) );
770 	aColorList.SetUpdateMode( sal_True );
771 	aColorList.SetSelectHdl( LINK( this, MyWin, SelectHdl ) );
772 	aColorList.Show();
773 	}
774 
775 	{
776 	aLineList.SetPosSizePixel( Point( 150, nY ), Size( 130, 180 ) );
777 	aLineList.SetUnit( FUNIT_POINT );
778 	aLineList.SetSourceUnit( FUNIT_TWIP );
779 	aLineList.InsertEntry( XubString( RTL_CONSTASCII_USTRINGPARAM( "Hairline" ) ) );
780 	aLineList.InsertEntry( 1500 );
781 	aLineList.InsertEntry( 3000 );
782 	aLineList.InsertEntry( 4500 );
783 	aLineList.InsertEntry( 6000 );
784 	aLineList.InsertEntry( 7500 );
785 	aLineList.InsertEntry( 9000 );
786 	aLineList.InsertEntry( 1500, 1500, 1500 );
787 	aLineList.InsertEntry( 3000, 1500, 1500 );
788 	aLineList.InsertEntry( 4500, 1500, 1500 );
789 	aLineList.InsertEntry( 3000, 3000, 1500 );
790 	aLineList.InsertEntry( 4500, 3000, 1500 );
791 	aLineList.InsertEntry( 4500, 4500, 1500 );
792 	aLineList.Show();
793 	}
794 
795 	{
796 	aValueSet.SetPosSizePixel( Point( 290, nY ), Size( 130, 180 ) );
797 	aValueSet.InsertItem(  9, Color( COL_BLACK ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) );
798 	aValueSet.InsertItem( 10, Color( COL_BLUE ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ) );
799 	aValueSet.InsertItem( 11, Color( COL_GREEN ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) );
800 	aValueSet.InsertItem( 12, Color( COL_CYAN ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Cyan" ) ) );
801 	aValueSet.InsertItem( 13, Color( COL_RED ), 		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) );
802 	aValueSet.InsertItem( 14, Color( COL_MAGENTA ), 	  XubString( RTL_CONSTASCII_USTRINGPARAM( "Magenta" ) ) );
803 	aValueSet.InsertItem( 15, Color( COL_BROWN ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ) );
804 	aValueSet.InsertItem( 16, Color( COL_GRAY ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Gray" ) ) );
805 	aValueSet.InsertItem( 17, Color( COL_LIGHTGRAY ),	  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGray" ) ) );
806 	aValueSet.InsertItem( 18, Color( COL_LIGHTBLUE ),	  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightBlue" ) ) );
807 	aValueSet.InsertItem( 19, Color( COL_LIGHTGREEN ),	  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightGreen" ) ) );
808 	aValueSet.InsertItem( 20, Color( COL_LIGHTCYAN ),	  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightCyan" ) ) );
809 	aValueSet.InsertItem( 21, Color( COL_LIGHTRED ),	  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightRed" ) ) );
810 	aValueSet.InsertItem( 22, Color( COL_LIGHTMAGENTA ),  XubString( RTL_CONSTASCII_USTRINGPARAM( "LightMagenta" ) ) );
811 	aValueSet.InsertItem( 23, Color( COL_YELLOW ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ) );
812 	aValueSet.InsertItem( 24, Color( COL_WHITE ),		  XubString( RTL_CONSTASCII_USTRINGPARAM( "White" ) ) );
813 	aValueSet.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) );
814 	aValueSet.SetColCount( 4 );
815 	aValueSet.SetLineCount( 4 );
816 	aValueSet.SetSelectHdl( LINK( this, MyWin, SelectHdl ) );
817 	aValueSet.Show();
818 	}
819 
820 	{
821 	aCalendarField.EnableEmptyFieldValue( sal_True );
822 	aCalendarField.SetCalendarStyle( aCalendarField.GetCalendarStyle() | WB_RANGESELECT );
823 	aCalendarField.SetSelectHdl( LINK( this, MyWin, CalSelectHdl ) );
824 //	  aCalendarField.SetDate( Date() );
825 	aCalendarField.SetEmptyDate();
826 	aCalendarField.EnableToday();
827 	aCalendarField.EnableNone();
828 	aCalendarField.SetPosSizePixel( Point( 430, nY ), Size( 130, 20 ) );
829 	aCalendarField.Show();
830 	}
831 
832 	{
833 	aCalendarField2.SetDate( Date() );
834 	aCalendarField2.SetPosSizePixel( Point( 570, nY ), Size( 130, 20 ) );
835 	aCalendarField2.Show();
836 	}
837 
838 	nY += 200;
839 	{
840 	aTabBar.SetPosSizePixel( Point( 10, nY ),
841 							 Size( 300, aTabBar.GetSizePixel().Height() ) );
842 	aTabBar.InsertPage(  1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 1" ) ) );
843 	aTabBar.InsertPage(  2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 2" ) ) );
844 	aTabBar.InsertPage(  3, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 3" ) ) );
845 	aTabBar.InsertPage(  4, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 4" ) ) );
846 	aTabBar.InsertPage(  5, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 5" ) ) );
847 	aTabBar.InsertPage(  6, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 6" ) ) );
848 	aTabBar.InsertPage(  7, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 7" ) ) );
849 	aTabBar.InsertPage(  8, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 8" ) ) );
850 	aTabBar.InsertPage(  9, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 9" ) ) );
851 	aTabBar.InsertPage( 10, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 10" ) ) );
852 	aTabBar.InsertPage( 11, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 11" ) ) );
853 	aTabBar.InsertPage( 12, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 12" ) ) );
854 	aTabBar.InsertPage( 13, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 13" ) ) );
855 	aTabBar.InsertPage( 14, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 14" ) ) );
856 	aTabBar.InsertPage( 15, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 15" ) ) );
857 	aTabBar.InsertPage( 16, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 16" ) ) );
858 	aTabBar.InsertPage( 17, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 17" ) ) );
859 	aTabBar.InsertPage( 18, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 18" ) ) );
860 	aTabBar.InsertPage( 19, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 19" ) ) );
861 	aTabBar.InsertPage( 20, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 20" ) ) );
862 	aTabBar.InsertPage( 21, XubString( RTL_CONSTASCII_USTRINGPARAM( "This is a long Page Text" ) ) );
863 	aTabBar.InsertPage( 22, XubString( RTL_CONSTASCII_USTRINGPARAM( "Short Text" ) ) );
864 	aTabBar.InsertPage( 23, XubString( RTL_CONSTASCII_USTRINGPARAM( "And now a very very long Page Text" ) ) );
865 	aTabBar.InsertPage( 24, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 24" ) ) );
866 	aTabBar.InsertPage( 25, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 25" ) ) );
867 	aTabBar.InsertPage( 26, XubString( RTL_CONSTASCII_USTRINGPARAM( "And now a very long Page Text" ) ) );
868 	aTabBar.InsertPage( 27, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 27" ) ) );
869 	aTabBar.InsertPage( 28, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 28" ) ) );
870 	aTabBar.InsertPage( 29, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 29" ) ) );
871 	aTabBar.InsertPage( 30, XubString( RTL_CONSTASCII_USTRINGPARAM( "Page 30" ) ) );
872 	aTabBar.EnableEditMode();
873 	aTabBar.Show();
874 	}
875 
876 	nY += 35;
877 	{
878 	aPrgsBar.SetPosPixel( Point( 10, nY ) );
879 	aPrgsBar.Show();
880 	}
881 
882 	nY += 40;
883 	{
884 	aFontBtn.SetPosSizePixel( Point( 10, nY ), Size( 100, 30 ) );
885 	aFontBtn.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Font..." ) ) );
886 	aFontBtn.SetClickHdl( LINK( this, MyWin, Test ) );
887 	aFontBtn.Show();
888 
889 	aCalendarBtn.SetPosSizePixel( Point( 120, nY ), Size( 100, 30 ) );
890 	aCalendarBtn.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Calendar" ) ) );
891 	aCalendarBtn.SetClickHdl( LINK( this, MyWin, Test ) );
892 	aCalendarBtn.Show();
893 
894 	aPrnSetupBtn.SetPosSizePixel( Point( 230, nY ), Size( 100, 30 ) );
895 	aPrnSetupBtn.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "PrnSetup..." ) ) );
896 	aPrnSetupBtn.SetClickHdl( LINK( this, MyWin, Test ) );
897 	aPrnSetupBtn.Show();
898 
899 	aPrnDlgBtn.SetPosSizePixel( Point( 340, nY ), Size( 100, 30 ) );
900 	aPrnDlgBtn.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Print...." ) ) );
901 	aPrnDlgBtn.SetClickHdl( LINK( this, MyWin, Test ) );
902 	aPrnDlgBtn.Show();
903 	}
904 }
905 
906 // -----------------------------------------------------------------------
907 
908 MyWin::~MyWin()
909 {
910 	if ( pCalendar )
911 		delete pCalendar;
912 
913 	if ( pMenu )
914 	{
915 		delete pMenu;
916 		delete pNameMenu;
917 		delete pStyleMenu;
918 		delete pSizeMenu;
919 	}
920 }
921 
922 // -----------------------------------------------------------------------
923 
924 IMPL_LINK( MyWin, Test, PushButton*, pBtn )
925 {
926 	if ( pBtn == &aFontBtn )
927 	{
928 		MyFontDialog* pDlg = new MyFontDialog( this );
929 		pDlg->Execute();
930 		delete pDlg;
931 	}
932 	else if ( pBtn == &aCalendarBtn )
933 	{
934 		if ( !pCalendar )
935 			pCalendar = new MyCalendar( this );
936 		pCalendar->ToTop();
937 		pCalendar->Show();
938 	}
939 	else if ( pBtn == &aPrnSetupBtn )
940 	{
941 		PrinterSetupDialog* pDlg = new PrinterSetupDialog( this );
942 		pDlg->SetPrinter( &aPrn );
943 		pDlg->Execute();
944 		delete pDlg;
945 	}
946 	else if ( pBtn == &aPrnDlgBtn )
947 	{
948         PrintDialog* pDlg = new PrintDialog( this, false );
949 		pDlg->SetPrinter( &aPrn );
950 		pDlg->EnableRange( PRINTDIALOG_ALL );
951 		pDlg->EnableRange( PRINTDIALOG_RANGE );
952 		pDlg->Execute();
953 		delete pDlg;
954 	}
955 
956 	return 0;
957 }
958 
959 // -----------------------------------------------------------------------
960 
961 IMPL_LINK( MyWin, SelectHdl, Window*, pCtrl )
962 {
963 	if ( pCtrl == &aColorList )
964 	{
965 		Color aColor = aColorList.GetSelectEntryColor();
966 		aValueSet.SetColor( aColor );
967 		aLineList.SetColor( aColor );
968 	}
969 	else if ( pCtrl == &aValueSet )
970 	{
971 		sal_uInt16 nId = aValueSet.GetSelectItemId();
972 		if ( nId > 8 )
973 		{
974 			Color aColor = aValueSet.GetItemColor( nId );
975 			aValueSet.SetFillColor( aColor );
976 		}
977 	}
978 	else if ( pCtrl == &aHeadBar )
979 	{
980 		sal_uInt16 nCurItemId = aHeadBar.GetCurItemId();
981 		for ( sal_uInt16 i = 0; i < aHeadBar.GetItemCount(); i++ )
982 		{
983 			sal_uInt16 nItemId = aHeadBar.GetItemId( i );
984 			HeaderBarItemBits nBits = aHeadBar.GetItemBits( nItemId );
985 			if ( nItemId == nCurItemId )
986 			{
987 				HeaderBarItemBits nOldBits = nBits;
988 				nBits &= ~(HIB_DOWNARROW | HIB_UPARROW);
989 				if ( nOldBits & HIB_DOWNARROW )
990 					nBits |= HIB_UPARROW;
991 				else
992 					nBits |= HIB_DOWNARROW;
993 			}
994 			else
995 				nBits &= ~(HIB_DOWNARROW | HIB_UPARROW);
996 			aHeadBar.SetItemBits( nItemId, nBits );
997 		}
998 	}
999 
1000 	return 0;
1001 }
1002 
1003 // -----------------------------------------------------------------------
1004 
1005 IMPL_LINK( MyWin, CalSelectHdl, CalendarField*, pCtrl )
1006 {
1007 	if ( pCtrl == &aCalendarField )
1008 	{
1009 		Calendar* l_pCalendar = pCtrl->GetCalendar();
1010 		aCalendarField2.SetDate( l_pCalendar->GetSelectDate( l_pCalendar->GetSelectDateCount()-1 ) );
1011 	}
1012 
1013 	return 0;
1014 }
1015 
1016 // -----------------------------------------------------------------------
1017 
1018 void MyWin::ContextMenu( const Point& rPos )
1019 {
1020 	FontList aList( this );
1021 
1022 	if ( !pMenu )
1023 	{
1024 		pMenu		= new PopupMenu;
1025 		pNameMenu	= new FontNameMenu;
1026 		pStyleMenu	= new FontStyleMenu;
1027 		pSizeMenu	= new FontSizeMenu;
1028 
1029 		pMenu->InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "Font" ) ) );
1030 		pMenu->InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Attribute" ) ) );
1031 		pMenu->InsertItem( 3, XubString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) );
1032 		pMenu->SetPopupMenu( 1, pNameMenu );
1033 		pMenu->SetPopupMenu( 2, pStyleMenu );
1034 		pMenu->SetPopupMenu( 3, pSizeMenu );
1035 
1036 		pNameMenu->Fill( &aList );
1037 		pNameMenu->SetCurName( aList.GetFontName( 0 ).GetName() );
1038 
1039 		pStyleMenu->InsertSeparator();
1040 		pStyleMenu->InsertItem( 1, XubString( RTL_CONSTASCII_USTRINGPARAM( "~Underline" ) ), MIB_CHECKABLE | MIB_AUTOCHECK );
1041 		pStyleMenu->InsertItem( 2, XubString( RTL_CONSTASCII_USTRINGPARAM( "Stri~keout" ) ), MIB_CHECKABLE | MIB_AUTOCHECK );
1042 		pStyleMenu->InsertItem( 3, XubString( RTL_CONSTASCII_USTRINGPARAM( "~Shadow" ) ), MIB_CHECKABLE | MIB_AUTOCHECK );
1043 		pStyleMenu->InsertItem( 4, XubString( RTL_CONSTASCII_USTRINGPARAM( "~Outline" ) ), MIB_CHECKABLE | MIB_AUTOCHECK );
1044 	}
1045 
1046 	pStyleMenu->Fill( pNameMenu->GetCurName(), &aList );
1047 	pSizeMenu->Fill( aList.Get( pNameMenu->GetCurName(),
1048 								pStyleMenu->GetCurStyle() ), &aList );
1049 
1050 	pMenu->Execute( this, rPos );
1051 }
1052 
1053 // -----------------------------------------------------------------------
1054 
1055 void MyWin::Command( const CommandEvent& rCEvt )
1056 {
1057 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
1058 		ContextMenu( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) );
1059 }
1060 
1061 // -----------------------------------------------------------------------
1062 
1063 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
1064 {
1065 	aValueSet.StartSelection();
1066 	WorkWindow::MouseButtonDown( rMEvt );
1067 }
1068 
1069 // -----------------------------------------------------------------------
1070 
1071 void MyWin::KeyInput( const KeyEvent& rKEvt )
1072 {
1073 	if ( rKEvt.GetKeyCode().GetCode() == KEY_P )
1074 	{
1075 		for ( sal_uInt16 i = 0; i <= 130; i += 2 )
1076 		{
1077 			for ( sal_uInt16 j = 0; j < 6000; j++ )
1078 			{
1079 				aPrgsBar.SetValue( i );
1080 				Application::Reschedule();
1081 			}
1082 		}
1083 	}
1084 	else if ( rKEvt.GetCharCode() == '+' )
1085 		aHeadBar.SetOffset( aHeadBar.GetOffset()+1 );
1086 	else if ( rKEvt.GetCharCode() == '-' )
1087 		aHeadBar.SetOffset( aHeadBar.GetOffset()-1 );
1088 
1089 	WorkWindow::KeyInput( rKEvt );
1090 }
1091 
1092 // -----------------------------------------------------------------------
1093 
1094 void MyWin::Paint( const Rectangle& rRect )
1095 {
1096 	WorkWindow::Paint( rRect );
1097 }
1098 
1099 // -----------------------------------------------------------------------
1100 
1101 void MyWin::Resize()
1102 {
1103 	Size aWinSize = GetOutputSizePixel();
1104 
1105 	aBox.SetSizePixel( Size( aWinSize.Width(), aBoxSize.Height() ) );
1106 
1107 	Size aSize = aBar.GetSizePixel();
1108 	aBar.SetPosSizePixel( Point( 0, aWinSize.Height()-aSize.Height() ),
1109 						  Size( aWinSize.Width(), aSize.Height() ) );
1110 
1111 	Size aBarSize = aSize;
1112 	Point aPos = aHeadBar.GetPosPixel();
1113 	aSize = aHeadBar.GetSizePixel();
1114 	aHeadBar.SetSizePixel( Size( aWinSize.Width(), aSize.Height() ) );
1115 	aHeadBar.SetDragSize( aWinSize.Height() - aSize.Height() - aPos.Y() - aBarSize.Height() );
1116 
1117 	aPos = aPrgsBar.GetPosPixel();
1118 	aSize = aPrgsBar.GetSizePixel();
1119 	if ( aPos.X() < aWinSize.Width()-10 )
1120 		aPrgsBar.SetSizePixel( Size( aWinSize.Width()-aPos.X()-10, aSize.Height() ) );
1121 }
1122 
1123 // -----------------------------------------------------------------------
1124 
1125 MyApp aMyApp;
1126