void base_visualizer_client::on_mouse_up (int x, int y, int button)
{
    coord<int> screen (x, y);
    dragging_ = false;
    last_coord_ = screen;
    on_paint();
}
void base_visualizer_client::on_mouse_move(int x, int y)
{
    coord<int> screen (x, y);
    if (dragging_)
    {
        pscope_->drag (screen - last_coord_);
        on_paint();
    }
    last_coord_ = screen;
}
void base_visualizer_client::on_mouse_down (int x, int y, int button)
{
    coord<int> screen (x, y);
    if (button == 0)
    {
        dragging_ = true;
        last_coord_ = screen;
    }
    else if (button == 1)
    {
    }
    on_paint();
}
void base_visualizer_client::on_key_down(int key)
{
    const float ZOOM = 1.2f;
    switch (key)
    {
    case VK_PRIOR:
        pscope_->zoom(ZOOM, last_coord_);
        break;
    case VK_NEXT:
        pscope_->zoom(1.0f / ZOOM, last_coord_);
        break;
    }
    on_paint();
}
Exemplo n.º 5
0
LRESULT
PaintWindow::on_message(HWND hWnd, UINT message,
                        WPARAM wParam, LPARAM lParam)
{
  switch (message) {
  case WM_ERASEBKGND:
    {
      Canvas canvas((HDC)wParam, get_width(), get_height());
      if (on_erase(canvas))
        return 0;
    }
    break;

  case WM_PAINT:
    {
      PaintCanvas canvas(*this, hWnd);
      on_paint(canvas);
    }
    return 0;
  }

  return Window::on_message(hWnd, message, wParam, lParam);
}
void base_visualizer_client::on_resize(int width, int height)
{
    //pd_->resize(width, height);
    on_paint();
}
void base_visualizer_client::on_wheel (int delta)
{
    pscope_->zoom (pow(1.2f, delta / 120.0f), last_coord_);
    on_paint();
}
Exemplo n.º 8
0
// ---------------------------------------------------------------------------
void X11WindowImpl::update()
{
  on_paint();
}
Exemplo n.º 9
0
void
TopWindow::expose() {
  on_paint(screen);
  screen.Flip();
}
Exemplo n.º 10
0
 void paint() {
   on_paint(canvas);
 }
Exemplo n.º 11
0
LRESULT
Window::on_message(HWND _hWnd, UINT message,
                       WPARAM wParam, LPARAM lParam)
{
  if (IsEmbedded() && !IsAltair()) {
    /* some older iPaqs such as the H3900 send only WM_KEYUP for
       VK_APP*, but never VK_KEYDOWN; the hx4700 has an additional set
       of undocumented key codes (0xca..0xcd) for the APP keys, but
       sends WM_KEYUP/VK_APP* additionally; the following rules
       hopefully catch all of these obscurities */
    if (message == WM_KEYUP && wParam >= 0x80)
      /* convert to WM_KEYDOWN to make all handlers catch it */
      message = WM_KEYDOWN;
    else if (message == WM_KEYDOWN && wParam >= 0x80)
      /* ignore the real WM_KEYDOWN, just in case it really happens */
      return 0;
  }

  switch (message) {
  case WM_CREATE:
    on_create();
    return 0;

  case WM_DESTROY:
    on_destroy();
    return 0;

  case WM_CLOSE:
    if (on_close())
      /* true returned: message was handled */
      return 0;
    break;

  case WM_SIZE:
    on_resize(LOWORD(lParam), HIWORD(lParam));
    return 0;

  case WM_MOUSEMOVE:
    if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam))
      return 0;
    break;

  case WM_LBUTTONDOWN:
    if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONUP:
    if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONDBLCLK:
    if (!double_clicks)
      /* instead of disabling CS_DBLCLKS (which would affect all
         instances of a window class), we just translate
         WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for
         built-in window class such as BUTTON */
      return on_message(_hWnd, WM_LBUTTONDOWN, wParam, lParam);

    if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }

    break;

#ifdef WM_MOUSEWHEEL
  case WM_MOUSEWHEEL:
    if (on_mouse_wheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                       GET_WHEEL_DELTA_WPARAM(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;
#endif

  case WM_KEYDOWN:
    if (on_key_down(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_KEYUP:
    if (on_key_up(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_COMMAND:
    if (on_command(LOWORD(wParam), HIWORD(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_CANCELMODE:
    if (on_cancel_mode())
      return 0;
    break;

  case WM_SETFOCUS:
    on_setfocus();
    return 0;

  case WM_KILLFOCUS:
    on_killfocus();
    return 0;

  case WM_TIMER:
    if (on_timer(*(WindowTimer *)wParam))
      return 0;
    break;

  case WM_PAINT:
    if (custom_painting) {
      PaintCanvas canvas(*this);
      on_paint(canvas, canvas.get_dirty());
      return 0;
    }
    break;

  case WM_GETDLGCODE:
    if (on_key_check(wParam))
      return DLGC_WANTMESSAGE;
    break;
  }

  if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER))
    return 0;

  return on_unhandled_message(_hWnd, message, wParam, lParam);
}
Exemplo n.º 12
0
// ---------------------------------------------------------------------------
OSStatus OSXWindowImpl::windowHandler(EventHandlerCallRef next, EventRef e) {
  EventClass clazz = GetEventClass(e);
  EventKind kind = GetEventKind(e);
  switch( clazz ) {
    case kEventClassWindow:
      {
        switch( kind ) {
          case kEventWindowDrawContent:
            on_paint();
            break;
          case kEventWindowClosed:
            on_dispose();
            break;
          case kEventWindowBoundsChanged:
            {
              aglUpdateContext(mGLContext);
              GetWindowBounds(mWindowRef,kWindowContentRgn,&mRect);
              if (window)
                window->resize( mRect.right - mRect.left, mRect.bottom - mRect.top );
            }
            break; 
        }
      }
      break;
    case kEventClassMouse:
      {
        EventMouseButton button;
        GetEventParameter(e,kEventParamMouseButton,   typeMouseButton, NULL, sizeof(button), NULL, &button);
        Point location;
        GetEventParameter(e,kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &location);
        int mouseX = location.h - mRect.left;
        int mouseY = location.v - mRect.top;
        switch( kind ) {
          case kEventMouseDown:
            {
          
              UInt32 mod = GetCurrentKeyModifiers();
              if (mod & EMULATE_RIGHT_KEYMOD) {
                mButtonDown = GUI_ButtonRight;
                mMouseDownMod = EMULATE_RIGHT_KEYMOD;
              } else if (mod & EMULATE_MIDDLE_KEYMOD) {
                mButtonDown = GUI_ButtonMiddle;
                mMouseDownMod = EMULATE_MIDDLE_KEYMOD;
              } else {
                mButtonDown = button;
                mMouseDownMod = 0;
              }
              window->buttonPress( mButtonDown,mouseX,mouseY);
            }
            break;
          case kEventMouseUp:
            if ( (mButtonDown) && ( (mMouseDownMod) || (mButtonDown == button) ) ) {
              window->buttonRelease( mButtonDown,mouseX,mouseY);
              mMouseDownMod = 0;
              mButtonDown   = 0;
            }
            break;
          case kEventMouseMoved:
          case kEventMouseDragged:
            window->mouseMove(mouseX,mouseY);
            break;
          case kEventMouseWheelMoved:
            UInt16 axis;
            GetEventParameter(e,kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis);
            if (axis == kEventMouseWheelAxisY) {
              int delta;
              GetEventParameter(e,kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(delta), NULL, &delta);
              if (delta != 0)
                window->wheelRotate( (delta > 0) ? GUI_WheelForward : GUI_WheelBackward );
            }
        }
      }
      break;
    case kEventClassKeyboard:
      {
        UInt32 keycode;
        GetEventParameter(e,kEventParamKeyCode, typeUInt32, NULL, sizeof(keycode), NULL, &keycode);
        switch( kind ) {
          case kEventRawKeyDown:
            break;
          case kEventRawKeyUp:
            break;
          case kEventRawKeyModifiersChanged:
            
            break;
          default:
            break;
        }
      }
      break;
    default:
      break;
  }   
  return CallNextEventHandler(next,e);
}