本文整理汇总了C++中wxGraphicsContext::GetTextExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ wxGraphicsContext::GetTextExtent方法的具体用法?C++ wxGraphicsContext::GetTextExtent怎么用?C++ wxGraphicsContext::GetTextExtent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxGraphicsContext
的用法示例。
在下文中一共展示了wxGraphicsContext::GetTextExtent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecalculateMargins
void GCDCGraphs::RecalculateMargins(wxGraphicsContext &dc) {
if (!m_recalulate_margins)
return;
double leftmargin = 36;
double bottommargin = 12;
double topmargin = 24;
for (size_t i = 0; i < m_draws.size(); i++) {
double tw, th, td, tel;
DrawInfo *di = m_draws[i]->GetDrawInfo();
wxString sval = di->GetValueStr(di->GetMax(), _T(""));
dc.GetTextExtent(sval, &tw, &th, &td, &tel);
if (leftmargin < tw + 1)
leftmargin = tw + 1;
if (bottommargin < th + 1)
bottommargin = th + 1;
if (topmargin < th + m_screen_margins.infotopmargin)
topmargin = th + m_screen_margins.infotopmargin;
dc.GetTextExtent(di->GetUnit(), &tw, &th, &td, &tel);
if (leftmargin < tw + 6)
leftmargin = tw + 6;
}
m_screen_margins.leftmargin = leftmargin;
m_screen_margins.bottommargin = bottommargin;
m_screen_margins.topmargin = topmargin;
m_recalulate_margins = false;
}
示例2: DrawParamName
void GCDCGraphs::DrawParamName(wxGraphicsContext &dc) {
DrawInfo *di = m_draws_wdg->GetCurrentDrawInfo();
if (di == NULL)
return;
dc.SetBrush(*wxBLACK_BRUSH);
dc.SetPen(*wxWHITE_PEN);
wxFont f = GetFont();
int ps = f.GetPointSize();
int fw = f.GetWeight();
f.SetWeight(wxFONTWEIGHT_BOLD);
f.SetPointSize(ps * 1.25);
dc.SetFont(f, di->GetDrawColor());
int w, h;
GetSize(&w, &h);
wxString text = m_cfg_mgr->GetConfigTitles()[di->GetBasePrefix()] + _T(":") + di->GetParamName();
double tw, th, _th, _ts;
dc.GetTextExtent(text, &tw, &th, &_th, &_ts);
dc.DrawRectangle(w / 2 - tw / 2 - 1, h / 2 - th / 2 - 1, tw + 2, th + 2);
dc.DrawText(text, w / 2 - tw / 2, h / 2 - th / 2);
f.SetPointSize(ps);
f.SetWeight(fw);
}
示例3: DrawXAxisVals
void GCDCGraphs::DrawXAxisVals(wxGraphicsContext& dc) {
Draw* draw = m_draws_wdg->GetSelectedDraw();
if (draw == NULL)
return;
/* Draw ticks on axis. */
int i = PeriodMarkShift[draw->GetPeriod()];
int size = draw->GetValuesTable().size();
int w, h;
GetClientSize(&w, &h);
wxDateTime prev_date;
while (i < size) {
int x = GetX(i);
dc.StrokeLine(x, h - m_screen_margins.bottommargin + 1, x, h - m_screen_margins.bottommargin - 1);
wxDateTime date = draw->GetTimeOfIndex(i);
/* Print date */
wxString datestring = get_date_string(draw->GetPeriod(), prev_date, date);
double textw, texth, td, tel;
dc.GetTextExtent(datestring, &textw, &texth, &td, &tel);
dc.DrawText(datestring, x - textw / 2, h - m_screen_margins.bottommargin + 1);
i += TimeIndex::PeriodMult[draw->GetPeriod()];
prev_date = date;
}
}
示例4: DrawUnit
void GCDCGraphs::DrawUnit(wxGraphicsContext &dc) {
Draw* draw = m_draws_wdg->GetSelectedDraw();
if (draw == NULL)
return;
double textw, texth, th, tsel;
wxString unit = draw->GetDrawInfo()->GetUnit();
dc.GetTextExtent(unit, &textw, &texth, &th, &tsel);
dc.DrawText(unit, m_screen_margins.leftmargin - 6 - textw, m_screen_margins.topmargin - 2 - texth);
}
示例5: DrawWindowInfo
void GCDCGraphs::DrawWindowInfo(wxGraphicsContext &dc) {
double info_left_marg = m_screen_margins.leftmargin + 8;
double param_name_shift = 5;
if (m_draws.size() < 1)
return;
int w, h;
GetClientSize(&w, &h);
DrawInfo *info = m_draws[0]->GetDrawInfo();
wxString name = info->GetSetName().c_str();
double namew, nameh, th, tsel;
dc.GetTextExtent(name, &namew, &nameh, &th, &tsel);
dc.DrawText(name, info_left_marg, m_screen_margins.infotopmargin);
int xpos = info_left_marg + namew + param_name_shift;
for (int i = 0; i < (int)m_draws.size(); ++i) {
if (!m_draws[i]->GetEnable())
continue;
DrawInfo *info = m_draws[i]->GetDrawInfo();
dc.SetFont(GetFont(), info->GetDrawColor());
name = info->GetShortName().c_str();
if (!name.IsEmpty()) {
dc.GetTextExtent(name, &namew, &nameh, &th, &tsel);
dc.DrawText(name, xpos, m_screen_margins.infotopmargin);
xpos += namew + param_name_shift;
} else {
xpos += param_name_shift;
}
}
}
示例6: DrawNoData
void GCDCGraphs::DrawNoData(wxGraphicsContext &dc) {
wxFont font = GetFont();
font.SetPointSize(font.GetPointSize() + 8);
dc.SetFont(font, *wxWHITE);
int w, h;
GetClientSize(&w, &h);
w -= m_screen_margins.leftmargin - m_screen_margins.rightmargin;
h -= m_screen_margins.topmargin - m_screen_margins.bottommargin;
wxString sval = _("No data");
double textw, texth, textd, textel;
dc.GetTextExtent(sval, &textw, &texth, &textd, &textel);
dc.DrawText(sval, m_screen_margins.leftmargin + w / 2 - textw / 2 - 1, m_screen_margins.topmargin + h / 2 - texth / 2);
}
示例7: DrawSeasonLimitInfo
void GCDCGraphs::DrawSeasonLimitInfo(wxGraphicsContext &dc, int i, int month, int day, bool summer) {
const double stripe_width = 2;
double x1 = GetX(i);
double x2 = GetX(i + 1);
double x = (x1 + x2) / 2;
int w, h;
GetClientSize(&w, &h);
wxColour color = summer ? *wxBLUE : *wxRED;
dc.SetFont(GetFont(), color);
dc.SetPen(wxPen(color, 1, wxSOLID));
wxBrush brush(color);
dc.SetBrush(brush);
dc.DrawRectangle(x + 1, m_screen_margins.topmargin, stripe_width, w - m_screen_margins.topmargin - m_screen_margins.bottommargin);
wxString str;
if (summer)
str = wxString(_("summer season"));
else
str = wxString(_("winter season"));
str += wxString::Format(_T(" %d "), day);
switch (month) {
case 1:
str += _("january");
break;
case 2:
str += _("february");
break;
case 3:
str += _("march");
break;
case 4:
str += _("april");
break;
case 5:
str += _("may");
break;
case 6:
str += _("june");
break;
case 7:
str += _("july");
break;
case 8:
str += _("august");
break;
case 9:
str += _("septermber");
break;
case 10:
str += _("october");
break;
case 11:
str += _("november");
break;
case 12:
str += _("december");
break;
default:
assert(false);
}
double tw, th, td, tsel;
dc.GetTextExtent(_T("W"), &tw, &th, &td, &tsel);
int ty = m_screen_margins.topmargin + 1;
for (size_t i = 0; i < str.Len(); ++i) {
double lw, lh, ld, lsel;
wxString letter = str.Mid(i, 1);
dc.GetTextExtent(letter, &lw, &lh, &ld, &lsel);
dc.DrawText(letter, x + stripe_width + 2 + (tw - lw) / 2, ty);
ty += th + 2;
}
}
示例8: DrawYAxisVals
void GCDCGraphs::DrawYAxisVals(wxGraphicsContext& dc) {
Draw* draw = m_draws_wdg->GetSelectedDraw();
if (draw == NULL)
return;
DrawInfo *di = draw->GetDrawInfo();
if (!di->IsValid())
return;
double min = di->GetMin();
double max = di->GetMax();
if( max <= min ) {
// FIXME: Draw3 should atomaticly detect axes in that case, but
// it currently doesnt :(
wxLogWarning(_T("Parameter %s has invalid min/max values: min %f, max %f. Min is set to 0, and max to 100."), di->GetName().c_str(), min, max);
min = 0;
max = 100;
}
//procedure for calculating distance between marks stolen from SzarpDraw2
double x = max - min;
double step;
int i = 0;
if (x < 1)
for (;x < 1; x *=10, --i);
else
for (;(int)x / 10; x /=10, ++i);
if (x <= 1.5)
step = .1;
else if (x <= 3.)
step = .2;
else if (x <= 7.5)
step = .5;
else
step = 1.;
double acc = 1;
int prec = di->GetPrec();
for (int p = prec; p > 0; --p)
acc /= 10;
double factor = (i > 0) ? 10 : .1;
for (;i; i -= i / abs(i))
step *= factor;
if (step < acc)
step = acc;
dc.SetPen(wxPen(*wxWHITE, 1, wxSOLID));
int w, h;
GetClientSize(&w, &h);
h -= m_screen_margins.bottommargin + m_screen_margins.topmargin;
for (double val = max; (min - val) < acc; val -= step) {
int y = GetY(val, di);
dc.StrokeLine(m_screen_margins.leftmargin - 8, y, m_screen_margins.leftmargin, y);
wxString sval = di->GetValueStr(val, _T("- -"));
double textw, texth, textd, textel;
dc.GetTextExtent(sval, &textw, &texth, &textd, &textel);
dc.DrawText(sval, m_screen_margins.leftmargin - textw - 1, y + 2);
}
}