1 /***************************************************************************
2 * Copyright (C) 2003 by Carsten Niehaus *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #include "elementbutton.h"
22 #include "infodialog_small_impl.h"
23 #include "detailinfodlg.h"
28 ElementButton::ElementButton(int number
, Element
*el
, QWidget
*parent
, const char *name
)
29 : QFrame(parent
, name
)
31 m_ElementNumber
= number
;
35 setMaximumSize( 40, 40 );
36 setFrameStyle( QFrame::Box
);
39 setFrameShadow( QFrame::Sunken
);
42 void ElementButton::mouseReleaseEvent( QMouseEvent
*mouse
)
44 int small
= Prefs::lMBbeh();
47 if ( mouse
->button() == LeftButton
)
49 infoDlgSmallImpl
*smallDlg
= new infoDlgSmallImpl( e
, this , "smallDlg" );
53 DetailedInfoDlg
*detailedDlg
= new DetailedInfoDlg( e
, this , "detailedDlg" );
59 if ( mouse
->button() == LeftButton
)
61 DetailedInfoDlg
*detailedDlg
= new DetailedInfoDlg( e
, this , "detailedDlg" );
65 infoDlgSmallImpl
*smallDlg
= new infoDlgSmallImpl( e
, this , "smallDlg" );
71 ElementButton::~ElementButton()
78 \fn ElementButton::m_ElementNumber
80 int ElementButton::ElementNumber()
82 return m_ElementNumber
;
87 \fn ElementButton::paintEvent( QPaintEvent* )
89 void ElementButton::paintEvent( QPaintEvent
* )
97 f
.setPointSize( f
.pointSize() + 2 );
101 //Draw the colored background
102 p
.setPen( elementColor() );
103 // p.setBrush( elementColor() );
104 p
.fillRect( 3, 3, w
-6, h
-6, elementColor() );
105 p
.drawRoundRect( 2, 2, w
-4, h
-4 );
107 //Draw text and border
108 p
.setPen( paletteForegroundColor() );
109 p
.drawText( 4, h
/2-6, QString::number( m_ElementNumber
) );
111 p
.drawText( w
/5, h
*3/4, sym
);
112 p
.drawRoundRect( 1, 1, w
-2, h
-2 );
117 void ElementButton::mousePressEvent( QMouseEvent
* /*e*/ )
119 emit
num( m_ElementNumber
);
122 #include "elementbutton.moc"