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#ifdef EXPERIMENTAL_THEMING
94 dc.SetTextForeground(altColor ?
theTheme.
Colour(clrTextNegativeNumbers) : c);
96 dc.SetTextForeground(altColor ? *wxBLUE : *wxBLACK);
98 dc.SetBackgroundMode(wxTRANSPARENT);
99 if (dc.GetFont() == fonts->major) {
101 dc.DrawText(text->Translation(), lx, ly);
102 wxSize textSize = dc.GetTextExtent(text->Translation());
103 dc.SetFont(fonts->minor);
104 int unitX = lx + textSize.GetWidth();
105 dc.DrawText(units.Translation(), unitX, ly);
106 dc.SetFont(fonts->major);
109 auto str = *text + units;
110 dc.DrawText(
str.Translation(), lx, ly);
117 wxDC& dc, wxFont font,
118 std::vector<bool>& bits,
119 int left,
int top,
int spacing,
int lead,
120 bool flip,
int orientation)
121 -> std::pair< wxRect, Label >
123 lab.lx = left - 1000;
126 auto length = bits.size() - 1;
131 wxCoord strW, strH, strD, strL;
132 auto strText = lab.text;
133 auto strUnits = lab.units;
138 dc.GetTextExtent(
str.Translation(), &strW, &strH, &strD, &strL);
140 int strPos, strLen, strLeft, strTop;
141 if (orientation == wxHORIZONTAL) {
143 strPos = pos - strW / 2;
146 if (strPos + strW >= length)
147 strPos = length - strW;
148 strLeft = left + strPos;
152 strTop = -strH - lead;
157 strPos = pos - strH / 2;
160 if (strPos + strH >= length)
161 strPos = length - strH;
162 strTop = top + strPos;
179 for (i = 0; i < strLen; i++)
180 if (bits[strPos + i])
190 int leftMargin = spacing;
191 if (strPos < leftMargin)
193 strPos -= leftMargin;
194 strLen += leftMargin;
196 int rightMargin = spacing;
197 if (strPos + strLen > length - spacing)
198 rightMargin = length - strPos - strLen;
199 strLen += rightMargin;
201 for (i = 0; i < strLen; i++)
202 bits[strPos + i] =
true;
206 lab.units = strUnits;
207 return { { strLeft, strTop, strW, strH }, lab };
219 const int mLeft = context.
mLeft;
220 const int mTop = context.
mTop;
221 const int mBottom = context.
mBottom;
222 const int mRight = context.
mRight;
224 const bool mFlip = context.
mFlip;
226 int displacementx = 0, displacementy = 0;
227 auto& box = allOutputs.
box;
229 if (mOrientation == wxHORIZONTAL) {
230 int d = mTop + box.GetHeight() + 5;
237 int d = mLeft - box.GetLeft() + 5;
245 if (mOrientation == wxHORIZONTAL) {
252 label.lx += displacementx;
253 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