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

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/winskin/waDigit.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
  The digit for the time
 
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
#include <waDigit.h>
 
15
 
 
16
 
 
17
 
 
18
 
 
19
WaDigit::WaDigit(WaSkinModell* waSkinModell,QWidget* parent,char* name):
 
20
 QWidget(parent,name) {
 
21
  this->waSkinModell=waSkinModell;
 
22
  
 
23
  connect(waSkinModell,
 
24
          SIGNAL(event_WA_SKIN_NUMBERS()),this,SLOT(pixmapChange()));
 
25
 
 
26
 
 
27
  digit1=new QPixmap();
 
28
  digit2=new QPixmap();
 
29
  digit3=new QPixmap();
 
30
  digit4=new QPixmap();
 
31
  minus=new QPixmap();
 
32
  background=new QPixmap();
 
33
 
 
34
  reloadBackground();
 
35
}
 
36
 
 
37
WaDigit::~WaDigit() {
 
38
  delete digit1;
 
39
  delete digit2;
 
40
  delete digit3;
 
41
  delete digit4;
 
42
  delete minus;
 
43
  delete background;
 
44
}
 
45
 
 
46
 
 
47
QSize WaDigit::sizeHint() const {
 
48
  return QSize(63,13);
 
49
}
 
50
 
 
51
 
 
52
void WaDigit::setTime(QString time) {
 
53
  timeString=time;
 
54
  pixmapChange();
 
55
}
 
56
 
 
57
 
 
58
QString WaDigit::getTime() {
 
59
  return timeString;
 
60
}
 
61
 
 
62
void WaDigit::paintEvent (QPaintEvent* paintEvent) {
 
63
  const char* timeString=getTime().latin1();
 
64
  int len=strlen(timeString);
 
65
  char cMinus=' ';
 
66
  char cDigit1=' ';
 
67
  char cDigit2=' ';
 
68
  char cDigit3=' ';
 
69
  char cDigit4=' ';
 
70
  
 
71
  if (len == 0) {
 
72
    return;
 
73
  }
 
74
  cMinus='-';
 
75
  int match=sscanf(timeString,"-%c%c:%c%c",
 
76
                   &cDigit1,&cDigit2,&cDigit3,&cDigit4);
 
77
  if (match != 4) {
 
78
    cMinus='-';
 
79
    cDigit1=' ';
 
80
    match=sscanf(timeString,"-%c:%c%c",&cDigit2,&cDigit3,&cDigit4);
 
81
    match++;
 
82
  }
 
83
 
 
84
  if (match != 4) {
 
85
    cMinus=' ';
 
86
    cDigit1=' ';
 
87
    match=sscanf(timeString,"%c:%c%c",&cDigit2,&cDigit3,&cDigit4);
 
88
    match++;
 
89
  }
 
90
  if (match != 4) {
 
91
    cMinus=' ';
 
92
    match=sscanf(timeString,"%c%c:%c%c",&cDigit1,&cDigit2,&cDigit3,&cDigit4);
 
93
  }
 
94
 
 
95
  if (match != 4) {
 
96
    return;
 
97
  }
 
98
    
 
99
  waSkinModell->getNumber(_WA_SKIN_NUMBERS,cMinus,minus);
 
100
  waSkinModell->getNumber(_WA_SKIN_NUMBERS,cDigit1,digit1);
 
101
  waSkinModell->getNumber(_WA_SKIN_NUMBERS,cDigit2,digit2);
 
102
  waSkinModell->getNumber(_WA_SKIN_NUMBERS,cDigit3,digit3);
 
103
  waSkinModell->getNumber(_WA_SKIN_NUMBERS,cDigit4,digit4);
 
104
 
 
105
 
 
106
  QPainter paint;
 
107
  WaSkinDesc* mapDesc;
 
108
  int x=40;
 
109
  int y=26;
 
110
  move(x,y);
 
111
  paint.begin(this);
 
112
  paint.drawPixmap(0,0,*background);
 
113
  mapDesc=waSkinModell->getWaSkinMapDesc(_WA_MAPPING_MINUS);
 
114
  paint.drawPixmap(mapDesc->getWidgetX()-x,mapDesc->getWidgetY()-y,
 
115
                   *minus);
 
116
 
 
117
  mapDesc=waSkinModell->getWaSkinMapDesc(_WA_MAPPING_DIGIT_1);
 
118
  paint.drawPixmap(mapDesc->getWidgetX()-x,mapDesc->getWidgetY()-y,
 
119
                   *digit1);
 
120
 
 
121
  mapDesc=waSkinModell->getWaSkinMapDesc(_WA_MAPPING_DIGIT_2);
 
122
  paint.drawPixmap(mapDesc->getWidgetX()-x,mapDesc->getWidgetY()-y,
 
123
                   *digit2);
 
124
  
 
125
  mapDesc=waSkinModell->getWaSkinMapDesc(_WA_MAPPING_DIGIT_3);
 
126
  paint.drawPixmap(mapDesc->getWidgetX()-x,mapDesc->getWidgetY()-y,
 
127
                   *digit3);
 
128
  
 
129
  mapDesc=waSkinModell->getWaSkinMapDesc(_WA_MAPPING_DIGIT_4);
 
130
  paint.drawPixmap(mapDesc->getWidgetX()-x,mapDesc->getWidgetY()-y,
 
131
                   *digit4);
 
132
  paint.end();  
 
133
  
 
134
  
 
135
}
 
136
    
 
137
 
 
138
void WaDigit::pixmapChange() {
 
139
  reloadBackground();
 
140
  repaint(false);
 
141
}
 
142
 
 
143
void WaDigit::reloadBackground() {
 
144
  QPixmap* pix=waSkinModell->get(_WA_SKIN_MAIN);
 
145
  QSize size=sizeHint();
 
146
  background->resize(size.width(),size.height());
 
147
  bitBlt(background,0,0,pix,40,26,size.width(),size.height());
 
148
  setBackgroundPixmap(*background);
 
149
}
 
150
 
 
151
#include "waDigit.moc"