11
11
#include <qframe.h>
12
12
#include <sys/time.h>
14
// Quick bit-shift lookup table
15
const unsigned int bitShiftLU[32] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
16
0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000,
17
0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000,
18
0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000 };
14
20
//---------------------------------------------------------
16
22
//---------------------------------------------------------
123
130
//---------------------------------------------------------
132
//---------------------------------------------------------
133
// Added by Tim. p3.3.8
135
QString u32bitmap2String(unsigned int bm)
138
//printf("bitmap2string: bm %04x", bm);
140
if (bm == 0xffffffff)
147
//unsigned int first = 0;
148
bool needSpace = false;
150
//for (int i = 0; i < 17; ++i) {
151
for (int i = 0; i < 33; ++i) {
152
if ((i < 32) && ((1U << i) & bm)) {
164
ns.sprintf("%d", first+1);
165
//ns.sprintf("%u", first+1);
167
ns.sprintf("%d-%d", first+1, i);
168
//ns.sprintf("%u-%u", first+1, i);
176
//printf(" -> <%s>\n", s.latin1());
180
//---------------------------------------------------------
125
182
//---------------------------------------------------------
176
233
return val & 0xffff;
236
//---------------------------------------------------------
238
//---------------------------------------------------------
239
// Added by Tim. p3.3.8
241
unsigned int string2u32bitmap(const QString& str)
244
unsigned int val = 0;
245
QString ss = str.simplifyWhiteSpace();
246
const char* s = ss.latin1();
247
//printf("string2bitmap <%s>\n", s);
251
if (strcmp(s, "all") == 0)
254
if (strcmp(s, "none") == 0)
256
// printf("str2bitmap: <%s> ", str.latin1);
258
//unsigned int tval = 0;
261
//unsigned int sval = 0;
265
if (*s >= '0' && *s <= '9') {
269
else if (*s == ' ' || *s == ',') {
271
for (int i = sval-1; i < tval; ++i)
272
//for (unsigned int i = sval-1; i < tval; ++i)
277
val |= (1U << (tval-1));
281
else if (*s == '-') {
289
for (int i = sval-1; i < tval; ++i)
290
//for (unsigned int i = sval-1; i < tval; ++i)
294
val |= (1U << (tval-1));
296
//return val & 0xffff;
300
//---------------------------------------------------------
301
// autoAdjustFontSize
302
// w: Widget to auto adjust font size
304
// ignoreWidth: Set if dealing with a vertically constrained widget - one which is free to resize horizontally.
305
// ignoreHeight: Set if dealing with a horizontally constrained widget - one which is free to resize vertically.
306
//---------------------------------------------------------
307
// Added by Tim. p3.3.8
309
bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth, bool ignoreHeight, int max, int min)
311
// In case the max or min was obtained from QFont::pointSize() which returns -1
312
// if the font is a pixel font, or if min is greater than max...
313
if(!w || (min < 0) || (max < 0) || (min > max))
316
// Limit the minimum and maximum sizes to something at least readable.
322
QRect cr = w->contentsRect();
324
QFont fnt = w->font();
325
// An extra amount just to be sure - I found it was still breaking up two words which would fit on one line.
327
// Allow at least one loop. min can be equal to max.
328
for(int i = max; i >= min; --i)
331
QFontMetrics fm(fnt);
332
r = fm.boundingRect(s);
333
// Would the text fit within the widget?
334
if((ignoreWidth || (r.width() <= (cr.width() - extra))) && (ignoreHeight || (r.height() <= cr.height())))
337
// Added by Tim. p3.3.9
338
//printf("autoAdjustFontSize: ptsz:%d widget:%s before setFont x:%d y:%d w:%d h:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height());
340
// Here we will always have a font ranging from min to max point size.
342
// Added by Tim. p3.3.9
343
//printf("autoAdjustFontSize: ptsz:%d widget:%s x:%d y:%d w:%d h:%d frame w:%d rw:%d rh:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height(), w->frameWidth(), cr.width(), cr.height());
345
// Force minimum height. Use the expected height for the highest given point size.
346
// This way the mixer strips aren't all different label heights, but can be larger if necessary.
347
// Only if ignoreHeight is set (therefore the height is adjustable).
350
fnt.setPointSize(max);
351
QFontMetrics fm(fnt);
352
// Set the label's minimum height equal to the height of the font.
353
w->setMinimumHeight(fm.height() + 2 * w->frameWidth());