static void DrawBanner(Canvas &canvas, PixelRect &rc) { const unsigned padding = 2; const Bitmap logo(IDB_LOGO); const unsigned banner_height = logo.GetHeight(); /* draw the XCSoar logo */ int x = rc.left + padding; canvas.Copy(x, rc.top + padding, logo.GetWidth(), logo.GetHeight(), logo, 0, 0); x += logo.GetWidth() + 8; canvas.Select(bold_font); canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); /* draw the XCSoar banner text with a larger font */ Font large_font; large_font.LoadFile("/opt/xcsoar/share/fonts/VeraBd.ttf", 40); canvas.Select(large_font); const unsigned name_y = rc.top + (banner_height - large_font.GetHeight()) / 2; const TCHAR *const name1 = _T("XC"); canvas.DrawText(x, name_y, name1); x += canvas.CalcTextWidth(name1); const TCHAR *const name2 = _T("Soar"); canvas.SetTextColor(COLOR_GRAY); canvas.DrawText(x, name_y, name2); canvas.SetTextColor(COLOR_BLACK); x += canvas.CalcTextWidth(name2) + 30; /* some more text */ const TCHAR *const website = _T("www.xcsoar.org"); canvas.Select(normal_font); canvas.DrawText(x, rc.top + (banner_height - normal_font.GetHeight()) / 2, website); const TCHAR *const comment = _T("powered off"); canvas.DrawText(rc.right - canvas.CalcTextWidth(comment) - padding, rc.top + padding, comment); rc.top += banner_height + 8; }
void RenderGlidePolarInfo(Canvas &canvas, const PixelRect rc, const ChartLook &chart_look, const GlidePolar &glide_polar) { canvas.Select(chart_look.label_font); StaticString<80> text; StaticString<20> value; canvas.SetBackgroundTransparent(); FormatUserMass(glide_polar.GetTotalMass(), value.buffer(), true); int left = rc.left*0.8 + rc.right*0.2; text.Format(_T("%s: %s"), _("Mass"), value.c_str()); canvas.DrawText(left, rc.bottom - Layout::Scale(50), text); double wl = glide_polar.GetWingLoading(); if (wl != 0) { FormatUserWingLoading(wl, value.buffer(), true); text.Format(_T("%s: %s"), _("Wing loading"), value.c_str()); canvas.DrawText(left, rc.bottom - Layout::Scale(35), text); } }
// display a simple splash screen until launcher is ready void BadaGraphicsManager::showSplash() { Canvas canvas; canvas.Construct(); canvas.SetBackgroundColor(Color::COLOR_BLACK); canvas.Clear(); int x = _videoMode.hardwareWidth / 3; int y = _videoMode.hardwareHeight / 3; Font *pFont = new Font(); pFont->Construct(FONT_STYLE_ITALIC | FONT_STYLE_BOLD, 55); canvas.SetFont(*pFont); canvas.SetForegroundColor(Color::COLOR_GREEN); canvas.DrawText(Point(x, y), L"ScummVM"); delete pFont; pFont = new Font(); pFont->Construct(FONT_STYLE_ITALIC | FONT_STYLE_BOLD, 35); canvas.SetFont(*pFont); canvas.SetForegroundColor(Color::COLOR_WHITE); canvas.DrawText(Point(x + 70, y + 50), L"Loading ..."); delete pFont; canvas.Show(); }
void OptionStartsWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned DrawListIndex) { assert(DrawListIndex <= task.GetOptionalStartPointCount() + (RealStartExists ? 2 : 1)); assert(GetList().GetLength() == task.GetOptionalStartPointCount() + (RealStartExists ? 2 : 1)); const unsigned padding = Layout::GetTextPadding(); const unsigned index_optional_starts = DrawListIndex - (RealStartExists ? 1 : 0); if (DrawListIndex == GetList().GetLength() - 1) { canvas.DrawText(rc.left + padding, rc.top + padding, _("(Add Alternate Start)")); } else { RasterPoint pt(rc.left + padding, rc.top + padding); const OrderedTaskPoint *tp; if (DrawListIndex == 0 && RealStartExists) { tp = &task.GetPoint(0); canvas.DrawText(pt.x, pt.y, _T("*")); pt.x += canvas.CalcTextWidth(_T("*")); } else tp = &task.GetOptionalStartPoint(index_optional_starts); assert(tp != nullptr); canvas.DrawText(pt.x, pt.y, tp->GetWaypoint().name.c_str()); } }
void WifiListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned idx) { const DialogLook &look = UIGlobals::GetDialogLook(); const auto &info = networks[idx]; const unsigned padding = Layout::GetTextPadding(); const unsigned x1 = rc.left + padding; const unsigned y1 = rc.top + padding; const unsigned y2 = y1 + look.text_font->GetHeight() + padding; static char wifi_security[][20] = { "WPA", "WEP", "Open", }; canvas.Select(*look.text_font); canvas.DrawText(x1, y1, info.ssid); canvas.Select(*look.small_font); canvas.DrawText(x1, y2, info.bssid); const TCHAR *state = nullptr; StaticString<40> state_buffer; /* found the currently connected wifi network? */ if (StringIsEqual(info.bssid, status.bssid)) { state = _("Connected"); /* look up ip address for eth0 */ const auto addr = IPv4Address::GetDeviceAddress("eth0"); if (addr.IsDefined()) { /* valid address? */ StaticString<40> addr_str; if (addr.ToString(addr_str.buffer(), addr_str.MAX_SIZE) != nullptr) { state_buffer.Format(_T("%s (%s)"), state, addr_str.c_str()); state = state_buffer; } } } else if (info.id >= 0) state = info.signal_level >= 0 ? _("Saved and visible") : _("Saved, but not visible"); else if (info.signal_level >= 0) state = _("Visible"); if (state != nullptr) { unsigned width = canvas.CalcTextWidth(state); canvas.DrawText(rc.right - padding - width, y1, state); } if (info.signal_level >= 0) { StaticString<20> text; text.UnsafeFormat(_T("%s %u"), wifi_security[info.security], info.signal_level); unsigned width = canvas.CalcTextWidth(text); canvas.DrawText(rc.right - padding - width, y2, text); } }
void AirspaceSettingsListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned i) { assert(i < AIRSPACECLASSCOUNT); const AirspaceComputerSettings &computer = CommonInterface::GetComputerSettings().airspace; const AirspaceRendererSettings &renderer = CommonInterface::GetMapSettings().airspace; const AirspaceLook &look = CommonInterface::main_window->GetLook().map.airspace; PixelScalar w0 = rc.right - rc.left - Layout::FastScale(4); PixelScalar w1 = canvas.CalcTextWidth(_("Warn")) + Layout::FastScale(10); PixelScalar w2 = canvas.CalcTextWidth(_("Display")) + Layout::FastScale(10); PixelScalar x0 = w0 - w1 - w2; const unsigned padding = Layout::GetTextPadding(); if (color_mode) { if (AirspacePreviewRenderer::PrepareFill( canvas, (AirspaceClass)i, look, renderer)) { canvas.Rectangle(rc.left + x0, rc.top + padding, rc.right - padding, rc.bottom - padding); AirspacePreviewRenderer::UnprepareFill(canvas); } if (AirspacePreviewRenderer::PrepareOutline( canvas, (AirspaceClass)i, look, renderer)) { canvas.Rectangle(rc.left + x0, rc.top + padding, rc.right - padding, rc.bottom - padding); } } else { if (computer.warnings.class_warnings[i]) canvas.DrawText(rc.left + w0 - w1 - w2, rc.top + padding, _("Warn")); if (renderer.classes[i].display) canvas.DrawText(rc.left + w0 - w2, rc.top + padding, _("Display")); } canvas.DrawClippedText(rc.left + padding, rc.top + padding, x0 - Layout::FastScale(10), AirspaceFormatter::GetClass((AirspaceClass)i)); }
result EnrichedTextForm::OnDraw(void) { result r = E_SUCCESS; Rectangle rect1(45, 250, 630, 313); Canvas* pCanvas = GetCanvasN(); if (pCanvas) { pCanvas->Clear(); pCanvas->SetLineWidth(3); pCanvas->FillRectangle(Color::GetColor(COLOR_ID_GREY), Rectangle(rect1)); } if (__pEnrichedText->GetTextLength() != 0) { __pEnrichedText->SetSize(rect1.width, rect1.height); pCanvas->DrawText(Point(rect1.x, rect1.y), *__pEnrichedText); } delete pCanvas; return r; }
void InfoBoxPreview::OnPaint(Canvas &canvas) { const bool is_current = i == parent->GetCurrentInfoBox(); if (is_current) canvas.Clear(COLOR_BLACK); else canvas.ClearWhite(); canvas.SelectHollowBrush(); canvas.SelectBlackPen(); canvas.Rectangle(0, 0, canvas.GetWidth() - 1, canvas.GetHeight() - 1); InfoBoxFactory::Type type = parent->GetContents(i); const TCHAR *caption = type < InfoBoxFactory::NUM_TYPES ? InfoBoxFactory::GetCaption(type) : NULL; if (caption == NULL) caption = _("Invalid"); else caption = gettext(caption); canvas.Select(parent->GetInfoBoxLook().title_font); canvas.SetBackgroundTransparent(); canvas.SetTextColor(is_current ? COLOR_WHITE : COLOR_BLACK); canvas.DrawText(2, 2, caption); }
void TerminalWindow::OnPaint(Canvas &canvas, const PixelRect &p_dirty) { canvas.SetBackgroundTransparent(); canvas.SetTextColor(look.text_color); canvas.Select(look.font); const PixelRect cell_dirty = { p_dirty.left / cell_size.cx, p_dirty.top / cell_size.cy, std::min(PixelScalar(p_dirty.right / cell_size.cx + 1), PixelScalar(data.GetWidth())), std::min(PixelScalar(p_dirty.bottom / cell_size.cy + 1), PixelScalar(data.GetHeight())), }; const PixelScalar x(cell_dirty.left * cell_size.cx); const size_t length = cell_dirty.right - cell_dirty.left; auto text = data.GetPointerAt(cell_dirty.left, cell_dirty.top); for (int cell_y = cell_dirty.top, p_y = cell_y * cell_size.cy; cell_y < cell_dirty.bottom; ++cell_y, p_y += cell_size.cy, text += data.GetWidth()) { canvas.DrawFilledRectangle(p_dirty.left, p_y, p_dirty.right, p_y + cell_size.cy, look.background_color); canvas.DrawText(x, p_y, text, length); } PixelScalar cell_bottom_y(cell_dirty.bottom * cell_size.cy); if (cell_bottom_y < p_dirty.bottom) canvas.DrawFilledRectangle(p_dirty.left, cell_bottom_y, p_dirty.right, p_dirty.bottom, look.background_color); }
void WaypointListDialog::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned i) { if (waypoint_list.empty()) { assert(i == 0); const UPixelScalar line_height = rc.bottom - rc.top; const Font &name_font = *UIGlobals::GetDialogLook().list.font; canvas.SetTextColor(COLOR_BLACK); canvas.Select(name_font); canvas.DrawText(rc.left + line_height + Layout::FastScale(2), rc.top + line_height / 2 - name_font.GetHeight() / 2, dialog_state.IsDefined() || way_points.IsEmpty() ? _("No Match!") : _("Choose a filter or click here")); return; } assert(i < waypoint_list.size()); const struct WaypointListItem &info = waypoint_list[i]; WaypointListRenderer::Draw(canvas, rc, *info.waypoint, info.GetVector(location), UIGlobals::GetDialogLook(), UIGlobals::GetMapLook().waypoint, CommonInterface::GetMapSettings().waypoint); }
void PageListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned idx) { const InfoBoxSettings &info_box_settings = CommonInterface::GetUISettings().info_boxes; assert(idx < PageSettings::MAX_PAGES); const auto &value = settings.pages[idx]; StaticString<64> buffer; switch (value.main) { case PageLayout::Main::MAP: buffer = _("Map"); break; case PageLayout::Main::FLARM_RADAR: buffer = _("FLARM radar"); break; case PageLayout::Main::THERMAL_ASSISTANT: buffer = _("Thermal assistant"); break; case PageLayout::Main::HORIZON: buffer = _("Horizon"); break; case PageLayout::Main::MAX: gcc_unreachable(); } if (value.infobox_config.enabled) { buffer.AppendFormat(_T(", %s"), _("InfoBoxes")); if (!value.infobox_config.auto_switch && value.infobox_config.panel < InfoBoxSettings::MAX_PANELS) buffer.AppendFormat(_T(" (%s)"), gettext(info_box_settings.panels[value.infobox_config.panel].name)); else buffer.AppendFormat(_T(" (%s)"), _("Auto")); } switch (value.bottom) { case PageLayout::Bottom::NOTHING: case PageLayout::Bottom::CUSTOM: break; case PageLayout::Bottom::CROSS_SECTION: buffer.AppendFormat(_T(", %s"), _("Cross section")); break; case PageLayout::Bottom::MAX: gcc_unreachable(); } canvas.DrawText(rc.left + Layout::GetTextPadding(), rc.top + Layout::GetTextPadding(), buffer); }
void InfoBoxPreview::OnPaint(Canvas &canvas) { const unsigned i = this - previews; const bool is_current = i == current_preview; if (is_current) canvas.Clear(COLOR_BLACK); else canvas.ClearWhite(); canvas.SelectHollowBrush(); canvas.SelectBlackPen(); canvas.Rectangle(0, 0, canvas.GetWidth() - 1, canvas.GetHeight() - 1); InfoBoxFactory::Type type = data.contents[i]; const TCHAR *caption = type < InfoBoxFactory::NUM_TYPES ? InfoBoxFactory::GetCaption(type) : NULL; if (caption == NULL) caption = _("Invalid"); else caption = gettext(caption); canvas.Select(*look->title.font); canvas.SetBackgroundTransparent(); canvas.SetTextColor(is_current ? COLOR_WHITE : COLOR_BLACK); canvas.DrawText(2, 2, caption); }
static void PaintItemCallback(Canvas &canvas, const PixelRect rc, unsigned idx) { TCHAR text[32]; _stprintf(text, _T("%u"), idx); canvas.DrawText(rc.left + 2, rc.top + 2, text); }
void FlarmTrafficControl::PaintID(Canvas &canvas, PixelRect rc, const FlarmTraffic &traffic) const { TCHAR buffer[20]; unsigned font_size; if (traffic.HasName()) { canvas.Select(look.call_sign_font); font_size = look.call_sign_font.GetHeight(); _tcscpy(buffer, traffic.name); } else { canvas.Select(look.info_labels_font); font_size = look.info_labels_font.GetHeight(); traffic.id.Format(buffer); } if (!WarningMode()) { // Team color dot FlarmFriends::Color team_color = FlarmFriends::GetFriendColor(traffic.id); // If no color found but target is teammate if (team_color == FlarmFriends::Color::NONE && settings.team_flarm_tracking && traffic.id == settings.team_flarm_id) // .. use green color team_color = FlarmFriends::Color::GREEN; // If team color found -> draw a colored circle in front of the name if (team_color != FlarmFriends::Color::NONE) { switch (team_color) { case FlarmFriends::Color::GREEN: canvas.Select(look.team_brush_green); break; case FlarmFriends::Color::BLUE: canvas.Select(look.team_brush_blue); break; case FlarmFriends::Color::YELLOW: canvas.Select(look.team_brush_yellow); break; case FlarmFriends::Color::MAGENTA: canvas.Select(look.team_brush_magenta); break; default: break; } canvas.SelectNullPen(); canvas.DrawCircle(rc.left + Layout::FastScale(7), rc.top + (font_size / 2), Layout::FastScale(7)); rc.left += Layout::FastScale(16); } } canvas.DrawText(rc.left, rc.top, buffer); }
void FlarmTrafficControl::PaintRelativeAltitude(Canvas &canvas, PixelRect rc, fixed relative_altitude) const { // Format relative altitude TCHAR buffer[20]; Unit unit = Units::GetUserAltitudeUnit(); FormatRelativeUserAltitude(relative_altitude, buffer, false); // Calculate unit size canvas.Select(look.info_units_font); const unsigned unit_width = UnitSymbolRenderer::GetSize(canvas, unit).cx; const unsigned unit_height = UnitSymbolRenderer::GetAscentHeight(look.info_units_font, unit); const unsigned space_width = unit_width / 3; // Calculate value size canvas.Select(look.info_values_font); const unsigned value_height = look.info_values_font.GetAscentHeight(); const unsigned value_width = canvas.CalcTextSize(buffer).cx; // Calculate positions const unsigned max_height = std::max(unit_height, value_height); // Paint value canvas.DrawText(rc.right - unit_width - space_width - value_width, rc.bottom - value_height, buffer); // Paint unit canvas.Select(look.info_units_font); UnitSymbolRenderer::Draw(canvas, RasterPoint(rc.right - unit_width, rc.bottom - unit_height), unit, look.unit_fraction_pen); // Paint label canvas.Select(look.info_labels_font); const unsigned label_width = canvas.CalcTextSize(_("Rel. Alt.")).cx; canvas.DrawText(rc.right - label_width, rc.bottom - max_height - look.info_labels_font.GetHeight(), _("Rel. Alt.")); }
void ManagedFileListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned i) { const FileItem &file = items[i]; const unsigned margin = Layout::GetTextPadding(); canvas.Select(row_renderer.GetFirstFont()); row_renderer.DrawFirstRow(canvas, rc, file.name.c_str()); canvas.Select(row_renderer.GetSecondFont()); if (file.downloading) { StaticString<64> text; if (file.download_status.position < 0) { text = _("Queued"); } else if (file.download_status.size > 0) { text.Format(_T("%s (%u%%)"), _("Downloading"), unsigned(file.download_status.position * 100 / file.download_status.size)); } else { TCHAR size[32]; FormatByteSize(size, ARRAY_SIZE(size), file.download_status.position); text.Format(_T("%s (%s)"), _("Downloading"), size); } const unsigned width = canvas.CalcTextWidth(text); canvas.DrawText(rc.right - width - margin, rc.top + row_renderer.GetFirstY(), text); } else if (file.failed) { const TCHAR *text = _("Error"); const unsigned width = canvas.CalcTextWidth(text); canvas.DrawText(rc.right - width - margin, rc.top + row_renderer.GetFirstY(), text); } row_renderer.DrawSecondRow(canvas, rc, file.size.c_str()); canvas.DrawText((rc.left + rc.right) / 2, rc.top + row_renderer.GetSecondY(), file.last_modified.c_str()); }
void MapWindow::DrawTaskOffTrackIndicator(Canvas &canvas) { if (Calculated().circling || !Basic().location_available || !Basic().track_available || !GetMapSettings().detour_cost_markers_enabled) return; const TaskStats &task_stats = Calculated().task_stats; const ElementStat ¤t_leg = task_stats.current_leg; if (!task_stats.task_valid || !current_leg.location_remaining.IsValid()) return; const GeoPoint target = current_leg.location_remaining; GeoVector vec(Basic().location, target); if ((Basic().track - vec.bearing).AsDelta().AbsoluteDegrees() < fixed(10)) // insignificant error return; fixed distance_max = std::min(vec.distance, render_projection.GetScreenDistanceMeters() * fixed(0.7)); // too short to bother if (distance_max < fixed(5000)) return; GeoPoint start = Basic().location; canvas.Select(*look.overlay_font); canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); GeoPoint dloc; int ilast = 0; for (fixed d = fixed(1) / 4; d <= fixed(1); d += fixed(1) / 4) { dloc = FindLatitudeLongitude(start, Basic().track, distance_max * d); fixed distance0 = start.Distance(dloc); fixed distance1 = target.Distance(dloc); fixed distance = fixed(distance0 + distance1) / vec.distance; int idist = iround((distance - fixed(1)) * 100); if ((idist != ilast) && (idist > 0) && (idist < 1000)) { TCHAR Buffer[5]; _stprintf(Buffer, _T("%d"), idist); RasterPoint sc = render_projection.GeoToScreen(dloc); PixelSize tsize = canvas.CalcTextSize(Buffer); canvas.DrawText(sc.x - tsize.cx / 2, sc.y - tsize.cy / 2, Buffer); ilast = idist; } } }
static void Draw(Canvas &canvas) { PixelRect rc = canvas.GetRect(); rc.Grow(-0.2 * rc.GetSize().cx); /* draw the banner text with a large font */ Font small_font; small_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed.ttf", (rc.GetSize().cy / 25)); canvas.Select(small_font); canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); const TCHAR *const text = _T("Powered Off"); const PixelSize text_size = canvas.CalcTextSize(text); const RasterPoint text_pos = { rc.left + 16, rc.bottom - 16 - text_size.cy }; canvas.DrawText(text_pos.x, text_pos.y, text); Font big_font; big_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed-Bold.ttf", (rc.GetSize().cy / 10)); canvas.Select(big_font); const TCHAR *const text2 = _T("LK8000"); const PixelSize text2_size = canvas.CalcTextSize(text2); const RasterPoint text2_pos = { (rc.left + rc.GetSize().cx + text2_size.cx) / 2, (rc.top + (rc.GetSize().cy / 10)) }; canvas.DrawText(text2_pos.x, text2_pos.y, text2); const double Scale = (double)rc.GetSize().cx / (double)bird_size.cx; RasterPoint polygon[array_size(bird_polygon)] = {}; std::transform(std::begin(bird_polygon), std::end(bird_polygon), std::begin(polygon), [Scale, rc, text2_size, text2_pos]( const RasterPoint& pt ) { return RasterPoint(pt.x*Scale + rc.left, pt.y*Scale + text2_pos.y + text2_size.cy); }); canvas.SelectBlackBrush(); canvas.DrawPolygon(polygon, array_size(polygon)); }
void FlarmTrafficControl::PaintClimbRate(Canvas &canvas, PixelRect rc, fixed climb_rate) const { // Paint label canvas.Select(look.info_labels_font); const unsigned label_width = canvas.CalcTextSize(_("Vario")).cx; canvas.DrawText(rc.right - label_width, rc.top, _("Vario")); // Format climb rate TCHAR buffer[20]; Unit unit = Units::GetUserVerticalSpeedUnit(); FormatUserVerticalSpeed(climb_rate, buffer, false); // Calculate unit size canvas.Select(look.info_units_font); const unsigned unit_width = UnitSymbolRenderer::GetSize(canvas, unit).cx; const unsigned unit_height = UnitSymbolRenderer::GetAscentHeight(look.info_units_font, unit); UPixelScalar space_width = unit_width / 3; // Calculate value size canvas.Select(look.info_values_font); const unsigned value_height = look.info_values_font.GetAscentHeight(); const unsigned value_width = canvas.CalcTextSize(buffer).cx; // Calculate positions const int max_height = std::max(unit_height, value_height); const int y = rc.top + look.info_units_font.GetHeight() + max_height; // Paint value canvas.DrawText(rc.right - unit_width - space_width - value_width, y - value_height, buffer); // Paint unit canvas.Select(look.info_units_font); UnitSymbolRenderer::Draw(canvas, RasterPoint(rc.right - unit_width, y - unit_height), unit, look.unit_fraction_pen); }
void WaypointExternalFileListHandler::OnPaintItem(Canvas &canvas, const PixelRect paint_rc, unsigned i) { auto file = waypoint.files_external.begin(); std::advance(file, i); canvas.DrawText(paint_rc.left + Layout::GetTextPadding(), paint_rc.top + Layout::GetTextPadding(), file->c_str()); }
void TaskListPanel::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned DrawListIndex) { assert(DrawListIndex <= task_store->Size()); const TCHAR *name = task_store->GetName(DrawListIndex); canvas.DrawText(rc.left + Layout::FastScale(2), rc.top + Layout::FastScale(2), name); }
void TaskListPanel::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned DrawListIndex) { assert(DrawListIndex <= task_store->Size()); const unsigned padding = Layout::GetTextPadding(); const TCHAR *name = task_store->GetName(DrawListIndex); canvas.DrawText(rc.left + padding, rc.top + padding, name); }
void FlarmTrafficControl::PaintDistance(Canvas &canvas, PixelRect rc, fixed distance) const { // Format distance TCHAR buffer[20]; Unit unit = FormatUserDistanceSmart(distance, buffer, false, fixed(1000)); // Calculate unit size canvas.Select(look.info_units_font); const unsigned unit_width = UnitSymbolRenderer::GetSize(canvas, unit).cx; const unsigned unit_height = UnitSymbolRenderer::GetAscentHeight(look.info_units_font, unit); const unsigned space_width = unit_width / 3; // Calculate value size canvas.Select(look.info_values_font); const unsigned value_height = look.info_values_font.GetAscentHeight(); const unsigned value_width = canvas.CalcTextSize(buffer).cx; // Calculate positions const unsigned max_height = std::max(unit_height, value_height); // Paint value canvas.DrawText(rc.left, rc.bottom - value_height, buffer); // Paint unit canvas.Select(look.info_units_font); UnitSymbolRenderer::Draw(canvas, RasterPoint(rc.left + value_width + space_width, rc.bottom - unit_height), unit, look.unit_fraction_pen); // Paint label canvas.Select(look.info_labels_font); canvas.DrawText(rc.left, rc.bottom - max_height - look.info_labels_font.GetHeight(), _("Distance")); }
result Form2::OnDraw() { Canvas *pCanvas = GetCanvasN(); Font *pFont = new Font; result r = pFont->Construct("/Res/LiberationMono-Regular.ttf", FONT_STYLE_PLAIN, font); pCanvas->SetFont(*pFont); for (int i = 0; i < 3; i++) pCanvas->DrawText(Point(10,600+i*font),legal[i]); delete pCanvas; delete pFont; r = E_SUCCESS; return r; }
/** * Paints a "No Traffic" sign on the given canvas * @param canvas The canvas to paint on */ void FlarmTrafficWindow::PaintRadarNoTraffic(Canvas &canvas) const { if (small) return; const TCHAR* str = _("No Traffic"); canvas.Select(look.no_traffic_font); PixelSize ts = canvas.CalcTextSize(str); canvas.SetTextColor(look.default_color); canvas.DrawText(radar_mid.x - (ts.cx / 2), radar_mid.y - (radius / 2), str); }
void CheckBoxControl::OnPaint(Canvas &canvas) { const auto &cb_look = look->check_box; const bool focused = HasCursorKeys() && HasFocus(); if (focused) canvas.Clear(cb_look.focus_background_brush); else if (HaveClipping()) canvas.Clear(look->background_brush); const auto &state_look = IsEnabled() ? (pressed ? cb_look.pressed : (focused ? cb_look.focused : cb_look.standard)) : cb_look.disabled; unsigned size = canvas.GetHeight() - 4; canvas.Select(state_look.box_brush); canvas.Select(state_look.box_pen); canvas.Rectangle(2, 2, size, size); if (checked) { canvas.Select(state_look.check_brush); canvas.SelectNullPen(); BulkPixelPoint check_mark[] = { {-8, -2}, {-3, 6}, {7, -9}, {8, -5}, {-3, 9}, {-9, 2}, }; unsigned top = canvas.GetHeight() / 2; for (unsigned i = 0; i < ARRAY_SIZE(check_mark); ++i) { check_mark[i].x = (check_mark[i].x * (int)size) / 24 + top; check_mark[i].y = (check_mark[i].y * (int)size) / 24 + top; } canvas.DrawPolygon(check_mark, ARRAY_SIZE(check_mark)); } canvas.Select(*cb_look.font); canvas.SetTextColor(state_look.text_color); canvas.SetBackgroundTransparent(); canvas.DrawText(canvas.GetHeight() + 2, 2, caption.c_str()); }
void TextWindow::OnPaint(Canvas &canvas) { #ifndef ENABLE_OPENGL canvas.ClearWhite(); #endif if (!text.empty()) { canvas.SetTextColor(COLOR_BLACK); canvas.SetBackgroundTransparent(); canvas.DrawText(1, 1, text.c_str()); } }
static void OnPaintAddItem(Canvas &canvas, const PixelRect rc, unsigned i) { assert(add_list != NULL); assert(i < add_list->size()); const AvailableFile &file = (*add_list)[i]; ACPToWideConverter name(file.GetName()); if (name.IsValid()) canvas.DrawText(rc.left + Layout::GetTextPadding(), rc.top + Layout::GetTextPadding(), name); }
/** * Paints the radar circle on the given canvas * @param canvas The canvas to paint on */ void FlarmTrafficWindow::PaintRadarBackground(Canvas &canvas) const { canvas.SelectHollowBrush(); canvas.Select(look.radar_pen); canvas.SetTextColor(look.radar_color); // Paint circles canvas.DrawCircle(radar_mid.x, radar_mid.y, radius); canvas.DrawCircle(radar_mid.x, radar_mid.y, radius / 2); PaintRadarPlane(canvas); if (small) return; // Paint zoom strings canvas.Select(look.label_font); canvas.SetBackgroundOpaque(); canvas.SetBackgroundColor(look.background_color); TCHAR distance_string[10]; FormatUserDistanceSmart(distance, distance_string, ARRAY_SIZE(distance_string), fixed(1000)); PixelSize s = canvas.CalcTextSize(distance_string); canvas.DrawText(radar_mid.x - s.cx / 2, radar_mid.y + radius - s.cy * 0.75, distance_string); FormatUserDistanceSmart(distance / 2, distance_string, ARRAY_SIZE(distance_string), fixed(1000)); s = canvas.CalcTextSize(distance_string); canvas.DrawText(radar_mid.x - s.cx / 2, radar_mid.y + radius / 2 - s.cy * 0.75, distance_string); canvas.SetBackgroundTransparent(); PaintNorth(canvas); }
void ManagedFileListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc, unsigned i) { const FileItem &file = items[i]; const UPixelScalar margin = Layout::GetTextPadding(); canvas.DrawText(rc.left + margin, rc.top + margin, file.name.c_str()); if (file.downloading) { StaticString<64> text; if (file.download_status.position < 0) { text = _("Queued"); } else if (file.download_status.size > 0) { text.Format(_T("%s (%u%%)"), _("Downloading"), unsigned(file.download_status.position * 100 / file.download_status.size)); } else { TCHAR size[32]; FormatByteSize(size, ARRAY_SIZE(size), file.download_status.position); text.Format(_T("%s (%s)"), _("Downloading"), size); } UPixelScalar width = canvas.CalcTextWidth(text); canvas.DrawText(rc.right - width - margin, rc.top + margin, text); } else if (file.failed) { const TCHAR *text = _("Error"); UPixelScalar width = canvas.CalcTextWidth(text); canvas.DrawText(rc.right - width - margin, rc.top + margin, text); } canvas.DrawText(rc.left + margin, rc.top + 2 * margin + font_height, file.size.c_str()); canvas.DrawText((rc.left + rc.right) / 2, rc.top + 2 * margin + font_height, file.last_modified.c_str()); }