-rw-r--r-- | microkde/kdeui/kbuttonbox.cpp | 2 | ||||
-rw-r--r-- | microkde/kdeui/kpopupmenu.cpp | 19 | ||||
-rw-r--r-- | microkde/kdeui/kpopupmenu.h | 22 | ||||
-rw-r--r-- | microkde/microkde.pro | 2 | ||||
-rw-r--r-- | microkde/microkdeE.pro | 2 |
5 files changed, 44 insertions, 3 deletions
diff --git a/microkde/kdeui/kbuttonbox.cpp b/microkde/kdeui/kbuttonbox.cpp index 16206e8..83d622a 100644 --- a/microkde/kdeui/kbuttonbox.cpp +++ b/microkde/kdeui/kbuttonbox.cpp @@ -1,300 +1,300 @@ /* This file is part of the KDE libraries Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * KButtonBox class * * A container widget for buttons. Uses Qt layout control to place the * buttons, can handle both vertical and horizontal button placement. * * HISTORY * * 03/08/2000 Mario Weilguni <mweilguni@kde.org> * Removed all those long outdated Motif stuff * Improved and clarified some if conditions (easier to understand) * * 11/13/98 Reginald Stadlbauer <reggie@kde.org> * Now in Qt 1.4x motif default buttons have no extra width/height anymore. * So the KButtonBox doesn't add this width/height to default buttons anymore * which makes the buttons look better. * * 01/17/98 Mario Weilguni <mweilguni@sime.com> * Fixed a bug in sizeHint() * Improved the handling of Motif default buttons * * 01/09/98 Mario Weilguni <mweilguni@sime.com> * The last button was to far right away from the right/bottom border. * Fixed this. Removed old code. Buttons get now a minimum width. * Programmer may now override minimum width and height of a button. * */ //US #include "kbuttonbox.moc" - + #include <kbuttonbox.h> #include <qpushbutton.h> #include <qptrlist.h> #include <assert.h> #define minButtonWidth 50 class KButtonBox::Item { public: QPushButton *button; bool noexpand; unsigned short stretch; unsigned short actual_size; }; template class QPtrList<KButtonBox::Item>; class KButtonBoxPrivate { public: unsigned short border; unsigned short autoborder; unsigned short orientation; bool activated; QPtrList<KButtonBox::Item> buttons; }; KButtonBox::KButtonBox(QWidget *parent, Orientation _orientation, int border, int autoborder) : QWidget(parent) { data = new KButtonBoxPrivate; assert(data != 0); data->orientation = _orientation; data->border = border; data->autoborder = autoborder < 0 ? border : autoborder; data->buttons.setAutoDelete(TRUE); } KButtonBox::~KButtonBox() { delete data; } QPushButton *KButtonBox::addButton(const QString& text, bool noexpand) { Item *item = new Item; item->button = new QPushButton(text, this); item->noexpand = noexpand; data->buttons.append(item); item->button->adjustSize(); return item->button; } QPushButton * KButtonBox::addButton( const QString & text, QObject * receiver, const char * slot, bool noexpand ) { QPushButton * pb = addButton(text, noexpand); if ((0 != receiver) && (0 != slot)) QObject::connect(pb, SIGNAL(clicked()), receiver, slot); return pb; } void KButtonBox::addStretch(int scale) { if(scale > 0) { Item *item = new Item; item->button = 0; item->noexpand = FALSE; item->stretch = scale; data->buttons.append(item); } } void KButtonBox::layout() { // resize all buttons QSize bs = bestButtonSize(); for(unsigned int i = 0; i < data->buttons.count(); i++) { Item *item = data->buttons.at(i); QPushButton *b = item->button; if(b != 0) { if(item->noexpand) b->setFixedSize(buttonSizeHint(b)); else b->setFixedSize(bs); } } setMinimumSize(sizeHint()); } void KButtonBox::placeButtons() { unsigned int i; if(data->orientation == Horizontal) { // calculate free size and stretches int fs = width() - 2 * data->border; int stretch = 0; for(i = 0; i < data->buttons.count(); i++) { Item *item = data->buttons.at(i); if(item->button != 0) { fs -= item->button->width(); // Last button? if(i != data->buttons.count() - 1) fs -= data->autoborder; } else stretch +=item->stretch; } // distribute buttons int x_pos = data->border; for(i = 0; i < data->buttons.count(); i++) { Item *item = data->buttons.at(i); if(item->button != 0) { QPushButton *b = item->button; b->move(x_pos, (height() - b->height()) / 2); x_pos += b->width() + data->autoborder; } else x_pos += (int)((((double)fs) * item->stretch) / stretch); } } else { // VERTICAL // calcualte free size and stretches int fs = height() - 2 * data->border; int stretch = 0; for(i = 0; i < data->buttons.count(); i++) { Item *item = data->buttons.at(i); if(item->button != 0) fs -= item->button->height() + data->autoborder; else stretch +=item->stretch; } // distribute buttons int y_pos = data->border; for(i = 0; i < data->buttons.count(); i++) { Item *item = data->buttons.at(i); if(item->button != 0) { QPushButton *b = item->button; b->move((width() - b->width()) / 2, y_pos); y_pos += b->height() + data->autoborder; } else y_pos += (int)((((double)fs) * item->stretch) / stretch); } } } void KButtonBox::resizeEvent(QResizeEvent *) { placeButtons(); } QSize KButtonBox::bestButtonSize() const { QSize s(0, 0); unsigned int i; // calculate optimal size for(i = 0; i < data->buttons.count(); i++) { KButtonBox *that = (KButtonBox*)this; // to remove the const ;( Item *item = that->data->buttons.at(i); QPushButton *b = item->button; if(b != 0 && !item->noexpand) { QSize bs = buttonSizeHint(b); if(bs.width() > s.width()) s.setWidth(bs.width()); if(bs.height() > s.height()) s.setHeight(bs.height()); } } return s; } QSize KButtonBox::sizeHint() const { unsigned int i, dw; if(data->buttons.count() == 0) return QSize(0, 0); else { dw = 2 * data->border; QSize bs = bestButtonSize(); for(i = 0; i < data->buttons.count(); i++) { KButtonBox *that = (KButtonBox*)this; Item *item = that->data->buttons.at(i); QPushButton *b = item->button; if(b != 0) { QSize s; if(item->noexpand) s = that->buttonSizeHint(b); else s = bs; if(data->orientation == Horizontal) dw += s.width(); else dw += s.height(); if( i != data->buttons.count() - 1 ) dw += data->autoborder; } } if(data->orientation == Horizontal) return QSize(dw, bs.height() + 2 * data->border); else return QSize(bs.width() + 2 * data->border, dw); } } QSizePolicy KButtonBox::sizePolicy() const { return data->orientation == Horizontal? QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) : QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ); } /* * Returns the best size for a button. If a button is less than * minButtonWidth pixels wide, return minButtonWidth pixels * as minimum width */ QSize KButtonBox::buttonSizeHint(QPushButton *b) const { QSize s = b->sizeHint(); QSize ms = b->minimumSize(); if(s.width() < minButtonWidth) s.setWidth(minButtonWidth); // allows the programmer to override the settings if(ms.width() > s.width()) s.setWidth(ms.width()); if(ms.height() > s.height()) s.setHeight(ms.height()); return s; } void KButtonBox::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } diff --git a/microkde/kdeui/kpopupmenu.cpp b/microkde/kdeui/kpopupmenu.cpp new file mode 100644 index 0000000..96d2a87 --- a/dev/null +++ b/microkde/kdeui/kpopupmenu.cpp @@ -0,0 +1,19 @@ + +#include <kpopupmenu.h> +#include <qtimer.h> + + +KPopupMenu::KPopupMenu ( QWidget * parent, const char * name ) + : QPopupMenu ( parent, name ) {;} + + + +KMenuBar::KMenuBar ( QWidget * parent, const char * name ) + : QPEMenuBar ( parent, name ) {} + +void KMenuBar::focusOutEvent ( QFocusEvent * e) +{ + QPEMenuBar::focusOutEvent( e ); + QTimer::singleShot( 100, this, SIGNAL ( lostFocus() ) ); + +} diff --git a/microkde/kdeui/kpopupmenu.h b/microkde/kdeui/kpopupmenu.h index 1352429..f16ce77 100644 --- a/microkde/kdeui/kpopupmenu.h +++ b/microkde/kdeui/kpopupmenu.h @@ -1,14 +1,32 @@ #ifndef KPOPUPMENU_H #define KPOPUPMENU_H #include <qpopupmenu.h> +#ifdef DESKTOP_VERSION +#include <qmenubar.h> +#define QPEMenuBar QMenubar +#else +#include <qpe/qpemenubar.h> +#endif class KPopupMenu : public QPopupMenu { +Q_OBJECT public: - KPopupMenu ( QWidget * parent=0, const char * name=0 ) - : QPopupMenu ( parent, name ) {} + KPopupMenu ( QWidget * parent=0, const char * name=0 ); + +}; + +class KMenuBar : public QPEMenuBar +{ +Q_OBJECT + public: + KMenuBar ( QWidget * parent=0, const char * name=0 ); + signals: + void lostFocus(); + protected: + void focusOutEvent ( QFocusEvent * e); }; #endif diff --git a/microkde/microkde.pro b/microkde/microkde.pro index 44e5f9d..7120bdd 100644 --- a/microkde/microkde.pro +++ b/microkde/microkde.pro @@ -1,178 +1,180 @@ TEMPLATE = lib CONFIG += qt warn_on include( ../variables.pri ) #INCLUDEPATH += $(QTDIR)/include . #DEPENDPATH += $(QTDIR)/include INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio #LIBS += -lqtcompat TARGET = microkde DESTDIR= ../bin DEFINES += DESKTOP_VERSION KDE_QT_ONLY unix : { staticlib: { INCLUDEPATH += ../kabc/plugins DEFINES += STATIC_RESOURCES } OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32: { DEFINES += _WIN32_ OBJECTS_DIR = obj/win MOC_DIR = moc/win } HEADERS = \ qlayoutengine_p.h \ KDGanttMinimizeSplitter.h \ kapplication.h \ kaudioplayer.h \ kcalendarsystem.h \ kcalendarsystemgregorian.h \ kcolorbutton.h \ kcombobox.h \ kconfig.h \ kdatetbl.h \ kdebug.h \ kdialog.h \ kdialogbase.h \ keditlistbox.h \ kemailsettings.h \ kfiledialog.h \ kfontdialog.h \ kglobal.h \ kglobalsettings.h \ kiconloader.h \ klineedit.h \ klineeditdlg.h \ kmessagebox.h \ knotifyclient.h \ kprinter.h \ kprocess.h \ krestrictedline.h \ krun.h \ ksimpleconfig.h \ kstaticdeleter.h \ ksystemtray.h \ ktempfile.h \ ktextedit.h \ kunload.h \ kurl.h \ kdeui/kguiitem.h \ kdeui/kcmodule.h \ kdeui/kbuttonbox.h \ kdeui/klistbox.h \ kdeui/klistview.h \ kdeui/kjanuswidget.h \ kdeui/kseparator.h \ kdeui/knuminput.h \ kdeui/knumvalidator.h \ kdeui/ksqueezedtextlabel.h \ kio/job.h \ kio/kio/kdirwatch.h \ kio/kio/kdirwatch_p.h \ kio/kfile/kurlrequester.h \ kresources/resource.h \ kresources/factory.h \ kresources/managerimpl.h \ kresources/manager.h \ kresources/selectdialog.h \ kresources/configpage.h \ kresources/configwidget.h \ kresources/configdialog.h \ kresources/kcmkresources.h \ kdecore/kmdcodec.h \ kdecore/kconfigbase.h \ kdecore/klocale.h \ kdecore/kcatalogue.h \ kdecore/ksharedptr.h \ kdecore/kshell.h \ kdecore/kstandarddirs.h \ kdecore/kstringhandler.h \ kdecore/kshortcut.h \ kutils/kcmultidialog.h \ kdeui/kxmlguiclient.h \ kdeui/kstdaction.h \ kdeui/kmainwindow.h \ kdeui/ktoolbar.h \ kdeui/ktoolbarbutton.h \ kdeui/ktoolbarhandler.h \ kdeui/kaction.h \ + kdeui/kpopupmenu.h \ kdeui/kactionclasses.h \ kdeui/kactioncollection.h \ kdecore/kprefs.h \ kdecore/klibloader.h \ kidmanager.h # kdecore/klibloader.h \ SOURCES = \ KDGanttMinimizeSplitter.cpp \ kapplication.cpp \ kcalendarsystem.cpp \ kcalendarsystemgregorian.cpp \ kcolorbutton.cpp \ kconfig.cpp \ kdatetbl.cpp \ kdialog.cpp \ kdialogbase.cpp \ keditlistbox.cpp \ kemailsettings.cpp \ kfontdialog.cpp \ kfiledialog.cpp \ kglobal.cpp \ kglobalsettings.cpp \ kiconloader.cpp \ kmessagebox.cpp \ ktextedit.cpp \ kprocess.cpp \ krun.cpp \ ksystemtray.cpp \ ktempfile.cpp \ kurl.cpp \ kdecore/kcatalogue.cpp \ kdecore/klocale.cpp \ kdecore/kmdcodec.cpp \ kdecore/kshell.cpp \ kdecore/kstandarddirs.cpp \ kdecore/kstringhandler.cpp \ kdeui/kbuttonbox.cpp \ kdeui/kcmodule.cpp \ kdeui/kguiitem.cpp \ kdeui/kjanuswidget.cpp \ kdeui/klistbox.cpp \ kdeui/klistview.cpp \ kdeui/knuminput.cpp \ kdeui/knumvalidator.cpp \ kdeui/kseparator.cpp \ kdeui/ksqueezedtextlabel.cpp \ kio/kio/kdirwatch.cpp \ kio/kfile/kurlrequester.cpp \ kresources/configpage.cpp \ kresources/configdialog.cpp \ kresources/configwidget.cpp \ kresources/factory.cpp \ kresources/kcmkresources.cpp \ kresources/managerimpl.cpp \ kresources/resource.cpp \ kresources/selectdialog.cpp \ kutils/kcmultidialog.cpp \ kdeui/kaction.cpp \ + kdeui/kpopupmenu.cpp \ kdeui/kactionclasses.cpp \ kdeui/kactioncollection.cpp \ kdeui/kmainwindow.cpp \ kdeui/ktoolbar.cpp \ kdeui/ktoolbarbutton.cpp \ kdeui/ktoolbarhandler.cpp \ kdeui/kstdaction.cpp \ kdeui/kxmlguiclient.cpp \ kdecore/kprefs.cpp \ kdecore/klibloader.cpp \ kidmanager.cpp diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro index 335fcd0..8fe2bd5 100644 --- a/microkde/microkdeE.pro +++ b/microkde/microkdeE.pro @@ -1,172 +1,174 @@ TEMPLATE = lib CONFIG += qt warn_on INCLUDEPATH += . .. $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/kabc kdecore kdeui kio/kfile kio/kio $(QPEDIR)/include DEPENDPATH += $(QPEDIR)/include LIBS += -lmicroqtcompat -L$(QPEDIR)/lib DEFINES += KDE_QT_ONLY TARGET = microkde OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/lib INTERFACES = \ HEADERS = \ qlayoutengine_p.h fncolordialog.h\ KDGanttMinimizeSplitter.h \ kapplication.h \ kaudioplayer.h \ kcalendarsystem.h \ kcalendarsystemgregorian.h \ kcolorbutton.h \ kcolordialog.h \ kcombobox.h \ kconfig.h \ kdatetbl.h \ kdebug.h \ kdialog.h \ kdialogbase.h \ keditlistbox.h \ kemailsettings.h \ kfiledialog.h \ kfontdialog.h \ kglobal.h \ kglobalsettings.h \ kiconloader.h \ klineedit.h \ klineeditdlg.h \ kmessagebox.h \ knotifyclient.h \ kprinter.h \ kprocess.h \ krestrictedline.h \ krun.h \ ksimpleconfig.h \ kstaticdeleter.h \ ksystemtray.h \ ktempfile.h \ ktextedit.h \ kunload.h \ kurl.h \ ofileselector_p.h \ ofontselector.h \ kdeui/kguiitem.h \ kdeui/kaction.h \ + kdeui/kpopupmenu.h \ kdeui/kactionclasses.h \ kdeui/kactioncollection.h \ kdeui/kcmodule.h \ kdeui/kstdaction.h \ kdeui/kbuttonbox.h \ kdeui/klistbox.h \ kdeui/klistview.h \ kdeui/kjanuswidget.h \ kdeui/kseparator.h \ kdeui/kmainwindow.h \ kdeui/knuminput.h \ kdeui/knumvalidator.h \ kdeui/ksqueezedtextlabel.h \ kdeui/ktoolbar.h \ kdeui/ktoolbarbutton.h \ kdeui/ktoolbarhandler.h \ kdeui/kxmlguiclient.h \ kio/job.h \ kio/kio/kdirwatch.h \ kio/kio/kdirwatch_p.h \ kio/kfile/kurlrequester.h \ kresources/resource.h \ kresources/factory.h \ kresources/managerimpl.h \ kresources/manager.h \ kresources/selectdialog.h \ kresources/configpage.h \ kresources/configwidget.h \ kresources/configdialog.h \ kresources/kcmkresources.h \ kdecore/kmdcodec.h \ kdecore/kconfigbase.h \ kdecore/klocale.h \ kdecore/klibloader.h \ kdecore/kcatalogue.h \ kdecore/kprefs.h \ kdecore/ksharedptr.h \ kdecore/kshell.h \ kdecore/kstandarddirs.h \ kdecore/kstringhandler.h \ kdecore/kshortcut.h \ kutils/kcmultidialog.h \ kidmanager.h SOURCES = \ KDGanttMinimizeSplitter.cpp fncolordialog.cpp \ kapplication.cpp \ kcalendarsystem.cpp \ kcalendarsystemgregorian.cpp \ kcolorbutton.cpp \ kcolordialog.cpp \ kconfig.cpp \ kdatetbl.cpp \ kdialog.cpp \ kdialogbase.cpp \ keditlistbox.cpp \ kemailsettings.cpp \ kfontdialog.cpp \ kfiledialog.cpp \ kglobal.cpp \ kglobalsettings.cpp \ kiconloader.cpp \ kmessagebox.cpp \ kprocess.cpp \ krun.cpp \ ksystemtray.cpp \ ktempfile.cpp \ kurl.cpp \ ktextedit.cpp \ ofileselector_p.cpp \ ofontselector.cpp \ kdecore/kcatalogue.cpp \ kdecore/klibloader.cpp \ kdecore/klocale.cpp \ kdecore/kmdcodec.cpp \ kdecore/kprefs.cpp \ kdecore/kshell.cpp \ kdecore/kstandarddirs.cpp \ kdecore/kstringhandler.cpp \ kdeui/kaction.cpp \ + kdeui/kpopupmenu.cpp \ kdeui/kactionclasses.cpp \ kdeui/kactioncollection.cpp \ kdeui/kbuttonbox.cpp \ kdeui/kcmodule.cpp \ kdeui/kguiitem.cpp \ kdeui/kjanuswidget.cpp \ kdeui/klistbox.cpp \ kdeui/klistview.cpp \ kdeui/kmainwindow.cpp \ kdeui/knuminput.cpp \ kdeui/knumvalidator.cpp \ kdeui/kseparator.cpp \ kdeui/kstdaction.cpp \ kdeui/ksqueezedtextlabel.cpp \ kdeui/ktoolbar.cpp \ kdeui/ktoolbarbutton.cpp \ kdeui/ktoolbarhandler.cpp \ kdeui/kxmlguiclient.cpp \ kio/kfile/kurlrequester.cpp \ kio/kio/kdirwatch.cpp \ kresources/configpage.cpp \ kresources/configdialog.cpp \ kresources/configwidget.cpp \ kresources/factory.cpp \ kresources/kcmkresources.cpp \ kresources/managerimpl.cpp \ kresources/resource.cpp \ kresources/selectdialog.cpp \ kutils/kcmultidialog.cpp \ kidmanager.cpp |