CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / source / ui / inc / Window.hxx
blob471f1f9dc6d5b114ec6473fae8b543a425f8ba9b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SD_WINDOW_HXX
29 #define SD_WINDOW_HXX
32 #include <tools/gen.hxx>
33 #include <vcl/window.hxx>
34 #include <svtools/transfer.hxx>
36 namespace sd {
38 class ViewShell;
40 // Since we removed all old SV-stuff, there is no brush any more
41 // and so there is no BRUSH_SIZE defined in VCL.
42 // So I define it here
43 // #i2237#
44 // removed old stuff here which still forced zoom to be
45 // %BRUSH_SIZE which is outdated now
46 //#define BRUSH_SIZE 8
48 /** An SdWindow contains the actual working area of ViewShell.
50 <p>The zoom factor used by this class controls how much the page and the
51 shapes on it are scaled down (<100%) or up (>100%) when displayed on the
52 output device represented by the <type>OutputDevice</type>base class. A
53 zoom factor of 100% would result (with a correctly set DPI value for an
54 output device) in a one to one mapping of the internal coordinates that
55 are stored in 100th of mm. The zoom factor is stored in the map mode
56 member of the <type>OutputDevice</type> base class. It is calculated to
57 be an integer percent value.
59 class Window
60 : public ::Window,
61 public ::DropTargetHelper
63 public:
64 Window (::Window* pParent);
65 virtual ~Window (void);
67 void SetViewShell (ViewShell* pViewSh);
69 /** Set the zoom factor to the specified value and center the display
70 area arround the zoom center.
71 @param nZoom
72 The zoom factor is given as integral percent value.
74 void SetZoomIntegral(long nZoom);
76 /** This internally used method performs the actual adaption of the
77 window's map mode to the specified zoom factor.
78 @param nZoom
79 The zoom factor is given as integral percent value.
80 @return
81 When the given zoom factor lies outside the valid range enclosed
82 by the minimal zoom factor previously calculated by
83 <member>CalcMinZoom</member> and a constant upper value it is
84 forced into that interval. Therefore the returned value is a
85 valid zoom factor.
87 long SetZoomFactor(long nZoom);
89 /** This method is called when the whole page shall be displayed in the
90 window. Position and zoom factor are set so that the given
91 rectangle is displayed as large as possible in the window while at
92 the same time maintaining the rectangle's aspect ratio and adding a
93 small space at all its four sides (about 3% of width and height).
94 The map mode is adapted accordingly.
95 @param rZoomRect
96 The rectangle is expected to be given relative to the upper left
97 corner of the window in logical coordinates (100th of mm).
98 @return
99 The new zoom factor is returned as integral percent value.
101 long SetZoomRect (const Rectangle& rZoomRect);
103 long GetZoomForRect( const Rectangle& rZoomRect );
106 void SetMinZoomAutoCalc (bool bAuto);
107 void SetCalcMinZoomByMinSide (bool bMin);
109 /** Calculate the minimal zoom factor as the value at which the
110 application area would completely fill the window. All values set
111 manually or programatically are set to this value if they are
112 smaller. If the currently used zoom factor is smaller than the minimal zoom
113 factor than set the minimal zoom factor as the new current zoom
114 factor.
116 <p>This calculation is performed only when the
117 <member>bMinZoomAutoCalc</member> is set (to <TRUE/>).</p>
119 void CalcMinZoom (void);
120 void SetMinZoom (long int nMin);
121 long GetMinZoom (void) const;
122 void SetMaxZoom (long int nMax);
123 long GetMaxZoom (void) const;
125 long GetZoom (void) const;
127 Point GetWinViewPos (void) const;
128 Point GetViewOrigin (void) const;
129 Size GetViewSize (void) const;
130 void SetWinViewPos(const Point& rPnt);
131 void SetViewOrigin(const Point& rPnt);
132 void SetViewSize(const Size& rSize);
133 void SetCenterAllowed (bool bIsAllowed);
135 /** Calculate origin of the map mode accoring to the size of the view
136 and window (its size in model coordinates; that takes the zoom
137 factor into account), and the bCenterAllowed flag. When it is not
138 set then nothing is changed. When in any direction the window is
139 larger than the view or the value of aWinPos in this direction is -1
140 then the window is centered in this direction.
142 void UpdateMapOrigin (sal_Bool bInvalidate = sal_True);
144 void UpdateMapMode (void);
146 double GetVisibleX(); // Interface fuer ScrollBars
147 double GetVisibleY();
148 void SetVisibleXY(double fX, double fY);
149 double GetVisibleWidth();
150 double GetVisibleHeight();
151 double GetScrlLineWidth();
152 double GetScrlLineHeight();
153 double GetScrlPageWidth();
154 double GetScrlPageHeight();
155 virtual void GrabFocus();
156 virtual void DataChanged( const DataChangedEvent& rDCEvt );
158 // DropTargetHelper
159 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
160 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
162 /** The DropScroll() method is used by AcceptDrop() to scroll the
163 content of the window while dragging and dropping. With this method
164 you can control whether DropScroll() shall be used.
166 void SetUseDropScroll (bool bUseDropScroll);
167 void DropScroll (const Point& rMousePos);
168 protected:
169 ::sd::Window* mpShareWin;
170 Point maWinPos;
171 Point maViewOrigin;
172 Size maViewSize;
173 sal_uInt16 mnMinZoom;
174 sal_uInt16 mnMaxZoom;
175 /** This flag tells whether to re-calculate the minimal zoom factor
176 depening on the current zoom factor. According to task #105436# its
177 default value is now sal_False.
179 bool mbMinZoomAutoCalc;
180 bool mbCalcMinZoomByMinSide;
181 bool mbCenterAllowed;
182 long mnTicks;
183 bool mbDraggedFrom;
185 ViewShell* mpViewShell;
186 bool mbUseDropScroll;
188 virtual void Resize();
189 virtual void PrePaint();
190 virtual void Paint(const Rectangle& rRect);
191 virtual void KeyInput(const KeyEvent& rKEvt);
192 virtual void MouseMove(const MouseEvent& rMEvt);
193 virtual void MouseButtonUp(const MouseEvent& rMEvt);
194 virtual void MouseButtonDown(const MouseEvent& rMEvt);
195 virtual void Command(const CommandEvent& rCEvt);
196 virtual void RequestHelp( const HelpEvent& rEvt );
197 virtual void LoseFocus();
198 virtual long Notify( NotifyEvent& rNEvt );
200 /** Create an accessibility object that makes this window accessible.
202 @return
203 The returned reference is empty if an accessible object could
204 not be created.
206 virtual ::com::sun::star::uno::Reference<
207 ::com::sun::star::accessibility::XAccessible>
208 CreateAccessible (void);
210 XubString GetSurroundingText() const;
211 Selection GetSurroundingTextSelection() const;
214 } // end of namespace sd
216 #endif