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 
20 #ifndef INCLUDED_FORMULA_SOURCE_UI_DLG_PARAWIN_HXX
21 #define INCLUDED_FORMULA_SOURCE_UI_DLG_PARAWIN_HXX
22 
23 #include <formula/funcutl.hxx>
24 #include <vcl/weld.hxx>
25 #include "ControlHelper.hxx"
26 #include <vector>
27 
28 namespace formula
29 {
30 
31 #define NOT_FOUND 0xffff
32 
33 class IFunctionDescription;
34 class IControlReferenceHandler;
35 
36 class ParaWin
37 {
38 private:
39         Link<ParaWin&,void>  aFxLink;
40         Link<ParaWin&,void>  aArgModifiedLink;
41 
42         ::std::vector<sal_uInt16>   aVisibleArgMapping;
43         const IFunctionDescription* pFuncDesc;
44         IControlReferenceHandler*   pMyParent;
45         sal_uInt16       nArgs;     // unsuppressed arguments, may be >= VAR_ARGS to indicate repeating parameters
46         sal_uInt16       nMaxArgs;  // max arguments, limited to supported number of arguments
47         vcl::Font        aFntBold;
48         vcl::Font        aFntLight;
49 
50         OUString        m_sOptional;
51         OUString        m_sRequired;
52 
53         sal_uInt16      nEdFocus;
54         sal_uInt16      nActiveLine;
55 
56         ArgInput        aArgInput[4];
57         OUString        aDefaultString;
58         ::std::vector<OUString> aParaArray;
59 
60         std::unique_ptr<weld::Builder> m_xBuilder;
61         std::unique_ptr<weld::Container> m_xContainer;
62 
63         std::unique_ptr<weld::ScrolledWindow> m_xSlider;
64         std::unique_ptr<weld::Widget> m_xParamGrid;
65         std::unique_ptr<weld::Widget> m_xGrid;
66 
67         std::unique_ptr<weld::Label> m_xFtEditDesc;
68         std::unique_ptr<weld::Label> m_xFtArgName;
69         std::unique_ptr<weld::Label> m_xFtArgDesc;
70 
71         std::unique_ptr<weld::Button> m_xBtnFx1;
72         std::unique_ptr<weld::Button> m_xBtnFx2;
73         std::unique_ptr<weld::Button> m_xBtnFx3;
74         std::unique_ptr<weld::Button> m_xBtnFx4;
75 
76         std::unique_ptr<weld::Label> m_xFtArg1;
77         std::unique_ptr<weld::Label> m_xFtArg2;
78         std::unique_ptr<weld::Label> m_xFtArg3;
79         std::unique_ptr<weld::Label> m_xFtArg4;
80 
81         std::unique_ptr<ArgEdit> m_xEdArg1;
82         std::unique_ptr<ArgEdit> m_xEdArg2;
83         std::unique_ptr<ArgEdit> m_xEdArg3;
84         std::unique_ptr<ArgEdit> m_xEdArg4;
85 
86         std::unique_ptr<RefButton> m_xRefBtn1;
87         std::unique_ptr<RefButton> m_xRefBtn2;
88         std::unique_ptr<RefButton> m_xRefBtn3;
89         std::unique_ptr<RefButton> m_xRefBtn4;
90 
91         DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void);
92         DECL_LINK( ModifyHdl, ArgInput&, void );
93         DECL_LINK( GetEdFocusHdl, ArgInput&, void );
94         DECL_LINK( GetFxFocusHdl, ArgInput&, void );
95         DECL_LINK( GetFxHdl, ArgInput&, void );
96 
97         void            ArgumentModified();
98 
99         void            InitArgInput(sal_uInt16 nPos, weld::Label& rFtArg, weld::Button& rBtnFx,
100                                      ArgEdit& rEdArg, RefButton& rRefBtn);
101 
102         void            SetArgumentDesc(const OUString& aText);
103         void            SetArgumentText(const OUString& aText);
104 
105 
106         void            SetArgName      (sal_uInt16 no,const OUString &aArg);
107         void            SetArgNameFont  (sal_uInt16 no,const vcl::Font&);
108 
109         void            UpdateArgDesc( sal_uInt16 nArg );
110         void            UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i );
111 
112 public:
113         ParaWin(weld::Container* pParent, IControlReferenceHandler* _pDlg);
114         ~ParaWin();
115 
116         void            SetFunctionDesc(const IFunctionDescription* pFDesc);
117         void            SetArgumentOffset(sal_uInt16 nOffset);
118         void            SetEditDesc(const OUString& aText);
119         void            UpdateParas();
120         void            ClearAll();
121 
GetActiveLine() const122         sal_uInt16      GetActiveLine() const { return nActiveLine;}
123         void            SetActiveLine(sal_uInt16 no);
124         RefEdit*    GetActiveEdit();
125         OUString        GetActiveArgName() const;
126 
127         OUString        GetArgument(sal_uInt16 no);
128         void            SetArgument(sal_uInt16 no, const OUString& aString);
129         void            SetArgumentFonts(const vcl::Font& aBoldFont,const vcl::Font& aLightFont);
130 
131         void            SetEdFocus(); // visible edit lines
132         sal_uInt16      GetSliderPos() const;
133         void            SetSliderPos(sal_uInt16 nSliderPos);
134 
SetArgModifiedHdl(const Link<ParaWin &,void> & rLink)135         void            SetArgModifiedHdl( const Link<ParaWin&,void>& rLink ) { aArgModifiedLink = rLink; }
SetFxHdl(const Link<ParaWin &,void> & rLink)136         void            SetFxHdl( const Link<ParaWin&,void>& rLink ) { aFxLink = rLink; }
137 
138         void            SliderMoved();
139 
Show()140         void            Show() { m_xContainer->show(); }
141 };
142 
143 
144 } // formula
145 
146 #endif // INCLUDED_FORMULA_SOURCE_UI_DLG_PARAWIN_HXX
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
149