summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-02 20:58:15 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-02 21:00:01 +0200
commitc859cc21cd4b577b4e7df8955375fcc5df2bd980 (patch)
tree4bd094e2a229aba5a460c1f349f3ac1a679555eb /vcl
parentec7986d43be123f66a952ab9619c4beccd0c8446 (diff)
Start hacking on zoom and scroll events at the VCL "public" level
On the internal ("Sal") VCL level they will correspond to wheel mouse events, I guess. Change-Id: Ia422f892d73afe501f529020c2aed9ff8fca99f9
Diffstat (limited to 'vcl')
-rw-r--r--vcl/android/androidinst.cxx58
-rw-r--r--vcl/inc/vcl/event.hxx60
-rw-r--r--vcl/inc/vcl/svapp.hxx4
-rw-r--r--vcl/inc/vcl/vclevent.hxx2
-rw-r--r--vcl/source/app/svapp.cxx14
5 files changed, 109 insertions, 29 deletions
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 7fa77792e441..fdac1ecf1d1e 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -922,10 +922,9 @@ Java_org_libreoffice_experimental_desktop_Desktop_key(JNIEnv * /* env */,
jchar c,
jshort /* timestamp */)
{
- KeyEvent aEvent(c, c, 0);
-
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
+ KeyEvent aEvent(c, c, 0);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent);
}
@@ -942,30 +941,30 @@ Java_org_libreoffice_experimental_desktop_Desktop_touch(JNIEnv * /* env */,
jint y,
jshort /* timestamp */)
{
- MouseEvent aEvent;
-
- sal_uLong nEvent;
- switch (action) {
- case AMOTION_EVENT_ACTION_DOWN:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
- break;
- case AMOTION_EVENT_ACTION_UP:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
- break;
- case AMOTION_EVENT_ACTION_MOVE:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLEMOVE, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
- break;
- default:
- LOGE("Java_org_libreoffice_experimental_desktop_Desktop_touch: Invalid action %d", action);
- return;
- }
-
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
- if (pFocus)
+ if (pFocus) {
+ MouseEvent aEvent;
+ sal_uLong nEvent;
+
+ switch (action) {
+ case AMOTION_EVENT_ACTION_DOWN:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
+ break;
+ case AMOTION_EVENT_ACTION_UP:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
+ break;
+ case AMOTION_EVENT_ACTION_MOVE:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLEMOVE, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
+ break;
+ default:
+ LOGE("Java_org_libreoffice_experimental_desktop_Desktop_touch: Invalid action %d", action);
+ return;
+ }
Application::PostMouseEvent(nEvent, pFocus->GetWindow(), &aEvent);
+ }
else
LOGW("No focused frame to emit event on");
}
@@ -978,12 +977,13 @@ Java_org_libreoffice_experimental_desktop_Desktop_zoom(JNIEnv * /* env */,
jint x,
jint y)
{
- (void) x;
- (void) y;
-
- if (scale > 1.05) {
- } else if (scale < 0.95) {
+ SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
+ if (pFocus) {
+ ZoomEvent aEvent( Point( x, y ), scale);
+ Application::PostZoomEvent(VCLEVENT_WINDOW_ZOOM, pFocus->GetWindow(), &aEvent);
}
+ else
+ LOGW("No focused frame to emit event on");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/event.hxx b/vcl/inc/vcl/event.hxx
index de7464dc2667..e89d52ad1e9a 100644
--- a/vcl/inc/vcl/event.hxx
+++ b/vcl/inc/vcl/event.hxx
@@ -177,6 +177,66 @@ inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks,
mnCode = nButtons | nModifier;
}
+class VCL_DLLPUBLIC ZoomEvent
+{
+private:
+ Point maCenter;
+ float mfScale;
+
+public:
+ ZoomEvent() :
+ mfScale( 1 )
+ {
+ }
+
+ ZoomEvent( const Point& rCenter,
+ float fScale ) :
+ maCenter( rCenter ),
+ mfScale( fScale )
+ {
+ }
+
+ const Point& GetCenter() const
+ {
+ return maCenter;
+ }
+
+ float GetScale() const
+ {
+ return mfScale;
+ }
+};
+
+class VCL_DLLPUBLIC ScrollEvent
+{
+private:
+ int mnXOffset;
+ int mnYOffset;
+
+public:
+ ScrollEvent() :
+ mnXOffset( 0 ),
+ mnYOffset( 0 )
+ {
+ }
+
+ ScrollEvent( int xOffset, int yOffset ) :
+ mnXOffset( xOffset ),
+ mnYOffset( yOffset )
+ {
+ }
+
+ int GetXOffset() const
+ {
+ return mnXOffset;
+ }
+
+ int GetYOffset() const
+ {
+ return mnYOffset;
+ }
+};
+
// -------------
// - HelpEvent -
// -------------
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index a3eb6b72a14e..e3e0779810b3 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -50,6 +50,8 @@ class KeyCode;
class NotifyEvent;
class KeyEvent;
class MouseEvent;
+class ZoomEvent;
+class ScrollEvent;
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/connection/XConnection.hpp>
@@ -229,6 +231,8 @@ public:
static sal_uLong PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
static sal_uLong PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent );
+ static sal_uLong PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent );
+ static sal_uLong PostScrollEvent( sal_uLong nEvent, Window *pWin, ScrollEvent* pScrollEvent );
static void RemoveMouseAndKeyEvents( Window *pWin );
static sal_uLong PostUserEvent( const Link& rLink, void* pCaller = NULL );
diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx
index ab7062e42ab5..bc4fa01362c2 100644
--- a/vcl/inc/vcl/vclevent.hxx
+++ b/vcl/inc/vcl/vclevent.hxx
@@ -67,6 +67,8 @@ namespace com { namespace sun { namespace star {
#define VCLEVENT_WINDOW_ENABLED 1020
#define VCLEVENT_WINDOW_DISABLED 1021
#define VCLEVENT_WINDOW_DATACHANGED 1022 // pData = DataChangedEvent*
+#define VCLEVENT_WINDOW_ZOOM 1023 // pData = ZoomEvent*
+#define VCLEVENT_WINDOW_SCROLL 1024 // pData = ScrollEvent*
// VclWindowEvent
#define VCLEVENT_CONTROL_GETFOCUS 1100
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 17d5f61aea85..dcd88efca40d 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -887,6 +887,20 @@ sal_uLong Application::PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEven
return nEventId;
}
+sal_uLong Application::PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent )
+{
+ const SolarMutexGuard aGuard;
+ sal_uLong nEventId = 0;
+
+ if( pWin && pZoomEvent )
+ {
+ // Implement...
+ (void) nEvent;
+ }
+
+ return nEventId;
+}
+
// -----------------------------------------------------------------------------
IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData )