summaryrefslogtreecommitdiff
path: root/starmath/inc/dialog.hxx
blob: a595917d450d40e978f46c4dd4020ad813b53079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#pragma once

#include <sfx2/tabdlg.hxx>
#include <vcl/outdev.hxx>
#include <vcl/customweld.hxx>
#include "symbol.hxx"

class SubsetMap;
class SmFormat;
class FontList;
class SvxShowCharSet;

#define CATEGORY_NONE   0xFFFF

/**************************************************************************/

void SetFontStyle(std::u16string_view rStyleName, vcl::Font &rFont);

/**************************************************************************/

class SmPrintOptionsTabPage final : public SfxTabPage
{
    std::unique_ptr<weld::CheckButton>      m_xTitle;
    std::unique_ptr<weld::CheckButton>      m_xText;
    std::unique_ptr<weld::CheckButton>      m_xFrame;
    std::unique_ptr<weld::RadioButton>      m_xSizeNormal;
    std::unique_ptr<weld::RadioButton>      m_xSizeScaled;
    std::unique_ptr<weld::RadioButton>      m_xSizeZoomed;
    std::unique_ptr<weld::MetricSpinButton> m_xZoom;
    std::unique_ptr<weld::CheckButton>      m_xNoRightSpaces;
    std::unique_ptr<weld::CheckButton>      m_xSaveOnlyUsedSymbols;
    std::unique_ptr<weld::CheckButton>      m_xAutoCloseBrackets;
    std::unique_ptr<weld::MetricSpinButton> m_xSmZoom;

    DECL_LINK(SizeButtonClickHdl, weld::Toggleable&, void);

    virtual bool    FillItemSet(SfxItemSet* rSet) override;
    virtual void    Reset(const SfxItemSet* rSet) override;

public:
    static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);

    SmPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions);
    virtual ~SmPrintOptionsTabPage() override;
};

/**************************************************************************/

class SmShowFont final : public weld::CustomWidgetController
{
    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;

    vcl::Font maFont;

public:
    SmShowFont()
    {
    }
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
    void SetFont(const vcl::Font& rFont);
};

class SmFontDialog : public weld::GenericDialogController
{
    vcl::Font maFont;
    SmShowFont m_aShowFont;
    std::unique_ptr<weld::EntryTreeView> m_xFontBox;
    std::unique_ptr<weld::Widget> m_xAttrFrame;
    std::unique_ptr<weld::CheckButton> m_xBoldCheckBox;
    std::unique_ptr<weld::CheckButton> m_xItalicCheckBox;
    std::unique_ptr<weld::CustomWeld> m_xShowFont;

    DECL_LINK(FontSelectHdl, weld::ComboBox&, void);
    DECL_LINK(AttrChangeHdl, weld::Toggleable&, void);

public:
    SmFontDialog(weld::Window* pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
    virtual ~SmFontDialog() override;

    const vcl::Font& GetFont() const
    {
        return maFont;
    }
    void SetFont(const vcl::Font &rFont);
};

/**************************************************************************/

class SmFontSizeDialog final : public weld::GenericDialogController
{
    std::unique_ptr<weld::MetricSpinButton> m_xBaseSize;
    std::unique_ptr<weld::MetricSpinButton> m_xTextSize;
    std::unique_ptr<weld::MetricSpinButton> m_xIndexSize;
    std::unique_ptr<weld::MetricSpinButton> m_xFunctionSize;
    std::unique_ptr<weld::MetricSpinButton> m_xOperatorSize;
    std::unique_ptr<weld::MetricSpinButton> m_xBorderSize;
    std::unique_ptr<weld::Button> m_xDefaultButton;

    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);

public:
    SmFontSizeDialog(weld::Window *pParent);
    virtual ~SmFontSizeDialog() override;

    void ReadFrom(const SmFormat &rFormat);
    void WriteTo (SmFormat &rFormat) const;
};

/**************************************************************************/

class SmFontTypeDialog final : public weld::GenericDialogController
{
    VclPtr<OutputDevice> pFontListDev;

    std::unique_ptr<SmFontPickListBox> m_xVariableFont;
    std::unique_ptr<SmFontPickListBox> m_xFunctionFont;
    std::unique_ptr<SmFontPickListBox> m_xNumberFont;
    std::unique_ptr<SmFontPickListBox> m_xTextFont;
    std::unique_ptr<SmFontPickListBox> m_xSerifFont;
    std::unique_ptr<SmFontPickListBox> m_xSansFont;
    std::unique_ptr<SmFontPickListBox> m_xFixedFont;
    std::unique_ptr<weld::MenuButton> m_xMenuButton;
    std::unique_ptr<weld::Button> m_xDefaultButton;

    DECL_LINK(MenuSelectHdl, const OUString&, void);
    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);

public:
    SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice);
    virtual ~SmFontTypeDialog() override;

    void ReadFrom(const SmFormat &rFormat);
    void WriteTo (SmFormat &rFormat) const;
};

/**************************************************************************/

#define NOCATEGORIES    10

class SmCategoryDesc
{
    OUString Name;
    OUString Strings[4];
    std::unique_ptr<weld::Widget> Graphics[4];    /* regular bitmaps */
    sal_uInt16 Minimum[4];
    sal_uInt16 Maximum[4];
    sal_uInt16 Value[4];

public:
    SmCategoryDesc(weld::Builder& rBuilder, sal_uInt16 nCategoryIdx);
    ~SmCategoryDesc();

    const OUString& GetName() const                 { return Name; }
    const OUString& GetString(sal_uInt16 Index) const   { return Strings[Index];  }
    sal_uInt16          GetMinimum(sal_uInt16 Index)        { return Minimum[Index]; }
    sal_uInt16          GetMaximum(sal_uInt16 Index)        { return Maximum[Index]; }
    sal_uInt16          GetValue(sal_uInt16 Index) const    { return Value[Index]; }
    void            SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}

    weld::Widget* GetGraphic(sal_uInt16 Index) const
    {
        return Graphics[Index].get();
    }
};

class SmDistanceDialog final : public weld::GenericDialogController
{
    std::unique_ptr<weld::Frame> m_xFrame;
    std::unique_ptr<weld::Label> m_xFixedText1;
    std::unique_ptr<weld::MetricSpinButton>    m_xMetricField1;
    std::unique_ptr<weld::Label> m_xFixedText2;
    std::unique_ptr<weld::MetricSpinButton>    m_xMetricField2;
    std::unique_ptr<weld::Label> m_xFixedText3;
    std::unique_ptr<weld::MetricSpinButton>    m_xMetricField3;
    std::unique_ptr<weld::CheckButton> m_xCheckBox1;
    std::unique_ptr<weld::Label> m_xFixedText4;
    std::unique_ptr<weld::MetricSpinButton> m_xMetricField4;
    std::unique_ptr<weld::MenuButton> m_xMenuButton;
    std::unique_ptr<weld::Button> m_xDefaultButton;
    std::unique_ptr<weld::Widget> m_xBitmap;

    weld::Widget* m_pCurrentImage;

    std::unique_ptr<SmCategoryDesc> m_xCategories[NOCATEGORIES];
    sal_uInt16          nActiveCategory;
    bool            bScaleAllBrackets;

    DECL_LINK(GetFocusHdl, weld::Widget&, void);
    DECL_LINK(MenuSelectHdl, const OUString&, void);
    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
    DECL_LINK(CheckBoxClickHdl, weld::Toggleable&, void);

    void    SetCategory(sal_uInt16 Category);

public:
    SmDistanceDialog(weld::Window *pParent);
    virtual ~SmDistanceDialog() override;

    void ReadFrom(const SmFormat &rFormat);
    void WriteTo (SmFormat &rFormat);
};

/**************************************************************************/


class SmAlignDialog final : public weld::GenericDialogController
{
    std::unique_ptr<weld::RadioButton> m_xLeft;
    std::unique_ptr<weld::RadioButton> m_xCenter;
    std::unique_ptr<weld::RadioButton> m_xRight;
    std::unique_ptr<weld::Button> m_xDefaultButton;

    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);

public:
    SmAlignDialog(weld::Window *pParent);
    virtual ~SmAlignDialog() override;

    void ReadFrom(const SmFormat &rFormat);
    void WriteTo (SmFormat &rFormat) const;
};

/**************************************************************************/

class SmShowSymbolSet final : public weld::CustomWidgetController
{
    Size m_aOldSize;
    SymbolPtrVec_t aSymbolSet;
    Link<SmShowSymbolSet&,void> aSelectHdlLink;
    Link<SmShowSymbolSet&,void> aDblClickHdlLink;
    tools::Long        nLen;
    sal_Int32      nRows, nColumns;
    tools::Long        nXOffset, nYOffset;
    sal_uInt16  nSelectSymbol;
    std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;

    void SetScrollBarRange();
    Point OffsetPoint(const Point &rPoint) const;

    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
    virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
    virtual bool KeyInput(const KeyEvent& rKEvt) override;
    virtual void Resize() override;

    DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);

public:
    SmShowSymbolSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow);

    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
    {
        CustomWidgetController::SetDrawingArea(pDrawingArea);
        m_aOldSize = Size(pDrawingArea->get_approximate_digit_width() * 27,
                          pDrawingArea->get_text_height() * 9);
        pDrawingArea->set_size_request(m_aOldSize.Width(), m_aOldSize.Height());
        SetOutputSizePixel(m_aOldSize);
        calccols(pDrawingArea->get_ref_device());
    }

    void calccols(const vcl::RenderContext& rRenderContext);
    void    SelectSymbol(sal_uInt16 nSymbol);
    sal_uInt16  GetSelectSymbol() const { return nSelectSymbol; }
    void SetSymbolSet(const SymbolPtrVec_t & rSymbolSet);
    void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; }
    void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; }
};

class SmShowSymbol final : public weld::CustomWidgetController
{
private:
    vcl::Font m_aFont;
    OUString m_aText;

    Link<SmShowSymbol&,void> aDblClickHdlLink;

    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
    virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;

    void setFontSize(vcl::Font &rFont) const;

public:
    SmShowSymbol();

    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
    {
        CustomWidgetController::SetDrawingArea(pDrawingArea);
        pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
                                       pDrawingArea->get_text_height() * 9);
    }

    void SetText(const OUString& rText) { m_aText = rText; }
    const OUString& GetText() const { return m_aText; }

    void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
    const vcl::Font& GetFont() const { return m_aFont; }

    void    SetSymbol(const SmSym *pSymbol);
    void    SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; }
};

class SmSymbolDialog final : public weld::GenericDialogController
{
    SmViewShell        &rViewSh;
    SmSymbolManager    &rSymbolMgr;

    OUString       aSymbolSetName;
    SymbolPtrVec_t      aSymbolSet;

    VclPtr<OutputDevice> pFontListDev;

    SmShowSymbol m_aSymbolDisplay;

    std::unique_ptr<weld::ComboBox> m_xSymbolSets;
    std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay;
    std::unique_ptr<weld::CustomWeld> m_xSymbolSetDisplayArea;
    std::unique_ptr<weld::Label> m_xSymbolName;
    std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
    std::unique_ptr<weld::Button> m_xGetBtn;
    std::unique_ptr<weld::Button> m_xEditBtn;

    DECL_LINK(SymbolSetChangeHdl, weld::ComboBox&, void);
    DECL_LINK(SymbolChangeHdl, SmShowSymbolSet&, void);
    DECL_LINK(SymbolDblClickHdl, SmShowSymbol&, void);
    DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSet&, void);
    DECL_LINK(EditClickHdl, weld::Button&, void);
    DECL_LINK(GetClickHdl, weld::Button&, void);
    void SymbolDblClickHdl();

    void            FillSymbolSets();
    const SmSym    *GetSymbol() const;

public:
    SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice,
            SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
    virtual ~SmSymbolDialog() override;

    bool    SelectSymbolSet(const OUString &rSymbolSetName);
    void    SelectSymbol(sal_uInt16 nSymbolPos);
};

class SmShowChar final : public weld::CustomWidgetController
{
private:
    OUString m_aText;
    vcl::Font m_aFont;

    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
    virtual void Resize() override;

public:
    SmShowChar()
    {
    }

    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
    {
        CustomWidgetController::SetDrawingArea(pDrawingArea);
        pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7,
                                       pDrawingArea->get_text_height() * 3);
    }

    void SetSymbol(const SmSym *pSym);
    void SetSymbol(sal_UCS4 cChar, const vcl::Font &rFont);
    void SetText(const OUString& rText) { m_aText = rText; }
    const OUString& GetText() const { return m_aText; }
    void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
    const vcl::Font& GetFont() const { return m_aFont; }
};

class SmSymDefineDialog final : public weld::GenericDialogController
{
    VclPtr<VirtualDevice> m_xVirDev;
    SmSymbolManager m_aSymbolMgrCopy;
    SmSymbolManager& m_rSymbolMgr;
    SmShowChar m_aOldSymbolDisplay;
    SmShowChar m_aSymbolDisplay;
    std::unique_ptr<SmSym> m_xOrigSymbol;
    std::unique_ptr<SubsetMap> m_xSubsetMap;
    std::unique_ptr<FontList> m_xFontList;
    std::unique_ptr<weld::ComboBox> m_xOldSymbols;
    std::unique_ptr<weld::ComboBox> m_xOldSymbolSets;
    std::unique_ptr<weld::ComboBox> m_xSymbols;
    std::unique_ptr<weld::ComboBox> m_xSymbolSets;
    std::unique_ptr<weld::ComboBox> m_xFonts;
    std::unique_ptr<weld::ComboBox> m_xFontsSubsetLB;
    std::unique_ptr<weld::ComboBox> m_xStyles;
    std::unique_ptr<weld::Label> m_xOldSymbolName;
    std::unique_ptr<weld::Label> m_xOldSymbolSetName;
    std::unique_ptr<weld::Label> m_xSymbolName;
    std::unique_ptr<weld::Label> m_xSymbolSetName;
    std::unique_ptr<weld::Button> m_xAddBtn;
    std::unique_ptr<weld::Button> m_xChangeBtn;
    std::unique_ptr<weld::Button> m_xDeleteBtn;
    std::unique_ptr<weld::CustomWeld> m_xOldSymbolDisplay;
    std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
    std::unique_ptr<SvxShowCharSet>  m_xCharsetDisplay;
    std::unique_ptr<weld::CustomWeld>  m_xCharsetDisplayArea;

    DECL_LINK(OldSymbolChangeHdl, weld::ComboBox&, void);
    DECL_LINK(OldSymbolSetChangeHdl, weld::ComboBox&, void);
    DECL_LINK(ModifyHdl, weld::ComboBox&, void);
    DECL_LINK(FontChangeHdl, weld::ComboBox&, void);
    DECL_LINK(SubsetChangeHdl, weld::ComboBox&, void);
    DECL_LINK(StyleChangeHdl, weld::ComboBox&, void);
    DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
    DECL_LINK(AddClickHdl, weld::Button&, void);
    DECL_LINK(ChangeClickHdl, weld::Button&, void);
    DECL_LINK(DeleteClickHdl, weld::Button&, void);

    void    FillSymbols(weld::ComboBox& rComboBox, bool bDeleteText = true);
    void    FillSymbolSets(weld::ComboBox& rComboBox, bool bDeleteText = true);
    void    FillFonts();
    void    FillStyles();

    void    SetSymbolSetManager(const SmSymbolManager &rMgr);
    void    SetFont(const OUString &rFontName, std::u16string_view rStyleName);
    void    SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
    void    UpdateButtons();

    bool    SelectSymbolSet(weld::ComboBox &rComboBox, std::u16string_view rSymbolSetName,
                            bool bDeleteText);
    bool    SelectSymbol(weld::ComboBox& rComboBox, const OUString &rSymbolName,
                            bool bDeleteText);
    bool    SelectFont(const OUString &rFontName, bool bApplyFont);
    bool    SelectStyle(const OUString &rStyleName, bool bApplyFont);

    SmSym* GetSymbol(const weld::ComboBox& rComboBox);
    const SmSym* GetSymbol(const weld::ComboBox& rComboBox) const
    {
        return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
    }

public:
    SmSymDefineDialog(weld::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
    virtual ~SmSymDefineDialog() override;

    virtual short run() override;

    void SelectOldSymbolSet(std::u16string_view rSymbolSetName)
    {
        SelectSymbolSet(*m_xOldSymbolSets, rSymbolSetName, false);
    }

    void SelectOldSymbol(const OUString &rSymbolName)
    {
        SelectSymbol(*m_xOldSymbols, rSymbolName, false);
    }

    bool SelectSymbolSet(std::u16string_view rSymbolSetName)
    {
        return SelectSymbolSet(*m_xSymbolSets, rSymbolSetName, false);
    }

    bool SelectSymbol(const OUString &rSymbolName)
    {
        return SelectSymbol(*m_xSymbols, rSymbolName, false);
    }

    bool        SelectFont(const OUString &rFontName)   { return SelectFont(rFontName, true); }
    bool        SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
    void        SelectChar(sal_Unicode cChar);
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */