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