本文整理汇总了C++中wxRect::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ wxRect::Intersects方法的具体用法?C++ wxRect::Intersects怎么用?C++ wxRect::Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxRect
的用法示例。
在下文中一共展示了wxRect::Intersects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void GroupVisual::Draw ( wxDC& dc, InstanceCtrl* parent, wxRect limitingRect, bool hasSelection, int selectionIndex, bool hasFocus, int focusIndex, bool highlight )
{
int i;
int count = items.size();
int style = 0;
wxRect rect;
// Draw the header
if(!no_header)
{
wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
if (highlight)
{
textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
}
wxBrush brush(textColor);
wxPen pen(textColor);
dc.SetBrush(brush);
dc.SetPen(pen);
wxSize sz = dc.GetTextExtent(GetName());
dc.SetTextForeground(textColor);
dc.DrawText( GetName() , 20, y_position + 5 );
int atheight = y_position + header_height / 2;
if(sz.x + 30 < limitingRect.width - 10)
dc.DrawLine(sz.x + 30,atheight, limitingRect.width - 10, atheight);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(textColor);
// Ungrouped can't be hidden, so don't draw the box.
if (m_group)
{
dc.DrawRectangle(5,atheight -5, 10,10);
dc.DrawRectangle(7,atheight -1, 6,2);
if(!IsExpanded())
{
dc.DrawRectangle(9,atheight -3, 2,6);
}
}
}
if(IsExpanded()) for (i = 0; i < count; i++)
{
parent->GetItemRect(VisualCoord(index,i), rect, false);
if (!limitingRect.Intersects(rect))
continue;
style = 0;
if (hasSelection && selectionIndex == i)
style |= wxINST_SELECTED;
if (hasFocus && i == focusIndex)
style |= wxINST_IS_FOCUS;
InstanceVisual& item = items[i];
item.Draw(dc, parent, rect, style);
}
}
示例2: SelectLast
/***
* Find the last cell in rectangle rect in this line.
*/
void MathCell::SelectLast(wxRect& rect, MathCell** last)
{
if (rect.Intersects(GetRect(false)))
*last = this;
if (m_nextToDraw != NULL)
m_nextToDraw->SelectLast(rect, last);
}
示例3: SelectFirst
/***
* Find the first cell in rectangle rect in this line.
*/
void MathCell::SelectFirst(wxRect& rect, MathCell** first)
{
if (rect.Intersects(GetRect(false)))
*first = this;
else if (m_nextToDraw != NULL)
m_nextToDraw->SelectFirst(rect, first);
else
*first = NULL;
}
示例4: DrawToDCClipped
// ----------------------------------------------------------------------------
// DrawToDCClipped - play back the op list to the DC but clip any objects
// known to be not in rect. This is a coarse level of
// clipping to speed things up when lots of objects are off
// screen and doesn't affect the dc level clipping
// ----------------------------------------------------------------------------
void wxPseudoDC::DrawToDCClipped(wxDC *dc, const wxRect& rect)
{
pdcObjectList::Node *pt = m_objectlist.GetFirst();
pdcObject *obj;
while (pt)
{
obj = pt->GetData();
if (!obj->IsBounded() || rect.Intersects(obj->GetBounds()))
obj->DrawToDC(dc);
pt = pt->GetNext();
}
}
示例5: IsSelectStateChanged
bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
EDA_RECT boundingBox = GetBoundingBox();
if( aRect.Intersects( boundingBox ) )
SetFlags( SELECTED );
else
ClearFlags( SELECTED );
return previousState != IsSelected();
}
示例6: TracePixel
bool MapTerrainT::TracePixel(const wxPoint& Pixel, int Radius, const ViewWindow2DT& ViewWin) const
{
const BoundingBox3fT BB =GetBB();
const wxRect Disc=wxRect(Pixel, Pixel).Inflate(Radius, Radius);
const wxRect Rect=wxRect(ViewWin.WorldToWindow(BB.Min), ViewWin.WorldToWindow(BB.Max));
// Note that the check against the Rect frame (that has a width of 2*Radius) is done in two steps:
// First by checking if Disc is entirely outside of Rect, then below by checking if Disc is entirely inside Rect.
if (!Rect.Intersects(Disc)) return false;
if (Disc.Contains(ViewWin.WorldToWindow(BB.GetCenter()))) return true;
if (Options.view2d.SelectByHandles) return false;
return !Rect.Contains(Disc);
}
示例7: PaintWindow
void wxWindowDFB::PaintWindow(const wxRect& rect)
{
wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" );
wxLogTrace(TRACE_PAINT,
"%p ('%s'): painting region [%i,%i,%i,%i]",
this, GetName().c_str(),
rect.x, rect.y, rect.GetRight(), rect.GetBottom());
m_updateRegion = rect;
// FIXME_DFB: don't waste time rendering the area if it's fully covered
// by some children, go directly to rendering the children
// (unless some child has HasTransparentBackground()=true!)
// NB: unconditionally send wxEraseEvent, because our implementation of
// wxWindow::Refresh() ignores the eraseBack argument
wxWindowDC dc((wxWindow*)this);
wxEraseEvent eventEr(m_windowId, &dc);
eventEr.SetEventObject(this);
HandleWindowEvent(eventEr);
wxRect clientRect(GetClientRect());
// only send wxNcPaintEvent if drawing at least part of nonclient area:
if ( !clientRect.Contains(rect) )
{
wxNcPaintEvent eventNc(GetId());
eventNc.SetEventObject(this);
HandleWindowEvent(eventNc);
}
else
{
wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxNcPaintEvent",
this, GetName().c_str());
}
// only send wxPaintEvent if drawing at least part of client area:
if ( rect.Intersects(clientRect) )
{
wxPaintEvent eventPt(GetId());
eventPt.SetEventObject(this);
HandleWindowEvent(eventPt);
}
else
{
wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxPaintEvent",
this, GetName().c_str());
}
// draw window's overlays on top of the painted window, if we have any:
PaintOverlays(rect);
m_updateRegion.Clear();
// client area portion of 'rect':
wxRect rectClientOnly(rect);
rectClientOnly.Intersect(clientRect);
// paint the children:
wxPoint origin = GetClientAreaOrigin();
wxWindowList& children = GetChildren();
for ( wxWindowList::iterator i = children.begin();
i != children.end(); ++i )
{
wxWindow *child = *i;
if ( child->IsFrozen() || !child->IsShown() )
continue; // don't paint anything if the window is frozen or hidden
// compute child's area to repaint
wxRect childrect(child->GetRect());
childrect.Offset(origin);
if ( child->CanBeOutsideClientArea() )
childrect.Intersect(rect);
else
childrect.Intersect(rectClientOnly);
if ( childrect.IsEmpty() )
continue;
// and repaint it:
childrect.Offset(-child->GetPosition());
childrect.Offset(-origin);
child->PaintWindow(childrect);
}
}
示例8: IsObjectInRect
Bool CFx::IsObjectInRect(wxRect& Rect)
{
return (Rect.Intersects(*_pFxRect) || Rect.Intersects(*_pFxStateRect));
}
示例9: ScaleImage
wxImage ScaleImage(wxImage image, double source_scale_factor, double content_scale_factor,
wxSize output_size, wxRect usable_rect, LSIFlags flags,
const wxColour& fill_color)
{
if (!image.IsOk())
{
wxFAIL_MSG("WxUtils::ScaleImage expects a valid image.");
return image;
}
if (content_scale_factor != 1.0)
{
output_size *= content_scale_factor;
usable_rect.SetPosition(usable_rect.GetPosition() * content_scale_factor);
usable_rect.SetSize(usable_rect.GetSize() * content_scale_factor);
}
// Fix the output size if it's unset.
wxSize img_size = image.GetSize();
if (output_size.GetWidth() < 1)
output_size.SetWidth(
static_cast<int>(img_size.GetWidth() * (content_scale_factor / source_scale_factor)));
if (output_size.GetHeight() < 1)
output_size.SetHeight(
static_cast<int>(img_size.GetHeight() * (content_scale_factor / source_scale_factor)));
// Fix the usable rect. If it's empty then the whole canvas is usable.
if (usable_rect.IsEmpty())
{
// Constructs a temp wxRect 0,0->output_size then move assigns it.
usable_rect = output_size;
}
else if (!usable_rect.Intersects(output_size))
{
wxFAIL_MSG("Usable Zone Rectangle is not inside the canvas. Check the output size is correct.");
image.Create(1, 1, false);
image.SetRGB(0, 0, fill_color.Red(), fill_color.Green(), fill_color.Blue());
if (fill_color.Alpha() == wxALPHA_TRANSPARENT)
image.SetMaskColour(fill_color.Red(), fill_color.Green(), fill_color.Blue());
usable_rect = output_size;
}
// Step 1: Scale the image
if ((flags & LSI_SCALE) != LSI_SCALE_NONE)
{
if (flags & LSI_SCALE_NO_ASPECT)
{
// Stretch scale without preserving the aspect ratio.
bool scale_width = (img_size.GetWidth() > usable_rect.GetWidth() && flags & LSI_SCALE_DOWN) ||
(img_size.GetWidth() < usable_rect.GetWidth() && flags & LSI_SCALE_UP);
bool scale_height =
(img_size.GetHeight() > usable_rect.GetHeight() && flags & LSI_SCALE_DOWN) ||
(img_size.GetHeight() < usable_rect.GetHeight() && flags & LSI_SCALE_UP);
if (scale_width || scale_height)
{
// NOTE: Using BICUBIC instead of HIGH because it's the same internally
// except that downscaling uses a box filter with awful obvious aliasing
// for non-integral scale factors.
image.Rescale(scale_width ? usable_rect.GetWidth() : img_size.GetWidth(),
scale_height ? usable_rect.GetHeight() : img_size.GetHeight(),
wxIMAGE_QUALITY_BICUBIC);
}
}
else
{
// Scale while preserving the aspect ratio.
double scale = std::min(static_cast<double>(usable_rect.GetWidth()) / img_size.GetWidth(),
static_cast<double>(usable_rect.GetHeight()) / img_size.GetHeight());
int target_width = static_cast<int>(img_size.GetWidth() * scale);
int target_height = static_cast<int>(img_size.GetHeight() * scale);
// Bilinear produces sharper images when upscaling, bicubic tends to smear/blur sharp edges.
if (scale > 1.0 && flags & LSI_SCALE_UP)
image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BILINEAR);
else if (scale < 1.0 && flags & LSI_SCALE_DOWN)
image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BICUBIC);
}
img_size = image.GetSize();
}
// Step 2: Resize the canvas to match the output size.
// NOTE: If NOT using LSI_SCALE_DOWN then this will implicitly crop the image
if (img_size != output_size || usable_rect.GetPosition() != wxPoint())
{
wxPoint base = usable_rect.GetPosition();
if (flags & LSI_ALIGN_HCENTER)
base.x += (usable_rect.GetWidth() - img_size.GetWidth()) / 2;
else if (flags & LSI_ALIGN_RIGHT)
base.x += usable_rect.GetWidth() - img_size.GetWidth();
if (flags & LSI_ALIGN_VCENTER)
base.y += (usable_rect.GetHeight() - img_size.GetHeight()) / 2;
else if (flags & LSI_ALIGN_BOTTOM)
base.y += usable_rect.GetHeight() - img_size.GetHeight();
int r = -1, g = -1, b = -1;
if (fill_color.Alpha() != wxALPHA_TRANSPARENT)
{
r = fill_color.Red();
g = fill_color.Green();
b = fill_color.Blue();
}
//.........这里部分代码省略.........
示例10: Intersects
bool wxSFShapeBase::Intersects(const wxRect& rct)
{
// HINT: overload it for custom actions...
return rct.Intersects(this->GetBoundingBox());
}
示例11: SelectRectInOutput
void GroupCell::SelectRectInOutput(wxRect& rect, wxPoint& one, wxPoint& two,
MathCell **first, MathCell **last)
{
if (m_hide)
return;
MathCell* tmp;
wxPoint start, end;
if (one.y < two.y || (one.y == two.y && one.x < two.x)) {
start = one;
end = two;
} else {
start = two;
end = one;
}
// Lets select a rectangle
tmp = m_output;
*first = *last = NULL;
while (tmp != NULL && !rect.Intersects(tmp->GetRect()))
tmp = tmp->m_nextToDraw;
*first = tmp;
*last = tmp;
while (tmp != NULL) {
if (rect.Intersects(tmp->GetRect()))
*last = tmp;
tmp = tmp->m_nextToDraw;
}
if (*first != NULL && *last != NULL) {
// If selection is on multiple lines, we need to correct it
if ((*first)->GetCurrentY() != (*last)->GetCurrentY()) {
tmp = *last;
MathCell *curr;
// Find the first cell in selection
while (*first != tmp &&
((*first)->GetCurrentX() + (*first)->GetWidth() < start.x
|| (*first)->GetCurrentY() + (*first)->GetDrop() < start.y))
*first = (*first)->m_nextToDraw;
// Find the last cell in selection
curr = *last = *first;
while (1) {
curr = curr->m_nextToDraw;
if (curr == NULL)
break;
if (curr->GetCurrentX() <= end.x &&
curr->GetCurrentY() - curr->GetMaxCenter() <= end.y)
*last = curr;
if (curr == tmp)
break;
}
}
if (*first == *last)
(*first)->SelectInner(rect, first, last);
}
}