libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQPushButton.cc
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       YQPushButton.cc
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #include <qpushbutton.h>
00027 #include <qsize.h>
00028 #define YUILogComponent "qt-ui"
00029 #include <yui/YUILog.h>
00030 
00031 #include "utf8.h"
00032 #include "YQUI.h"
00033 #include <yui/YEvent.h>
00034 #include "YQPushButton.h"
00035 
00036 
00037 YQPushButton::YQPushButton( YWidget *           parent,
00038                             const std::string & label )
00039     : YQGenericButton( parent, label )
00040 {
00041     setWidgetRep( this );
00042 
00043     QPushButton * button = new QPushButton( fromUTF8( label ), this );
00044     Q_CHECK_PTR( button );
00045 
00046     setQPushButton( button );
00047 
00048     button->setMinimumSize( 2, 2 );
00049     button->move( YQButtonBorder, YQButtonBorder );
00050     setMinimumSize( button->minimumSize()
00051                     + 2 * QSize( YQButtonBorder, YQButtonBorder ) );
00052 
00053     connect( button, SIGNAL( clicked() ),
00054              this,   SLOT  ( hit()     ) );
00055 }
00056 
00057 
00058 YQPushButton::~YQPushButton()
00059 {
00060 }
00061 
00062 
00063 int YQPushButton::preferredWidth()
00064 {
00065     return 2 * YQButtonBorder + qPushButton()->sizeHint().width();
00066 }
00067 
00068 
00069 int YQPushButton::preferredHeight()
00070 {
00071     return 2 * YQButtonBorder + qPushButton()->sizeHint().height();
00072 }
00073 
00074 
00075 void YQPushButton::setSize( int newWidth, int newHeight )
00076 {
00077     qPushButton()->resize( newWidth  - 2 * YQButtonBorder,
00078                            newHeight - 2 * YQButtonBorder );
00079     resize( newWidth, newHeight );
00080 }
00081 
00082 
00083 void YQPushButton::hit()
00084 {
00085     YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
00086 }
00087 
00088 
00089 #include "YQPushButton.moc"
 All Classes Functions Variables