Audacity 3.2.0
IntFormat.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 IntFormat.cpp
6
7 Dominic Mazzoni
8 Michael Papadopoulos split from Ruler.h
9
10**********************************************************************/
11
12#include "IntFormat.h"
13
15{
16 static IntFormat instance;
17 return instance;
18}
19
21 double units, double& major, double& minor, double& minorMinor,
22 int& mDigits
23) const
24{
25 double d;
26 d = 1.0;
27 for (;;) {
28 if (units < d) {
29 minor = d;
30 major = d * 5.0;
31 return;
32 }
33 d *= 5.0;
34 if (units < d) {
35 minor = d;
36 major = d * 2.0;
37 return;
38 }
39 d *= 2.0;
40 }
41}
42
44 wxString& s, double d, double, double minor, int mDigits, TickType tickType
45) const
46{
47 // Replace -0 with 0
48 if (d < 0.0 && (d + minor > 0.0))
49 d = 0.0;
50 s.Printf(wxT("%d"), (int)floor(d + 0.5));
51}
52
53IntFormat::~IntFormat() = default;
wxT("CloseDown"))
~IntFormat() override
static const IntFormat & Instance()
Definition: IntFormat.cpp:14
void SetTickSizes(double units, double &major, double &minor, double &minorMinor, int &mDigits) const override
Definition: IntFormat.cpp:20
void SetLabelString(wxString &s, double d, double units, double minor, int mDigits, TickType tickType) const override
Definition: IntFormat.cpp:43