LMMS
Loading...
Searching...
No Matches
plugins
CarlaBase
carla
source
native-plugins
external
zynaddsubfx
UI
TipWin.cpp
Go to the documentation of this file.
1
/*
2
ZynAddSubFX - a software synthesizer
3
4
TipWin.cpp - Tooltips
5
Copyright (C) 2016 Mark McCurry
6
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
*/
12
#include <cstdio>
13
#include <cmath>
14
#include <FL/Fl_Tooltip.H>
15
#include <FL/fl_draw.H>
16
#include "
TipWin.h
"
17
18
TipWin::TipWin
(
void
):Fl_Menu_Window(1, 1)
19
{
20
strcpy(
format
,
"%0.2f"
);
21
set_override();
22
end();
23
}
24
25
void
TipWin::set_rounding
(
unsigned
int
digits)
26
{
27
format
[3] =
"0123456789"
[digits < 9 ? digits : 9];
28
}
29
30
void
TipWin::draw
()
31
{
32
//setup window
33
draw_box(FL_BORDER_BOX, 0, 0,
w
(),
h
(), Fl_Color(175));
34
fl_color(Fl_Tooltip::textcolor());
35
fl_font(labelfont(), labelsize());
36
37
//Draw the current string
38
fl_draw(
getStr
(), 3, 3,
w
() - 6,
h
() - 6,
39
Fl_Align(FL_ALIGN_LEFT | FL_ALIGN_WRAP));
40
}
41
42
void
TipWin::showValue
(
float
f
)
43
{
44
//convert the value to a string
45
char
tmp[10];
46
snprintf(tmp, 9,
format
,
f
);
47
tip
= tmp;
48
49
textmode
=
false
;
50
redraw
();
51
show();
52
}
53
54
void
TipWin::setText
(
const
char
*
c
)
55
{
56
text
=
c
;
57
textmode
=
true
;
58
redraw
();
59
}
60
61
void
TipWin::showText
()
62
{
63
if
(!
text
.empty()) {
64
textmode
=
true
;
65
redraw
();
66
show();
67
}
68
}
69
70
void
TipWin::redraw
()
71
{
72
// Recalc size of window
73
fl_font(labelfont(), labelsize());
74
int
W = 0, H = 0;
75
fl_measure(
getStr
(), W, H, 0);
76
//provide a bit of extra space
77
W += 8;
78
H += 4;
79
size
(W, H);
80
Fl_Menu_Window::redraw();
81
}
82
83
const
char
*
TipWin::getStr
()
const
84
{
85
return
(
textmode
?
text
:
tip
).c_str();
86
}
TipWin.h
TipWin::tip
string tip
Definition
TipWin.h:31
TipWin::showText
void showText()
Definition
TipWin.cpp:61
TipWin::showValue
void showValue(float f)
Definition
TipWin.cpp:42
TipWin::redraw
void redraw()
Definition
TipWin.cpp:70
TipWin::draw
void draw()
Definition
TipWin.cpp:30
TipWin::set_rounding
void set_rounding(unsigned int digits=0)
Definition
TipWin.cpp:25
TipWin::format
char format[6]
Definition
TipWin.h:34
TipWin::setText
void setText(const char *c)
Definition
TipWin.cpp:54
TipWin::textmode
bool textmode
Definition
TipWin.h:33
TipWin::getStr
const char * getStr() const
Definition
TipWin.cpp:83
TipWin::text
string text
Definition
TipWin.h:32
TipWin::TipWin
TipWin()
Definition
TipWin.cpp:18
w
UINT_D64 w
Definition
inflate.c:942
f
unsigned f
Definition
inflate.c:1572
c
return c
Definition
crypt.c:175
h
uch h[RAND_HEAD_LEN]
Definition
crypt.c:459
size
ulg size
Definition
extract.c:2350
Generated on
for LMMS by
1.16.1