void wxSFLayoutMesh::DoLayout(ShapeList& shapes) { int i = 0, cols = floor( sqrt( (float)shapes.GetCount() ) ); double roffset, coffset, maxh = -m_HSpace; roffset = coffset = 0; wxRealPoint nStart = GetTopLeft( shapes ); for( ShapeList::iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxSFShapeBase *pShape = *it; if( i++ % cols == 0 ) { coffset = 0; roffset += maxh + m_HSpace; maxh = 0; } pShape->MoveTo( nStart.x + coffset, nStart.y + roffset ); wxRect rctBB = pShape->GetBoundingBox(); coffset += rctBB.GetWidth() + m_VSpace; if( rctBB.GetHeight() > maxh ) maxh = rctBB.GetHeight(); } }
void CRealMediaWindowlessSite::SubtractSite(REGION* pRegion) { PNxPoint topLeft; memset(&topLeft, 0, sizeof(PNxPoint)); GetTopLeft(&topLeft); REGION* pTempRegion = RMACreateRectRegion(topLeft.x, topLeft.y, topLeft.x + m_size.cx, topLeft.y + m_size.cy); RMASubtractRegion(pRegion, pTempRegion, pRegion); RMADestroyRegion(pTempRegion); }
// ----------------------------------------------------------------------------- // Draws function text (spec+args) for [context] at [left,top]. // Returns a rect of the bounds of the drawn text // ----------------------------------------------------------------------------- wxRect SCallTip::drawFunctionContext( wxDC& dc, const TLFunction::Context& context, int left, int top, wxColour& col_faded, wxFont& bold) const { auto rect_func = drawFunctionSpec(dc, context, left, top); auto rect_args = drawArgs(dc, context, rect_func.GetRight() + 1, rect_func.GetTop(), col_faded, bold); return wxRect{ rect_func.GetTopLeft(), wxPoint{ std::max(rect_func.GetRight(), rect_args.GetRight()), std::max(rect_func.GetBottom(), rect_args.GetBottom()) } }; }
Group::Group(List<Shape *> *nodes) : Node() { for (List<Shape *>::Iterator i = nodes->Iterate(); !i; i++) { if (dynamic_cast<Node *>(*i) != NULL) { m_children.Add(*i); } } AddPorts(); Member *name = FindMember(wxT("Name")); DeleteMember(name); DESTROY(name); AddProperty(NEW(TextProperty, (this, wxT("Name")))); SetPosition(GetTopLeft(nodes)); EvalSize(); }
void wxSFLayoutHorizontalTree::DoLayout(ShapeList& shapes) { ShapeList lstConnections; ShapeList lstRoots; wxRealPoint nStart = GetTopLeft( shapes ); m_nMinY = nStart.y; // find root items for( ShapeList::iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxSFShapeBase *pShape = *it; lstConnections.Clear(); pShape->GetAssignedConnections( CLASSINFO(wxSFLineShape), wxSFShapeBase::lineENDING, lstConnections ); if( lstConnections.IsEmpty() ) { m_nCurrMaxHeight = 0; ProcessNode( pShape, nStart.x ); } } }
void CRealMediaWindowlessSite::ComputeRegion() { REGION* pTempRegion = NULL; if(m_pRegion) { pTempRegion = RMACreateRegion(); RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion); RMADestroyRegion(m_pRegion); } if(m_pRegionWithoutChildren) { RMADestroyRegion(m_pRegionWithoutChildren); } PNxPoint topleft = {0,0}; GetTopLeft(&topleft); if(IsSiteVisible()) { m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy); if(m_pParentSite) { RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren); POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition(); while(pos) { CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos); if(pSiblingSite != this) { INT32 zOrder; pSiblingSite->GetZOrder(zOrder); if(zOrder > m_lZOrder && pSiblingSite->IsSiteVisible()) { pSiblingSite->SubtractSite(m_pRegionWithoutChildren); } } } } m_pRegion = RMACreateRegion(); RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion); POSITION pos = m_pChildren.GetHeadPosition(); while(pos) { CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos); if(pChildSite->IsSiteVisible()) pChildSite->SubtractSite(m_pRegion); } } else { m_pRegionWithoutChildren = RMACreateRectRegion(0,0,0,0); m_pRegion = RMACreateRectRegion(0,0,0,0); } if(pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion)) { ForceRedraw(); } RMADestroyRegion(pTempRegion); }
void menu(void) { struct Solid cursor; char selection = 0; displayMenu(&cursor); StartTimer(0, 200); StartTimer(1, 200); for (;;) { if (CheckTimer(0)) { if (GetUp()) { if (selection > 0) { solid_moveLocation(&cursor, cursor.x - 22, cursor.y); selection--; StartTimer(0, 200); } } else if (GetDown()) { if (selection < 7) { solid_moveLocation(&cursor, cursor.x + 22, cursor.y); selection++; StartTimer(0, 200); } } } if (CheckTimer(1)) { if (GetTopLeft()) { if (selection == 0) { StarBattle(); displayMenu(&cursor); selection = 0; } else if (selection == 1) { BrickBreaker(); displayMenu(&cursor); selection = 0; } else if (selection == 2) { Debris(); displayMenu(&cursor); selection = 0; } else if (selection == 3) { Pong(); displayMenu(&cursor); selection = 0; } else if (selection == 4) { Draw(); displayMenu(&cursor); selection = 0; } StartTimer(1, 200); } } } }
void OnPaint() { wxPaintDC dc(this); auto rect = GetClientRect(); dc.SetPen(wxPen(wxColor(0x26, 0x1E, 0x00))); dc.SetBrush(wxBrush(wxColor(0x26, 0x1E, 0x00))); dc.DrawRectangle(rect); int const disp_half = rect.GetWidth() / 2; int const disp_shift = kFullKeysWidth / 2 - disp_half; auto draw_key = [&](auto note_num, auto const &prop, auto const &img) { int const octave = note_num / 12; auto key_rect = prop.rect_; key_rect.Offset(octave * kKeyWidth * 7 - disp_shift, 0); if(key_rect.GetLeft() >= rect.GetWidth()) { return; } if(key_rect.GetRight() < 0) { return; } dc.DrawBitmap(wxBitmap(img), key_rect.GetTopLeft()); // if(is_playing) { // col_pen = kKeyBorderColorPlaying; // col_brush = kPlayingNoteColor; // dc.SetPen(wxPen(col_pen)); // dc.SetBrush(wxBrush(col_brush)); // } // dc.DrawRoundedRectangle(key_rect, 2); }; for(int i = 0; i < kNumKeys; ++i) { if(IsWhiteKey(i) == false) { continue; } bool const is_playing = playing_notes_[i]; bool next_pushed = false; if(i < kNumKeys - 2) { if(IsWhiteKey(i+1) && playing_notes_[i+1]) { next_pushed = true; } else if(IsWhiteKey(i+2) && playing_notes_[i+2]) { next_pushed = true; } } auto const &img = (is_playing && next_pushed) ? img_white_pushed_contiguous_ : (is_playing ? img_white_pushed_ : img_white_); draw_key(i, kKeyPropertyList[i % 12], img); } for(int i = 0; i < kNumKeys; ++i) { if(IsBlackKey(i) == false) { continue; } bool const is_playing = playing_notes_[i]; auto const &img = (is_playing ? img_black_pushed_ : img_black_); draw_key(i, kKeyPropertyList[i % 12], img); } auto font = wxFont(wxFontInfo(wxSize(8, 10)).Family(wxFONTFAMILY_DEFAULT)); dc.SetFont(font); for(int i = 0; i < kNumKeys; i += 12) { int const octave = i / 12; dc.DrawLabel(wxString::Format("C%d", i / 12 - 2), wxBitmap(), wxRect(wxPoint(octave * kKeyWidth * 7 - disp_shift, rect.GetHeight() * 0.8), wxSize(kKeyWidth, 10)), wxALIGN_CENTER ); } }