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