1
/**************************************************************************
3
ktrianglebutton.cpp - The KTriangleButton widget (button with an arrow)
4
Copyright (C) 1998 Antonio Larrosa Jimenez
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
Send comments and bug fixes to larrosa@kde.org
21
or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23
Note: This widget was based on KButton as found in the kdelibs/kdeui
24
KButton was originally copyrighted by Torben Weis (weis@kde.org)
25
and Matthias Ettrich (ettrich@kde.org) on 1997
27
***************************************************************************/
28
#include "ktrianglebutton.h"
30
#include <qdrawutil.h>
32
KTriangleButton::KTriangleButton( Direction d,QWidget *_parent, const char *name )
33
: QButton( _parent , name)
37
setFocusPolicy( NoFocus );
40
KTriangleButton::~KTriangleButton()
44
void KTriangleButton::enterEvent( QEvent* )
53
void KTriangleButton::leaveEvent( QEvent * )
63
void KTriangleButton::drawButton( QPainter *_painter )
68
void KTriangleButton::drawButtonLabel( QPainter *_painter )
73
void KTriangleButton::paint( QPainter *painter )
75
if ( isDown() || isOn() )
77
if ( style().guiStyle() == WindowsStyle )
78
qDrawWinButton( painter, 0, 0, width(),
79
height(), colorGroup(), TRUE );
81
qDrawShadePanel( painter, 0, 0, width(),
82
height(), colorGroup(), TRUE, 2, 0L );
86
if ( style().guiStyle() == WindowsStyle )
87
qDrawWinButton( painter, 0, 0, width(), height(),
88
colorGroup(), FALSE );
90
qDrawShadePanel( painter, 0, 0, width(), height(),
91
colorGroup(), FALSE, 2, 0L );
100
int maxi=width()-2*x;
101
double m=(double)(l/2)/maxi;
104
painter->drawLine(x,y+(int)(i*m),x,y+l-(int)(i*m));
115
int maxi=width()-2*x;
117
double m=(double)(l/2)/maxi;
120
painter->drawLine(x,y+(int)(i*m),x,y+l-(int)(i*m));
129
void KTriangleButton::mousePressEvent(QMouseEvent *e)
131
QButton::mousePressEvent(e);
138
void KTriangleButton::mouseReleaseEvent(QMouseEvent *e)
141
QButton::mouseReleaseEvent(e);
144
void KTriangleButton::timerEvent(QTimerEvent *)
146
if (!usingTimer) {killTimers();return;};
159
else if (timeCount>0) timeCount++;
160
emit clickedQuickly();
163
#include "ktrianglebutton.moc"