本文整理汇总了C++中Painter::draw_string方法的典型用法代码示例。如果您正苦于以下问题:C++ Painter::draw_string方法的具体用法?C++ Painter::draw_string怎么用?C++ Painter::draw_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Painter
的用法示例。
在下文中一共展示了Painter::draw_string方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void TemperatureWidget::paint(Painter& painter) {
const auto logger = portapack::temperature_logger;
const auto rect = screen_rect();
const Color color_background { 0, 0, 64 };
const Color color_foreground = Color::green();
const Color color_reticle { 128, 128, 128 };
const auto graph_width = static_cast<int>(logger.capacity()) * bar_width;
const Rect graph_rect {
rect.left() + (rect.width() - graph_width) / 2, rect.top() + 8,
graph_width, rect.height()
};
const Rect frame_rect {
graph_rect.left() - 1, graph_rect.top() - 1,
graph_rect.width() + 2, graph_rect.height() + 2
};
painter.draw_rectangle(frame_rect, color_reticle);
painter.fill_rectangle(graph_rect, color_background);
const auto history = logger.history();
for(size_t i=0; i<history.size(); i++) {
const Coord x = graph_rect.right() - (history.size() - i) * bar_width;
const auto sample = history[i];
const auto temp = temperature(sample);
const auto y = screen_y(temp, graph_rect);
const Dim bar_height = graph_rect.bottom() - y;
painter.fill_rectangle({ x, y, bar_width, bar_height }, color_foreground);
}
if( !history.empty() ) {
const auto sample = history.back();
const auto temp = temperature(sample);
const auto last_y = screen_y(temp, graph_rect);
const Coord x = graph_rect.right() + 8;
const Coord y = last_y - 8;
painter.draw_string({ x, y }, style(), temperature_str(temp));
}
const auto display_temp_max = display_temp_min + (graph_rect.height() / display_temp_scale);
for(auto temp=display_temp_min; temp<=display_temp_max; temp+=10) {
const int32_t tick_length = 6;
const auto tick_x = graph_rect.left() - tick_length;
const auto tick_y = screen_y(temp, graph_rect);
painter.fill_rectangle({ tick_x, tick_y, tick_length, 1 }, color_reticle);
const auto text_x = graph_rect.left() - temp_len * 8 - 8;
const auto text_y = tick_y - 8;
painter.draw_string({ text_x, text_y }, style(), temperature_str(temp));
}
}
示例2: draw_field
Rect AISRecentEntryDetailView::draw_field(
Painter& painter,
const Rect& draw_rect,
const Style& style,
const std::string& label,
const std::string& value
) {
const int label_length_max = 4;
painter.draw_string(Point { draw_rect.left(), draw_rect.top() }, style, label);
painter.draw_string(Point { draw_rect.left() + (label_length_max + 1) * 8, draw_rect.top() }, style, value);
return { draw_rect.left(), draw_rect.top() + draw_rect.height(), draw_rect.width(), draw_rect.height() };
}
示例3:
void RecentEntriesView<TPMSRecentEntries>::draw(
const Entry& entry,
const Rect& target_rect,
Painter& painter,
const Style& style,
const bool is_selected
) {
const auto& draw_style = is_selected ? style.invert() : style;
std::string line = tpms::format::type(entry.type) + " " + tpms::format::id(entry.id);
if( entry.last_pressure.is_valid() ) {
line += " " + tpms::format::pressure(entry.last_pressure.value());
} else {
line += " " " ";
}
if( entry.last_temperature.is_valid() ) {
line += " " + tpms::format::temperature(entry.last_temperature.value());
} else {
line += " " " ";
}
if( entry.received_count > 999 ) {
line += " +++";
} else {
line += " " + to_string_dec_uint(entry.received_count, 3);
}
line.resize(target_rect.width() / 8, ' ');
painter.draw_string(target_rect.pos, draw_style, line);
}
示例4: paint
void NumberField::paint(Painter& painter) {
const auto text = to_string_dec_int(value_, length_, fill_char);
const auto paint_style = has_focus() ? style().invert() : style();
painter.draw_string(
screen_pos(),
paint_style,
text
);
}
示例5: paint
void FrequencyField::paint(Painter& painter) {
const auto mhz = to_string_dec_int(value_ / 1000000, 4);
const auto hz100 = to_string_dec_int((value_ / 100) % 10000, 4, '0');
const auto paint_style = has_focus() ? style().invert() : style();
painter.draw_string(
screen_pos(),
paint_style,
mhz
);
painter.draw_string(
screen_pos() + Point { 4 * 8, 0 },
paint_style,
"."
);
painter.draw_string(
screen_pos() + Point { 5 * 8, 0 },
paint_style,
hz100
);
}
示例6:
void DebugRFFC5072RegistersWidget::draw_legend(Painter& painter) {
for(size_t i=0; i<registers_count; i+=registers_per_row) {
const Point offset {
0, static_cast<Coord>((i / registers_per_row) * row_height)
};
const auto text = to_string_hex(i, legend_length);
painter.draw_string(
screen_pos() + offset,
style(),
text
);
}
}
示例7: draw_legend
void RegistersWidget::draw_legend(const Coord left, Painter& painter) {
const auto pos = screen_pos();
for(int i=0; i<config.registers_count; i+=config.registers_per_row) {
const Point offset {
left, (i / config.registers_per_row) * row_height
};
const auto text = to_string_hex(i, config.legend_length);
painter.draw_string(
pos + offset,
style().invert(),
text
);
}
}
示例8:
void RecentEntriesView<ERTRecentEntries>::draw_header(
const Rect& target_rect,
Painter& painter,
const Style& style
) {
auto x = 0;
for(const auto& column : ert_columns) {
const auto width = column.second;
auto text = column.first;
if( width > text.length() ) {
text.append(width - text.length(), ' ');
}
painter.draw_string({ x, target_rect.pos.y }, style, text);
x += (width * 8) + 8;
}
}
示例9:
void RecentEntriesTable<ERTRecentEntries>::draw(
const Entry& entry,
const Rect& target_rect,
Painter& painter,
const Style& style
) {
std::string line = ert::format::id(entry.id) + " " + ert::format::commodity_type(entry.commodity_type) + " " + ert::format::consumption(entry.last_consumption);
if( entry.received_count > 999 ) {
line += " +++";
} else {
line += " " + to_string_dec_uint(entry.received_count, 3);
}
line.resize(target_rect.width() / 8, ' ');
painter.draw_string(target_rect.location(), style, line);
}
示例10: paint
void MenuItemView::paint(Painter& painter) {
const auto r = screen_rect();
const auto paint_style = (highlighted() && parent()->has_focus()) ? style().invert() : style();
const auto font_height = paint_style.font.line_height();
painter.fill_rectangle(
r,
paint_style.background
);
painter.draw_string(
{ r.left() + 8, r.top() + (r.height() - font_height) / 2 },
paint_style,
item.text
);
}
示例11:
void RecentEntriesView<AISRecentEntries>::draw(
const Entry& entry,
const Rect& target_rect,
Painter& painter,
const Style& style,
const bool is_selected
) {
const auto& draw_style = is_selected ? style.invert() : style;
std::string line = ais::format::mmsi(entry.mmsi) + " ";
if( !entry.name.empty() ) {
line += entry.name;
} else {
line += entry.call_sign;
}
line.resize(target_rect.width() / 8, ' ');
painter.draw_string(target_rect.pos, draw_style, line);
}
示例12: draw_values
void RegistersWidget::draw_values(
const Coord left,
Painter& painter
) {
const auto pos = screen_pos();
for(int i=0; i<config.registers_count; i++) {
const Point offset = {
left + config.legend_width() + 8 + (i % config.registers_per_row) * (config.value_width() + 8),
(i / config.registers_per_row) * row_height
};
const auto value = reader(i);
const auto text = to_string_hex(value, config.value_length);
painter.draw_string(
pos + offset,
style(),
text
);
}
}