Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SD_SOURCE_UI_INC_WINDOW_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_WINDOW_HXX
22 :
23 : #include <tools/gen.hxx>
24 : #include <vcl/window.hxx>
25 : #include <svtools/transfer.hxx>
26 :
27 : namespace sd {
28 :
29 : class ViewShell;
30 :
31 : /** An SdWindow contains the actual working area of ViewShell.
32 :
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.
41 : */
42 : class Window
43 : : public ::vcl::Window,
44 : public ::DropTargetHelper
45 : {
46 : public:
47 : Window (vcl::Window* pParent);
48 : virtual ~Window (void);
49 :
50 : void SetViewShell (ViewShell* pViewSh);
51 :
52 : /** Set the zoom factor to the specified value and center the display
53 : area around the zoom center.
54 : @param nZoom
55 : The zoom factor is given as integral percent value.
56 : */
57 : void SetZoomIntegral(long nZoom);
58 :
59 : /** This internally used method performs the actual adaption of the
60 : window's map mode to the specified zoom factor.
61 : @param nZoom
62 : The zoom factor is given as integral percent value.
63 : @return
64 : When the given zoom factor lies outside the valid range enclosed
65 : by the minimal zoom factor previously calculated by
66 : <member>CalcMinZoom</member> and a constant upper value it is
67 : forced into that interval. Therefore the returned value is a
68 : valid zoom factor.
69 : */
70 : long SetZoomFactor(long nZoom);
71 :
72 : /** This method is called when the whole page shall be displayed in the
73 : window. Position and zoom factor are set so that the given
74 : rectangle is displayed as large as possible in the window while at
75 : the same time maintaining the rectangle's aspect ratio and adding a
76 : small space at all its four sides (about 3% of width and height).
77 : The map mode is adapted accordingly.
78 : @param rZoomRect
79 : The rectangle is expected to be given relative to the upper left
80 : corner of the window in logical coordinates (100th of mm).
81 : @return
82 : The new zoom factor is returned as integral percent value.
83 : */
84 : long SetZoomRect (const Rectangle& rZoomRect);
85 :
86 : long GetZoomForRect( const Rectangle& rZoomRect );
87 :
88 : void SetMinZoomAutoCalc (bool bAuto);
89 : void SetCalcMinZoomByMinSide (bool bMin);
90 :
91 : /** Calculate the minimal zoom factor as the value at which the
92 : application area would completely fill the window. All values set
93 : manually or programatically are set to this value if they are
94 : smaller. If the currently used zoom factor is smaller than the minimal zoom
95 : factor than set the minimal zoom factor as the new current zoom
96 : factor.
97 :
98 : <p>This calculation is performed only when the
99 : <member>bMinZoomAutoCalc</member> is set (to <TRUE/>).</p>
100 : */
101 : void CalcMinZoom (void);
102 : void SetMinZoom (long int nMin);
103 207 : long GetMinZoom (void) const { return mnMinZoom;}
104 : void SetMaxZoom (long int nMax);
105 207 : long GetMaxZoom (void) const { return mnMaxZoom;}
106 :
107 : long GetZoom (void) const;
108 :
109 1452 : Point GetWinViewPos (void) const { return maWinPos;}
110 13 : Point GetViewOrigin (void) const { return maViewOrigin;}
111 13 : Size GetViewSize (void) const { return maViewSize;}
112 : void SetWinViewPos(const Point& rPnt);
113 : void SetViewOrigin(const Point& rPnt);
114 : void SetViewSize(const Size& rSize);
115 : void SetCenterAllowed (bool bIsAllowed);
116 :
117 : /** Calculate origin of the map mode according to the size of the view
118 : and window (its size in model coordinates; that takes the zoom
119 : factor into account), and the bCenterAllowed flag. When it is not
120 : set then nothing is changed. When in any direction the window is
121 : larger than the view or the value of aWinPos in this direction is -1
122 : then the window is centered in this direction.
123 : */
124 : void UpdateMapOrigin (bool bInvalidate = true);
125 :
126 : void UpdateMapMode (void);
127 :
128 : double GetVisibleX(); // Interface fuer ScrollBars
129 : double GetVisibleY();
130 : void SetVisibleXY(double fX, double fY);
131 : double GetVisibleWidth();
132 : double GetVisibleHeight();
133 : double GetScrlLineWidth();
134 : double GetScrlLineHeight();
135 : double GetScrlPageWidth();
136 : double GetScrlPageHeight();
137 : virtual void GrabFocus();
138 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
139 :
140 : // DropTargetHelper
141 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
142 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
143 :
144 : /** The DropScroll() method is used by AcceptDrop() to scroll the
145 : content of the window while dragging and dropping. With this method
146 : you can control whether DropScroll() shall be used.
147 : */
148 : void SetUseDropScroll (bool bUseDropScroll);
149 : void DropScroll (const Point& rMousePos);
150 : protected:
151 : ::sd::Window* mpShareWin;
152 : Point maWinPos;
153 : Point maViewOrigin;
154 : Size maViewSize;
155 : Size maPrevSize; // contains previous window size in logical coords
156 : sal_uInt16 mnMinZoom;
157 : sal_uInt16 mnMaxZoom;
158 :
159 : /** This flag tells whether to re-calculate the minimal zoom factor
160 : depening on the current zoom factor. Its default value is now false.
161 : */
162 : bool mbMinZoomAutoCalc;
163 : bool mbCalcMinZoomByMinSide;
164 : bool mbCenterAllowed;
165 : long mnTicks;
166 : bool mbDraggedFrom;
167 :
168 : ViewShell* mpViewShell;
169 : bool mbUseDropScroll;
170 :
171 : virtual void Resize() SAL_OVERRIDE;
172 : virtual void PrePaint() SAL_OVERRIDE;
173 : virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
174 : virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
175 : virtual void MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE;
176 : virtual void MouseButtonUp(const MouseEvent& rMEvt) SAL_OVERRIDE;
177 : virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
178 : virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
179 : virtual void RequestHelp( const HelpEvent& rEvt ) SAL_OVERRIDE;
180 : virtual void LoseFocus() SAL_OVERRIDE;
181 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
182 :
183 : /** Create an accessibility object that makes this window accessible.
184 :
185 : @return
186 : The returned reference is empty if an accessible object could
187 : not be created.
188 : */
189 : virtual ::com::sun::star::uno::Reference<
190 : ::com::sun::star::accessibility::XAccessible>
191 : CreateAccessible (void) SAL_OVERRIDE;
192 : virtual void SwitchView();
193 :
194 : OUString GetSurroundingText() const SAL_OVERRIDE;
195 : Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
196 : };
197 :
198 : } // end of namespace sd
199 :
200 : #endif
201 :
202 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|