1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Window.hxx,v $
10 * $Revision: 1.7.70.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <tools/gen.hxx>
36 #include <vcl/window.hxx>
37 #include <svtools/transfer.hxx>
43 // Since we removed all old SV-stuff, there is no brush any more
44 // and so there is no BRUSH_SIZE defined in VCL.
45 // So I define it here
47 // removed old stuff here which still forced zoom to be
48 // %BRUSH_SIZE which is outdated now
49 //#define BRUSH_SIZE 8
51 /** An SdWindow contains the actual working area of ViewShell.
53 <p>The zoom factor used by this class controls how much the page and the
54 shapes on it are scaled down (<100%) or up (>100%) when displayed on the
55 output device represented by the <type>OutputDevice</type>base class. A
56 zoom factor of 100% would result (with a correctly set DPI value for an
57 output device) in a one to one mapping of the internal coordinates that
58 are stored in 100th of mm. The zoom factor is stored in the map mode
59 member of the <type>OutputDevice</type> base class. It is calculated to
60 be an integer percent value.
64 public ::DropTargetHelper
67 Window (::Window
* pParent
);
68 virtual ~Window (void);
70 void SetViewShell (ViewShell
* pViewSh
);
72 void ShareViewArea(::sd::Window
* pOtherWin
);
74 /** Set the zoom factor to the specified value and center the display
75 area arround the zoom center.
77 The zoom factor is given as integral percent value.
79 void SetZoomIntegral(long nZoom
);
81 /** This internally used method performs the actual adaption of the
82 window's map mode to the specified zoom factor.
84 The zoom factor is given as integral percent value.
86 When the given zoom factor lies outside the valid range enclosed
87 by the minimal zoom factor previously calculated by
88 <member>CalcMinZoom</member> and a constant upper value it is
89 forced into that interval. Therefore the returned value is a
92 long SetZoomFactor(long nZoom
);
94 /** This method is called when the whole page shall be displayed in the
95 window. Position and zoom factor are set so that the given
96 rectangle is displayed as large as possible in the window while at
97 the same time maintaining the rectangle's aspect ratio and adding a
98 small space at all its four sides (about 3% of width and height).
99 The map mode is adapted accordingly.
101 The rectangle is expected to be given relative to the upper left
102 corner of the window in logical coordinates (100th of mm).
104 The new zoom factor is returned as integral percent value.
106 long SetZoomRect (const Rectangle
& rZoomRect
);
108 long GetZoomForRect( const Rectangle
& rZoomRect
);
111 void SetMinZoomAutoCalc (bool bAuto
);
112 void SetCalcMinZoomByMinSide (bool bMin
);
114 /** Calculate the minimal zoom factor as the value at which the
115 application area would completely fill the window. All values set
116 manually or programatically are set to this value if they are
117 smaller. If the currently used zoom factor is smaller than the minimal zoom
118 factor than set the minimal zoom factor as the new current zoom
121 <p>This calculation is performed only when the
122 <member>bMinZoomAutoCalc</member> is set (to <TRUE/>).</p>
124 void CalcMinZoom (void);
125 void SetMinZoom (long int nMin
);
126 long GetMinZoom (void) const;
127 void SetMaxZoom (long int nMax
);
128 long GetMaxZoom (void) const;
130 long GetZoom (void) const;
132 Point
GetWinViewPos (void) const;
133 Point
GetViewOrigin (void) const;
134 Size
GetViewSize (void) const;
135 void SetWinViewPos(const Point
& rPnt
);
136 void SetViewOrigin(const Point
& rPnt
);
137 void SetViewSize(const Size
& rSize
);
138 void SetCenterAllowed (bool bIsAllowed
);
140 /** Calculate origin of the map mode accoring to the size of the view
141 and window (its size in model coordinates; that takes the zoom
142 factor into account), and the bCenterAllowed flag. When it is not
143 set then nothing is changed. When in any direction the window is
144 larger than the view or the value of aWinPos in this direction is -1
145 then the window is centered in this direction.
147 void UpdateMapOrigin (BOOL bInvalidate
= TRUE
);
149 void UpdateMapMode (void);
151 double GetVisibleX(); // Interface fuer ScrollBars
152 double GetVisibleY();
153 void SetVisibleXY(double fX
, double fY
);
154 double GetVisibleWidth();
155 double GetVisibleHeight();
156 double GetScrlLineWidth();
157 double GetScrlLineHeight();
158 double GetScrlPageWidth();
159 double GetScrlPageHeight();
160 virtual void GrabFocus();
161 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
164 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
165 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
167 /** The DropScroll() method is used by AcceptDrop() to scroll the
168 content of the window while dragging and dropping. With this method
169 you can control whether DropScroll() shall be used.
171 void SetUseDropScroll (bool bUseDropScroll
);
172 void DropScroll (const Point
& rMousePos
);
174 ::sd::Window
* mpShareWin
;
178 Size maPrevSize
; // contains previous window size in logical coords
181 /** This flag tells whether to re-calculate the minimal zoom factor
182 depening on the current zoom factor. According to task #105436# its
183 default value is now FALSE.
185 bool mbMinZoomAutoCalc
;
186 bool mbCalcMinZoomByMinSide
;
187 bool mbCenterAllowed
;
191 ViewShell
* mpViewShell
;
192 bool mbUseDropScroll
;
194 virtual void Resize();
195 virtual void PrePaint();
196 virtual void Paint(const Rectangle
& rRect
);
197 virtual void KeyInput(const KeyEvent
& rKEvt
);
198 virtual void MouseMove(const MouseEvent
& rMEvt
);
199 virtual void MouseButtonUp(const MouseEvent
& rMEvt
);
200 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
201 virtual void Command(const CommandEvent
& rCEvt
);
202 virtual void RequestHelp( const HelpEvent
& rEvt
);
203 virtual void LoseFocus();
204 virtual long Notify( NotifyEvent
& rNEvt
);
206 /** Create an accessibility object that makes this window accessible.
209 The returned reference is empty if an accessible object could
212 virtual ::com::sun::star::uno::Reference
<
213 ::com::sun::star::accessibility::XAccessible
>
214 CreateAccessible (void);
216 XubString
GetSurroundingText() const;
217 Selection
GetSurroundingTextSelection() const;
220 } // end of namespace sd