当前位置: 首页>>代码示例>>C++>>正文


C++ Rect::IsPointIn方法代码示例

本文整理汇总了C++中Rect::IsPointIn方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::IsPointIn方法的具体用法?C++ Rect::IsPointIn怎么用?C++ Rect::IsPointIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rect的用法示例。


在下文中一共展示了Rect::IsPointIn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnMouseButtonEvent

bool GuiList::OnMouseButtonEvent(const MouseButtonEvent& mbe)
{
  if (!IsVisible())
  {
    return false;
  }

  Vec2f cursorPos(mbe.x, mbe.y);
 
  if (mbe.button == AMJU_BUTTON_MOUSE_LEFT &&
      mbe.isDown)
  {
    // Stop scrolling, no?
    GuiScroll* scroll = dynamic_cast<GuiScroll*>(GetParent());
    Assert(scroll);
    scroll->StopScrolling();

    // Check each item
    int selected = -1;
    for (unsigned int i = 0; i < m_children.size(); i++)
    {
      GuiElement* item = m_children[i];

      Rect r = GetRect(item);

      if (r.IsPointIn(cursorPos))
      {
        selected = i;
        break; 
      }
    }

    if (selected != -1)
    {
      // TODO Should react on mouse up when up item == down item ??

      if (IsMultiSel())
      {
        // Toggle selected flag for this child
        SetSelected(selected, !IsSelected(selected));
      }
      else
      {
        SetSelected(selected, true);
        if (m_singleClickFunc)
        {
          m_singleClickFunc(this, selected);
        }
      }

      // TODO Why is this a bad idea ?
      //m_items[m_selected]->ExecuteCommand(); 

      // Problem with nested item, but should open up on mouse over anyway...
//      SetVisible(false); // TODO flag for this behaviour
      return true; // handled
    }
  }
  return false; // not handled
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:60,代码来源:GuiListBox.cpp

示例2: OnCursorEvent

bool GuiTextEdit::OnCursorEvent(const CursorEvent& ce)
{
  // TODO In drag mode, select part of the text

  Rect r = GetRect(this);
  if (!r.IsPointIn(Vec2f(ce.x, ce.y)))
  {
    //return false; // not handled - cursor not in edit box
    // We do want to hande this, e.g. if we drag mouse past the right hand end, we want to select all text.
  }

  if (s_drag && HasFocus())
  {
    m_selectedText = CalcCursorPos(ce.x);
    m_triListSelection = 0;
      
#ifdef TEXT_EDIT_DEBUG
std::cout << "Selected: m_caret: " << m_caret << " m_selectedText: " << m_selectedText << ": \"";
if (m_caret > m_selectedText)
{
  std::cout << m_text.substr(m_selectedText, m_caret - m_selectedText);
}
else
{
  std::cout << m_text.substr(m_caret, m_selectedText - m_caret);
}
std::cout << "\"\n";
#endif
  }

  return false;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:32,代码来源:GuiTextEdit.cpp

示例3: OnDoubleClickEvent

bool GuiList::OnDoubleClickEvent(const DoubleClickEvent& dce)
{
  if (dce.button != AMJU_BUTTON_MOUSE_LEFT)
  {
    return false;
  }

  if (!IsVisible())
  {
    return false;
  }

  if (m_doubleClickFunc)
  {
    Vec2f cursorPos(dce.x, dce.y);
    for (unsigned int i = 0; i < m_children.size(); i++)
    {
      GuiElement* item = m_children[i];
      Rect r = GetRect(item);
      if (r.IsPointIn(cursorPos))
      {
        m_doubleClickFunc(this, i);
        return true; 
      }
    }
  }

  return false;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:29,代码来源:GuiListBox.cpp

示例4: OnMouseButtonEvent

bool GuiTextEdit::OnMouseButtonEvent(const MouseButtonEvent& mbe)
{
  if (!IsVisible())
  {
    return false;
  }

  Rect r = GetRect(this);
  if (!r.IsPointIn(Vec2f(mbe.x, mbe.y)))
  {
    return false; // not handled - cursor not in edit box
  }

  // We want to drag to select text even if this is not the focus ?
  //if (HasFocus())
  {
    s_drag = mbe.isDown;
#ifdef TEXT_EDIT_DEBUG
std::cout << "GuiTextEdit Drag is now " << (s_drag ? "ON" : "OFF") << "\n";
#endif
  }

  // If clicked in bounding rect, this element gets focus
  SetHasFocus(true);

  if (!mbe.isDown)
  {
    return true;  
  }

  m_caret = CalcCursorPos(mbe.x);
  m_selectedText = m_caret;
  m_triListSelection = 0;

#ifdef TEXT_EDIT_DEBUG
std::cout << "MB down, resetting selection trilist.\n";
#endif

  return true; // ?
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:40,代码来源:GuiTextEdit.cpp


注:本文中的Rect::IsPointIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。