Exemplo n.º 1
0
  bool HandleMouseEvent(const Lum::OS::MouseEvent& event)
  {
    if (!visible) {
      return false;
    }

    if (event.type==Lum::OS::MouseEvent::down &&
        PointIsIn(event) &&
        event.button==Lum::OS::MouseEvent::button1) {
      requestNewMap=false;
      startLon=lon;
      startLat=lat;
      startX=event.x;
      startY=event.y;
      return true;
    }
    else if (event.IsGrabEnd() &&
             event.button==Lum::OS::MouseEvent::button1) {
      HandleMouseMove(event);
      requestNewMap=true;
      Redraw();
    }
    else if (event.type==Lum::OS::MouseEvent::move &&
             event.IsGrabed() &&
             event.button==Lum::OS::MouseEvent::none &&
             event.qualifier==Lum::OS::qualifierButton1) {
      HandleMouseMove(event);
      Redraw();
      return true;
    }
    else if (event.type==Lum::OS::MouseEvent::down &&
             event.button==Lum::OS::MouseEvent::button4) {
      ZoomIn(1.35);

      return true;
    }
    else if (event.type==Lum::OS::MouseEvent::down &&
             event.button==Lum::OS::MouseEvent::button5) {
      ZoomOut(1.35);

      return true;
    }

    return false;
  }
Exemplo n.º 2
0
  bool Button::HandleMouseEvent(const OS::MouseEvent& event)
  {
    /* It makes no sense to get the focus if we are currently not visible */
    if (!visible || !model.Valid() || !model->IsEnabled()) {
      return false;
    }

    /*
      When the left mousebutton gets pressed without any qualifier
      in the bounds of our button...
    */

    if (event.type==OS::MouseEvent::down &&
        PointIsIn(event) &&
        event.button==OS::MouseEvent::button1) {
      if (!model->IsStarted()) {
        /* We change our state to pressed and redisplay ourself */
        triggering=true;
        model->Start();

        if (pulse) {
          model->Trigger();
          triggering=false;
          OS::display->AddTimer(pulseSec,pulseMSec,model);
        }

        /*
          Since we want the focus for waiting for buttonup we return
          a pointer to ourself.
        */
        return true;
      }
    }
    else if (event.IsGrabEnd()) {
      if (model->IsStarted()) {
        /*
          If the users released the left mousebutton over our bounds we really
          got selected.
        */
        if (PointIsIn(event)) {
          if (pulse) {
            model->Cancel();
            triggering=false;
          }
          else {
            model->Finish();
            triggering=false;
          }
        }
        else {
          model->Cancel();
          triggering=false;
        }
      }

      // Clean up and remove possibly remaining timer event.
      if (pulse) {
        OS::display->RemoveTimer(model);
      }
    }
    else if (event.type==OS::MouseEvent::move && event.IsGrabed()) {
      if (PointIsIn(event)) {
        if (!model->IsStarted()) {
          triggering=true;
          model->Start();
        }
      }
      else {
        if (model->IsStarted()) {
          model->Cancel();
          triggering=false;
        }
      }

      return true;
    }

    return false;
  }