bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / Window.hxx
blob026a6d1a460fe2658913fc52ed03ee4da7161538
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_SD_SOURCE_UI_INC_WINDOW_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_WINDOW_HXX
23 #include <tools/gen.hxx>
24 #include <vcl/window.hxx>
25 #include <vcl/transfer.hxx>
27 namespace sd {
29 class ViewShell;
31 /** An SdWindow contains the actual working area of ViewShell.
33 <p>The zoom factor used by this class controls how much the page and the
34 shapes on it are scaled down (<100%) or up (>100%) when displayed on the
35 output device represented by the <type>OutputDevice</type>base class. A
36 zoom factor of 100% would result (with a correctly set DPI value for an
37 output device) in a one to one mapping of the internal coordinates that
38 are stored in 100th of mm. The zoom factor is stored in the map mode
39 member of the <type>OutputDevice</type> base class. It is calculated to
40 be an integer percent value.
42 class Window
43 : public vcl::Window,
44 public ::DropTargetHelper
46 public:
47 Window (vcl::Window* pParent);
48 virtual ~Window () override;
49 virtual void dispose() override;
51 void SetViewShell (ViewShell* pViewSh);
52 ViewShell* GetViewShell();
54 /** Set the zoom factor to the specified value and center the display
55 area around the zoom center.
56 @param nZoom
57 The zoom factor is given as integral percent value.
59 void SetZoomIntegral(long nZoom);
61 /** This internally used method performs the actual adaption of the
62 window's map mode to the specified zoom factor.
63 @param nZoom
64 The zoom factor is given as integral percent value.
65 @return
66 When the given zoom factor lies outside the valid range enclosed
67 by the minimal zoom factor previously calculated by
68 <member>CalcMinZoom</member> and a constant upper value it is
69 forced into that interval. Therefore the returned value is a
70 valid zoom factor.
72 long SetZoomFactor(long nZoom);
74 /** This method is called when the whole page shall be displayed in the
75 window. Position and zoom factor are set so that the given
76 rectangle is displayed as large as possible in the window while at
77 the same time maintaining the rectangle's aspect ratio and adding a
78 small space at all its four sides (about 3% of width and height).
79 The map mode is adapted accordingly.
80 @param rZoomRect
81 The rectangle is expected to be given relative to the upper left
82 corner of the window in logical coordinates (100th of mm).
83 @return
84 The new zoom factor is returned as integral percent value.
86 long SetZoomRect (const ::tools::Rectangle& rZoomRect);
88 long GetZoomForRect( const ::tools::Rectangle& rZoomRect );
90 void SetMinZoomAutoCalc (bool bAuto);
92 /** Calculate the minimal zoom factor as the value at which the
93 application area would completely fill the window. All values set
94 manually or programmatically are set to this value if they are
95 smaller. If the currently used zoom factor is smaller than the minimal zoom
96 factor than set the minimal zoom factor as the new current zoom
97 factor.
99 <p>This calculation is performed only when the
100 <member>bMinZoomAutoCalc</member> is set (to <TRUE/>).</p>
102 void CalcMinZoom();
103 void SetMinZoom (long int nMin);
104 long GetMinZoom() const { return mnMinZoom;}
105 void SetMaxZoom (long int nMax);
106 long GetMaxZoom() const { return mnMaxZoom;}
108 long GetZoom() const;
110 const Point& GetWinViewPos() const { return maWinPos;}
111 const Point& GetViewOrigin() const { return maViewOrigin;}
112 const Size& GetViewSize() const { return maViewSize;}
113 void SetWinViewPos(const Point& rPnt);
114 void SetViewOrigin(const Point& rPnt);
115 void SetViewSize(const Size& rSize);
116 void SetCenterAllowed (bool bIsAllowed);
118 /** Calculate origin of the map mode according to the size of the view
119 and window (its size in model coordinates; that takes the zoom
120 factor into account), and the bCenterAllowed flag. When it is not
121 set then nothing is changed. When in any direction the window is
122 larger than the view or the value of aWinPos in this direction is -1
123 then the window is centered in this direction.
125 void UpdateMapOrigin (bool bInvalidate = true);
127 void UpdateMapMode();
129 double GetVisibleX(); // interface for ScrollBars
130 double GetVisibleY();
131 void SetVisibleXY(double fX, double fY);
132 double GetVisibleWidth();
133 double GetVisibleHeight();
134 Point GetVisibleCenter();
135 double GetScrlLineWidth();
136 double GetScrlLineHeight();
137 double GetScrlPageWidth();
138 double GetScrlPageHeight();
139 void GrabFocus();
140 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
142 // DropTargetHelper
143 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
144 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
146 /** The DropScroll() method is used by AcceptDrop() to scroll the
147 content of the window while dragging and dropping. With this method
148 you can control whether DropScroll() shall be used.
150 void SetUseDropScroll (bool bUseDropScroll);
151 void DropScroll (const Point& rMousePos);
152 virtual void KeyInput(const KeyEvent& rKEvt) override;
153 protected:
154 Point maWinPos;
155 Point maViewOrigin;
156 Size maViewSize;
157 Size maPrevSize; // contains previous window size in logical coords
158 sal_uInt16 mnMinZoom;
159 sal_uInt16 mnMaxZoom;
161 /** This flag tells whether to re-calculate the minimal zoom factor
162 depending on the current zoom factor. Its default value is now false.
164 bool mbMinZoomAutoCalc;
165 bool mbCenterAllowed;
166 long mnTicks;
168 ViewShell* mpViewShell;
169 bool mbUseDropScroll;
171 virtual void Resize() override;
172 virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
173 virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
174 virtual void MouseMove(const MouseEvent& rMEvt) override;
175 virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
176 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
177 virtual void Command(const CommandEvent& rCEvt) override;
178 virtual void RequestHelp( const HelpEvent& rEvt ) override;
179 virtual void LoseFocus() override;
180 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
182 /** Create an accessibility object that makes this window accessible.
184 @return
185 The returned reference is empty if an accessible object could
186 not be created.
188 virtual css::uno::Reference<css::accessibility::XAccessible>
189 CreateAccessible() override;
191 OUString GetSurroundingText() const override;
192 Selection GetSurroundingTextSelection() const override;
193 /// @see Window::LogicInvalidate().
194 void LogicInvalidate(const ::tools::Rectangle* pRectangle) override;
195 /// Same as MouseButtonDown(), but coordinates are in logic unit.
196 virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
197 /// Same as MouseButtonUp(), but coordinates are in logic unit.
198 virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
199 /// Same as MouseMove(), but coordinates are in logic unit.
200 virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
202 FactoryFunction GetUITestFactory() const override;
205 } // end of namespace sd
207 #endif
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */