Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / starmath / inc / dialog.hxx
blob81f043c59fde3dd0b06e81169a5342eeebdd5259
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 std::unique_ptr<weld::CheckButton> m_xTitle;
56 std::unique_ptr<weld::CheckButton> m_xText;
57 std::unique_ptr<weld::CheckButton> m_xFrame;
58 std::unique_ptr<weld::RadioButton> m_xSizeNormal;
59 std::unique_ptr<weld::RadioButton> m_xSizeScaled;
60 std::unique_ptr<weld::RadioButton> m_xSizeZoomed;
61 std::unique_ptr<weld::MetricSpinButton> m_xZoom;
62 std::unique_ptr<weld::CheckButton> m_xNoRightSpaces;
63 std::unique_ptr<weld::CheckButton> m_xSaveOnlyUsedSymbols;
64 std::unique_ptr<weld::CheckButton> m_xAutoCloseBrackets;
66 DECL_LINK(SizeButtonClickHdl, weld::ToggleButton&, void);
68 virtual bool FillItemSet(SfxItemSet* rSet) override;
69 virtual void Reset(const SfxItemSet* rSet) override;
71 public:
72 static VclPtr<SfxTabPage> Create(TabPageParent pWindow, const SfxItemSet &rSet);
74 SmPrintOptionsTabPage(TabPageParent pPage, const SfxItemSet &rOptions);
75 virtual ~SmPrintOptionsTabPage() override;
78 /**************************************************************************/
80 class SmShowFont : public vcl::Window
82 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
84 vcl::Font maFont;
86 public:
87 SmShowFont(vcl::Window *pParent, WinBits nStyle)
88 : Window(pParent, nStyle)
91 virtual Size GetOptimalSize() const 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&, void);
106 DECL_LINK(FontModifyHdl, Edit&, void);
107 DECL_LINK(AttrChangeHdl, Button *, void);
109 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
111 public:
112 SmFontDialog(vcl::Window * pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
113 virtual ~SmFontDialog() override;
114 virtual void dispose() override;
116 const vcl::Font& GetFont() const
118 return maFont;
120 void SetFont(const vcl::Font &rFont);
123 /**************************************************************************/
125 class SmFontSizeDialog : public weld::GenericDialogController
127 std::unique_ptr<weld::MetricSpinButton> m_xBaseSize;
128 std::unique_ptr<weld::MetricSpinButton> m_xTextSize;
129 std::unique_ptr<weld::MetricSpinButton> m_xIndexSize;
130 std::unique_ptr<weld::MetricSpinButton> m_xFunctionSize;
131 std::unique_ptr<weld::MetricSpinButton> m_xOperatorSize;
132 std::unique_ptr<weld::MetricSpinButton> m_xBorderSize;
133 std::unique_ptr<weld::Button> m_xDefaultButton;
135 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
137 public:
138 SmFontSizeDialog(weld::Window *pParent);
139 virtual ~SmFontSizeDialog() override;
141 void ReadFrom(const SmFormat &rFormat);
142 void WriteTo (SmFormat &rFormat) const;
145 /**************************************************************************/
147 class SmFontTypeDialog : public weld::GenericDialogController
149 VclPtr<OutputDevice> pFontListDev;
151 std::unique_ptr<SmFontPickListBox> m_xVariableFont;
152 std::unique_ptr<SmFontPickListBox> m_xFunctionFont;
153 std::unique_ptr<SmFontPickListBox> m_xNumberFont;
154 std::unique_ptr<SmFontPickListBox> m_xTextFont;
155 std::unique_ptr<SmFontPickListBox> m_xSerifFont;
156 std::unique_ptr<SmFontPickListBox> m_xSansFont;
157 std::unique_ptr<SmFontPickListBox> m_xFixedFont;
158 std::unique_ptr<weld::MenuButton> m_xMenuButton;
159 std::unique_ptr<weld::Button> m_xDefaultButton;
161 DECL_LINK(MenuSelectHdl, const OString&, void);
162 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
164 public:
165 SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice);
166 virtual ~SmFontTypeDialog() override;
168 void ReadFrom(const SmFormat &rFormat);
169 void WriteTo (SmFormat &rFormat) const;
172 /**************************************************************************/
174 #define NOCATEGORIES 10
176 class SmCategoryDesc
178 OUString Name;
179 OUString Strings[4];
180 std::unique_ptr<weld::Widget> Graphics[4]; /* regular bitmaps */
181 sal_uInt16 Minimum[4];
182 sal_uInt16 Maximum[4];
183 sal_uInt16 Value[4];
185 public:
186 SmCategoryDesc(weld::Builder& rBuilder, sal_uInt16 nCategoryIdx);
187 ~SmCategoryDesc();
189 const OUString& GetName() const { return Name; }
190 const OUString& GetString(sal_uInt16 Index) const { return Strings[Index]; }
191 sal_uInt16 GetMinimum(sal_uInt16 Index) { return Minimum[Index]; }
192 sal_uInt16 GetMaximum(sal_uInt16 Index) { return Maximum[Index]; }
193 sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; }
194 void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
196 weld::Widget* GetGraphic(sal_uInt16 Index) const
198 return Graphics[Index].get();
202 class SmDistanceDialog : public weld::GenericDialogController
204 std::unique_ptr<weld::Frame> m_xFrame;
205 std::unique_ptr<weld::Label> m_xFixedText1;
206 std::unique_ptr<weld::MetricSpinButton> m_xMetricField1;
207 std::unique_ptr<weld::Label> m_xFixedText2;
208 std::unique_ptr<weld::MetricSpinButton> m_xMetricField2;
209 std::unique_ptr<weld::Label> m_xFixedText3;
210 std::unique_ptr<weld::MetricSpinButton> m_xMetricField3;
211 std::unique_ptr<weld::CheckButton> m_xCheckBox1;
212 std::unique_ptr<weld::Label> m_xFixedText4;
213 std::unique_ptr<weld::MetricSpinButton> m_xMetricField4;
214 std::unique_ptr<weld::MenuButton> m_xMenuButton;
215 std::unique_ptr<weld::Button> m_xDefaultButton;
216 std::unique_ptr<weld::Widget> m_xBitmap;
218 weld::Widget* m_pCurrentImage;
220 SmCategoryDesc *Categories[NOCATEGORIES];
221 sal_uInt16 nActiveCategory;
222 bool bScaleAllBrackets;
224 DECL_LINK(GetFocusHdl, weld::Widget&, void);
225 DECL_LINK(MenuSelectHdl, const OString&, void);
226 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
227 DECL_LINK(CheckBoxClickHdl, weld::ToggleButton&, void);
229 void SetCategory(sal_uInt16 Category);
231 public:
232 SmDistanceDialog(weld::Window *pParent);
233 virtual ~SmDistanceDialog() override;
235 void ReadFrom(const SmFormat &rFormat);
236 void WriteTo (SmFormat &rFormat);
239 /**************************************************************************/
242 class SmAlignDialog : public weld::GenericDialogController
244 std::unique_ptr<weld::RadioButton> m_xLeft;
245 std::unique_ptr<weld::RadioButton> m_xCenter;
246 std::unique_ptr<weld::RadioButton> m_xRight;
247 std::unique_ptr<weld::Button> m_xDefaultButton;
249 DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
251 public:
252 SmAlignDialog(weld::Window *pParent);
253 virtual ~SmAlignDialog() override;
255 void ReadFrom(const SmFormat &rFormat);
256 void WriteTo (SmFormat &rFormat) const;
259 /**************************************************************************/
261 class SmShowSymbolSet : public weld::CustomWidgetController
263 Size m_aOldSize;
264 SymbolPtrVec_t aSymbolSet;
265 Link<SmShowSymbolSet&,void> aSelectHdlLink;
266 Link<SmShowSymbolSet&,void> aDblClickHdlLink;
267 long nLen;
268 long nRows, nColumns;
269 long nXOffset, nYOffset;
270 sal_uInt16 nSelectSymbol;
271 std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
273 void SetScrollBarRange();
274 Point OffsetPoint(const Point &rPoint) const;
276 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
277 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
278 virtual bool KeyInput(const KeyEvent& rKEvt) override;
280 DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
282 public:
283 SmShowSymbolSet(weld::ScrolledWindow* pScrolledWindow);
285 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
287 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
288 pDrawingArea->get_text_height() * 9);
289 CustomWidgetController::SetDrawingArea(pDrawingArea);
292 void calccols(vcl::RenderContext& rRenderContext);
293 void SelectSymbol(sal_uInt16 nSymbol);
294 sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; }
295 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
296 void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; }
297 void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; }
300 class SmShowSymbol : public weld::CustomWidgetController
302 private:
303 vcl::Font m_aFont;
304 OUString m_aText;
306 Link<SmShowSymbol&,void> aDblClickHdlLink;
308 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
309 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
311 void setFontSize(vcl::Font &rFont) const;
313 public:
314 SmShowSymbol();
316 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
318 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
319 pDrawingArea->get_text_height() * 9);
320 CustomWidgetController::SetDrawingArea(pDrawingArea);
323 void SetText(const OUString& rText) { m_aText = rText; }
324 const OUString& GetText() const { return m_aText; }
326 void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
327 const vcl::Font& GetFont() const { return m_aFont; }
329 void SetSymbol(const SmSym *pSymbol);
330 void SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; }
333 class SmSymbolDialog : public weld::GenericDialogController
335 SmViewShell &rViewSh;
336 SmSymbolManager &rSymbolMgr;
338 OUString aSymbolSetName;
339 SymbolPtrVec_t aSymbolSet;
341 VclPtr<OutputDevice> pFontListDev;
343 SmShowSymbol m_aSymbolDisplay;
345 std::unique_ptr<weld::ComboBoxText> m_xSymbolSets;
346 std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay;
347 std::unique_ptr<weld::CustomWeld> m_xSymbolSetDisplayArea;
348 std::unique_ptr<weld::Label> m_xSymbolName;
349 std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
350 std::unique_ptr<weld::Button> m_xGetBtn;
351 std::unique_ptr<weld::Button> m_xEditBtn;
353 DECL_LINK(SymbolSetChangeHdl, weld::ComboBoxText&, void);
354 DECL_LINK(SymbolChangeHdl, SmShowSymbolSet&, void);
355 DECL_LINK(SymbolDblClickHdl, SmShowSymbol&, void);
356 DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSet&, void);
357 DECL_LINK(EditClickHdl, weld::Button&, void);
358 DECL_LINK(GetClickHdl, weld::Button&, void);
359 void SymbolDblClickHdl();
361 void FillSymbolSets();
362 const SmSym *GetSymbol() const;
364 public:
365 SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice,
366 SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
367 virtual ~SmSymbolDialog() override;
369 bool SelectSymbolSet(const OUString &rSymbolSetName);
370 void SelectSymbol(sal_uInt16 nSymbolPos);
373 class SmShowChar : public weld::CustomWidgetController
375 private:
376 OUString m_aText;
377 vcl::Font m_aFont;
379 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
380 virtual void Resize() override;
382 public:
383 SmShowChar()
387 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
389 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7,
390 pDrawingArea->get_text_height() * 3);
391 CustomWidgetController::SetDrawingArea(pDrawingArea);
394 void SetSymbol(const SmSym *pSym);
395 void SetSymbol(sal_UCS4 cChar, const vcl::Font &rFont);
396 void SetText(const OUString& rText) { m_aText = rText; }
397 const OUString& GetText() const { return m_aText; }
398 void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
399 const vcl::Font& GetFont() const { return m_aFont; }
402 class SmSymDefineDialog : public weld::GenericDialogController
404 VclPtr<VirtualDevice> m_xVirDev;
405 SmSymbolManager m_aSymbolMgrCopy;
406 SmSymbolManager& m_rSymbolMgr;
407 SmShowChar m_aOldSymbolDisplay;
408 SmShowChar m_aSymbolDisplay;
409 std::unique_ptr<SmSym> m_xOrigSymbol;
410 std::unique_ptr<SubsetMap> m_xSubsetMap;
411 std::unique_ptr<FontList> m_xFontList;
412 std::unique_ptr<weld::ComboBoxText> m_xOldSymbols;
413 std::unique_ptr<weld::ComboBoxText> m_xOldSymbolSets;
414 std::unique_ptr<weld::ComboBoxText> m_xSymbols;
415 std::unique_ptr<weld::ComboBoxText> m_xSymbolSets;
416 std::unique_ptr<weld::ComboBoxText> m_xFonts;
417 std::unique_ptr<weld::ComboBoxText> m_xFontsSubsetLB;
418 std::unique_ptr<weld::ComboBoxText> m_xStyles;
419 std::unique_ptr<weld::Label> m_xOldSymbolName;
420 std::unique_ptr<weld::Label> m_xOldSymbolSetName;
421 std::unique_ptr<weld::Label> m_xSymbolName;
422 std::unique_ptr<weld::Label> m_xSymbolSetName;
423 std::unique_ptr<weld::Button> m_xAddBtn;
424 std::unique_ptr<weld::Button> m_xChangeBtn;
425 std::unique_ptr<weld::Button> m_xDeleteBtn;
426 std::unique_ptr<weld::CustomWeld> m_xOldSymbolDisplay;
427 std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
428 std::unique_ptr<SvxShowCharSet> m_xCharsetDisplay;
429 std::unique_ptr<weld::CustomWeld> m_xCharsetDisplayArea;
431 DECL_LINK(OldSymbolChangeHdl, weld::ComboBoxText&, void);
432 DECL_LINK(OldSymbolSetChangeHdl, weld::ComboBoxText&, void);
433 DECL_LINK(ModifyHdl, weld::ComboBoxText&, void);
434 DECL_LINK(FontChangeHdl, weld::ComboBoxText&, void);
435 DECL_LINK(SubsetChangeHdl, weld::ComboBoxText&, void);
436 DECL_LINK(StyleChangeHdl, weld::ComboBoxText&, void);
437 DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
438 DECL_LINK(AddClickHdl, weld::Button&, void);
439 DECL_LINK(ChangeClickHdl, weld::Button&, void);
440 DECL_LINK(DeleteClickHdl, weld::Button&, void);
442 void FillSymbols(weld::ComboBoxText& rComboBox, bool bDeleteText = true);
443 void FillSymbolSets(weld::ComboBoxText& rComboBox, bool bDeleteText = true);
444 void FillFonts();
445 void FillStyles();
447 void SetSymbolSetManager(const SmSymbolManager &rMgr);
448 void SetFont(const OUString &rFontName, const OUString &rStyleName);
449 void SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
450 void UpdateButtons();
452 bool SelectSymbolSet(weld::ComboBoxText &rComboBox, const OUString &rSymbolSetName,
453 bool bDeleteText);
454 bool SelectSymbol(weld::ComboBoxText& rComboBox, const OUString &rSymbolName,
455 bool bDeleteText);
456 bool SelectFont(const OUString &rFontName, bool bApplyFont);
457 bool SelectStyle(const OUString &rStyleName, bool bApplyFont);
459 SmSym* GetSymbol(const weld::ComboBoxText& rComboBox);
460 const SmSym* GetSymbol(const weld::ComboBoxText& rComboBox) const
462 return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
465 public:
466 SmSymDefineDialog(weld::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
467 virtual ~SmSymDefineDialog() override;
469 short execute();
471 void SelectOldSymbolSet(const OUString &rSymbolSetName)
473 SelectSymbolSet(*m_xOldSymbolSets, rSymbolSetName, false);
476 void SelectOldSymbol(const OUString &rSymbolName)
478 SelectSymbol(*m_xOldSymbols, rSymbolName, false);
481 bool SelectSymbolSet(const OUString &rSymbolSetName)
483 return SelectSymbolSet(*m_xSymbolSets, rSymbolSetName, false);
486 bool SelectSymbol(const OUString &rSymbolName)
488 return SelectSymbol(*m_xSymbols, rSymbolName, false);
491 bool SelectFont(const OUString &rFontName) { return SelectFont(rFontName, true); }
492 bool SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
493 void SelectChar(sal_Unicode cChar);
497 #endif
499 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */