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