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 FORMULA_CONTROL_HELPER_HXX_INCLUDED
24 #define FORMULA_CONTROL_HELPER_HXX_INCLUDED
25 
26 #include "formula/funcutl.hxx"
27 #include <svtools/svmedit.hxx>
28 namespace formula
29 {
30 
31 //============================================================================
32 // class ValWnd
33 class ValWnd : public Window
34 {
35 public:
36 			ValWnd( Window* pParent, const ResId& rId );
37 
38 	void	SetValue( const String& rStrVal );
39 
40 protected:
41 	virtual void	Paint( const Rectangle& rRect );
42 
43 private:
44 	String		aStrValue;
45 	Rectangle	aRectOut;
46 };
47 
48 //============================================================================
49 // class EditBox
50 class EditBox : public Control
51 {
52 private:
53 
54 	MultiLineEdit*	pMEdit;
55 	Link			aSelChangedLink;
56 	Selection		aOldSel;
57 	sal_Bool			bMouseFlag;
58 					DECL_LINK( ChangedHdl, EditBox* );
59 
60 protected:
61 
62 	virtual long	PreNotify( NotifyEvent& rNEvt );
63 	virtual void	SelectionChanged();
64 	virtual void	Resize();
65 	virtual void	GetFocus();
66 
67 
68 public:
69 					EditBox( Window* pParent,
70 								WinBits nWinStyle = WB_LEFT | WB_BORDER );
71 					EditBox( Window* pParent, const ResId& rResId );
72 
73 					virtual ~EditBox();
74 
GetEdit()75 	MultiLineEdit*	GetEdit() {return pMEdit;}
76 
SetSelChangedHdl(const Link & rLink)77 	void            SetSelChangedHdl( const Link& rLink ) { aSelChangedLink = rLink; }
GetSelChangedHdl() const78 	const Link&     GetSelChangedHdl() const { return aSelChangedLink; }
79 
80 	void			UpdateOldSel();
81 };
82 
83 //============================================================================
84 // class ArgEdit
85 
86 class ArgEdit : public RefEdit
87 {
88 public:
89 			ArgEdit( Window* pParent, const ResId& rResId );
90 
91 	void	Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
92 				  ScrollBar& rArgSlider, sal_uInt16 nArgCount );
93 
94 protected:
95 	virtual void	KeyInput( const KeyEvent& rKEvt );
96 
97 private:
98 	ArgEdit*	pEdPrev;
99 	ArgEdit*	pEdNext;
100 	ScrollBar*	pSlider;
101 	sal_uInt16		nArgs;
102 };
103 
104 
105 //============================================================================
106 // class ArgInput
107 
108 class ArgInput
109 {
110 private:
111 
112 	Link			aFxClickLink;
113 	Link			aRefClickLink;
114 	Link			aFxFocusLink;
115 	Link			aRefFocusLink;
116 	Link			aEdFocusLink;
117 	Link			aEdModifyLink;
118 
119 	FixedText*		pFtArg;
120 	ImageButton*	pBtnFx;
121 	ArgEdit*		pEdArg;
122 	RefButton*	pRefBtn;
123 
124 	DECL_LINK(	FxBtnClickHdl, ImageButton* );
125 	DECL_LINK(	RefBtnClickHdl,RefButton* );
126 	DECL_LINK(	FxBtnFocusHdl, ImageButton* );
127 	DECL_LINK(	RefBtnFocusHdl,RefButton* );
128 	DECL_LINK(	EdFocusHdl, ArgEdit* );
129 	DECL_LINK(	EdModifyHdl,ArgEdit* );
130 
131 protected:
132 
133 	virtual void	FxClick();
134 	virtual void	RefClick();
135 	virtual void	FxFocus();
136 	virtual void	RefFocus();
137 	virtual void	EdFocus();
138 	virtual void	EdModify();
139 
140 public:
141 
142 	ArgInput();
143 
144 	void		InitArgInput (	FixedText*		pftArg,
145 								ImageButton*	pbtnFx,
146 								ArgEdit*		pedArg,
147 								RefButton*	prefBtn);
148 
149 	void		SetArgName(const String &aArg);
150 	String		GetArgName();
151 	void		SetArgNameFont(const Font&);
152 
153 	void		SetArgVal(const String &aVal);
154 	String		GetArgVal();
155 
156 	void		SetArgSelection	(const Selection& rSel );
157 	void		ReplaceSelOfArg	(const String& rStr );
158 
159 	Selection	GetArgSelection();
160 
161 
GetArgEdPtr()162 	ArgEdit*	GetArgEdPtr() {return pEdArg;}
163 
164 
SetFxClickHdl(const Link & rLink)165 	void            SetFxClickHdl( const Link& rLink ) { aFxClickLink = rLink; }
GetFxClickHdl() const166 	const Link&     GetFxClickHdl() const { return aFxClickLink; }
167 
SetRefClickHdl(const Link & rLink)168 	void            SetRefClickHdl( const Link& rLink ) { aRefClickLink = rLink; }
GetRefClickHdl() const169 	const Link&     GetRefClickHdl() const { return aRefClickLink; }
170 
SetFxFocusHdl(const Link & rLink)171 	void            SetFxFocusHdl( const Link& rLink ) { aFxFocusLink = rLink; }
GetFxFocusHdl() const172 	const Link&     GetFxFocusHdl() const { return aFxFocusLink; }
173 
SetRefFocusHdl(const Link & rLink)174 	void            SetRefFocusHdl( const Link& rLink ) { aRefFocusLink = rLink; }
GetRefFocusHdl() const175 	const Link&     GetRefFocusHdl() const { return aRefFocusLink; }
176 
SetEdFocusHdl(const Link & rLink)177 	void            SetEdFocusHdl( const Link& rLink ) { aEdFocusLink = rLink; }
GetEdFocusHdl() const178 	const Link&     GetEdFocusHdl() const { return aEdFocusLink; }
179 
SetEdModifyHdl(const Link & rLink)180 	void            SetEdModifyHdl( const Link& rLink ) { aEdModifyLink = rLink; }
GetEdModifyHdl() const181 	const Link&     GetEdModifyHdl() const { return aEdModifyLink; }
182 
183 	void Hide();
184 	void Show();
185 
186 	void UpdateAccessibleNames();
187 };
188 
189 }
190 #endif // FORMULA_FORMULA_HELPER_HXX_INCLUDED
191