Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / inputwin.hxx
blob4930da17fe578b282f1681d30b12e14b5a3d991f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <vector>
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 Accelerator;
34 class EditView;
35 class ScAccessibleEditLineTextData;
36 class ScEditEngineDefaulter;
37 class ScInputBarGroup;
38 class ScInputHandler;
39 class ScRangeList;
40 class ScTabViewShell;
41 struct EENotify;
42 struct ESelection;
44 class ScTextWndBase : public vcl::Window
46 public:
47 ScTextWndBase( vcl::Window* pParent, WinBits nStyle );
48 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
49 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
50 virtual void SetTextString( const OUString& rString ) = 0;
51 virtual const OUString& GetTextString() const = 0;
52 virtual void StartEditEngine() = 0;
53 virtual void StopEditEngine( bool bAll ) = 0;
54 virtual EditView* GetEditView() = 0;
55 virtual void MakeDialogEditView() = 0;
56 virtual void SetFormulaMode( bool bSet ) = 0;
57 virtual bool IsInputActive() = 0;
58 virtual void TextGrabFocus() = 0;
61 class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
63 public:
64 ScTextWnd(ScInputBarGroup* pParent, ScTabViewShell* pViewSh);
65 virtual ~ScTextWnd();
66 virtual void dispose() override;
68 virtual void SetTextString( const OUString& rString ) override;
69 virtual const OUString& GetTextString() const override;
71 bool IsInputActive() override;
72 virtual EditView* GetEditView() override;
74 // for function autopilots
75 virtual void MakeDialogEditView() override;
77 virtual void StartEditEngine() override;
78 virtual void StopEditEngine( bool bAll ) override;
80 virtual void TextGrabFocus() override;
82 virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
84 virtual void SetFormulaMode( bool bSet ) override;
86 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
88 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override;
89 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override;
91 virtual void Resize() override;
93 long GetPixelHeightForLines(long nLines);
94 long GetEditEngTxtHeight();
96 long GetNumLines() { return mnLines; }
97 void SetNumLines(long nLines);
98 long GetLastNumExpandedLines() { return mnLastExpandedLines; }
100 void DoScroll();
102 DECL_LINK_TYPED(NotifyHdl, EENotify&, void);
103 DECL_LINK_TYPED(ModifyHdl, LinkParamNone*, void);
105 protected:
106 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override;
108 virtual void MouseMove( const MouseEvent& rMEvt ) override;
109 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
110 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
111 virtual void Command( const CommandEvent& rCEvt ) override;
112 virtual void KeyInput(const KeyEvent& rKEvt) override;
113 virtual void GetFocus() override;
114 virtual void LoseFocus() override;
116 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
118 virtual OUString GetText() const override;
120 void ImplInitSettings();
121 void UpdateAutoCorrFlag();
123 void SetScrollBarRange();
125 void InitEditEngine();
127 ScTabViewShell* GetViewShell() { return mpViewShell;}
129 typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
131 OUString aString;
132 vcl::Font aTextFont;
133 ScEditEngineDefaulter* pEditEngine; // only created when needed
134 EditView* pEditView;
135 AccTextDataVector maAccTextDatas; // #i105267# text datas may be cloned, remember all copies
136 bool bIsRTL;
137 bool bIsInsertMode;
138 bool bFormulaMode;
140 // #102710#; this flag should be true if a key input or a command is handled
141 // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
142 bool bInputMode;
144 private:
145 ScTabViewShell* mpViewShell;
146 ScInputBarGroup& mrGroupBar;
147 long mnLines;
148 long mnLastExpandedLines;
149 long mnBorderHeight;
150 bool mbInvalidate;
153 class ScPosWnd : public ComboBox, public SfxListener // Display position
155 private:
156 OUString aPosStr;
157 sal_uLong nTipVisible;
158 bool bFormulaMode;
160 public:
161 ScPosWnd( vcl::Window* pParent );
162 virtual ~ScPosWnd();
163 virtual void dispose() override;
165 void SetPos( const OUString& rPosStr ); // Displayed Text
166 void SetFormulaMode( bool bSet );
168 protected:
169 virtual void Select() override;
170 virtual void Modify() override;
172 virtual bool Notify( NotifyEvent& rNEvt ) override;
174 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
176 private:
177 void FillRangeNames();
178 void FillFunctions();
179 void DoEnter();
180 void HideTip();
182 void ReleaseFocus_Impl();
185 class ScInputBarGroup : public ScTextWndBase
188 public:
189 ScInputBarGroup( vcl::Window* Parent, ScTabViewShell* pViewSh );
190 virtual ~ScInputBarGroup();
191 virtual void dispose() override;
192 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override;
193 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) override;
194 void SetTextString( const OUString& rString ) override;
195 void StartEditEngine() override;
196 EditView* GetEditView() override;
197 virtual void Resize() override;
198 virtual const OUString& GetTextString() const override;
199 virtual void StopEditEngine( bool bAll ) override;
200 virtual void TextGrabFocus() override;
201 void SetFormulaMode( bool bSet ) override;
202 void MakeDialogEditView() override;
203 bool IsInputActive() override;
204 ScrollBar& GetScrollBar() { return *maScrollbar.get(); }
205 void IncrementVerticalSize();
206 void DecrementVerticalSize();
207 long GetNumLines() { return maTextWnd->GetNumLines(); }
208 long GetVertOffset() { return mnVertOffset; }
210 private:
211 void TriggerToolboxLayout();
213 VclPtr<ScTextWnd> maTextWnd;
214 VclPtr<ImageButton> maButton;
215 VclPtr<ScrollBar> maScrollbar;
216 long mnVertOffset;
218 DECL_LINK_TYPED( ClickHdl, Button*, void );
219 DECL_LINK_TYPED( Impl_ScrollHdl, ScrollBar*, void );
222 class ScInputWindow : public ToolBox // Parent toolbox
224 public:
225 ScInputWindow( vcl::Window* pParent, SfxBindings* pBind );
226 virtual ~ScInputWindow();
227 virtual void dispose() override;
229 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override;
230 virtual void Resize() override;
231 virtual void Select() override;
233 void SetFuncString( const OUString& rString, bool bDoEdit = true );
234 void SetPosString( const OUString& rStr );
235 void SetTextString( const OUString& rString );
237 void SetOkCancelMode();
238 void SetSumAssignMode();
239 void EnableButtons( bool bEnable = true );
241 void SetFormulaMode( bool bSet );
243 bool IsInputActive();
244 EditView* GetEditView();
246 void TextGrabFocus();
247 void TextInvalidate();
248 void SwitchToTextWin();
250 void PosGrabFocus();
252 // For function autopilots
253 void MakeDialogEditView();
255 void StopEditEngine( bool bAll );
257 void SetInputHandler( ScInputHandler* pNew );
259 ScInputHandler* GetInputHandler(){ return pInputHdl;}
261 void StateChanged( StateChangedType nType ) override;
262 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
263 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
264 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
265 virtual void MouseMove( const MouseEvent& rMEvt ) override;
267 protected:
268 virtual void SetText( const OUString& rString ) override;
269 virtual OUString GetText() const override;
271 static bool UseSubTotal( ScRangeList* pRangeList );
272 bool IsPointerAtResizePos();
274 private:
275 VclPtr<ScPosWnd> aWndPos;
276 VclPtr<ScTextWndBase> pRuntimeWindow;
277 ScTextWndBase& aTextWindow;
278 ScInputHandler* pInputHdl;
279 OUString aTextOk;
280 OUString aTextCancel;
281 OUString aTextSum;
282 OUString aTextEqual;
283 long mnMaxY;
284 bool bIsOkCancelMode;
285 bool bInResize;
288 class ScInputWindowWrapper : public SfxChildWindow
290 public:
291 ScInputWindowWrapper( vcl::Window* pParent,
292 sal_uInt16 nId,
293 SfxBindings* pBindings,
294 SfxChildWinInfo* pInfo );
296 SFX_DECL_CHILDWINDOW_WITHID(ScInputWindowWrapper);
299 #endif
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */