bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / Window.hxx
blobc1cc2143d85876643b38bdb5412cdec622c840ad
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 <svtools/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 ();
49 virtual void dispose() SAL_OVERRIDE;
51 void SetViewShell (ViewShell* pViewSh);
53 /** Set the zoom factor to the specified value and center the display
54 area around the zoom center.
55 @param nZoom
56 The zoom factor is given as integral percent value.
58 void SetZoomIntegral(long nZoom);
60 /** This internally used method performs the actual adaption of the
61 window's map mode to the specified zoom factor.
62 @param nZoom
63 The zoom factor is given as integral percent value.
64 @return
65 When the given zoom factor lies outside the valid range enclosed
66 by the minimal zoom factor previously calculated by
67 <member>CalcMinZoom</member> and a constant upper value it is
68 forced into that interval. Therefore the returned value is a
69 valid zoom factor.
71 long SetZoomFactor(long nZoom);
73 /** This method is called when the whole page shall be displayed in the
74 window. Position and zoom factor are set so that the given
75 rectangle is displayed as large as possible in the window while at
76 the same time maintaining the rectangle's aspect ratio and adding a
77 small space at all its four sides (about 3% of width and height).
78 The map mode is adapted accordingly.
79 @param rZoomRect
80 The rectangle is expected to be given relative to the upper left
81 corner of the window in logical coordinates (100th of mm).
82 @return
83 The new zoom factor is returned as integral percent value.
85 long SetZoomRect (const Rectangle& rZoomRect);
87 long GetZoomForRect( const Rectangle& rZoomRect );
89 void SetMinZoomAutoCalc (bool bAuto);
90 void SetCalcMinZoomByMinSide (bool bMin);
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 programatically 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 Point GetWinViewPos() const { return maWinPos;}
111 Point GetViewOrigin() const { return maViewOrigin;}
112 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 fuer ScrollBars
130 double GetVisibleY();
131 void SetVisibleXY(double fX, double fY);
132 double GetVisibleWidth();
133 double GetVisibleHeight();
134 double GetScrlLineWidth();
135 double GetScrlLineHeight();
136 double GetScrlPageWidth();
137 double GetScrlPageHeight();
138 void GrabFocus();
139 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
141 // DropTargetHelper
142 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
143 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
145 /** The DropScroll() method is used by AcceptDrop() to scroll the
146 content of the window while dragging and dropping. With this method
147 you can control whether DropScroll() shall be used.
149 void SetUseDropScroll (bool bUseDropScroll);
150 void DropScroll (const Point& rMousePos);
151 virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
152 protected:
153 VclPtr< ::sd::Window> mpShareWin;
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 depening on the current zoom factor. Its default value is now false.
164 bool mbMinZoomAutoCalc;
165 bool mbCalcMinZoomByMinSide;
166 bool mbCenterAllowed;
167 long mnTicks;
168 bool mbDraggedFrom;
170 ViewShell* mpViewShell;
171 bool mbUseDropScroll;
173 virtual void Resize() SAL_OVERRIDE;
174 virtual void PrePaint(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
175 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
176 virtual void MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE;
177 virtual void MouseButtonUp(const MouseEvent& rMEvt) SAL_OVERRIDE;
178 virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
179 virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
180 virtual void RequestHelp( const HelpEvent& rEvt ) SAL_OVERRIDE;
181 virtual void LoseFocus() SAL_OVERRIDE;
182 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
184 /** Create an accessibility object that makes this window accessible.
186 @return
187 The returned reference is empty if an accessible object could
188 not be created.
190 virtual ::com::sun::star::uno::Reference<
191 ::com::sun::star::accessibility::XAccessible>
192 CreateAccessible() SAL_OVERRIDE;
194 OUString GetSurroundingText() const SAL_OVERRIDE;
195 Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
196 /// @see OutputDevice::LogicInvalidate().
197 void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
200 } // end of namespace sd
202 #endif
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */