25{
26 const double mMin = context.
mMin;
27 const double mMax = context.
mMax;
28
29 const int mLeft = context.
mLeft;
30 const int mTop = context.
mTop;
31 const int mRight = context.
mRight;
32 const int mBottom = context.
mBottom;
33 const int mLength = context.
mLength;
35
37 constexpr int spacing = 2;
38 const bool mFlip = context.
mFlip;
41
42 auto TickAtValue =
43 [this, &dc, &mFonts, mOrientation, mLabelEdges,
44 mMin, mMax, mLength, mRight, mBottom, &context]
45 (double value, double *pos) -> bool {
46
48 double max = std::max(mMin, mMax);
49 if ((value <=
min && !mLabelEdges) || value <
min)
50 return false;
51 if ((value >= max && !mLabelEdges) || value > max)
52 return false;
53
54 int mid = (int)(mLength * ((mMin - value) / (mMin - mMax)) + 0.5);
55
56 const int iMaxPos = (mOrientation == wxHORIZONTAL) ? mRight : mBottom - 5;
57 if (mid >= 0 && mid < iMaxPos) {
58 *pos = mid;
59 return true;
60 }
61 return false;
62 };
63
64
65
66 if (labelIdx >= outputs.labels.size())
67 return false;
68
69
70
71 double pos;
72 if (!TickAtValue(outputs.labels[labelIdx].value, &pos))
73 return false;
74
75 Label lab;
76 lab.value = 0.0;
77 lab.pos = pos;
78
79
80 lab.text = outputs.labels[labelIdx].text;
81 lab.units = mUnits;
82
84 lab,
85 dc, font,
86 outputs.bits,
87 mLeft, mTop, spacing, mFonts.
lead,
88 mFlip,
89 mOrientation);
90
91 if (!result.second.text)
92
94
95 auto& rect = result.first;
96 outputs.box.Union(rect);
97 outputs.labels[labelIdx] = (result.second);
98 return !rect.IsEmpty();
99}
static std::pair< wxRect, Label > MakeTick(RulerUpdater::Label lab, wxDC &dc, wxFont font, std::vector< bool > &bits, int left, int top, int spacing, int lead, bool flip, int orientation)
Holds a msgid for the translation catalog; may also bind format arguments.
std::unique_ptr< Fonts > mpFonts
TranslatableString mUnits