1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DIALOG_HXX 28 #define DIALOG_HXX 29 30 #include <vcl/image.hxx> 31 #include <vcl/dialog.hxx> 32 #include <vcl/fixed.hxx> 33 #include <vcl/button.hxx> 34 #include <vcl/image.hxx> 35 #include <sfx2/tabdlg.hxx> 36 #include <vcl/combobox.hxx> 37 #include <svx/charmap.hxx> 38 #include <sfx2/basedlgs.hxx> 39 #include <vcl/field.hxx> 40 #include <vcl/menubtn.hxx> 41 #include <vcl/scrbar.hxx> 42 #include <vcl/ctrl.hxx> 43 #include <vcl/menu.hxx> 44 #include <vcl/outdev.hxx> 45 #include <svtools/ctrlbox.hxx> 46 #include <svtools/ctrltool.hxx> 47 #include "utility.hxx" 48 #include "format.hxx" 49 #include "symbol.hxx" 50 51 class SubsetMap; 52 #define CATEGORY_NONE 0xFFFF 53 54 /**************************************************************************/ 55 56 const XubString GetFontStyleName(const Font &rFont); 57 void SetFontStyle(const XubString &rStyleName, Font &rFont); 58 59 /**************************************************************************/ 60 61 class SmPrintOptionsTabPage : public SfxTabPage 62 { 63 FixedLine aFixedLine1; 64 CheckBox aTitle; 65 CheckBox aText; 66 CheckBox aFrame; 67 FixedLine aFixedLine2; 68 RadioButton aSizeNormal; 69 RadioButton aSizeScaled; 70 RadioButton aSizeZoomed; 71 MetricField aZoom; 72 FixedLine aFixedLine3; 73 CheckBox aNoRightSpaces; 74 CheckBox aSaveOnlyUsedSymbols; 75 76 DECL_LINK(SizeButtonClickHdl, Button *); 77 78 virtual sal_Bool FillItemSet(SfxItemSet& rSet); 79 virtual void Reset(const SfxItemSet& rSet); 80 81 public: 82 static SfxTabPage* Create(Window *pWindow, const SfxItemSet &rSet); 83 84 SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions); 85 }; 86 87 /**************************************************************************/ 88 89 class SmShowFont : public Control 90 { 91 virtual void Paint(const Rectangle&); 92 93 public: 94 SmShowFont(Window *pParent, const ResId& rResId) : 95 Control(pParent, rResId) 96 { 97 } 98 99 void SetFont(const Font& rFont); 100 }; 101 102 class SmFontDialog : public ModalDialog 103 { 104 FixedText aFixedText1; 105 ComboBox aFontBox; 106 CheckBox aBoldCheckBox; 107 CheckBox aItalicCheckBox; 108 OKButton aOKButton1; 109 CancelButton aCancelButton1; 110 SmShowFont aShowFont; 111 FixedText aFixedText2; 112 113 Font Face; 114 115 DECL_LINK(FontSelectHdl, ComboBox *); 116 DECL_LINK(FontModifyHdl, ComboBox *); 117 DECL_LINK(AttrChangeHdl, CheckBox *); 118 119 void InitColor_Impl(); 120 121 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 122 123 public: 124 SmFontDialog(Window * pParent, OutputDevice *pFntListDevice, sal_Bool bHideCheckboxes, sal_Bool bFreeRes = sal_True); 125 126 const Font& GetFont() const { return Face; } 127 void SetFont(const Font &rFont); 128 }; 129 130 /**************************************************************************/ 131 132 class SmFontSizeDialog : public ModalDialog 133 { 134 FixedText aFixedText1; 135 MetricField aBaseSize; 136 FixedText aFixedText4; 137 MetricField aTextSize; 138 FixedText aFixedText5; 139 MetricField aIndexSize; 140 FixedText aFixedText6; 141 MetricField aFunctionSize; 142 FixedText aFixedText7; 143 MetricField aOperatorSize; 144 FixedText aFixedText8; 145 MetricField aBorderSize; 146 FixedLine aFixedLine1; 147 OKButton aOKButton1; 148 CancelButton aCancelButton1; 149 PushButton aDefaultButton; 150 151 DECL_LINK(DefaultButtonClickHdl, Button *); 152 153 public: 154 SmFontSizeDialog(Window *pParent, sal_Bool bFreeRes = sal_True); 155 156 void ReadFrom(const SmFormat &rFormat); 157 void WriteTo (SmFormat &rFormat) const; 158 }; 159 160 /**************************************************************************/ 161 162 class SmFontTypeDialog : public ModalDialog 163 { 164 FixedText aFixedText1; 165 SmFontPickListBox aVariableFont; 166 FixedText aFixedText2; 167 SmFontPickListBox aFunctionFont; 168 FixedText aFixedText3; 169 SmFontPickListBox aNumberFont; 170 FixedText aFixedText4; 171 SmFontPickListBox aTextFont; 172 FixedText aFixedText5; 173 SmFontPickListBox aSerifFont; 174 FixedText aFixedText6; 175 SmFontPickListBox aSansFont; 176 FixedText aFixedText7; 177 SmFontPickListBox aFixedFont; 178 FixedLine aFixedLine1; 179 FixedLine aFixedLine2; 180 OKButton aOKButton1; 181 CancelButton aCancelButton1; 182 MenuButton aMenuButton; 183 PushButton aDefaultButton; 184 185 OutputDevice *pFontListDev; 186 187 DECL_LINK(MenuSelectHdl, Menu *); 188 DECL_LINK(DefaultButtonClickHdl, Button *); 189 190 public: 191 SmFontTypeDialog(Window *pParent, OutputDevice *pFntListDevice, sal_Bool bFreeRes = sal_True); 192 193 void ReadFrom(const SmFormat &rFormat); 194 void WriteTo (SmFormat &rFormat) const; 195 }; 196 197 /**************************************************************************/ 198 199 #define NOCATEGORIES 10 200 201 class SmCategoryDesc : public Resource 202 { 203 XubString Name; 204 XubString *Strings[4]; 205 Bitmap *Graphics[4]; /* regular bitmaps */ 206 Bitmap *GraphicsH[4]; /* high contrast bitmaps */ 207 sal_uInt16 Minimum[4]; 208 sal_uInt16 Maximum[4]; 209 sal_uInt16 Value[4]; 210 sal_Bool bIsHighContrast; 211 212 public: 213 SmCategoryDesc(const ResId &rResId, sal_uInt16 nCategoryIdx); 214 ~SmCategoryDesc(); 215 216 const XubString & GetName() const { return Name; } 217 const XubString * GetString(sal_uInt16 Index) const { return Strings[Index]; } 218 sal_uInt16 GetMinimum(sal_uInt16 Index) { return Minimum[Index]; } 219 sal_uInt16 GetMaximum(sal_uInt16 Index) { return Maximum[Index]; } 220 sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; } 221 void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;} 222 223 void SetHighContrast( sal_Bool bVal ) { bIsHighContrast = bVal; } 224 const Bitmap * GetGraphic(sal_uInt16 Index) const 225 { 226 return bIsHighContrast ? GraphicsH[Index] : Graphics[Index]; 227 } 228 }; 229 230 231 class SmDistanceDialog : public ModalDialog 232 { 233 FixedText aFixedText1; 234 MetricField aMetricField1; 235 FixedText aFixedText2; 236 MetricField aMetricField2; 237 FixedText aFixedText3; 238 MetricField aMetricField3; 239 CheckBox aCheckBox1; 240 FixedText aFixedText4; 241 MetricField aMetricField4; 242 OKButton aOKButton1; 243 CancelButton aCancelButton1; 244 MenuButton aMenuButton; 245 PushButton aDefaultButton; 246 FixedBitmap aBitmap; 247 FixedLine aFixedLine; 248 249 SmCategoryDesc *Categories[NOCATEGORIES]; 250 sal_uInt16 nActiveCategory; 251 sal_Bool bScaleAllBrackets; 252 253 DECL_LINK(GetFocusHdl, Control *); 254 DECL_LINK(MenuSelectHdl, Menu *); 255 DECL_LINK(DefaultButtonClickHdl, Button *); 256 DECL_LINK(CheckBoxClickHdl, CheckBox *); 257 258 using Window::SetHelpId; 259 void SetHelpId(MetricField &rField, const rtl::OString& sHelpId); 260 void SetCategory(sal_uInt16 Category); 261 262 void ApplyImages(); 263 264 public: 265 SmDistanceDialog(Window *pParent, sal_Bool bFreeRes = sal_True); 266 ~SmDistanceDialog(); 267 268 void ReadFrom(const SmFormat &rFormat); 269 void WriteTo (SmFormat &rFormat) /*const*/; 270 271 // Window 272 virtual void DataChanged( const DataChangedEvent &rEvt ); 273 }; 274 275 276 /**************************************************************************/ 277 278 279 class SmAlignDialog : public ModalDialog 280 { 281 RadioButton aLeft; 282 RadioButton aCenter; 283 RadioButton aRight; 284 FixedLine aFixedLine1; 285 OKButton aOKButton1; 286 CancelButton aCancelButton1; 287 PushButton aDefaultButton; 288 289 DECL_LINK(DefaultButtonClickHdl, Button *); 290 291 public: 292 SmAlignDialog(Window *pParent, sal_Bool bFreeRes = sal_True); 293 294 void ReadFrom(const SmFormat &rFormat); 295 void WriteTo (SmFormat &rFormat) const; 296 }; 297 298 /**************************************************************************/ 299 300 class SmShowSymbolSet : public Control 301 { 302 SymbolPtrVec_t aSymbolSet; 303 ScrollBar aVScrollBar; 304 Size aOutputSize; 305 Link aSelectHdlLink; 306 Link aDblClickHdlLink; 307 sal_uInt16 nLen; 308 sal_uInt16 nRows, nColumns; 309 sal_uInt16 nSelectSymbol; 310 311 virtual void Paint(const Rectangle&); 312 virtual void MouseButtonDown(const MouseEvent& rMEvt); 313 virtual void KeyInput(const KeyEvent& rKEvt); 314 315 DECL_LINK( ScrollHdl, ScrollBar* ); 316 317 public: 318 SmShowSymbolSet(Window *pParent, const ResId& rResId); 319 320 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet); 321 322 void SelectSymbol(sal_uInt16 nSymbol); 323 sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; } 324 325 void SetSelectHdl(const Link& rLink) { aSelectHdlLink = rLink; } 326 void SetDblClickHdl(const Link& rLink) { aDblClickHdlLink = rLink; } 327 }; 328 329 //////////////////////////////////////////////////////////////////////////////// 330 331 class SmShowSymbol : public Control 332 { 333 Link aDblClickHdlLink; 334 335 virtual void Paint(const Rectangle&); 336 virtual void MouseButtonDown(const MouseEvent& rMEvt); 337 338 public: 339 SmShowSymbol(Window *pParent, const ResId& rResId) : 340 Control(pParent, rResId) {} 341 342 void SetSymbol(const SmSym *pSymbol); 343 void SetDblClickHdl(const Link &rLink) { aDblClickHdlLink = rLink; } 344 }; 345 346 //////////////////////////////////////////////////////////////////////////////// 347 348 class SmSymDefineDialog; 349 350 class SmSymbolDialog : public ModalDialog 351 { 352 FixedText aSymbolSetText; 353 ListBox aSymbolSets; 354 SmShowSymbolSet aSymbolSetDisplay; 355 FixedText aSymbolName; 356 SmShowSymbol aSymbolDisplay; 357 PushButton aGetBtn; 358 PushButton aCloseBtn; 359 PushButton aEditBtn; 360 361 SmViewShell &rViewSh; 362 SmSymbolManager &rSymbolMgr; 363 364 String aSymbolSetName; 365 SymbolPtrVec_t aSymbolSet; 366 367 OutputDevice *pFontListDev; 368 369 DECL_LINK(SymbolSetChangeHdl, ListBox *); 370 DECL_LINK(SymbolChangeHdl, SmShowSymbolSet *); 371 DECL_LINK(SymbolDblClickHdl, SmShowSymbolSet *); 372 DECL_LINK(CloseClickHdl, Button *); 373 DECL_LINK(EditClickHdl, Button *); 374 DECL_LINK(GetClickHdl, Button *); 375 376 void FillSymbolSets(sal_Bool bDeleteText = sal_True); 377 void SetSymbolSetManager(SmSymbolManager &rMgr); 378 const SmSym *GetSymbol() const; 379 void InitColor_Impl(); 380 381 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 382 383 public: 384 SmSymbolDialog(Window * pParent, OutputDevice *pFntListDevice, 385 SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell, sal_Bool bFreeRes = sal_True); 386 virtual ~SmSymbolDialog(); 387 388 sal_Bool SelectSymbolSet(const XubString &rSymbolSetName); 389 void SelectSymbol(sal_uInt16 nSymbolPos); 390 sal_uInt16 GetSelectedSymbol() const { return aSymbolSetDisplay.GetSelectSymbol(); } 391 }; 392 393 //////////////////////////////////////////////////////////////////////////////// 394 395 class SmShowChar : public Control 396 { 397 virtual void Paint(const Rectangle&); 398 399 public: 400 SmShowChar(Window *pParent, const ResId& rResId) 401 : Control(pParent, rResId) 402 { 403 } 404 405 void SetSymbol( const SmSym *pSym ); 406 void SetSymbol( sal_UCS4 cChar, const Font &rFont ); 407 }; 408 409 //////////////////////////////////////////////////////////////////////////////// 410 411 class SmSymDefineDialog : public ModalDialog 412 { 413 FixedText aOldSymbolText; 414 ComboBox aOldSymbols; 415 FixedText aOldSymbolSetText; 416 ComboBox aOldSymbolSets; 417 SvxShowCharSet aCharsetDisplay; 418 FixedText aSymbolText; 419 ComboBox aSymbols; 420 FixedText aSymbolSetText; 421 ComboBox aSymbolSets; 422 FixedText aFontText; 423 ListBox aFonts; 424 FixedText aFontsSubsetFT; 425 ListBox aFontsSubsetLB; 426 FixedText aStyleText; 427 FontStyleBox aStyles; 428 FixedText aOldSymbolName; 429 SmShowChar aOldSymbolDisplay; 430 FixedText aOldSymbolSetName; 431 FixedText aSymbolName; 432 SmShowChar aSymbolDisplay; 433 FixedText aSymbolSetName; 434 OKButton aOkBtn; 435 CancelButton aCancelBtn; 436 PushButton aAddBtn; 437 PushButton aChangeBtn; 438 PushButton aDeleteBtn; 439 FixedImage aRightArrow; 440 Image aRigthArrow_Im; 441 Image aRigthArrow_Im_HC; // hi-contrast version 442 443 SmSymbolManager aSymbolMgrCopy, 444 &rSymbolMgr; 445 const SmSym *pOrigSymbol; 446 447 const SubsetMap *pSubsetMap; 448 FontList *pFontList; 449 450 DECL_LINK(OldSymbolChangeHdl, ComboBox *); 451 DECL_LINK(OldSymbolSetChangeHdl, ComboBox *); 452 DECL_LINK(ModifyHdl, ComboBox *); 453 DECL_LINK(FontChangeHdl, ListBox *); 454 DECL_LINK(SubsetChangeHdl, ListBox*); 455 DECL_LINK(StyleChangeHdl, ComboBox *); 456 DECL_LINK(CharHighlightHdl, Control* pControl); 457 DECL_LINK(AddClickHdl, Button *); 458 DECL_LINK(ChangeClickHdl, Button *); 459 DECL_LINK(DeleteClickHdl, Button *); 460 461 void FillSymbols(ComboBox &rComboBox, sal_Bool bDeleteText = sal_True); 462 void FillSymbolSets(ComboBox &rComboBox, sal_Bool bDeleteText = sal_True); 463 void FillFonts(sal_Bool bDeleteText = sal_True); 464 void FillStyles(sal_Bool bDeleteText = sal_True); 465 466 void SetSymbolSetManager(const SmSymbolManager &rMgr); 467 void SetFont(const XubString &rFontName, const XubString &rStyleName); 468 void SetOrigSymbol(const SmSym *pSymbol, const XubString &rSymbolSetName); 469 void UpdateButtons(); 470 471 sal_Bool SelectSymbolSet(ComboBox &rComboBox, const XubString &rSymbolSetName, 472 sal_Bool bDeleteText); 473 sal_Bool SelectSymbol(ComboBox &rComboBox, const XubString &rSymbolName, 474 sal_Bool bDeleteText); 475 sal_Bool SelectFont(const XubString &rFontName, sal_Bool bApplyFont); 476 sal_Bool SelectStyle(const XubString &rStyleName, sal_Bool bApplyFont); 477 478 SmSym * GetSymbol(const ComboBox &rComboBox); 479 const SmSym * GetSymbol(const ComboBox &rComboBox) const 480 { 481 return ((SmSymDefineDialog *) this)->GetSymbol(rComboBox); 482 } 483 484 void InitColor_Impl(); 485 486 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 487 488 public: 489 SmSymDefineDialog(Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr, sal_Bool bFreeRes = sal_True); 490 ~SmSymDefineDialog(); 491 492 using OutputDevice::SetFont; 493 494 // Dialog 495 virtual short Execute(); 496 497 sal_Bool SelectOldSymbolSet(const XubString &rSymbolSetName) 498 { 499 return SelectSymbolSet(aOldSymbolSets, rSymbolSetName, sal_False); 500 } 501 502 sal_Bool SelectOldSymbol(const XubString &rSymbolName) 503 { 504 return SelectSymbol(aOldSymbols, rSymbolName, sal_False); 505 } 506 507 sal_Bool SelectSymbolSet(const XubString &rSymbolSetName) 508 { 509 return SelectSymbolSet(aSymbolSets, rSymbolSetName, sal_False); 510 } 511 512 sal_Bool SelectSymbol(const XubString &rSymbolName) 513 { 514 return SelectSymbol(aSymbols, rSymbolName, sal_False); 515 } 516 517 sal_Bool SelectFont(const XubString &rFontName) { return SelectFont(rFontName, sal_True); } 518 sal_Bool SelectStyle(const XubString &rStyleName) { return SelectStyle(rStyleName, sal_True); }; 519 void SelectChar(xub_Unicode cChar); 520 }; 521 522 523 524 #endif 525 526