1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <vcl/image.hxx>
23 #include <vcl/dialog.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/button.hxx>
26 #include <sfx2/tabdlg.hxx>
27 #include <vcl/combobox.hxx>
28 #include <svx/charmap.hxx>
29 #include <sfx2/basedlgs.hxx>
30 #include <vcl/field.hxx>
31 #include <vcl/menubtn.hxx>
32 #include <vcl/scrbar.hxx>
33 #include <vcl/ctrl.hxx>
34 #include <vcl/menu.hxx>
35 #include <vcl/outdev.hxx>
36 #include <svtools/ctrlbox.hxx>
37 #include <svtools/ctrltool.hxx>
38 #include "utility.hxx"
43 #define CATEGORY_NONE 0xFFFF
45 /**************************************************************************/
47 void SetFontStyle(const OUString
&rStyleName
, Font
&rFont
);
49 /**************************************************************************/
51 class SmPrintOptionsTabPage
: public SfxTabPage
53 FixedLine aFixedLine1
;
57 FixedLine aFixedLine2
;
58 RadioButton aSizeNormal
;
59 RadioButton aSizeScaled
;
60 RadioButton aSizeZoomed
;
62 FixedLine aFixedLine3
;
63 CheckBox aNoRightSpaces
;
64 CheckBox aSaveOnlyUsedSymbols
;
66 DECL_LINK(SizeButtonClickHdl
, Button
*);
68 virtual sal_Bool
FillItemSet(SfxItemSet
& rSet
);
69 virtual void Reset(const SfxItemSet
& rSet
);
72 static SfxTabPage
* Create(Window
*pWindow
, const SfxItemSet
&rSet
);
74 SmPrintOptionsTabPage(Window
*pParent
, const SfxItemSet
&rOptions
);
77 /**************************************************************************/
79 class SmShowFont
: public Control
81 virtual void Paint(const Rectangle
&);
84 SmShowFont(Window
*pParent
, const ResId
& rResId
) :
85 Control(pParent
, rResId
)
89 void SetFont(const Font
& rFont
);
92 class SmFontDialog
: public ModalDialog
94 FixedText aFixedText1
;
96 CheckBox aBoldCheckBox
;
97 CheckBox aItalicCheckBox
;
99 HelpButton aHelpButton1
;
100 CancelButton aCancelButton1
;
101 SmShowFont aShowFont
;
102 FixedText aFixedText2
;
106 DECL_LINK(FontSelectHdl
, ComboBox
*);
107 DECL_LINK(FontModifyHdl
, ComboBox
*);
108 DECL_LINK(AttrChangeHdl
, CheckBox
*);
109 DECL_LINK(HelpButtonClickHdl
, Button
*);
111 void InitColor_Impl();
113 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
116 SmFontDialog(Window
* pParent
, OutputDevice
*pFntListDevice
, bool bHideCheckboxes
, bool bFreeRes
= true);
118 const Font
& GetFont() const { return Face
; }
119 void SetFont(const Font
&rFont
);
122 /**************************************************************************/
124 class SmFontSizeDialog
: public ModalDialog
126 FixedText aFixedText1
;
127 MetricField aBaseSize
;
128 FixedText aFixedText4
;
129 MetricField aTextSize
;
130 FixedText aFixedText5
;
131 MetricField aIndexSize
;
132 FixedText aFixedText6
;
133 MetricField aFunctionSize
;
134 FixedText aFixedText7
;
135 MetricField aOperatorSize
;
136 FixedText aFixedText8
;
137 MetricField aBorderSize
;
138 FixedLine aFixedLine1
;
140 HelpButton aHelpButton1
;
141 CancelButton aCancelButton1
;
142 PushButton aDefaultButton
;
144 DECL_LINK(DefaultButtonClickHdl
, Button
*);
145 DECL_LINK(HelpButtonClickHdl
, Button
*);
148 SmFontSizeDialog(Window
*pParent
, bool bFreeRes
= true);
150 void ReadFrom(const SmFormat
&rFormat
);
151 void WriteTo (SmFormat
&rFormat
) const;
154 /**************************************************************************/
156 class SmFontTypeDialog
: public ModalDialog
158 FixedText aFixedText1
;
159 SmFontPickListBox aVariableFont
;
160 FixedText aFixedText2
;
161 SmFontPickListBox aFunctionFont
;
162 FixedText aFixedText3
;
163 SmFontPickListBox aNumberFont
;
164 FixedText aFixedText4
;
165 SmFontPickListBox aTextFont
;
166 FixedText aFixedText5
;
167 SmFontPickListBox aSerifFont
;
168 FixedText aFixedText6
;
169 SmFontPickListBox aSansFont
;
170 FixedText aFixedText7
;
171 SmFontPickListBox aFixedFont
;
172 FixedLine aFixedLine1
;
173 FixedLine aFixedLine2
;
175 HelpButton aHelpButton1
;
176 CancelButton aCancelButton1
;
177 MenuButton aMenuButton
;
178 PushButton aDefaultButton
;
180 OutputDevice
*pFontListDev
;
182 DECL_LINK(MenuSelectHdl
, Menu
*);
183 DECL_LINK(DefaultButtonClickHdl
, Button
*);
184 DECL_LINK(HelpButtonClickHdl
, Button
*);
187 SmFontTypeDialog(Window
*pParent
, OutputDevice
*pFntListDevice
, bool bFreeRes
= true);
189 void ReadFrom(const SmFormat
&rFormat
);
190 void WriteTo (SmFormat
&rFormat
) const;
193 /**************************************************************************/
195 #define NOCATEGORIES 10
197 class SmCategoryDesc
: public Resource
200 OUString
*Strings
[4];
201 Bitmap
*Graphics
[4]; /* regular bitmaps */
202 sal_uInt16 Minimum
[4];
203 sal_uInt16 Maximum
[4];
207 SmCategoryDesc(const ResId
&rResId
, sal_uInt16 nCategoryIdx
);
210 const OUString
& GetName() const { return Name
; }
211 const OUString
* GetString(sal_uInt16 Index
) const { return Strings
[Index
]; }
212 sal_uInt16
GetMinimum(sal_uInt16 Index
) { return Minimum
[Index
]; }
213 sal_uInt16
GetMaximum(sal_uInt16 Index
) { return Maximum
[Index
]; }
214 sal_uInt16
GetValue(sal_uInt16 Index
) const { return Value
[Index
]; }
215 void SetValue(sal_uInt16 Index
, sal_uInt16 nVal
) { Value
[Index
] = nVal
;}
217 const Bitmap
* GetGraphic(sal_uInt16 Index
) const
219 return Graphics
[Index
];
224 class SmDistanceDialog
: public ModalDialog
226 FixedText aFixedText1
;
227 MetricField aMetricField1
;
228 FixedText aFixedText2
;
229 MetricField aMetricField2
;
230 FixedText aFixedText3
;
231 MetricField aMetricField3
;
233 FixedText aFixedText4
;
234 MetricField aMetricField4
;
236 HelpButton aHelpButton1
;
237 CancelButton aCancelButton1
;
238 MenuButton aMenuButton
;
239 PushButton aDefaultButton
;
241 FixedLine aFixedLine
;
243 SmCategoryDesc
*Categories
[NOCATEGORIES
];
244 sal_uInt16 nActiveCategory
;
245 bool bScaleAllBrackets
;
247 DECL_LINK(GetFocusHdl
, Control
*);
248 DECL_LINK(MenuSelectHdl
, Menu
*);
249 DECL_LINK(DefaultButtonClickHdl
, Button
*);
250 DECL_LINK(HelpButtonClickHdl
, Button
*);
251 DECL_LINK(CheckBoxClickHdl
, CheckBox
*);
253 using Window::SetHelpId
;
254 void SetHelpId(MetricField
&rField
, const OString
& sHelpId
);
255 void SetCategory(sal_uInt16 Category
);
258 SmDistanceDialog(Window
*pParent
, bool bFreeRes
= true);
261 void ReadFrom(const SmFormat
&rFormat
);
262 void WriteTo (SmFormat
&rFormat
) /*const*/;
265 virtual void DataChanged( const DataChangedEvent
&rEvt
);
269 /**************************************************************************/
272 class SmAlignDialog
: public ModalDialog
277 FixedLine aFixedLine1
;
279 HelpButton aHelpButton1
;
280 CancelButton aCancelButton1
;
281 PushButton aDefaultButton
;
283 DECL_LINK(DefaultButtonClickHdl
, Button
*);
284 DECL_LINK(HelpButtonClickHdl
, Button
*);
287 SmAlignDialog(Window
*pParent
, bool bFreeRes
= true);
289 void ReadFrom(const SmFormat
&rFormat
);
290 void WriteTo (SmFormat
&rFormat
) const;
293 /**************************************************************************/
295 class SmShowSymbolSet
: public Control
297 SymbolPtrVec_t aSymbolSet
;
298 ScrollBar aVScrollBar
;
301 Link aDblClickHdlLink
;
303 sal_uInt16 nRows
, nColumns
;
304 sal_uInt16 nSelectSymbol
;
306 virtual void Paint(const Rectangle
&);
307 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
308 virtual void KeyInput(const KeyEvent
& rKEvt
);
310 DECL_LINK( ScrollHdl
, ScrollBar
* );
313 SmShowSymbolSet(Window
*pParent
, const ResId
& rResId
);
315 void SetSymbolSet(const SymbolPtrVec_t
& rSymbolSet
);
317 void SelectSymbol(sal_uInt16 nSymbol
);
318 sal_uInt16
GetSelectSymbol() const { return nSelectSymbol
; }
320 void SetSelectHdl(const Link
& rLink
) { aSelectHdlLink
= rLink
; }
321 void SetDblClickHdl(const Link
& rLink
) { aDblClickHdlLink
= rLink
; }
324 ////////////////////////////////////////////////////////////////////////////////
326 class SmShowSymbol
: public Control
328 Link aDblClickHdlLink
;
330 virtual void Paint(const Rectangle
&);
331 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
334 SmShowSymbol(Window
*pParent
, const ResId
& rResId
) :
335 Control(pParent
, rResId
) {}
337 void SetSymbol(const SmSym
*pSymbol
);
338 void SetDblClickHdl(const Link
&rLink
) { aDblClickHdlLink
= rLink
; }
341 ////////////////////////////////////////////////////////////////////////////////
343 class SmSymDefineDialog
;
345 class SmSymbolDialog
: public ModalDialog
347 FixedText aSymbolSetText
;
349 SmShowSymbolSet aSymbolSetDisplay
;
350 FixedText aSymbolName
;
351 SmShowSymbol aSymbolDisplay
;
354 PushButton aCloseBtn
;
357 SmViewShell
&rViewSh
;
358 SmSymbolManager
&rSymbolMgr
;
360 OUString aSymbolSetName
;
361 SymbolPtrVec_t aSymbolSet
;
363 OutputDevice
*pFontListDev
;
365 DECL_LINK(SymbolSetChangeHdl
, ListBox
*);
366 DECL_LINK(SymbolChangeHdl
, SmShowSymbolSet
*);
367 DECL_LINK(SymbolDblClickHdl
, SmShowSymbolSet
*);
368 DECL_LINK(CloseClickHdl
, Button
*);
369 DECL_LINK(EditClickHdl
, Button
*);
370 DECL_LINK(GetClickHdl
, Button
*);
371 DECL_LINK(HelpButtonClickHdl
, Button
*);
373 void FillSymbolSets(bool bDeleteText
= true);
374 void SetSymbolSetManager(SmSymbolManager
&rMgr
);
375 const SmSym
*GetSymbol() const;
376 void InitColor_Impl();
378 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
381 SmSymbolDialog(Window
* pParent
, OutputDevice
*pFntListDevice
,
382 SmSymbolManager
&rSymbolMgr
, SmViewShell
&rViewShell
, bool bFreeRes
= true);
383 virtual ~SmSymbolDialog();
385 bool SelectSymbolSet(const OUString
&rSymbolSetName
);
386 void SelectSymbol(sal_uInt16 nSymbolPos
);
387 sal_uInt16
GetSelectedSymbol() const { return aSymbolSetDisplay
.GetSelectSymbol(); }
390 ////////////////////////////////////////////////////////////////////////////////
392 class SmShowChar
: public Control
394 virtual void Paint(const Rectangle
&);
397 SmShowChar(Window
*pParent
, const ResId
& rResId
)
398 : Control(pParent
, rResId
)
402 void SetSymbol( const SmSym
*pSym
);
403 void SetSymbol( sal_UCS4 cChar
, const Font
&rFont
);
406 ////////////////////////////////////////////////////////////////////////////////
408 class SmSymDefineDialog
: public ModalDialog
410 FixedText aOldSymbolText
;
411 ComboBox aOldSymbols
;
412 FixedText aOldSymbolSetText
;
413 ComboBox aOldSymbolSets
;
414 SvxShowCharSet aCharsetDisplay
;
415 FixedText aSymbolText
;
417 FixedText aSymbolSetText
;
418 ComboBox aSymbolSets
;
421 FixedText aFontsSubsetFT
;
422 ListBox aFontsSubsetLB
;
423 FixedText aStyleText
;
424 FontStyleBox aStyles
;
425 FixedText aOldSymbolName
;
426 SmShowChar aOldSymbolDisplay
;
427 FixedText aOldSymbolSetName
;
428 FixedText aSymbolName
;
429 SmShowChar aSymbolDisplay
;
430 FixedText aSymbolSetName
;
433 CancelButton aCancelBtn
;
435 PushButton aChangeBtn
;
436 PushButton aDeleteBtn
;
437 FixedImage aRightArrow
;
438 Image aRigthArrow_Im
;
440 SmSymbolManager aSymbolMgrCopy
,
442 const SmSym
*pOrigSymbol
;
444 const SubsetMap
*pSubsetMap
;
447 DECL_LINK(OldSymbolChangeHdl
, ComboBox
*);
448 DECL_LINK(OldSymbolSetChangeHdl
, ComboBox
*);
449 DECL_LINK(ModifyHdl
, ComboBox
*);
450 DECL_LINK(FontChangeHdl
, ListBox
*);
451 DECL_LINK(SubsetChangeHdl
, ListBox
*);
452 DECL_LINK(StyleChangeHdl
, ComboBox
*);
453 DECL_LINK(CharHighlightHdl
, void *);
454 DECL_LINK(AddClickHdl
, Button
*);
455 DECL_LINK(ChangeClickHdl
, Button
*);
456 DECL_LINK(DeleteClickHdl
, Button
*);
457 DECL_LINK(HelpButtonClickHdl
, Button
*);
459 void FillSymbols(ComboBox
&rComboBox
, bool bDeleteText
= true);
460 void FillSymbolSets(ComboBox
&rComboBox
, bool bDeleteText
= true);
461 void FillFonts(bool bDeleteText
= true);
462 void FillStyles(bool bDeleteText
= true);
464 void SetSymbolSetManager(const SmSymbolManager
&rMgr
);
465 void SetFont(const OUString
&rFontName
, const OUString
&rStyleName
);
466 void SetOrigSymbol(const SmSym
*pSymbol
, const OUString
&rSymbolSetName
);
467 void UpdateButtons();
469 bool SelectSymbolSet(ComboBox
&rComboBox
, const OUString
&rSymbolSetName
,
471 bool SelectSymbol(ComboBox
&rComboBox
, const OUString
&rSymbolName
,
473 bool SelectFont(const OUString
&rFontName
, bool bApplyFont
);
474 bool SelectStyle(const OUString
&rStyleName
, bool bApplyFont
);
476 SmSym
* GetSymbol(const ComboBox
&rComboBox
);
477 const SmSym
* GetSymbol(const ComboBox
&rComboBox
) const
479 return ((SmSymDefineDialog
*) this)->GetSymbol(rComboBox
);
482 void InitColor_Impl();
484 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
487 SmSymDefineDialog(Window
*pParent
, OutputDevice
*pFntListDevice
, SmSymbolManager
&rMgr
, bool bFreeRes
= true);
488 ~SmSymDefineDialog();
490 using OutputDevice::SetFont
;
493 virtual short Execute();
495 bool SelectOldSymbolSet(const OUString
&rSymbolSetName
)
497 return SelectSymbolSet(aOldSymbolSets
, rSymbolSetName
, false);
500 bool SelectOldSymbol(const OUString
&rSymbolName
)
502 return SelectSymbol(aOldSymbols
, rSymbolName
, false);
505 bool SelectSymbolSet(const OUString
&rSymbolSetName
)
507 return SelectSymbolSet(aSymbolSets
, rSymbolSetName
, false);
510 bool SelectSymbol(const OUString
&rSymbolName
)
512 return SelectSymbol(aSymbols
, rSymbolName
, false);
515 bool SelectFont(const OUString
&rFontName
) { return SelectFont(rFontName
, true); }
516 bool SelectStyle(const OUString
&rStyleName
) { return SelectStyle(rStyleName
, true); };
517 void SelectChar(sal_Unicode cChar
);
524 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */