LMMS
Loading...
Searching...
No Matches
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
18TipWin::TipWin(void):Fl_Menu_Window(1, 1)
19{
20 strcpy(format, "%0.2f");
21 set_override();
22 end();
23}
24
25void TipWin::set_rounding(unsigned int digits)
26{
27 format[3] = "0123456789"[digits < 9 ? digits : 9];
28}
29
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
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
54void TipWin::setText(const char *c)
55{
56 text = c;
57 textmode = true;
58 redraw();
59}
60
62{
63 if(!text.empty()) {
64 textmode = true;
65 redraw();
66 show();
67 }
68}
69
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
83const char *TipWin::getStr() const
84{
85 return (textmode ? text : tip).c_str();
86}
string tip
Definition TipWin.h:31
void showText()
Definition TipWin.cpp:61
void showValue(float f)
Definition TipWin.cpp:42
void redraw()
Definition TipWin.cpp:70
void draw()
Definition TipWin.cpp:30
void set_rounding(unsigned int digits=0)
Definition TipWin.cpp:25
char format[6]
Definition TipWin.h:34
void setText(const char *c)
Definition TipWin.cpp:54
bool textmode
Definition TipWin.h:33
const char * getStr() const
Definition TipWin.cpp:83
string text
Definition TipWin.h:32
TipWin()
Definition TipWin.cpp:18
UINT_D64 w
Definition inflate.c:942
unsigned f
Definition inflate.c:1572
return c
Definition crypt.c:175
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
ulg size
Definition extract.c:2350