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