lib/widgets/resizablecombo.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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"
This file is part of the documentation for KDevelop Version 3.0.4.