Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / inputwin.hxx
blobff44c57ebe60f1e4e77c6c7b8ae93861bb974f3b
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 SC_INPUTWIN_HXX
21 #define SC_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 ScEditEngineDefaulter;
34 class EditView;
35 struct ESelection;
36 class ScInputHandler;
37 class ScAccessibleEditLineTextData;
38 struct EENotify;
39 class ScRangeList;
40 class ScTabViewShell;
42 //========================================================================
44 class ScTextWndBase : public Window
46 public:
47 ScTextWndBase( 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( sal_Bool bAll ) = 0;
54 virtual EditView* GetEditView() = 0;
55 virtual void MakeDialogEditView() = 0;
56 virtual void SetFormulaMode( sal_Bool bSet ) = 0;
57 virtual sal_Bool IsInputActive() = 0;
58 virtual void TextGrabFocus() = 0;
61 class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
63 public:
64 ScTextWnd( Window* pParent, ScTabViewShell* pViewSh );
65 virtual ~ScTextWnd();
67 virtual void SetTextString( const OUString& rString );
68 virtual const OUString& GetTextString() const;
70 sal_Bool IsInputActive();
71 virtual EditView* GetEditView();
73 // for function autopilots
74 virtual void MakeDialogEditView();
76 virtual void StartEditEngine();
77 virtual void StopEditEngine( sal_Bool bAll );
79 virtual void TextGrabFocus();
81 virtual void DataChanged( const DataChangedEvent& rDCEvt );
83 virtual void SetFormulaMode( sal_Bool bSet );
85 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
87 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
88 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
90 DECL_LINK( NotifyHdl, void* );
92 protected:
93 virtual void Paint( const Rectangle& rRect );
94 virtual void Resize();
96 virtual void MouseMove( const MouseEvent& rMEvt );
97 virtual void MouseButtonDown( const MouseEvent& rMEvt );
98 virtual void MouseButtonUp( const MouseEvent& rMEvt );
99 virtual void Command( const CommandEvent& rCEvt );
100 virtual void KeyInput(const KeyEvent& rKEvt);
101 virtual void GetFocus();
102 virtual void LoseFocus();
104 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
106 virtual OUString GetText() const;
108 void ImplInitSettings();
109 void UpdateAutoCorrFlag();
111 ScTabViewShell* GetViewShell();
113 typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
115 OUString aString;
116 Font aTextFont;
117 ScEditEngineDefaulter* pEditEngine; // only created when needed
118 EditView* pEditView;
119 AccTextDataVector maAccTextDatas; // #i105267# text datas may be cloned, remember all copies
120 sal_Bool bIsRTL;
121 sal_Bool bIsInsertMode;
122 sal_Bool bFormulaMode;
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
126 sal_Bool bInputMode;
128 private:
129 ScTabViewShell* mpViewShell;
132 //========================================================================
134 class ScPosWnd : public ComboBox, public SfxListener // Display position
136 private:
137 OUString aPosStr;
138 Accelerator* pAccel;
139 sal_uLong nTipVisible;
140 sal_Bool bFormulaMode;
142 public:
143 ScPosWnd( Window* pParent );
144 virtual ~ScPosWnd();
146 void SetPos( const OUString& rPosStr ); // Displayed Text
147 void SetFormulaMode( sal_Bool bSet );
149 protected:
150 virtual void Select();
151 virtual void Modify();
153 virtual long Notify( NotifyEvent& rNEvt );
155 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
157 private:
158 void FillRangeNames();
159 void FillFunctions();
160 void DoEnter();
161 void HideTip();
163 void ReleaseFocus_Impl();
166 //========================================================================
167 class ScInputBarGroup;
169 class ScMultiTextWnd : public ScTextWnd
171 public:
172 ScMultiTextWnd( ScInputBarGroup* pParent, ScTabViewShell* pViewSh );
173 virtual ~ScMultiTextWnd();
174 virtual void StartEditEngine();
175 virtual void StopEditEngine( sal_Bool bAll );
176 virtual void Resize();
177 virtual EditView* GetEditView();
178 long GetPixelHeightForLines( long nLines );
179 long GetEditEngTxtHeight();
181 void DoScroll();
182 virtual void SetTextString( const OUString& rString );
183 void SetNumLines( long nLines );
184 long GetNumLines() { return mnLines; }
185 long GetLastNumExpandedLines() { return mnLastExpandedLines; }
186 protected:
187 void SetScrollBarRange();
188 void InitEditEngine();
190 virtual void Paint( const Rectangle& rRect );
191 DECL_LINK( NotifyHdl, EENotify* );
192 DECL_LINK( ModifyHdl, EENotify* );
193 private:
194 long GetPixelTextHeight();
195 ScInputBarGroup& mrGroupBar;
196 long mnLines;
197 long mnLastExpandedLines;
198 long mnBorderHeight;
199 bool mbInvalidate;
202 class ScInputBarGroup : public ScTextWndBase
205 public:
206 ScInputBarGroup( Window* Parent, ScTabViewShell* pViewSh );
207 virtual ~ScInputBarGroup();
208 virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
209 virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
210 // virtual void Paint(const Rectangle& rRect );
211 void SetTextString( const OUString& rString );
212 void StartEditEngine();
213 EditView* GetEditView();
214 void SetSize(Size aSize);
215 virtual void Resize();
216 virtual const OUString& GetTextString() const;
217 virtual void StopEditEngine( sal_Bool bAll );
218 virtual void TextGrabFocus();
219 void InitEditEngine(SfxObjectShell* pObjSh);
220 void SetFormulaMode( sal_Bool bSet );
221 bool IsFocus();
222 void MakeDialogEditView();
223 sal_Bool IsInputActive();
224 ScrollBar& GetScrollBar() { return aScrollBar; }
225 void IncrementVerticalSize();
226 void DecrementVerticalSize();
227 long GetNumLines() { return aMultiTextWnd.GetNumLines(); }
228 long GetVertOffset() { return nVertOffset; }
229 private:
230 void TriggerToolboxLayout();
231 ScMultiTextWnd aMultiTextWnd;
232 ImageButton aButton;
233 ScrollBar aScrollBar;
234 long nVertOffset;
235 DECL_LINK( ClickHdl, void* );
236 DECL_LINK( Impl_ScrollHdl, void* );
241 class ScInputWindow : public ToolBox // Parent toolbox
243 public:
244 ScInputWindow( Window* pParent, SfxBindings* pBind );
245 virtual ~ScInputWindow();
247 virtual void Paint( const Rectangle& rRect );
248 virtual void Resize();
249 virtual void Select();
251 void SetFuncString( const OUString& rString, sal_Bool bDoEdit = sal_True );
252 void SetPosString( const OUString& rStr );
253 void SetTextString( const OUString& rString );
255 void SetOkCancelMode();
256 void SetSumAssignMode();
257 void EnableButtons( sal_Bool bEnable = sal_True );
259 void SetFormulaMode( sal_Bool bSet );
261 virtual sal_Bool IsInputActive();
262 EditView* GetEditView();
264 void TextGrabFocus();
265 void TextInvalidate();
266 void SwitchToTextWin();
268 void PosGrabFocus();
270 // For function autopilots
271 void MakeDialogEditView();
273 void StopEditEngine( sal_Bool bAll );
275 void SetInputHandler( ScInputHandler* pNew );
277 ScInputHandler* GetInputHandler(){ return pInputHdl;}
279 void StateChanged( StateChangedType nType );
280 virtual void DataChanged( const DataChangedEvent& rDCEvt );
281 virtual void MouseButtonUp( const MouseEvent& rMEvt );
282 virtual void MouseButtonDown( const MouseEvent& rMEvt );
283 virtual void MouseMove( const MouseEvent& rMEvt );
284 bool IsMultiLineInput() { return mbIsMultiLine; }
285 protected:
286 virtual void SetText( const OUString& rString );
287 virtual OUString GetText() const;
289 bool UseSubTotal( ScRangeList* pRangeList ) const;
290 bool IsPointerAtResizePos();
291 private:
292 ScPosWnd aWndPos;
293 std::auto_ptr<ScTextWndBase> pRuntimeWindow;
294 ScTextWndBase& aTextWindow;
295 ScInputHandler* pInputHdl;
296 OUString aTextOk;
297 OUString aTextCancel;
298 OUString aTextSum;
299 OUString aTextEqual;
300 long mnMaxY;
301 sal_Bool bIsOkCancelMode;
302 bool bInResize;
303 bool mbIsMultiLine;
306 //==================================================================
308 class ScInputWindowWrapper : public SfxChildWindow
310 public:
311 ScInputWindowWrapper( Window* pParent,
312 sal_uInt16 nId,
313 SfxBindings* pBindings,
314 SfxChildWinInfo* pInfo );
316 SFX_DECL_CHILDWINDOW_WITHID(ScInputWindowWrapper);
320 #endif
322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */