Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse position #210

Closed
rjopek opened this issue Apr 22, 2020 · 0 comments
Closed

Mouse position #210

rjopek opened this issue Apr 22, 2020 · 0 comments

Comments

@rjopek
Copy link

rjopek commented Apr 22, 2020

Hi,

Source code provided by Rolf
is it possible to make changes?

diff -ru a/contrib/gtwvg/gtwgud.c b/contrib/gtwvg/gtwgud.c
--- a/contrib/gtwvg/gtwgud.c	2018-01-04 18:31:52.000000000 +0100
+++ b/contrib/gtwvg/gtwgud.c	2018-02-05 12:50:41.567139205 +0100
@@ -232,6 +232,8 @@
 
    pWVT->MousePos.x        = 0;
    pWVT->MousePos.y        = 0;
+   pWVT->MousePosPxl.x     = 0;
+   pWVT->MousePosPxl.y     = 0;
    pWVT->MouseMove         = HB_TRUE;
    pWVT->hWnd              = NULL;
    pWVT->keyPointerIn      = 0;
@@ -1608,6 +1610,16 @@
             }
          }
          break;
+      case HB_GTI_MOUSEPOS_XY:
+         if( pWVT->hWnd )
+         {
+            if( ! pInfo->pResult )
+               pInfo->pResult = hb_itemNew( NULL );
+            hb_arrayNew( pInfo->pResult, 2 );
+            hb_arraySetNI( pInfo->pResult, 1, pWVT->MousePosPxl.x );
+            hb_arraySetNI( pInfo->pResult, 2, pWVT->MousePosPxl.y );
+         }
+         break;
       case HB_GTI_SETPOS_XY:
       case HB_GTI_SETPOS_ROWCOL:
          if( pWVT->hWnd )
diff -ru a/contrib/gtwvg/gtwgu.h b/contrib/gtwvg/gtwgu.h
--- a/contrib/gtwvg/gtwgu.h	2018-01-04 18:31:52.000000000 +0100
+++ b/contrib/gtwvg/gtwgu.h	2018-02-05 12:41:55.939119694 +0100
@@ -261,6 +261,7 @@
    int      COLS;                           /* number of displayable columns in window */
 
    POINT    MousePos;                       /* the last mouse position */
+   POINT    MousePosPxl;                    /* the last mouse position in pixel*/
    HB_BOOL  MouseMove;                      /* Flag to say whether to return mouse movement events */
 
    int      Keys[ WVT_CHAR_QUEUE_SIZE ];    /* Array to hold the characters & events */
diff -ru a/contrib/gtwvg/gtwvgd.c b/contrib/gtwvg/gtwvgd.c
--- a/contrib/gtwvg/gtwvgd.c	2018-01-04 18:31:52.000000000 +0100
+++ b/contrib/gtwvg/gtwvgd.c	2018-02-05 12:47:25.267131919 +0100
@@ -382,6 +382,8 @@
    pWVT->CaretWidth        = 0;
    pWVT->MousePos.x        = 0;
    pWVT->MousePos.y        = 0;
+   pWVT->MousePosPxl.x     = 0;
+   pWVT->MousePosPxl.y     = 0;
    pWVT->MouseMove         = HB_TRUE;
    pWVT->hWnd              = NULL;
    pWVT->keyPointerIn      = 0;
@@ -1208,6 +1210,8 @@
 
    colrow = hb_gt_wvt_GetColRowFromXY( pWVT, xy.x, xy.y );
    hb_gt_wvt_SetMousePos( pWVT, colrow.y, colrow.x );
+   pWVT->MousePosPxl.y = xy.y;
+   pWVT->MousePosPxl.x = xy.x;
 
    switch( message )
    {
@@ -3660,6 +3664,14 @@
             pWVT->ResizeMode = hb_itemGetNI( pInfo->pNewVal );
          break;
 
+      case HB_GTI_MOUSEPOS_XY:
+         if( ! pInfo->pResult )
+            pInfo->pResult = hb_itemNew( NULL );
+         hb_arrayNew( pInfo->pResult, 2 );
+         hb_arraySetNI( pInfo->pResult, 1, pWVT->MousePosPxl.x );
+         hb_arraySetNI( pInfo->pResult, 2, pWVT->MousePosPxl.y );
+         break;
+
       case HB_GTI_SETPOS_XY:
       case HB_GTI_SETPOS_ROWCOL:
          if( pWVT->hWnd )
diff -ru a/contrib/gtwvg/gtwvg.h b/contrib/gtwvg/gtwvg.h
--- a/contrib/gtwvg/gtwvg.h	2018-01-04 18:31:52.000000000 +0100
+++ b/contrib/gtwvg/gtwvg.h	2018-02-05 12:42:53.683121838 +0100
@@ -337,6 +337,7 @@
    int      CaretWidth;                     /* Width of solid caret */
 
    POINT    MousePos;                       /* the last mouse position */
+   POINT    MousePosPxl;                    /* the last mouse position in pixel*/
    HB_BOOL  MouseMove;                      /* Flag to say whether to return mouse movement events */
 
    int      Keys[ WVT_CHAR_QUEUE_SIZE ];    /* Array to hold the characters & events */
diff -ru a/src/rtl/gtwvt/gtwvt.c b/src/rtl/gtwvt/gtwvt.c
--- a/src/rtl/gtwvt/gtwvt.c	2018-01-04 18:31:52.000000000 +0100
+++ b/src/rtl/gtwvt/gtwvt.c	2018-02-05 12:17:15.103064735 +0100
@@ -344,6 +344,8 @@
    pWVT->CaretWidth        = 0;
    pWVT->MousePos.x        = 0;
    pWVT->MousePos.y        = 0;
+   pWVT->MousePosPxl.x     = 0;
+   pWVT->MousePosPxl.y     = 0;
    pWVT->hWnd              = NULL;
    pWVT->keyPointerIn      = 0;
    pWVT->keyPointerOut     = 0;
@@ -2200,6 +2202,8 @@
 
    xy.x = LOWORD( lParam );
    xy.y = HIWORD( lParam );
+   pWVT->MousePosPxl.y = xy.y - pWVT->MarginLeft;
+   pWVT->MousePosPxl.x = xy.x - pWVT->MarginTop;
 
    if( message == WM_MOUSEWHEEL )
       ScreenToClient( pWVT->hWnd, &xy );
@@ -4308,6 +4312,14 @@
          }
          break;
 
+      case HB_GTI_MOUSEPOS_XY:
+         if( ! pInfo->pResult )
+            pInfo->pResult = hb_itemNew( NULL );
+         hb_arrayNew( pInfo->pResult, 2 );
+         hb_arraySetNI( pInfo->pResult, 1, pWVT->MousePosPxl.x );
+         hb_arraySetNI( pInfo->pResult, 2, pWVT->MousePosPxl.y );
+         break;
+
       case HB_GTI_SETPOS_XY:
       case HB_GTI_SETPOS_ROWCOL:
       {
diff -ru a/src/rtl/gtwvt/gtwvt.h b/src/rtl/gtwvt/gtwvt.h
--- a/src/rtl/gtwvt/gtwvt.h	2018-01-04 18:31:52.000000000 +0100
+++ b/src/rtl/gtwvt/gtwvt.h	2018-02-05 12:19:43.819070255 +0100
@@ -283,6 +283,7 @@
    int      CaretWidth;                   /* Width of solid caret */
 
    POINT    MousePos;                     /* the last mouse position */
+   POINT    MousePosPxl;                  /* the last mouse position in pixels */
 
    int      Keys[ 128 ];                  /* Array to hold the characters & events */
    int      keyPointerIn;                 /* Offset into key array for character to be placed */
@rjopek rjopek closed this as completed Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant