1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEMARGINCONTROL_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEMARGINCONTROL_HXX
21 
22 #include <sfx2/tbxctrl.hxx>
23 #include <vcl/fixed.hxx>
24 #include <vcl/field.hxx>
25 #include <vcl/layout.hxx>
26 
27 #define SWPAGE_NARROW_VALUE    720
28 #define SWPAGE_NORMAL_VALUE    1136
29 #define SWPAGE_WIDE_VALUE1     1440
30 #define SWPAGE_WIDE_VALUE2     2880
31 #define SWPAGE_WIDE_VALUE3     1800
32 
33 // #i19922# - tdf#126051 see cui/source/tabpages/page.cxx and svx/source/dialog/hdft.cxx
34 static const long MINBODY = 56;  // 1mm in twips rounded
35 
36 namespace sw { namespace sidebar {
37 
38 class PageMarginControl : public SfxPopupWindow
39 {
40 public:
41     explicit PageMarginControl( sal_uInt16 nId, vcl::Window* pParent );
42     virtual ~PageMarginControl() override;
43     virtual void dispose() override;
44 
45 private:
46     VclPtr<PushButton> m_pNarrow;
47     VclPtr<PushButton> m_pNormal;
48     VclPtr<PushButton> m_pWide;
49     VclPtr<PushButton> m_pMirrored;
50     VclPtr<PushButton> m_pLast;
51 
52     VclPtr<FixedText> m_pLeft;
53     VclPtr<FixedText> m_pRight;
54     VclPtr<FixedText> m_pInner;
55     VclPtr<FixedText> m_pOuter;
56 
57     VclPtr<VclVBox> m_pContainer;
58 
59     VclPtr<MetricField> m_pLeftMarginEdit;
60     VclPtr<MetricField> m_pRightMarginEdit;
61     VclPtr<MetricField> m_pTopMarginEdit;
62     VclPtr<MetricField> m_pBottomMarginEdit;
63 
64     // hidden metric field
65     VclPtr<MetricField> m_pWidthHeightField;
66 
67     long m_nPageLeftMargin;
68     long m_nPageRightMargin;
69     long m_nPageTopMargin;
70     long m_nPageBottomMargin;
71     bool m_bMirrored;
72 
73     const MapUnit m_eUnit;
74 
75     Size m_aPageSize;
76 
77     bool m_bUserCustomValuesAvailable;
78     long m_nUserCustomPageLeftMargin;
79     long m_nUserCustomPageRightMargin;
80     long m_nUserCustomPageTopMargin;
81     long m_nUserCustomPageBottomMargin;
82     bool m_bUserCustomMirrored;
83 
84     bool m_bCustomValuesUsed;
85 
86     DECL_LINK( SelectMarginHdl, Button*, void );
87     DECL_LINK( ModifyLRMarginHdl, Edit&, void );
88     DECL_LINK( ModifyULMarginHdl, Edit&, void );
89 
90     static void ExecuteMarginLRChange(
91         const long nPageLeftMargin,
92         const long nPageRightMargin );
93     static void ExecuteMarginULChange(
94         const long nPageTopMargin,
95         const long nPageBottomMargin );
96     static void ExecutePageLayoutChange( const bool bMirrored );
97 
98     void SetMetricFieldMaxValues(const Size& rPageSize);
99 
100     bool GetUserCustomValues();
101     void StoreUserCustomValues();
102 
103     void FillHelpText( const bool bUserCustomValuesAvailable );
104 };
105 
106 } } // end of namespace sw::sidebar
107 
108 #endif
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
111