1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/***************************************************************************
picture.cpp - description
-------------------
begin : Mon Aug 19 2002
copyright : (C) 2002 by Stefan Winter
email : mail@stefan-winter.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tqwidget.h>
#include <tqpainter.h>
#include <tqpixmap.h>
#include <kstandarddirs.h>
#include "picture.h"
#include "interface_wireless.h"
#define X_OFFSET 20
#define Y_OFFSET 10
Picture::Picture (TQWidget * tqparent, Interface_wireless * device):TQWidget (tqparent,
"picture")
{
this->device = device;
KStandardDirs finder;
kdedir = finder.findResourceDir ("data", "kwifimanager/pics/no_card.png");
kdedir += "kwifimanager/pics/";
NO_CARD = new TQPixmap (kdedir + "no_card.png");
AD_HOC = new TQPixmap (kdedir + "ad_hoc.png");
ALL_ALONE = new TQPixmap (kdedir + "all_alone.png");
AP_CONNECT = new TQPixmap (kdedir + "ap_connect.png");
}
TQSize Picture::mySizeHint() {
/* make this quite general, just in case someone uses different icons */
TQSize* temp = new TQSize(NO_CARD->size());
if (AD_HOC->size().width() > temp->width ()) { temp->setWidth (AD_HOC->size().width ()); }
if (AD_HOC->size().height() > temp->height()) { temp->setHeight(AD_HOC->size().height()); }
if (ALL_ALONE->size().width() > temp->width ()) { temp->setWidth (ALL_ALONE->size().width ()); }
if (ALL_ALONE->size().height() > temp->height()) { temp->setHeight(ALL_ALONE->size().height()); }
if (AP_CONNECT->size().width() > temp->width ()) { temp->setWidth (AP_CONNECT->size().width ()); }
if (AP_CONNECT->size().height() > temp->height()) { temp->setHeight(AP_CONNECT->size().height()); }
temp->setWidth (temp->width() + X_OFFSET);
temp->setHeight(temp->height() + Y_OFFSET);
return *temp;
}
Picture::~Picture ()
{
delete NO_CARD;
delete AD_HOC;
delete ALL_ALONE;
delete AP_CONNECT;
}
void
Picture::paintEvent (TQPaintEvent *)
{
TQPainter *picturepainter = new TQPainter (this);
double freq;
int mode;
device->get_mode (mode);
int sig, noise, qual;
device->get_current_quality (sig, noise, qual);
if (!device->get_device_freq (freq) || device->get_txpower_disabled())
{
picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *NO_CARD);
}
else if (mode == 1)
{
picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *AD_HOC);
}
else if (qual == 0)
{
picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *ALL_ALONE);
}
else if (qual > 0)
{
picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *AP_CONNECT);
}
else
picturepainter->drawPixmap (X_OFFSET, Y_OFFSET, *NO_CARD);
delete picturepainter;
}
|