Bump version to 21.06.18.1
[LibreOffice.git] / starmath / inc / dialog.hxx
blobcb3fcc67706901acdcfc37593639e0c1487aa82b
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 <sfx2/tabdlg.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/customweld.hxx>
25 #include "symbol.hxx"
26 #include <memory>
28 class SubsetMap;
29 class SmFormat;
30 class FontList;
31 class SvxShowCharSet;
33 #define CATEGORY_NONE 0xFFFF
35 /**************************************************************************/
37 void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont);
39 /**************************************************************************/
41 class SmPrintOptionsTabPage final : public SfxTabPage
43 std::unique_ptr<weld::CheckButton> m_xTitle;
44 std::unique_ptr<weld::CheckButton> m_xText;
45 std::unique_ptr<weld::CheckButton> m_xFrame;
46 std::unique_ptr<weld::RadioButton> m_xSizeNormal;
47 std::unique_ptr<weld::RadioButton> m_xSizeScaled;
48 std::unique_ptr<weld::RadioButton> m_xSizeZoomed;
49 std::unique_ptr<weld::MetricSpinButton> m_xZoom;
50 std::unique_ptr<weld::CheckButton> m_xNoRightSpaces;
51 std::unique_ptr<weld::CheckButton> m_xSaveOnlyUsedSymbols;
52 std::unique_ptr<weld::CheckButton> m_xAutoCloseBrackets;
54 DECL_LINK(SizeButtonClickHdl, weld::ToggleButton&, void);
56 virtual bool FillItemSet(SfxItemSet* rSet) override;
57 virtual void Reset(const SfxItemSet* rSet) override;
59 public:
60 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
62 SmPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions);
63 virtual ~SmPrintOptionsTabPage() override;
66 /**************************************************************************/
68 class SmShowFont final : public weld::CustomWidgetController
70 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
72 vcl::Font maFont;
74 public:
75 SmShowFont()
78 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
79 void SetFont(const vcl::Font& rFont);
82 class SmFontDialog : public weld::GenericDialogController
84 vcl::Font maFont;
85 SmShowFont m_aShowFont;
86 std::unique_ptr<weld::EntryTreeView> m_xFontBox;
87 std::unique_ptr<weld::Widget> m_xAttrFrame;
88 std::unique_ptr<weld::CheckButton> m_xBoldCheckBox;
89 std::unique_ptr<weld::CheckButton> m_xItalicCheckBox;
90 std::unique_ptr<weld::CustomWeld> m_xShowFont;
92 DECL_LINK(FontSelectHdl, weld::ComboBox&, void);
93 DECL_LINK(AttrChangeHdl, weld::ToggleButton&, void);
95 public:
96 SmFontDialog(weld::Window* pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
97 virtual ~SmFontDialog() override;
99 const vcl::Font& GetFont() const
101 return maFont;
103 void SetFont(const vcl::Font &rFont);
106 /**************************************************************************/
108 class SmFontSizeDialog final : public weld::GenericDialogController
110 std::unique_ptr<weld::MetricSpinButton> m_xBaseSize;
111 std::unique_ptr<weld::MetricSpinButton> m_xTextSize;
112 std::unique_ptr<weld::MetricSpinButton> m_xIndexSize;
113 std::unique_ptr<weld::MetricSpinButton> m_xFunctionSize;
114 std::unique_ptr<weld::MetricSpinButton> m_xOperatorSize;
115 std::unique_ptr<weld::MetricSpinButton> m_xBorderSize;
116 std::unique_ptr<weld::Button> m_xDefaultButton;
118 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
120 public:
121 SmFontSizeDialog(weld::Window *pParent);
122 virtual ~SmFontSizeDialog() override;
124 void ReadFrom(const SmFormat &rFormat);
125 void WriteTo (SmFormat &rFormat) const;
128 /**************************************************************************/
130 class SmFontTypeDialog final : public weld::GenericDialogController
132 VclPtr<OutputDevice> pFontListDev;
134 std::unique_ptr<SmFontPickListBox> m_xVariableFont;
135 std::unique_ptr<SmFontPickListBox> m_xFunctionFont;
136 std::unique_ptr<SmFontPickListBox> m_xNumberFont;
137 std::unique_ptr<SmFontPickListBox> m_xTextFont;
138 std::unique_ptr<SmFontPickListBox> m_xSerifFont;
139 std::unique_ptr<SmFontPickListBox> m_xSansFont;
140 std::unique_ptr<SmFontPickListBox> m_xFixedFont;
141 std::unique_ptr<weld::MenuButton> m_xMenuButton;
142 std::unique_ptr<weld::Button> m_xDefaultButton;
144 DECL_LINK(MenuSelectHdl, const OString&, void);
145 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
147 public:
148 SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice);
149 virtual ~SmFontTypeDialog() override;
151 void ReadFrom(const SmFormat &rFormat);
152 void WriteTo (SmFormat &rFormat) const;
155 /**************************************************************************/
157 #define NOCATEGORIES 10
159 class SmCategoryDesc
161 OUString Name;
162 OUString Strings[4];
163 std::unique_ptr<weld::Widget> Graphics[4]; /* regular bitmaps */
164 sal_uInt16 Minimum[4];
165 sal_uInt16 Maximum[4];
166 sal_uInt16 Value[4];
168 public:
169 SmCategoryDesc(weld::Builder& rBuilder, sal_uInt16 nCategoryIdx);
170 ~SmCategoryDesc();
172 const OUString& GetName() const { return Name; }
173 const OUString& GetString(sal_uInt16 Index) const { return Strings[Index]; }
174 sal_uInt16 GetMinimum(sal_uInt16 Index) { return Minimum[Index]; }
175 sal_uInt16 GetMaximum(sal_uInt16 Index) { return Maximum[Index]; }
176 sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; }
177 void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
179 weld::Widget* GetGraphic(sal_uInt16 Index) const
181 return Graphics[Index].get();
185 class SmDistanceDialog final : public weld::GenericDialogController
187 std::unique_ptr<weld::Frame> m_xFrame;
188 std::unique_ptr<weld::Label> m_xFixedText1;
189 std::unique_ptr<weld::MetricSpinButton> m_xMetricField1;
190 std::unique_ptr<weld::Label> m_xFixedText2;
191 std::unique_ptr<weld::MetricSpinButton> m_xMetricField2;
192 std::unique_ptr<weld::Label> m_xFixedText3;
193 std::unique_ptr<weld::MetricSpinButton> m_xMetricField3;
194 std::unique_ptr<weld::CheckButton> m_xCheckBox1;
195 std::unique_ptr<weld::Label> m_xFixedText4;
196 std::unique_ptr<weld::MetricSpinButton> m_xMetricField4;
197 std::unique_ptr<weld::MenuButton> m_xMenuButton;
198 std::unique_ptr<weld::Button> m_xDefaultButton;
199 std::unique_ptr<weld::Widget> m_xBitmap;
201 weld::Widget* m_pCurrentImage;
203 std::unique_ptr<SmCategoryDesc> m_xCategories[NOCATEGORIES];
204 sal_uInt16 nActiveCategory;
205 bool bScaleAllBrackets;
207 DECL_LINK(GetFocusHdl, weld::Widget&, void);
208 DECL_LINK(MenuSelectHdl, const OString&, void);
209 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
210 DECL_LINK(CheckBoxClickHdl, weld::ToggleButton&, void);
212 void SetCategory(sal_uInt16 Category);
214 public:
215 SmDistanceDialog(weld::Window *pParent);
216 virtual ~SmDistanceDialog() override;
218 void ReadFrom(const SmFormat &rFormat);
219 void WriteTo (SmFormat &rFormat);
222 /**************************************************************************/
225 class SmAlignDialog final : public weld::GenericDialogController
227 std::unique_ptr<weld::RadioButton> m_xLeft;
228 std::unique_ptr<weld::RadioButton> m_xCenter;
229 std::unique_ptr<weld::RadioButton> m_xRight;
230 std::unique_ptr<weld::Button> m_xDefaultButton;
232 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
234 public:
235 SmAlignDialog(weld::Window *pParent);
236 virtual ~SmAlignDialog() override;
238 void ReadFrom(const SmFormat &rFormat);
239 void WriteTo (SmFormat &rFormat) const;
242 /**************************************************************************/
244 class SmShowSymbolSet final : public weld::CustomWidgetController
246 Size m_aOldSize;
247 SymbolPtrVec_t aSymbolSet;
248 Link<SmShowSymbolSet&,void> aSelectHdlLink;
249 Link<SmShowSymbolSet&,void> aDblClickHdlLink;
250 tools::Long nLen;
251 sal_Int32 nRows, nColumns;
252 tools::Long nXOffset, nYOffset;
253 sal_uInt16 nSelectSymbol;
254 std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
256 void SetScrollBarRange();
257 Point OffsetPoint(const Point &rPoint) const;
259 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
260 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
261 virtual bool KeyInput(const KeyEvent& rKEvt) override;
262 virtual void Resize() override;
264 DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
266 public:
267 SmShowSymbolSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow);
269 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
271 CustomWidgetController::SetDrawingArea(pDrawingArea);
272 m_aOldSize = Size(pDrawingArea->get_approximate_digit_width() * 27,
273 pDrawingArea->get_text_height() * 9);
274 pDrawingArea->set_size_request(m_aOldSize.Width(), m_aOldSize.Height());
275 SetOutputSizePixel(m_aOldSize);
276 calccols(pDrawingArea->get_ref_device());
279 void calccols(const vcl::RenderContext& rRenderContext);
280 void SelectSymbol(sal_uInt16 nSymbol);
281 sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; }
282 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
283 void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; }
284 void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; }
287 class SmShowSymbol final : public weld::CustomWidgetController
289 private:
290 vcl::Font m_aFont;
291 OUString m_aText;
293 Link<SmShowSymbol&,void> aDblClickHdlLink;
295 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
296 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
298 void setFontSize(vcl::Font &rFont) const;
300 public:
301 SmShowSymbol();
303 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
305 CustomWidgetController::SetDrawingArea(pDrawingArea);
306 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
307 pDrawingArea->get_text_height() * 9);
310 void SetText(const OUString& rText) { m_aText = rText; }
311 const OUString& GetText() const { return m_aText; }
313 void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
314 const vcl::Font& GetFont() const { return m_aFont; }
316 void SetSymbol(const SmSym *pSymbol);
317 void SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; }
320 class SmSymbolDialog final : public weld::GenericDialogController
322 SmViewShell &rViewSh;
323 SmSymbolManager &rSymbolMgr;
325 OUString aSymbolSetName;
326 SymbolPtrVec_t aSymbolSet;
328 VclPtr<OutputDevice> pFontListDev;
330 SmShowSymbol m_aSymbolDisplay;
332 std::unique_ptr<weld::ComboBox> m_xSymbolSets;
333 std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay;
334 std::unique_ptr<weld::CustomWeld> m_xSymbolSetDisplayArea;
335 std::unique_ptr<weld::Label> m_xSymbolName;
336 std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
337 std::unique_ptr<weld::Button> m_xGetBtn;
338 std::unique_ptr<weld::Button> m_xEditBtn;
340 DECL_LINK(SymbolSetChangeHdl, weld::ComboBox&, void);
341 DECL_LINK(SymbolChangeHdl, SmShowSymbolSet&, void);
342 DECL_LINK(SymbolDblClickHdl, SmShowSymbol&, void);
343 DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSet&, void);
344 DECL_LINK(EditClickHdl, weld::Button&, void);
345 DECL_LINK(GetClickHdl, weld::Button&, void);
346 void SymbolDblClickHdl();
348 void FillSymbolSets();
349 const SmSym *GetSymbol() const;
351 public:
352 SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice,
353 SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
354 virtual ~SmSymbolDialog() override;
356 bool SelectSymbolSet(const OUString &rSymbolSetName);
357 void SelectSymbol(sal_uInt16 nSymbolPos);
360 class SmShowChar final : public weld::CustomWidgetController
362 private:
363 OUString m_aText;
364 vcl::Font m_aFont;
366 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
367 virtual void Resize() override;
369 public:
370 SmShowChar()
374 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
376 CustomWidgetController::SetDrawingArea(pDrawingArea);
377 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7,
378 pDrawingArea->get_text_height() * 3);
381 void SetSymbol(const SmSym *pSym);
382 void SetSymbol(sal_UCS4 cChar, const vcl::Font &rFont);
383 void SetText(const OUString& rText) { m_aText = rText; }
384 const OUString& GetText() const { return m_aText; }
385 void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
386 const vcl::Font& GetFont() const { return m_aFont; }
389 class SmSymDefineDialog final : public weld::GenericDialogController
391 VclPtr<VirtualDevice> m_xVirDev;
392 SmSymbolManager m_aSymbolMgrCopy;
393 SmSymbolManager& m_rSymbolMgr;
394 SmShowChar m_aOldSymbolDisplay;
395 SmShowChar m_aSymbolDisplay;
396 std::unique_ptr<SmSym> m_xOrigSymbol;
397 std::unique_ptr<SubsetMap> m_xSubsetMap;
398 std::unique_ptr<FontList> m_xFontList;
399 std::unique_ptr<weld::ComboBox> m_xOldSymbols;
400 std::unique_ptr<weld::ComboBox> m_xOldSymbolSets;
401 std::unique_ptr<weld::ComboBox> m_xSymbols;
402 std::unique_ptr<weld::ComboBox> m_xSymbolSets;
403 std::unique_ptr<weld::ComboBox> m_xFonts;
404 std::unique_ptr<weld::ComboBox> m_xFontsSubsetLB;
405 std::unique_ptr<weld::ComboBox> m_xStyles;
406 std::unique_ptr<weld::Label> m_xOldSymbolName;
407 std::unique_ptr<weld::Label> m_xOldSymbolSetName;
408 std::unique_ptr<weld::Label> m_xSymbolName;
409 std::unique_ptr<weld::Label> m_xSymbolSetName;
410 std::unique_ptr<weld::Button> m_xAddBtn;
411 std::unique_ptr<weld::Button> m_xChangeBtn;
412 std::unique_ptr<weld::Button> m_xDeleteBtn;
413 std::unique_ptr<weld::CustomWeld> m_xOldSymbolDisplay;
414 std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
415 std::unique_ptr<SvxShowCharSet> m_xCharsetDisplay;
416 std::unique_ptr<weld::CustomWeld> m_xCharsetDisplayArea;
418 DECL_LINK(OldSymbolChangeHdl, weld::ComboBox&, void);
419 DECL_LINK(OldSymbolSetChangeHdl, weld::ComboBox&, void);
420 DECL_LINK(ModifyHdl, weld::ComboBox&, void);
421 DECL_LINK(FontChangeHdl, weld::ComboBox&, void);
422 DECL_LINK(SubsetChangeHdl, weld::ComboBox&, void);
423 DECL_LINK(StyleChangeHdl, weld::ComboBox&, void);
424 DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
425 DECL_LINK(AddClickHdl, weld::Button&, void);
426 DECL_LINK(ChangeClickHdl, weld::Button&, void);
427 DECL_LINK(DeleteClickHdl, weld::Button&, void);
429 void FillSymbols(weld::ComboBox& rComboBox, bool bDeleteText = true);
430 void FillSymbolSets(weld::ComboBox& rComboBox, bool bDeleteText = true);
431 void FillFonts();
432 void FillStyles();
434 void SetSymbolSetManager(const SmSymbolManager &rMgr);
435 void SetFont(const OUString &rFontName, const OUString &rStyleName);
436 void SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
437 void UpdateButtons();
439 bool SelectSymbolSet(weld::ComboBox &rComboBox, const OUString &rSymbolSetName,
440 bool bDeleteText);
441 bool SelectSymbol(weld::ComboBox& rComboBox, const OUString &rSymbolName,
442 bool bDeleteText);
443 bool SelectFont(const OUString &rFontName, bool bApplyFont);
444 bool SelectStyle(const OUString &rStyleName, bool bApplyFont);
446 SmSym* GetSymbol(const weld::ComboBox& rComboBox);
447 const SmSym* GetSymbol(const weld::ComboBox& rComboBox) const
449 return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
452 public:
453 SmSymDefineDialog(weld::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
454 virtual ~SmSymDefineDialog() override;
456 virtual short run() override;
458 void SelectOldSymbolSet(const OUString &rSymbolSetName)
460 SelectSymbolSet(*m_xOldSymbolSets, rSymbolSetName, false);
463 void SelectOldSymbol(const OUString &rSymbolName)
465 SelectSymbol(*m_xOldSymbols, rSymbolName, false);
468 bool SelectSymbolSet(const OUString &rSymbolSetName)
470 return SelectSymbolSet(*m_xSymbolSets, rSymbolSetName, false);
473 bool SelectSymbol(const OUString &rSymbolName)
475 return SelectSymbol(*m_xSymbols, rSymbolName, false);
478 bool SelectFont(const OUString &rFontName) { return SelectFont(rFontName, true); }
479 bool SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
480 void SelectChar(sal_Unicode cChar);
484 #endif
486 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */