xref: /AOO41X/main/starmath/inc/dialog.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DIALOG_HXX
24 #define DIALOG_HXX
25 
26 #include <vcl/image.hxx>
27 #include <vcl/dialog.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/button.hxx>
30 #include <vcl/image.hxx>
31 #include <sfx2/tabdlg.hxx>
32 #include <vcl/combobox.hxx>
33 #include <svx/charmap.hxx>
34 #include <sfx2/basedlgs.hxx>
35 #include <vcl/field.hxx>
36 #include <vcl/menubtn.hxx>
37 #include <vcl/scrbar.hxx>
38 #include <vcl/ctrl.hxx>
39 #include <vcl/menu.hxx>
40 #include <vcl/outdev.hxx>
41 #include <svtools/ctrlbox.hxx>
42 #include <svtools/ctrltool.hxx>
43 #include "utility.hxx"
44 #include "format.hxx"
45 #include "symbol.hxx"
46 
47 class SubsetMap;
48 #define CATEGORY_NONE   0xFFFF
49 
50 /**************************************************************************/
51 
52 const XubString GetFontStyleName(const Font &rFont);
53 void            SetFontStyle(const XubString &rStyleName, Font &rFont);
54 
55 /**************************************************************************/
56 
57 class SmPrintOptionsTabPage : public SfxTabPage
58 {
59     FixedLine       aFixedLine1;
60     CheckBox        aTitle;
61     CheckBox        aText;
62     CheckBox        aFrame;
63     FixedLine       aFixedLine2;
64     RadioButton     aSizeNormal;
65     RadioButton     aSizeScaled;
66     RadioButton     aSizeZoomed;
67     MetricField     aZoom;
68     FixedLine       aFixedLine3;
69     CheckBox        aNoRightSpaces;
70     CheckBox        aSaveOnlyUsedSymbols;
71 
72     DECL_LINK(SizeButtonClickHdl, Button *);
73 
74     virtual sal_Bool    FillItemSet(SfxItemSet& rSet);
75     virtual void    Reset(const SfxItemSet& rSet);
76 
77 public:
78     static SfxTabPage* Create(Window *pWindow, const SfxItemSet &rSet);
79 
80     SmPrintOptionsTabPage(Window *pParent, const SfxItemSet &rOptions);
81 };
82 
83 /**************************************************************************/
84 
85 class SmShowFont : public Control
86 {
87     virtual void    Paint(const Rectangle&);
88 
89 public:
SmShowFont(Window * pParent,const ResId & rResId)90     SmShowFont(Window *pParent, const ResId& rResId) :
91         Control(pParent, rResId)
92     {
93     }
94 
95     void SetFont(const Font& rFont);
96 };
97 
98 class SmFontDialog : public ModalDialog
99 {
100     FixedText       aFixedText1;
101     ComboBox        aFontBox;
102     CheckBox        aBoldCheckBox;
103     CheckBox        aItalicCheckBox;
104     OKButton        aOKButton1;
105     CancelButton    aCancelButton1;
106     SmShowFont      aShowFont;
107     FixedText       aFixedText2;
108 
109     Font    Face;
110 
111     DECL_LINK(FontSelectHdl, ComboBox *);
112     DECL_LINK(FontModifyHdl, ComboBox *);
113     DECL_LINK(AttrChangeHdl, CheckBox *);
114 
115     void            InitColor_Impl();
116 
117     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
118 
119 public:
120     SmFontDialog(Window * pParent, OutputDevice *pFntListDevice, sal_Bool bHideCheckboxes, sal_Bool bFreeRes = sal_True);
121 
GetFont() const122     const Font& GetFont() const { return Face; }
123     void        SetFont(const Font &rFont);
124 };
125 
126 /**************************************************************************/
127 
128 class SmFontSizeDialog : public ModalDialog
129 {
130     FixedText       aFixedText1;
131     MetricField     aBaseSize;
132     FixedText       aFixedText4;
133     MetricField     aTextSize;
134     FixedText       aFixedText5;
135     MetricField     aIndexSize;
136     FixedText       aFixedText6;
137     MetricField     aFunctionSize;
138     FixedText       aFixedText7;
139     MetricField     aOperatorSize;
140     FixedText       aFixedText8;
141     MetricField     aBorderSize;
142     FixedLine       aFixedLine1;
143     OKButton        aOKButton1;
144     CancelButton    aCancelButton1;
145     PushButton      aDefaultButton;
146 
147     DECL_LINK(DefaultButtonClickHdl, Button *);
148 
149 public:
150     SmFontSizeDialog(Window *pParent, sal_Bool bFreeRes = sal_True);
151 
152     void ReadFrom(const SmFormat &rFormat);
153     void WriteTo (SmFormat &rFormat) const;
154 };
155 
156 /**************************************************************************/
157 
158 class SmFontTypeDialog : public ModalDialog
159 {
160     FixedText           aFixedText1;
161     SmFontPickListBox   aVariableFont;
162     FixedText           aFixedText2;
163     SmFontPickListBox   aFunctionFont;
164     FixedText           aFixedText3;
165     SmFontPickListBox   aNumberFont;
166     FixedText           aFixedText4;
167     SmFontPickListBox   aTextFont;
168     FixedText           aFixedText5;
169     SmFontPickListBox   aSerifFont;
170     FixedText           aFixedText6;
171     SmFontPickListBox   aSansFont;
172     FixedText           aFixedText7;
173     SmFontPickListBox   aFixedFont;
174     FixedLine           aFixedLine1;
175     FixedLine           aFixedLine2;
176     OKButton            aOKButton1;
177     CancelButton        aCancelButton1;
178     MenuButton          aMenuButton;
179     PushButton          aDefaultButton;
180 
181     OutputDevice       *pFontListDev;
182 
183     DECL_LINK(MenuSelectHdl, Menu *);
184     DECL_LINK(DefaultButtonClickHdl, Button *);
185 
186 public:
187     SmFontTypeDialog(Window *pParent, OutputDevice *pFntListDevice, sal_Bool bFreeRes = sal_True);
188 
189     void ReadFrom(const SmFormat &rFormat);
190     void WriteTo (SmFormat &rFormat) const;
191 };
192 
193 /**************************************************************************/
194 
195 #define NOCATEGORIES    10
196 
197 class SmCategoryDesc : public Resource
198 {
199     XubString       Name;
200     XubString      *Strings[4];
201     Bitmap         *Graphics[4];    /* regular bitmaps */
202     Bitmap         *GraphicsH[4];   /* high contrast bitmaps */
203     sal_uInt16          Minimum[4];
204     sal_uInt16          Maximum[4];
205     sal_uInt16          Value[4];
206     sal_Bool            bIsHighContrast;
207 
208 public:
209     SmCategoryDesc(const ResId &rResId, sal_uInt16 nCategoryIdx);
210     ~SmCategoryDesc();
211 
GetName() const212     const XubString &   GetName() const                 { return Name; }
GetString(sal_uInt16 Index) const213     const XubString *   GetString(sal_uInt16 Index) const   { return Strings[Index];  }
GetMinimum(sal_uInt16 Index)214     sal_uInt16          GetMinimum(sal_uInt16 Index)        { return Minimum[Index]; }
GetMaximum(sal_uInt16 Index)215     sal_uInt16          GetMaximum(sal_uInt16 Index)        { return Maximum[Index]; }
GetValue(sal_uInt16 Index) const216     sal_uInt16          GetValue(sal_uInt16 Index) const    { return Value[Index]; }
SetValue(sal_uInt16 Index,sal_uInt16 nVal)217     void            SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
218 
SetHighContrast(sal_Bool bVal)219     void            SetHighContrast( sal_Bool bVal )    { bIsHighContrast = bVal; }
GetGraphic(sal_uInt16 Index) const220     const Bitmap *  GetGraphic(sal_uInt16 Index) const
221     {
222         return bIsHighContrast ? GraphicsH[Index] : Graphics[Index];
223     }
224 };
225 
226 
227 class SmDistanceDialog : public ModalDialog
228 {
229     FixedText       aFixedText1;
230     MetricField     aMetricField1;
231     FixedText       aFixedText2;
232     MetricField     aMetricField2;
233     FixedText       aFixedText3;
234     MetricField     aMetricField3;
235     CheckBox        aCheckBox1;
236     FixedText       aFixedText4;
237     MetricField     aMetricField4;
238     OKButton        aOKButton1;
239     CancelButton    aCancelButton1;
240     MenuButton      aMenuButton;
241     PushButton      aDefaultButton;
242     FixedBitmap     aBitmap;
243     FixedLine       aFixedLine;
244 
245     SmCategoryDesc *Categories[NOCATEGORIES];
246     sal_uInt16          nActiveCategory;
247     sal_Bool            bScaleAllBrackets;
248 
249     DECL_LINK(GetFocusHdl, Control *);
250     DECL_LINK(MenuSelectHdl, Menu *);
251     DECL_LINK(DefaultButtonClickHdl, Button *);
252     DECL_LINK(CheckBoxClickHdl, CheckBox *);
253 
254     using   Window::SetHelpId;
255     void    SetHelpId(MetricField &rField, const rtl::OString& sHelpId);
256     void    SetCategory(sal_uInt16 Category);
257 
258     void    ApplyImages();
259 
260 public:
261     SmDistanceDialog(Window *pParent, sal_Bool bFreeRes = sal_True);
262     ~SmDistanceDialog();
263 
264     void ReadFrom(const SmFormat &rFormat);
265     void WriteTo (SmFormat &rFormat) /*const*/;
266 
267     // Window
268     virtual void    DataChanged( const DataChangedEvent &rEvt );
269 };
270 
271 
272 /**************************************************************************/
273 
274 
275 class SmAlignDialog : public ModalDialog
276 {
277     RadioButton  aLeft;
278     RadioButton  aCenter;
279     RadioButton  aRight;
280     FixedLine    aFixedLine1;
281     OKButton     aOKButton1;
282     CancelButton aCancelButton1;
283     PushButton   aDefaultButton;
284 
285     DECL_LINK(DefaultButtonClickHdl, Button *);
286 
287 public:
288     SmAlignDialog(Window *pParent, sal_Bool bFreeRes = sal_True);
289 
290     void ReadFrom(const SmFormat &rFormat);
291     void WriteTo (SmFormat &rFormat) const;
292 };
293 
294 /**************************************************************************/
295 
296 class SmShowSymbolSet : public Control
297 {
298     SymbolPtrVec_t aSymbolSet;
299     ScrollBar   aVScrollBar;
300     Size        aOutputSize;
301     Link        aSelectHdlLink;
302     Link        aDblClickHdlLink;
303     sal_uInt16      nLen;
304     sal_uInt16      nRows, nColumns;
305     sal_uInt16      nSelectSymbol;
306 
307     virtual void    Paint(const Rectangle&);
308     virtual void    MouseButtonDown(const MouseEvent& rMEvt);
309     virtual void    KeyInput(const KeyEvent& rKEvt);
310 
311     DECL_LINK( ScrollHdl, ScrollBar* );
312 
313 public:
314     SmShowSymbolSet(Window *pParent, const ResId& rResId);
315 
316     void    SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
317 
318     void    SelectSymbol(sal_uInt16 nSymbol);
GetSelectSymbol() const319     sal_uInt16  GetSelectSymbol() const { return nSelectSymbol; }
320 
SetSelectHdl(const Link & rLink)321     void SetSelectHdl(const Link& rLink)   { aSelectHdlLink = rLink; }
SetDblClickHdl(const Link & rLink)322     void SetDblClickHdl(const Link& rLink) { aDblClickHdlLink = rLink; }
323 };
324 
325 ////////////////////////////////////////////////////////////////////////////////
326 
327 class SmShowSymbol : public Control
328 {
329     Link  aDblClickHdlLink;
330 
331     virtual void    Paint(const Rectangle&);
332     virtual void    MouseButtonDown(const MouseEvent& rMEvt);
333 
334 public:
SmShowSymbol(Window * pParent,const ResId & rResId)335     SmShowSymbol(Window *pParent, const ResId& rResId) :
336         Control(pParent, rResId) {}
337 
338     void    SetSymbol(const SmSym *pSymbol);
SetDblClickHdl(const Link & rLink)339     void    SetDblClickHdl(const Link &rLink) { aDblClickHdlLink = rLink; }
340 };
341 
342 ////////////////////////////////////////////////////////////////////////////////
343 
344 class SmSymDefineDialog;
345 
346 class SmSymbolDialog : public ModalDialog
347 {
348     FixedText       aSymbolSetText;
349     ListBox         aSymbolSets;
350     SmShowSymbolSet aSymbolSetDisplay;
351     FixedText       aSymbolName;
352     SmShowSymbol    aSymbolDisplay;
353     PushButton      aGetBtn;
354     PushButton      aCloseBtn;
355     PushButton      aEditBtn;
356 
357     SmViewShell        &rViewSh;
358     SmSymbolManager    &rSymbolMgr;
359 
360     String              aSymbolSetName;
361     SymbolPtrVec_t      aSymbolSet;
362 
363     OutputDevice       *pFontListDev;
364 
365     DECL_LINK(SymbolSetChangeHdl, ListBox *);
366     DECL_LINK(SymbolChangeHdl, SmShowSymbolSet *);
367     DECL_LINK(SymbolDblClickHdl, SmShowSymbolSet *);
368     DECL_LINK(CloseClickHdl, Button *);
369     DECL_LINK(EditClickHdl, Button *);
370     DECL_LINK(GetClickHdl, Button *);
371 
372     void            FillSymbolSets(sal_Bool bDeleteText = sal_True);
373     void            SetSymbolSetManager(SmSymbolManager &rMgr);
374     const SmSym    *GetSymbol() const;
375     void            InitColor_Impl();
376 
377     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
378 
379 public:
380     SmSymbolDialog(Window * pParent, OutputDevice *pFntListDevice,
381             SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell, sal_Bool bFreeRes = sal_True);
382     virtual ~SmSymbolDialog();
383 
384     sal_Bool    SelectSymbolSet(const XubString &rSymbolSetName);
385     void    SelectSymbol(sal_uInt16 nSymbolPos);
GetSelectedSymbol() const386     sal_uInt16  GetSelectedSymbol() const   { return aSymbolSetDisplay.GetSelectSymbol(); }
387 };
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 
391 class SmShowChar : public Control
392 {
393     virtual void    Paint(const Rectangle&);
394 
395 public:
SmShowChar(Window * pParent,const ResId & rResId)396     SmShowChar(Window *pParent, const ResId& rResId)
397     : Control(pParent, rResId)
398     {
399     }
400 
401     void    SetSymbol( const SmSym *pSym );
402     void    SetSymbol( sal_UCS4 cChar, const Font &rFont );
403 };
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 
407 class SmSymDefineDialog : public ModalDialog
408 {
409     FixedText       aOldSymbolText;
410     ComboBox        aOldSymbols;
411     FixedText       aOldSymbolSetText;
412     ComboBox        aOldSymbolSets;
413     SvxShowCharSet  aCharsetDisplay;
414     FixedText       aSymbolText;
415     ComboBox        aSymbols;
416     FixedText       aSymbolSetText;
417     ComboBox        aSymbolSets;
418     FixedText       aFontText;
419     ListBox         aFonts;
420     FixedText       aFontsSubsetFT;
421     ListBox         aFontsSubsetLB;
422     FixedText       aStyleText;
423     FontStyleBox    aStyles;
424     FixedText       aOldSymbolName;
425     SmShowChar      aOldSymbolDisplay;
426     FixedText       aOldSymbolSetName;
427     FixedText       aSymbolName;
428     SmShowChar      aSymbolDisplay;
429     FixedText       aSymbolSetName;
430     OKButton        aOkBtn;
431     CancelButton    aCancelBtn;
432     PushButton      aAddBtn;
433     PushButton      aChangeBtn;
434     PushButton      aDeleteBtn;
435     FixedImage      aRightArrow;
436     Image           aRigthArrow_Im;
437     Image           aRigthArrow_Im_HC;     // hi-contrast version
438 
439     SmSymbolManager     aSymbolMgrCopy,
440                        &rSymbolMgr;
441     const SmSym        *pOrigSymbol;
442 
443     const SubsetMap    *pSubsetMap;
444     FontList           *pFontList;
445 
446     DECL_LINK(OldSymbolChangeHdl, ComboBox *);
447     DECL_LINK(OldSymbolSetChangeHdl, ComboBox *);
448     DECL_LINK(ModifyHdl, ComboBox *);
449     DECL_LINK(FontChangeHdl, ListBox *);
450     DECL_LINK(SubsetChangeHdl, ListBox*);
451     DECL_LINK(StyleChangeHdl, ComboBox *);
452     DECL_LINK(CharHighlightHdl, Control* pControl);
453     DECL_LINK(AddClickHdl, Button *);
454     DECL_LINK(ChangeClickHdl, Button *);
455     DECL_LINK(DeleteClickHdl, Button *);
456 
457     void    FillSymbols(ComboBox &rComboBox, sal_Bool bDeleteText = sal_True);
458     void    FillSymbolSets(ComboBox &rComboBox, sal_Bool bDeleteText = sal_True);
459     void    FillFonts(sal_Bool bDeleteText = sal_True);
460     void    FillStyles(sal_Bool bDeleteText = sal_True);
461 
462     void    SetSymbolSetManager(const SmSymbolManager &rMgr);
463     void    SetFont(const XubString &rFontName, const XubString &rStyleName);
464     void    SetOrigSymbol(const SmSym *pSymbol, const XubString &rSymbolSetName);
465     void    UpdateButtons();
466 
467     sal_Bool    SelectSymbolSet(ComboBox &rComboBox, const XubString &rSymbolSetName,
468                             sal_Bool bDeleteText);
469     sal_Bool    SelectSymbol(ComboBox &rComboBox, const XubString &rSymbolName,
470                             sal_Bool bDeleteText);
471     sal_Bool    SelectFont(const XubString &rFontName, sal_Bool bApplyFont);
472     sal_Bool    SelectStyle(const XubString &rStyleName, sal_Bool bApplyFont);
473 
474     SmSym       * GetSymbol(const ComboBox &rComboBox);
GetSymbol(const ComboBox & rComboBox) const475     const SmSym * GetSymbol(const ComboBox &rComboBox) const
476     {
477         return ((SmSymDefineDialog *) this)->GetSymbol(rComboBox);
478     }
479 
480     void            InitColor_Impl();
481 
482     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
483 
484 public:
485     SmSymDefineDialog(Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr, sal_Bool bFreeRes = sal_True);
486     ~SmSymDefineDialog();
487 
488     using OutputDevice::SetFont;
489 
490     // Dialog
491     virtual short   Execute();
492 
SelectOldSymbolSet(const XubString & rSymbolSetName)493     sal_Bool SelectOldSymbolSet(const XubString &rSymbolSetName)
494     {
495         return SelectSymbolSet(aOldSymbolSets, rSymbolSetName, sal_False);
496     }
497 
SelectOldSymbol(const XubString & rSymbolName)498     sal_Bool SelectOldSymbol(const XubString &rSymbolName)
499     {
500         return SelectSymbol(aOldSymbols, rSymbolName, sal_False);
501     }
502 
SelectSymbolSet(const XubString & rSymbolSetName)503     sal_Bool SelectSymbolSet(const XubString &rSymbolSetName)
504     {
505         return SelectSymbolSet(aSymbolSets, rSymbolSetName, sal_False);
506     }
507 
SelectSymbol(const XubString & rSymbolName)508     sal_Bool SelectSymbol(const XubString &rSymbolName)
509     {
510         return SelectSymbol(aSymbols, rSymbolName, sal_False);
511     }
512 
SelectFont(const XubString & rFontName)513     sal_Bool        SelectFont(const XubString &rFontName)   { return SelectFont(rFontName, sal_True); }
SelectStyle(const XubString & rStyleName)514     sal_Bool        SelectStyle(const XubString &rStyleName) { return SelectStyle(rStyleName, sal_True); };
515     void        SelectChar(xub_Unicode cChar);
516 };
517 
518 
519 
520 #endif
521 
522