/*********************************************************************
*
*       WM_SetCaptureMove
*/
void WM_SetCaptureMove(WM_HWIN hWin, const GUI_PID_STATE* pState, int MinVisibility) {
  if (!WM_HasCaptured(hWin)) {
    WM_SetCapture(hWin, 1);        /* Set capture with auto release */
    WM__CapturePoint.x = pState->x;
    WM__CapturePoint.y = pState->y;
  } else {                         /* Moving ... let the window move ! */
    int dx, dy;
    dx = pState->x - WM__CapturePoint.x;
    dy = pState->y - WM__CapturePoint.y;
    /* make sure at least a part of the windows stays inside of its parent */
    if (MinVisibility == 0) {
      WM_MoveWindow(hWin, dx, dy);
    } else {
      GUI_RECT Rect, RectParent;
      /* make sure at least a part of the windows stays inside of its parent */
      WM_GetWindowRectEx(hWin, &Rect);
      WM_GetWindowRectEx(WM_GetParent(hWin), &RectParent);
      GUI_MoveRect(&Rect, dx, dy);
      GUI__ReduceRect(&RectParent, &RectParent, MinVisibility);
      if (GUI_RectsIntersect(&Rect, &RectParent)) {
        WM_MoveWindow(hWin, dx, dy);
      }
    }
  }
}
/*********************************************************************
*
*       _cbTransWindow
*/
static void _cbTransWindow(WM_MESSAGE* pMsg) {
  static GUI_PID_STATE   StateOld;
  GUI_PID_STATE        * pState;
  GUI_PID_STATE          StateNew;
  GUI_PID_STATE          State;
  WM_HWIN                hBelow;
  WM_HWIN                hWin;
  
  hWin = pMsg->hWin;
  GUI_PID_GetState(&StateNew);
  State    = ((StateNew.x == -1) && (StateNew.y == -1)) ? StateOld : StateNew;
  StateOld = State;
  switch (pMsg->MsgId) {
  case WM_PAINT:
    State.x -= WM_GetWindowOrgX(hWin);
    State.y -= WM_GetWindowOrgY(hWin);
    _DrawEye(EYE_X1, EYE_Y, State.x, State.y, EYE_RX, EYE_RY);
    _DrawEye(EYE_X2, EYE_Y, State.x, State.y, EYE_RX, EYE_RY);
    break;
  case WM_TOUCH:
    if (pMsg->Data.p) {
      pState = (GUI_PID_STATE *)pMsg->Data.p;
      if (pState->Pressed) {
        if (!_ClickedOutsideArea(pState->x, pState->y) || WM_HasCaptured(hWin)) {
          WM_SetCaptureMove(hWin, pState, MIN_VISIBILITY, 0);
        } else {
          //
          // Transfer the message to the underlying window, since the transparent area has been clicked
          //
          hBelow = WM_Screen2hWinEx(hWin, State.x, State.y);
          if (hBelow) {
            pState->x = State.x - WM_GetWindowOrgX(hBelow);
            pState->y = State.y - WM_GetWindowOrgY(hBelow);
            WM_SendMessage(hBelow, pMsg);
          }
        }
      }
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
/*********************************************************************
*
*       _SetCapture
*/
static void _SetCapture(FRAMEWIN_Handle hWin, int x, int y, int Mode) {
    if ((_CaptureFlags & FRAMEWIN_REPOS_X) == 0) {
        _CaptureX = x;
    }
    if ((_CaptureFlags & FRAMEWIN_REPOS_Y) == 0) {
        _CaptureY = y;
    }
    if (Mode) {
        if (WM_HasCaptured(hWin) == 0) {
            WM_SetCapture(hWin, 0);
        }
#if GUI_SUPPORT_CURSOR
        _SetResizeCursor(Mode);
#endif
        if (Mode & FRAMEWIN_MOUSEOVER) {
            Mode = 0;
        }
        _CaptureFlags = (Mode | FRAMEWIN_MOUSEOVER);
    }
}
Beispiel #4
0
static void _OnTouch(FRAMEWIN_Handle hWin, FRAMEWIN_Obj* pObj, WM_MESSAGE* pMsg) {
  GUI_TOUCH_tState* pState;
  pState = (GUI_TOUCH_tState*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      WM_SetFocus(hWin);
      WM_BringToTop(hWin);
      if (pObj->Flags & FRAMEWIN_SF_MOVEABLE) {
        if (!WM_HasCaptured(hWin)) {
          WM_SetCapture(hWin, 1);
          pObj->CapturePoint.x = pState->x;
          pObj->CapturePoint.y = pState->y;
        } else {
          int dx, dy;
          dx = pState->x - pObj->CapturePoint.x;
          dy = pState->y - pObj->CapturePoint.y;
          WM_MoveWindow(hWin, dx, dy);
        }
      }
    }
  }
}
Beispiel #5
0
/*********************************************************************
*
*       _OnTouch
*/
static int _OnTouch(FRAMEWIN_Handle hWin, WM_MESSAGE* pMsg) {
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    GUI_PID_STATE* pState;
    pState = (GUI_PID_STATE*)pMsg->Data.p;
    if (pState->Pressed) {
      int x, y;
      x = pState->x;
      y = pState->y;
      if (WM_HasCaptured(hWin) == 0) {
        GUI_RECT Rect;
        int Mode = 0;
        int BorderSize = 4;
        WM_GetClientRectEx(hWin, &Rect);
        if (x > (Rect.x1 - BorderSize)) {
          Mode |= RESIZE_X;
        } else if (x < BorderSize) {
          Mode |= RESIZE_X | REPOS_X;
        }
        if (y > (Rect.y1 - BorderSize)) {
          Mode |= RESIZE_Y;
        } else if (y < BorderSize) {
          Mode |= RESIZE_Y | REPOS_Y;
        }
        if (Mode) {
          WM_SetFocus(hWin);
          WM_BringToTop(hWin);
          _SetCapture(hWin, x, y, Mode);
          return 1;
        }
      } else if (_HasCaptured) {
        _ChangeWindowPosSize(hWin, &x, &y);
        _SetCapture(hWin, x, y, 0);
        return 1;
      }
    }
  }
  _HasCaptured = 0;
  return 0;
}
static int _OnMouseOver(FRAMEWIN_Handle hWin, WM_MESSAGE* pMsg) {
    const GUI_PID_STATE* pState = (const GUI_PID_STATE *)pMsg->Data.p;
    if (pState) {
        int x, y, Mode;
        x    = pState->x;
        y    = pState->y;
        Mode = _CheckReactBorder(hWin, x, y);
        if (Mode) {
            if (_ForwardMouseOverMsg(hWin, pMsg) == 0) {
                _SetCapture(hWin, x, y, Mode | FRAMEWIN_MOUSEOVER);
            }
            return 1;
        } else if (WM_HasCaptured(hWin)) {
            if ((_CaptureFlags & FRAMEWIN_RESIZE) == 0) {
                WM_ReleaseCapture();
                _ForwardMouseOverMsg(hWin, pMsg);
            }
            return 1;
        }
    }
    return 0;
}
/*********************************************************************
*
*       _OnTouch
*/
static int _OnTouch(FRAMEWIN_Handle hWin, WM_MESSAGE* pMsg) {
    const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p;
    if (pState) {  /* Something happened in our area (pressed or released) */
        int x, y, Mode;
        x    = pState->x;
        y    = pState->y;
        Mode = _CheckReactBorder(hWin, x, y);
        if (pState->Pressed == 1) {
            if (_CaptureFlags & FRAMEWIN_RESIZE) {
                _ChangeWindowPosSize(hWin, &x, &y);
                _SetCapture(hWin, x, y, 0);
                return 1;
            } else if (Mode) {
                WM_SetFocus(hWin);
                WM_BringToTop(hWin);
                _SetCapture(hWin, x, y, Mode);
                return 1;
            }
#if (GUI_SUPPORT_MOUSE & GUI_SUPPORT_CURSOR)
            else if (_CaptureFlags) {
                WM_ReleaseCapture();
                return 1;
            }
#endif
        } else if (WM_HasCaptured(hWin)) {
            _CaptureFlags &= ~(FRAMEWIN_RESIZE);
#if (GUI_SUPPORT_MOUSE & GUI_SUPPORT_CURSOR)
            if (!Mode)
#endif
            {
                WM_ReleaseCapture();
            }
            return 1;
        }
    }
    return 0;
}
Beispiel #8
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(CHECKBOX_Handle hObj, CHECKBOX_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification = 0;
  int Hit = 0;
  const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (!WM_HasCaptured(hObj)) {
      if (pState->Pressed) {
        WM_SetCapture(hObj, 1);
        CHECKBOX_SetState(hObj, (pObj->CurrentState + 1) % pObj->NumStates);
        Notification = WM_NOTIFICATION_CLICKED;
      } else {
        Hit =1;
        Notification = WM_NOTIFICATION_RELEASED;
      }
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("CHECKBOX: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
/*********************************************************************
*
*       _HOOKFUNC_Resizeable
*/
static int _HOOKFUNC_Resizeable(WM_MESSAGE* pMsg) {
    WM_HWIN hWin = pMsg->hWin;
    if (WM_HasCaptured(hWin) && (_CaptureFlags == 0)) {
        return 0;
    }
    if (FRAMEWIN_IsMinimized(hWin) || FRAMEWIN_IsMaximized(hWin)) {
        return 0;
    }
    switch(pMsg->MsgId) {
    case WM_TOUCH:
        return _OnTouch(hWin, pMsg);
#if (GUI_SUPPORT_MOUSE & GUI_SUPPORT_CURSOR)
    case WM_MOUSEOVER:
        return _OnMouseOver(hWin, pMsg);
#endif
    case WM_CAPTURE_RELEASED:
#if GUI_SUPPORT_CURSOR
        _SetResizeCursor(0);
#endif
        _CaptureFlags = 0;
        return 1;
    }
    return 0;
}