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