renamed wxRect::Inside() to wxRect::Contains(), wxRect::Inside(wxRect) is too confusing

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-09-13 17:12:25 +00:00
parent 23621b352c
commit 22a35096a0
30 changed files with 74 additions and 60 deletions

View File

@@ -417,10 +417,17 @@ public:
bool operator!=(const wxRect& rect) const { return !(*this == rect); }
// return true if the point is (not strcitly) inside the rect
bool Inside(int x, int y) const;
bool Inside(const wxPoint& pt) const { return Inside(pt.x, pt.y); }
bool Contains(int x, int y) const;
bool Contains(const wxPoint& pt) const { return Contains(pt.x, pt.y); }
// return true if the rectangle is (not strcitly) inside the rect
bool Inside(const wxRect& rect) const;
bool Contains(const wxRect& rect) const;
#if WXWIN_COMPATIBILITY_2_6
// use Contains() instead
wxDEPRECATED( bool Inside(int x, int y) const );
wxDEPRECATED( bool Inside(const wxPoint& pt) const );
wxDEPRECATED( bool Inside(const wxRect& rect) const );
#endif // WXWIN_COMPATIBILITY_2_6
// return true if the rectangles have a non empty intersection
bool Intersects(const wxRect& rect) const;
@@ -453,6 +460,13 @@ public:
int x, y, width, height;
};
#if WXWIN_COMPATIBILITY_2_6
inline bool wxRect::Inside(int x, int y) const { return Contains(x, y); }
inline bool wxRect::Inside(const wxPoint& pt) const { return Contains(pt); }
inline bool wxRect::Inside(const wxRect& rect) const { return Contains(rect); }
#endif // WXWIN_COMPATIBILITY_2_6
// ---------------------------------------------------------------------------
// Management of pens, brushes and fonts
// ---------------------------------------------------------------------------

View File

@@ -500,7 +500,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc)
// true if a tab was hit, otherwise false
bool wxAuiTabContainer::TabHitTest(int x, int y, wxWindow** hit) const
{
if (!m_rect.Inside(x,y))
if (!m_rect.Contains(x,y))
return false;
size_t i, page_count = m_pages.GetCount();
@@ -508,7 +508,7 @@ bool wxAuiTabContainer::TabHitTest(int x, int y, wxWindow** hit) const
for (i = 0; i < page_count; ++i)
{
wxAuiNotebookPage& page = m_pages.Item(i);
if (page.rect.Inside(x,y))
if (page.rect.Contains(x,y))
{
*hit = page.window;
return true;
@@ -523,7 +523,7 @@ bool wxAuiTabContainer::TabHitTest(int x, int y, wxWindow** hit) const
bool wxAuiTabContainer::ButtonHitTest(int x, int y,
wxAuiTabContainerButton** hit) const
{
if (!m_rect.Inside(x,y))
if (!m_rect.Contains(x,y))
return false;
size_t i, button_count = m_buttons.GetCount();
@@ -531,7 +531,7 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y,
for (i = 0; i < button_count; ++i)
{
wxAuiTabContainerButton& button = m_buttons.Item(i);
if (button.rect.Inside(x,y))
if (button.rect.Contains(x,y))
{
*hit = &button;
return true;
@@ -1455,7 +1455,7 @@ wxAuiTabCtrl* wxAuiMultiNotebook::GetTabCtrlFromPoint(const wxPoint& pt)
continue;
wxTabFrame* tabframe = (wxTabFrame*)all_panes.Item(i).window;
if (tabframe->m_tab_rect.Inside(pt))
if (tabframe->m_tab_rect.Contains(pt))
return tabframe->m_tabs;
}

View File

@@ -562,7 +562,7 @@ wxDockUIPart* wxFrameManager::HitTest(int x, int y)
continue;
// if the point is inside the rectangle, we have a hit
if (item->rect.Inside(x,y))
if (item->rect.Contains(x,y))
result = item;
}
@@ -2371,7 +2371,7 @@ bool wxFrameManager::DoDrop(wxDockInfoArray& docks,
// should float if being dragged over center pane windows
if (!part->dock->fixed || part->dock->dock_direction == wxAUI_DOCK_CENTER)
{
if (m_last_rect.IsEmpty() || m_last_rect.Inside(pt.x, pt.y ))
if (m_last_rect.IsEmpty() || m_last_rect.Contains(pt.x, pt.y ))
{
m_skipping = true;
}

View File

@@ -1825,7 +1825,7 @@ void wxComboCtrlBase::OnPopupDismiss()
// If cursor not on dropdown button, then clear its state
// (technically not required by all ports, but do it for all just in case)
if ( !m_btnArea.Inside(ScreenToClient(::wxGetMousePosition())) )
if ( !m_btnArea.Contains(ScreenToClient(::wxGetMousePosition())) )
m_btnState = 0;
// Return parent's tab traversal flag.

View File

@@ -409,7 +409,7 @@ wxGBSizerItem* wxGridBagSizer::FindItemAtPoint(const wxPoint& pt)
wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();
wxRect rect(item->GetPosition(), item->GetSize());
rect.Inflate(m_hgap, m_vgap);
if ( rect.Inside(pt) )
if ( rect.Contains(pt) )
return item;
node = node->GetNext();
}

View File

@@ -183,7 +183,7 @@ wxRect& wxRect::Inflate(wxCoord dx, wxCoord dy)
return *this;
}
bool wxRect::Inside(int cx, int cy) const
bool wxRect::Contains(int cx, int cy) const
{
return ( (cx >= x) && (cy >= y)
&& ((cy - y) < height)
@@ -191,9 +191,9 @@ bool wxRect::Inside(int cx, int cy) const
);
}
bool wxRect::Inside(const wxRect& rect) const
bool wxRect::Contains(const wxRect& rect) const
{
return Inside(rect.GetTopLeft()) && Inside(rect.GetBottomRight());
return Contains(rect.GetTopLeft()) && Contains(rect.GetBottomRight());
}
wxRect& wxRect::Intersect(const wxRect& rect)

View File

@@ -999,8 +999,8 @@ void wxImage::SetRGB( const wxRect& rect_, unsigned char r, unsigned char g, uns
}
else
{
wxCHECK_RET( imageRect.Inside(rect.GetTopLeft()) &&
imageRect.Inside(rect.GetBottomRight()),
wxCHECK_RET( imageRect.Contains(rect.GetTopLeft()) &&
imageRect.Contains(rect.GetBottomRight()),
wxT("invalid bounding rectangle") );
}

View File

@@ -373,7 +373,7 @@ void wxPopupTransientWindow::OnIdle(wxIdleEvent& event)
wxPoint pos = ScreenToClient(wxGetMousePosition());
wxRect rect(GetSize());
if ( rect.Inside(pos) )
if ( rect.Contains(pos) )
{
if ( m_child->HasCapture() )
{

View File

@@ -210,8 +210,8 @@ void wxTopLevelWindowBase::DoCentre(int dir)
// parent frame under Mac but could happen elsewhere too if the frame
// was hidden/moved away for some reason), don't use it as otherwise
// this window wouldn't be visible at all
if ( !rectDisplay.Inside(rectParent.GetTopLeft()) &&
!rectParent.Inside(rectParent.GetBottomRight()) )
if ( !rectDisplay.Contains(rectParent.GetTopLeft()) &&
!rectParent.Contains(rectParent.GetBottomRight()) )
{
// this is enough to make IsEmpty() test below pass
rectParent.width = 0;
@@ -235,9 +235,9 @@ void wxTopLevelWindowBase::DoCentre(int dir)
// we don't want to place the window off screen if Centre() is called as
// this is (almost?) never wanted and it would be very difficult to prevent
// it from happening from the user code if we didn't check for it here
if ( rectDisplay.Inside(rect.GetTopLeft()) )
if ( rectDisplay.Contains(rect.GetTopLeft()) )
{
if ( !rectDisplay.Inside(rect.GetBottomRight()) )
if ( !rectDisplay.Contains(rect.GetBottomRight()) )
{
// check if we can move the window so that the bottom right corner
// is visible without hiding the top left one

View File

@@ -1077,7 +1077,7 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt)
}
wxRect rect(pos, sz);
if (rect.Inside(pt))
if (rect.Contains(pt))
return win;
return NULL;

View File

@@ -697,7 +697,7 @@ void wxWindowDFB::PaintWindow(const wxRect& rect)
wxRect clientRect(GetClientRect());
// only send wxNcPaintEvent if drawing at least part of nonclient area:
if ( !clientRect.Inside(rect) )
if ( !clientRect.Contains(rect) )
{
wxNcPaintEvent eventNc(GetId());
eventNc.SetEventObject(this);

View File

@@ -280,7 +280,7 @@ void wxGenericComboControl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
void wxGenericComboControl::OnMouseEvent( wxMouseEvent& event )
{
bool isOnButtonArea = m_btnArea.Inside(event.m_x,event.m_y);
bool isOnButtonArea = m_btnArea.Contains(event.m_x,event.m_y);
int handlerFlags = isOnButtonArea ? wxCC_MF_ON_BUTTON : 0;
// Preprocessing fabricates double-clicks and prevents

View File

@@ -202,13 +202,13 @@ void wxHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
void wxHyperlinkCtrl::OnLeftDown(wxMouseEvent& event)
{
// the left click must start from the hyperlink rect
m_clicking = GetLabelRect().Inside(event.GetPosition());
m_clicking = GetLabelRect().Contains(event.GetPosition());
}
void wxHyperlinkCtrl::OnLeftUp(wxMouseEvent& event)
{
// the click must be started and ended in the hyperlink rect
if (!m_clicking || !GetLabelRect().Inside(event.GetPosition()))
if (!m_clicking || !GetLabelRect().Contains(event.GetPosition()))
return;
SetForegroundColour(m_visitedColour);
@@ -225,7 +225,7 @@ void wxHyperlinkCtrl::OnLeftUp(wxMouseEvent& event)
void wxHyperlinkCtrl::OnRightUp(wxMouseEvent& event)
{
if( GetWindowStyle() & wxHL_CONTEXTMENU )
if ( GetLabelRect().Inside(event.GetPosition()) )
if ( GetLabelRect().Contains(event.GetPosition()) )
DoContextMenu(wxPoint(event.m_x, event.m_y));
}
@@ -233,7 +233,7 @@ void wxHyperlinkCtrl::OnMotion(wxMouseEvent& event)
{
wxRect textrc = GetLabelRect();
if (textrc.Inside(event.GetPosition()))
if (textrc.Contains(event.GetPosition()))
{
SetCursor(wxCursor(wxCURSOR_HAND));
SetForegroundColour(m_hoverColour);

View File

@@ -173,7 +173,7 @@ int wxListbook::HitTest(const wxPoint& pt, long *flags) const
const wxPoint listPt = list->ScreenToClient(ClientToScreen(pt));
// is the point inside list control?
if ( wxRect(list->GetSize()).Inside(listPt) )
if ( wxRect(list->GetSize()).Contains(listPt) )
{
int flagsList;
pagePos = list->HitTest(listPt, flagsList);
@@ -193,7 +193,7 @@ int wxListbook::HitTest(const wxPoint& pt, long *flags) const
}
else // not over list control at all
{
if ( flags && GetPageRect().Inside(pt) )
if ( flags && GetPageRect().Contains(pt) )
*flags |= wxBK_HITTEST_ONPAGE;
}

View File

@@ -961,7 +961,7 @@ bool wxListItemData::IsHit( int x, int y ) const
{
wxCHECK_MSG( m_rect, false, _T("can't be called in this mode") );
return wxRect(GetX(), GetY(), GetWidth(), GetHeight()).Inside(x, y);
return wxRect(GetX(), GetY(), GetWidth(), GetHeight()).Contains(x, y);
}
int wxListItemData::GetX() const
@@ -2381,7 +2381,7 @@ long wxListMainWindow::HitTestLine(size_t line, int x, int y) const
wxListLineData *ld = GetLine(line);
if ( ld->HasImage() && GetLineIconRect(line).Inside(x, y) )
if ( ld->HasImage() && GetLineIconRect(line).Contains(x, y) )
return wxLIST_HITTEST_ONITEMICON;
// VS: Testing for "ld->HasText() || InReportView()" instead of
@@ -2392,7 +2392,7 @@ long wxListMainWindow::HitTestLine(size_t line, int x, int y) const
wxRect rect = InReportView() ? GetLineRect(line)
: GetLineLabelRect(line);
if ( rect.Inside(x, y) )
if ( rect.Contains(x, y) )
return wxLIST_HITTEST_ONITEMLABEL;
}

View File

@@ -362,7 +362,7 @@ void wxTipWindowView::OnMouseMove(wxMouseEvent& event)
const wxRect& rectBound = m_parent->m_rectBound;
if ( rectBound.width &&
!rectBound.Inside(ClientToScreen(event.GetPosition())) )
!rectBound.Contains(ClientToScreen(event.GetPosition())) )
{
// mouse left the bounding rect, disappear
m_parent->Close();

View File

@@ -321,7 +321,7 @@ int wxToolbook::HitTest(const wxPoint& pt, long *flags) const
const wxPoint tbarPt = tbar->ScreenToClient(ClientToScreen(pt));
// is the point over the toolbar?
if ( wxRect(tbar->GetSize()).Inside(tbarPt) )
if ( wxRect(tbar->GetSize()).Contains(tbarPt) )
{
const wxToolBarToolBase * const
tool = tbar->FindToolForPosition(tbarPt.x, tbarPt.y);
@@ -335,7 +335,7 @@ int wxToolbook::HitTest(const wxPoint& pt, long *flags) const
}
else // not over the toolbar
{
if ( flags && GetPageRect().Inside(pt) )
if ( flags && GetPageRect().Contains(pt) )
*flags |= wxBK_HITTEST_ONPAGE;
}

View File

@@ -743,7 +743,7 @@ int wxTreebook::HitTest(wxPoint const & pt, long * flags) const
const wxPoint treePt = tree->ScreenToClient(ClientToScreen(pt));
// is it over the tree?
if ( wxRect(tree->GetSize()).Inside(treePt) )
if ( wxRect(tree->GetSize()).Contains(treePt) )
{
int flagsTree;
wxTreeItemId id = tree->HitTest(treePt, flagsTree);
@@ -769,7 +769,7 @@ int wxTreebook::HitTest(wxPoint const & pt, long * flags) const
}
else // not over the tree
{
if ( flags && GetPageRect().Inside( pt ) )
if ( flags && GetPageRect().Contains( pt ) )
*flags |= wxBK_HITTEST_ONPAGE;
}

View File

@@ -1022,7 +1022,7 @@ int wxListBox::DoListHitTest(const wxPoint& point) const
{
// gtk_tree_view_get_path_at_pos() also gets items that are not visible and
// we only want visible items we need to check for it manually here
if ( !GetClientRect().Inside(point) )
if ( !GetClientRect().Contains(point) )
return wxNOT_FOUND;
// need to translate from master window since it is in client coords

View File

@@ -804,7 +804,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
wxPoint pos = GetPosition();
rect.x -= pos.x;
rect.y -= pos.y;
if ( rect.Inside( pt ) )
if ( rect.Contains( pt ) )
*flags |= wxBK_HITTEST_ONPAGE;
}
}

View File

@@ -688,7 +688,7 @@ int wxRadioBox::GetItemFromPoint(const wxPoint& point) const
for ( wxRadioBoxButtonsInfoList::compatibility_iterator
node = m_buttonsInfo.GetFirst(); node; node = node->GetNext(), n++ )
{
if ( m_buttonsInfo[n]->rect.Inside(pt) )
if ( m_buttonsInfo[n]->rect.Contains(pt) )
return n;
}

View File

@@ -489,7 +489,7 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
void wxComboCtrl::OnMouseEvent( wxMouseEvent& event )
{
bool isOnButtonArea = m_btnArea.Inside(event.m_x,event.m_y);
bool isOnButtonArea = m_btnArea.Contains(event.m_x,event.m_y);
int handlerFlags = isOnButtonArea ? wxCC_MF_ON_BUTTON : 0;
// Preprocessing fabricates double-clicks and prevents

View File

@@ -819,7 +819,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
*flags |= wxBK_HITTEST_ONICON;
if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
*flags |= wxBK_HITTEST_ONLABEL;
if ( item == wxNOT_FOUND && GetPageSize().Inside(pt) )
if ( item == wxNOT_FOUND && GetPageSize().Contains(pt) )
*flags |= wxBK_HITTEST_ONPAGE;
}

View File

@@ -2056,7 +2056,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
GetBoundingRect(event.m_item, ItemRect, false);
// If the point is inside the bounding rectangle, use it as the click position.
// This should be the case for WM_CONTEXTMENU as the result of a right-click
if (ItemRect.Inside(MenuPoint))
if (ItemRect.Contains(MenuPoint))
{
event.m_pointDrag = MenuPoint;
}

View File

@@ -2168,7 +2168,7 @@ long wxListCtrl::FindItem (
vLibRect.SetTop(vRect.yTop);
vLibRect.SetRight(vRect.xRight);
vLibRect.SetBottom(vRect.yBottom);
if (vLibRect.Inside(rPoint))
if (vLibRect.Contains(rPoint))
return pRecord->m_ulItemId;
for (i = lStart + 1; i < vCnrInfo.cRecords; i++)
@@ -2188,7 +2188,7 @@ long wxListCtrl::FindItem (
vLibRect.SetTop(vRect.yTop);
vLibRect.SetRight(vRect.xRight);
vLibRect.SetBottom(vRect.yBottom);
if (vLibRect.Inside(rPoint))
if (vLibRect.Contains(rPoint))
return pRecord->m_ulItemId;
}
return -1L;

View File

@@ -1093,7 +1093,7 @@ bool wxTreeCtrl::IsVisible (
vWxRectContainer.SetTop(vRectContainer.yTop);
vWxRectContainer.SetRight(vRectContainer.xRight);
vWxRectContainer.SetBottom(vRectContainer.yBottom);
return (vWxRectContainer.Inside(wxPoint(vWxRectRecord.x, vWxRectRecord.y)));
return (vWxRectContainer.Contains(wxPoint(vWxRectRecord.x, vWxRectRecord.y)));
} // end of wxTreeCtrl::IsVisible
bool wxTreeCtrl::ItemHasChildren (

View File

@@ -588,7 +588,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
*flags = wxBK_HITTEST_NOWHERE;
// first check that it is in this window at all
if ( !GetClientRect().Inside(pt) )
if ( !GetClientRect().Contains(pt) )
{
return -1;
}
@@ -626,7 +626,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
GetTabSize(n, &rectTabs.width, &rectTabs.height);
if ( rectTabs.Inside(pt) )
if ( rectTabs.Contains(pt) )
{
if ( flags )
{

View File

@@ -832,7 +832,7 @@ wxScrollThumb::Shaft wxSlider::HitTest(const wxPoint& pt) const
CalcThumbRect(&rectShaft, &rectThumb, NULL);
// check for possible shaft or thumb hit
if (!rectShaft.Inside(pt) && !rectThumb.Inside(pt))
if (!rectShaft.Contains(pt) && !rectThumb.Contains(pt))
{
return wxScrollThumb::Shaft_None;
}

View File

@@ -329,9 +329,9 @@ wxScrollArrows::Arrow wxSpinButton::HitTest(const wxPoint& pt) const
wxRect rectArrow1, rectArrow2;
CalcArrowRects(&rectArrow1, &rectArrow2);
if ( rectArrow1.Inside(pt) )
if ( rectArrow1.Contains(pt) )
return wxScrollArrows::Arrow_First;
else if ( rectArrow2.Inside(pt) )
else if ( rectArrow2.Contains(pt) )
return wxScrollArrows::Arrow_Second;
else
return wxScrollArrows::Arrow_None;

View File

@@ -3707,7 +3707,7 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
{
wxRect client = GetFrameClientArea(rect, flags);
if ( client.Inside(pt) )
if ( client.Contains(pt) )
return wxHT_TOPLEVEL_CLIENT_AREA;
if ( flags & wxTOPLEVEL_TITLEBAR )
@@ -3716,7 +3716,7 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
if ( flags & wxTOPLEVEL_ICON )
{
if ( wxRect(client.GetPosition(), GetFrameIconSize()).Inside(pt) )
if ( wxRect(client.GetPosition(), GetFrameIconSize()).Contains(pt) )
return wxHT_TOPLEVEL_ICON;
}
@@ -3726,31 +3726,31 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
if ( flags & wxTOPLEVEL_BUTTON_CLOSE )
{
if ( btnRect.Inside(pt) )
if ( btnRect.Contains(pt) )
return wxHT_TOPLEVEL_BUTTON_CLOSE;
btnRect.x -= FRAME_BUTTON_WIDTH + 2;
}
if ( flags & wxTOPLEVEL_BUTTON_MAXIMIZE )
{
if ( btnRect.Inside(pt) )
if ( btnRect.Contains(pt) )
return wxHT_TOPLEVEL_BUTTON_MAXIMIZE;
btnRect.x -= FRAME_BUTTON_WIDTH;
}
if ( flags & wxTOPLEVEL_BUTTON_RESTORE )
{
if ( btnRect.Inside(pt) )
if ( btnRect.Contains(pt) )
return wxHT_TOPLEVEL_BUTTON_RESTORE;
btnRect.x -= FRAME_BUTTON_WIDTH;
}
if ( flags & wxTOPLEVEL_BUTTON_ICONIZE )
{
if ( btnRect.Inside(pt) )
if ( btnRect.Contains(pt) )
return wxHT_TOPLEVEL_BUTTON_ICONIZE;
btnRect.x -= FRAME_BUTTON_WIDTH;
}
if ( flags & wxTOPLEVEL_BUTTON_HELP )
{
if ( btnRect.Inside(pt) )
if ( btnRect.Contains(pt) )
return wxHT_TOPLEVEL_BUTTON_HELP;
btnRect.x -= FRAME_BUTTON_WIDTH;
}