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 .
19 #ifndef INCLUDED_STARMATH_INC_DIALOG_HXX
20 #define INCLUDED_STARMATH_INC_DIALOG_HXX
22 #include <vcl/image.hxx>
23 #include <vcl/dialog.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/layout.hxx>
27 #include <sfx2/tabdlg.hxx>
28 #include <vcl/combobox.hxx>
29 #include <svx/charmap.hxx>
30 #include <sfx2/basedlgs.hxx>
31 #include <vcl/field.hxx>
32 #include <vcl/menubtn.hxx>
33 #include <vcl/scrbar.hxx>
34 #include <vcl/ctrl.hxx>
35 #include <vcl/menu.hxx>
36 #include <vcl/outdev.hxx>
37 #include <svtools/ctrlbox.hxx>
38 #include <svtools/ctrltool.hxx>
39 #include "utility.hxx"
45 #define CATEGORY_NONE 0xFFFF
47 /**************************************************************************/
49 void SetFontStyle(const OUString
&rStyleName
, vcl::Font
&rFont
);
51 /**************************************************************************/
53 class SmPrintOptionsTabPage
: public SfxTabPage
55 VclPtr
<CheckBox
> m_pTitle
;
56 VclPtr
<CheckBox
> m_pText
;
57 VclPtr
<CheckBox
> m_pFrame
;
58 VclPtr
<RadioButton
> m_pSizeNormal
;
59 VclPtr
<RadioButton
> m_pSizeScaled
;
60 VclPtr
<RadioButton
> m_pSizeZoomed
;
61 VclPtr
<MetricField
> m_pZoom
;
62 VclPtr
<CheckBox
> m_pNoRightSpaces
;
63 VclPtr
<CheckBox
> m_pSaveOnlyUsedSymbols
;
64 VclPtr
<CheckBox
> m_pAutoCloseBrackets
;
66 DECL_LINK(SizeButtonClickHdl
, Button
*, void);
68 virtual bool FillItemSet(SfxItemSet
* rSet
) override
;
69 virtual void Reset(const SfxItemSet
* rSet
) override
;
72 static VclPtr
<SfxTabPage
> Create(vcl::Window
*pWindow
, const SfxItemSet
&rSet
);
74 SmPrintOptionsTabPage(vcl::Window
*pParent
, const SfxItemSet
&rOptions
);
75 virtual ~SmPrintOptionsTabPage() override
;
76 virtual void dispose() override
;
79 /**************************************************************************/
81 class SmShowFont
: public vcl::Window
83 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
88 SmShowFont(vcl::Window
*pParent
, WinBits nStyle
)
89 : Window(pParent
, nStyle
)
92 virtual Size
GetOptimalSize() const override
;
93 void SetFont(const vcl::Font
& rFont
);
96 class SmFontDialog
: public ModalDialog
98 VclPtr
<ComboBox
> m_pFontBox
;
99 VclPtr
<VclContainer
> m_pAttrFrame
;
100 VclPtr
<CheckBox
> m_pBoldCheckBox
;
101 VclPtr
<CheckBox
> m_pItalicCheckBox
;
102 VclPtr
<SmShowFont
> m_pShowFont
;
106 DECL_LINK(FontSelectHdl
, ComboBox
&, void);
107 DECL_LINK(FontModifyHdl
, Edit
&, void);
108 DECL_LINK(AttrChangeHdl
, Button
*, void);
110 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
113 SmFontDialog(vcl::Window
* pParent
, OutputDevice
*pFntListDevice
, bool bHideCheckboxes
);
114 virtual ~SmFontDialog() override
;
115 virtual void dispose() override
;
117 const vcl::Font
& GetFont() const
121 void SetFont(const vcl::Font
&rFont
);
124 /**************************************************************************/
126 class SmFontSizeDialog
: public ModalDialog
128 VclPtr
<MetricField
> m_pBaseSize
;
129 VclPtr
<MetricField
> m_pTextSize
;
130 VclPtr
<MetricField
> m_pIndexSize
;
131 VclPtr
<MetricField
> m_pFunctionSize
;
132 VclPtr
<MetricField
> m_pOperatorSize
;
133 VclPtr
<MetricField
> m_pBorderSize
;
134 VclPtr
<PushButton
> m_pDefaultButton
;
136 DECL_LINK(DefaultButtonClickHdl
, Button
*, void);
139 SmFontSizeDialog(vcl::Window
*pParent
);
140 virtual ~SmFontSizeDialog() override
;
141 virtual void dispose() override
;
143 void ReadFrom(const SmFormat
&rFormat
);
144 void WriteTo (SmFormat
&rFormat
) const;
147 /**************************************************************************/
149 class SmFontTypeDialog
: public ModalDialog
151 VclPtr
<SmFontPickListBox
> m_pVariableFont
;
152 VclPtr
<SmFontPickListBox
> m_pFunctionFont
;
153 VclPtr
<SmFontPickListBox
> m_pNumberFont
;
154 VclPtr
<SmFontPickListBox
> m_pTextFont
;
155 VclPtr
<SmFontPickListBox
> m_pSerifFont
;
156 VclPtr
<SmFontPickListBox
> m_pSansFont
;
157 VclPtr
<SmFontPickListBox
> m_pFixedFont
;
158 VclPtr
<MenuButton
> m_pMenuButton
;
159 VclPtr
<PushButton
> m_pDefaultButton
;
161 VclPtr
<OutputDevice
> pFontListDev
;
163 DECL_LINK(MenuSelectHdl
, Menu
*, bool);
164 DECL_LINK(DefaultButtonClickHdl
, Button
*, void);
167 SmFontTypeDialog(vcl::Window
*pParent
, OutputDevice
*pFntListDevice
);
168 virtual ~SmFontTypeDialog() override
;
169 virtual void dispose() override
;
171 void ReadFrom(const SmFormat
&rFormat
);
172 void WriteTo (SmFormat
&rFormat
) const;
175 /**************************************************************************/
177 #define NOCATEGORIES 10
182 OUString
*Strings
[4];
183 Image
*Graphics
[4]; /* regular bitmaps */
184 sal_uInt16 Minimum
[4];
185 sal_uInt16 Maximum
[4];
189 SmCategoryDesc(VclBuilderContainer
& rBuilder
, sal_uInt16 nCategoryIdx
);
192 const OUString
& GetName() const { return Name
; }
193 const OUString
* GetString(sal_uInt16 Index
) const { return Strings
[Index
]; }
194 sal_uInt16
GetMinimum(sal_uInt16 Index
) { return Minimum
[Index
]; }
195 sal_uInt16
GetMaximum(sal_uInt16 Index
) { return Maximum
[Index
]; }
196 sal_uInt16
GetValue(sal_uInt16 Index
) const { return Value
[Index
]; }
197 void SetValue(sal_uInt16 Index
, sal_uInt16 nVal
) { Value
[Index
] = nVal
;}
199 const Image
* GetGraphic(sal_uInt16 Index
) const
201 return Graphics
[Index
];
206 class SmDistanceDialog
: public ModalDialog
208 VclPtr
<VclFrame
> m_pFrame
;
209 VclPtr
<FixedText
> m_pFixedText1
;
210 VclPtr
<MetricField
> m_pMetricField1
;
211 VclPtr
<FixedText
> m_pFixedText2
;
212 VclPtr
<MetricField
> m_pMetricField2
;
213 VclPtr
<FixedText
> m_pFixedText3
;
214 VclPtr
<MetricField
> m_pMetricField3
;
215 VclPtr
<CheckBox
> m_pCheckBox1
;
216 VclPtr
<FixedText
> m_pFixedText4
;
217 VclPtr
<MetricField
> m_pMetricField4
;
218 VclPtr
<MenuButton
> m_pMenuButton
;
219 VclPtr
<PushButton
> m_pDefaultButton
;
220 VclPtr
<FixedImage
> m_pBitmap
;
222 SmCategoryDesc
*Categories
[NOCATEGORIES
];
223 sal_uInt16 nActiveCategory
;
224 bool bScaleAllBrackets
;
226 DECL_LINK(GetFocusHdl
, Control
&, void);
227 DECL_LINK(MenuSelectHdl
, Menu
*, bool);
228 DECL_LINK(DefaultButtonClickHdl
, Button
*, void);
229 DECL_LINK(CheckBoxClickHdl
, Button
*, void);
231 using Window::SetHelpId
;
232 static void SetHelpId(MetricField
&rField
, const OString
& sHelpId
);
233 void SetCategory(sal_uInt16 Category
);
236 SmDistanceDialog(vcl::Window
*pParent
);
237 virtual ~SmDistanceDialog() override
;
238 virtual void dispose() override
;
240 void ReadFrom(const SmFormat
&rFormat
);
241 void WriteTo (SmFormat
&rFormat
);
245 /**************************************************************************/
248 class SmAlignDialog
: public ModalDialog
250 VclPtr
<RadioButton
> m_pLeft
;
251 VclPtr
<RadioButton
> m_pCenter
;
252 VclPtr
<RadioButton
> m_pRight
;
253 VclPtr
<PushButton
> m_pDefaultButton
;
255 DECL_LINK(DefaultButtonClickHdl
, Button
*, void);
258 SmAlignDialog(vcl::Window
*pParent
);
259 virtual ~SmAlignDialog() override
;
260 virtual void dispose() override
;
262 void ReadFrom(const SmFormat
&rFormat
);
263 void WriteTo (SmFormat
&rFormat
) const;
266 /**************************************************************************/
268 class SmShowSymbolSetWindow
: public Control
270 VclPtr
<ScrollBar
> m_pVScrollBar
;
271 SymbolPtrVec_t aSymbolSet
;
272 Link
<SmShowSymbolSetWindow
&,void> aSelectHdlLink
;
273 Link
<SmShowSymbolSetWindow
&,void> aDblClickHdlLink
;
275 long nRows
, nColumns
;
276 long nXOffset
, nYOffset
;
277 sal_uInt16 nSelectSymbol
;
279 void SetScrollBarRange();
280 Point
OffsetPoint(const Point
&rPoint
) const;
282 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
283 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
284 virtual void KeyInput(const KeyEvent
& rKEvt
) override
;
285 virtual void Resize() override
;
286 virtual Size
GetOptimalSize() const override
;
288 DECL_LINK( ScrollHdl
, ScrollBar
*, void );
290 SmShowSymbolSetWindow(vcl::Window
*pParent
, WinBits nStyle
);
291 virtual ~SmShowSymbolSetWindow() override
;
292 virtual void dispose() override
;
293 void setScrollbar(ScrollBar
*pVScrollBar
);
295 void SelectSymbol(sal_uInt16 nSymbol
);
296 sal_uInt16
GetSelectSymbol() const { return nSelectSymbol
; }
297 void SetSymbolSet(const SymbolPtrVec_t
& rSymbolSet
);
298 void SetSelectHdl(const Link
<SmShowSymbolSetWindow
&,void>& rLink
) { aSelectHdlLink
= rLink
; }
299 void SetDblClickHdl(const Link
<SmShowSymbolSetWindow
&,void>& rLink
) { aDblClickHdlLink
= rLink
; }
302 class SmShowSymbolSet
: public VclHBox
304 VclPtr
<SmShowSymbolSetWindow
> aSymbolWindow
;
305 VclPtr
<ScrollBar
> aVScrollBar
;
308 SmShowSymbolSet(vcl::Window
*pParent
);
309 virtual ~SmShowSymbolSet() override
;
310 virtual void dispose() override
;
312 void SetSymbolSet(const SymbolPtrVec_t
& rSymbolSet
) { aSymbolWindow
->SetSymbolSet(rSymbolSet
); }
314 void SelectSymbol(sal_uInt16 nSymbol
) { aSymbolWindow
->SelectSymbol(nSymbol
); }
315 sal_uInt16
GetSelectSymbol() const { return aSymbolWindow
->GetSelectSymbol(); }
317 void SetSelectHdl(const Link
<SmShowSymbolSetWindow
&,void>& rLink
) { aSymbolWindow
->SetSelectHdl(rLink
); }
318 void SetDblClickHdl(const Link
<SmShowSymbolSetWindow
&,void>& rLink
) { aSymbolWindow
->SetDblClickHdl(rLink
); }
322 class SmShowSymbol
: public Control
324 Link
<SmShowSymbol
&,void> aDblClickHdlLink
;
326 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
327 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
328 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
329 virtual void Resize() override
;
331 void setFontSize(vcl::Font
&rFont
) const;
334 SmShowSymbol(vcl::Window
*pParent
, WinBits nStyle
)
335 : Control(pParent
, nStyle
)
339 void SetSymbol(const SmSym
*pSymbol
);
340 void SetDblClickHdl(const Link
<SmShowSymbol
&,void> &rLink
) { aDblClickHdlLink
= rLink
; }
344 class SmSymbolDialog
: public ModalDialog
346 VclPtr
<ListBox
> m_pSymbolSets
;
347 VclPtr
<SmShowSymbolSet
> m_pSymbolSetDisplay
;
348 VclPtr
<FixedText
> m_pSymbolName
;
349 VclPtr
<SmShowSymbol
> m_pSymbolDisplay
;
350 VclPtr
<PushButton
> m_pGetBtn
;
351 VclPtr
<PushButton
> m_pEditBtn
;
353 SmViewShell
&rViewSh
;
354 SmSymbolManager
&rSymbolMgr
;
356 OUString aSymbolSetName
;
357 SymbolPtrVec_t aSymbolSet
;
359 VclPtr
<OutputDevice
> pFontListDev
;
361 DECL_LINK(SymbolSetChangeHdl
, ListBox
&, void);
362 DECL_LINK(SymbolChangeHdl
, SmShowSymbolSetWindow
&, void);
363 DECL_LINK(SymbolDblClickHdl
, SmShowSymbol
&, void);
364 DECL_LINK(SymbolDblClickHdl2
, SmShowSymbolSetWindow
&, void);
365 DECL_LINK(EditClickHdl
, Button
*, void);
366 DECL_LINK(GetClickHdl
, Button
*, void);
367 void SymbolDblClickHdl();
369 void FillSymbolSets();
370 const SmSym
*GetSymbol() const;
372 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
375 SmSymbolDialog(vcl::Window
* pParent
, OutputDevice
*pFntListDevice
,
376 SmSymbolManager
&rSymbolMgr
, SmViewShell
&rViewShell
);
377 virtual ~SmSymbolDialog() override
;
378 virtual void dispose() override
;
380 bool SelectSymbolSet(const OUString
&rSymbolSetName
);
381 void SelectSymbol(sal_uInt16 nSymbolPos
);
385 class SmShowChar
: public Control
387 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
388 virtual void Resize() override
;
391 SmShowChar(vcl::Window
*pParent
, WinBits nStyle
)
392 : Control(pParent
, nStyle
)
396 void SetSymbol( const SmSym
*pSym
);
397 void SetSymbol( sal_UCS4 cChar
, const vcl::Font
&rFont
);
401 class SmSymDefineDialog
: public ModalDialog
403 VclPtr
<ComboBox
> pOldSymbols
;
404 VclPtr
<ComboBox
> pOldSymbolSets
;
405 VclPtr
<SvxShowCharSet
> pCharsetDisplay
;
406 VclPtr
<ComboBox
> pSymbols
;
407 VclPtr
<ComboBox
> pSymbolSets
;
408 VclPtr
<ListBox
> pFonts
;
409 VclPtr
<ListBox
> pFontsSubsetLB
;
410 VclPtr
<FontStyleBox
> pStyles
;
411 VclPtr
<FixedText
> pOldSymbolName
;
412 VclPtr
<SmShowChar
> pOldSymbolDisplay
;
413 VclPtr
<FixedText
> pOldSymbolSetName
;
414 VclPtr
<FixedText
> pSymbolName
;
415 VclPtr
<SmShowChar
> pSymbolDisplay
;
416 VclPtr
<FixedText
> pSymbolSetName
;
417 VclPtr
<PushButton
> pAddBtn
;
418 VclPtr
<PushButton
> pChangeBtn
;
419 VclPtr
<PushButton
> pDeleteBtn
;
421 SmSymbolManager aSymbolMgrCopy
,
423 std::unique_ptr
<SmSym
> pOrigSymbol
;
425 std::unique_ptr
<SubsetMap
> pSubsetMap
;
428 DECL_LINK(OldSymbolChangeHdl
, ComboBox
&, void);
429 DECL_LINK(OldSymbolSetChangeHdl
, ComboBox
&, void);
430 DECL_LINK(ModifyHdl
, Edit
&, void);
431 DECL_LINK(FontChangeHdl
, ListBox
&, void);
432 DECL_LINK(SubsetChangeHdl
, ListBox
&, void);
433 DECL_LINK(StyleChangeHdl
, ComboBox
&, void);
434 DECL_LINK(CharHighlightHdl
, SvxShowCharSet
*, void);
435 DECL_LINK(AddClickHdl
, Button
*, void);
436 DECL_LINK(ChangeClickHdl
, Button
*, void);
437 DECL_LINK(DeleteClickHdl
, Button
*, void);
439 void FillSymbols(ComboBox
&rComboBox
, bool bDeleteText
= true);
440 void FillSymbolSets(ComboBox
&rComboBox
, bool bDeleteText
= true);
444 void SetSymbolSetManager(const SmSymbolManager
&rMgr
);
445 void SetFont(const OUString
&rFontName
, const OUString
&rStyleName
);
446 void SetOrigSymbol(const SmSym
*pSymbol
, const OUString
&rSymbolSetName
);
447 void UpdateButtons();
449 bool SelectSymbolSet(ComboBox
&rComboBox
, const OUString
&rSymbolSetName
,
451 bool SelectSymbol(ComboBox
&rComboBox
, const OUString
&rSymbolName
,
453 bool SelectFont(const OUString
&rFontName
, bool bApplyFont
);
454 bool SelectStyle(const OUString
&rStyleName
, bool bApplyFont
);
456 SmSym
* GetSymbol(const ComboBox
&rComboBox
);
457 const SmSym
* GetSymbol(const ComboBox
&rComboBox
) const
459 return const_cast<SmSymDefineDialog
*>(this)->GetSymbol(rComboBox
);
462 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
465 SmSymDefineDialog(vcl::Window
*pParent
, OutputDevice
*pFntListDevice
, SmSymbolManager
&rMgr
);
466 virtual ~SmSymDefineDialog() override
;
467 virtual void dispose() override
;
469 using OutputDevice::SetFont
;
472 virtual short Execute() override
;
474 void SelectOldSymbolSet(const OUString
&rSymbolSetName
)
476 SelectSymbolSet(*pOldSymbolSets
, rSymbolSetName
, false);
479 void SelectOldSymbol(const OUString
&rSymbolName
)
481 SelectSymbol(*pOldSymbols
, rSymbolName
, false);
484 bool SelectSymbolSet(const OUString
&rSymbolSetName
)
486 return SelectSymbolSet(*pSymbolSets
, rSymbolSetName
, false);
489 bool SelectSymbol(const OUString
&rSymbolName
)
491 return SelectSymbol(*pSymbols
, rSymbolName
, false);
494 bool SelectFont(const OUString
&rFontName
) { return SelectFont(rFontName
, true); }
495 bool SelectStyle(const OUString
&rStyleName
) { return SelectStyle(rStyleName
, true); };
496 void SelectChar(sal_Unicode cChar
);
502 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */