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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/***************************************************************************
rtoolbutton.cpp - description
-------------------
begin : Mon Sep 27 1999
copyright : (C) 1999 by Andreas Mustun
email : andrew@ribbonsoft.com
***************************************************************************/
/****************************************************************************
** rtoolbutton.cpp 1999/04/14 A. Mustun RibbonSoft
**
** Copyright (C) 1998/99 RibbonSoft. All rights reserved.
**
*****************************************************************************/
#include <qapplication.h>
#include <qpainter.h>
#include <qpointarray.h>
#include "rtoolbutton.h"
// Constructor:
//
RToolButton::RToolButton(QWidget* _parent,
const char* _name,
bool _forwardRightClick)
:QToolButton(_parent, _name)
{
forwardRightClick = _forwardRightClick;
}
// Destructor:
//
RToolButton::~RToolButton()
{
}
// Forward the right mouse click to parent widget:
//
// Mouse Release event:
//
void
RToolButton::mouseReleaseEvent(QMouseEvent* _ev)
{
QToolButton::mouseReleaseEvent(_ev);
if(forwardRightClick &&
_ev->button()==RightButton) {
qApp->notify(parentWidget(), _ev);
}
}
/*! Draws the edges and decoration of the button (pretty much
nothing) and calls drawButtonLabel().
\sa drawButtonLabel() QButton::paintEvent() */
void
RToolButton::drawButton( QPainter * p )
{
QPointArray a;
a.setPoints( 3, 0, height()-1, 0, 0, width()-1, 0 );
if (uses3D() || isOn()) {
if (isOn()) {
if ( style() == WindowsStyle ) {
p->setBrush( QBrush(white,Dense4Pattern) );
p->setPen( NoPen );
p->setBackgroundMode( OpaqueMode );
p->drawRect( 0,0, width(),height() );
p->setBackgroundMode( TransparentMode );
}
else {
p->setBrush( colorGroup().mid() );
p->setPen( NoPen );
p->drawRect( 0,0, width(),height() );
}
}
p->setPen( isDown() && !uses3D()
? colorGroup().light()
: colorGroup().dark() );
p->drawPolyline( a );
a[1] = QPoint( width()-1, height()-1 );
p->setPen( isDown() && !uses3D()
? colorGroup().dark()
: colorGroup().light() );
p->drawPolyline( a );
}
else {
p->setPen( isDown() || isOn()
? colorGroup().dark()
: colorGroup().light() );
p->drawPolyline( a );
a[1] = QPoint( width()-1, height()-1 );
p->setPen( isDown() || isOn()
? colorGroup().light()
: colorGroup().dark() );
p->drawPolyline( a );
}
drawButtonLabel( p );
if ( hasFocus() ) {
if ( style() == WindowsStyle ) {
p->drawWinFocusRect( 3, 3, width()-6, height()-6,
colorGroup().background() );
}
else {
p->setPen( black );
p->drawRect( 3, 3, width()-6, height()-6 );
}
}
}
// EOF
|