Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / starmath / inc / dialog.hxx
blob7efaa1fc916005174962ea51dc54a50cd51dd098
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"
43 class SubsetMap;
44 #define CATEGORY_NONE 0xFFFF
46 /**************************************************************************/
48 void SetFontStyle(const OUString &rStyleName, Font &rFont);
50 /**************************************************************************/
52 class SmPrintOptionsTabPage : public SfxTabPage
54 CheckBox* m_pTitle;
55 CheckBox* m_pText;
56 CheckBox* m_pFrame;
57 RadioButton* m_pSizeNormal;
58 RadioButton* m_pSizeScaled;
59 RadioButton* m_pSizeZoomed;
60 MetricField* m_pZoom;
61 CheckBox* m_pNoRightSpaces;
62 CheckBox* m_pSaveOnlyUsedSymbols;
64 DECL_LINK(SizeButtonClickHdl, Button *);
66 virtual bool FillItemSet(SfxItemSet& rSet) SAL_OVERRIDE;
67 virtual void Reset(const SfxItemSet& rSet) SAL_OVERRIDE;
69 public:
70 static SfxTabPage* Create(Window *pWindow, const SfxItemSet &rSet);
72 SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions);
75 /**************************************************************************/
77 class SmShowFont : public Window
79 virtual void Paint(const Rectangle&) SAL_OVERRIDE;
81 public:
82 SmShowFont(Window *pParent, WinBits nStyle)
83 : Window(pParent, nStyle)
86 virtual Size GetOptimalSize() const SAL_OVERRIDE;
87 void SetFont(const Font& rFont);
90 class SmFontDialog : public ModalDialog
92 ComboBox* m_pFontBox;
93 VclContainer* m_pAttrFrame;
94 CheckBox* m_pBoldCheckBox;
95 CheckBox* m_pItalicCheckBox;
96 SmShowFont* m_pShowFont;
98 Font Face;
100 DECL_LINK(FontSelectHdl, ComboBox *);
101 DECL_LINK(FontModifyHdl, ComboBox *);
102 DECL_LINK(AttrChangeHdl, CheckBox *);
104 void InitColor_Impl();
106 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
108 public:
109 SmFontDialog(Window * pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
111 const Font& GetFont() const { return Face; }
112 void SetFont(const Font &rFont);
115 /**************************************************************************/
117 class SmFontSizeDialog : public ModalDialog
119 MetricField* m_pBaseSize;
120 MetricField* m_pTextSize;
121 MetricField* m_pIndexSize;
122 MetricField* m_pFunctionSize;
123 MetricField* m_pOperatorSize;
124 MetricField* m_pBorderSize;
125 PushButton* m_pDefaultButton;
127 DECL_LINK(DefaultButtonClickHdl, Button *);
129 public:
130 SmFontSizeDialog(Window *pParent);
132 void ReadFrom(const SmFormat &rFormat);
133 void WriteTo (SmFormat &rFormat) const;
136 /**************************************************************************/
138 class SmFontTypeDialog : public ModalDialog
140 SmFontPickListBox* m_pVariableFont;
141 SmFontPickListBox* m_pFunctionFont;
142 SmFontPickListBox* m_pNumberFont;
143 SmFontPickListBox* m_pTextFont;
144 SmFontPickListBox* m_pSerifFont;
145 SmFontPickListBox* m_pSansFont;
146 SmFontPickListBox* m_pFixedFont;
147 MenuButton* m_pMenuButton;
148 PushButton* m_pDefaultButton;
150 OutputDevice *pFontListDev;
152 DECL_LINK(MenuSelectHdl, Menu *);
153 DECL_LINK(DefaultButtonClickHdl, Button *);
154 DECL_LINK(HelpButtonClickHdl, Button *);
156 public:
157 SmFontTypeDialog(Window *pParent, OutputDevice *pFntListDevice);
159 void ReadFrom(const SmFormat &rFormat);
160 void WriteTo (SmFormat &rFormat) const;
163 /**************************************************************************/
165 #define NOCATEGORIES 10
167 class SmCategoryDesc
169 OUString Name;
170 OUString *Strings[4];
171 Image *Graphics[4]; /* regular bitmaps */
172 sal_uInt16 Minimum[4];
173 sal_uInt16 Maximum[4];
174 sal_uInt16 Value[4];
176 public:
177 SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx);
178 ~SmCategoryDesc();
180 const OUString& GetName() const { return Name; }
181 const OUString* GetString(sal_uInt16 Index) const { return Strings[Index]; }
182 sal_uInt16 GetMinimum(sal_uInt16 Index) { return Minimum[Index]; }
183 sal_uInt16 GetMaximum(sal_uInt16 Index) { return Maximum[Index]; }
184 sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; }
185 void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
187 const Image * GetGraphic(sal_uInt16 Index) const
189 return Graphics[Index];
194 class SmDistanceDialog : public ModalDialog
196 VclFrame* m_pFrame;
197 FixedText* m_pFixedText1;
198 MetricField* m_pMetricField1;
199 FixedText* m_pFixedText2;
200 MetricField* m_pMetricField2;
201 FixedText* m_pFixedText3;
202 MetricField* m_pMetricField3;
203 CheckBox* m_pCheckBox1;
204 FixedText* m_pFixedText4;
205 MetricField* m_pMetricField4;
206 MenuButton* m_pMenuButton;
207 PushButton* m_pDefaultButton;
208 FixedImage* m_pBitmap;
210 SmCategoryDesc *Categories[NOCATEGORIES];
211 sal_uInt16 nActiveCategory;
212 bool bScaleAllBrackets;
214 DECL_LINK(GetFocusHdl, Control *);
215 DECL_LINK(MenuSelectHdl, Menu *);
216 DECL_LINK(DefaultButtonClickHdl, Button *);
217 DECL_LINK(CheckBoxClickHdl, CheckBox *);
219 using Window::SetHelpId;
220 void SetHelpId(MetricField &rField, const OString& sHelpId);
221 void SetCategory(sal_uInt16 Category);
223 public:
224 SmDistanceDialog(Window *pParent);
225 virtual ~SmDistanceDialog();
227 void ReadFrom(const SmFormat &rFormat);
228 void WriteTo (SmFormat &rFormat) /*const*/;
230 // Window
231 virtual void DataChanged( const DataChangedEvent &rEvt ) SAL_OVERRIDE;
235 /**************************************************************************/
238 class SmAlignDialog : public ModalDialog
240 RadioButton* m_pLeft;
241 RadioButton* m_pCenter;
242 RadioButton* m_pRight;
243 PushButton* m_pDefaultButton;
245 DECL_LINK(DefaultButtonClickHdl, Button *);
247 public:
248 SmAlignDialog(Window *pParent);
250 void ReadFrom(const SmFormat &rFormat);
251 void WriteTo (SmFormat &rFormat) const;
254 /**************************************************************************/
256 class SmShowSymbolSetWindow : public Control
258 ScrollBar* m_pVScrollBar;
259 SymbolPtrVec_t aSymbolSet;
260 Link aSelectHdlLink;
261 Link aDblClickHdlLink;
262 sal_uInt16 nLen;
263 sal_uInt16 nRows, nColumns;
264 sal_uInt16 nXOffset, nYOffset;
265 sal_uInt16 nSelectSymbol;
267 void SetScrollBarRange();
268 Point OffsetPoint(const Point &rPoint) const;
270 virtual void Paint(const Rectangle&) SAL_OVERRIDE;
271 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
272 virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
273 virtual void Resize() SAL_OVERRIDE;
274 virtual Size GetOptimalSize() const SAL_OVERRIDE;
276 DECL_LINK( ScrollHdl, ScrollBar* );
277 public:
278 SmShowSymbolSetWindow(Window *pParent, WinBits nStyle);
279 void setScrollbar(ScrollBar *pVScrollBar);
280 void calccols();
281 void SelectSymbol(sal_uInt16 nSymbol);
282 sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; }
283 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
284 void SetSelectHdl(const Link& rLink) { aSelectHdlLink = rLink; }
285 void SetDblClickHdl(const Link& rLink) { aDblClickHdlLink = rLink; }
288 class SmShowSymbolSet : public VclHBox
290 SmShowSymbolSetWindow aSymbolWindow;
291 ScrollBar aVScrollBar;
292 Size aOutputSize;
294 public:
295 SmShowSymbolSet(Window *pParent);
297 void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) { aSymbolWindow.SetSymbolSet(rSymbolSet); }
299 void SelectSymbol(sal_uInt16 nSymbol) { aSymbolWindow.SelectSymbol(nSymbol); }
300 sal_uInt16 GetSelectSymbol() const { return aSymbolWindow.GetSelectSymbol(); }
302 void SetSelectHdl(const Link& rLink) { aSymbolWindow.SetSelectHdl(rLink); }
303 void SetDblClickHdl(const Link& rLink) { aSymbolWindow.SetDblClickHdl(rLink); }
308 class SmShowSymbol : public Control
310 Link aDblClickHdlLink;
312 virtual void Paint(const Rectangle&) SAL_OVERRIDE;
313 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
314 virtual void Resize() SAL_OVERRIDE;
316 void setFontSize(Font &rFont) const;
318 public:
319 SmShowSymbol(Window *pParent, WinBits nStyle)
320 : Control(pParent, nStyle)
324 void SetSymbol(const SmSym *pSymbol);
325 void SetDblClickHdl(const Link &rLink) { aDblClickHdlLink = rLink; }
330 class SmSymDefineDialog;
332 class SmSymbolDialog : public ModalDialog
334 ListBox* m_pSymbolSets;
335 SmShowSymbolSet* m_pSymbolSetDisplay;
336 FixedText* m_pSymbolName;
337 SmShowSymbol* m_pSymbolDisplay;
338 PushButton* m_pGetBtn;
339 PushButton* m_pEditBtn;
341 SmViewShell &rViewSh;
342 SmSymbolManager &rSymbolMgr;
344 OUString aSymbolSetName;
345 SymbolPtrVec_t aSymbolSet;
347 OutputDevice *pFontListDev;
349 DECL_LINK(SymbolSetChangeHdl, void*);
350 DECL_LINK(SymbolChangeHdl, void*);
351 DECL_LINK(SymbolDblClickHdl, void*);
352 DECL_LINK(EditClickHdl, void*);
353 DECL_LINK(GetClickHdl, void*);
355 void FillSymbolSets(bool bDeleteText = true);
356 void SetSymbolSetManager(SmSymbolManager &rMgr);
357 const SmSym *GetSymbol() const;
358 void InitColor_Impl();
360 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
362 public:
363 SmSymbolDialog(Window * pParent, OutputDevice *pFntListDevice,
364 SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
366 bool SelectSymbolSet(const OUString &rSymbolSetName);
367 void SelectSymbol(sal_uInt16 nSymbolPos);
368 sal_uInt16 GetSelectedSymbol() const { return m_pSymbolSetDisplay->GetSelectSymbol(); }
373 class SmShowChar : public Control
375 virtual void Paint(const Rectangle&) SAL_OVERRIDE;
376 virtual void Resize() SAL_OVERRIDE;
378 public:
379 SmShowChar(Window *pParent, WinBits nStyle)
380 : Control(pParent, nStyle)
384 void SetSymbol( const SmSym *pSym );
385 void SetSymbol( sal_UCS4 cChar, const Font &rFont );
390 class SmSymDefineDialog : public ModalDialog
392 ComboBox* pOldSymbols;
393 ComboBox* pOldSymbolSets;
394 SvxShowCharSet* pCharsetDisplay;
395 ComboBox* pSymbols;
396 ComboBox* pSymbolSets;
397 ListBox* pFonts;
398 ListBox* pFontsSubsetLB;
399 FontStyleBox* pStyles;
400 FixedText* pOldSymbolName;
401 SmShowChar* pOldSymbolDisplay;
402 FixedText* pOldSymbolSetName;
403 FixedText* pSymbolName;
404 SmShowChar* pSymbolDisplay;
405 FixedText* pSymbolSetName;
406 PushButton* pAddBtn;
407 PushButton* pChangeBtn;
408 PushButton* pDeleteBtn;
410 SmSymbolManager aSymbolMgrCopy,
411 &rSymbolMgr;
412 const SmSym *pOrigSymbol;
414 const SubsetMap *pSubsetMap;
415 FontList *pFontList;
417 DECL_LINK(OldSymbolChangeHdl, ComboBox *);
418 DECL_LINK(OldSymbolSetChangeHdl, ComboBox *);
419 DECL_LINK(ModifyHdl, ComboBox *);
420 DECL_LINK(FontChangeHdl, ListBox *);
421 DECL_LINK(SubsetChangeHdl, ListBox*);
422 DECL_LINK(StyleChangeHdl, ComboBox *);
423 DECL_LINK(CharHighlightHdl, void *);
424 DECL_LINK(AddClickHdl, Button *);
425 DECL_LINK(ChangeClickHdl, Button *);
426 DECL_LINK(DeleteClickHdl, Button *);
428 void FillSymbols(ComboBox &rComboBox, bool bDeleteText = true);
429 void FillSymbolSets(ComboBox &rComboBox, bool bDeleteText = true);
430 void FillFonts(bool bDeleteText = true);
431 void FillStyles(bool bDeleteText = true);
433 void SetSymbolSetManager(const SmSymbolManager &rMgr);
434 void SetFont(const OUString &rFontName, const OUString &rStyleName);
435 void SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
436 void UpdateButtons();
438 bool SelectSymbolSet(ComboBox &rComboBox, const OUString &rSymbolSetName,
439 bool bDeleteText);
440 bool SelectSymbol(ComboBox &rComboBox, const OUString &rSymbolName,
441 bool bDeleteText);
442 bool SelectFont(const OUString &rFontName, bool bApplyFont);
443 bool SelectStyle(const OUString &rStyleName, bool bApplyFont);
445 SmSym * GetSymbol(const ComboBox &rComboBox);
446 const SmSym * GetSymbol(const ComboBox &rComboBox) const
448 return ((SmSymDefineDialog *) this)->GetSymbol(rComboBox);
451 void InitColor_Impl();
453 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
455 public:
456 SmSymDefineDialog(Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
457 virtual ~SmSymDefineDialog();
459 using OutputDevice::SetFont;
461 // Dialog
462 virtual short Execute() SAL_OVERRIDE;
464 bool SelectOldSymbolSet(const OUString &rSymbolSetName)
466 return SelectSymbolSet(*pOldSymbolSets, rSymbolSetName, false);
469 bool SelectOldSymbol(const OUString &rSymbolName)
471 return SelectSymbol(*pOldSymbols, rSymbolName, false);
474 bool SelectSymbolSet(const OUString &rSymbolSetName)
476 return SelectSymbolSet(*pSymbolSets, rSymbolSetName, false);
479 bool SelectSymbol(const OUString &rSymbolName)
481 return SelectSymbol(*pSymbols, rSymbolName, false);
484 bool SelectFont(const OUString &rFontName) { return SelectFont(rFontName, true); }
485 bool SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
486 void SelectChar(sal_Unicode cChar);
491 #endif
493 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */