uint32 inline CRenderer::AddChar( uint32 c, int32 x, int32 y, uint32 flags ) { float tx1, ty1, tx2, ty2; uint32 w, h, spacing; colour_t col; rectangle_t r; CheckVertexBuffer( 12 ); tx1 = renderFont->texCoords[c][0]; tx2 = renderFont->texCoords[c][2]; ty1 = 1.0f - renderFont->texCoords[c][1]; ty2 = 1.0f - renderFont->texCoords[c][3]; w = (uint32)( ( tx2 - tx1 ) * renderFont->width ); h = (uint32)( ( ty1 - ty2 ) * renderFont->height ); spacing = (uint32)renderFont->spacing * 2; r.x = (int16)x, r.y = (int16)y, r.w = (uint16)w, r.h = (uint16)h; if ( clipping && ( x < (int32)clip.x || (int32)(x+w) > (int32)clip.x+clip.w+spacing+1 || y < (int32)clip.y || (int32)(y+h) > (int32)clip.y+clip.h ) ) { return ( w - spacing ); } if ( flags & TFLAG_SHADOW ) { colour_t shadowCol = colour_t( 0, 0, 0, drawColour.a ); static const int32 shadowOffset = 1; col.hex = drawColour.hex; SetDrawColour( &shadowCol ); AddVertexTextured( x+shadowOffset, y+shadowOffset, tx1, ty1 ); AddVertexTextured( x+w+shadowOffset, y+shadowOffset, tx2, ty1 ); AddVertexTextured( x+shadowOffset, y+h+shadowOffset, tx1, ty2 ); AddVertexTextured( x+w+shadowOffset, y+shadowOffset, tx2, ty1 ); AddVertexTextured( x+w+shadowOffset, y+h+shadowOffset, tx2, ty2 ); AddVertexTextured( x+shadowOffset, y+h+shadowOffset, tx1, ty2 ); SetDrawColour( &col ); } AddVertexTextured( x, y, tx1, ty1 ); AddVertexTextured( x+w, y, tx2, ty1 ); AddVertexTextured( x, y+h, tx1, ty2 ); AddVertexTextured( x+w, y, tx2, ty1 ); AddVertexTextured( x+w, y+h, tx2, ty2 ); AddVertexTextured( x, y+h, tx1, ty2 ); return ( w - 2 * renderFont->spacing ); }
// Colored table void FancyTable(wxArrayString& header, wxArrayPtrVoid& data) { // Colors, line width and bold font SetFillColour(wxColour(255,0,0)); SetTextColour(255); SetDrawColour(wxColour(128,0,0)); SetLineWidth(.3); SetFont(wxS(""),wxS("B")); //Header double w[4] = {40,35,40,45}; size_t i; for (i = 0; i < header.GetCount(); i++) { Cell(w[i],7,header[i],wxPDF_BORDER_FRAME, 0, wxPDF_ALIGN_CENTER, 1); } Ln(); // Color and font restoration SetFillColour(wxColour(224,235,255)); SetTextColour(0); SetFont(wxS("")); // Data int fill = 0; size_t j; for (j = 0; j < data.GetCount(); j++) { wxArrayString* row = (wxArrayString*) data[j]; Cell(w[0],6,(*row)[0],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_LEFT,fill); Cell(w[1],6,(*row)[1],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_LEFT,fill); Cell(w[2],6,(*row)[2],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT,fill); Cell(w[3],6,(*row)[3],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT,fill); Ln(); fill = 1 - fill; } Cell((w[0]+w[1]+w[2]+w[3]),0,wxS(""),wxPDF_BORDER_TOP); }
void CRenderer::ProcessUnderline( const CFont* font, int32 x, int32 y, int32& x2, int32& y2, colour_t& lineColour ) { colour_t col; switch ( lineStatus ) { case LINE_BEGIN: x2 = x; y2 = y + font->size + 2; lineColour = drawColour; lineStatus = LINE_DRAWING; break; case LINE_DRAW: Flush(); col = drawColour; SetDrawColour( &lineColour ); DrawRect( x2, y2, x - x2, 1 ); Flush(); UpdateVertexFormat( true ); renderTexture = font->texture; SetDrawColour( &col ); if ( lineContinue ) { lineStatus = LINE_DRAWING; lineContinue = false; x2 = x; y2 = y + font->size; } else { lineStatus = LINE_IDLE; } lineColour = colour; break; } }
void VisualCard::drawAt(Point pos) { m_rect=Rect(pos,CARD_WIDTH,CARD_HEIGHT); if (isFaceUp()) { SetDrawColour(180,180,180); DrawRectangleFilled(m_rect.get_left(),m_rect.get_top(),m_rect.get_right(),m_rect.get_bottom()); char text[2]="0"; SetDrawColour(0,0,0); text[0]=toCharSuit(); DrawText(m_rect.get_left()+10,m_rect.get_top()+8,text); text[0] = toCharDenomination(); DrawText(m_rect.get_left()+10,m_rect.get_top()+30,text); } else { SetDrawColour(0,190,0); DrawRectangleFilled(m_rect.get_left(),m_rect.get_top(),m_rect.get_right(),m_rect.get_bottom()); } }
void CRenderer::ProcessTag( const MGuiFormatTag* tag ) { colour_t col; if ( tag->flags & TAG_COLOUR || tag->flags & TAG_COLOUR_END ) { SetDrawColour( &tag->colour ); if ( lineStatus == LINE_DRAWING ) { lineStatus = LINE_DRAW; lineContinue = true; } } if ( tag->flags & TAG_UNDERLINE ) { lineStatus = LINE_BEGIN; } else if ( tag->flags & TAG_UNDERLINE_END ) { switch ( lineStatus ) { case LINE_DRAWING: case LINE_DRAW: lineStatus = LINE_DRAW; lineContinue = false; break; default: lineStatus = LINE_IDLE; break; } } }
void CRenderer::DrawText( const MGuiRendFont* fnt, const char_t* text, int32 x, int32 y, uint32 flags, const MGuiFormatTag tags[], uint32 ntags ) { int32 dx, dy, lineX, lineY; uint32 c, ntag = 0, idx = 0; colour_t lineColour, defaultColour; register const char_t* s; const MGuiFormatTag* tag = NULL; const CFont* font = (const CFont*)fnt; if ( fnt == NULL || text == NULL ) return; lineStatus = LINE_IDLE; if ( renderTexture == NULL || renderTexture != font->texture ) { Flush(); renderTexture = font->texture; } IncreaseZPlane(); UpdateVertexFormat( true ); renderFont = font; defaultColour.hex = drawColour.hex; if ( tags && ntags > 0 ) tag = &tags[ntag]; dx = x; lineX = dx; dy = y; lineY = dy; for ( s = text; *s; ++s, ++idx ) { c = *(uchar_t*)s; // Process possible format tags for this index if ( tag && tag->index == idx ) { ProcessTag( tag ); ProcessUnderline( font, dx, dy, lineX, lineY, lineColour ); if ( ++ntag < ntags ) tag = &tags[ntag]; else tag = NULL; } if ( c < font->first_char || c > font->last_char ) { continue; } else { dx += AddChar( c - font->first_char, dx, dy, flags ); } } Flush(); // Finish the underline in case the end tag was missing if ( lineStatus == LINE_DRAWING ) { lineStatus = LINE_DRAW; ProcessUnderline( font, dx, dy, lineX, lineY, lineColour ); } // Reset back to default colour if the end tag was missing. if ( drawColour.hex != defaultColour.hex ) { SetDrawColour( &defaultColour ); } UpdateVertexFormat( false ); renderTexture = NULL; renderFont = NULL; }
void BackBuffer::SetDrawColour(unsigned char r, unsigned char g, unsigned char b) { SetDrawColour(r, g, b, 0xFF); }