2
// File : kvi_colorwin.cpp (/usr/build/NEW_kvirc/kvirc/kvirc/kvi_colorwin.cpp)
3
// Last major modification : Wed Jan 6 1999 04:30:20 by Szymon Stefanek
5
// This file is part of the KVirc irc client distribution
6
// Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
8
// This program is FREE software. You can redistribute it and/or
9
// modify it under the terms of the GNU General Public License
10
// as published by the Free Software Foundation; either version 2
11
// of the License, or (at your opinion) any later version.
13
// This program is distributed in the HOPE that it will be USEFUL,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
// See the GNU General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with this program. If not, write to the Free Software Foundation,
20
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "kvi_colorwin.h"
25
#include "kvi_options.h"
27
#include "kvi_xutils.h"
29
#include <qnamespace.h>
31
#ifdef COMPILE_USE_AA_FONTS
32
extern XftFont * g_pXftFont;
33
extern XftDraw * g_pXftDraw;
34
extern int qt_use_xft (void); // qpainter_x11.cpp
35
extern void *qt_ft_font (const QFont *f); // qfont_x11.cpp
36
extern XftDraw * qt_lookup_ft_draw (Drawable draw, bool paintEventClipOn, QRegion *crgn);
39
KviColorWindow::KviColorWindow()
40
:QWidget(0,"KviColorWindow",Qt::WType_Popup)
42
setFocusPolicy(QWidget::NoFocus);
43
setBackgroundMode(NoBackground);
46
QFont fnt("fixed",10);
50
KviColorWindow::~KviColorWindow()
53
// if(m_pOwner)m_pOwner->setFocus();
56
void KviColorWindow::popup(QWidget *owner)
62
void KviColorWindow::paintEvent(QPaintEvent *)
64
static int clrIdx[16]={ 1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1 };
65
Display *dpy = x11Display();
66
GC gc_aux = XCreateGC(dpy,handle(),0,0);
67
XSetLineAttributes(dpy,gc_aux,1,LineSolid,CapButt,JoinMiter);
68
#ifdef COMPILE_USE_AA_FONTS
71
g_pXftFont = (XftFont *)qt_ft_font(&(font()));
72
g_pXftDraw = qt_lookup_ft_draw (handle(),false,0);
75
XSetFont(dpy,gc_aux,font().handle());
81
XSetFont(dpy,gc_aux,font().handle());
82
#ifdef COMPILE_USE_AA_FONTS
87
kvi_xDraw3dRect(dpy,gc_aux,handle(),colorGroup(),0,0,width()-1,height()-1,false);
90
kvi_xDraw3dRect(dpy,gc_aux,handle(),colorGroup(),curX,1,curX+17,18,true);
91
XSetForeground(dpy,gc_aux,g_pOptions->m_pMircColor[i]->pixel());
92
XFillRectangle(dpy,handle(),gc_aux,curX+1,2,16,16);
93
XSetForeground(dpy,gc_aux,g_pOptions->m_pMircColor[clrIdx[i]]->pixel());
95
#ifdef COMPILE_USE_AA_FONTS
98
QColor * clr = g_pOptions->m_pMircColor[clrIdx[i]];
99
color.color.red = clr->red() | clr->red() << 8;
100
color.color.green = clr->green() | clr->green() << 8;
101
color.color.blue = clr->blue() | clr->blue() << 8;
102
color.color.alpha = 0xffff;
103
color.pixel = clr->pixel();
104
XftDrawString8(g_pXftDraw,&color,g_pXftFont,curX+5,14,(unsigned char *)&c,1);
107
XDrawString(dpy,handle(),gc_aux,curX+5,14,&c,1);
111
for(int i=8;i<16;i++){
112
kvi_xDraw3dRect(dpy,gc_aux,handle(),colorGroup(),curX,19,curX+17,36,true);
113
XSetForeground(dpy,gc_aux,g_pOptions->m_pMircColor[i]->pixel());
114
XFillRectangle(dpy,handle(),gc_aux,curX+1,20,16,16);
115
XSetForeground(dpy,gc_aux,g_pOptions->m_pMircColor[clrIdx[i]]->pixel());
119
#ifdef COMPILE_USE_AA_FONTS
122
QColor * clr = g_pOptions->m_pMircColor[clrIdx[i]];
123
color.color.red = clr->red() | clr->red() << 8;
124
color.color.green = clr->green() | clr->green() << 8;
125
color.color.blue = clr->blue() | clr->blue() << 8;
126
color.color.alpha = 0xffff;
127
color.pixel = clr->pixel();
128
XftDrawString8(g_pXftDraw,&color,g_pXftFont,curX+5,33,
129
(unsigned char *)c,1);
132
XDrawString(dpy,handle(),gc_aux,curX+5,33,c,1);
136
#ifdef COMPILE_USE_AA_FONTS
139
QColor * clr = g_pOptions->m_pMircColor[clrIdx[i]];
140
color.color.red = clr->red() | clr->red() << 8;
141
color.color.green = clr->green() | clr->green() << 8;
142
color.color.blue = clr->blue() | clr->blue() << 8;
143
color.color.alpha = 0xffff;
144
color.pixel = clr->pixel();
145
XftDrawString8(g_pXftDraw,&color,g_pXftFont,curX+2,33,
146
(unsigned char *)c,2);
149
XDrawString(dpy,handle(),gc_aux,curX+2,33,c,2);
156
void KviColorWindow::keyPressEvent(QKeyEvent *e)
160
if(m_pOwner)g_pApp->sendEvent(m_pOwner,e);
163
void KviColorWindow::mousePressEvent(QMouseEvent *)
169
void KviColorWindow::show()
171
startTimer(10000); //10 sec ...seems enough
175
void KviColorWindow::timerEvent(QTimerEvent *)
181
#include "m_kvi_colorwin.moc"