summaryrefslogtreecommitdiffstats
path: root/client/buttonimage.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-01 21:17:46 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-01 21:17:46 +0000
commit21a1d3cffb820b001b0901f8e82d4c8bfc5e1683 (patch)
treead9d08bc725d963acafab219a33699ae2d6e723c /client/buttonimage.cpp
parent424422475d6f30da2b84041dcb2b13b425126f04 (diff)
downloadtwin-style-crystal-21a1d3cffb820b001b0901f8e82d4c8bfc5e1683.tar.gz
twin-style-crystal-21a1d3cffb820b001b0901f8e82d4c8bfc5e1683.zip
TQt4 port kwin-style-crystal
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kwin-style-crystal@1239032 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'client/buttonimage.cpp')
-rw-r--r--client/buttonimage.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/client/buttonimage.cpp b/client/buttonimage.cpp
index c195eed..a55d29e 100644
--- a/client/buttonimage.cpp
+++ b/client/buttonimage.cpp
@@ -19,7 +19,7 @@
***************************************************************************/
-#include <qimage.h>
+#include <tqimage.h>
#include <math.h>
#include <kimageeffect.h>
@@ -29,14 +29,14 @@
-ButtonImage::ButtonImage(const QRgb *d_normal,int w,int h)
+ButtonImage::ButtonImage(const TQRgb *d_normal,int w,int h)
{
normal=hovered=pressed=animated=NULL;
image_width=w;
image_height=h;
normal_data=hovered_data=animated_data=pressed_data=NULL;
org_normal_data=org_hovered_data=NULL;
- normal_color=hovered_color=pressed_color=QColor(255,255,255);
+ normal_color=hovered_color=pressed_color=TQColor(255,255,255);
reset();
if (d_normal)SetNormal(d_normal,w,h);
}
@@ -55,10 +55,10 @@ ButtonImage::~ButtonImage()
if (org_hovered_data)delete[] org_hovered_data;
}
-QImage ButtonImage::CreateImage(QRgb *data,QColor color)
+TQImage ButtonImage::CreateImage(TQRgb *data,TQColor color)
{
tint(data,color);
- QImage img=QImage((uchar*)data,image_width,image_height,32,NULL,0,QImage::LittleEndian),img2;
+ TQImage img=TQImage((uchar*)data,image_width,image_height,32,NULL,0,TQImage::LittleEndian),img2;
img.setAlphaBuffer(true);
return img;
@@ -86,7 +86,7 @@ void ButtonImage::reset()
drawMode=0;
}
-void ButtonImage::SetNormal(const QRgb *d_normal,int w,int h)
+void ButtonImage::SetNormal(const TQRgb *d_normal,int w,int h)
{
image_width=w;
image_height=h;
@@ -101,25 +101,25 @@ void ButtonImage::SetNormal(const QRgb *d_normal,int w,int h)
pressed_data=NULL;
if (normal_data)delete[] normal_data;
- org_normal_data=new QRgb[image_width*image_height];
- memcpy(org_normal_data,d_normal,sizeof(QRgb)*image_width*image_height);
- normal_data=new QRgb[image_width*image_height];
- memcpy(normal_data,d_normal,sizeof(QRgb)*image_width*image_height);
- normal=new QImage(CreateImage(normal_data,normal_color));
+ org_normal_data=new TQRgb[image_width*image_height];
+ memcpy(org_normal_data,d_normal,sizeof(TQRgb)*image_width*image_height);
+ normal_data=new TQRgb[image_width*image_height];
+ memcpy(normal_data,d_normal,sizeof(TQRgb)*image_width*image_height);
+ normal=new TQImage(CreateImage(normal_data,normal_color));
}
-void ButtonImage::SetHovered(const QRgb *d_hovered)
+void ButtonImage::SetHovered(const TQRgb *d_hovered)
{
if (hovered)delete hovered;
if (hovered_data)delete[] hovered_data;
if (org_hovered_data)delete[] org_hovered_data;
if (d_hovered)
{
- org_hovered_data=new QRgb[image_width*image_height];
- hovered_data=new QRgb[image_width*image_height];
- memcpy(hovered_data,d_hovered,sizeof(QRgb)*image_width*image_height);
- memcpy(org_hovered_data,d_hovered,sizeof(QRgb)*image_width*image_height);
- hovered=new QImage(CreateImage(hovered_data,hovered_color));
+ org_hovered_data=new TQRgb[image_width*image_height];
+ hovered_data=new TQRgb[image_width*image_height];
+ memcpy(hovered_data,d_hovered,sizeof(TQRgb)*image_width*image_height);
+ memcpy(org_hovered_data,d_hovered,sizeof(TQRgb)*image_width*image_height);
+ hovered=new TQImage(CreateImage(hovered_data,hovered_color));
}else{
hovered=NULL;
hovered_data=NULL;
@@ -127,15 +127,15 @@ void ButtonImage::SetHovered(const QRgb *d_hovered)
}
}
-void ButtonImage::SetPressed(const QRgb *d_pressed)
+void ButtonImage::SetPressed(const TQRgb *d_pressed)
{
if (pressed)delete pressed;
if (pressed_data)delete[] pressed_data;
if (d_pressed)
{
- pressed_data=new QRgb[image_width*image_height];
- memcpy(pressed_data,d_pressed,sizeof(QRgb)*image_width*image_height);
- pressed=new QImage(CreateImage(pressed_data,pressed_color));
+ pressed_data=new TQRgb[image_width*image_height];
+ memcpy(pressed_data,d_pressed,sizeof(TQRgb)*image_width*image_height);
+ pressed=new TQImage(CreateImage(pressed_data,pressed_color));
}else{
pressed=NULL;
pressed_data=NULL;
@@ -156,22 +156,22 @@ void ButtonImage::finish()
}
if (!hovered_data){
- hovered_data=new QRgb[image_width*image_height];
+ hovered_data=new TQRgb[image_width*image_height];
float faktor=::factory->hovereffect?0.5:1.0;
for (int i=0;i<image_width*image_height;i++)
{
- hovered_data[i]=qRgba(qRed(org_normal_data[i]),qGreen(org_normal_data[i]),qBlue(org_normal_data[i]),
- (int)(255.0*pow((float)qAlpha(org_normal_data[i])/255.0,faktor)));
+ hovered_data[i]=tqRgba(tqRed(org_normal_data[i]),tqGreen(org_normal_data[i]),tqBlue(org_normal_data[i]),
+ (int)(255.0*pow((float)tqAlpha(org_normal_data[i])/255.0,faktor)));
}
if (org_hovered_data)delete[] org_hovered_data;
- org_hovered_data=new QRgb[image_width*image_height];
- memcpy(org_hovered_data,hovered_data,sizeof(QRgb)*image_width*image_height);
- hovered=new QImage(CreateImage(hovered_data,hovered_color));
+ org_hovered_data=new TQRgb[image_width*image_height];
+ memcpy(org_hovered_data,hovered_data,sizeof(TQRgb)*image_width*image_height);
+ hovered=new TQImage(CreateImage(hovered_data,hovered_color));
}
if (!pressed_data){
float faktor=::factory->hovereffect?0.5:0.4;
- pressed_data=new QRgb[image_width*image_height];
+ pressed_data=new TQRgb[image_width*image_height];
if (!org_hovered_data)
{
org_hovered_data=hovered_data;
@@ -180,37 +180,37 @@ void ButtonImage::finish()
for (int i=0;i<image_width*image_height;i++)
{
- pressed_data[i]=qRgba(qRed(org_hovered_data[i]),qGreen(org_hovered_data[i]),qBlue(org_hovered_data[i]),
- (int)(255.0*pow((float)qAlpha(org_hovered_data[i])/255.0,faktor)));
+ pressed_data[i]=tqRgba(tqRed(org_hovered_data[i]),tqGreen(org_hovered_data[i]),tqBlue(org_hovered_data[i]),
+ (int)(255.0*pow((float)tqAlpha(org_hovered_data[i])/255.0,faktor)));
}
- pressed=new QImage(CreateImage(pressed_data,pressed_color));
+ pressed=new TQImage(CreateImage(pressed_data,pressed_color));
}
- if (!animated_data)animated_data=new QRgb[image_width*image_height];
+ if (!animated_data)animated_data=new TQRgb[image_width*image_height];
if (!animated)
{
- animated=new QImage((uchar*)animated_data,image_width,image_height,32,NULL,0,QImage::LittleEndian);
+ animated=new TQImage((uchar*)animated_data,image_width,image_height,32,NULL,0,TQImage::LittleEndian);
animated->setAlphaBuffer(true);
}
}
-QImage* ButtonImage::getAnimated( float anim)
+TQImage* ButtonImage::getAnimated( float anim)
{
if (!normal_data)return NULL;
if (!animated_data)return NULL;
for (int i=0;i<image_width*image_height;i++)
{
- const float r1=(float)qRed(normal_data[i])/255.0f;
- const float r2=(float)qRed(hovered_data[i])/255.0f;
- const float g1=(float)qGreen(normal_data[i])/255.0f;
- const float g2=(float)qGreen(hovered_data[i])/255.0f;
- const float b1=(float)qBlue(normal_data[i])/255.0f;
- const float b2=(float)qBlue(hovered_data[i])/255.0f;
- const float a1=(float)qAlpha(normal_data[i])/255.0f;
- const float a2=(float)qAlpha(hovered_data[i])/255.0f;
+ const float r1=(float)tqRed(normal_data[i])/255.0f;
+ const float r2=(float)tqRed(hovered_data[i])/255.0f;
+ const float g1=(float)tqGreen(normal_data[i])/255.0f;
+ const float g2=(float)tqGreen(hovered_data[i])/255.0f;
+ const float b1=(float)tqBlue(normal_data[i])/255.0f;
+ const float b2=(float)tqBlue(hovered_data[i])/255.0f;
+ const float a1=(float)tqAlpha(normal_data[i])/255.0f;
+ const float a2=(float)tqAlpha(hovered_data[i])/255.0f;
- animated_data[i]=qRgba(
+ animated_data[i]=tqRgba(
(int)((r1*(1.0f-anim)+r2*anim)*255.0f),
(int)((g1*(1.0f-anim)+g2*anim)*255.0f),
(int)((b1*(1.0f-anim)+b2*anim)*255.0f),
@@ -220,25 +220,25 @@ QImage* ButtonImage::getAnimated( float anim)
return animated;
}
-void ButtonImage::tint(QRgb *data,QColor color)
+void ButtonImage::tint(TQRgb *data,TQColor color)
{
float f_r=(float)color.red()/255.0;
float f_g=(float)color.green()/255.0;
float f_b=(float)color.blue()/255.0;
for (int i=0;i<image_width*image_height;i++)
{
- float r=(float)qRed(data[i])/255.0;
- float g=(float)qGreen(data[i])/255.0;
- float b=(float)qBlue(data[i])/255.0;
+ float r=(float)tqRed(data[i])/255.0;
+ float g=(float)tqGreen(data[i])/255.0;
+ float b=(float)tqBlue(data[i])/255.0;
r*=f_r;
g*=f_g;
b*=f_b;
- data[i]=qRgba(
+ data[i]=tqRgba(
(int)(r*255.0),
(int)(g*255.0),
(int)(b*255.0),
- qAlpha(data[i]));
+ tqAlpha(data[i]));
}
}