Exemplo n.º 1
0
void PopupWindow::onHitTest(HitTestEvent& ev)
{
  Widget* picked = manager()->pick(ev.point());
  if (picked) {
    WidgetType type = picked->type();
    if ((type == kWindowWidget && picked == this) ||
        type == kBoxWidget ||
        type == kLabelWidget ||
        type == kGridWidget ||
        type == kSeparatorWidget) {
      ev.setHit(HitTestCaption);
      return;
    }
  }
  Window::onHitTest(ev);
}
Exemplo n.º 2
0
void PopupWindowPin::onHitTest(HitTestEvent& ev)
{
  PopupWindow::onHitTest(ev);

  if ((m_pin.isSelected()) &&
      (ev.hit() == HitTestClient)) {
    if (ev.point().x <= bounds().x+2)
      ev.setHit(HitTestBorderW);
    else if (ev.point().x >= bounds().x2()-3)
      ev.setHit(HitTestBorderE);
    else
      ev.setHit(HitTestCaption);
  }
}
Exemplo n.º 3
0
void Window::onHitTest(HitTestEvent& ev)
{
  HitTest ht = HitTestNowhere;

  if (!m_isMoveable) {
    ev.setHit(ht);
    return;
  }

  int x = ev.getPoint().x;
  int y = ev.getPoint().y;
  gfx::Rect pos = getBounds();
  gfx::Rect cpos = getChildrenBounds();

  // Move
  if ((hasText())
      && (((x >= cpos.x) &&
           (x < cpos.x2()) &&
           (y >= pos.y+this->border_width.b) &&
           (y < cpos.y)))) {
    ht = HitTestCaption;
  }
  // Resize
  else if (m_isSizeable) {
    if ((x >= pos.x) && (x < cpos.x)) {
      if ((y >= pos.y) && (y < cpos.y))
        ht = HitTestBorderNW;
      else if ((y > cpos.y2()-1) && (y <= pos.y2()-1))
        ht = HitTestBorderSW;
      else
        ht = HitTestBorderW;
    }
    else if ((y >= pos.y) && (y < cpos.y)) {
      if ((x >= pos.x) && (x < cpos.x))
        ht = HitTestBorderNW;
      else if ((x > cpos.x2()-1) && (x <= pos.x2()-1))
        ht = HitTestBorderNE;
      else
        ht = HitTestBorderN;
    }
    else if ((x > cpos.x2()-1) && (x <= pos.x2()-1)) {
      if ((y >= pos.y) && (y < cpos.y))
        ht = HitTestBorderNE;
      else if ((y > cpos.y2()-1) && (y <= pos.y2()-1))
        ht = HitTestBorderSE;
      else
        ht = HitTestBorderE;
    }
    else if ((y > cpos.y2()-1) && (y <= pos.y2()-1)) {
      if ((x >= pos.x) && (x < cpos.x))
        ht = HitTestBorderSW;
      else if ((x > cpos.x2()-1) && (x <= pos.x2()-1))
        ht = HitTestBorderSE;
      else
        ht = HitTestBorderS;
    }
  }
  else {
    // Client area
    ht = HitTestClient;
  }

  ev.setHit(ht);
}
Exemplo n.º 4
0
void Window::onHitTest(HitTestEvent& ev)
{
  HitTest ht = HitTestNowhere;

  // If this window is not movable or we are not completely visible.
  if (!m_isMoveable ||
      // TODO check why this is necessary, there should be a bug in
      // the manager where we are receiving mouse events and are not
      // the top most window.
      getManager()->pick(ev.getPoint()) != this) {
    ev.setHit(ht);
    return;
  }

  int x = ev.getPoint().x;
  int y = ev.getPoint().y;
  gfx::Rect pos = getBounds();
  gfx::Rect cpos = getChildrenBounds();

  // Move
  if ((hasText())
      && (((x >= cpos.x) &&
           (x < cpos.x2()) &&
           (y >= pos.y+this->border_width.b) &&
           (y < cpos.y)))) {
    ht = HitTestCaption;
  }
  // Resize
  else if (m_isSizeable) {
    if ((x >= pos.x) && (x < cpos.x)) {
      if ((y >= pos.y) && (y < cpos.y))
        ht = HitTestBorderNW;
      else if ((y > cpos.y2()-1) && (y <= pos.y2()-1))
        ht = HitTestBorderSW;
      else
        ht = HitTestBorderW;
    }
    else if ((y >= pos.y) && (y < cpos.y)) {
      if ((x >= pos.x) && (x < cpos.x))
        ht = HitTestBorderNW;
      else if ((x > cpos.x2()-1) && (x <= pos.x2()-1))
        ht = HitTestBorderNE;
      else
        ht = HitTestBorderN;
    }
    else if ((x > cpos.x2()-1) && (x <= pos.x2()-1)) {
      if ((y >= pos.y) && (y < cpos.y))
        ht = HitTestBorderNE;
      else if ((y > cpos.y2()-1) && (y <= pos.y2()-1))
        ht = HitTestBorderSE;
      else
        ht = HitTestBorderE;
    }
    else if ((y > cpos.y2()-1) && (y <= pos.y2()-1)) {
      if ((x >= pos.x) && (x < cpos.x))
        ht = HitTestBorderSW;
      else if ((x > cpos.x2()-1) && (x <= pos.x2()-1))
        ht = HitTestBorderSE;
      else
        ht = HitTestBorderS;
    }
  }
  else {
    // Client area
    ht = HitTestClient;
  }

  ev.setHit(ht);
}
Exemplo n.º 5
0
void Window::onHitTest(HitTestEvent& ev)
{
    HitTest ht = HitTestNowhere;

    if (!m_isMoveable) {
        ev.setHit(ht);
        return;
    }

    int x = ev.getPoint().x;
    int y = ev.getPoint().y;
    JRect pos = jwidget_get_rect(this);
    JRect cpos = jwidget_get_child_rect(this);

    // Move
    if ((this->hasText())
            && (((x >= cpos->x1) &&
                 (x < cpos->x2) &&
                 (y >= pos->y1+this->border_width.b) &&
                 (y < cpos->y1)))) {
        ht = HitTestCaption;
    }
    // Resize
    else if (m_isSizeable) {
        if ((x >= pos->x1) && (x < cpos->x1)) {
            if ((y >= pos->y1) && (y < cpos->y1))
                ht = HitTestBorderNW;
            else if ((y > cpos->y2-1) && (y <= pos->y2-1))
                ht = HitTestBorderSW;
            else
                ht = HitTestBorderW;
        }
        else if ((y >= pos->y1) && (y < cpos->y1)) {
            if ((x >= pos->x1) && (x < cpos->x1))
                ht = HitTestBorderNW;
            else if ((x > cpos->x2-1) && (x <= pos->x2-1))
                ht = HitTestBorderNE;
            else
                ht = HitTestBorderN;
        }
        else if ((x > cpos->x2-1) && (x <= pos->x2-1)) {
            if ((y >= pos->y1) && (y < cpos->y1))
                ht = HitTestBorderNE;
            else if ((y > cpos->y2-1) && (y <= pos->y2-1))
                ht = HitTestBorderSE;
            else
                ht = HitTestBorderE;
        }
        else if ((y > cpos->y2-1) && (y <= pos->y2-1)) {
            if ((x >= pos->x1) && (x < cpos->x1))
                ht = HitTestBorderSW;
            else if ((x > cpos->x2-1) && (x <= pos->x2-1))
                ht = HitTestBorderSE;
            else
                ht = HitTestBorderS;
        }
    }
    else {
        // Client area
        ht = HitTestClient;
    }

    jrect_free(pos);
    jrect_free(cpos);

    ev.setHit(ht);
}