Ejemplo n.º 1
0
void WidgetList::Draw(const Point2i &mousePosition)
{
  Rectanglei clip;
  Rectanglei wlr = GetClip(clip);
  if (!wlr.GetSizeX() || !wlr.GetSizeY())
      return;

  for (std::list<Widget*>::const_iterator w=widget_list.begin();
      w != widget_list.end();
      w++)
  {
    Rectanglei r((*w)->GetPosition(), (*w)->GetSize());
    r.Clip(wlr);

    if (r.GetSizeX() && r.GetSizeY()) {
      Rectanglei wr = r;
      SwapWindowClip(r);
      (*w)->RedrawBackground(wr);
      (*w)->Draw(mousePosition);
      (*w)->RedrawForeground();
      SwapWindowClip(r);
    }
  }

  // Restore initial clip rectangle
  UnsetClip(clip);
}
Ejemplo n.º 2
0
bool WidgetList::Update(const Point2i& mousePosition,
                        const Point2i& lastMousePosition)
{
  Rectanglei clip;
  Rectanglei wlr = GetClip(clip);
  if (!wlr.GetSizeX() || !wlr.GetSizeY())
      return false;

  // Redraw the background
  bool updated = false;
  if (need_redrawing)
    RedrawBackground(wlr);

  for (std::list<Widget*>::const_iterator w=widget_list.begin();
      w != widget_list.end();
      w++)
  {
    Rectanglei r((*w)->GetPosition(), (*w)->GetSize());
    r.Clip(wlr);

    if (r.GetSizeX() && r.GetSizeY()) {
      SwapWindowClip(r);
      updated |= (*w)->Update(mousePosition, lastMousePosition);
      SwapWindowClip(r);
    }
  }

  if (updated)
    RedrawForeground();

  // Restore initial clip rectangle
  UnsetClip(clip);
  need_redrawing = false;
  return updated;
}
Ejemplo n.º 3
0
void TextBox::Draw(const Point2i & mousePosition)
{
  Rectanglei clip;
  Rectanglei wlr = GetClip(clip);
  if (!wlr.GetSizeX() || !wlr.GetSizeY())
      return;

  Label::Draw(mousePosition);
  DrawCursor(position, cursor_pos);

  // Restore initial clip rectangle
  UnsetClip(clip);
}
Ejemplo n.º 4
0
inline bool PhysicalObj::Intersect(const Rectanglei & rect) const
{
  int dim = m_width - m_test_right - m_test_left;
  dim = dim ? dim : 1;

  int obj_test1 = GetX() + m_test_left;
  int obj_test2 = obj_test1 + dim - 1;
  int test1 = rect.GetPositionX();
  int test2 = test1 + rect.GetSizeX() - 1;

  if (obj_test2 >= test1 && obj_test1 <= test2) {
    dim = m_height - m_test_bottom - m_test_top;
    dim = dim ? dim : 1;
    obj_test1 = GetY() + m_test_top;
    obj_test2 = obj_test1 + dim - 1;
    test1 = rect.GetPositionY();
    test2 = test1 + rect.GetSizeY() - 1;

    if (obj_test2 >= test1 && obj_test1 <= test2)
      return true;
  }
  return false;
}