bump product version to 5.0.4.1
[LibreOffice.git] / starmath / inc / dialog.hxx
blobaaf4c0f0e3a12c42d061def47122b95dfed7d0e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
40 #include "format.hxx"
41 #include "symbol.hxx"
42 #include <memory>
44 class SubsetMap;
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;
65 DECL_LINK(SizeButtonClickHdl, Button *);
67 virtual bool FillItemSet(SfxItemSet* rSet) SAL_OVERRIDE;
68 virtual void Reset(const SfxItemSet* rSet) SAL_OVERRIDE;
70 public:
71 static VclPtr<SfxTabPage> Create(vcl::Window *pWindow, const SfxItemSet &rSet);
73 SmPrintOptionsTabPage(vcl::Window *pParent, const SfxItemSet &rOptions);
74 virtual ~SmPrintOptionsTabPage();
75 virtual void dispose() SAL_OVERRIDE;
78 /**************************************************************************/
80 class SmShowFont : public vcl::Window
82 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
84 vcl::Font maFont;
86 public:
87 SmShowFont(vcl::Window *pParent, WinBits nStyle)
88 : Window(pParent, nStyle)
91 virtual Size GetOptimalSize() const SAL_OVERRIDE;
92 void SetFont(const vcl::Font& rFont);
95 class SmFontDialog : public ModalDialog
97 VclPtr<ComboBox> m_pFontBox;
98 VclPtr<VclContainer> m_pAttrFrame;
99 VclPtr<CheckBox> m_pBoldCheckBox;
100 VclPtr<CheckBox> m_pItalicCheckBox;
101 VclPtr<SmShowFont> m_pShowFont;
103 vcl::Font maFont;
105 DECL_LINK(FontSelectHdl, ComboBox *);
106 DECL_LINK(FontModifyHdl, ComboBox *);
107 DECL_LINK(AttrChangeHdl, CheckBox *);
109 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
111 public:
112 SmFontDialog(vcl::Window * pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
113 virtual ~SmFontDialog();
114 virtual void dispose() SAL_OVERRIDE;
116 const vcl::Font& GetFont() const
118 return maFont;
120 void SetFont(const vcl::Font &rFont);
123 /**************************************************************************/
125 class SmFontSizeDialog : public ModalDialog
127 VclPtr<MetricField> m_pBaseSize;
128 VclPtr<MetricField> m_pTextSize;
129 VclPtr<MetricField> m_pIndexSize;
130 VclPtr<MetricField> m_pFunctionSize;
131 VclPtr<MetricField> m_pOperatorSize;
132 VclPtr<MetricField> m_pBorderSize;
133 VclPtr<PushButton> m_pDefaultButton;
135 DECL_LINK(DefaultButtonClickHdl, Button *);
137 public:
138 SmFontSizeDialog(vcl::Window *pParent);
139 virtual ~SmFontSizeDialog();
140 virtual void dispose() SAL_OVERRIDE;
142 void ReadFrom(const SmFormat &rFormat);
143 void WriteTo (SmFormat &rFormat) const;
146 /**************************************************************************/
148 class SmFontTypeDialog : public ModalDialog
150 VclPtr<SmFontPickListBox> m_pVariableFont;
151 VclPtr<SmFontPickListBox> m_pFunctionFont;
152 VclPtr<SmFontPickListBox> m_pNumberFont;
153 VclPtr<SmFontPickListBox> m_pTextFont;
154 VclPtr<SmFontPickListBox> m_pSerifFont;
155 VclPtr<SmFontPickListBox> m_pSansFont;
156 VclPtr<SmFontPickListBox> m_pFixedFont;
157 VclPtr<MenuButton> m_pMenuButton;
158 VclPtr<PushButton> m_pDefaultButton;
160 VclPtr<OutputDevice> pFontListDev;
162 DECL_LINK(MenuSelectHdl, Menu *);
163 DECL_LINK(DefaultButtonClickHdl, Button *);
164 DECL_LINK(HelpButtonClickHdl, Button *);
166 public:
167 SmFontTypeDialog(vcl::Window *pParent, OutputDevice *pFntListDevice);
168 virtual ~SmFontTypeDialog();
169 virtual void dispose() SAL_OVERRIDE;
171 void ReadFrom(const SmFormat &rFormat);
172 void WriteTo (SmFormat &rFormat) const;
175 /**************************************************************************/
177 #define NOCATEGORIES 10
179 class SmCategoryDesc
181 OUString Name;
182 OUString *Strings[4];
183 Image *Graphics[4]; /* regular bitmaps */
184 sal_uInt16 Minimum[4];
185 sal_uInt16 Maximum[4];
186 sal_uInt16 Value[4];
188 public:
189 SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx);
190 ~SmCategoryDesc();
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 *);
227 DECL_LINK(MenuSelectHdl, Menu *);
228 DECL_LINK(DefaultButtonClickHdl, Button *);
229 DECL_LINK(CheckBoxClickHdl, CheckBox *);
231 using Window::SetHelpId;
232 static void SetHelpId(MetricField &rField, const OString& sHelpId);
233 void SetCategory(sal_uInt16 Category);
235 public:
236 SmDistanceDialog(vcl::Window *pParent);
237 virtual ~SmDistanceDialog();
238 virtual void dispose() SAL_OVERRIDE;
240 void ReadFrom(const SmFormat &rFormat);
241 void WriteTo (SmFormat &rFormat) /*const*/;
243 // Window
244 virtual void DataChanged( const DataChangedEvent &rEvt ) SAL_OVERRIDE;
248 /**************************************************************************/
251 class SmAlignDialog : public ModalDialog
253 VclPtr<RadioButton> m_pLeft;
254 VclPtr<RadioButton> m_pCenter;
255 VclPtr<RadioButton> m_pRight;
256 VclPtr<PushButton> m_pDefaultButton;
258 DECL_LINK(DefaultButtonClickHdl, Button *);
260 public:
261 SmAlignDialog(vcl::Window *pParent);
262 virtual ~SmAlignDialog();
263 virtual void dispose() SAL_OVERRIDE;
265 void ReadFrom(const SmFormat &rFormat);
266 void WriteTo (SmFormat &rFormat) const;
269 /**************************************************************************/
271 class SmShowSymbolSetWindow : public Control
273 VclPtr<ScrollBar> m_pVScrollBar;
274 SymbolPtrVec_t aSymbolSet;
275 Link<> aSelectHdlLink;
276 Link<> aDblClickHdlLink;
277 long nLen;
278 long nRows, nColumns;
279 long nXOffset, nYOffset;
280 sal_uInt16 nSelectSymbol;
282 void SetScrollBarRange();
283 Point OffsetPoint(const Point &rPoint) const;
285 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
286 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
287 virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
288 virtual void Resize() SAL_OVERRIDE;
289 virtual Size GetOptimalSize() const SAL_OVERRIDE;
291 DECL_LINK( ScrollHdl, ScrollBar* );
292 public:
293 SmShowSymbolSetWindow(vcl::Window *pParent, WinBits nStyle);
294 virtual ~SmShowSymbolSetWindow();
295 virtual void dispose() SAL_OVERRIDE;
296 void setScrollbar(ScrollBar *pVScrollBar);
297 void calccols();
298 void SelectSymbol(sal_uInt16 nSymbol);
299 sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; }
300 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
301 void SetSelectHdl(const Link<>& rLink) { aSelectHdlLink = rLink; }
302 void SetDblClickHdl(const Link<>& rLink) { aDblClickHdlLink = rLink; }
305 class SmShowSymbolSet : public VclHBox
307 VclPtr<SmShowSymbolSetWindow> aSymbolWindow;
308 VclPtr<ScrollBar> aVScrollBar;
310 public:
311 SmShowSymbolSet(vcl::Window *pParent);
312 virtual ~SmShowSymbolSet();
313 virtual void dispose() SAL_OVERRIDE;
315 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) { aSymbolWindow->SetSymbolSet(rSymbolSet); }
317 void SelectSymbol(sal_uInt16 nSymbol) { aSymbolWindow->SelectSymbol(nSymbol); }
318 sal_uInt16 GetSelectSymbol() const { return aSymbolWindow->GetSelectSymbol(); }
320 void SetSelectHdl(const Link<>& rLink) { aSymbolWindow->SetSelectHdl(rLink); }
321 void SetDblClickHdl(const Link<>& rLink) { aSymbolWindow->SetDblClickHdl(rLink); }
326 class SmShowSymbol : public Control
328 Link<> aDblClickHdlLink;
330 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
331 virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
332 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
333 virtual void Resize() SAL_OVERRIDE;
335 void setFontSize(vcl::Font &rFont) const;
337 public:
338 SmShowSymbol(vcl::Window *pParent, WinBits nStyle)
339 : Control(pParent, nStyle)
343 void SetSymbol(const SmSym *pSymbol);
344 void SetDblClickHdl(const Link<> &rLink) { aDblClickHdlLink = rLink; }
349 class SmSymDefineDialog;
351 class SmSymbolDialog : public ModalDialog
353 VclPtr<ListBox> m_pSymbolSets;
354 VclPtr<SmShowSymbolSet> m_pSymbolSetDisplay;
355 VclPtr<FixedText> m_pSymbolName;
356 VclPtr<SmShowSymbol> m_pSymbolDisplay;
357 VclPtr<PushButton> m_pGetBtn;
358 VclPtr<PushButton> m_pEditBtn;
360 SmViewShell &rViewSh;
361 SmSymbolManager &rSymbolMgr;
363 OUString aSymbolSetName;
364 SymbolPtrVec_t aSymbolSet;
366 VclPtr<OutputDevice> pFontListDev;
368 DECL_LINK(SymbolSetChangeHdl, void*);
369 DECL_LINK(SymbolChangeHdl, void*);
370 DECL_LINK(SymbolDblClickHdl, void*);
371 DECL_LINK(EditClickHdl, void*);
372 DECL_LINK(GetClickHdl, void*);
374 void FillSymbolSets(bool bDeleteText = true);
375 void SetSymbolSetManager(SmSymbolManager &rMgr);
376 const SmSym *GetSymbol() const;
378 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
380 public:
381 SmSymbolDialog(vcl::Window * pParent, OutputDevice *pFntListDevice,
382 SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
383 virtual ~SmSymbolDialog();
384 virtual void dispose() SAL_OVERRIDE;
386 bool SelectSymbolSet(const OUString &rSymbolSetName);
387 void SelectSymbol(sal_uInt16 nSymbolPos);
388 sal_uInt16 GetSelectedSymbol() const { return m_pSymbolSetDisplay->GetSelectSymbol(); }
393 class SmShowChar : public Control
395 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
396 virtual void Resize() SAL_OVERRIDE;
398 public:
399 SmShowChar(vcl::Window *pParent, WinBits nStyle)
400 : Control(pParent, nStyle)
404 void SetSymbol( const SmSym *pSym );
405 void SetSymbol( sal_UCS4 cChar, const vcl::Font &rFont );
410 class SmSymDefineDialog : public ModalDialog
412 VclPtr<ComboBox> pOldSymbols;
413 VclPtr<ComboBox> pOldSymbolSets;
414 VclPtr<SvxShowCharSet> pCharsetDisplay;
415 VclPtr<ComboBox> pSymbols;
416 VclPtr<ComboBox> pSymbolSets;
417 VclPtr<ListBox> pFonts;
418 VclPtr<ListBox> pFontsSubsetLB;
419 VclPtr<FontStyleBox> pStyles;
420 VclPtr<FixedText> pOldSymbolName;
421 VclPtr<SmShowChar> pOldSymbolDisplay;
422 VclPtr<FixedText> pOldSymbolSetName;
423 VclPtr<FixedText> pSymbolName;
424 VclPtr<SmShowChar> pSymbolDisplay;
425 VclPtr<FixedText> pSymbolSetName;
426 VclPtr<PushButton> pAddBtn;
427 VclPtr<PushButton> pChangeBtn;
428 VclPtr<PushButton> pDeleteBtn;
430 SmSymbolManager aSymbolMgrCopy,
431 &rSymbolMgr;
432 std::unique_ptr<SmSym> pOrigSymbol;
434 std::unique_ptr<SubsetMap> pSubsetMap;
435 FontList *pFontList;
437 DECL_LINK(OldSymbolChangeHdl, ComboBox *);
438 DECL_LINK(OldSymbolSetChangeHdl, ComboBox *);
439 DECL_LINK(ModifyHdl, ComboBox *);
440 DECL_LINK(FontChangeHdl, ListBox *);
441 DECL_LINK(SubsetChangeHdl, ListBox*);
442 DECL_LINK(StyleChangeHdl, ComboBox *);
443 DECL_LINK(CharHighlightHdl, void *);
444 DECL_LINK(AddClickHdl, Button *);
445 DECL_LINK(ChangeClickHdl, Button *);
446 DECL_LINK(DeleteClickHdl, Button *);
448 void FillSymbols(ComboBox &rComboBox, bool bDeleteText = true);
449 void FillSymbolSets(ComboBox &rComboBox, bool bDeleteText = true);
450 void FillFonts(bool bDeleteText = true);
451 void FillStyles(bool bDeleteText = true);
453 void SetSymbolSetManager(const SmSymbolManager &rMgr);
454 void SetFont(const OUString &rFontName, const OUString &rStyleName);
455 void SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
456 void UpdateButtons();
458 bool SelectSymbolSet(ComboBox &rComboBox, const OUString &rSymbolSetName,
459 bool bDeleteText);
460 bool SelectSymbol(ComboBox &rComboBox, const OUString &rSymbolName,
461 bool bDeleteText);
462 bool SelectFont(const OUString &rFontName, bool bApplyFont);
463 bool SelectStyle(const OUString &rStyleName, bool bApplyFont);
465 SmSym * GetSymbol(const ComboBox &rComboBox);
466 const SmSym * GetSymbol(const ComboBox &rComboBox) const
468 return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
471 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
473 public:
474 SmSymDefineDialog(vcl::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
475 virtual ~SmSymDefineDialog();
476 virtual void dispose() SAL_OVERRIDE;
478 using OutputDevice::SetFont;
480 // Dialog
481 virtual short Execute() SAL_OVERRIDE;
483 bool SelectOldSymbolSet(const OUString &rSymbolSetName)
485 return SelectSymbolSet(*pOldSymbolSets, rSymbolSetName, false);
488 bool SelectOldSymbol(const OUString &rSymbolName)
490 return SelectSymbol(*pOldSymbols, rSymbolName, false);
493 bool SelectSymbolSet(const OUString &rSymbolSetName)
495 return SelectSymbolSet(*pSymbolSets, rSymbolSetName, false);
498 bool SelectSymbol(const OUString &rSymbolName)
500 return SelectSymbol(*pSymbols, rSymbolName, false);
503 bool SelectFont(const OUString &rFontName) { return SelectFont(rFontName, true); }
504 bool SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
505 void SelectChar(sal_Unicode cChar);
510 #endif
512 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */