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