libyui-qt  2.43.3
 All Classes Functions Variables
YQPushButton.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQPushButton.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <qpushbutton.h>
27 #include <qsize.h>
28 #define YUILogComponent "qt-ui"
29 #include <yui/YUILog.h>
30 
31 #include "utf8.h"
32 #include "YQUI.h"
33 #include <yui/YEvent.h>
34 #include "YQPushButton.h"
35 
36 
37 YQPushButton::YQPushButton( YWidget * parent,
38  const std::string & label )
39  : YQGenericButton( parent, label )
40 {
41  setWidgetRep( this );
42 
43  QPushButton * button = new QPushButton( fromUTF8( label ), this );
44  Q_CHECK_PTR( button );
45 
46  setQPushButton( button );
47 
48  button->setMinimumSize( 2, 2 );
49  button->move( YQButtonBorder, YQButtonBorder );
50  setMinimumSize( button->minimumSize()
51  + 2 * QSize( YQButtonBorder, YQButtonBorder ) );
52 
53  connect( button, SIGNAL( clicked() ),
54  this, SLOT ( hit() ) );
55 }
56 
57 
59 {
60 }
61 
62 
64 {
65  return 2 * YQButtonBorder + qPushButton()->sizeHint().width();
66 }
67 
68 
70 {
71  return 2 * YQButtonBorder + qPushButton()->sizeHint().height();
72 }
73 
74 
75 void YQPushButton::setSize( int newWidth, int newHeight )
76 {
77  qPushButton()->resize( newWidth - 2 * YQButtonBorder,
78  newHeight - 2 * YQButtonBorder );
79  resize( newWidth, newHeight );
80 }
81 
82 
84 {
85  YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
86 }
87 
88 
89 #include "YQPushButton.moc"