2010-10-27 12:53:26 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-01-20 10:47:02 +00:00
|
|
|
|
2013-10-23 22:38:46 +02:00
|
|
|
#ifndef INCLUDED_SD_SOURCE_UI_INC_WINDOW_HXX
|
|
|
|
#define INCLUDED_SD_SOURCE_UI_INC_WINDOW_HXX
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <svtools/transfer.hxx>
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
|
|
|
class ViewShell;
|
|
|
|
|
|
|
|
/** An SdWindow contains the actual working area of ViewShell.
|
|
|
|
|
|
|
|
<p>The zoom factor used by this class controls how much the page and the
|
|
|
|
shapes on it are scaled down (<100%) or up (>100%) when displayed on the
|
|
|
|
output device represented by the <type>OutputDevice</type>base class. A
|
|
|
|
zoom factor of 100% would result (with a correctly set DPI value for an
|
|
|
|
output device) in a one to one mapping of the internal coordinates that
|
|
|
|
are stored in 100th of mm. The zoom factor is stored in the map mode
|
|
|
|
member of the <type>OutputDevice</type> base class. It is calculated to
|
|
|
|
be an integer percent value.
|
|
|
|
*/
|
|
|
|
class Window
|
2015-04-28 23:09:13 +03:00
|
|
|
: public vcl::Window,
|
2004-01-20 10:47:02 +00:00
|
|
|
public ::DropTargetHelper
|
|
|
|
{
|
|
|
|
public:
|
2014-09-23 11:20:40 +02:00
|
|
|
Window (vcl::Window* pParent);
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~Window () override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void dispose() override;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
void SetViewShell (ViewShell* pViewSh);
|
2016-05-22 05:54:11 +02:00
|
|
|
ViewShell* GetViewShell();
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
/** Set the zoom factor to the specified value and center the display
|
2014-04-10 09:45:25 +02:00
|
|
|
area around the zoom center.
|
2004-01-20 10:47:02 +00:00
|
|
|
@param nZoom
|
|
|
|
The zoom factor is given as integral percent value.
|
|
|
|
*/
|
2006-12-12 16:40:36 +00:00
|
|
|
void SetZoomIntegral(long nZoom);
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
/** This internally used method performs the actual adaption of the
|
|
|
|
window's map mode to the specified zoom factor.
|
|
|
|
@param nZoom
|
|
|
|
The zoom factor is given as integral percent value.
|
|
|
|
@return
|
|
|
|
When the given zoom factor lies outside the valid range enclosed
|
|
|
|
by the minimal zoom factor previously calculated by
|
|
|
|
<member>CalcMinZoom</member> and a constant upper value it is
|
|
|
|
forced into that interval. Therefore the returned value is a
|
|
|
|
valid zoom factor.
|
|
|
|
*/
|
|
|
|
long SetZoomFactor(long nZoom);
|
|
|
|
|
|
|
|
/** This method is called when the whole page shall be displayed in the
|
|
|
|
window. Position and zoom factor are set so that the given
|
|
|
|
rectangle is displayed as large as possible in the window while at
|
|
|
|
the same time maintaining the rectangle's aspect ratio and adding a
|
|
|
|
small space at all its four sides (about 3% of width and height).
|
2004-07-13 13:06:01 +00:00
|
|
|
The map mode is adapted accordingly.
|
2004-01-20 10:47:02 +00:00
|
|
|
@param rZoomRect
|
|
|
|
The rectangle is expected to be given relative to the upper left
|
|
|
|
corner of the window in logical coordinates (100th of mm).
|
|
|
|
@return
|
|
|
|
The new zoom factor is returned as integral percent value.
|
|
|
|
*/
|
2017-03-30 20:27:55 +02:00
|
|
|
long SetZoomRect (const ::tools::Rectangle& rZoomRect);
|
2004-01-20 10:47:02 +00:00
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
long GetZoomForRect( const ::tools::Rectangle& rZoomRect );
|
2008-10-29 11:47:54 +00:00
|
|
|
|
2004-07-13 13:06:01 +00:00
|
|
|
void SetMinZoomAutoCalc (bool bAuto);
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
/** Calculate the minimal zoom factor as the value at which the
|
|
|
|
application area would completely fill the window. All values set
|
2018-01-29 13:05:45 +01:00
|
|
|
manually or programmatically are set to this value if they are
|
2004-01-20 10:47:02 +00:00
|
|
|
smaller. If the currently used zoom factor is smaller than the minimal zoom
|
|
|
|
factor than set the minimal zoom factor as the new current zoom
|
|
|
|
factor.
|
|
|
|
|
|
|
|
<p>This calculation is performed only when the
|
|
|
|
<member>bMinZoomAutoCalc</member> is set (to <TRUE/>).</p>
|
|
|
|
*/
|
2015-04-14 12:44:47 +02:00
|
|
|
void CalcMinZoom();
|
2004-07-13 13:06:01 +00:00
|
|
|
void SetMinZoom (long int nMin);
|
2015-04-14 12:44:47 +02:00
|
|
|
long GetMinZoom() const { return mnMinZoom;}
|
2004-07-13 13:06:01 +00:00
|
|
|
void SetMaxZoom (long int nMax);
|
2015-04-14 12:44:47 +02:00
|
|
|
long GetMaxZoom() const { return mnMaxZoom;}
|
2004-07-13 13:06:01 +00:00
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
long GetZoom() const;
|
2004-07-13 13:06:01 +00:00
|
|
|
|
2016-04-13 15:37:03 +02:00
|
|
|
const Point& GetWinViewPos() const { return maWinPos;}
|
|
|
|
const Point& GetViewOrigin() const { return maViewOrigin;}
|
|
|
|
const Size& GetViewSize() const { return maViewSize;}
|
2004-07-13 13:06:01 +00:00
|
|
|
void SetWinViewPos(const Point& rPnt);
|
|
|
|
void SetViewOrigin(const Point& rPnt);
|
|
|
|
void SetViewSize(const Size& rSize);
|
|
|
|
void SetCenterAllowed (bool bIsAllowed);
|
|
|
|
|
2014-04-29 19:25:03 +00:00
|
|
|
/** Calculate origin of the map mode according to the size of the view
|
2004-07-13 13:06:01 +00:00
|
|
|
and window (its size in model coordinates; that takes the zoom
|
|
|
|
factor into account), and the bCenterAllowed flag. When it is not
|
|
|
|
set then nothing is changed. When in any direction the window is
|
|
|
|
larger than the view or the value of aWinPos in this direction is -1
|
|
|
|
then the window is centered in this direction.
|
|
|
|
*/
|
2014-04-24 10:52:02 +02:00
|
|
|
void UpdateMapOrigin (bool bInvalidate = true);
|
2004-07-13 13:06:01 +00:00
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
void UpdateMapMode();
|
2004-07-13 13:06:01 +00:00
|
|
|
|
2017-07-02 14:24:27 +02:00
|
|
|
double GetVisibleX(); // interface for ScrollBars
|
2004-01-20 10:47:02 +00:00
|
|
|
double GetVisibleY();
|
|
|
|
void SetVisibleXY(double fX, double fY);
|
|
|
|
double GetVisibleWidth();
|
|
|
|
double GetVisibleHeight();
|
2018-03-08 21:07:40 +01:00
|
|
|
Point GetVisibleCenter();
|
2004-01-20 10:47:02 +00:00
|
|
|
double GetScrlLineWidth();
|
|
|
|
double GetScrlLineHeight();
|
|
|
|
double GetScrlPageWidth();
|
|
|
|
double GetScrlPageHeight();
|
2015-01-20 12:38:10 +02:00
|
|
|
void GrabFocus();
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
// DropTargetHelper
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
|
|
|
|
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
2004-07-13 13:06:01 +00:00
|
|
|
/** The DropScroll() method is used by AcceptDrop() to scroll the
|
|
|
|
content of the window while dragging and dropping. With this method
|
|
|
|
you can control whether DropScroll() shall be used.
|
|
|
|
*/
|
|
|
|
void SetUseDropScroll (bool bUseDropScroll);
|
|
|
|
void DropScroll (const Point& rMousePos);
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void KeyInput(const KeyEvent& rKEvt) override;
|
2004-01-20 10:47:02 +00:00
|
|
|
protected:
|
2015-04-28 18:12:36 +02:00
|
|
|
VclPtr< ::sd::Window> mpShareWin;
|
2004-07-13 13:06:01 +00:00
|
|
|
Point maWinPos;
|
|
|
|
Point maViewOrigin;
|
|
|
|
Size maViewSize;
|
2011-03-13 06:22:49 -05:00
|
|
|
Size maPrevSize; // contains previous window size in logical coords
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 mnMinZoom;
|
2011-03-12 20:06:58 +01:00
|
|
|
sal_uInt16 mnMaxZoom;
|
|
|
|
|
2004-01-20 10:47:02 +00:00
|
|
|
/** This flag tells whether to re-calculate the minimal zoom factor
|
2015-09-30 12:15:36 +02:00
|
|
|
depending on the current zoom factor. Its default value is now false.
|
2004-01-20 10:47:02 +00:00
|
|
|
*/
|
2004-07-13 13:06:01 +00:00
|
|
|
bool mbMinZoomAutoCalc;
|
|
|
|
bool mbCenterAllowed;
|
|
|
|
long mnTicks;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
ViewShell* mpViewShell;
|
2004-07-13 13:06:01 +00:00
|
|
|
bool mbUseDropScroll;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void Resize() override;
|
|
|
|
virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
|
2017-03-30 20:27:55 +02:00
|
|
|
virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void MouseMove(const MouseEvent& rMEvt) override;
|
|
|
|
virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
|
|
|
|
virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
|
|
|
|
virtual void Command(const CommandEvent& rCEvt) override;
|
|
|
|
virtual void RequestHelp( const HelpEvent& rEvt ) override;
|
|
|
|
virtual void LoseFocus() override;
|
2016-11-24 22:40:33 +01:00
|
|
|
virtual bool EventNotify( NotifyEvent& rNEvt ) override;
|
2004-01-20 10:47:02 +00:00
|
|
|
|
|
|
|
/** Create an accessibility object that makes this window accessible.
|
|
|
|
|
|
|
|
@return
|
|
|
|
The returned reference is empty if an accessible object could
|
|
|
|
not be created.
|
|
|
|
*/
|
2015-10-28 12:01:32 +02:00
|
|
|
virtual css::uno::Reference<css::accessibility::XAccessible>
|
2015-10-12 16:04:04 +02:00
|
|
|
CreateAccessible() override;
|
2009-06-17 10:58:14 +00:00
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
OUString GetSurroundingText() const override;
|
|
|
|
Selection GetSurroundingTextSelection() const override;
|
2018-03-28 10:08:30 +02:00
|
|
|
/// @see Window::LogicInvalidate().
|
2017-03-30 20:27:55 +02:00
|
|
|
void LogicInvalidate(const ::tools::Rectangle* pRectangle) override;
|
2018-02-24 12:19:57 +05:30
|
|
|
/// Same as MouseButtonDown(), but coordinates are in logic unit.
|
|
|
|
virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
|
|
|
|
/// Same as MouseButtonUp(), but coordinates are in logic unit.
|
|
|
|
virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
|
|
|
|
/// Same as MouseMove(), but coordinates are in logic unit.
|
|
|
|
virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
|
2016-05-22 05:54:11 +02:00
|
|
|
|
|
|
|
FactoryFunction GetUITestFactory() const override;
|
2004-01-20 10:47:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace sd
|
|
|
|
|
|
|
|
#endif
|
2010-10-27 12:53:26 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|