KDevelop API Documentation

lib/widgets/resizablecombo.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 #include "resizablecombo.h" 00020 00021 #include "kcomboview.h" 00022 00023 #include <qevent.h> 00024 #include <qlayout.h> 00025 #include <qpixmap.h> 00026 #include <qapplication.h> 00027 #include <qwhatsthis.h> 00028 00029 #include <klocale.h> 00030 00031 static const char * resize_xpm[] = { 00032 "9 18 2 1", 00033 " c None", 00034 ". c #000000", 00035 " . ", 00036 " ", 00037 " . ", 00038 " ", 00039 " . ", 00040 " ", 00041 " . . . ", 00042 " .. .. ", 00043 ".........", 00044 " .. .. ", 00045 " . . . ", 00046 " ", 00047 " . ", 00048 " ", 00049 " . ", 00050 " ", 00051 " . ", 00052 " "}; 00053 00054 ResizableCombo::ResizableCombo(KComboView *view, QWidget *parent, const char *name): 00055 QWidget(parent, name), m_sizer(0), m_combo(view) 00056 { 00057 QHBoxLayout *l = new QHBoxLayout(this); 00058 view->reparent(this, QPoint(0,0)); 00059 l->addWidget(view); 00060 00061 m_sizer = new MyPushButton(this); 00062 m_sizer->setPixmap(QPixmap(resize_xpm)); 00063 QWhatsThis::add(m_sizer, i18n("Drag this to resize the combobox.")); 00064 l->addWidget(m_sizer); 00065 } 00066 00067 void MyPushButton::mousePressEvent( QMouseEvent * e ) 00068 { 00069 m_resizing = true; 00070 m_pressedPos = e->globalPos(); 00071 m_width = m_combo->m_combo->width(); 00072 QPushButton::mousePressEvent(e); 00073 } 00074 00075 void MyPushButton::mouseReleaseEvent( QMouseEvent * e ) 00076 { 00077 m_resizing = false; 00078 QPushButton::mouseReleaseEvent(e); 00079 } 00080 00081 void MyPushButton::mouseMoveEvent( QMouseEvent * e ) 00082 { 00083 if (m_resizing) 00084 m_combo->m_combo->setMinimumWidth(m_width + e->globalPos().x() - pressedPos().x()); 00085 00086 QPushButton::mouseMoveEvent(e); 00087 } 00088 00089 MyPushButton::MyPushButton( ResizableCombo * parent, const char * name ) 00090 :QPushButton(parent, name), m_resizing(false), m_combo(parent) 00091 { 00092 setFocusPolicy(NoFocus); 00093 setFlat(true); 00094 m_width = m_combo->m_combo->width(); 00095 } 00096 00097 00098 #include "resizablecombo.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:09 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003