Import fmit upstream version 0.97.6
[fmit.git] / src / modules / GLVolumeHistory.cpp
1 // Copyright 2004 "Gilles Degottex"
2
3 // This file is part of "fmit"
4
5 // "fmit" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // "fmit" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19 #include "GLVolumeHistory.h"
20
21 static const unsigned char g_icon_volume_graph[] = {
22         0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
23         0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20,
24         0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7a, 0x7a, 0xf4, 0x00, 0x00, 0x06,
25         0x83, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xb5, 0xd7, 0x59, 0x6c, 0x54,
26         0xd7, 0x19, 0xc0, 0xf1, 0xff, 0xdd, 0xe6, 0xce, 0xcc, 0x9d, 0x19, 0x8f,
27         0xf7, 0xb1, 0xf1, 0xd8, 0x9e, 0xc1, 0x6b, 0xcd, 0x62, 0x23, 0x4c, 0x1c,
28         0xc4, 0x52, 0x9a, 0x84, 0xf2, 0x10, 0x08, 0x52, 0x17, 0x1e, 0xaa, 0x54,
29         0xed, 0x43, 0xd3, 0x36, 0x7d, 0x69, 0xd4, 0x3e, 0xa4, 0xd0, 0xb7, 0xbe,
30         0xb4, 0x51, 0x53, 0xa9, 0x8d, 0xaa, 0x34, 0x95, 0x1a, 0x35, 0x0f, 0x88,
31         0x2c, 0x6a, 0x4a, 0x24, 0xa8, 0x4a, 0x94, 0x02, 0x0d, 0x34, 0x21, 0xec,
32         0x9b, 0x31, 0x06, 0x4c, 0x60, 0xa8, 0xf7, 0xf1, 0x78, 0x9b, 0xed, 0xee,
33         0x7d, 0x00, 0x13, 0x63, 0x3c, 0xb6, 0x83, 0xe8, 0x27, 0x8d, 0x34, 0x73,
34         0x74, 0xbe, 0xf3, 0xfd, 0x74, 0xee, 0x39, 0xf7, 0x9c, 0x11, 0x78, 0xf4,
35         0xf0, 0x03, 0xdf, 0x02, 0x9a, 0x45, 0x49, 0x2a, 0x77, 0x6c, 0xbb, 0x1b,
36         0x38, 0x71, 0xef, 0xb3, 0xe4, 0x10, 0x1e, 0xa5, 0xb2, 0x2c, 0x2b, 0xbb,
37         0x81, 0xdd, 0x15, 0xd5, 0xb5, 0xb4, 0xac, 0xee, 0xf4, 0x04, 0x42, 0x61,
38         0x25, 0x71, 0xb3, 0x37, 0xdb, 0x7b, 0xe1, 0x94, 0xe8, 0x38, 0xf6, 0x09,
39         0x3d, 0x9f, 0xfb, 0x1e, 0x70, 0xfb, 0xff, 0x01, 0xf0, 0x7b, 0x54, 0xef,
40         0x15, 0x2d, 0x58, 0x54, 0xf9, 0xc3, 0x5f, 0xbc, 0xe2, 0x8d, 0xb7, 0xac,
41         0xe4, 0xd3, 0x7f, 0x1d, 0xa4, 0xf7, 0xe2, 0x19, 0x04, 0x51, 0x42, 0x14,
42         0x05, 0xb2, 0xe9, 0x49, 0xeb, 0xc2, 0x89, 0xa3, 0xa6, 0x65, 0x59, 0xbb,
43         0xc1, 0xfd, 0x03, 0xe0, 0x3c, 0x36, 0x80, 0xac, 0x7a, 0x4f, 0x95, 0x57,
44         0x54, 0xad, 0x7d, 0xf9, 0xd5, 0xb7, 0x90, 0x24, 0x99, 0xbf, 0xfe, 0xfe,
45         0x57, 0x34, 0xac, 0x5a, 0x4f, 0xb4, 0xa1, 0x0d, 0x00, 0xdb, 0xb6, 0xe8,
46         0x3e, 0x79, 0x98, 0xa9, 0xe4, 0x20, 0x7d, 0x3d, 0xe7, 0x32, 0x13, 0x63,
47         0x23, 0x57, 0x0d, 0x3d, 0xbf, 0x09, 0xc8, 0x16, 0x1a, 0x53, 0x5a, 0x6a,
48         0x71, 0xc5, 0xab, 0xfd, 0x40, 0xc0, 0x7d, 0xe1, 0xc7, 0x7b, 0x5e, 0x15,
49         0xaa, 0xa2, 0x31, 0xf6, 0xfe, 0xf1, 0xd7, 0xb4, 0x6f, 0xda, 0x4e, 0x79,
50         0x75, 0xdd, 0xfd, 0x3e, 0xa2, 0x28, 0x52, 0x19, 0x5d, 0x8e, 0x1a, 0x08,
51         0x91, 0x99, 0x4e, 0x79, 0x64, 0x59, 0x2e, 0xcd, 0xa6, 0xa7, 0x9b, 0x1c,
52         0xdb, 0xfe, 0x5b, 0xa1, 0x71, 0xc5, 0x25, 0xd6, 0x6f, 0x94, 0x15, 0xe5,
53         0x77, 0xcd, 0xab, 0x3a, 0x85, 0xc6, 0xb6, 0x0e, 0x86, 0xfb, 0x6f, 0xa3,
54         0xf8, 0x03, 0x04, 0xc3, 0xa5, 0xf3, 0x76, 0xae, 0x5c, 0x16, 0xe7, 0xab,
55         0x3b, 0xbe, 0x4f, 0x51, 0x69, 0x44, 0x55, 0x14, 0xcf, 0x4e, 0x04, 0xe1,
56         0x85, 0x42, 0x03, 0x2f, 0x65, 0x06, 0xfc, 0xbe, 0x60, 0xf8, 0xb8, 0xa5,
57         0xe7, 0x22, 0x2f, 0xee, 0xf9, 0x2d, 0xa1, 0x70, 0x09, 0x1f, 0xec, 0xfd,
58         0x33, 0x2b, 0x9e, 0x78, 0x06, 0x59, 0xf1, 0x14, 0x4c, 0x92, 0x64, 0x85,
59         0xb2, 0xaa, 0x3a, 0x2c, 0x23, 0x2b, 0x8f, 0xf4, 0xdf, 0xfa, 0xba, 0xeb,
60         0x38, 0x07, 0x81, 0xa1, 0xb9, 0xfd, 0x16, 0x9d, 0x01, 0x5f, 0x30, 0xfc,
61         0x4e, 0x65, 0x7d, 0x4b, 0xbc, 0x79, 0x55, 0x27, 0xcb, 0xea, 0x1b, 0x48,
62         0x4f, 0x4f, 0x62, 0x18, 0x26, 0xaa, 0x4f, 0x5b, 0x54, 0x1e, 0x2e, 0x8b,
63         0x50, 0x51, 0xd3, 0x48, 0xd7, 0x96, 0x67, 0x15, 0xc5, 0xa3, 0x1e, 0x00,
64         0x02, 0x5f, 0x0a, 0xe0, 0xd5, 0x42, 0x3f, 0xaf, 0x6b, 0x5b, 0xb7, 0x11,
65         0xd7, 0x15, 0xeb, 0x1a, 0x5a, 0x00, 0x18, 0x4c, 0xdc, 0xa4, 0x34, 0x12,
66         0x5d, 0xb4, 0xf8, 0x4c, 0xac, 0x78, 0xe2, 0x6b, 0xe4, 0xf2, 0x39, 0x21,
67         0x52, 0x13, 0x0b, 0x03, 0xdf, 0x5d, 0x32, 0x40, 0x94, 0xa4, 0xce, 0x50,
68         0x59, 0xe4, 0x67, 0xcb, 0x3b, 0x36, 0x16, 0xe5, 0xd3, 0x13, 0x44, 0x6a,
69         0x62, 0x00, 0x8c, 0x27, 0x87, 0xd1, 0x42, 0x25, 0x4b, 0x06, 0x00, 0xac,
70         0xd9, 0xb4, 0x9d, 0xaa, 0xda, 0xb8, 0x5f, 0xf5, 0xfa, 0x7e, 0xba, 0x54,
71         0x40, 0x89, 0x3f, 0x54, 0xba, 0xaf, 0xe3, 0x99, 0x6f, 0x47, 0x00, 0xd2,
72         0x13, 0x49, 0x22, 0xd1, 0x7a, 0x00, 0x52, 0xa3, 0xc3, 0x04, 0x42, 0xc5,
73         0x5f, 0x0a, 0x50, 0x5c, 0x5e, 0x8d, 0x65, 0xda, 0x20, 0x08, 0x51, 0x60,
74         0xdd, 0x62, 0x00, 0xc1, 0x17, 0x0c, 0xef, 0x5f, 0xb3, 0x75, 0x57, 0x5c,
75         0x56, 0x54, 0x6c, 0xcb, 0x24, 0x3d, 0x99, 0x22, 0x52, 0x73, 0x17, 0x30,
76         0x9e, 0x1c, 0x26, 0x50, 0x54, 0x72, 0xef, 0xfb, 0x10, 0xbd, 0x17, 0x4f,
77         0x92, 0xcf, 0x65, 0x16, 0x45, 0x44, 0xea, 0x9a, 0x58, 0xd9, 0xb9, 0x41,
78         0x96, 0x15, 0xcf, 0x4f, 0x16, 0x04, 0x78, 0xb5, 0xd0, 0x2b, 0x4d, 0x9d,
79         0x4f, 0x75, 0x04, 0x4b, 0x2a, 0x04, 0x00, 0x3d, 0x3b, 0x8d, 0xaa, 0xfa,
80         0xf0, 0x6b, 0x41, 0x00, 0x4c, 0xd3, 0x44, 0x92, 0x15, 0x06, 0xef, 0xdc,
81         0xe4, 0xc4, 0x27, 0xc7, 0x48, 0x8c, 0x4e, 0x71, 0xe4, 0xd0, 0x07, 0x24,
82         0x87, 0xfe, 0xbb, 0x20, 0xa0, 0x71, 0x75, 0x17, 0x92, 0xe4, 0x91, 0x5d,
83         0xc7, 0xd9, 0x05, 0x04, 0xe7, 0x05, 0xc8, 0x1e, 0x75, 0x5b, 0x59, 0xcd,
84         0xf2, 0xe7, 0x6b, 0x9a, 0xdb, 0xef, 0xaf, 0x56, 0xd5, 0x17, 0x40, 0xcf,
85         0x67, 0x31, 0x0d, 0x1d, 0x80, 0x70, 0x71, 0x29, 0x99, 0xa9, 0x09, 0x6e,
86         0xf4, 0x5e, 0x46, 0x09, 0x94, 0x22, 0x08, 0x22, 0x4a, 0x28, 0xc2, 0x95,
87         0x8b, 0xa7, 0x17, 0x04, 0x78, 0x54, 0x1f, 0x08, 0x12, 0x91, 0x68, 0xcc,
88         0x04, 0xbe, 0x31, 0x1f, 0xa0, 0xdc, 0x1f, 0x2a, 0x79, 0x7d, 0xe5, 0xe6,
89         0x1d, 0x95, 0xb3, 0x13, 0x25, 0xc5, 0x83, 0x57, 0x0b, 0x92, 0x1c, 0x1e,
90         0x00, 0x20, 0x12, 0x8d, 0x31, 0x9e, 0x1c, 0x98, 0x6b, 0x27, 0x6b, 0x49,
91         0xdc, 0xf9, 0xbc, 0x77, 0x41, 0x44, 0x79, 0x75, 0x3d, 0x55, 0xd1, 0x98,
92         0x1f, 0x68, 0x7b, 0x08, 0xe0, 0x0d, 0x14, 0xbd, 0xd4, 0xba, 0x7e, 0x5b,
93         0x9d, 0x28, 0xc9, 0x0f, 0x25, 0x6a, 0xa1, 0x12, 0x46, 0x07, 0xef, 0x4e,
94         0x71, 0xa4, 0xa6, 0x8e, 0xc9, 0xe4, 0x30, 0x82, 0xf8, 0x20, 0x40, 0xf6,
95         0x6a, 0xf4, 0xf5, 0x76, 0x2f, 0x08, 0x28, 0x2a, 0xab, 0x42, 0x56, 0x3c,
96         0xa2, 0xea, 0xf3, 0xb7, 0xce, 0x05, 0x08, 0xb2, 0xe2, 0xf9, 0x66, 0x69,
97         0x75, 0x6c, 0xde, 0xc3, 0xc9, 0x17, 0x2c, 0xba, 0xff, 0x8c, 0x2b, 0xaa,
98         0x6b, 0x99, 0x4c, 0x0d, 0xcd, 0x7b, 0x8a, 0xe9, 0x86, 0xb5, 0x20, 0xa0,
99         0xb8, 0x3c, 0x82, 0x6d, 0x5b, 0x08, 0x82, 0xb0, 0x7c, 0x2e, 0xa0, 0xae,
100         0x38, 0x52, 0x1b, 0x12, 0x84, 0xf9, 0x0f, 0x47, 0x8f, 0x3f, 0xc4, 0xe8,
101         0x50, 0x3f, 0x00, 0x5e, 0x9f, 0x1f, 0x3d, 0x97, 0xc1, 0xa3, 0x3c, 0xfc,
102         0x16, 0x77, 0x1c, 0x77, 0x41, 0x80, 0x4f, 0x0b, 0x61, 0x59, 0x16, 0x96,
103         0x69, 0x2e, 0x9b, 0x0b, 0x48, 0x99, 0xf9, 0x9c, 0x5d, 0x28, 0xd1, 0x1f,
104         0x2a, 0xa1, 0xaf, 0xe7, 0xe2, 0x17, 0xbf, 0x35, 0x8d, 0xc6, 0xb6, 0x0e,
105         0x8c, 0xe9, 0xe1, 0x39, 0x3d, 0x17, 0x06, 0x00, 0xc8, 0xb2, 0x07, 0xcb,
106         0x34, 0x82, 0x80, 0x36, 0x1b, 0x30, 0x65, 0xe4, 0xb3, 0x05, 0xe7, 0x2f,
107         0x12, 0x6b, 0xe5, 0xf3, 0x6b, 0x97, 0x18, 0x19, 0xb8, 0x03, 0xc0, 0x86,
108         0xad, 0xcf, 0x91, 0xb8, 0x7a, 0x9e, 0xb2, 0xe2, 0x62, 0x5c, 0xe7, 0x8b,
109         0xfb, 0x46, 0xa1, 0x19, 0x7c, 0x20, 0x04, 0x11, 0xc5, 0xa3, 0x9a, 0x40,
110         0x74, 0x36, 0x00, 0x53, 0xcf, 0xa5, 0x5d, 0x77, 0xfe, 0xcb, 0x8b, 0xea,
111         0x0f, 0x50, 0x15, 0x6f, 0xe3, 0xd8, 0xa1, 0xf7, 0x01, 0x58, 0xde, 0xb2,
112         0x8a, 0xd1, 0xc1, 0x5b, 0x74, 0x74, 0x6d, 0xc1, 0xcd, 0x8c, 0xe0, 0x3a,
113         0x0e, 0x96, 0x9e, 0xa5, 0xb2, 0xb2, 0x62, 0x09, 0x00, 0x30, 0x0d, 0x5d,
114         0x06, 0xc6, 0x1e, 0x00, 0x18, 0xf9, 0xcc, 0x9b, 0x83, 0x37, 0xba, 0xf5,
115         0x42, 0x79, 0x35, 0x2d, 0x6b, 0x38, 0x76, 0x68, 0x3f, 0x8e, 0x7d, 0xf7,
116         0x49, 0xd5, 0x37, 0x34, 0x33, 0x3d, 0x9e, 0xe4, 0xe9, 0x67, 0x77, 0x11,
117         0x2d, 0xd3, 0x68, 0x8a, 0x45, 0xe9, 0xe8, 0xda, 0xb2, 0x68, 0x7d, 0xcb,
118         0xd0, 0x91, 0x65, 0x25, 0x07, 0x8c, 0x3e, 0x00, 0xd0, 0xb3, 0xe9, 0xd7,
119         0xae, 0x7e, 0xf6, 0xe1, 0xf9, 0xf1, 0xa1, 0xc4, 0xbc, 0xd3, 0x50, 0xba,
120         0x2c, 0x0e, 0x08, 0x5c, 0x3a, 0xfd, 0x1f, 0x00, 0x36, 0x6c, 0xdd, 0xc9,
121         0x95, 0x33, 0x47, 0x11, 0x25, 0x89, 0x96, 0xf6, 0x27, 0x89, 0xb7, 0xac,
122         0x5e, 0xb4, 0xb8, 0x6d, 0x5b, 0xd8, 0x96, 0x89, 0xa2, 0xaa, 0x89, 0x99,
123         0xb6, 0xd9, 0x9b, 0xd9, 0xc8, 0x4d, 0x4f, 0x3c, 0x75, 0xee, 0xa3, 0xf7,
124         0x0e, 0x5e, 0x3f, 0x7d, 0x24, 0xe5, 0xba, 0x0f, 0x2e, 0x28, 0x41, 0x10,
125         0xa8, 0x6e, 0x6e, 0xe7, 0xe8, 0xc1, 0x77, 0x01, 0x28, 0x2a, 0x2e, 0xa5,
126         0xb2, 0xaa, 0x8a, 0x81, 0x5b, 0xd7, 0x16, 0x2d, 0x3c, 0x13, 0xe9, 0x89,
127         0x31, 0x70, 0x5d, 0x5c, 0xc7, 0xb9, 0x32, 0xd3, 0x36, 0x77, 0x2f, 0x99,
128         0x96, 0x91, 0xdf, 0x37, 0x3d, 0x3e, 0x32, 0xd6, 0x7f, 0xfd, 0x62, 0x9b,
129         0xc7, 0xab, 0xf9, 0x03, 0xc5, 0xe5, 0xf2, 0xcc, 0xe2, 0xd2, 0x8a, 0xca,
130         0x38, 0x73, 0x78, 0x3f, 0xd5, 0xd1, 0x18, 0x55, 0xb5, 0x71, 0x1a, 0xbf,
131         0xd2, 0xce, 0xa1, 0xf7, 0xfe, 0x42, 0x4d, 0xc3, 0x0a, 0xa4, 0x79, 0x5e,
132         0x60, 0x73, 0xe3, 0xf2, 0xa9, 0xc3, 0x64, 0xa6, 0x52, 0xf6, 0xc0, 0xed,
133         0xbe, 0x77, 0x81, 0x7f, 0xcf, 0x07, 0x00, 0xc0, 0xb6, 0xcc, 0x73, 0x46,
134         0x2e, 0xfd, 0x46, 0x6a, 0xf0, 0x96, 0xde, 0x7f, 0xed, 0x42, 0xcc, 0xe3,
135         0xd3, 0xfc, 0x81, 0x70, 0xb9, 0x2c, 0x7b, 0x54, 0xb4, 0x70, 0x19, 0xff,
136         0xdc, 0xf7, 0x3a, 0xeb, 0x36, 0x6f, 0x23, 0x10, 0x0a, 0x53, 0xdb, 0xd8,
137         0xc2, 0xd1, 0x03, 0x6f, 0x13, 0x6d, 0x58, 0xb1, 0x60, 0x71, 0xc7, 0xb6,
138         0xb9, 0x76, 0xee, 0x18, 0xdd, 0xa7, 0x8f, 0xdb, 0x8e, 0x63, 0xef, 0x01,
139         0xfa, 0x0b, 0x02, 0x66, 0x1c, 0xb6, 0x69, 0x1c, 0x9f, 0x0b, 0x89, 0xc4,
140         0x5a, 0x65, 0x23, 0x9f, 0xe1, 0x93, 0x0f, 0xdf, 0x67, 0xc3, 0xd6, 0x9d,
141         0x84, 0xc2, 0x25, 0xa4, 0x27, 0xc6, 0xe8, 0xeb, 0x3e, 0x47, 0x65, 0x6d,
142         0x43, 0xc1, 0xc1, 0x7a, 0xce, 0x1e, 0x63, 0x7a, 0x6c, 0xc8, 0x49, 0x0e,
143         0x0f, 0x7c, 0x64, 0x5b, 0xe6, 0x6f, 0x66, 0xda, 0x97, 0x72, 0x29, 0x9d,
144         0x05, 0xb9, 0xad, 0xf7, 0x5f, 0xbb, 0x10, 0xab, 0x6e, 0x58, 0xe9, 0x1f,
145         0x1b, 0x4c, 0xc8, 0xc3, 0x77, 0x6e, 0xd2, 0xde, 0xb5, 0x99, 0xba, 0x86,
146         0x56, 0x04, 0xc1, 0xe5, 0xe3, 0x7f, 0xbc, 0x4d, 0xa4, 0xb6, 0xf1, 0xa1,
147         0xcb, 0x6a, 0x72, 0x30, 0xc1, 0x8d, 0x4b, 0x9f, 0x72, 0xe1, 0xc4, 0x51,
148         0xcb, 0x34, 0xf5, 0xe7, 0xb8, 0xb7, 0x05, 0x97, 0x0a, 0x78, 0x08, 0x32,
149         0x3e, 0x94, 0xd0, 0x5d, 0xc7, 0x6d, 0x4c, 0xf4, 0xf5, 0x14, 0xdd, 0xbe,
150         0xd1, 0x23, 0x34, 0xaf, 0x5a, 0x4b, 0x4d, 0xac, 0x91, 0xa6, 0x15, 0x77,
151         0xd7, 0x44, 0x6a, 0x74, 0x08, 0x51, 0x94, 0x98, 0x4a, 0x8d, 0xd2, 0x73,
152         0xf6, 0x63, 0x52, 0x43, 0xb7, 0xc8, 0x65, 0xa6, 0x8c, 0xb1, 0x91, 0x81,
153         0xbd, 0xb6, 0x6d, 0xbd, 0x39, 0x7b, 0xd0, 0x47, 0xfa, 0x6f, 0x78, 0x2f,
154         0x54, 0xc5, 0xab, 0xfd, 0x52, 0x96, 0xc4, 0x97, 0x5c, 0xd7, 0xd5, 0xbe,
155         0xf3, 0xe2, 0xcb, 0xac, 0x7f, 0x7a, 0x07, 0x00, 0x03, 0x89, 0x9b, 0x5c,
156         0xbf, 0x7c, 0x16, 0x45, 0x55, 0x89, 0xc6, 0x9a, 0xf9, 0xfb, 0x5b, 0xaf,
157         0xe9, 0x3d, 0xe7, 0x3f, 0x1b, 0x30, 0xf4, 0x7c, 0x17, 0x30, 0xf2, 0xb8,
158         0x00, 0xf7, 0x21, 0x92, 0xe2, 0x79, 0x43, 0x14, 0xc4, 0xe7, 0xa3, 0xf1,
159         0x26, 0x67, 0xed, 0xc6, 0xad, 0x72, 0x75, 0x5d, 0x9c, 0xcc, 0xf4, 0x24,
160         0x89, 0x1b, 0x57, 0xed, 0x23, 0x07, 0xde, 0xb1, 0x81, 0x93, 0x86, 0x9e,
161         0xdf, 0x0e, 0x4c, 0xcc, 0x4d, 0x7e, 0x1c, 0x80, 0x99, 0x28, 0x03, 0x7e,
162         0xe4, 0xf5, 0x69, 0x4f, 0x0a, 0x82, 0xd0, 0x2a, 0x88, 0x42, 0xca, 0x32,
163         0xcd, 0xab, 0x86, 0x9e, 0xff, 0x13, 0x70, 0xbc, 0x50, 0xd2, 0xff, 0x00,
164         0x3c, 0x39, 0x7b, 0xa0, 0x73, 0xfc, 0x63, 0xd4, 0x00, 0x00, 0x00, 0x00,
165         0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
166 };
167
168 #include <iostream>
169 using namespace std;
170 #include <GL/glut.h>
171 #include <qtimer.h>
172 #include <qimage.h>
173 #include <Music/Music.h>
174
175 GLVolumeHistory::Note::Note(int h)
176 : ht(h)
177 {
178 }
179 GLVolumeHistory::Note::Note(int h, int num, int den)
180 : ht(h)
181 {
182         factor = QString::number(num)+"/"+QString::number(den);
183 }
184 GLVolumeHistory::Note::Note(int h, float cents)
185 : ht(h)
186 {
187         factor = QString::number(cents);
188 }
189 QString GLVolumeHistory::Note::getName() const
190 {
191         return Music::h2n(ht)+factor;
192 }
193
194 GLVolumeHistory::GLVolumeHistory(QWidget* parent)
195 : QGLWidget(parent, "GLVolumeHistory")
196 , View("Volume history", this)
197 {
198         QImage img;
199         setting_show->setToggleAction(true);
200         img.loadFromData(g_icon_volume_graph, sizeof(g_icon_volume_graph), "PNG");
201         setting_show->setIconSet(QIconSet(QImage(img)));
202         setting_show->setOn(false);
203         hide();
204
205         m_volume_treshold = -100;
206
207         setting_keep = new QAction(this);
208         setting_keep->setMenuText(tr("Keep previous notes"));
209         setting_keep->setToggleAction(true);
210         setting_keep->setOn(false);
211         connect(setting_keep, SIGNAL(toggled(bool)), this, SLOT(keepPreviousNotes(bool)));
212 //      setting_keep->addTo(&m_popup_menu);
213 }
214
215 void GLVolumeHistory::save()
216 {
217         s_settings->writeEntry("keep", setting_keep->isOn());
218 }
219 void GLVolumeHistory::load()
220 {
221         setting_keep->setOn(s_settings->readBoolEntry("keep", setting_keep->isOn()));
222 }
223 void GLVolumeHistory::clearSettings()
224 {
225         s_settings->removeEntry("keep");
226 }
227
228 void GLVolumeHistory::addNote(GLVolumeHistory::Note note)
229 {
230         m_notes.push_back(note);
231
232         if(!setting_keep->isOn())
233                 while(m_notes.size()>1)
234                         m_notes.pop_front();
235 }
236 void GLVolumeHistory::addVolume(float vol)
237 {
238         m_notes.back().volumes.push_back(vol);
239 }
240
241 void GLVolumeHistory::keepPreviousNotes(bool keep)
242 {
243         if(!keep)
244                 while(m_notes.size()>1)
245                         m_notes.pop_front();
246 }
247
248 void GLVolumeHistory::setVolumeTreshold(int treshold)
249 {
250         m_volume_treshold = treshold;
251 }
252
253 void GLVolumeHistory::initializeGL()
254 {
255         // Set the clear color to black
256         glClearColor(1.0, 1.0, 1.0, 0.0);
257
258         // glShadeModel( GL_FLAT );
259         glShadeModel( GL_SMOOTH );
260
261         glLoadIdentity();
262 }
263
264 void GLVolumeHistory::paintGL()
265 {
266 //      cerr << "GLVolumeHistory::paintGL " << m_notes.size() << endl;
267
268         glClear(GL_COLOR_BUFFER_BIT);
269
270         glLineWidth(1.0f);
271
272         // name
273         QString str = tr("Volume");
274         glColor3f(0.75,0.75,0.75);
275         glRasterPos2i(2, height()-20);
276         for(size_t i = 0; i < str.length(); i++)
277                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str.latin1()[i]);
278
279         int s = 2+fontMetrics().width("50%");
280
281         // horiz lines
282         if(2*height()/50>2)
283         {
284                 glBegin(GL_LINES);
285                 float gray = 0.875;
286                 glColor3f(gray, gray, gray);
287                 for(int h=2; h<50; h+=2)
288                 {
289                         glVertex2i(s, h*height()/50);
290                         glVertex2i(width(), h*height()/50);
291                 }
292                 glEnd();
293         }
294         if(10*height()/50>2)
295         {
296                 glBegin(GL_LINES);
297                 float gray = 0.75;
298                 glColor3f(gray, gray, gray);
299                 for(int h=10; h<50; h+=10)
300                 {
301                         glVertex2i(s, h*height()/50);
302                         glVertex2i(width(), h*height()/50);
303                 }
304                 glEnd();
305         }
306
307         int dy = 3;
308         glColor3f(0.5f,0.5f,0.5f);
309         string sfraq = "-10";
310         glRasterPos2i(2, height()-10*height()/50-dy);
311         for(size_t i = 0; i < sfraq.size(); i++)
312                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, sfraq[i]);
313         sfraq = "-20";
314         glRasterPos2i(2, height()-20*height()/50-dy);
315         for(size_t i = 0; i < sfraq.size(); i++)
316                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, sfraq[i]);
317         sfraq = "-30";
318         glRasterPos2i(2, height()-30*height()/50-dy);
319         for(size_t i = 0; i < sfraq.size(); i++)
320                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, sfraq[i]);
321         sfraq = "-40";
322         glRasterPos2i(2, height()-40*height()/50-dy);
323         for(size_t i = 0; i < sfraq.size(); i++)
324                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, sfraq[i]);
325
326         glColor3f(1.0,0.5,0.5);
327         glLineWidth(2.0f);
328         glBegin(GL_LINES);
329         glVertex2f(s, height()+height()*m_volume_treshold/50);
330         glVertex2f(width(), height()+height()*m_volume_treshold/50);
331         glEnd();
332
333         // volumes
334         if(!m_notes.empty())
335         {
336                 int total_size = 0;
337                 for(size_t i=0; i<m_notes.size(); i++)
338                         total_size += m_notes[i].volumes.size()-1;
339
340                 float step = float(width()-s)/total_size;
341
342 //              cerr << "total_size=" << total_size << " step=" << step << endl;
343
344                 int curr_total = 0;
345                 for(size_t i=0; i<m_notes.size(); i++)
346                 {
347                         float x = s+step*curr_total;
348
349                         // if it's not the first, add a separation
350                         if(i>0)
351                         {
352                                 glColor3f(0.75,0.75,0.75);
353                                 glLineWidth(1.0f);
354                                 glBegin(GL_LINES);
355                                 glVertex2f(x, 0);       glVertex2f(x, height());
356                                 glEnd();
357                         }
358
359                         // the note name
360                         string str = Music::h2n(m_notes[i].ht);
361                         glColor3f(0.0,0.0,1.0);
362                         glRasterPos2f(x+2, 2);
363                         for(size_t c=0; c<str.length(); c++)
364                                 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[c]);
365
366                         // draw the volume graph
367                         if(!m_notes[i].volumes.empty())
368                         {
369 //                              glColor3f(0.33,0.33,1.0);
370                                 glColor3f(0.0f,0.0f,0.0f);
371                                 glLineWidth(2.0f);
372                                 glBegin(GL_LINE_STRIP);
373                                 for(int j=0; j<int(m_notes[i].volumes.size()); j++)
374                                         glVertex2f(x+j*step, height()+height()*m_notes[i].volumes[j]/50.0);
375                                 glEnd();
376                         }
377
378                         curr_total += m_notes[i].volumes.size()-1;
379                 }
380         }
381
382         glFlush();
383 }
384
385 void GLVolumeHistory::resizeGL( int w, int h )
386 {
387         // Set the new viewport size
388         glViewport(0, 0, (GLint)w, (GLint)h);
389
390         // Choose the projection matrix to be the matrix
391         // manipulated by the following calls
392         glMatrixMode(GL_PROJECTION);
393
394         // Set the projection matrix to be the identity matrix
395         glLoadIdentity();
396
397         // Define the dimensions of the Orthographic Viewing Volume
398         glOrtho(0.0, w, 0.0, h, 0.0, 1.0);
399
400         // Choose the modelview matrix to be the matrix
401         // manipulated by further calls
402         glMatrixMode(GL_MODELVIEW);
403 }
404