Audacity
3.2.0
src
widgets
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
14
const
IntFormat
&
::IntFormat::Instance
()
15
{
16
static
IntFormat
instance;
17
return
instance;
18
}
19
20
void
IntFormat::SetTickSizes
(
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
43
void
IntFormat::SetLabelString
(
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
53
IntFormat::~IntFormat
() =
default
;
wxT
wxT("CloseDown"))
IntFormat.h
IntFormat
Definition:
IntFormat.h:17
IntFormat::~IntFormat
~IntFormat() override
IntFormat::Instance
static const IntFormat & Instance()
Definition:
IntFormat.cpp:14
IntFormat::SetTickSizes
void SetTickSizes(double units, double &major, double &minor, double &minorMinor, int &mDigits) const override
Definition:
IntFormat.cpp:20
IntFormat::SetLabelString
void SetLabelString(wxString &s, double d, double units, double minor, int mDigits, TickType tickType) const override
Definition:
IntFormat.cpp:43
RulerFormat::TickType
TickType
Definition:
RulerFormat.h:19
Generated by
1.9.3