Example #1
0
void DropChoice::DoWheel(int zdelta)
{
	if(!appending)
		DoKey(zdelta < 0 ? K_UP : K_DOWN);
}
Example #2
0
void Compositor::Deliver(const Input& input) {

    int             delta_x;
    int             delta_y;

    // Calculate m_cursor_x and delta_x
    {
        int new_x = m_cursor_x + input.DeltaX();
        if (new_x < 0) {
            new_x = 0;
        }
        if (new_x >= anvil_sysinfo->vbe_info.width) {
            new_x = anvil_sysinfo->vbe_info.width - 1;
        }
        delta_x = new_x - m_cursor_x;
        m_cursor_x = new_x;
    }

    // Calculate m_cursor_y and delta_y
    {
        int new_y = m_cursor_y - input.DeltaY();
        if (new_y < 0) {
            new_y = 0;
        }
        if (new_y >= anvil_sysinfo->vbe_info.height) {
            new_y = anvil_sysinfo->vbe_info.height - 1;
        }
        delta_y = new_y - m_cursor_y;
        m_cursor_y = new_y;
    }

    // Work out who gets the event
    ClientWindow    *event_win;
    if (m_mouse_mode == MOUSE_MODE_NONE) {
        event_win = (ClientWindow *)(m_windowlist.CheckBounds(m_cursor_x, m_cursor_y, (int&)m_cursor_type));
        if (event_win && !event_win->isResizable())
        {
            m_cursor_type = CURSOR_NORM;
        }
    }
    else {
        event_win = m_focussed_win;
    }

    //anvil_syslog(0, "Compositor::Deliver %016lx %d\n", mouse_win, cur_type);
    /*
     * We know the window but not every event goes directly to the
     * window. It depends on the mouse_mode and the shift_state
     */

    switch (input.Type()) {

        case INPUT_TYPE_KEY_PRESS:
        case INPUT_TYPE_KEY_RELEASE:
            DoKey(event_win, input);
            break;

        case INPUT_TYPE_MOUSE_DOWN:
            switch (input.Button()) {
                case INPUT_MOUSE_BTN_LEFT:
                    DoPressLeft(event_win, input);
                    break;
                case INPUT_MOUSE_BTN_MIDDLE:
                    DoPressMiddle(event_win, input);
                    break;
                case INPUT_MOUSE_BTN_RIGHT:
                    DoPressRight(event_win, input);
                    break;
            }
            break;

        case INPUT_TYPE_MOUSE_UP:
            switch (input.Button()) {
                case INPUT_MOUSE_BTN_LEFT:
                    DoReleaseLeft(event_win, input);
                    break;
                case INPUT_MOUSE_BTN_MIDDLE:
                    DoReleaseMiddle(event_win, input);
                    break;
                case INPUT_MOUSE_BTN_RIGHT:
                    DoReleaseRight(event_win, input);
                    break;
            }
            break;
        case INPUT_TYPE_MOUSE_MOVE:
            if (m_mouse_mode == MOUSE_MODE_NONE) {
                // Detect mouse entry and exit events here
            }
            else if (m_mouse_mode == MOUSE_MODE_MOVE) {
                if (m_focussed_win && m_focussed_win->isMoveable()) {
                    m_focussed_win->Move(delta_x, delta_y);
                    m_windowlist.SetDirty();
                }
            }
            else {
                if (m_focussed_win && m_focussed_win->isResizable()) {
                    // Create a resize message to the window
                    int x1, y1, x2, y2, w, h;
                    m_focussed_win->GetPos(x1, y1);
                    m_focussed_win->GetSize(w, h);
                    x2 = x1 + w;
                    y2 = y1 + h;
                    if (m_mouse_mode & MOUSE_MODE_RESIZE_L) {
                        x1 = m_cursor_x;
                        if (x1 >= x2) x1 = x2 - 1;
                    }
                    if (m_mouse_mode & MOUSE_MODE_RESIZE_T) {
                        y1 = m_cursor_y;
                        if (y1 >= y2) y1 = y2 - 1;
                    }
                    if (m_mouse_mode & MOUSE_MODE_RESIZE_R) {
                        x2 = m_cursor_x;
                        if (x2 <= x1) x2 = x1 + 1;
                    }
                    if (m_mouse_mode & MOUSE_MODE_RESIZE_B) {
                        y2 = m_cursor_y;
                        if (y2 <= y1) y2 = y1 + 1;
                    }
                    //anvil_syslog(0, "Checking move %d %d %d %d\n", x1, x2, y1, y2);
                    ace_event_t event;
                    event.type = ACE_EVTYPE_SIZE;
                    event.size.width = x2 - x1;
                    event.size.height = y2 - y1;
                    m_focussed_win->AddEvent(event);
                    m_focussed_win->setResizeMode(m_mouse_mode);
                    //m_windowlist.SetDirty();
                }
            }

            break;
    }

    ChooseCursor();

    RedoAll();
}
Example #3
0
FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
                                         IFWL_Widget* pMessageForm) {
  FX_BOOL bRet = FALSE;
  switch (pMessage->GetClassID()) {
    case FWL_MSGHASH_Activate: {
      bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_Deactivate: {
      bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage),
                          pMessageForm);
      break;
    }
    case FWL_MSGHASH_SetFocus: {
      bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_KillFocus: {
      bRet =
          DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_Key: {
      bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_Mouse: {
      bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_MouseWheel: {
      bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm);
      break;
    }
    case FWL_MSGHASH_Size: {
      bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage));
      break;
    }
    case FWL_MSGHASH_Cursor: {
      bRet = TRUE;
      break;
    }
    case FWL_MSGHASH_WindowMove: {
      bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage),
                          pMessageForm);
      break;
    }
    case FWL_MSGHASH_DropFiles: {
      bRet =
          DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm);
      break;
    }
    default: {
      bRet = TRUE;
      break;
    }
  }
  if (bRet) {
    IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL);
    if (pDelegate) {
      pDelegate->OnProcessMessage(pMessage);
    }
  }
  return bRet;
}