~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/winskin/waSkinModell.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
Import upstream version 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Modell for winamp skins
 
3
  Copyright (C) 1999  Martin Vogt
 
4
 
 
5
  This program 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.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
 
 
15
 
 
16
#include <waSkinModell.h>
 
17
 
 
18
 
 
19
 
 
20
WaSkinModell::WaSkinModell() {
 
21
  
 
22
  WaSkinOperation::makeEmptySkinModell(this);
 
23
  skinDir="";
 
24
}
 
25
 
 
26
 
 
27
WaSkinModell::~WaSkinModell() {
 
28
}
 
29
 
 
30
 
 
31
void WaSkinModell::load(int id,QPixmap* pixmap) {
 
32
  int lEmit;
 
33
 
 
34
  lEmit=emitChangeEvent(id);
 
35
  if (lEmit == true) {
 
36
    waSkinDesc[id].setPixmap(pixmap);
 
37
  }
 
38
 
 
39
}
 
40
 
 
41
 
 
42
int WaSkinModell::emitChangeEvent(int id) {
 
43
  int back=true;
 
44
 
 
45
  switch(id) {
 
46
  case _WA_SKIN_MAIN: {
 
47
    emit(event_WA_SKIN_MAIN());
 
48
    break;
 
49
  } 
 
50
  case _WA_SKIN_CBUTTONS_PREV_NORM: {
 
51
    emit(event_WA_SKIN_CBUTTONS_PREV_NORM());
 
52
    break;
 
53
  }
 
54
  case _WA_SKIN_CBUTTONS_PREV_PRES: {
 
55
    emit(event_WA_SKIN_CBUTTONS_PREV_PRES());
 
56
    break;
 
57
  }
 
58
  case _WA_SKIN_CBUTTONS_PLAY_NORM: {
 
59
    emit(event_WA_SKIN_CBUTTONS_PLAY_NORM());
 
60
    break;
 
61
  }
 
62
  case _WA_SKIN_CBUTTONS_PLAY_PRES: {
 
63
    emit(event_WA_SKIN_CBUTTONS_PLAY_PRES());
 
64
    break;
 
65
  }
 
66
  case _WA_SKIN_CBUTTONS_PAUSE_NORM: {
 
67
    emit(event_WA_SKIN_CBUTTONS_PAUSE_NORM());
 
68
    break;
 
69
  }
 
70
  case _WA_SKIN_CBUTTONS_PAUSE_PRES: {
 
71
    emit(event_WA_SKIN_CBUTTONS_PAUSE_PRES());
 
72
    break;
 
73
  }
 
74
  case _WA_SKIN_CBUTTONS_STOP_NORM: {
 
75
    emit(event_WA_SKIN_CBUTTONS_STOP_NORM());
 
76
    break;
 
77
  }
 
78
  case _WA_SKIN_CBUTTONS_STOP_PRES: {
 
79
    emit(event_WA_SKIN_CBUTTONS_STOP_PRES());
 
80
    break;
 
81
  }
 
82
  case _WA_SKIN_CBUTTONS_NEXT_NORM: {
 
83
    emit(event_WA_SKIN_CBUTTONS_NEXT_NORM());
 
84
    break;
 
85
  }
 
86
  case _WA_SKIN_CBUTTONS_NEXT_PRES: {
 
87
    emit(event_WA_SKIN_CBUTTONS_NEXT_PRES());
 
88
    break;
 
89
  }
 
90
  case _WA_SKIN_CBUTTONS_EJECT_NORM: {
 
91
    emit(event_WA_SKIN_CBUTTONS_EJECT_NORM());
 
92
    break;
 
93
  }
 
94
  case _WA_SKIN_CBUTTONS_EJECT_PRESS: {
 
95
    emit(event_WA_SKIN_CBUTTONS_EJECT_PRESS());
 
96
    break;
 
97
  }
 
98
  case _WA_SKIN_MONOSTER_STEREO_TRUE: {
 
99
    emit(event_WA_SKIN_MONOSTER_STEREO_TRUE());
 
100
    break;
 
101
  }
 
102
  case _WA_SKIN_MONOSTER_STEREO_FALSE: {
 
103
    emit(event_WA_SKIN_MONOSTER_STEREO_FALSE());
 
104
    break;
 
105
  }
 
106
  case _WA_SKIN_MONOSTER_MONO_TRUE: {
 
107
    emit(event_WA_SKIN_MONOSTER_MONO_TRUE());
 
108
    break;
 
109
  }
 
110
  case _WA_SKIN_MONOSTER_MONO_FALSE: {
 
111
    emit(event_WA_SKIN_MONOSTER_MONO_FALSE());
 
112
    break;
 
113
  }
 
114
  case _WA_SKIN_NUMBERS: {
 
115
    emit(event_WA_SKIN_NUMBERS());
 
116
    break;
 
117
  }
 
118
  case _WA_SKIN_NUMBERS_MINUS: {
 
119
    emit(event_WA_SKIN_NUMBERS_MINUS());
 
120
    break;
 
121
  } 
 
122
  case _WA_SKIN_SHUFREP_REPEAT_NOT_SET_NORM: {
 
123
    emit(event_WA_SKIN_SHUFREP_REPEAT_NOT_SET_NORM());
 
124
    break;
 
125
  }
 
126
  case _WA_SKIN_SHUFREP_REPEAT_NOT_SET_PRES: {
 
127
    emit(event_WA_SKIN_SHUFREP_REPEAT_NOT_SET_PRES());
 
128
    break;
 
129
  }
 
130
  case _WA_SKIN_SHUFREP_REPEAT_SET_NORM: {
 
131
    emit(event_WA_SKIN_SHUFREP_REPEAT_SET_NORM());
 
132
    break;
 
133
  }
 
134
  case _WA_SKIN_SHUFREP_REPEAT_SET_PRES: {
 
135
    emit(event_WA_SKIN_SHUFREP_REPEAT_SET_PRES());
 
136
    break;
 
137
  }
 
138
  case _WA_SKIN_SHUFREP_SHUFFLE_NOT_SET_NORM: {
 
139
    emit(event_WA_SKIN_SHUFREP_SHUFFLE_NOT_SET_NORM());
 
140
    break;
 
141
  }
 
142
  case _WA_SKIN_SHUFREP_SHUFFLE_NOT_SET_PRES: {
 
143
    emit(event_WA_SKIN_SHUFREP_SHUFFLE_NOT_SET_PRES());
 
144
    break;
 
145
  }
 
146
  case _WA_SKIN_SHUFREP_SHUFFLE_SET_NORM: {
 
147
    emit(event_WA_SKIN_SHUFREP_SHUFFLE_SET_NORM());
 
148
    break;
 
149
  }
 
150
  case _WA_SKIN_SHUFREP_SHUFFLE_SET_PRES: {
 
151
    emit(event_WA_SKIN_SHUFREP_SHUFFLE_SET_PRES());
 
152
    break;
 
153
  }
 
154
  case _WA_SKIN_SHUFREP_PLAYLIST_NOT_SET_NORM: {
 
155
    emit(event_WA_SKIN_SHUFREP_PLAYLIST_NOT_SET_NORM());
 
156
    break;
 
157
  }
 
158
  case _WA_SKIN_SHUFREP_PLAYLIST_NOT_SET_PRES: {
 
159
    emit(event_WA_SKIN_SHUFREP_PLAYLIST_NOT_SET_PRES());
 
160
    break;
 
161
  }
 
162
  case _WA_SKIN_SHUFREP_PLAYLIST_SET_NORM: {
 
163
    emit(event_WA_SKIN_SHUFREP_PLAYLIST_SET_NORM());
 
164
    break;
 
165
  }
 
166
  case _WA_SKIN_SHUFREP_PLAYLIST_SET_PRES: {
 
167
    emit(event_WA_SKIN_SHUFREP_PLAYLIST_SET_PRES());
 
168
    break;
 
169
  }
 
170
  case _WA_SKIN_SHUFREP_EQ_SET_NORM: {
 
171
    emit(event_WA_SKIN_SHUFREP_EQ_SET_NORM());
 
172
    break;
 
173
  }
 
174
  case _WA_SKIN_SHUFREP_EQ_SET_PRES: {
 
175
    emit(event_WA_SKIN_SHUFREP_EQ_SET_PRES());
 
176
    break;
 
177
  }
 
178
  case _WA_SKIN_SHUFREP_EQ_NOT_SET_NORM: {
 
179
    emit(event_WA_SKIN_SHUFREP_EQ_NOT_SET_NORM());
 
180
    break;
 
181
  }
 
182
  case _WA_SKIN_SHUFREP_EQ_NOT_SET_PRES: {
 
183
    emit(event_WA_SKIN_SHUFREP_EQ_NOT_SET_PRES());
 
184
    break;
 
185
  }
 
186
  case _WA_SKIN_TEXT: {
 
187
    emit(event_WA_SKIN_TEXT());
 
188
    break;
 
189
  }
 
190
  case _WA_SKIN_VOLUME_BAR: {
 
191
    emit(event_WA_SKIN_VOLUME_BAR());
 
192
    break;
 
193
  }
 
194
  case _WA_SKIN_VOLUME_BAR_ALL_BARS: {
 
195
    break;
 
196
  }
 
197
  case _WA_SKIN_VOLUME_SLIDER_NORM: {
 
198
    emit(event_WA_SKIN_VOLUME_SLIDER_NORM());
 
199
    break;
 
200
  }
 
201
  case _WA_SKIN_VOLUME_SLIDER_PRES: {
 
202
    emit(event_WA_SKIN_VOLUME_SLIDER_PRES());
 
203
    break;
 
204
  }
 
205
  case _WA_SKIN_BALANCE_BAR: {
 
206
    emit(event_WA_SKIN_BALANCE_BAR());
 
207
    break;
 
208
  }
 
209
  case _WA_SKIN_BALANCE_SLIDER_NORM: {
 
210
    emit(event_WA_SKIN_BALANCE_SLIDER_NORM());
 
211
    break;
 
212
  }
 
213
  case _WA_SKIN_BALANCE_SLIDER_PRES: {
 
214
    emit(event_WA_SKIN_BALANCE_SLIDER_PRES());
 
215
    break;
 
216
  }
 
217
  case _WA_SKIN_POS_BAR: {
 
218
    emit(event_WA_SKIN_POS_BAR());
 
219
    break;
 
220
  }
 
221
  case _WA_SKIN_POS_BAR_SLIDER_NORM: {
 
222
    emit(event_WA_SKIN_POS_BAR_SLIDER_NORM());
 
223
    break;
 
224
  }
 
225
  case _WA_SKIN_POS_BAR_SLIDER_PRES: {
 
226
    emit(event_WA_SKIN_POS_BAR_SLIDER_PRES());
 
227
    break;
 
228
  }
 
229
  case _WA_SKIN_PLAYPAUS_PLAY: {
 
230
    emit(event_WA_SKIN_PLAYPAUS_PLAY());
 
231
    break;
 
232
  }
 
233
  case _WA_SKIN_PLAYPAUS_PAUSE: {
 
234
    emit(event_WA_SKIN_PLAYPAUS_PAUSE());
 
235
    break;
 
236
  }
 
237
  case _WA_SKIN_PLAYPAUS_STOP: {
 
238
    emit(event_WA_SKIN_PLAYPAUS_STOP());
 
239
    break;
 
240
  }
 
241
  case _WA_SKIN_TITLE: {
 
242
        emit(event_WA_SKIN_TITLE());
 
243
        break;
 
244
  }
 
245
  case _WA_SKIN_TITLE_SHADE_PRES: {
 
246
        emit(event_WA_SKIN_TITLE_SHADE_PRES());
 
247
  }
 
248
  case _WA_SKIN_TITLE_SHADE_NORM: {
 
249
        emit (event_WA_SKIN_TITLE_SHADE_NORM());
 
250
  }
 
251
 
 
252
  default:
 
253
    back=false;
 
254
  }
 
255
  return back;
 
256
}
 
257
 
 
258
 
 
259
QPixmap* WaSkinModell::get(int id) {
 
260
  QPixmap* back;
 
261
  if ((id < 0) || (id >= _WA_SKIN_ENTRIES)) {
 
262
    return NULL;
 
263
  }
 
264
  back=waSkinDesc[id].getPixmap();
 
265
  return back;
 
266
}
 
267
 
 
268
  
 
269
 
 
270
WaSkinDesc* WaSkinModell::getWaSkinDesc(int id) {
 
271
  if ((id < 0) || (id >= _WA_SKIN_ENTRIES)) {
 
272
    return NULL;
 
273
  }
 
274
  WaSkinDesc* back=&(waSkinDesc[id]);
 
275
  return back;
 
276
}
 
277
 
 
278
 
 
279
WaSkinDesc* WaSkinModell::getWaSkinMapDesc(int id) {
 
280
  if ((id < 0) || (id >= _WA_MAPPING_ENTRIES)) {
 
281
    return NULL;
 
282
  }
 
283
  WaSkinDesc* back=&(waSkinMap[id]);
 
284
  return back;
 
285
}
 
286
 
 
287
 
 
288
 
 
289
QPixmap* WaSkinModell::get(int id,int argument) {
 
290
 
 
291
  switch (id) {
 
292
  case _WA_SKIN_POS_BAR : {
 
293
    QPixmap* dest=get(_WA_SKIN_POS_BAR);
 
294
    return dest;
 
295
    break;
 
296
  }    
 
297
  case _WA_SKIN_VOLUME_BAR : {
 
298
    int percent=argument;
 
299
    QPixmap* allBars=get(_WA_SKIN_VOLUME_BAR_ALL_BARS);
 
300
    QPixmap* dest=get(_WA_SKIN_VOLUME_BAR);
 
301
    int nBar=(int)((float)percent*(float)28/(float)100);
 
302
    bitBlt(dest,0,0,allBars,0,15*nBar,68,13);
 
303
    return dest;
 
304
    break;
 
305
  }    
 
306
  case _WA_SKIN_BALANCE_BAR : {
 
307
    int percent=argument;
 
308
    QPixmap* allBars=get(_WA_SKIN_VOLUME_BAR_ALL_BARS);
 
309
    QPixmap* dest=get(_WA_SKIN_BALANCE_BAR);
 
310
    if (percent < 0) {
 
311
      percent=-1*percent;
 
312
    }
 
313
      
 
314
    int nBar=(int)((float)percent*(float)28/(float)100);
 
315
    bitBlt(dest,0,0,allBars,0,15*nBar,68,13);
 
316
    return dest;
 
317
    break;
 
318
  }    
 
319
  default: {
 
320
 
 
321
  }
 
322
  }
 
323
  QPixmap* dest=get(_WA_SKIN_VOLUME_BAR);
 
324
  return dest;
 
325
}
 
326
 
 
327
 
 
328
void WaSkinModell::getNumber(int id,char cNumber,QPixmap* dest) {
 
329
 
 
330
  switch (id) {
 
331
  case _WA_SKIN_NUMBERS : {
 
332
    if (cNumber=='-') {
 
333
      QPixmap* pix=get(_WA_SKIN_NUMBERS_MINUS);
 
334
      dest->resize(pix->width(),pix->height());
 
335
      bitBlt(dest,0,0,pix);
 
336
      return;
 
337
    }
 
338
    // number
 
339
    QPixmap* pix=get(_WA_SKIN_NUMBERS);
 
340
    dest->resize(9,13);
 
341
    // empty number ?
 
342
    if (cNumber==' ') {
 
343
      bitBlt(dest,0,0,pix,10*9,0,9,13);
 
344
      return;
 
345
    }
 
346
    // ordinary number:
 
347
    int number=cNumber-'0';
 
348
    if ((number < 0) || (number > 9)) {
 
349
      return;
 
350
    }
 
351
    bitBlt(dest,0,0,pix,number*9,0,9,13);
 
352
    return;
 
353
    break;
 
354
  }
 
355
  case _WA_SKIN_TEXT: {
 
356
    getText(cNumber,dest);
 
357
    break;
 
358
  }
 
359
  
 
360
  default: {
 
361
 
 
362
  }
 
363
  }
 
364
  return ;
 
365
}
 
366
 
 
367
 
 
368
 
 
369
void WaSkinModell::getText(char zeichen,QPixmap* dest) {
 
370
  QPixmap* pix=get(_WA_SKIN_TEXT);
 
371
  dest->resize(5,6);
 
372
  if (('A' <= zeichen) && (zeichen <= 'Z')) {
 
373
    bitBlt(dest,0,0,pix,(zeichen-'A')*5,0,5,6);
 
374
    return;
 
375
  }
 
376
  if (('a' <= zeichen) && (zeichen <= 'z')) {
 
377
    bitBlt(dest,0,0,pix,(zeichen-'a')*5,0,5,6);
 
378
    return;
 
379
  }
 
380
  if (('0' <= zeichen) && (zeichen <= '9')) {
 
381
    bitBlt(dest,0,0,pix,(zeichen-'0')*5,6,5,6);
 
382
    return;
 
383
  }  
 
384
  if ('"' == zeichen) {
 
385
    bitBlt(dest,0,0,pix,27*5,0,5,6);
 
386
    return;
 
387
  }
 
388
  if ('@' == zeichen) {
 
389
    bitBlt(dest,0,0,pix,28*5,0,5,6);
 
390
    return;
 
391
  }
 
392
 
 
393
 
 
394
  if ('.' == zeichen) {
 
395
    bitBlt(dest,0,0,pix,11*5,6,5,6);
 
396
    return;
 
397
  }
 
398
  if (':' == zeichen) {
 
399
    bitBlt(dest,0,0,pix,12*5,6,5,6);
 
400
    return;
 
401
  }  
 
402
  if ('(' == zeichen) {
 
403
    bitBlt(dest,0,0,pix,13*5,6,5,6);
 
404
    return;
 
405
  }  
 
406
  if (')' == zeichen) {
 
407
    bitBlt(dest,0,0,pix,14*5,6,5,6);
 
408
    return;
 
409
  }          
 
410
  if ('-' == zeichen) {
 
411
    bitBlt(dest,0,0,pix,15*5,6,5,6);
 
412
    return;
 
413
  }          
 
414
  if ('`' == zeichen) {
 
415
    bitBlt(dest,0,0,pix,16*5,6,5,6);
 
416
    return;
 
417
  } 
 
418
  if ('!' == zeichen) {
 
419
    bitBlt(dest,0,0,pix,17*5,6,5,6);
 
420
    return;
 
421
  } 
 
422
  if ('_' == zeichen) {
 
423
    bitBlt(dest,0,0,pix,18*5,6,5,6);
 
424
    return;
 
425
  } 
 
426
  if ('+' == zeichen) {
 
427
    bitBlt(dest,0,0,pix,19*5,6,5,6);
 
428
    return;
 
429
  } 
 
430
  if ('\\' == zeichen) {
 
431
    bitBlt(dest,0,0,pix,20*5,6,5,6);
 
432
    return;
 
433
  }  
 
434
  if ('/' == zeichen) {
 
435
    bitBlt(dest,0,0,pix,21*5,6,5,6);
 
436
    return;
 
437
  }  
 
438
  if ('[' == zeichen) {
 
439
    bitBlt(dest,0,0,pix,22*5,6,5,6);
 
440
    return;
 
441
  }  
 
442
  if (']' == zeichen) {
 
443
    bitBlt(dest,0,0,pix,23*5,6,5,6);
 
444
    return;
 
445
  } 
 
446
  if ('^' == zeichen) {
 
447
    bitBlt(dest,0,0,pix,24*5,6,5,6);
 
448
    return;
 
449
  } 
 
450
  if ('&' == zeichen) {
 
451
    bitBlt(dest,0,0,pix,25*5,6,5,6);
 
452
    return;
 
453
  } 
 
454
  if ('%' == zeichen) {
 
455
    bitBlt(dest,0,0,pix,26*5,6,5,6);
 
456
    return;
 
457
  } 
 
458
  if (',' == zeichen) {
 
459
    bitBlt(dest,0,0,pix,27*5,6,5,6);
 
460
    return;
 
461
  } 
 
462
  if ('=' == zeichen) {
 
463
    bitBlt(dest,0,0,pix,28*5,6,5,6);
 
464
    return;
 
465
  } 
 
466
  if ('$' == zeichen) {
 
467
    bitBlt(dest,0,0,pix,29*5,6,5,6);
 
468
    return;
 
469
  } 
 
470
  if ('#' == zeichen) {
 
471
    bitBlt(dest,0,0,pix,30*5,6,5,6);
 
472
    return;
 
473
  } 
 
474
  if (('�' == zeichen) || ('�' == zeichen)) {
 
475
    bitBlt(dest,0,0,pix,0*5,12,5,6);
 
476
    return;
 
477
  } 
 
478
  if (('�' == zeichen) || ('�' == zeichen)) {
 
479
    bitBlt(dest,0,0,pix,1*5,12,5,6);
 
480
    return;
 
481
  } 
 
482
  if (('�' == zeichen) || ('�' == zeichen)) {
 
483
    bitBlt(dest,0,0,pix,2*5,12,5,6);
 
484
    return;
 
485
  } 
 
486
  if ('?' == zeichen) {
 
487
    bitBlt(dest,0,0,pix,3*5,12,5,6);
 
488
    return;
 
489
  }     
 
490
  if ('*' == zeichen) {
 
491
    bitBlt(dest,0,0,pix,4*5,12,5,6);
 
492
    return;
 
493
  }   
 
494
  // default back is space char
 
495
  bitBlt(dest,0,0,pix,(10*5),12,5,6);
 
496
 
 
497
}
 
498
 
 
499
    
 
500
 
 
501
void WaSkinModell::setSkinDirectory(QString dir) {
 
502
  skinDir=dir;
 
503
}
 
504
 
 
505
 
 
506
QString WaSkinModell::getSkinDirectory() {
 
507
  return skinDir;
 
508
}
 
509
 
 
510
 
 
511
#include "waSkinModell.moc"