00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "precompiled_starmath.hxx"
00038
00039
00040 #define SMDLL 1
00041
00042 #ifndef _TOOLS_RCID_H
00043 #include "tools/rcid.h"
00044 #endif
00045
00046 #ifndef _SFXENUMITEM_HXX //autogen
00047 #include <svtools/eitem.hxx>
00048 #endif
00049 #ifndef _SFXINTITEM_HXX //autogen
00050 #include <svtools/intitem.hxx>
00051 #endif
00052 #ifndef _SFXSTRITEM_HXX //autogen
00053 #include <svtools/stritem.hxx>
00054 #endif
00055 #ifndef _SFXAPP_HXX //autogen
00056 #include <sfx2/app.hxx>
00057 #endif
00058 #ifndef _SV_MSGBOX_HXX //autogen
00059 #include <vcl/msgbox.hxx>
00060 #endif
00061 #ifndef _CTRLTOOL_HXX //autogen
00062 #include <svtools/ctrltool.hxx>
00063 #endif
00064 #ifndef _SFX_PRINTER_HXX
00065 #include <sfx2/printer.hxx>
00066 #endif
00067 #ifndef _SV_SOUND_HXX //autogen
00068 #include <vcl/sound.hxx>
00069 #endif
00070 #ifndef _SV_SNDSTYLE_HXX //autogen
00071 #include <vcl/sndstyle.hxx>
00072 #endif
00073 #ifndef _SV_WAITOBJ_HXX
00074 #include <vcl/waitobj.hxx>
00075 #endif
00076 #ifndef _SV_SETTINGS_HXX
00077 #include <vcl/settings.hxx>
00078 #endif
00079 #ifndef _SV_WALL_HXX
00080 #include <vcl/wall.hxx>
00081 #endif
00082 #ifndef _SFXDISPATCH_HXX //autogen
00083 #include <sfx2/dispatch.hxx>
00084 #endif
00085 #ifndef _SFX_HRC //autogen
00086 #include <sfx2/sfx.hrc>
00087 #endif
00088 #ifndef _STRING_HXX //autogen
00089 #include <tools/string.hxx>
00090 #endif
00091 #ifndef _TOOLS_DEBUG_HXX //autogen
00092 #include <tools/debug.hxx>
00093 #endif
00094 #ifndef _SVX_SUBSETMAP_HXX
00095 #include <svx/ucsubset.hxx>
00096 #endif
00097
00098
00099 #ifndef CONFIG_HXX
00100 #include "config.hxx"
00101 #endif
00102 #ifndef DIALOG_HXX
00103 #include "dialog.hxx"
00104 #endif
00105 #ifndef _STARMATH_HRC
00106 #include "starmath.hrc"
00107 #endif
00108
00109 #include "dialog.hrc"
00110
00111 #ifndef _SMMOD_HXX
00112 #include "smmod.hxx"
00113 #endif
00114 #ifndef SYMBOL_HXX
00115 #include "symbol.hxx"
00116 #endif
00117 #ifndef VIEW_HXX
00118 #include "view.hxx"
00119 #endif
00120 #ifndef DOCUMENT_HXX
00121 #include "document.hxx"
00122 #endif
00123
00125
00126
00127
00128
00129
00130
00131 class SmFontStyles
00132 {
00133 String aNormal;
00134 String aBold;
00135 String aItalic;
00136 String aBoldItalic;
00137 String aEmpty;
00138
00139 public:
00140 SmFontStyles();
00141
00142 USHORT GetCount() const { return 4; }
00143 const String & GetStyleName( const Font &rFont ) const;
00144 const String & GetStyleName( USHORT nIdx ) const;
00145 };
00146
00147
00148 SmFontStyles::SmFontStyles() :
00149 aNormal ( ResId( RID_FONTREGULAR, *SM_MOD()->GetResMgr() ) ),
00150 aBold ( ResId( RID_FONTBOLD, *SM_MOD()->GetResMgr() ) ),
00151 aItalic ( ResId( RID_FONTITALIC, *SM_MOD()->GetResMgr() ) )
00152 {
00153
00154
00155 aBoldItalic = aBold;
00156 aBoldItalic.AppendAscii( ", " );
00157 aBoldItalic += aItalic;
00158 }
00159
00160
00161 const String & SmFontStyles::GetStyleName( const Font &rFont ) const
00162 {
00164 BOOL bBold = IsBold( rFont ),
00165 bItalic = IsItalic( rFont );
00166
00167 if (bBold && bItalic)
00168 return aBoldItalic;
00169 else if (bItalic)
00170 return aItalic;
00171 else if (bBold)
00172 return aBold;
00173 else
00174 return aNormal;
00175 }
00176
00177
00178 const String & SmFontStyles::GetStyleName( USHORT nIdx ) const
00179 {
00180
00181
00182
00183 #if OSL_DEBUG_LEVEL > 1
00184 DBG_ASSERT( nIdx < GetCount(), "index out of range" );
00185 #endif
00186 switch (nIdx)
00187 {
00188 case 0 : return aNormal;
00189 case 1 : return aItalic;
00190 case 2 : return aBold;
00191 case 3 : return aBoldItalic;
00192 }
00193 return aEmpty;
00194 }
00195
00196
00197 const SmFontStyles & GetFontStyles()
00198 {
00199 static const SmFontStyles aImpl;
00200 return aImpl;
00201 }
00202
00204
00205 void SetFontStyle(const XubString &rStyleName, Font &rFont)
00206 {
00207
00208
00209 USHORT nIndex = 0;
00210 if (rStyleName.Len())
00211 {
00212 USHORT i;
00213 const SmFontStyles &rStyles = GetFontStyles();
00214 for (i = 0; i < rStyles.GetCount(); i++)
00215 if (rStyleName.CompareTo( rStyles.GetStyleName(i) ) == COMPARE_EQUAL)
00216 break;
00217 #if OSL_DEBUG_LEVEL > 1
00218 DBG_ASSERT(i < rStyles.GetCount(), "style-name unknown");
00219 #endif
00220 nIndex = i;
00221 }
00222
00223 rFont.SetItalic((nIndex & 0x1) ? ITALIC_NORMAL : ITALIC_NONE);
00224 rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL);
00225 }
00226
00227
00228
00229
00230 IMPL_LINK_INLINE_START( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, EMPTYARG )
00231 {
00232 aZoom.Enable(aSizeZoomed.IsChecked());
00233 return 0;
00234 }
00235 IMPL_LINK_INLINE_END( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, pButton )
00236
00237
00238 SmPrintOptionsTabPage::SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions)
00239 : SfxTabPage(pParent, SmResId(RID_PRINTOPTIONPAGE), rOptions),
00240 aFixedLine1 (this, SmResId( FL_PRINTOPTIONS )),
00241 aTitle (this, SmResId( CB_TITLEROW )),
00242 aText (this, SmResId( CB_EQUATION_TEXT )),
00243 aFrame (this, SmResId( CB_FRAME )),
00244 aFixedLine2 (this, SmResId( FL_PRINT_FORMAT )),
00245 aSizeNormal (this, SmResId( RB_ORIGINAL_SIZE )),
00246 aSizeScaled (this, SmResId( RB_FIT_TO_PAGE )),
00247 aSizeZoomed (this, SmResId( RB_ZOOM )),
00248 aZoom (this, SmResId( MF_ZOOM )),
00249 aFixedLine3 (this, SmResId( FL_MISC_OPTIONS )),
00250 aNoRightSpaces (this, SmResId( CB_IGNORE_SPACING ))
00251 {
00252 FreeResource();
00253
00254 aSizeNormal.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
00255 aSizeScaled.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
00256 aSizeZoomed.SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
00257
00258 Reset(rOptions);
00259 }
00260
00261
00262 BOOL SmPrintOptionsTabPage::FillItemSet(SfxItemSet& rSet)
00263 {
00264 UINT16 nPrintSize;
00265 if (aSizeNormal.IsChecked())
00266 nPrintSize = PRINT_SIZE_NORMAL;
00267 else if (aSizeScaled.IsChecked())
00268 nPrintSize = PRINT_SIZE_SCALED;
00269 else
00270 nPrintSize = PRINT_SIZE_ZOOMED;
00271
00272 rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), (UINT16) nPrintSize));
00273 rSet.Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), (UINT16) aZoom.GetValue()));
00274 rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), aTitle.IsChecked()));
00275 rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), aText.IsChecked()));
00276 rSet.Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), aFrame.IsChecked()));
00277 rSet.Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), aNoRightSpaces.IsChecked()));
00278
00279 return TRUE;
00280 }
00281
00282
00283 void SmPrintOptionsTabPage::Reset(const SfxItemSet& rSet)
00284 {
00285 SmPrintSize ePrintSize = (SmPrintSize)((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTSIZE))).GetValue();
00286
00287 aSizeNormal.Check(ePrintSize == PRINT_SIZE_NORMAL);
00288 aSizeScaled.Check(ePrintSize == PRINT_SIZE_SCALED);
00289 aSizeZoomed.Check(ePrintSize == PRINT_SIZE_ZOOMED);
00290
00291 aZoom.Enable(aSizeZoomed.IsChecked());
00292
00293 aZoom.SetValue(((const SfxUInt16Item &)rSet.Get(GetWhich(SID_PRINTZOOM))).GetValue());
00294
00295 aTitle.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTITLE))).GetValue());
00296 aText.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTEXT))).GetValue());
00297 aFrame.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTFRAME))).GetValue());
00298 aNoRightSpaces.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue());
00299 }
00300
00301
00302 SfxTabPage* SmPrintOptionsTabPage::Create(Window* pWindow, const SfxItemSet& rSet)
00303 {
00304 return (new SmPrintOptionsTabPage(pWindow, rSet));
00305 }
00306
00307
00308
00309
00310 void SmShowFont::Paint(const Rectangle& rRect )
00311 {
00312 Control::Paint( rRect );
00313
00314 XubString Text (GetFont().GetName());
00315 Size TextSize(GetTextWidth(Text), GetTextHeight());
00316
00317 DrawText(Point((GetOutputSize().Width() - TextSize.Width()) / 2,
00318 (GetOutputSize().Height() - TextSize.Height()) / 2), Text);
00319 }
00320
00321
00322 void SmShowFont::SetFont(const Font& rFont)
00323 {
00324 Color aTxtColor( GetTextColor() );
00325 Font aFont (rFont);
00326
00327 Invalidate();
00328 aFont.SetSize(Size(0, 24));
00329 aFont.SetAlign(ALIGN_TOP);
00330 Control::SetFont(aFont);
00331
00332
00333 SetTextColor( aTxtColor );
00334 }
00335
00336
00337 IMPL_LINK_INLINE_START( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
00338 {
00339 Face.SetName(pComboBox->GetText());
00340 aShowFont.SetFont(Face);
00341 return 0;
00342 }
00343 IMPL_LINK_INLINE_END( SmFontDialog, FontSelectHdl, ComboBox *, pComboBox )
00344
00345
00346 IMPL_LINK( SmFontDialog, FontModifyHdl, ComboBox *, pComboBox )
00347 {
00348
00349 USHORT nPos = pComboBox->GetEntryPos( pComboBox->GetText() );
00350 if (COMBOBOX_ENTRY_NOTFOUND != nPos)
00351 {
00352 FontSelectHdl( pComboBox );
00353 }
00354 return 0;
00355 }
00356
00357
00358 IMPL_LINK( SmFontDialog, AttrChangeHdl, CheckBox *, EMPTYARG )
00359 {
00360 if (aBoldCheckBox.IsChecked())
00361 Face.SetWeight(FontWeight(WEIGHT_BOLD));
00362 else
00363 Face.SetWeight(FontWeight(WEIGHT_NORMAL));
00364
00365 if (aItalicCheckBox.IsChecked())
00366 Face.SetItalic(ITALIC_NORMAL);
00367 else
00368 Face.SetItalic(ITALIC_NONE);
00369
00370 aShowFont.SetFont(Face);
00371 return 0;
00372 }
00373
00374
00375 void SmFontDialog::SetFont(const Font &rFont)
00376 {
00377 Face = rFont;
00378
00379 aFontBox.SetText( Face.GetName() );
00380 aBoldCheckBox.Check( IsBold( Face ) );
00381 aItalicCheckBox.Check( IsItalic( Face ) );
00382
00383 aShowFont.SetFont(Face);
00384 }
00385
00386
00387 SmFontDialog::SmFontDialog(Window * pParent,
00388 OutputDevice *pFntListDevice, BOOL bHideCheckboxes, BOOL bFreeRes)
00389 : ModalDialog(pParent,SmResId(RID_FONTDIALOG)),
00390 aFixedText1 (this, SmResId(1)),
00391 aFontBox (this, SmResId(1)),
00392 aBoldCheckBox (this, SmResId(1)),
00393 aItalicCheckBox (this, SmResId(2)),
00394 aOKButton1 (this, SmResId(1)),
00395 aCancelButton1 (this, SmResId(1)),
00396 aShowFont (this, SmResId(1)),
00397 aFixedText2 (this, SmResId(2))
00398 {
00399 if (bFreeRes)
00400 FreeResource();
00401
00402 {
00403 WaitObject( this );
00404
00405 FontList aFontList( pFntListDevice );
00406
00407 USHORT nCount = aFontList.GetFontNameCount();
00408 for (USHORT i = 0; i < nCount; i++)
00409 aFontBox.InsertEntry( aFontList.GetFontName(i).GetName() );
00410
00411 Face.SetSize(Size(0, 24));
00412 Face.SetWeight(WEIGHT_NORMAL);
00413 Face.SetItalic(ITALIC_NONE);
00414 Face.SetFamily(FAMILY_DONTKNOW);
00415 Face.SetPitch(PITCH_DONTKNOW);
00416 Face.SetCharSet(RTL_TEXTENCODING_DONTKNOW);
00417 Face.SetTransparent(TRUE);
00418
00419 InitColor_Impl();
00420
00421
00422 aShowFont.SetBorderStyle( WINDOW_BORDER_MONO );
00423 }
00424
00425 aFontBox.SetSelectHdl(LINK(this, SmFontDialog, FontSelectHdl));
00426 aFontBox.SetModifyHdl(LINK(this, SmFontDialog, FontModifyHdl));
00427 aBoldCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
00428 aItalicCheckBox.SetClickHdl(LINK(this, SmFontDialog, AttrChangeHdl));
00429
00430 if (bHideCheckboxes)
00431 {
00432 aBoldCheckBox.Check( FALSE );
00433 aBoldCheckBox.Enable( FALSE );
00434 aBoldCheckBox.Show( FALSE );
00435 aItalicCheckBox.Check( FALSE );
00436 aItalicCheckBox.Enable( FALSE );
00437 aItalicCheckBox.Show( FALSE );
00438 aFixedText2.Show( FALSE );
00439
00440 Size aSize( aFontBox.GetSizePixel() );
00441 long nComboBoxBottom = aFontBox.GetPosPixel().Y() + aFontBox.GetSizePixel().Height();
00442 long nCheckBoxBottom = aItalicCheckBox.GetPosPixel().Y() + aItalicCheckBox.GetSizePixel().Height();
00443 aSize.Height() += nCheckBoxBottom - nComboBoxBottom;
00444 aFontBox.SetSizePixel( aSize );
00445 }
00446 }
00447
00448 void SmFontDialog::InitColor_Impl()
00449 {
00450 #if OSL_DEBUG_LEVEL > 1
00451 Color aBC( GetDisplayBackground().GetColor() );
00452 #endif
00453 ColorData nBgCol = COL_WHITE,
00454 nTxtCol = COL_BLACK;
00455 if (GetDisplayBackground().GetColor().IsDark())
00456 {
00457 const StyleSettings &rS = GetSettings().GetStyleSettings();
00458 nBgCol = rS.GetFieldColor().GetColor();
00459 nTxtCol = rS.GetFieldTextColor().GetColor();
00460 }
00461
00462 Color aTmpColor( nBgCol );
00463 Wallpaper aWall( aTmpColor );
00464 Color aTxtColor( nTxtCol );
00465 aShowFont.SetBackground( aWall );
00466 aShowFont.SetTextColor( aTxtColor );
00467 }
00468
00469
00470 void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt )
00471 {
00472 if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
00473 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
00474 InitColor_Impl();
00475
00476 ModalDialog::DataChanged( rDCEvt );
00477 }
00478
00479
00480
00481
00482 IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG )
00483 {
00484 QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
00485
00486 if (pQueryBox->Execute() == RET_YES)
00487 {
00488 SmModule *pp = SM_MOD1();
00489 SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
00490 WriteTo( aFmt );
00491 pp->GetConfig()->SetStandardFormat( aFmt );
00492 }
00493
00494 delete pQueryBox;
00495 return 0;
00496 }
00497
00498
00499 SmFontSizeDialog::SmFontSizeDialog(Window * pParent, BOOL bFreeRes)
00500 : ModalDialog(pParent, SmResId(RID_FONTSIZEDIALOG)),
00501 aFixedText1(this, SmResId(1)),
00502 aBaseSize(this, SmResId(1)),
00503 aFixedText4(this, SmResId(4)),
00504 aTextSize(this, SmResId(4)),
00505 aFixedText5(this, SmResId(5)),
00506 aIndexSize(this, SmResId(5)),
00507 aFixedText6(this, SmResId(6)),
00508 aFunctionSize(this, SmResId(6)),
00509 aFixedText7(this, SmResId(7)),
00510 aOperatorSize(this, SmResId(7)),
00511 aFixedText8(this, SmResId(8)),
00512 aBorderSize(this, SmResId(8)),
00513 aFixedLine1(this, SmResId(1)),
00514 aOKButton1(this, SmResId(1)),
00515 aCancelButton1(this, SmResId(1)),
00516 aDefaultButton(this, SmResId(1))
00517 {
00518 if (bFreeRes)
00519 FreeResource();
00520
00521 aDefaultButton.SetClickHdl(LINK(this, SmFontSizeDialog, DefaultButtonClickHdl));
00522 }
00523
00524
00525 void SmFontSizeDialog::ReadFrom(const SmFormat &rFormat)
00526 {
00528 aBaseSize.SetValue( SmRoundFraction(
00529 Sm100th_mmToPts( rFormat.GetBaseSize().Height() ) ) );
00530
00531 aTextSize .SetValue( rFormat.GetRelSize(SIZ_TEXT) );
00532 aIndexSize .SetValue( rFormat.GetRelSize(SIZ_INDEX) );
00533 aFunctionSize.SetValue( rFormat.GetRelSize(SIZ_FUNCTION) );
00534 aOperatorSize.SetValue( rFormat.GetRelSize(SIZ_OPERATOR) );
00535 aBorderSize .SetValue( rFormat.GetRelSize(SIZ_LIMITS) );
00536 }
00537
00538
00539 void SmFontSizeDialog::WriteTo(SmFormat &rFormat) const
00540 {
00541 rFormat.SetBaseSize( Size(0, SmPtsTo100th_mm( static_cast< long >(aBaseSize.GetValue()))) );
00542
00543 rFormat.SetRelSize(SIZ_TEXT, (USHORT) aTextSize .GetValue());
00544 rFormat.SetRelSize(SIZ_INDEX, (USHORT) aIndexSize .GetValue());
00545 rFormat.SetRelSize(SIZ_FUNCTION, (USHORT) aFunctionSize.GetValue());
00546 rFormat.SetRelSize(SIZ_OPERATOR, (USHORT) aOperatorSize.GetValue());
00547 rFormat.SetRelSize(SIZ_LIMITS, (USHORT) aBorderSize .GetValue());
00548
00549 const Size aTmp (rFormat.GetBaseSize());
00550 for (USHORT i = FNT_BEGIN; i <= FNT_END; i++)
00551 rFormat.SetFontSize(i, aTmp);
00552
00553 rFormat.RequestApplyChanges();
00554 }
00555
00556
00557
00558
00559
00560 IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu )
00561 {
00562 SmFontPickListBox *pActiveListBox;
00563
00564 BOOL bHideCheckboxes = FALSE;
00565 switch (pMenu->GetCurItemId())
00566 {
00567 case 1: pActiveListBox = &aVariableFont; break;
00568 case 2: pActiveListBox = &aFunctionFont; break;
00569 case 3: pActiveListBox = &aNumberFont; break;
00570 case 4: pActiveListBox = &aTextFont; break;
00571 case 5: pActiveListBox = &aSerifFont; bHideCheckboxes = TRUE; break;
00572 case 6: pActiveListBox = &aSansFont; bHideCheckboxes = TRUE; break;
00573 case 7: pActiveListBox = &aFixedFont; bHideCheckboxes = TRUE; break;
00574 default:pActiveListBox = NULL;
00575 }
00576
00577 if (pActiveListBox)
00578 {
00579 SmFontDialog *pFontDialog = new SmFontDialog(this, pFontListDev, bHideCheckboxes);
00580
00581 pActiveListBox->WriteTo(*pFontDialog);
00582 if (pFontDialog->Execute() == RET_OK)
00583 pActiveListBox->ReadFrom(*pFontDialog);
00584 delete pFontDialog;
00585 }
00586 return 0;
00587 }
00588
00589
00590 IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG )
00591 {
00592 QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
00593 if (pQueryBox->Execute() == RET_YES)
00594 {
00595 SmModule *pp = SM_MOD1();
00596 SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
00597 WriteTo( aFmt );
00598 pp->GetConfig()->SetStandardFormat( aFmt );
00599 }
00600
00601 delete pQueryBox;
00602 return 0;
00603 }
00604 IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton )
00605
00606
00607 SmFontTypeDialog::SmFontTypeDialog(Window * pParent, OutputDevice *pFntListDevice, BOOL bFreeRes)
00608 : ModalDialog(pParent, SmResId(RID_FONTTYPEDIALOG)),
00609 aFixedText1 (this, SmResId(1)),
00610 aVariableFont (this, SmResId(1)),
00611 aFixedText2 (this, SmResId(2)),
00612 aFunctionFont (this, SmResId(2)),
00613 aFixedText3 (this, SmResId(3)),
00614 aNumberFont (this, SmResId(3)),
00615 aFixedText4 (this, SmResId(4)),
00616 aTextFont (this, SmResId(4)),
00617 aFixedText5 (this, SmResId(5)),
00618 aSerifFont (this, SmResId(5)),
00619 aFixedText6 (this, SmResId(6)),
00620 aSansFont (this, SmResId(6)),
00621 aFixedText7 (this, SmResId(7)),
00622 aFixedFont (this, SmResId(7)),
00623 aFixedLine1 (this, SmResId(1)),
00624 aFixedLine2 (this, SmResId(2)),
00625 aOKButton1 (this, SmResId(1)),
00626 aCancelButton1 (this, SmResId(1)),
00627 aMenuButton (this, SmResId(1)),
00628 aDefaultButton (this, SmResId(2)),
00629 pFontListDev (pFntListDevice)
00630 {
00631 if (bFreeRes)
00632 FreeResource();
00633
00634 aDefaultButton.SetClickHdl(LINK(this, SmFontTypeDialog, DefaultButtonClickHdl));
00635
00636 aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmFontTypeDialog, MenuSelectHdl));
00637 }
00638
00639 void SmFontTypeDialog::ReadFrom(const SmFormat &rFormat)
00640 {
00641 SmModule *pp = SM_MOD1();
00642
00643 aVariableFont = pp->GetConfig()->GetFontPickList(FNT_VARIABLE);
00644 aFunctionFont = pp->GetConfig()->GetFontPickList(FNT_FUNCTION);
00645 aNumberFont = pp->GetConfig()->GetFontPickList(FNT_NUMBER);
00646 aTextFont = pp->GetConfig()->GetFontPickList(FNT_TEXT);
00647 aSerifFont = pp->GetConfig()->GetFontPickList(FNT_SERIF);
00648 aSansFont = pp->GetConfig()->GetFontPickList(FNT_SANS);
00649 aFixedFont = pp->GetConfig()->GetFontPickList(FNT_FIXED);
00650
00651 aVariableFont.Insert( rFormat.GetFont(FNT_VARIABLE) );
00652 aFunctionFont.Insert( rFormat.GetFont(FNT_FUNCTION) );
00653 aNumberFont .Insert( rFormat.GetFont(FNT_NUMBER) );
00654 aTextFont .Insert( rFormat.GetFont(FNT_TEXT) );
00655 aSerifFont .Insert( rFormat.GetFont(FNT_SERIF) );
00656 aSansFont .Insert( rFormat.GetFont(FNT_SANS) );
00657 aFixedFont .Insert( rFormat.GetFont(FNT_FIXED) );
00658 }
00659
00660
00661 void SmFontTypeDialog::WriteTo(SmFormat &rFormat) const
00662 {
00663 SmModule *pp = SM_MOD1();
00664
00665 pp->GetConfig()->GetFontPickList(FNT_VARIABLE) = aVariableFont;
00666 pp->GetConfig()->GetFontPickList(FNT_FUNCTION) = aFunctionFont;
00667 pp->GetConfig()->GetFontPickList(FNT_NUMBER) = aNumberFont;
00668 pp->GetConfig()->GetFontPickList(FNT_TEXT) = aTextFont;
00669 pp->GetConfig()->GetFontPickList(FNT_SERIF) = aSerifFont;
00670 pp->GetConfig()->GetFontPickList(FNT_SANS) = aSansFont;
00671 pp->GetConfig()->GetFontPickList(FNT_FIXED) = aFixedFont;
00672
00673 rFormat.SetFont( FNT_VARIABLE, aVariableFont.Get(0) );
00674 rFormat.SetFont( FNT_FUNCTION, aFunctionFont.Get(0) );
00675 rFormat.SetFont( FNT_NUMBER, aNumberFont .Get(0) );
00676 rFormat.SetFont( FNT_TEXT, aTextFont .Get(0) );
00677 rFormat.SetFont( FNT_SERIF, aSerifFont .Get(0) );
00678 rFormat.SetFont( FNT_SANS, aSansFont .Get(0) );
00679 rFormat.SetFont( FNT_FIXED, aFixedFont .Get(0) );
00680
00681 rFormat.RequestApplyChanges();
00682 }
00683
00684
00685
00686 struct FieldMinMax
00687 {
00688 USHORT nMin, nMax;
00689 };
00690
00691
00692
00693 static const FieldMinMax pMinMaxData[10][4] =
00694 {
00695
00696 {{ 0, 200 }, { 0, 200 }, { 0, 100 }, { 0, 0 }},
00697
00698 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
00699
00700 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
00701
00702 {{ 0, 100 }, { 1, 100 }, { 0, 0 }, { 0, 0 }},
00703
00704 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
00705
00706 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 100 }},
00707
00708 {{ 0, 300 }, { 0, 300 }, { 0, 0 }, { 0, 0 }},
00709
00710 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
00711
00712 {{ 0, 100 }, { 0, 100 }, { 0, 0 }, { 0, 0 }},
00713
00714 {{ 0, 10000 }, { 0, 10000 }, { 0, 10000 }, { 0, 10000 }}
00715 };
00716
00717 SmCategoryDesc::SmCategoryDesc(const ResId& rResId, USHORT nCategoryIdx) :
00718 Resource(rResId),
00719 bIsHighContrast(FALSE)
00720 {
00721 if (IsAvailableRes(ResId(1,*rResId.GetResMgr()).SetRT(RSC_STRING)))
00722 {
00723 Name = XubString(ResId(1,*rResId.GetResMgr()));
00724
00725 int i;
00726 for (i = 0; i < 4; i++)
00727 {
00728 int nI2 = i + 2;
00729
00730 if (IsAvailableRes(ResId(nI2,*rResId.GetResMgr()).SetRT(RSC_STRING)))
00731 {
00732 Strings [i] = new XubString(ResId(nI2,*rResId.GetResMgr()));
00733 Graphics [i] = new Bitmap(ResId(10*nI2,*rResId.GetResMgr()));
00734 GraphicsH[i] = new Bitmap(ResId(10*nI2+1,*rResId.GetResMgr()));
00735 }
00736 else
00737 {
00738 Strings [i] = 0;
00739 Graphics [i] = 0;
00740 GraphicsH[i] = 0;
00741 }
00742 }
00743
00744 for (i = 0; i < 4; i++)
00745 {
00746 const FieldMinMax &rMinMax = pMinMaxData[ nCategoryIdx ][i];
00747 Value[i] = Minimum[i] = rMinMax.nMin;
00748 Maximum[i] = rMinMax.nMax;
00749 }
00750 }
00751
00752 FreeResource();
00753 }
00754
00755
00756 SmCategoryDesc::~SmCategoryDesc()
00757 {
00758 for (int i = 0; i < 4; i++)
00759 {
00760 delete Strings [i];
00761 delete Graphics [i];
00762 delete GraphicsH[i];
00763 }
00764 }
00765
00766
00767
00768 IMPL_LINK( SmDistanceDialog, GetFocusHdl, Control *, pControl )
00769 {
00770 if (Categories[nActiveCategory])
00771 {
00772 USHORT i;
00773
00774 if (pControl == &aMetricField1)
00775 i = 0;
00776 else if (pControl == &aMetricField2)
00777 i = 1;
00778 else if (pControl == &aMetricField3)
00779 i = 2;
00780 else if (pControl == &aMetricField4)
00781 i = 3;
00782 else
00783 return 0;
00784 aBitmap.SetBitmap(*(Categories[nActiveCategory]->GetGraphic(i)));
00785 }
00786 return 0;
00787 }
00788
00789 IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
00790 {
00791 SetCategory(pMenu->GetCurItemId() - 1);
00792 return 0;
00793 }
00794
00795
00796 IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG )
00797 {
00798 QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
00799
00800 if (pQueryBox->Execute() == RET_YES)
00801 {
00802 SmModule *pp = SM_MOD1();
00803 SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
00804 WriteTo( aFmt );
00805 pp->GetConfig()->SetStandardFormat( aFmt );
00806 }
00807 delete pQueryBox;
00808 return 0;
00809 }
00810
00811
00812 IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox )
00813 {
00814 if (pCheckBox == &aCheckBox1)
00815 {
00816 aCheckBox1.Toggle();
00817
00818 BOOL bChecked = aCheckBox1.IsChecked();
00819 aFixedText4 .Enable( bChecked );
00820 aMetricField4.Enable( bChecked );
00821 }
00822 return 0;
00823 }
00824
00825
00826 void SmDistanceDialog::SetHelpId(MetricField &rField, ULONG nHelpId)
00827 {
00831
00832 const XubString aEmptyText;
00833 #if OSL_DEBUG_LEVEL > 1
00834 DBG_ASSERT(aEmptyText.Len() == 0, "Sm: Ooops...");
00835 #endif
00836
00837 rField.SetHelpId(nHelpId);
00838 rField.SetHelpText(aEmptyText);
00839
00840
00841
00842
00843 Edit *pSubEdit = rField.GetSubEdit();
00844 if (pSubEdit)
00845 { pSubEdit->SetHelpId(nHelpId);
00846 pSubEdit->SetHelpText(aEmptyText);
00847 }
00848 }
00849
00850
00851 void SmDistanceDialog::SetCategory(USHORT nCategory)
00852 {
00853 #if OSL_DEBUG_LEVEL > 1
00854 DBG_ASSERT(0 <= nCategory && nCategory < NOCATEGORIES,
00855 "Sm: falsche Kategorienummer in SmDistanceDialog");
00856 #endif
00857
00858
00859
00860 #if OSL_DEBUG_LEVEL > 1
00861 DBG_ASSERT(NOCATEGORIES == 10, "Sm : Array passt nicht zu Anzahl der Kategorien");
00862 #endif
00863 ULONG __READONLY_DATA aCatMf2Hid[10][4] =
00864 {
00865 { HID_SMA_DEFAULT_DIST, HID_SMA_LINE_DIST, HID_SMA_ROOT_DIST, 0 },
00866 { HID_SMA_SUP_DIST, HID_SMA_SUB_DIST , 0, 0 },
00867 { HID_SMA_NUMERATOR_DIST, HID_SMA_DENOMINATOR_DIST, 0, 0 },
00868 { HID_SMA_FRACLINE_EXCWIDTH, HID_SMA_FRACLINE_LINEWIDTH, 0, 0 },
00869 { HID_SMA_UPPERLIMIT_DIST, HID_SMA_LOWERLIMIT_DIST, 0, 0 },
00870 { HID_SMA_BRACKET_EXCHEIGHT, HID_SMA_BRACKET_DIST, 0, HID_SMA_BRACKET_EXCHEIGHT2 },
00871 { HID_SMA_MATRIXROW_DIST, HID_SMA_MATRIXCOL_DIST, 0, 0 },
00872 { HID_SMA_ATTRIBUT_DIST, HID_SMA_INTERATTRIBUT_DIST, 0, 0 },
00873 { HID_SMA_OPERATOR_EXCHEIGHT, HID_SMA_OPERATOR_DIST, 0, 0 },
00874 { HID_SMA_LEFTBORDER_DIST, HID_SMA_RIGHTBORDER_DIST, HID_SMA_UPPERBORDER_DIST, HID_SMA_LOWERBORDER_DIST }
00875 };
00876
00877
00878 Window * __READONLY_DATA aWin[4][2] =
00879 {
00880 { &aFixedText1, &aMetricField1 },
00881 { &aFixedText2, &aMetricField2 },
00882 { &aFixedText3, &aMetricField3 },
00883 { &aFixedText4, &aMetricField4 }
00884 };
00885
00886 SmCategoryDesc *pCat;
00887
00888
00889
00890 if (nActiveCategory != CATEGORY_NONE)
00891 {
00892 pCat = Categories[nActiveCategory];
00893 pCat->SetValue(0, (USHORT) aMetricField1.GetValue());
00894 pCat->SetValue(1, (USHORT) aMetricField2.GetValue());
00895 pCat->SetValue(2, (USHORT) aMetricField3.GetValue());
00896 pCat->SetValue(3, (USHORT) aMetricField4.GetValue());
00897
00898 if (nActiveCategory == 5)
00899 bScaleAllBrackets = aCheckBox1.IsChecked();
00900
00901 aMenuButton.GetPopupMenu()->CheckItem(nActiveCategory + 1, FALSE);
00902 }
00903
00904
00905
00906 BOOL bActive;
00907 for (USHORT i = 0; i < 4; i++)
00908 {
00909 FixedText *pFT = (FixedText * const) aWin[i][0];
00910 MetricField *pMF = (MetricField * const) aWin[i][1];
00911
00912
00913
00914 bActive = aCatMf2Hid[nCategory][i] != 0;
00915
00916 pFT->Show(bActive);
00917 pFT->Enable(bActive);
00918 pMF->Show(bActive);
00919 pMF->Enable(bActive);
00920
00921
00922 FieldUnit eUnit;
00923 USHORT nDigits;
00924 if (nCategory < 9)
00925 {
00926 eUnit = FUNIT_CUSTOM;
00927 nDigits = 0;
00928 pMF->SetCustomUnitText( '%' );
00929 }
00930 else
00931 {
00932 eUnit = FUNIT_100TH_MM;
00933 nDigits = 2;
00934 }
00935 pMF->SetUnit(eUnit);
00936 pMF->SetDecimalDigits(nDigits);
00937
00938 if (bActive)
00939 {
00940 pCat = Categories[nCategory];
00941 pFT->SetText(*pCat->GetString(i));
00942
00943 pMF->SetMin(pCat->GetMinimum(i));
00944 pMF->SetMax(pCat->GetMaximum(i));
00945 pMF->SetValue(pCat->GetValue(i));
00946
00947 SetHelpId(*pMF, aCatMf2Hid[nCategory][i]);
00948 }
00949 }
00950
00951
00952 bActive = nCategory == 5;
00953 aCheckBox1.Show(bActive);
00954 aCheckBox1.Enable(bActive);
00955 if (bActive)
00956 {
00957 aCheckBox1.Check( bScaleAllBrackets );
00958
00959 BOOL bChecked = aCheckBox1.IsChecked();
00960 aFixedText4 .Enable( bChecked );
00961 aMetricField4.Enable( bChecked );
00962 }
00963
00964 aMenuButton.GetPopupMenu()->CheckItem(nCategory + 1, TRUE);
00965 aFixedLine.SetText(Categories[nCategory]->GetName());
00966
00967 nActiveCategory = nCategory;
00968
00969 aMetricField1.GrabFocus();
00970 Invalidate();
00971 Update();
00972 }
00973
00974
00975 SmDistanceDialog::SmDistanceDialog(Window *pParent, BOOL bFreeRes)
00976 : ModalDialog(pParent, SmResId(RID_DISTANCEDIALOG)),
00977 aFixedText1 (this, SmResId(1)),
00978 aMetricField1 (this, SmResId(1)),
00979 aFixedText2 (this, SmResId(2)),
00980 aMetricField2 (this, SmResId(2)),
00981 aFixedText3 (this, SmResId(3)),
00982 aMetricField3 (this, SmResId(3)),
00983 aCheckBox1 (this, SmResId(1)),
00984 aFixedText4 (this, SmResId(4)),
00985 aMetricField4 (this, SmResId(4)),
00986 aOKButton1 (this, SmResId(1)),
00987 aCancelButton1 (this, SmResId(1)),
00988 aMenuButton (this, SmResId(1)),
00989 aDefaultButton (this, SmResId(1)),
00990 aBitmap (this, SmResId(1)),
00991 aFixedLine (this, SmResId(1))
00992 {
00993 for (USHORT i = 0; i < NOCATEGORIES; i++)
00994 Categories[i] = new SmCategoryDesc(SmResId(i + 1), i);
00995 nActiveCategory = CATEGORY_NONE;
00996 bScaleAllBrackets = FALSE;
00997
00998 if (bFreeRes)
00999 FreeResource();
01000
01001 ApplyImages();
01002
01003
01004 aBitmap.SetBorderStyle( WINDOW_BORDER_MONO );
01005
01006 aMetricField1.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
01007 aMetricField2.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
01008 aMetricField3.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
01009 aMetricField4.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
01010 aCheckBox1.SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
01011
01012 aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
01013
01014 aDefaultButton.SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
01015 }
01016
01017
01018 SmDistanceDialog::~SmDistanceDialog()
01019 {
01020 for (int i = 0; i < NOCATEGORIES; i++)
01021 DELETEZ(Categories[i]);
01022 }
01023
01024 void SmDistanceDialog::ApplyImages()
01025 {
01026 BOOL bHighContrast = GetDisplayBackground().GetColor().IsDark() != 0;
01027 for (int i = 0; i < NOCATEGORIES; ++i)
01028 {
01029 SmCategoryDesc *pCat = Categories[i];
01030 if (pCat)
01031 pCat->SetHighContrast( bHighContrast );
01032 }
01033 }
01034
01035 void SmDistanceDialog::DataChanged( const DataChangedEvent &rEvt )
01036 {
01037 if ( (rEvt.GetType() == DATACHANGED_SETTINGS) && (rEvt.GetFlags() & SETTINGS_STYLE) )
01038 ApplyImages();
01039
01040 ModalDialog::DataChanged( rEvt );
01041 }
01042
01043 void SmDistanceDialog::ReadFrom(const SmFormat &rFormat)
01044 {
01045 Categories[0]->SetValue(0, rFormat.GetDistance(DIS_HORIZONTAL));
01046 Categories[0]->SetValue(1, rFormat.GetDistance(DIS_VERTICAL));
01047 Categories[0]->SetValue(2, rFormat.GetDistance(DIS_ROOT));
01048 Categories[1]->SetValue(0, rFormat.GetDistance(DIS_SUPERSCRIPT));
01049 Categories[1]->SetValue(1, rFormat.GetDistance(DIS_SUBSCRIPT));
01050 Categories[2]->SetValue(0, rFormat.GetDistance(DIS_NUMERATOR));
01051 Categories[2]->SetValue(1, rFormat.GetDistance(DIS_DENOMINATOR));
01052 Categories[3]->SetValue(0, rFormat.GetDistance(DIS_FRACTION));
01053 Categories[3]->SetValue(1, rFormat.GetDistance(DIS_STROKEWIDTH));
01054 Categories[4]->SetValue(0, rFormat.GetDistance(DIS_UPPERLIMIT));
01055 Categories[4]->SetValue(1, rFormat.GetDistance(DIS_LOWERLIMIT));
01056 Categories[5]->SetValue(0, rFormat.GetDistance(DIS_BRACKETSIZE));
01057 Categories[5]->SetValue(1, rFormat.GetDistance(DIS_BRACKETSPACE));
01058 Categories[5]->SetValue(3, rFormat.GetDistance(DIS_NORMALBRACKETSIZE));
01059 Categories[6]->SetValue(0, rFormat.GetDistance(DIS_MATRIXROW));
01060 Categories[6]->SetValue(1, rFormat.GetDistance(DIS_MATRIXCOL));
01061 Categories[7]->SetValue(0, rFormat.GetDistance(DIS_ORNAMENTSIZE));
01062 Categories[7]->SetValue(1, rFormat.GetDistance(DIS_ORNAMENTSPACE));
01063 Categories[8]->SetValue(0, rFormat.GetDistance(DIS_OPERATORSIZE));
01064 Categories[8]->SetValue(1, rFormat.GetDistance(DIS_OPERATORSPACE));
01065 Categories[9]->SetValue(0, rFormat.GetDistance(DIS_LEFTSPACE));
01066 Categories[9]->SetValue(1, rFormat.GetDistance(DIS_RIGHTSPACE));
01067 Categories[9]->SetValue(2, rFormat.GetDistance(DIS_TOPSPACE));
01068 Categories[9]->SetValue(3, rFormat.GetDistance(DIS_BOTTOMSPACE));
01069
01070 bScaleAllBrackets = rFormat.IsScaleNormalBrackets();
01071
01072
01073
01074 nActiveCategory = CATEGORY_NONE;
01075 SetCategory(0);
01076 }
01077
01078
01079 void SmDistanceDialog::WriteTo(SmFormat &rFormat)
01080 {
01081
01082
01083 SetCategory(nActiveCategory);
01084
01085 rFormat.SetDistance( DIS_HORIZONTAL, Categories[0]->GetValue(0) );
01086 rFormat.SetDistance( DIS_VERTICAL, Categories[0]->GetValue(1) );
01087 rFormat.SetDistance( DIS_ROOT, Categories[0]->GetValue(2) );
01088 rFormat.SetDistance( DIS_SUPERSCRIPT, Categories[1]->GetValue(0) );
01089 rFormat.SetDistance( DIS_SUBSCRIPT, Categories[1]->GetValue(1) );
01090 rFormat.SetDistance( DIS_NUMERATOR, Categories[2]->GetValue(0) );
01091 rFormat.SetDistance( DIS_DENOMINATOR, Categories[2]->GetValue(1) );
01092 rFormat.SetDistance( DIS_FRACTION, Categories[3]->GetValue(0) );
01093 rFormat.SetDistance( DIS_STROKEWIDTH, Categories[3]->GetValue(1) );
01094 rFormat.SetDistance( DIS_UPPERLIMIT, Categories[4]->GetValue(0) );
01095 rFormat.SetDistance( DIS_LOWERLIMIT, Categories[4]->GetValue(1) );
01096 rFormat.SetDistance( DIS_BRACKETSIZE, Categories[5]->GetValue(0) );
01097 rFormat.SetDistance( DIS_BRACKETSPACE, Categories[5]->GetValue(1) );
01098 rFormat.SetDistance( DIS_MATRIXROW, Categories[6]->GetValue(0) );
01099 rFormat.SetDistance( DIS_MATRIXCOL, Categories[6]->GetValue(1) );
01100 rFormat.SetDistance( DIS_ORNAMENTSIZE, Categories[7]->GetValue(0) );
01101 rFormat.SetDistance( DIS_ORNAMENTSPACE, Categories[7]->GetValue(1) );
01102 rFormat.SetDistance( DIS_OPERATORSIZE, Categories[8]->GetValue(0) );
01103 rFormat.SetDistance( DIS_OPERATORSPACE, Categories[8]->GetValue(1) );
01104 rFormat.SetDistance( DIS_LEFTSPACE, Categories[9]->GetValue(0) );
01105 rFormat.SetDistance( DIS_RIGHTSPACE, Categories[9]->GetValue(1) );
01106 rFormat.SetDistance( DIS_TOPSPACE, Categories[9]->GetValue(2) );
01107 rFormat.SetDistance( DIS_BOTTOMSPACE, Categories[9]->GetValue(3) );
01108 rFormat.SetDistance( DIS_NORMALBRACKETSIZE, Categories[5]->GetValue(3) );
01109
01110 rFormat.SetScaleNormalBrackets( bScaleAllBrackets );
01111
01112 rFormat.RequestApplyChanges();
01113 }
01114
01115
01116
01117
01118
01119 IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG )
01120 {
01121 QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY));
01122
01123 if (pQueryBox->Execute() == RET_YES)
01124 {
01125 SmModule *pp = SM_MOD1();
01126 SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
01127 WriteTo( aFmt );
01128 pp->GetConfig()->SetStandardFormat( aFmt );
01129 }
01130
01131 delete pQueryBox;
01132 return 0;
01133 }
01134
01135
01136 SmAlignDialog::SmAlignDialog(Window * pParent, BOOL bFreeRes)
01137 : ModalDialog(pParent, SmResId(RID_ALIGNDIALOG)),
01138 aLeft (this, SmResId(1)),
01139 aCenter (this, SmResId(2)),
01140 aRight (this, SmResId(3)),
01141 aFixedLine1 (this, SmResId(1)),
01142 aOKButton1 (this, SmResId(1)),
01143 aCancelButton1 (this, SmResId(1)),
01144 aDefaultButton (this, SmResId(1))
01145 {
01146 if (bFreeRes)
01147 FreeResource();
01148
01149 aDefaultButton.SetClickHdl(LINK(this, SmAlignDialog, DefaultButtonClickHdl));
01150 }
01151
01152
01153 void SmAlignDialog::ReadFrom(const SmFormat &rFormat)
01154 {
01155 switch (rFormat.GetHorAlign())
01156 {
01157 case AlignLeft:
01158 aLeft .Check(TRUE);
01159 aCenter.Check(FALSE);
01160 aRight .Check(FALSE);
01161 break;
01162
01163 case AlignCenter:
01164 aLeft .Check(FALSE);
01165 aCenter.Check(TRUE);
01166 aRight .Check(FALSE);
01167 break;
01168
01169 case AlignRight:
01170 aLeft .Check(FALSE);
01171 aCenter.Check(FALSE);
01172 aRight .Check(TRUE);
01173 break;
01174 }
01175 }
01176
01177
01178 void SmAlignDialog::WriteTo(SmFormat &rFormat) const
01179 {
01180 if (aLeft.IsChecked())
01181 rFormat.SetHorAlign(AlignLeft);
01182 else if (aRight.IsChecked())
01183 rFormat.SetHorAlign(AlignRight);
01184 else
01185 rFormat.SetHorAlign(AlignCenter);
01186
01187 rFormat.RequestApplyChanges();
01188 }
01189
01190
01191
01192
01193
01194 void SmShowSymbolSet::Paint(const Rectangle&)
01195 {
01196 Push(PUSH_MAPMODE);
01197
01198
01199 SetMapMode(MapMode(MAP_PIXEL));
01200
01201 USHORT v = sal::static_int_cast< USHORT >((aVScrollBar.GetThumbPos() * nColumns));
01202 USHORT nSymbols = aSymbolSet.GetCount();
01203
01204 Color aTxtColor( GetTextColor() );
01205 for (USHORT i = v; i < nSymbols ; i++)
01206 {
01207 SmSym aSymbol (aSymbolSet.GetSymbol(i));
01208 Font aFont (aSymbol.GetFace());
01209 aFont.SetAlign(ALIGN_TOP);
01210
01211
01212
01213 aFont.SetSize(Size(0, nLen - (nLen / 3)));
01214 SetFont(aFont);
01215
01216 SetTextColor( aTxtColor );
01217
01218 int nIV = i - v;
01219 Size aSize(GetTextWidth(aSymbol.GetCharacter()), GetTextHeight());
01220
01221 DrawText(Point((nIV % nColumns) * nLen + (nLen - aSize.Width()) / 2,
01222 (nIV / nColumns) * nLen + (nLen - aSize.Height()) / 2),
01223 aSymbol.GetCharacter());
01224 }
01225
01226 if (nSelectSymbol != SYMBOL_NONE)
01227 {
01228 Invert(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
01229 ((nSelectSymbol - v) / nColumns) * nLen),
01230 Size(nLen, nLen)));
01231 }
01232
01233 Pop();
01234 }
01235
01236
01237 void SmShowSymbolSet::MouseButtonDown(const MouseEvent& rMEvt)
01238 {
01239 GrabFocus();
01240
01241 if (rMEvt.IsLeft() && Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel()))
01242 {
01243 long nPos = (rMEvt.GetPosPixel().Y() / nLen) * nColumns + (rMEvt.GetPosPixel().X() / nLen) +
01244 aVScrollBar.GetThumbPos() * nColumns;
01245 SelectSymbol( sal::static_int_cast< USHORT >(nPos) );
01246
01247 aSelectHdlLink.Call(this);
01248
01249 if (rMEvt.GetClicks() > 1) aDblClickHdlLink.Call(this);
01250 }
01251 else Control::MouseButtonDown (rMEvt);
01252 }
01253
01254
01255 void SmShowSymbolSet::KeyInput(const KeyEvent& rKEvt)
01256 {
01257 USHORT n = nSelectSymbol;
01258
01259 if (n != SYMBOL_NONE)
01260 {
01261 switch (rKEvt.GetKeyCode().GetCode())
01262 {
01263 case KEY_DOWN: n = n + nColumns; break;
01264 case KEY_UP: n = n - nColumns; break;
01265 case KEY_LEFT: n -= 1; break;
01266 case KEY_RIGHT: n += 1; break;
01267 case KEY_HOME: n = 0; break;
01268 case KEY_END: n = aSymbolSet.GetCount() - 1; break;
01269 case KEY_PAGEUP: n -= nColumns * nRows; break;
01270 case KEY_PAGEDOWN: n += nColumns * nRows; break;
01271
01272 default:
01273 Control::KeyInput(rKEvt);
01274 return;
01275 }
01276 }
01277 else
01278 n = 0;
01279
01280 if (n >= aSymbolSet.GetCount())
01281 n = nSelectSymbol;
01282
01283
01284 if ((n < (USHORT) (aVScrollBar.GetThumbPos() * nColumns)) ||
01285 (n >= (USHORT) ((aVScrollBar.GetThumbPos() + nRows) * nColumns)))
01286 {
01287 aVScrollBar.SetThumbPos(n / nColumns);
01288 Invalidate();
01289 Update();
01290 }
01291
01292 SelectSymbol(n);
01293 aSelectHdlLink.Call(this);
01294 }
01295
01296
01297 SmShowSymbolSet::SmShowSymbolSet(Window *pParent, const ResId& rResId) :
01298 Control(pParent, rResId),
01299 aVScrollBar(this, WinBits(WB_VSCROLL))
01300 {
01301 nSelectSymbol = SYMBOL_NONE;
01302
01303 aOutputSize = GetOutputSizePixel();
01304 long nScrollBarWidth = aVScrollBar.GetSizePixel().Width(),
01305 nUseableWidth = aOutputSize.Width() - nScrollBarWidth;
01306
01307
01308 nLen = (USHORT) LogicToPixel(Size(0, 16), MapMode(MAP_POINT)).Height();
01309
01310 nColumns = sal::static_int_cast< USHORT >(nUseableWidth / nLen);
01311 if (nColumns > 2 && nColumns % 2 != 0)
01312 nColumns--;
01313 nRows = sal::static_int_cast< USHORT >(aOutputSize.Height() / nLen);
01314 #if OSL_DEBUG_LEVEL > 1
01315 DBG_ASSERT(nColumns > 0, "Sm : keine Spalten");
01316 DBG_ASSERT(nRows > 0, "Sm : keine Zeilen");
01317 #endif
01318
01319
01320 aOutputSize.Width() = nColumns * nLen;
01321 aOutputSize.Height() = nRows * nLen;
01322
01323 aVScrollBar.SetPosSizePixel(Point(aOutputSize.Width() + 1, -1),
01324 Size(nScrollBarWidth, aOutputSize.Height() + 2));
01325 aVScrollBar.Enable(FALSE);
01326 aVScrollBar.Show();
01327 aVScrollBar.SetScrollHdl(LINK(this, SmShowSymbolSet, ScrollHdl));
01328
01329 Size WindowSize (aOutputSize);
01330 WindowSize.Width() += nScrollBarWidth;
01331 SetOutputSizePixel(WindowSize);
01332
01333 }
01334
01335
01336 void SmShowSymbolSet::SetSymbolSet(const SmSymSet& rSymbolSet)
01337 {
01338 aSymbolSet = rSymbolSet;
01339
01340 if (aSymbolSet.GetCount() > (nColumns * nRows))
01341 {
01342 aVScrollBar.SetRange(Range(0, ((aSymbolSet.GetCount() + (nColumns - 1)) / nColumns) - nRows));
01343 aVScrollBar.Enable(TRUE);
01344 }
01345 else
01346 {
01347 aVScrollBar.SetRange(Range(0,0));
01348 aVScrollBar.Enable (FALSE);
01349 }
01350
01351 Invalidate();
01352 }
01353
01354
01355 void SmShowSymbolSet::SelectSymbol(USHORT nSymbol)
01356 {
01357 int v = (int) (aVScrollBar.GetThumbPos() * nColumns);
01358
01359 if (nSelectSymbol != SYMBOL_NONE)
01360 Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
01361 ((nSelectSymbol - v) / nColumns) * nLen),
01362 Size(nLen, nLen)));
01363
01364 if (nSymbol < aSymbolSet.GetCount())
01365 nSelectSymbol = nSymbol;
01366
01367 if (aSymbolSet.GetCount() == 0)
01368 nSelectSymbol = SYMBOL_NONE;
01369
01370 if (nSelectSymbol != SYMBOL_NONE)
01371 Invalidate(Rectangle(Point(((nSelectSymbol - v) % nColumns) * nLen,
01372 ((nSelectSymbol - v) / nColumns) * nLen),
01373 Size(nLen, nLen)));
01374
01375 Update();
01376 }
01377
01378
01379 IMPL_LINK( SmShowSymbolSet, ScrollHdl, ScrollBar*, EMPTYARG )
01380 {
01381 Invalidate();
01382 return 0;
01383 }
01384
01386
01387 void SmShowSymbol::Paint(const Rectangle &rRect)
01388 {
01389 Control::Paint( rRect );
01390
01391 const XubString &rText = GetText();
01392 Size aTextSize(GetTextWidth(rText), GetTextHeight());
01393
01394 DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
01395 (GetOutputSize().Height() - aTextSize.Height()) / 2), rText);
01396 }
01397
01398
01399 void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt)
01400 {
01401 if (rMEvt.GetClicks() > 1)
01402 aDblClickHdlLink.Call(this);
01403 else
01404 Control::MouseButtonDown (rMEvt);
01405 }
01406
01407
01408 void SmShowSymbol::SetSymbol(const SmSym *pSymbol)
01409 {
01410 if (pSymbol)
01411 {
01412 Color aTxtColor( GetTextColor() );
01413
01414 Font aFont (pSymbol->GetFace());
01415 aFont.SetSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
01416 aFont.SetAlign(ALIGN_TOP);
01417 SetFont(aFont);
01418
01419
01420 SetTextColor(aTxtColor);
01421
01422 SetText(XubString(pSymbol->GetCharacter()));
01423 }
01424
01425
01426
01427
01428 Invalidate();
01429 }
01430
01431
01433
01434 void SmSymbolDialog::FillSymbolSets(BOOL bDeleteText)
01435
01436
01437 {
01438 aSymbolSets.Clear();
01439 if (bDeleteText)
01440 aSymbolSets.SetNoSelection();
01441
01442 USHORT nNumSymSets = rSymSetMgr.GetSymbolSetCount();
01443 for (USHORT i = 0; i < nNumSymSets; i++)
01444 aSymbolSets.InsertEntry(rSymSetMgr.GetSymbolSet(i)->GetName());
01445 }
01446
01447
01448 IMPL_LINK( SmSymbolDialog, SymbolSetChangeHdl, ListBox *, EMPTYARG pListBox )
01449 {
01450 (void) pListBox;
01451 #if OSL_DEBUG_LEVEL > 1
01452 DBG_ASSERT(pListBox == &aSymbolSets, "Sm : falsches Argument");
01453 #endif
01454
01455 SelectSymbolSet(aSymbolSets.GetSelectEntry());
01456 return 0;
01457 }
01458
01459
01460 IMPL_LINK( SmSymbolDialog, SymbolChangeHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet )
01461 {
01462 (void) pShowSymbolSet;
01463 #if OSL_DEBUG_LEVEL > 1
01464 DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument");
01465 #endif
01466
01467 SelectSymbol(aSymbolSetDisplay.GetSelectSymbol());
01468 return 0;
01469 }
01470
01471 IMPL_LINK( SmSymbolDialog, EditClickHdl, Button *, EMPTYARG pButton )
01472 {
01473 (void) pButton;
01474 #if OSL_DEBUG_LEVEL > 1
01475 DBG_ASSERT(pButton == &aEditBtn, "Sm : falsches Argument");
01476 #endif
01477
01478 SmSymDefineDialog *pDialog = new SmSymDefineDialog(this, pFontListDev, rSymSetMgr);
01479
01480
01481 const XubString aSymSetName (aSymbolSets.GetSelectEntry()),
01482 aSymName (aSymbolName.GetText());
01483 pDialog->SelectOldSymbolSet(aSymSetName);
01484 pDialog->SelectOldSymbol(aSymName);
01485 pDialog->SelectSymbolSet(aSymSetName);
01486 pDialog->SelectSymbol(aSymName);
01487
01488
01489 XubString aOldSymbolSet (aSymbolSets.GetSelectEntry());
01490
01491 USHORT nSymPos = GetSelectedSymbol();
01492
01493
01494 if (pDialog->Execute() == RET_OK && rSymSetMgr.IsModified())
01495 {
01496 rSymSetMgr.Save();
01497 FillSymbolSets();
01498 }
01499
01500
01501
01502 if (!SelectSymbolSet(aOldSymbolSet) && aSymbolSets.GetEntryCount() > 0)
01503 SelectSymbolSet(aSymbolSets.GetEntry(0));
01504
01505 SelectSymbol( nSymPos );
01506
01507 delete pDialog;
01508 return 0;
01509 }
01510
01511
01512 IMPL_LINK( SmSymbolDialog, SymbolDblClickHdl, SmShowSymbolSet *, EMPTYARG pShowSymbolSet )
01513 {
01514 (void) pShowSymbolSet;
01515 #if OSL_DEBUG_LEVEL > 1
01516 DBG_ASSERT(pShowSymbolSet == &aSymbolSetDisplay, "Sm : falsches Argument");
01517 #endif
01518
01519 GetClickHdl(&aGetBtn);
01520 EndDialog(RET_OK);
01521 return 0;
01522 }
01523
01524
01525 IMPL_LINK( SmSymbolDialog, GetClickHdl, Button *, EMPTYARG pButton )
01526 {
01527 (void) pButton;
01528 #if OSL_DEBUG_LEVEL > 1
01529 DBG_ASSERT(pButton == &aGetBtn, "Sm : falscher Button");
01530 #endif
01531
01532 const SmSym *pSym = GetSymbol();
01533 if (pSym)
01534 {
01535 XubString aText ('%');
01536 aText += pSym->GetName();
01537
01538 rViewSh.GetViewFrame()->GetDispatcher()->Execute(
01539 SID_INSERTTEXT, SFX_CALLMODE_STANDARD,
01540 new SfxStringItem(SID_INSERTTEXT, aText), 0L);
01541 }
01542
01543 return 0;
01544 }
01545
01546
01547 IMPL_LINK_INLINE_START( SmSymbolDialog, CloseClickHdl, Button *, EMPTYARG pButton )
01548 {
01549 (void) pButton;
01550 #if OSL_DEBUG_LEVEL > 1
01551 DBG_ASSERT(pButton == &aCloseBtn, "Sm : falscher Button");
01552 #endif
01553
01554 EndDialog(TRUE);
01555 return 0;
01556 }
01557 IMPL_LINK_INLINE_END( SmSymbolDialog, CloseClickHdl, Button *, pButton )
01558
01559
01560 SmSymbolDialog::SmSymbolDialog(Window *pParent, OutputDevice *pFntListDevice,
01561 SmSymSetManager &rMgr, SmViewShell &rViewShell, BOOL bFreeRes) :
01562 ModalDialog (pParent, SmResId(RID_SYMBOLDIALOG)),
01563 aSymbolSetText (this, SmResId(1)),
01564 aSymbolSets (this, SmResId(1)),
01565 aSymbolSetDisplay (this, SmResId(1)),
01566 aSymbolName (this, SmResId(2)),
01567 aSymbolDisplay (this, SmResId(2)),
01568 aGetBtn (this, SmResId(2)),
01569 aCloseBtn (this, SmResId(3)),
01570 aEditBtn (this, SmResId(1)),
01571 rViewSh (rViewShell),
01572 rSymSetMgr (rMgr),
01573 pFontListDev (pFntListDevice)
01574 {
01575 if (bFreeRes)
01576 FreeResource();
01577
01578 pSymSet = NULL;
01579 FillSymbolSets();
01580 if (aSymbolSets.GetEntryCount() > 0)
01581 SelectSymbolSet(aSymbolSets.GetEntry(0));
01582
01583 InitColor_Impl();
01584
01585
01586 aSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO );
01587
01588 aSymbolSets .SetSelectHdl (LINK(this, SmSymbolDialog, SymbolSetChangeHdl));
01589 aSymbolSetDisplay.SetSelectHdl (LINK(this, SmSymbolDialog, SymbolChangeHdl));
01590 aSymbolSetDisplay.SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
01591 aSymbolDisplay .SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl));
01592 aCloseBtn .SetClickHdl (LINK(this, SmSymbolDialog, CloseClickHdl));
01593 aEditBtn .SetClickHdl (LINK(this, SmSymbolDialog, EditClickHdl));
01594 aGetBtn .SetClickHdl (LINK(this, SmSymbolDialog, GetClickHdl));
01595 }
01596
01597
01598 SmSymbolDialog::~SmSymbolDialog()
01599 {
01600 }
01601
01602
01603 void SmSymbolDialog::InitColor_Impl()
01604 {
01605 #if OSL_DEBUG_LEVEL > 1
01606 Color aBC( GetDisplayBackground().GetColor() );
01607 #endif
01608 ColorData nBgCol = COL_WHITE,
01609 nTxtCol = COL_BLACK;
01610 if (GetDisplayBackground().GetColor().IsDark())
01611 {
01612 const StyleSettings &rS = GetSettings().GetStyleSettings();
01613 nBgCol = rS.GetFieldColor().GetColor();
01614 nTxtCol = rS.GetFieldTextColor().GetColor();
01615 }
01616
01617 Color aTmpColor( nBgCol );
01618 Wallpaper aWall( aTmpColor );
01619 Color aTxtColor( nTxtCol );
01620 aSymbolDisplay .SetBackground( aWall );
01621 aSymbolDisplay .SetTextColor( aTxtColor );
01622 aSymbolSetDisplay.SetBackground( aWall );
01623 aSymbolSetDisplay.SetTextColor( aTxtColor );
01624 }
01625
01626
01627 void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt )
01628 {
01629 if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
01630 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
01631 InitColor_Impl();
01632
01633 ModalDialog::DataChanged( rDCEvt );
01634 }
01635
01636
01637 BOOL SmSymbolDialog::SelectSymbolSet(const XubString &rSymbolSetName)
01638 {
01639 BOOL bRet = FALSE;
01640 USHORT nPos = aSymbolSets.GetEntryPos(rSymbolSetName);
01641
01642 pSymSet = NULL;
01643 if (nPos != LISTBOX_ENTRY_NOTFOUND)
01644 {
01645 aSymbolSets.SelectEntryPos(nPos);
01646 USHORT nSymbolSetNo = rSymSetMgr.GetSymbolSetPos(aSymbolSets.GetSelectEntry());
01647 pSymSet = rSymSetMgr.GetSymbolSet(nSymbolSetNo);
01648 #if OSL_DEBUG_LEVEL > 1
01649 DBG_ASSERT(pSymSet, "Sm : NULL pointer");
01650 #endif
01651
01652 aSymbolSetDisplay.SetSymbolSet(*pSymSet);
01653 if (pSymSet->GetCount() > 0)
01654 SelectSymbol(0);
01655
01656 bRet = TRUE;
01657 }
01658 else
01659 aSymbolSets.SetNoSelection();
01660
01661 return bRet;
01662 }
01663
01664
01665 void SmSymbolDialog::SelectSymbol(USHORT nSymbolNo)
01666 {
01667 const SmSym *pSym = NULL;
01668 if (pSymSet && nSymbolNo < pSymSet->GetCount())
01669 pSym = &pSymSet->GetSymbol(nSymbolNo);
01670
01671 aSymbolSetDisplay.SelectSymbol(nSymbolNo);
01672 aSymbolDisplay.SetSymbol(pSym);
01673 aSymbolName.SetText(pSym ? pSym->GetName() : XubString());
01674 }
01675
01676
01677 const SmSym * SmSymbolDialog::GetSymbol() const
01678 {
01679 USHORT nSymbolNo = aSymbolSetDisplay.GetSelectSymbol();
01680 return pSymSet == NULL ? NULL : &pSymSet->GetSymbol(nSymbolNo);
01681 }
01682
01683
01685
01686
01687 void SmShowChar::Paint(const Rectangle &rRect)
01688 {
01689 Control::Paint( rRect );
01690
01691 XubString Text (GetText ());
01692 if (Text.Len() > 0)
01693 {
01694 Size aTextSize(GetTextWidth(Text), GetTextHeight());
01695
01696 DrawText(Point((GetOutputSize().Width() - aTextSize.Width()) / 2,
01697 (GetOutputSize().Height() - aTextSize.Height()) / 2), Text);
01698 }
01699 }
01700
01701
01702 void SmShowChar::SetChar(xub_Unicode aChar)
01703 {
01704 SetText(XubString(aChar));
01705 Invalidate();
01706 }
01707
01708
01709 void SmShowChar::SetFont(const Font &rFont)
01710 {
01711 Color aTxtColor( GetTextColor() );
01712
01713 Font aFont (rFont);
01714 Size aSize (Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3));
01715
01716 aFont.SetSize(aSize);
01717 aFont.SetAlign(ALIGN_TOP);
01718 aFont.SetTransparent(TRUE);
01719 Control::SetFont(aFont);
01720
01721
01722 SetTextColor( aTxtColor );
01723
01724 Invalidate();
01725 }
01726
01728
01729 void SmSymDefineDialog::FillSymbols(ComboBox &rComboBox, BOOL bDeleteText)
01730 {
01731 #if OSL_DEBUG_LEVEL > 1
01732 DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
01733 "Sm : falsche ComboBox");
01734 #endif
01735
01736 rComboBox.Clear();
01737 if (bDeleteText)
01738 rComboBox.SetText(XubString());
01739
01740 ComboBox &rSymbolSets = &rComboBox == &aOldSymbols ?
01741 aOldSymbolSets : aSymbolSets;
01742 const SmSymSet *pSymSet = GetSymbolSet(rSymbolSets);
01743 if (pSymSet)
01744 { USHORT nNumSymbols = pSymSet->GetCount();
01745 for (USHORT i = 0; i < nNumSymbols; i++)
01746 rComboBox.InsertEntry(pSymSet->GetSymbol(i).GetName());
01747 }
01748
01749 }
01750
01751
01752 void SmSymDefineDialog::FillSymbolSets(ComboBox &rComboBox, BOOL bDeleteText)
01753 {
01754 #if OSL_DEBUG_LEVEL > 1
01755 DBG_ASSERT(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets,
01756 "Sm : falsche ComboBox");
01757 #endif
01758
01759 rComboBox.Clear();
01760 if (bDeleteText)
01761 rComboBox.SetText(XubString());
01762
01763 USHORT nNumSymSets = aSymSetMgrCopy.GetSymbolSetCount();
01764 for (USHORT i = 0; i < nNumSymSets; i++)
01765 rComboBox.InsertEntry(aSymSetMgrCopy.GetSymbolSet(i)->GetName());
01766 }
01767
01768
01769 void SmSymDefineDialog::FillFonts(BOOL bDelete)
01770 {
01771 aFonts.Clear();
01772 if (bDelete)
01773 aFonts.SetNoSelection();
01774
01775
01776
01777
01778 if (pFontList)
01779 {
01780 USHORT nCount = pFontList->GetFontNameCount();
01781 for (USHORT i = 0; i < nCount; i++)
01782 aFonts.InsertEntry( pFontList->GetFontName(i).GetName() );
01783 }
01784 }
01785
01786
01787 void SmSymDefineDialog::FillStyles(BOOL bDeleteText)
01788 {
01789 aStyles.Clear();
01790 if (bDeleteText)
01791 aStyles.SetText(XubString());
01792
01793 XubString aText (aFonts.GetSelectEntry());
01794 if (aText.Len() != 0)
01795 {
01796
01797
01798 const SmFontStyles &rStyles = GetFontStyles();
01799 for (USHORT i = 0; i < rStyles.GetCount(); i++)
01800 aStyles.InsertEntry( rStyles.GetStyleName(i) );
01801
01802 #if OSL_DEBUG_LEVEL > 1
01803 DBG_ASSERT(aStyles.GetEntryCount() > 0, "Sm : keine Styles vorhanden");
01804 #endif
01805 aStyles.SetText( aStyles.GetEntry(0) );
01806 }
01807 }
01808
01809
01810 SmSymSet * SmSymDefineDialog::GetSymbolSet(const ComboBox &rComboBox)
01811 {
01812 #if OSL_DEBUG_LEVEL > 1
01813 DBG_ASSERT(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets,
01814 "Sm : falsche ComboBox");
01815 #endif
01816 USHORT nSymbolSetNo = aSymSetMgrCopy.GetSymbolSetPos(rComboBox.GetText());
01817
01818 return nSymbolSetNo == SYMBOLSET_NONE ?
01819 NULL : aSymSetMgrCopy.GetSymbolSet(nSymbolSetNo);
01820 }
01821
01822
01823 SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox)
01824 {
01825 #if OSL_DEBUG_LEVEL > 1
01826 DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
01827 "Sm : falsche ComboBox");
01828 #endif
01829 return aSymSetMgrCopy.GetSymbolByName(rComboBox.GetText());
01830 }
01831
01832
01833 IMPL_LINK( SmSymDefineDialog, OldSymbolChangeHdl, ComboBox *, EMPTYARG pComboBox )
01834 {
01835 (void) pComboBox;
01836 #if OSL_DEBUG_LEVEL > 1
01837 DBG_ASSERT(pComboBox == &aOldSymbols, "Sm : falsches Argument");
01838 #endif
01839 SelectSymbol(aOldSymbols, aOldSymbols.GetText(), FALSE);
01840 return 0;
01841 }
01842
01843
01844 IMPL_LINK( SmSymDefineDialog, OldSymbolSetChangeHdl, ComboBox *, EMPTYARG pComboBox )
01845 {
01846 (void) pComboBox;
01847 #if OSL_DEBUG_LEVEL > 1
01848 DBG_ASSERT(pComboBox == &aOldSymbolSets, "Sm : falsches Argument");
01849 #endif
01850 SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), FALSE);
01851 return 0;
01852 }
01853
01854
01855 IMPL_LINK( SmSymDefineDialog, ModifyHdl, ComboBox *, pComboBox )
01856 {
01857
01858 Selection aSelection (pComboBox->GetSelection());
01859
01860 if (pComboBox == &aSymbols)
01861 SelectSymbol(aSymbols, aSymbols.GetText(), FALSE);
01862 else if (pComboBox == &aSymbolSets)
01863 SelectSymbolSet(aSymbolSets, aSymbolSets.GetText(), FALSE);
01864 else if (pComboBox == &aOldSymbols)
01865
01866 SelectSymbol(aOldSymbols, aOldSymbols.GetText(), TRUE);
01867 else if (pComboBox == &aOldSymbolSets)
01868
01869 SelectSymbolSet(aOldSymbolSets, aOldSymbolSets.GetText(), TRUE);
01870 else if (pComboBox == &aStyles)
01871
01872 SelectStyle(aStyles.GetText(), TRUE);
01873 else
01874 {
01875 #if OSL_DEBUG_LEVEL > 1
01876 DBG_ASSERT(0, "Sm : falsche ComboBox Argument");
01877 #endif
01878 }
01879
01880 pComboBox->SetSelection(aSelection);
01881
01882 UpdateButtons();
01883
01884 return 0;
01885 }
01886
01887
01888 IMPL_LINK( SmSymDefineDialog, FontChangeHdl, ListBox *, EMPTYARG pListBox )
01889 {
01890 (void) pListBox;
01891 #if OSL_DEBUG_LEVEL > 1
01892 DBG_ASSERT(pListBox == &aFonts, "Sm : falsches Argument");
01893 #endif
01894
01895 SelectFont(aFonts.GetSelectEntry());
01896 return 0;
01897 }
01898
01899
01900 IMPL_LINK( SmSymDefineDialog, SubsetChangeHdl, ListBox *, EMPTYARG pListBox )
01901 {
01902 (void) pListBox;
01903 USHORT nPos = aFontsSubsetLB.GetSelectEntryPos();
01904 if (LISTBOX_ENTRY_NOTFOUND != nPos)
01905 {
01906 const Subset* pSubset = reinterpret_cast<const Subset*> (aFontsSubsetLB.GetEntryData( nPos ));
01907 if (pSubset)
01908 {
01909 aCharsetDisplay.SelectCharacter( pSubset->GetRangeMin() );
01910 }
01911 }
01912 return 0;
01913 }
01914
01915
01916 IMPL_LINK( SmSymDefineDialog, StyleChangeHdl, ComboBox *, EMPTYARG pComboBox )
01917 {
01918 (void) pComboBox;
01919 #if OSL_DEBUG_LEVEL > 1
01920 DBG_ASSERT(pComboBox == &aStyles, "Sm : falsches Argument");
01921 #endif
01922
01923 SelectStyle(aStyles.GetText());
01924 return 0;
01925 }
01926
01927
01928 IMPL_LINK( SmSymDefineDialog, CharHighlightHdl, Control *, EMPTYARG )
01929 {
01930 sal_UCS4 cChar = aCharsetDisplay.GetSelectCharacter();
01931
01932 #if OSL_DEBUG_LEVEL > 1
01933 DBG_ASSERT( pSubsetMap, "SubsetMap missing" )
01934 #endif
01935 if (pSubsetMap)
01936 {
01937 const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
01938 if (pSubset)
01939 aFontsSubsetLB.SelectEntry( pSubset->GetName() );
01940 else
01941 aFontsSubsetLB.SetNoSelection();
01942 }
01943
01944
01945 aSymbolDisplay.SetChar( sal::static_int_cast< sal_Unicode >(cChar) );
01946 UpdateButtons();
01947 return 0;
01948 }
01949
01950
01951 IMPL_LINK( SmSymDefineDialog, AddClickHdl, Button *, EMPTYARG pButton )
01952 {
01953 (void) pButton;
01954 #if OSL_DEBUG_LEVEL > 1
01955 DBG_ASSERT(pButton == &aAddBtn, "Sm : falsches Argument");
01956 DBG_ASSERT(aAddBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
01957 #endif
01958
01959 SmSymSet *pSymSet = GetSymbolSet(aSymbolSets);
01960
01961
01962 if (!pSymSet)
01963 {
01964 pSymSet = new SmSymSet(aSymbolSets.GetText());
01965 aSymSetMgrCopy.AddSymbolSet(pSymSet);
01966 FillSymbolSets(aOldSymbolSets, FALSE);
01967 FillSymbolSets(aSymbolSets, FALSE);
01968 }
01969 #if OSL_DEBUG_LEVEL > 1
01970 DBG_ASSERT(pSymSet, "Sm : NULL pointer");
01971 #endif
01972
01973
01974
01975 SmSym *pSym = new SmSym(aSymbols.GetText(), aCharsetDisplay.GetFont(),
01976 sal::static_int_cast< sal_Unicode >(aCharsetDisplay.GetSelectCharacter()),
01977 aSymbolSets.GetText());
01978 pSymSet->AddSymbol(pSym);
01979
01980
01981
01982 aSymSetMgrCopy.ChangeSymbolSet((SmSymSet *)1);
01983
01984
01985 FillSymbols(aOldSymbols ,FALSE);
01986 FillSymbols(aSymbols ,FALSE);
01987
01988 UpdateButtons();
01989
01990 return 0;
01991 }
01992
01993
01994 IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, Button *, EMPTYARG pButton )
01995 {
01996 (void) pButton;
01997 #if OSL_DEBUG_LEVEL > 1
01998 DBG_ASSERT(pButton == &aChangeBtn, "Sm : falsches Argument");
01999 DBG_ASSERT(aChangeBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
02000 #endif
02001
02002
02003 SmSymSet *pOldSymSet = GetSymbolSet(aOldSymbolSets);
02004 #if OSL_DEBUG_LEVEL > 1
02005 DBG_ASSERT(pOldSymSet, "Sm : NULL pointer");
02006 #endif
02007
02008
02009 SmSymSet *pNewSymSet = GetSymbolSet(aSymbolSets);
02010
02011 if (!pNewSymSet)
02012 {
02013 pNewSymSet = new SmSymSet(aSymbolSets.GetText());
02014 aSymSetMgrCopy.AddSymbolSet(pNewSymSet);
02015 FillSymbolSets(aOldSymbolSets, FALSE);
02016 FillSymbolSets(aSymbolSets, FALSE);
02017 }
02018
02019
02020 USHORT nSymbol = pOldSymSet->GetSymbolPos(aOldSymbols.GetText());
02021 SmSym *pSym = (SmSym *) &pOldSymSet->GetSymbol(nSymbol);
02022 #if OSL_DEBUG_LEVEL > 1
02023 DBG_ASSERT( SYMBOL_NONE != nSymbol, "symbol not found" );
02024 DBG_ASSERT(pSym, "Sm : NULL pointer");
02025 #endif
02026
02027
02028 pSym->SetName( aSymbols.GetText() );
02031 pSym->SetFace( aSymbolDisplay.GetFont() );
02032
02033 pSym->SetCharacter( sal::static_int_cast< sal_Unicode >(aCharsetDisplay.GetSelectCharacter()) );
02034
02035
02036 if (pOldSymSet != pNewSymSet)
02037 {
02038 pNewSymSet->AddSymbol( new SmSym( *pSym ) );
02039 pOldSymSet->DeleteSymbol(nSymbol);
02040
02041
02042
02043
02044
02045 String aTmpOldSymbolName( pOrigSymbol->GetName() );
02046 aOldSymbols.SetText( String() );
02047 aOldSymbols.RemoveEntry( aTmpOldSymbolName );
02048 if (aSymbolSets.GetText() == aOldSymbolSets.GetText())
02049 aSymbols.RemoveEntry( aTmpOldSymbolName );
02050
02051 SetOrigSymbol(NULL, XubString());
02052 }
02053
02056 aSymSetMgrCopy.ChangeSymbolSet((SmSymSet *)1);
02057
02058 UpdateButtons();
02059
02060 return 0;
02061 }
02062
02063
02064 IMPL_LINK( SmSymDefineDialog, DeleteClickHdl, Button *, EMPTYARG pButton )
02065 {
02066 (void) pButton;
02067 #if OSL_DEBUG_LEVEL > 1
02068 DBG_ASSERT(pButton == &aDeleteBtn, "Sm : falsches Argument");
02069 DBG_ASSERT(aDeleteBtn.IsEnabled(), "Sm : Voraussetzungen erfuellt ??");
02070 #endif
02071
02072 if (pOrigSymbol)
02073 {
02074
02075
02076
02077 SmSymSet *pSymSet = GetSymbolSet(aOldSymbolSets);
02078
02079 XubString aTmpOldSymbolName (pOrigSymbol->GetName());
02080 USHORT nSymbolNo = pSymSet->GetSymbolPos(aTmpOldSymbolName);
02081
02082 SetOrigSymbol(NULL, XubString());
02083
02084 pSymSet->DeleteSymbol(nSymbolNo);
02085 #if OSL_DEBUG_LEVEL > 1
02086 DBG_ASSERT(pSymSet, "Sm : NULL pointer");
02087 DBG_ASSERT(nSymbolNo != SYMBOL_NONE, "Sm : kein Symbol");
02088 #endif
02089
02094 aSymSetMgrCopy.ChangeSymbolSet((SmSymSet *)1);
02095
02096
02097 aOldSymbols.SetText(XubString());
02098 aOldSymbols.RemoveEntry(aTmpOldSymbolName);
02099 if (aSymbolSets.GetText() == aOldSymbolSets.GetText())
02100 aSymbols.RemoveEntry(aTmpOldSymbolName);
02101 }
02102
02103 UpdateButtons();
02104
02105 return 0;
02106 }
02107
02108
02109 void SmSymDefineDialog::UpdateButtons()
02110 {
02111 BOOL bAdd = FALSE,
02112 bChange = FALSE,
02113 bDelete = FALSE,
02114 bEqual;
02115 XubString aTmpSymbolName (aSymbols.GetText()),
02116 aTmpSymbolSetName (aSymbolSets.GetText());
02117
02118 if (aTmpSymbolName.Len() > 0 && aTmpSymbolSetName.Len() > 0)
02119 {
02120
02122 bEqual = pOrigSymbol
02123 && aTmpSymbolSetName.EqualsIgnoreCaseAscii(aOldSymbolSetName.GetText())
02124 && aTmpSymbolName.Equals(pOrigSymbol->GetName())
02125 && aFonts.GetSelectEntry().EqualsIgnoreCaseAscii(
02126 pOrigSymbol->GetFace().GetName())
02127 && aStyles.GetText().EqualsIgnoreCaseAscii(
02128 GetFontStyles().GetStyleName(pOrigSymbol->GetFace()))
02129 && aCharsetDisplay.GetSelectCharacter() == pOrigSymbol->GetCharacter();
02130
02131
02132 bAdd = aSymSetMgrCopy.GetSymbolByName(aTmpSymbolName) == NULL;
02133
02134
02135 bDelete = pOrigSymbol != NULL;
02136
02137
02138
02139
02140 BOOL bEqualName = pOrigSymbol && aTmpSymbolName == pOrigSymbol->GetName();
02141 bChange = pOrigSymbol && (bEqualName && !bEqual || !bEqualName && bAdd);
02142 }
02143
02144 aAddBtn .Enable(bAdd);
02145 aChangeBtn.Enable(bChange);
02146 aDeleteBtn.Enable(bDelete);
02147 }
02148
02149
02150 SmSymDefineDialog::SmSymDefineDialog(Window * pParent,
02151 OutputDevice *pFntListDevice, SmSymSetManager &rMgr, BOOL bFreeRes) :
02152 ModalDialog (pParent, SmResId(RID_SYMDEFINEDIALOG)),
02153 aOldSymbolText (this, SmResId(1)),
02154 aOldSymbols (this, SmResId(1)),
02155 aOldSymbolSetText (this, SmResId(2)),
02156 aOldSymbolSets (this, SmResId(2)),
02157 aCharsetDisplay (this, SmResId(1)),
02158 aSymbolText (this, SmResId(9)),
02159 aSymbols (this, SmResId(4)),
02160 aSymbolSetText (this, SmResId(10)),
02161 aSymbolSets (this, SmResId(5)),
02162 aFontText (this, SmResId(3)),
02163 aFonts (this, SmResId(1)),
02164 aFontsSubsetFT (this, SmResId( FT_FONTS_SUBSET )),
02165 aFontsSubsetLB (this, SmResId( LB_FONTS_SUBSET )),
02166 aStyleText (this, SmResId(4)),
02167 aStyles (this, SmResId(3)),
02168 aOldSymbolName (this, SmResId(7)),
02169 aOldSymbolDisplay (this, SmResId(3)),
02170 aOldSymbolSetName (this, SmResId(8)),
02171 aSymbolName (this, SmResId(5)),
02172 aSymbolDisplay (this, SmResId(2)),
02173 aSymbolSetName (this, SmResId(6)),
02174 aOkBtn (this, SmResId(1)),
02175 aCancelBtn (this, SmResId(1)),
02176 aAddBtn (this, SmResId(1)),
02177 aChangeBtn (this, SmResId(2)),
02178 aDeleteBtn (this, SmResId(3)),
02179 aRightArrow (this, SmResId(1)),
02180 aRigthArrow_Im (SmResId(1)),
02181 aRigthArrow_Im_HC (SmResId(2)),
02182 rSymSetMgr (rMgr),
02183 pSubsetMap (NULL),
02184 pFontList (NULL)
02185 {
02186 if (bFreeRes)
02187 FreeResource();
02188
02189 pFontList = new FontList( pFntListDevice );
02190
02191 pOrigSymbol = 0;
02192
02193
02194 aOldSymbols.EnableAutocomplete(TRUE, TRUE);
02195 aSymbols .EnableAutocomplete(TRUE, TRUE);
02196
02197 FillFonts();
02198 if (aFonts.GetEntryCount() > 0)
02199 SelectFont(aFonts.GetEntry(0));
02200
02201 InitColor_Impl();
02202
02203 SetSymbolSetManager(rSymSetMgr);
02204
02205 aOldSymbols .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolChangeHdl));
02206 aOldSymbolSets .SetSelectHdl(LINK(this, SmSymDefineDialog, OldSymbolSetChangeHdl));
02207 aSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
02208 aOldSymbolSets .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
02209 aSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
02210 aOldSymbols .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
02211 aStyles .SetModifyHdl(LINK(this, SmSymDefineDialog, ModifyHdl));
02212 aFonts .SetSelectHdl(LINK(this, SmSymDefineDialog, FontChangeHdl));
02213 aFontsSubsetLB .SetSelectHdl(LINK(this, SmSymDefineDialog, SubsetChangeHdl));
02214 aStyles .SetSelectHdl(LINK(this, SmSymDefineDialog, StyleChangeHdl));
02215 aAddBtn .SetClickHdl (LINK(this, SmSymDefineDialog, AddClickHdl));
02216 aChangeBtn .SetClickHdl (LINK(this, SmSymDefineDialog, ChangeClickHdl));
02217 aDeleteBtn .SetClickHdl (LINK(this, SmSymDefineDialog, DeleteClickHdl));
02218 aCharsetDisplay.SetHighlightHdl( LINK( this, SmSymDefineDialog, CharHighlightHdl ) );
02219
02220
02221 aOldSymbolDisplay.SetBorderStyle( WINDOW_BORDER_MONO );
02222 aSymbolDisplay .SetBorderStyle( WINDOW_BORDER_MONO );
02223 }
02224
02225
02226 SmSymDefineDialog::~SmSymDefineDialog()
02227 {
02228 delete pSubsetMap;
02229 delete pOrigSymbol;
02230 }
02231
02232 void SmSymDefineDialog::InitColor_Impl()
02233 {
02234 #if OSL_DEBUG_LEVEL > 1
02235 Color aBC( GetDisplayBackground().GetColor() );
02236 #endif
02237 ColorData nBgCol = COL_WHITE,
02238 nTxtCol = COL_BLACK;
02239 BOOL bHighContrast = GetDisplayBackground().GetColor().IsDark() != 0;
02240 if (bHighContrast)
02241 {
02242 const StyleSettings &rS = GetSettings().GetStyleSettings();
02243 nBgCol = rS.GetFieldColor().GetColor();
02244 nTxtCol = rS.GetFieldTextColor().GetColor();
02245 }
02246
02247 Color aTmpColor( nBgCol );
02248 Wallpaper aWall( aTmpColor );
02249 Color aTxtColor( nTxtCol );
02250 aCharsetDisplay .SetBackground( aWall );
02251 aCharsetDisplay .SetTextColor( aTxtColor );
02252 aOldSymbolDisplay.SetBackground( aWall );
02253 aOldSymbolDisplay.SetTextColor( aTxtColor );
02254 aSymbolDisplay .SetBackground( aWall );
02255 aSymbolDisplay .SetTextColor( aTxtColor );
02256
02257 const Image &rArrowRight = bHighContrast ? aRigthArrow_Im_HC : aRigthArrow_Im;
02258 aRightArrow.SetImage( rArrowRight );
02259 }
02260
02261
02262 void SmSymDefineDialog::DataChanged( const DataChangedEvent& rDCEvt )
02263 {
02264 if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
02265 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
02266 InitColor_Impl();
02267
02268 ModalDialog::DataChanged( rDCEvt );
02269 }
02270
02271
02272 short SmSymDefineDialog::Execute()
02273 {
02274 short nResult = ModalDialog::Execute();
02275
02276
02277 if (aSymSetMgrCopy.IsModified() && nResult == RET_OK)
02278 {
02279
02280
02281
02282 USHORT nSymbolSets = aSymSetMgrCopy.GetSymbolSetCount();
02283 for (USHORT i = 0; i < nSymbolSets; i++)
02284 {
02285 USHORT nIdx = nSymbolSets - 1 - i;
02286 if (aSymSetMgrCopy.GetSymbolSet(nIdx)->GetCount() == 0)
02287 aSymSetMgrCopy.DeleteSymbolSet(nIdx);
02288 }
02289
02290
02291
02292 rSymSetMgr = aSymSetMgrCopy;
02293 #ifdef DEBUG
02294
02295 #endif
02296 }
02297
02298 return nResult;
02299 }
02300
02301
02302 void SmSymDefineDialog::SetSymbolSetManager(const SmSymSetManager &rMgr)
02303 {
02304 aSymSetMgrCopy = rMgr;
02305 #ifdef DEBUG
02306
02307 #endif
02308
02309
02310
02311 aSymSetMgrCopy.SetModified(FALSE);
02312
02313 FillSymbolSets(aOldSymbolSets);
02314 if (aOldSymbolSets.GetEntryCount() > 0)
02315 SelectSymbolSet(aOldSymbolSets.GetEntry(0));
02316 FillSymbolSets(aSymbolSets);
02317 if (aSymbolSets.GetEntryCount() > 0)
02318 SelectSymbolSet(aSymbolSets.GetEntry(0));
02319 FillSymbols(aOldSymbols);
02320 if (aOldSymbols.GetEntryCount() > 0)
02321 SelectSymbol(aOldSymbols.GetEntry(0));
02322 FillSymbols(aSymbols);
02323 if (aSymbols.GetEntryCount() > 0)
02324 SelectSymbol(aSymbols.GetEntry(0));
02325
02326 UpdateButtons();
02327 }
02328
02329
02330 BOOL SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox,
02331 const XubString &rSymbolSetName, BOOL bDeleteText)
02332 {
02333 #if OSL_DEBUG_LEVEL > 1
02334 DBG_ASSERT(&rComboBox == &aOldSymbolSets || &rComboBox == &aSymbolSets,
02335 "Sm : falsche ComboBox");
02336 #endif
02337
02338
02339 XubString aNormName (rSymbolSetName);
02340 aNormName.EraseLeadingChars(' ');
02341 aNormName.EraseTrailingChars(' ');
02342
02343 rComboBox.SetText(aNormName);
02344
02345 BOOL bRet = FALSE;
02346 USHORT nPos = rComboBox.GetEntryPos(aNormName);
02347
02348 if (nPos != COMBOBOX_ENTRY_NOTFOUND)
02349 {
02350 rComboBox.SetText(rComboBox.GetEntry(nPos));
02351 bRet = TRUE;
02352 }
02353 else if (bDeleteText)
02354 rComboBox.SetText(XubString());
02355
02356 BOOL bIsOld = &rComboBox == &aOldSymbolSets;
02357
02358
02359 FixedText &rFT = bIsOld ? aOldSymbolSetName : aSymbolSetName;
02360 rFT.SetText(rComboBox.GetText());
02361
02362
02363
02364 ComboBox &rCB = bIsOld ? aOldSymbols : aSymbols;
02365 FillSymbols(rCB, FALSE);
02366
02367
02368
02369 if (bIsOld)
02370 {
02371 XubString aTmpOldSymbolName;
02372 if (aOldSymbols.GetEntryCount() > 0)
02373 aTmpOldSymbolName = aOldSymbols.GetEntry(0);
02374 SelectSymbol(aOldSymbols, aTmpOldSymbolName, TRUE);
02375 }
02376
02377 UpdateButtons();
02378
02379 return bRet;
02380 }
02381
02382
02383 void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol,
02384 const XubString &rSymbolSetName)
02385 {
02386
02387 delete pOrigSymbol;
02388 pOrigSymbol = 0;
02389
02390 XubString aSymName,
02391 aSymSetName;
02392 if (pSymbol)
02393 {
02394
02395 pOrigSymbol = new SmSym( *pSymbol );
02396
02397 aSymName = pSymbol->GetName();
02398 aSymSetName = rSymbolSetName;
02399 aOldSymbolDisplay.SetFont(pSymbol->GetFace());
02400 aOldSymbolDisplay.SetChar(pSymbol->GetCharacter());
02401 }
02402 else
02403 {
02404 aOldSymbolDisplay.SetText(XubString());
02405 aOldSymbolDisplay.Invalidate();
02406 }
02407 aOldSymbolName .SetText(aSymName);
02408 aOldSymbolSetName.SetText(aSymSetName);
02409 }
02410
02411
02412 BOOL SmSymDefineDialog::SelectSymbol(ComboBox &rComboBox,
02413 const XubString &rSymbolName, BOOL bDeleteText)
02414 {
02415 #if OSL_DEBUG_LEVEL > 1
02416 DBG_ASSERT(&rComboBox == &aOldSymbols || &rComboBox == &aSymbols,
02417 "Sm : falsche ComboBox");
02418 #endif
02419
02420
02421 XubString aNormName (rSymbolName);
02422 aNormName.EraseAllChars(' ');
02423
02424 rComboBox.SetText(aNormName);
02425
02426 BOOL bRet = FALSE;
02427 USHORT nPos = rComboBox.GetEntryPos(aNormName);
02428
02429 BOOL bIsOld = &rComboBox == &aOldSymbols;
02430
02431 if (nPos != COMBOBOX_ENTRY_NOTFOUND)
02432 {
02433 rComboBox.SetText(rComboBox.GetEntry(nPos));
02434
02435 if (!bIsOld)
02436 {
02437 const SmSym *pSymbol = GetSymbol(aSymbols);
02438 if (pSymbol)
02439 {
02440
02441 const Font &rFont = pSymbol->GetFace();
02442 SelectFont(rFont.GetName(), FALSE);
02443 SelectStyle(GetFontStyles().GetStyleName(rFont), FALSE);
02444
02445
02446
02447
02448
02449 aCharsetDisplay.SetFont(rFont);
02450 aSymbolDisplay.SetFont(rFont);
02451
02452
02453 SelectChar(pSymbol->GetCharacter());
02454 }
02455 }
02456
02457 bRet = TRUE;
02458 }
02459 else if (bDeleteText)
02460 rComboBox.SetText(XubString());
02461
02462 if (bIsOld)
02463 {
02464
02465 const SmSym *pOldSymbol = NULL;
02466 XubString aTMpOldSymbolSetName;
02467 if (nPos != COMBOBOX_ENTRY_NOTFOUND)
02468 {
02469 pOldSymbol = aSymSetMgrCopy.GetSymbolByName(aNormName);
02470 aTMpOldSymbolSetName = aOldSymbolSets.GetText();
02471 }
02472 SetOrigSymbol(pOldSymbol, aTMpOldSymbolSetName);
02473 }
02474 else
02475 aSymbolName.SetText(rComboBox.GetText());
02476
02477 UpdateButtons();
02478
02479 return bRet;
02480 }
02481
02482
02483 void SmSymDefineDialog::SetFont(const XubString &rFontName, const XubString &rStyleName)
02484 {
02485
02486 FontInfo aFI;
02487 if (pFontList)
02488 aFI = pFontList->Get(rFontName, WEIGHT_NORMAL, ITALIC_NONE);
02489 SetFontStyle(rStyleName, aFI);
02490
02491 aCharsetDisplay.SetFont(aFI);
02492 aSymbolDisplay.SetFont(aFI);
02493
02494
02495 FontCharMap aFontCharMap;
02496 aCharsetDisplay.GetFontCharMap( aFontCharMap );
02497 if (pSubsetMap)
02498 delete pSubsetMap;
02499 pSubsetMap = new SubsetMap( &aFontCharMap );
02500
02501 aFontsSubsetLB.Clear();
02502 bool bFirst = true;
02503 const Subset* pSubset;
02504 while( NULL != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
02505 {
02506 USHORT nPos = aFontsSubsetLB.InsertEntry( pSubset->GetName());
02507 aFontsSubsetLB.SetEntryData( nPos, (void *) pSubset );
02508
02509 if( bFirst )
02510 aFontsSubsetLB.SelectEntryPos( nPos );
02511 bFirst = false;
02512 }
02513 if( bFirst )
02514 aFontsSubsetLB.SetNoSelection();
02515 aFontsSubsetLB.Enable( !bFirst );
02516 }
02517
02518
02519 BOOL SmSymDefineDialog::SelectFont(const XubString &rFontName, BOOL bApplyFont)
02520 {
02521 BOOL bRet = FALSE;
02522 USHORT nPos = aFonts.GetEntryPos(rFontName);
02523
02524 if (nPos != LISTBOX_ENTRY_NOTFOUND)
02525 {
02526 aFonts.SelectEntryPos(nPos);
02527 if (aStyles.GetEntryCount() > 0)
02528 SelectStyle(aStyles.GetEntry(0));
02529 if (bApplyFont)
02530 SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
02531 bRet = TRUE;
02532 }
02533 else
02534 aFonts.SetNoSelection();
02535 FillStyles();
02536
02537 UpdateButtons();
02538
02539 return bRet;
02540 }
02541
02542
02543 BOOL SmSymDefineDialog::SelectStyle(const XubString &rStyleName, BOOL bApplyFont)
02544 {
02545 BOOL bRet = FALSE;
02546 USHORT nPos = aStyles.GetEntryPos(rStyleName);
02547
02548
02549
02550 if (nPos == COMBOBOX_ENTRY_NOTFOUND && aStyles.GetEntryCount() > 0)
02551 nPos = 0;
02552
02553 if (nPos != COMBOBOX_ENTRY_NOTFOUND)
02554 {
02555 aStyles.SetText(aStyles.GetEntry(nPos));
02556 if (bApplyFont)
02557 SetFont(aFonts.GetSelectEntry(), aStyles.GetText());
02558 bRet = TRUE;
02559 }
02560 else
02561 aStyles.SetText(XubString());
02562
02563 UpdateButtons();
02564
02565 return bRet;
02566 }
02567
02568
02569 void SmSymDefineDialog::SelectChar(xub_Unicode cChar)
02570 {
02571 aCharsetDisplay.SelectCharacter( cChar );
02572 aSymbolDisplay.SetChar( cChar );
02573
02574 UpdateButtons();
02575 }
02576
02577
02578
02579