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