void CReportEntityBox::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CReportEntityBox::Draw Description : Draws the object. Access : Public Return : void Parameters : CDC* dc - "CDC" to draw to CRect rect - True (zoomed) rectangle to draw to. Usage : Called from "CDiagramEditor::DrawObjects". ============================================================*/ { if( GetFill() ) { const float* table = Drawer::GetColorByIndex(GetFillColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); dc->FillSolidRect(rect,clr); } CPen pen; if( GetBorderStyle()!=0 ) { const float* table = Drawer::GetColorByIndex(GetBorderColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); pen.CreatePen( PS_SOLID, GetBorderThickness(), clr ); dc->SelectObject( &pen ); if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_LEFT) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.left,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_RIGHT) { dc->MoveTo(rect.right,rect.bottom); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_TOP) { dc->MoveTo(rect.left,rect.top); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_BOTTOM) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.right,rect.bottom); } } else dc->SelectStockObject( NULL_PEN ); dc->SelectStockObject( BLACK_PEN ); dc->SelectStockObject( WHITE_BRUSH ); }
//填数字 void fill() { for (int i = 1; i < 10; i++) { for (int j = 1; j < 10; j++) { comp(i, j, GetFill(i, j)); } } }
void CReportEntityBox::Serialize(CArchive& ar) { typedef struct { int a_f; int b_f; } BOX_RESERVE_FIELDS; BOX_RESERVE_FIELDS box_reserve; memset(&box_reserve,0,sizeof(BOX_RESERVE_FIELDS)); CDiagramEntity::Serialize(ar); if (ar.IsStoring()) { // —охран¤ем double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); ar.Write(&thickness,sizeof(double)); unsigned int bst = GetBorderStyle( ); ar.Write(&bst,sizeof(unsigned int)); unsigned int brC = GetBorderColor( ); ar.Write(&brC,sizeof(unsigned int)); BOOL gf = GetFill(); ar.Write(&gf, sizeof(BOOL)); brC = GetFillColor(); ar.Write(&brC,sizeof(unsigned int)); ar.Write(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); } else { // „итаем double bordhickness; ar.Read(&bordhickness,sizeof(double)); unsigned int bordst; ar.Read(&bordst,sizeof(unsigned int)); unsigned int linecolor; ar.Read(&linecolor,sizeof(unsigned int)); BOOL fil; ar.Read(&fil,sizeof(BOOL)); unsigned int filcolor; ar.Read(&filcolor,sizeof(unsigned int)); ar.Read(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); int bt = CUnitConversion::InchesToPixels( bordhickness ); SetBorderThickness( bt ); SetBorderStyle( bordst ); SetBorderColor( linecolor ); SetFill( fil ); SetFillColor( filcolor ); } }
RESULTCODE FerryRegionSymbolImpl::Draw(Geometry* pGeometry, Renderer* pRenderer, Transformation* pTransform) { if(pGeometry==NULL) { return AG_FAILURE; } augeGeometryType geom_type = pGeometry->GeometryType(); if((geom_type!=augeGTPolygon) &&(geom_type!=augeGTMultiPolygon)) { return AG_FAILURE; } if(m_size==0) { return AG_FAILURE; } RendererCairo* pRendererCairo = static_cast<RendererCairo*>(pRenderer); cairo_t *canvas_cairo = pRendererCairo->GetCairo(); cairo_surface_t *canvas_surface=pRendererCairo->GetCairoSurface(); Fill *pFill = GetFill(); Stroke *pStroke = GetStroke(); g_uchar* wkb = pGeometry->AsBinary(); cairo_new_path(canvas_cairo); switch(geom_type) { case augeGTPolygon: build_path(canvas_cairo, (WKBPolygon*)wkb, pTransform); break; case augeGTMultiPolygon: build_path(canvas_cairo, (WKBMultiPolygon*)wkb, pTransform); break; } if(pFill!=NULL) { GColor& color = pFill->GetColor(); cairo_set_source_rgba(canvas_cairo, color.GetRedF(), color.GetGreenF(), color.GetBlueF(), color.GetAlphaF()); if(pStroke==NULL) cairo_fill(canvas_cairo); else cairo_fill_preserve(canvas_cairo); } if(pStroke!=NULL) { set_stroke_style(canvas_cairo, pStroke); cairo_stroke(canvas_cairo); } return AG_SUCCESS; }
CString CReportEntityBox::GetString() const /* ============================================================ Function : CReportEntityBox::GetString Description : Creates a string representing this object. Access : Public Return : CString - Resulting string Parameters : none Usage : Call to save this object to file. ============================================================*/ { CRect rect = GetRect(); double oldleft = GetLeft(); double oldright = GetRight(); double oldtop = GetTop(); double oldbottom = GetBottom(); double left = CUnitConversion::PixelsToInches( rect.left ); double right = CUnitConversion::PixelsToInches( rect.right ); double top = CUnitConversion::PixelsToInches( rect.top ); double bottom = CUnitConversion::PixelsToInches( rect.bottom ); CReportEntityBox* const local = const_cast< CReportEntityBox* const >( this ); local->SetLeft( left ); local->SetRight( right ); local->SetTop( top ); local->SetBottom( bottom ); CString str; double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); str.Format( _T( ",%f,%i,%i,%i,%i" ), thickness, GetBorderStyle( ), GetBorderColor( ), GetFill( ), GetFillColor( ) ); str += _T( ";" ); str = GetDefaultGetString() + str; local->SetLeft( oldleft ); local->SetRight( oldright ); local->SetTop( oldtop ); local->SetBottom( oldbottom ); return str; }