1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_INPUTWIN_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_INPUTWIN_HXX
24 #include <vcl/toolbox.hxx>
25 #include <sfx2/childwin.hxx>
26 #include <svl/lstner.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/combobox.hxx>
29 #include <vcl/scrbar.hxx>
30 #include <vcl/window.hxx>
31 #include <svtools/transfer.hxx>
33 class ScEditEngineDefaulter
;
37 class ScAccessibleEditLineTextData
;
43 class ScTextWndBase
: public vcl::Window
46 ScTextWndBase( vcl::Window
* pParent
, WinBits nStyle
);
47 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) = 0;
48 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) = 0;
49 virtual void SetTextString( const OUString
& rString
) = 0;
50 virtual const OUString
& GetTextString() const = 0;
51 virtual void StartEditEngine() = 0;
52 virtual void StopEditEngine( bool bAll
) = 0;
53 virtual EditView
* GetEditView() = 0;
54 virtual void MakeDialogEditView() = 0;
55 virtual void SetFormulaMode( bool bSet
) = 0;
56 virtual bool IsInputActive() = 0;
57 virtual void TextGrabFocus() = 0;
60 class ScTextWnd
: public ScTextWndBase
, public DragSourceHelper
// edit window
63 ScTextWnd( vcl::Window
* pParent
, ScTabViewShell
* pViewSh
);
65 virtual void dispose() SAL_OVERRIDE
;
67 virtual void SetTextString( const OUString
& rString
) SAL_OVERRIDE
;
68 virtual const OUString
& GetTextString() const SAL_OVERRIDE
;
70 bool IsInputActive() SAL_OVERRIDE
;
71 virtual EditView
* GetEditView() SAL_OVERRIDE
;
73 // for function autopilots
74 virtual void MakeDialogEditView() SAL_OVERRIDE
;
76 virtual void StartEditEngine() SAL_OVERRIDE
;
77 virtual void StopEditEngine( bool bAll
) SAL_OVERRIDE
;
79 virtual void TextGrabFocus() SAL_OVERRIDE
;
81 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
83 virtual void SetFormulaMode( bool bSet
) SAL_OVERRIDE
;
85 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible() SAL_OVERRIDE
;
87 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) SAL_OVERRIDE
;
88 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) SAL_OVERRIDE
;
90 DECL_LINK( NotifyHdl
, void* );
93 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
94 virtual void Resize() SAL_OVERRIDE
;
96 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
97 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
98 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
99 virtual void Command( const CommandEvent
& rCEvt
) SAL_OVERRIDE
;
100 virtual void KeyInput(const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
101 virtual void GetFocus() SAL_OVERRIDE
;
102 virtual void LoseFocus() SAL_OVERRIDE
;
104 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) SAL_OVERRIDE
;
106 virtual OUString
GetText() const SAL_OVERRIDE
;
108 void ImplInitSettings();
109 void UpdateAutoCorrFlag();
111 ScTabViewShell
* GetViewShell() { return mpViewShell
;}
113 typedef ::std::vector
< ScAccessibleEditLineTextData
* > AccTextDataVector
;
117 ScEditEngineDefaulter
* pEditEngine
; // only created when needed
119 AccTextDataVector maAccTextDatas
; // #i105267# text datas may be cloned, remember all copies
124 // #102710#; this flag should be true if a key input or a command is handled
125 // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
129 ScTabViewShell
* mpViewShell
;
132 class ScPosWnd
: public ComboBox
, public SfxListener
// Display position
137 sal_uLong nTipVisible
;
141 ScPosWnd( vcl::Window
* pParent
);
143 virtual void dispose() SAL_OVERRIDE
;
145 void SetPos( const OUString
& rPosStr
); // Displayed Text
146 void SetFormulaMode( bool bSet
);
149 virtual void Select() SAL_OVERRIDE
;
150 virtual void Modify() SAL_OVERRIDE
;
152 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
154 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
157 void FillRangeNames();
158 void FillFunctions();
162 void ReleaseFocus_Impl();
165 class ScInputBarGroup
;
167 class ScMultiTextWnd
: public ScTextWnd
170 ScMultiTextWnd( ScInputBarGroup
* pParent
, ScTabViewShell
* pViewSh
);
171 virtual ~ScMultiTextWnd();
172 virtual void StartEditEngine() SAL_OVERRIDE
;
173 virtual void StopEditEngine( bool bAll
) SAL_OVERRIDE
;
174 virtual void Resize() SAL_OVERRIDE
;
175 virtual EditView
* GetEditView() SAL_OVERRIDE
;
176 long GetPixelHeightForLines( long nLines
);
177 long GetEditEngTxtHeight();
180 virtual void SetTextString( const OUString
& rString
) SAL_OVERRIDE
;
181 void SetNumLines( long nLines
);
182 long GetNumLines() { return mnLines
; }
183 long GetLastNumExpandedLines() { return mnLastExpandedLines
; }
185 void SetScrollBarRange();
186 void InitEditEngine();
188 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
189 DECL_LINK( NotifyHdl
, EENotify
* );
190 DECL_LINK( ModifyHdl
, EENotify
* );
192 long GetPixelTextHeight();
193 ScInputBarGroup
& mrGroupBar
;
195 long mnLastExpandedLines
;
200 class ScInputBarGroup
: public ScTextWndBase
204 ScInputBarGroup( vcl::Window
* Parent
, ScTabViewShell
* pViewSh
);
205 virtual ~ScInputBarGroup();
206 virtual void dispose() SAL_OVERRIDE
;
207 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) SAL_OVERRIDE
;
208 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData
& rTextData
) SAL_OVERRIDE
;
209 // virtual void Paint(const Rectangle& rRect );
210 void SetTextString( const OUString
& rString
) SAL_OVERRIDE
;
211 void StartEditEngine() SAL_OVERRIDE
;
212 EditView
* GetEditView() SAL_OVERRIDE
;
213 void SetSize(Size aSize
);
214 virtual void Resize() SAL_OVERRIDE
;
215 virtual const OUString
& GetTextString() const SAL_OVERRIDE
;
216 virtual void StopEditEngine( bool bAll
) SAL_OVERRIDE
;
217 virtual void TextGrabFocus() SAL_OVERRIDE
;
218 void InitEditEngine(SfxObjectShell
* pObjSh
);
219 void SetFormulaMode( bool bSet
) SAL_OVERRIDE
;
221 void MakeDialogEditView() SAL_OVERRIDE
;
222 bool IsInputActive() SAL_OVERRIDE
;
223 ScrollBar
& GetScrollBar() { return *aScrollBar
.get(); }
224 void IncrementVerticalSize();
225 void DecrementVerticalSize();
226 long GetNumLines() { return aMultiTextWnd
->GetNumLines(); }
227 long GetVertOffset() { return nVertOffset
; }
229 void TriggerToolboxLayout();
230 VclPtr
<ScMultiTextWnd
> aMultiTextWnd
;
231 VclPtr
<ImageButton
> aButton
;
232 VclPtr
<ScrollBar
> aScrollBar
;
234 DECL_LINK( ClickHdl
, void* );
235 DECL_LINK( Impl_ScrollHdl
, void* );
239 class ScInputWindow
: public ToolBox
// Parent toolbox
242 ScInputWindow( vcl::Window
* pParent
, SfxBindings
* pBind
);
243 virtual ~ScInputWindow();
244 virtual void dispose() SAL_OVERRIDE
;
246 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
247 virtual void Resize() SAL_OVERRIDE
;
248 virtual void Select() SAL_OVERRIDE
;
250 void SetFuncString( const OUString
& rString
, bool bDoEdit
= true );
251 void SetPosString( const OUString
& rStr
);
252 void SetTextString( const OUString
& rString
);
254 void SetOkCancelMode();
255 void SetSumAssignMode();
256 void EnableButtons( bool bEnable
= true );
258 void SetFormulaMode( bool bSet
);
260 bool IsInputActive();
261 EditView
* GetEditView();
263 void TextGrabFocus();
264 void TextInvalidate();
265 void SwitchToTextWin();
269 // For function autopilots
270 void MakeDialogEditView();
272 void StopEditEngine( bool bAll
);
274 void SetInputHandler( ScInputHandler
* pNew
);
276 ScInputHandler
* GetInputHandler(){ return pInputHdl
;}
278 void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
279 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
280 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
281 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
282 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
283 bool IsMultiLineInput() { return mbIsMultiLine
; }
285 virtual void SetText( const OUString
& rString
) SAL_OVERRIDE
;
286 virtual OUString
GetText() const SAL_OVERRIDE
;
288 static bool UseSubTotal( ScRangeList
* pRangeList
);
289 bool IsPointerAtResizePos();
291 VclPtr
<ScPosWnd
> aWndPos
;
292 VclPtr
<ScTextWndBase
> pRuntimeWindow
;
293 ScTextWndBase
& aTextWindow
;
294 ScInputHandler
* pInputHdl
;
296 OUString aTextCancel
;
300 bool bIsOkCancelMode
;
305 class ScInputWindowWrapper
: public SfxChildWindow
308 ScInputWindowWrapper( vcl::Window
* pParent
,
310 SfxBindings
* pBindings
,
311 SfxChildWinInfo
* pInfo
);
313 SFX_DECL_CHILDWINDOW_WITHID(ScInputWindowWrapper
);
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */