summaryrefslogtreecommitdiff
path: root/sw/source/ui/envelp/labfmt.hxx
blob: 5a7258f7e73a7a4b59b78e9522e1a27b1a88d461 (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
/* -*- 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 .
 */
#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_LABFMT_HXX
#define INCLUDED_SW_SOURCE_UI_ENVELP_LABFMT_HXX

#include "swuilabimp.hxx"
#include <labimg.hxx>
#include <vcl/idle.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>

class SwLabFormatPage;

class SwLabPreview : public weld::CustomWidgetController
{
    Color const m_aGrayColor;

    OUString const m_aHDistStr;
    OUString const m_aVDistStr;
    OUString const m_aWidthStr;
    OUString const m_aHeightStr;
    OUString const m_aLeftStr;
    OUString const m_aUpperStr;
    OUString const m_aColsStr;
    OUString const m_aRowsStr;

    long m_lHDistWidth;
    long m_lVDistWidth;
    long m_lHeightWidth;
    long m_lLeftWidth;
    long m_lUpperWidth;
    long m_lColsWidth;

    long m_lXWidth;
    long m_lXHeight;

    SwLabItem m_aItem;

    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;

public:

    SwLabPreview();

    void UpdateItem(const SwLabItem& rItem);
};

class SwLabFormatPage : public SfxTabPage
{
    Idle aPreviewIdle;
    SwLabItem aItem;
    bool bModified;

    SwLabPreview m_aPreview;

    std::unique_ptr<weld::Label>  m_xMakeFI;
    std::unique_ptr<weld::Label>  m_xTypeFI;
    std::unique_ptr<weld::CustomWeld> m_xPreview;
    std::unique_ptr<weld::MetricSpinButton>  m_xHDistField;
    std::unique_ptr<weld::MetricSpinButton>  m_xVDistField;
    std::unique_ptr<weld::MetricSpinButton>  m_xWidthField;
    std::unique_ptr<weld::MetricSpinButton>  m_xHeightField;
    std::unique_ptr<weld::MetricSpinButton>  m_xLeftField;
    std::unique_ptr<weld::MetricSpinButton>  m_xUpperField;
    std::unique_ptr<weld::SpinButton> m_xColsField;
    std::unique_ptr<weld::SpinButton> m_xRowsField;
    std::unique_ptr<weld::MetricSpinButton>  m_xPWidthField;
    std::unique_ptr<weld::MetricSpinButton>  m_xPHeightField;
    std::unique_ptr<weld::Button> m_xSavePB;


    DECL_LINK( ModifyHdl, weld::SpinButton&, void );
    DECL_LINK( MetricModifyHdl, weld::MetricSpinButton&, void );
    DECL_LINK( PreviewHdl, Timer *, void );
    DECL_LINK( SaveHdl, weld::Button&, void );

    void ChangeMinMax();

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;

public:
    SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet);
    virtual ~SwLabFormatPage() override;

    static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);

    virtual void ActivatePage(const SfxItemSet& rSet) override;
    virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
            void FillItem(SwLabItem& rItem);
    virtual bool FillItemSet(SfxItemSet* rSet) override;
    virtual void Reset(const SfxItemSet* rSet) override;

    SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());}
};

class SwSaveLabelDlg : public weld::GenericDialogController
{
    bool        bSuccess;
    SwLabDlg*   m_pLabDialog;
    SwLabRec&   rLabRec;

    std::unique_ptr<weld::ComboBox> m_xMakeCB;
    std::unique_ptr<weld::Entry>        m_xTypeED;
    std::unique_ptr<weld::Button>       m_xOKPB;

    DECL_LINK(OkHdl, weld::Button&, void);
    DECL_LINK(ModifyEntryHdl, weld::Entry&, void);
    DECL_LINK(ModifyComboHdl, weld::ComboBox&, void);

    void Modify();

public:
    SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec);
    virtual ~SwSaveLabelDlg() override;

    void SetLabel(const OUString& rMake, const OUString& rType)
    {
        m_xMakeCB->set_entry_text(rMake);
        m_xTypeED->set_text(rType);
    }
    bool GetLabel(SwLabItem& rItem);
};
#endif

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