void ButtonWindow::OnPaint(Canvas &canvas) { const bool focused = HasCursorKeys() ? HasFocus() : down; if (focused) { Pen pen(Layout::Scale(1), COLOR_BLACK); canvas.Select(pen); canvas.SelectHollowBrush(); canvas.Rectangle(-1, -1, canvas.GetWidth(), canvas.GetHeight()); } PixelRect rc(2, 2, canvas.GetWidth() - 4, canvas.GetHeight() - 4); if (down) { rc.left += Layout::FastScale(1); rc.top += Layout::FastScale(1); } canvas.DrawButton(GetClientRect(), down); canvas.SetTextColor(IsEnabled() ? (IsDithered() && down ? COLOR_WHITE : COLOR_BLACK) : COLOR_GRAY); canvas.SetBackgroundTransparent(); unsigned style = GetTextStyle(); if (IsDithered()) style |= DT_UNDERLINE; canvas.DrawFormattedText(&rc, text.c_str(), style); }
void DrawMText( AcGiWorldDraw* mode, const AcGePoint3d& pt, double angle, const CString& str, double height, AcDbMText::AttachmentPoint ap, const CString& style ) { //acutPrintf(_T("\n绘制前--文字颜色:%d"), mode->subEntityTraits().color()); AcDbMText mt; // //AcDbObjectId style; // 文字样式 AcDbObjectId fontId = GetTextStyle(style); if(!fontId.isNull()) { acutPrintf(_T("\n设置样式为罗马字体")); mt.setTextStyle(fontId); } mt.setLocation( pt ); mt.setTextHeight( height ); mt.setAttachment( ap ); mt.setRotation( angle ); mt.setContents( str ); // 经过测试发现,AcDbMText调用worldDraw的同时会修改mode的一些属性 mt.setColorIndex( mode->subEntityTraits().color() ); mt.worldDraw( mode ); //acutPrintf(_T("\n绘制后--文字颜色:%d"), mode->subEntityTraits().color()); }
/* * Extract a TEStyle object from the buffer. */ void RStyleBlock::TEStyle::Create(const uint8_t* buf) { fFontID = Reformat::Get32LE(buf); fForeColor = Reformat::Get16LE(buf + 4); fBackColor = Reformat::Get16LE(buf + 6); fUserData = Reformat::Get32LE(buf + 8); LOGI(" TEStyle: font fam=0x%04x size=%-2d style=0x%02x fore=0x%04x", GetFontFamily(), GetFontSize(), GetTextStyle(), fForeColor); }
void WndButton::OnPaint(Canvas &canvas) { PixelRect rc = { PixelScalar(0), PixelScalar(0), PixelScalar(canvas.get_width()), PixelScalar(canvas.get_height()) }; const bool focused = HasFocus(); const bool pressed = is_down(); renderer.DrawButton(canvas, rc, focused, pressed); // If button has text on it tstring caption = get_text(); if (caption.empty()) return; rc = renderer.GetDrawingRect(rc, pressed); canvas.SetBackgroundTransparent(); if (!IsEnabled()) canvas.SetTextColor(look.button.disabled.color); else if (focused) canvas.SetTextColor(look.button.focused.foreground_color); else canvas.SetTextColor(look.button.standard.foreground_color); #ifndef USE_GDI canvas.formatted_text(&rc, caption.c_str(), GetTextStyle()); #else unsigned style = DT_CENTER | DT_NOCLIP | DT_WORDBREAK; canvas.Select(*(look.button.font)); PixelRect text_rc = rc; canvas.formatted_text(&text_rc, caption.c_str(), style | DT_CALCRECT); text_rc.right = rc.right; PixelScalar offset = rc.bottom - text_rc.bottom; if (offset > 0) { offset /= 2; text_rc.top += offset; text_rc.bottom += offset; } canvas.formatted_text(&text_rc, caption.c_str(), style); #endif }
void LargeTextWindow::OnPaint(Canvas &canvas) { canvas.ClearWhite(); PixelRect rc(0, 0, canvas.GetWidth() - 1, canvas.GetHeight() - 1); canvas.DrawOutlineRectangle(rc.left, rc.top, rc.right, rc.bottom, COLOR_BLACK); if (value.empty()) return; const PixelScalar padding = Layout::GetTextPadding(); rc.Grow(-padding); canvas.SetBackgroundTransparent(); canvas.SetTextColor(COLOR_BLACK); rc.top -= origin * GetFont().GetHeight(); canvas.DrawFormattedText(&rc, value.c_str(), GetTextStyle()); }
void WndCustomButton::OnPaint(Canvas &canvas) { #ifdef HAVE_CLIPPING /* background and selector */ canvas.Clear(look.background_brush); #endif PixelRect rc = GetClientRect(); // Draw focus rectangle if (HasFocus()) { canvas.DrawFilledRectangle(rc, look.focused.background_color); canvas.SetTextColor(IsEnabled() ? look.focused.text_color : look.button.disabled.color); } else { canvas.DrawFilledRectangle(rc, look.background_color); canvas.SetTextColor(IsEnabled() ? look.text_color : look.button.disabled.color); } // If button has text on it tstring caption = get_text(); if (caption.empty()) return; // If button is pressed, offset the text for 3D effect if (is_down()) OffsetRect(&rc, 1, 1); canvas.SelectNullPen(); canvas.SetBackgroundTransparent(); #ifndef USE_GDI canvas.formatted_text(&rc, caption.c_str(), GetTextStyle()); #else unsigned s = DT_CENTER | DT_NOCLIP | DT_WORDBREAK; canvas.Select(*(look.button.font)); canvas.formatted_text(&rc, caption.c_str(), s); #endif }