bump product version to 5.0.4.1
[LibreOffice.git] / starmath / inc / view.hxx
blob952dfac9fe8c115076edb85021f629e2c9e16a86
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 .
19 #ifndef INCLUDED_STARMATH_INC_VIEW_HXX
20 #define INCLUDED_STARMATH_INC_VIEW_HXX
22 #include <sal/config.h>
24 #include <memory>
26 #include <sfx2/dockwin.hxx>
27 #include <sfx2/viewsh.hxx>
28 #include <svtools/scrwin.hxx>
29 #include <sfx2/ctrlitem.hxx>
30 #include <sfx2/shell.hxx>
31 #include <sfx2/viewfac.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <vcl/timer.hxx>
34 #include <svtools/colorcfg.hxx>
35 #include "document.hxx"
36 #include "edit.hxx"
37 #include "node.hxx"
39 class Menu;
40 class DataChangedEvent;
41 class SmClipboardChangeListener;
42 class SmDocShell;
43 class SmViewShell;
44 class SmPrintUIOptions;
45 class SmGraphicAccessible;
47 class SmGraphicWindow : public ScrollableWindow
49 Point aFormulaDrawPos;
50 // old style editing pieces
51 Rectangle aCursorRect;
52 bool bIsCursorVisible;
53 bool bIsLineVisible;
54 AutoTimer aCaretBlinkTimer;
55 public:
56 bool IsCursorVisible() const
58 return bIsCursorVisible;
60 void ShowCursor(bool bShow);
61 bool IsLineVisible() const
63 return bIsLineVisible;
65 void ShowLine(bool bShow);
66 const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
67 protected:
68 void SetIsCursorVisible(bool bVis)
70 bIsCursorVisible = bVis;
72 using Window::SetCursor;
73 void SetCursor(const SmNode *pNode);
74 void SetCursor(const Rectangle &rRect);
75 bool IsInlineEditEnabled() const;
77 private:
78 css::uno::Reference<css::accessibility::XAccessible> xAccessible;
79 SmGraphicAccessible* pAccessible;
81 SmViewShell* pViewShell;
82 sal_uInt16 nZoom;
84 protected:
85 void SetFormulaDrawPos(const Point &rPos)
87 aFormulaDrawPos = rPos;
90 virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
91 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
92 virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
93 virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
94 virtual void StateChanged( StateChangedType eChanged ) SAL_OVERRIDE;
95 DECL_LINK(MenuSelectHdl, Menu*);
97 private:
98 void RepaintViewShellDoc();
99 DECL_LINK_TYPED(CaretBlinkTimerHdl, Timer *, void);
100 void CaretBlinkInit();
101 void CaretBlinkStart();
102 void CaretBlinkStop();
103 public:
104 SmGraphicWindow(SmViewShell* pShell);
105 virtual ~SmGraphicWindow();
106 virtual void dispose() SAL_OVERRIDE;
108 // Window
109 virtual void MouseButtonDown(const MouseEvent &rMEvt) SAL_OVERRIDE;
110 virtual void MouseMove(const MouseEvent &rMEvt) SAL_OVERRIDE;
111 virtual void GetFocus() SAL_OVERRIDE;
112 virtual void LoseFocus() SAL_OVERRIDE;
114 SmViewShell* GetView()
116 return pViewShell;
119 using Window::SetZoom;
120 void SetZoom(sal_uInt16 Factor);
121 using Window::GetZoom;
122 sal_uInt16 GetZoom() const
124 return nZoom;
127 const Point& GetFormulaDrawPos() const
129 return aFormulaDrawPos;
132 void ZoomToFitInWindow();
133 using ScrollableWindow::SetTotalSize;
134 void SetTotalSize();
136 void ApplyColorConfigValues(const svtools::ColorConfig &rColorCfg);
138 // for Accessibility
139 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
141 using Window::GetAccessible;
142 SmGraphicAccessible* GetAccessible_Impl()
144 return pAccessible;
148 class SmGraphicController: public SfxControllerItem
150 protected:
151 SmGraphicWindow &rGraphic;
152 public:
153 SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
154 virtual void StateChanged(sal_uInt16 nSID,
155 SfxItemState eState,
156 const SfxPoolItem* pState) SAL_OVERRIDE;
159 class SmEditController: public SfxControllerItem
161 protected:
162 SmEditWindow &rEdit;
164 public:
165 SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
166 #if OSL_DEBUG_LEVEL > 1
167 virtual ~SmEditController();
168 #endif
170 virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) SAL_OVERRIDE;
173 class SmCmdBoxWindow : public SfxDockingWindow
175 VclPtr<SmEditWindow> aEdit;
176 SmEditController aController;
177 bool bExiting;
179 Timer aInitialFocusTimer;
181 DECL_LINK_TYPED(InitialFocusTimerHdl, Timer *, void);
183 protected :
185 // Window
186 virtual void GetFocus() SAL_OVERRIDE;
187 virtual void Resize() SAL_OVERRIDE;
188 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
189 virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
191 virtual Size CalcDockingSize(SfxChildAlignment eAlign) SAL_OVERRIDE;
192 virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
193 SfxChildAlignment eWish) SAL_OVERRIDE;
195 virtual void ToggleFloatingMode() SAL_OVERRIDE;
197 public:
198 SmCmdBoxWindow(SfxBindings *pBindings,
199 SfxChildWindow *pChildWindow,
200 Window *pParent);
202 virtual ~SmCmdBoxWindow ();
203 virtual void dispose() SAL_OVERRIDE;
205 void AdjustPosition();
207 SmEditWindow& GetEditWindow()
209 return *aEdit.get();
211 SmViewShell* GetView();
214 class SmCmdBoxWrapper : public SfxChildWindow
216 SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
218 protected:
219 SmCmdBoxWrapper(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo);
221 #if OSL_DEBUG_LEVEL > 1
222 virtual ~SmCmdBoxWrapper();
223 #endif
225 public:
227 SmEditWindow& GetEditWindow()
229 return static_cast<SmCmdBoxWindow *>(pWindow.get())->GetEditWindow();
233 namespace sfx2 { class FileDialogHelper; }
234 struct SmViewShell_Impl;
236 class SmViewShell: public SfxViewShell
238 // for handling the PasteClipboardState
239 friend class SmClipboardChangeListener;
241 std::unique_ptr<SmViewShell_Impl> pImpl;
243 VclPtr<SmGraphicWindow> aGraphic;
244 SmGraphicController aGraphicController;
245 OUString aStatusText;
247 bool bPasteState;
249 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
250 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
252 /** Used to determine whether insertions using SID_INSERTSYMBOL and SID_INSERTCOMMAND
253 * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
254 * visual editor was last to have focus.
256 bool bInsertIntoEditWindow;
257 protected:
259 static Size GetTextLineSize(OutputDevice& rDevice,
260 const OUString& rLine);
261 static Size GetTextSize(OutputDevice& rDevice,
262 const OUString& rText,
263 long MaxWidth);
264 static void DrawTextLine(OutputDevice& rDevice,
265 const Point& rPosition,
266 const OUString& rLine);
267 static void DrawText(OutputDevice& rDevice,
268 const Point& rPosition,
269 const OUString& rText,
270 sal_uInt16 MaxWidth);
272 virtual SfxPrinter *GetPrinter(bool bCreate = false) SAL_OVERRIDE;
273 virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
274 SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false) SAL_OVERRIDE;
276 void Insert( SfxMedium& rMedium );
277 void InsertFrom(SfxMedium &rMedium);
279 virtual bool HasPrintOptionsPage() const SAL_OVERRIDE;
280 virtual VclPtr<SfxTabPage> CreatePrintOptionsPage(vcl::Window *pParent,
281 const SfxItemSet &rOptions) SAL_OVERRIDE;
282 virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
283 virtual void Activate(bool IsMDIActivate) SAL_OVERRIDE;
284 virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize) SAL_OVERRIDE;
285 virtual void InnerResizePixel(const Point &rOfs, const Size &rSize) SAL_OVERRIDE;
286 virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) SAL_OVERRIDE;
287 virtual void QueryObjAreaPixel( Rectangle& rRect ) const SAL_OVERRIDE;
288 virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) SAL_OVERRIDE;
290 public:
291 TYPEINFO_OVERRIDE();
293 SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
294 virtual ~SmViewShell();
296 SmDocShell * GetDoc()
298 return static_cast<SmDocShell *>( GetViewFrame()->GetObjectShell() );
301 SmEditWindow * GetEditWindow();
303 SmGraphicWindow& GetGraphicWindow()
305 return *aGraphic.get();
307 const SmGraphicWindow& GetGraphicWindow() const
309 return *aGraphic.get();
312 void SetStatusText(const OUString& rText);
314 void ShowError( const SmErrorDesc *pErrorDesc );
315 void NextError();
316 void PrevError();
318 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
319 SFX_DECL_VIEWFACTORY(SmViewShell);
321 private:
322 /// SfxInterface initializer.
323 static void InitInterface_Impl();
325 public:
326 void Execute( SfxRequest& rReq );
327 void GetState(SfxItemSet &);
329 void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
330 Rectangle aOutRect, Point aZeroPoint );
332 /** Set bInsertIntoEditWindow so we know where to insert
334 * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
335 * so that when text is inserted from catalog or elsewhere we know whether to
336 * insert for the visual editor, or the text editor.
338 void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast = true){
339 bInsertIntoEditWindow = bEditWindowHadFocusLast;
341 bool IsInlineEditEnabled() const;
344 #endif
346 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */