void StatusButtonDown(HDC hDC, PSTATEL ip) { RECT rc; HPEN hpenOld; TEXTMETRIC tm; rc = ip->rc; TopLeft(hDC, &rc, hpenBlack, TRUE); BottomRight(hDC, &rc, hpenBlack, FALSE); rc.top++; rc.bottom--; rc.left++; rc.right--; TopLeft(hDC, &rc, hpenLowlight, TRUE); rc.top++; rc.left++; TopLeft(hDC, &rc, hpenNeutral, TRUE); rc.top++; rc.left++; TopLeft(hDC, &rc, hpenNeutral, TRUE); rc.top++; rc.left++; hpenOld = (HPEN)SelectObject(hDC, hpenNeutral); Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); SelectObject(hDC, hpenOld); GetTextMetrics(hDC, &tm); rc.top += tm.tmExternalLeading; DrawText(hDC, ip->text, lstrlen(ip->text), &rc, DT_CENTER | DT_VCENTER); }
void range::GetFormulaName(char *outString, cell inLocation) const { TopLeft().GetFormulaName(outString, inLocation); if (!(TopLeft() == BotRight())) { char t[12]; BotRight().GetFormulaName(t, inLocation); strcat(outString, ".."); strcat(outString, t); } } /* GetFormulaName */
void range::GetName(char *outString) const { TopLeft().GetName(outString); if (!(TopLeft() == BotRight())) { char t[12]; BotRight().GetName(t); strcat(outString, ".."); strcat(outString, t); } } /* range::GetName */
void range::GetRCName(char *name) const { TopLeft().GetRCName(name); if (!(TopLeft() == BotRight())) { char t[12]; BotRight().GetRCName(t); strcat(name, ":"); strcat(name, t); } } // range::GetRCName
range range::GetRefRange(cell loc) const { range result; result.TopLeft() = TopLeft().GetRefCell(loc); result.BotRight() = BotRight().GetRefCell(loc); return result; } /* range::GetRefRange */
SoccerPitch::SoccerPitch(int cx, int cy): m_cxClient(cx), m_cyClient(cy), m_bPaused(false) { //GoalWidth指的是得分區厚度 int GoalWidth = 200; m_pPlayingArea = new Region(20, 20, cx-20, cy-20); // m_pRedGoal = new Goal(V2D(m_pPlayingArea->Left(), (cy-GoalWidth)/2), V2D(m_pPlayingArea->Left(), cy - (cy-GoalWidth)/2), V2D(1,0)); m_pBlueGoal = new Goal(V2D( m_pPlayingArea->Right(), (cy-GoalWidth)/2), V2D(m_pPlayingArea->Right(), cy - (cy-GoalWidth)/2), V2D(-1,0)); //建立外牆 V2D TopLeft(m_pPlayingArea->Left(), m_pPlayingArea->Top()); V2D TopRight(m_pPlayingArea->Right(), m_pPlayingArea->Top()); V2D BottomRight(m_pPlayingArea->Right(), m_pPlayingArea->Bottom()); V2D BottomLeft(m_pPlayingArea->Left(), m_pPlayingArea->Bottom()); m_vecWalls.push_back(Wall(BottomLeft, m_pRedGoal->RightPost())); m_vecWalls.push_back(Wall(m_pRedGoal->LeftPost(), TopLeft)); m_vecWalls.push_back(Wall(TopLeft, TopRight)); m_vecWalls.push_back(Wall(TopRight, m_pBlueGoal->LeftPost())); m_vecWalls.push_back(Wall(m_pBlueGoal->RightPost(), BottomRight)); m_vecWalls.push_back(Wall(BottomRight, BottomLeft)); }
//------------------------------- ctor ----------------------------------- //------------------------------------------------------------------------ SoccerPitch::SoccerPitch(int cx, int cy):m_cxClient(cx), m_cyClient(cy), m_bPaused(false), m_bGoalKeeperHasBall(false), m_Regions(NumRegionsHorizontal*NumRegionsVertical), m_bGameOn(true) { //define the playing area m_pPlayingArea = new Region(20, 20, cx-20, cy-20); //create the regions CreateRegions(PlayingArea()->Width() / (double)NumRegionsHorizontal, PlayingArea()->Height() / (double)NumRegionsVertical); //create the goals m_pRedGoal = new Goal(Vector2D( m_pPlayingArea->Left(), (cy-Prm.GoalWidth)/2), Vector2D(m_pPlayingArea->Left(), cy - (cy-Prm.GoalWidth)/2), Vector2D(1,0)); m_pBlueGoal = new Goal( Vector2D( m_pPlayingArea->Right(), (cy-Prm.GoalWidth)/2), Vector2D(m_pPlayingArea->Right(), cy - (cy-Prm.GoalWidth)/2), Vector2D(-1,0)); //create the soccer ball m_pBall = new SoccerBall(Vector2D((double)m_cxClient/2.0, (double)m_cyClient/2.0), Prm.BallSize, Prm.BallMass, m_vecWalls); //create the teams m_pRedTeam = new SoccerTeam(m_pRedGoal, m_pBlueGoal, this, SoccerTeam::red); m_pBlueTeam = new SoccerTeam(m_pBlueGoal, m_pRedGoal, this, SoccerTeam::blue); //make sure each team knows who their opponents are m_pRedTeam->SetOpponents(m_pBlueTeam); m_pBlueTeam->SetOpponents(m_pRedTeam); //create the walls Vector2D TopLeft(m_pPlayingArea->Left(), m_pPlayingArea->Top()); Vector2D TopRight(m_pPlayingArea->Right(), m_pPlayingArea->Top()); Vector2D BottomRight(m_pPlayingArea->Right(), m_pPlayingArea->Bottom()); Vector2D BottomLeft(m_pPlayingArea->Left(), m_pPlayingArea->Bottom()); m_vecWalls.push_back(Wall2D(BottomLeft, m_pRedGoal->RightPost())); m_vecWalls.push_back(Wall2D(m_pRedGoal->LeftPost(), TopLeft)); m_vecWalls.push_back(Wall2D(TopLeft, TopRight)); m_vecWalls.push_back(Wall2D(TopRight, m_pBlueGoal->LeftPost())); m_vecWalls.push_back(Wall2D(m_pBlueGoal->RightPost(), BottomRight)); m_vecWalls.push_back(Wall2D(BottomRight, BottomLeft)); ParamLoader* p = ParamLoader::Instance(); }
App::PointInt Viewer::calculateWindowTopLeft(ResizePositionMethod method, const SizeInt &newSize ) { wxDisplay display(DisplayFromPointFallback(PositionScreen())); auto rtDesktop = wxToRect(display.GetClientArea()); switch (method) { case ResizePositionMethod::PositionToScreen: return rtDesktop.TopLeft() + RoundCast((rtDesktop.Dimensions() - newSize) * 0.5f); case ResizePositionMethod::PositionToCurrent: { auto pt = AnchorCenter() + RoundCast(newSize * -0.5f); if ((pt.X + newSize.Width) > rtDesktop.Right()) { pt.X = rtDesktop.Right() - newSize.Width; } else if (pt.X < rtDesktop.Left()) { pt.X = rtDesktop.Left(); } if (pt.Y + newSize.Height > rtDesktop.Bottom()) { pt.Y = rtDesktop.Bottom() - newSize.Height; } else if (pt.Y < rtDesktop.Top()) { pt.Y = rtDesktop.Top(); } AnchorTL(pt); return pt; } case ResizePositionMethod::PositionNothing: { // Cap to screen PointInt pt = AnchorTL(); if ((pt.X + newSize.Width) > rtDesktop.Right()) pt.X=rtDesktop.Right()-newSize.Width; else if (pt.X < rtDesktop.Left()) pt.X = rtDesktop.Left(); if ((pt.Y + newSize.Height) > rtDesktop.Bottom()) pt.Y=rtDesktop.Bottom()-newSize.Height; else if (pt.Y < rtDesktop.Top()) pt.Y=rtDesktop.Top(); AnchorCenter(pt + RoundCast(newSize * 0.5f)); return pt; } default: DO_THROW(Err::InvalidParam, "Invalid reposition method: " + ToAString(method)); } }
/*! \fn swUiControl::Clip( Rect &r ) */ bool swUiControl::Clip( Rect &r ) { swUiControl* myparent; Rect R(0,0, Width(), Height()); R += TopLeft(true); r &= R; // I am toplevel then I am the last to clip the subrect ==> stop clipping: if( ( UiFlag( uiflags::toplevel )) || (!Parent() ) ) return false; // I am not a toplevel control and I am confined into my parent control ==> passe result rect to my parent if( (myparent=FirstParentAs<swUiControl>()) ) myparent->Clip( r ); return false; }
BOOL CSDWindow::IsCursorInTitlebar(const CPoint &cursor) { CPoint ptTopLeft; ptTopLeft = TopLeft(); // Check is in titlebar if ((ptTopLeft.x <= cursor.x && cursor.x <= ptTopLeft.x + Width()) && (ptTopLeft.y <= cursor.y && cursor.y <= ptTopLeft.y + SIZE_TITLEBAR)) { return TRUE; } return FALSE; }
/*! \fn swUiControl::_mouseSelect( const pxy& xy ) \brief Test and confirm/infirm if the mouse is targeting inside the geometry's UI control \param pxy xy the coordinates in screen absolute of the mouse pointer \return swUiControl* self or child target, or NULL if totally outside inner geometry. \note No actions taken at this level - it just returns the UI control instance as the positive response or null if no target . */ swUiControl* swUiControl::_mouseSelect( const pxy& xy ) { swUiControl* child; Rect R = m_geometry; R += TopLeft(true); if( ! R.contains( xy ) ) return 0l; // Still have to check if we are visible "targetable" - that is immuable rule if( ! ( Visible() || Enabled() ) ) return 0l;//UiFlag( uiflags::visible ) ) return 0l; if(! (child = FirstChild<swUiControl>()) ) return this; if( ( child = child->_mouseSelect( xy )) ) return child; for(; child; child = NextChild<swUiControl>() ) if( ( child = child->_mouseSelect( xy )) ) return child; return this; }
void CSwingBorderWnd::OnPaint() { CWnd::OnPaint(); CPaintDC dc(this); // device context for painting CDC *pDC = GetWindowDC(); CRect rectItem, pRect; GetWindowRect(pRect); GetClientRect(rectItem); rectItem.right = rectItem.left + pRect.Width(); rectItem.bottom = rectItem.top + pRect.Height(); CPoint TopLeft(rectItem.left, rectItem.top); CPoint BottomRight(rectItem.right - 1, rectItem.bottom - 1); CPoint TopRight(rectItem.right - 1, rectItem.top); CPoint BottomLeft(rectItem.left, rectItem.bottom - 1); pDC->SelectObject(&nDarkBorder); pDC->MoveTo(TopLeft); pDC->LineTo(TopRight); pDC->MoveTo(TopLeft); pDC->LineTo(BottomLeft); pDC->MoveTo(BottomLeft.x, BottomLeft.y - 1); pDC->LineTo(BottomRight.x, BottomRight.y - 1); pDC->MoveTo(BottomRight.x - 1, BottomRight.y); pDC->LineTo(TopRight.x - 1, TopRight.y); pDC->SelectObject(&nWhiteBorder); pDC->MoveTo(BottomLeft); pDC->LineTo(BottomRight); pDC->MoveTo(BottomRight); pDC->LineTo(TopRight); pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1); pDC->LineTo(TopRight.x - 1, TopRight.y + 1); pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1); pDC->LineTo(BottomLeft.x + 1, BottomLeft.y - 1); ReleaseDC(pDC); // TODO: Add your message handler code here // Do not call CWnd::OnPaint() for painting messages }
CRect CDepartmentEstimationDialog::ConvertPhysicalRectToCanvas(CRectReal Coordinate) { CRect CanvasRect; SPosition TopLeft(Coordinate.left, Coordinate.top), ButtomRight(Coordinate.right, Coordinate.bottom); POINT TopLeftCanvas, ButtomRightCanvas; TopLeftCanvas = ConvertPhysicalCoordinateToCanvas(TopLeft); ButtomRightCanvas = ConvertPhysicalCoordinateToCanvas(ButtomRight); CanvasRect.top = TopLeftCanvas.y; CanvasRect.left = TopLeftCanvas.x; CanvasRect.bottom = ButtomRightCanvas.y; CanvasRect.right = ButtomRightCanvas.x; return CanvasRect; }
void FPaperExtractSpritesViewportClient::DrawRectangle(FCanvas* Canvas, const FLinearColor& Color, const FIntRect& Rect) { FVector2D TopLeft(-ZoomPos.X * ZoomAmount + Rect.Min.X * ZoomAmount, -ZoomPos.Y * ZoomAmount + Rect.Min.Y * ZoomAmount); FVector2D BottomRight(-ZoomPos.X * ZoomAmount + Rect.Max.X * ZoomAmount, -ZoomPos.Y * ZoomAmount + Rect.Max.Y * ZoomAmount); FVector2D RectVertices[4]; RectVertices[0] = FVector2D(TopLeft.X, TopLeft.Y); RectVertices[1] = FVector2D(BottomRight.X, TopLeft.Y); RectVertices[2] = FVector2D(BottomRight.X, BottomRight.Y); RectVertices[3] = FVector2D(TopLeft.X, BottomRight.Y); for (int32 RectVertexIndex = 0; RectVertexIndex < 4; ++RectVertexIndex) { const int32 NextVertexIndex = (RectVertexIndex + 1) % 4; FCanvasLineItem RectLine(RectVertices[RectVertexIndex], RectVertices[NextVertexIndex]); RectLine.SetColor(Color); Canvas->DrawItem(RectLine); } }
void MHmgphy::WriteJython( const vector<double> &X, double trim, int Ntr ) { FILE *f = FileOpenOrDie( "JythonTransforms.txt", "w" ); fprintf( f, "transforms = {\n" ); int nr = vRgn.size(); for( int i = 0, itrf = 0; i < nr; ++i ) { const RGN& I = vRgn[(*zs)[i].i]; // skip unused tiles if( I.itr < 0 ) continue; ++itrf; const char *path; DisplayStrings( NULL, path, I ); // fix origin : undo trimming int j = I.itr * NX; THmgphy T( &X[j] ); double x_orig; double y_orig; TopLeft( y_orig, x_orig, T, gW, gH, trim ); fprintf( f, "\"%s\" : [%f, %f, %f, %f, %f, %f, %.12g, %.12g]%s\n", path, X[j+0], X[j+3], X[j+6], X[j+1], X[j+4], X[j+7], x_orig, y_orig, (itrf == Ntr ? "" : ",") ); } fprintf( f, "}\n" ); fclose( f ); IDBT2ICacheClear(); }
Dimension BottomRight() const { const auto &top_left = TopLeft(); return {num_rows - top_left.num_rows, num_columns - top_left.num_columns}; }
void LowerRect(HDC hDC, LPRECT rcp) { TopLeft(hDC, rcp, hpenLowlight, FALSE); BottomRight(hDC, rcp, hpenHilight, FALSE); }
void range::Offset(cell inLocation, bool horizontal, int first, int count) { bool wasSpecial = false; range rf = GetFlatRange(inLocation); if (horizontal) if (count < 0) { if (rf.left > first + count && rf.right <= first) { TopLeft() = cell::InvalidCell; BotRight() = cell::InvalidCell; wasSpecial = true; } else if (rf.left > first + count && rf.left <= first) { int dx = first - rf.left + 1; if (inLocation.h < first) dx += count; TopLeft().OffsetRefBy(dx, 0); BotRight().Offset(inLocation, true, first, count); wasSpecial = true; } else if (rf.right > first + count && rf.right <= first) { int dx = first - rf.right; if (inLocation.h < first) dx += count; BotRight().OffsetRefBy(dx, 0); TopLeft().Offset(inLocation, true, first, count); wasSpecial = true; } } else { if (rf.left < first && rf.right >= first) { if (inLocation.h < first) BotRight().OffsetRefBy(count, 0); else TopLeft().OffsetRefBy(-count, 0); wasSpecial = true; } } else if (count < 0) { if (rf.top > first + count && rf.bottom <= first) { TopLeft() = cell::InvalidCell; BotRight() = cell::InvalidCell; wasSpecial = true; } else if (rf.top > first + count && rf.top <= first) { int dy = first - rf.top + 1; if (inLocation.v < first) dy += count; TopLeft().OffsetRefBy(0, dy); BotRight().Offset(inLocation, true, first, count); wasSpecial = true; } else if (rf.bottom > first + count && rf.bottom <= first) { int dy = first - rf.bottom; if (inLocation.v < first) dy += count; BotRight().OffsetRefBy(0, dy); TopLeft().Offset(inLocation, true, first, count); wasSpecial = true; } } else { if (rf.top < first && rf.bottom >= first) { if (inLocation.v < first) BotRight().OffsetRefBy(0, count); else TopLeft().OffsetRefBy(0, -count); wasSpecial = true; } } if (!wasSpecial) { TopLeft().Offset(inLocation, horizontal, first, count); BotRight().Offset(inLocation, horizontal, first, count); } } /* range::Offset */
void CSwingCheckBox::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC* pDC = CDC::FromHandle(lpDIS->hDC); CRect rectItem(lpDIS->rcItem); CRect rectCheck(rectItem); rectCheck.right = rectCheck.left + 12; rectCheck.bottom = rectCheck.top + 12; CPoint TopLeft(rectCheck.left, rectCheck.top); CPoint BottomRight(rectCheck.right, rectCheck.bottom); CPoint TopRight(rectCheck.right, rectCheck.top); CPoint BottomLeft(rectCheck.left, rectCheck.bottom); // TODO: Add your code to draw the specified item pDC->SelectObject(&nInactiveBrush); pDC->SelectStockObject(NULL_PEN); pDC->Rectangle(rectItem); pDC->SelectObject(&nDarkBorder); pDC->MoveTo(TopLeft); pDC->LineTo(TopRight); pDC->MoveTo(TopLeft); pDC->LineTo(BottomLeft); pDC->MoveTo(BottomLeft.x, BottomLeft.y - 1); pDC->LineTo(BottomRight.x, BottomRight.y - 1); pDC->MoveTo(BottomRight.x - 1, BottomRight.y); pDC->LineTo(TopRight.x - 1, TopRight.y); pDC->SelectObject(&nWhiteBorder); pDC->MoveTo(BottomLeft); pDC->LineTo(BottomRight); pDC->MoveTo(BottomRight); pDC->LineTo(TopRight); pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1); pDC->LineTo(TopRight.x - 1, TopRight.y + 1); pDC->MoveTo(TopLeft.x + 1, TopLeft.y + 1); pDC->LineTo(BottomLeft.x + 1, BottomLeft.y - 1); pDC->SelectStockObject(DEFAULT_GUI_FONT); pDC->TextOut(16, 0, m_strCaption); if (m_Checked) { pDC->SelectObject(&nCheck); pDC->MoveTo(2, 3); pDC->LineTo(3, 8); pDC->MoveTo(3, 9); pDC->LineTo(9, 3); } if (lpDIS->itemState & ODS_FOCUS) { pDC->SelectObject(&nSelectedBorder); pDC->SelectStockObject(NULL_BRUSH); int xlen = pDC->GetTextExtent(m_strCaption).cx; pDC->Rectangle(15, 0, 13 + xlen + 3, 12); } }
void MHmgphy::WriteTrakEM( double xmax, double ymax, const vector<double> &X, double trim, int xml_type, int xml_min, int xml_max ) { FILE *f = FileOpenOrDie( "MultLayHmgphy.xml", "w" ); int oid = 3; fprintf( f, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ); TrakEM2WriteDTD( f ); fprintf( f, "<trakem2>\n" ); fprintf( f, "\t<project\n" "\t\tid=\"0\"\n" "\t\ttitle=\"Project\"\n" "\t\tmipmaps_folder=\"trakem2.mipmaps/\"\n" "\t\tn_mipmap_threads=\"8\"\n" "\t/>\n" ); fprintf( f, "\t<t2_layer_set\n" "\t\toid=\"%d\"\n" "\t\ttransform=\"matrix(1,0,0,1,0,0)\"\n" "\t\ttitle=\"Top level\"\n" "\t\tlayer_width=\"%.2f\"\n" "\t\tlayer_height=\"%.2f\"\n" "\t>\n", oid++, xmax, ymax ); int prev = -1; // will be previously written layer int offset = int(2 * trim + 0.5); int nr = vRgn.size(); for( int i = 0; i < nr; ++i ) { const RGN& I = vRgn[(*zs)[i].i]; // skip unused tiles if( I.itr < 0 ) continue; // changed layer if( (*zs)[i].z != prev ) { if( prev != -1 ) fprintf( f, "\t\t</t2_layer>\n" ); fprintf( f, "\t\t<t2_layer\n" "\t\t\toid=\"%d\"\n" "\t\t\tthickness=\"0\"\n" "\t\t\tz=\"%d\"\n" "\t\t>\n", oid++, (*zs)[i].z ); prev = (*zs)[i].z; } const char *path; char title[128]; DisplayStrings( title, path, I ); // fix origin : undo trimming int j = I.itr * NX; THmgphy T( &X[j] ); double x_orig; double y_orig; TopLeft( y_orig, x_orig, T, gW, gH, trim ); fprintf( f, "\t\t\t<t2_patch\n" "\t\t\t\toid=\"%d\"\n" "\t\t\t\twidth=\"%d\"\n" "\t\t\t\theight=\"%d\"\n" "\t\t\t\ttransform=\"matrix(1,0,0,1,%f,%f)\"\n" "\t\t\t\ttitle=\"%s\"\n" "\t\t\t\ttype=\"%d\"\n" "\t\t\t\tfile_path=\"%s\"\n" "\t\t\t\to_width=\"%d\"\n" "\t\t\t\to_height=\"%d\"\n", oid++, gW - offset, gH - offset, x_orig, y_orig, title, xml_type, path, gW - offset, gH - offset ); if( xml_min < xml_max ) { fprintf( f, "\t\t\t\tmin=\"%d\"\n" "\t\t\t\tmax=\"%d\"\n" "\t\t\t>\n", xml_min, xml_max ); } else fprintf( f, "\t\t\t>\n" ); fprintf( f, "\t\t\t<ict_transform" " class=\"mpicbg.trakem2.transform.HomographyModel2D\"" " data=\"%f %f %f %f %f %f %.12g %.12g 1\"/>\n" "\t\t\t</t2_patch>\n", X[j ], X[j+1], X[j+2], X[j+3], X[j+4], X[j+5], X[j+6], X[j+7] ); } if( nr > 0 ) fprintf( f, "\t\t</t2_layer>\n" ); fprintf( f, "\t</t2_layer_set>\n" ); fprintf( f, "</trakem2>\n" ); fclose( f ); IDBT2ICacheClear(); }
const WPoint WRectangle::TopLeft() const { return TopLeft(); }