54 mUnits = ((orientation == wxHORIZONTAL) ? 22 : 16) * fabs(UPP);
79 format->SetLabelString(s, d, mUnits, mMinor, mDigits, tickType);
87 wxDC& dc,
bool twoTone, wxColour c,
88 std::unique_ptr<RulerStruct::Fonts>& fonts)
const
90 if (text.has_value() && !text->empty()) {
91 bool altColor = twoTone && value < 0.0;
93 dc.SetTextForeground(altColor ?
theTheme.
Colour(clrTextNegativeNumbers) : c);
94 dc.SetBackgroundMode(wxTRANSPARENT);
95 if (dc.GetFont() == fonts->major) {
97 dc.DrawText(text->Translation(), lx, ly);
98 wxSize textSize = dc.GetTextExtent(text->Translation());
99 dc.SetFont(fonts->minor);
100 int unitX = lx + textSize.GetWidth();
101 dc.DrawText(units.Translation(), unitX, ly);
102 dc.SetFont(fonts->major);
105 auto str = *text + units;
106 dc.DrawText(
str.Translation(), lx, ly);
113 wxDC& dc, wxFont font,
114 std::vector<bool>& bits,
115 int left,
int top,
int spacing,
int lead,
116 bool flip,
int orientation)
117 -> std::pair< wxRect, Label >
119 lab.lx = left - 1000;
122 auto length = bits.size() - 1;
127 wxCoord strW, strH, strD, strL;
128 auto strText = lab.text;
129 auto strUnits = lab.units;
134 dc.GetTextExtent(
str.Translation(), &strW, &strH, &strD, &strL);
136 int strPos, strLen, strLeft, strTop;
137 if (orientation == wxHORIZONTAL) {
139 strPos = pos - strW / 2;
142 if (strPos + strW >= length)
143 strPos = length - strW;
144 strLeft = left + strPos;
148 strTop = -strH - lead;
153 strPos = pos - strH / 2;
156 if (strPos + strH >= length)
157 strPos = length - strH;
158 strTop = top + strPos;
175 for (i = 0; i < strLen; i++)
176 if (bits[strPos + i])
192 int rightMargin = spacing;
193 if (strPos + strLen > length - spacing)
194 rightMargin = length - strPos - strLen;
195 strLen += rightMargin;
197 for (i = 0; i < strLen; i++)
198 bits[strPos + i] =
true;
202 lab.units = strUnits;
203 return { { strLeft, strTop, strW, strH }, lab };
215 const int mLeft = context.
mLeft;
216 const int mTop = context.
mTop;
217 const int mBottom = context.
mBottom;
218 const int mRight = context.
mRight;
220 const bool mFlip = context.
mFlip;
222 int displacementx = 0, displacementy = 0;
223 auto& box = allOutputs.
box;
225 if (mOrientation == wxHORIZONTAL) {
226 int d = mTop + box.GetHeight() + 5;
233 int d = mLeft - box.GetLeft() + 5;
241 if (mOrientation == wxHORIZONTAL) {
248 label.lx += displacementx;
249 label.ly += displacementy;
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
void BoxAdjust(UpdateOutputs &allOutputs, const RulerStruct &context) const
virtual ~RulerUpdater()=0
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)
wxColour & Colour(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
An array of these created by the Updater is used to determine what and where text annotations to the ...
void Draw(wxDC &dc, bool twoTone, wxColour c, std::unique_ptr< RulerStruct::Fonts > &fonts) const
TranslatableString LabelString(double d, const RulerFormat *format) const
TickSizes(double UPP, int orientation, const RulerFormat *format, bool log)
Labels & minorMinorLabels