00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022
00023 #include "TQtBrush.h"
00024 #include "TGQt.h"
00025 #include "qbitmap.h"
00026 #include <QDebug>
00027
00028
00029
00030
00031
00032 static uchar p1_bits[] = {
00033 (0xaa),(0xaa),(0x55),(0x55),(0xaa),(0xaa),(0x55),(0x55),(0xaa),(0xaa),(0x55),(0x55),
00034 (0xaa),(0xaa),(0x55),(0x55),(0xaa),(0xaa),(0x55),(0x55),(0xaa),(0xaa),(0x55),(0x55),
00035 (0xaa),(0xaa),(0x55),(0x55),(0xaa),(0xaa),(0x55),(0x55)};
00036 static uchar p2_bits[] = {
00037 (0x44),(0x44),(0x11),(0x11),(0x44),(0x44),(0x11),(0x11),(0x44),(0x44),(0x11),(0x11),
00038 (0x44),(0x44),(0x11),(0x11),(0x44),(0x44),(0x11),(0x11),(0x44),(0x44),(0x11),(0x11),
00039 (0x44),(0x44),(0x11),(0x11),(0x44),(0x44),(0x11),(0x11)};
00040 static uchar p3_bits[] = {
00041 (0x00),(0x00),(0x44),(0x44),(0x00),(0x00),(0x11),(0x11),(0x00),(0x00),(0x44),(0x44),
00042 (0x00),(0x00),(0x11),(0x11),(0x00),(0x00),(0x44),(0x44),(0x00),(0x00),(0x11),(0x11),
00043 (0x00),(0x00),(0x44),(0x44),(0x00),(0x00),(0x11),(0x11)};
00044 static uchar p4_bits[] = {
00045 (0x80),(0x80),(0x40),(0x40),(0x20),(0x20),(0x10),(0x10),(0x08),(0x08),(0x04),(0x04),
00046 (0x02),(0x02),(0x01),(0x01),(0x80),(0x80),(0x40),(0x40),(0x20),(0x20),(0x10),(0x10),
00047 (0x08),(0x08),(0x04),(0x04),(0x02),(0x02),(0x01),(0x01)};
00048 static uchar p5_bits[] = {
00049 (0x20),(0x20),(0x40),(0x40),(0x80),(0x80),(0x01),(0x01),(0x02),(0x02),(0x04),(0x04),
00050 (0x08),(0x08),(0x10),(0x10),(0x20),(0x20),(0x40),(0x40),(0x80),(0x80),(0x01),(0x01),
00051 (0x02),(0x02),(0x04),(0x04),(0x08),(0x08),(0x10),(0x10)};
00052 static uchar p6_bits[] = {
00053 (0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),
00054 (0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),
00055 (0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44)};
00056 static uchar p7_bits[] = {
00057 (0x00),(0x00),(0x00),(0x00),(0x00),(0x00),(0xff),(0xff),(0x00),(0x00),(0x00),(0x00),
00058 (0x00),(0x00),(0xff),(0xff),(0x00),(0x00),(0x00),(0x00),(0x00),(0x00),(0xff),(0xff),
00059 (0x00),(0x00),(0x00),(0x00),(0x00),(0x00),(0xff),(0xff)};
00060 static uchar p8_bits[] = {
00061 (0x11),(0x11),(0xb8),(0xb8),(0x7c),(0x7c),(0x3a),(0x3a),(0x11),(0x11),(0xa3),(0xa3),
00062 (0xc7),(0xc7),(0x8b),(0x8b),(0x11),(0x11),(0xb8),(0xb8),(0x7c),(0x7c),(0x3a),(0x3a),
00063 (0x11),(0x11),(0xa3),(0xa3),(0xc7),(0xc7),(0x8b),(0x8b)};
00064 static uchar p9_bits[] = {
00065 (0x10),(0x10),(0x10),(0x10),(0x28),(0x28),(0xc7),(0xc7),(0x01),(0x01),(0x01),(0x01),
00066 (0x82),(0x82),(0x7c),(0x7c),(0x10),(0x10),(0x10),(0x10),(0x28),(0x28),(0xc7),(0xc7),
00067 (0x01),(0x01),(0x01),(0x01),(0x82),(0x82),(0x7c),(0x7c)};
00068 static uchar p10_bits[] = {
00069 (0x10),(0x10),(0x10),(0x10),(0x10),(0x10),(0xff),(0xff),(0x01),(0x01),(0x01),(0x01),
00070 (0x01),(0x01),(0xff),(0xff),(0x10),(0x10),(0x10),(0x10),(0x10),(0x10),(0xff),(0xff),
00071 (0x01),(0x01),(0x01),(0x01),(0x01),(0x01),(0xff),(0xff)};
00072 static uchar p11_bits[] = {
00073 (0x08),(0x08),(0x49),(0x49),(0x2a),(0x2a),(0x1c),(0x1c),(0x2a),(0x2a),(0x49),(0x49),
00074 (0x08),(0x08),(0x00),(0x00),(0x80),(0x80),(0x94),(0x94),(0xa2),(0xa2),(0xc1),(0xc1),
00075 (0xa2),(0xa2),(0x94),(0x94),(0x80),(0x80),(0x00),(0x00)};
00076 static uchar p12_bits[] = {
00077 (0x1c),(0x1c),(0x22),(0x22),(0x41),(0x41),(0x41),(0x41),(0x41),(0x41),(0x22),(0x22),
00078 (0x1c),(0x1c),(0x00),(0x00),(0xc1),(0xc1),(0x22),(0x22),(0x14),(0x14),(0x14),(0x14),
00079 (0x14),(0x14),(0x22),(0x22),(0xc1),(0xc1),(0x00),(0x00)};
00080 static uchar p13_bits[] = {
00081 (0x01),(0x01),(0x82),(0x82),(0x44),(0x44),(0x28),(0x28),(0x10),(0x10),(0x28),(0x28),
00082 (0x44),(0x44),(0x82),(0x82),(0x01),(0x01),(0x82),(0x82),(0x44),(0x44),(0x28),(0x28),
00083 (0x10),(0x10),(0x28),(0x28),(0x44),(0x44),(0x82),(0x82)};
00084 static uchar p14_bits[] = {
00085 (0xff),(0xff),(0x11),(0x10),(0x11),(0x10),(0x11),(0x10),(0xf1),(0x1f),(0x11),(0x11),
00086 (0x11),(0x11),(0x11),(0x11),(0xff),(0x11),(0x01),(0x11),(0x01),(0x11),(0x01),(0x11),
00087 (0xff),(0xff),(0x01),(0x10),(0x01),(0x10),(0x01),(0x10)};
00088 static uchar p15_bits[] = {
00089 (0x22),(0x22),(0x55),(0x55),(0x22),(0x22),(0x00),(0x00),(0x88),(0x88),(0x55),(0x55),
00090 (0x88),(0x88),(0x00),(0x00),(0x22),(0x22),(0x55),(0x55),(0x22),(0x22),(0x00),(0x00),
00091 (0x88),(0x88),(0x55),(0x55),(0x88),(0x88),(0x00),(0x00)};
00092 static uchar p16_bits[] = {
00093 (0x0e),(0x0e),(0x11),(0x11),(0xe0),(0xe0),(0x00),(0x00),(0x0e),(0x0e),(0x11),(0x11),
00094 (0xe0),(0xe0),(0x00),(0x00),(0x0e),(0x0e),(0x11),(0x11),(0xe0),(0xe0),(0x00),(0x00),
00095 (0x0e),(0x0e),(0x11),(0x11),(0xe0),(0xe0),(0x00),(0x00)};
00096 static uchar p17_bits[] = {
00097 (0x44),(0x44),(0x22),(0x22),(0x11),(0x11),(0x00),(0x00),(0x44),(0x44),(0x22),(0x22),
00098 (0x11),(0x11),(0x00),(0x00),(0x44),(0x44),(0x22),(0x22),(0x11),(0x11),(0x00),(0x00),
00099 (0x44),(0x44),(0x22),(0x22),(0x11),(0x11),(0x00),(0x00)};
00100 static uchar p18_bits[] = {
00101 (0x11),(0x11),(0x22),(0x22),(0x44),(0x44),(0x00),(0x00),(0x11),(0x11),(0x22),(0x22),
00102 (0x44),(0x44),(0x00),(0x00),(0x11),(0x11),(0x22),(0x22),(0x44),(0x44),(0x00),(0x00),
00103 (0x11),(0x11),(0x22),(0x22),(0x44),(0x44),(0x00),(0x00)};
00104 static uchar p19_bits[] = {
00105 (0xe0),(0x03),(0x98),(0x0c),(0x84),(0x10),(0x42),(0x21),(0x42),(0x21),(0x21),(0x42),
00106 (0x19),(0x4c),(0x07),(0xf0),(0x19),(0x4c),(0x21),(0x42),(0x42),(0x21),(0x42),(0x21),
00107 (0x84),(0x10),(0x98),(0x0c),(0xe0),(0x03),(0x80),(0x00)};
00108 static uchar p20_bits[] = {
00109 (0x22),(0x22),(0x11),(0x11),(0x11),(0x11),(0x11),(0x11),(0x22),(0x22),(0x44),(0x44),
00110 (0x44),(0x44),(0x44),(0x44),(0x22),(0x22),(0x11),(0x11),(0x11),(0x11),(0x11),(0x11),
00111 (0x22),(0x22),(0x44),(0x44),(0x44),(0x44),(0x44),(0x44)};
00112 static uchar p21_bits[] = {
00113 (0xf1),(0xf1),(0x10),(0x10),(0x10),(0x10),(0x10),(0x10),(0x1f),(0x1f),(0x01),(0x01),
00114 (0x01),(0x01),(0x01),(0x01),(0xf1),(0xf1),(0x10),(0x10),(0x10),(0x10),(0x10),(0x10),
00115 (0x1f),(0x1f),(0x01),(0x01),(0x01),(0x01),(0x01),(0x01)};
00116 static uchar p22_bits[] = {
00117 (0x8f),(0x8f),(0x08),(0x08),(0x08),(0x08),(0x08),(0x08),(0xf8),(0xf8),(0x80),(0x80),
00118 (0x80),(0x80),(0x80),(0x80),(0x8f),(0x8f),(0x08),(0x08),(0x08),(0x08),(0x08),(0x08),
00119 (0xf8),(0xf8),(0x80),(0x80),(0x80),(0x80),(0x80),(0x80)};
00120 static uchar p23_bits[] = {
00121 (0xAA),(0xAA),(0x55),(0x55),(0x6a),(0x6a),(0x74),(0x74),(0x78),(0x78),(0x74),(0x74),
00122 (0x6a),(0x6a),(0x55),(0x55),(0xAA),(0xAA),(0x55),(0x55),(0x6a),(0x6a),(0x74),(0x74),
00123 (0x78),(0x78),(0x74),(0x74),(0x6a),(0x6a),(0x55),(0x55)};
00124 static uchar p24_bits[] = {
00125 (0x80),(0x00),(0xc0),(0x00),(0xea),(0xa8),(0xd5),(0x54),(0xea),(0xa8),(0xd5),(0x54),
00126 (0xeb),(0xe8),(0xd5),(0xd4),(0xe8),(0xe8),(0xd4),(0xd4),(0xa8),(0xe8),(0x54),(0xd5),
00127 (0xa8),(0xea),(0x54),(0xd5),(0xfc),(0xff),(0xfe),(0xff)};
00128 static uchar p25_bits[] = {
00129 (0x80),(0x00),(0xc0),(0x00),(0xe0),(0x00),(0xf0),(0x00),(0xff),(0xf0),(0xff),(0xf0),
00130 (0xfb),(0xf0),(0xf9),(0xf0),(0xf8),(0xf0),(0xf8),(0x70),(0xf8),(0x30),(0xff),(0xf0),
00131 (0xff),(0xf8),(0xff),(0xfc),(0xff),(0xfe),(0xff),(0xff)};
00132
00133
00134 static uchar *patter_bits[]= { p1_bits, p2_bits, p3_bits, p4_bits, p5_bits,
00135 p6_bits, p7_bits, p8_bits, p9_bits, p10_bits,
00136 p11_bits, p12_bits, p13_bits, p14_bits, p15_bits,
00137 p16_bits, p17_bits, p18_bits, p19_bits, p20_bits,
00138 p21_bits, p22_bits, p23_bits, p24_bits, p25_bits};
00139
00140 ClassImp(TQtBrush)
00141
00142 TQtBrush::TQtBrush(): QBrush(),fStyle(0),fFasi(0),fAlpha(255)
00143 {}
00144
00145 TQtBrush::TQtBrush(const TAttFill &rootFillAttributes)
00146 {
00147
00148 SetFillAttributes(rootFillAttributes);
00149
00150 }
00151
00152 TQtBrush::~TQtBrush()
00153 {
00154
00155 }
00156
00157 TQtBrush &TQtBrush::operator=(const TAttFill &rootFillAttributes)
00158 {
00159 SetFillAttributes(rootFillAttributes);
00160 return *this;
00161 }
00162
00163 void TQtBrush::SetFillAttributes(const TAttFill &rootFillAttributes)
00164 {
00165 SetColor(rootFillAttributes.GetFillColor());
00166 SetStyle(rootFillAttributes.GetFillStyle());
00167 }
00168
00169
00170 void TQtBrush::SetColor(Color_t cindex)
00171 {
00172
00173
00174 if (cindex >= 0) SetColor(gQt->ColorIndex(gQt->UpdateColor(cindex)));
00175 else fAlpha = cindex;
00176 }
00177
00178 void TQtBrush::SetColor(const QColor &qtcolor)
00179 {
00180
00181 fAlpha = qtcolor.alpha();
00182 fBackground = qtcolor;
00183 SetColorOwn();
00184 }
00185
00186
00187 void TQtBrush::SetColorOwn()
00188 {
00189
00190
00191
00192 static const int opaqAlpha = QColor(0,0,0).alpha();
00193 static const float opaqFactor = opaqAlpha/100.;
00194 if (fAlpha >=0 ) {
00195 int alpha = ( fStyle == 4) ? int(opaqFactor*fFasi) : fAlpha;
00196 if (fBackground.alpha() != alpha) fBackground.setAlpha(alpha);
00197 setColor(fBackground);
00198 }
00199 }
00200
00201
00202 void TQtBrush::SetStyle(int sty, int fasi)
00203 {
00204
00205
00206
00207
00208 fStyle = sty;
00209 fFasi = fasi;
00210
00211 switch( fStyle ) {
00212
00213 case 0:
00214 setStyle(Qt::NoBrush);
00215 fBackground = Qt::transparent;
00216 fAlpha = 0;
00217 break;
00218 case 1:
00219 setStyle(Qt::SolidPattern);
00220 break;
00221 case 3:
00222 {
00223 int pattern = 1;
00224 if (fasi > 0 && fasi < 26 ) pattern = fasi-1;
00225 QBitmap bm = QBitmap::fromData(QSize(16,16),patter_bits[pattern]);
00226 setTexture(bm);
00227 }
00228 break;
00229 case 2:
00230 switch (fasi)
00231 {
00232 case 1: setStyle(Qt::BDiagPattern);
00233 break;
00234 case 2: setStyle(Qt::CrossPattern);
00235 break;
00236 case 3: setStyle(Qt::DiagCrossPattern);
00237 break;
00238 case 4: setStyle(Qt::FDiagPattern);
00239 break;
00240 case 5: setStyle(Qt::HorPattern);
00241 break;
00242 case 6: setStyle(Qt::VerPattern );
00243 break;
00244 default: setStyle(Qt::FDiagPattern);
00245 break;
00246 }
00247 break;
00248 case 4:
00249 if (!fasi) setStyle(Qt::NoBrush);
00250 else setStyle(Qt::SolidPattern);
00251 break;
00252 default:
00253 setStyle(Qt::SolidPattern);
00254 break;
00255 }
00256 SetColorOwn();
00257 }