-rw-r--r-- | microkde/kdeui/ktoolbar.h | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h index 3319fa8..4e00abd 100644 --- a/microkde/kdeui/ktoolbar.h +++ b/microkde/kdeui/ktoolbar.h @@ -5,216 +5,224 @@ (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) (C) 1999, 2000 Kurt Granroth (granroth@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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. */ #ifndef KTOOLBAR_H #define KTOOLBAR_H #ifndef DESKTOP_VERSION #define private public -#include <qtoolbar.h> +#include <q3toolbar.h> #undef private #include <qpe/qpetoolbar.h> #else -#include <qtoolbar.h> +#include <q3toolbar.h> #endif -#include <qmainwindow.h> +#include <q3mainwindow.h> #include <qcombobox.h> #include <qmap.h> -#include <qptrlist.h> +#include <q3ptrlist.h> +//Added by qt3to4: +#include <QPixmap> +#include <QResizeEvent> +#include <Q3PopupMenu> +#include <QMouseEvent> +#include <QChildEvent> +#include <QEvent> +#include <QShowEvent> #include <kglobal.h> -#include <qguardedptr.h> -#include <qframe.h> -#include <qiconset.h> +#include <qpointer.h> +#include <q3frame.h> +#include <qicon.h> class QDomElement; class QSize; class QPixmap; -class QPopupMenu; +class Q3PopupMenu; class QStringList; class QDomDocument; class QTimer; class KLineEdit; class KToolBar; class KToolBarButton; class KToolBoxManager; //US class KAnimWidget; //US class KPopupMenu; //US class KInstance; class KComboBox; class KXMLGUIClient; class KToolBarPrivate; -class KToolBarSeparator : public QFrame +class KToolBarSeparator : public Q3Frame { Q_OBJECT public: - KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 ); + KToolBarSeparator( Qt::Orientation, bool l, Q3ToolBar *parent, const char* name=0 ); QSize sizeHint() const; - Orientation orientation() const { return orient; } + Qt::Orientation orientation() const { return orient; } QSizePolicy sizePolicy() const; bool showLine() const { return line; } public slots: - void setOrientation( Orientation ); + void setOrientation( Qt::Orientation ); protected: void styleChange( QStyle& ); private: - Orientation orient; + Qt::Orientation orient; bool line; }; /** * A KDE-style toolbar. * * KToolBar can be dragged around in and between different docks. * * A KToolBar can contain all sorts of widgets. * * KToolBar can be used as a standalone widget, but @ref KMainWindow * provides easy factories and management of one or more toolbars. * Once you have a KToolBar object, you can insert items into it with the * insert... methods, or remove them with the @ref removeItem() method. This * can be done at any time; the toolbar will be automatically updated. * There are also many methods to set per-child properties like alignment * and toggle behaviour. * * KToolBar uses a global config group to load toolbar settings on * construction. It will reread this config group on a * @ref KApplication::appearanceChanged() signal. * * @short Floatable toolbar with auto resize. * @version $Id$ * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>. */ // strange things are happening ... so I have to use strange define methods ... // porting KToolBar back to Qt2 really needs some strange hacks #ifndef DESKTOP_VERSION -#define QToolBar QPEToolBar +#define Q3ToolBar QPEToolBar #endif - class KToolBar : public QToolBar + class KToolBar : public Q3ToolBar { Q_OBJECT Q_ENUMS( IconText BarPosition ) Q_PROPERTY( IconText iconText READ iconText WRITE setIconText ) Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos ) Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize ) Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize ) Q_PROPERTY( QString text READ text WRITE setText ) #ifndef DESKTOP_VERSION -#undef QToolBar +#undef Q3ToolBar #endif public: enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom}; /** * The state of the status bar. * @deprecated **/ enum BarStatus{Toggle, Show, Hide}; /** * Possible bar positions. **/ enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat}; /** * Constructor. * This constructor is used by the XML-GUI. If you use it, you need * to call QMainWindow::addToolBar to specify the position of the toolbar. * So it's simpler to use the other constructor. * * The toolbar will read in various global config settings for * things like icon size and text position, etc. However, some of * the settings will be honored only if @ref #_honor_mode is set to * true. All other toolbars will be IconOnly and use Medium icons. * * @param parent The standard toolbar parent (usually a * @ref KMainWindow) * @param name The standard internal name * @param honor_style If true, then global settings for IconSize and IconText will be honored * @param readConfig whether to apply the configuration (global and application-specific) */ KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); /** * Constructor for non-XML-GUI applications. * * The toolbar will read in various global config settings for * things like icon size and text position, etc. However, some of * the settings will be honored only if @ref #_honor_mode is set to * true. All other toolbars will be IconOnly and use Medium icons. * * @param parentWindow The window that should be the parent of this toolbar * @param dock The position of the toolbar. Usually QMainWindow::Top. * @param newLine If true, start a new line in the dock for this toolbar. * @param name The standard internal name * @param honor_style If true, then global settings for IconSize and IconText will be honored * @param readConfig whether to apply the configuration (global and application-specific) */ - KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, + KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); /** * Constructor for non-XML-GUI applications. * * The toolbar will read in various global config settings for * things like icon size and text position, etc. However, some of * the settings will be honored only if @ref #_honor_mode is set to * true. All other toolbars will be IconOnly and use Medium icons. * * @param parentWindow The window that should be the parent of this toolbar * @param dock Another widget than the mainwindow to dock toolbar to. * @param newLine If true, start a new line in the dock for this toolbar. * @param name The standard internal name * @param honor_style If true, then global settings for IconSize and IconText will be honored * @param readConfig whether to apply the configuration (global and application-specific) */ - KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false, + KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine = false, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); virtual ~KToolBar(); /** * Insert a button (a @ref KToolBarButton) with a pixmap. The * pixmap is loaded by the button itself based on the global icon * settings. * * You should connect to one or more signals in KToolBar: * @ref clicked() , @ref pressed() , @ref released() , or * @ref highlighted() and if the button is a toggle button * (@ref setToggle() ) @ref toggled() . Those signals have @p id * of a button that caused the signal. If you want to bind a popup * to button, see @ref setButton(). * * @param icon The name of the icon to use as the active pixmap * @param id The id of this button * @param enabled Enable or disable the button at startup * @param text The tooltip or toolbar text (depending on state) * @param index The position of the button. (-1 = at end). * * @return The item index. */ @@ -282,121 +290,121 @@ public: * @param receiver The slot's parent * @param enabled Enable or disable the button at startup * @param text The tooltip or toolbar text (depending on state) * @param index The position of the button. (-1 = at end). * * @return The item index. */ int insertButton(const QPixmap& pixmap, int id, const char *signal, const QObject *receiver, const char *slot, bool enabled = true, const QString& text = QString::null, int index=-1 ); /** * Inserts a button with popupmenu. * * Button will have small * triangle. You have to connect to popup's signals. The * signals @ref KButton::pressed(), @ref KButton::released(), * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not * emmited by * this button (see @ref setDelayedPopup() for that). * You can add custom popups which inherit @ref QPopupMenu to get popups * with tables, drawings etc. Just don't fiddle with events there. */ - int insertButton(const QString& icon, int id, QPopupMenu *popup, + int insertButton(const QString& icon, int id, Q3PopupMenu *popup, bool enabled, const QString&_text, int index=-1); /** * Inserts a button with popupmenu. * * Button will have small * triangle. You have to connect to popup's signals. The * signals @ref KButton::pressed(), @ref KButton::released(), * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not * emmited by * this button (see @ref setDelayedPopup() for that). * You can add custom popups which inherit @ref QPopupMenu to get popups * with tables, drawings etc. Just don't fiddle with events there. */ - int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, + int insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup, bool enabled, const QString&_text, int index=-1); /** * Inserts a @ref KLineEdit. You have to specify signals and slots to * which KLineEdit will be connected. KLineEdit has all slots QLineEdit * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation * KLineEdit can be set to autoresize itself to full free width * in toolbar, that is to last right aligned item. For that, * toolbar must be set to full width (which it is by default). * @see setFullWidth() * @see setItemAutoSized() * @see KLineEdit * @return Item index. */ int insertLined (const QString& text, int id, const char *signal, const QObject *receiver, const char *slot, bool enabled = true, const QString& toolTipText = QString::null, int size = 70, int index =-1); /** * Inserts a @ref KComboBox with list. * * Can be writable, but cannot contain * pixmaps. By default inserting policy is AtBottom, i.e. typed items * are placed at the bottom of the list. Can be autosized. If the size * argument is specified as -1, the width of the combobox is automatically * computed. * * @see setFullWidth() * @see setItemAutoSized() * @see KComboBox * @return Item index. */ int insertCombo (const QStringList &list, int id, bool writable, const char *signal, const QObject *receiver, const char *slot, bool enabled=true, const QString& tooltiptext=QString::null, int size=70, int index=-1, - QComboBox::Policy policy = QComboBox::AtBottom); + QComboBox::Policy policy = QComboBox::InsertAtBottom); /** * Insert a @ref KComboBox with text. * * The rest is the same as above. * @see setItemAutoSized() * * @see KComboBox * @return Item index. */ int insertCombo (const QString& text, int id, bool writable, const char *signal, QObject *recevier, const char *slot, bool enabled=true, const QString& tooltiptext=QString::null, int size=70, int index=-1, - QComboBox::Policy policy = QComboBox::AtBottom); + QComboBox::Policy policy = QComboBox::InsertAtBottom); /** * Inserts a separator into the toolbar with the given id. * Returns the separator's index */ int insertSeparator( int index = -1, int id = -1 ); /** * Inserts a line separator into the toolbar with the given id. * Returns the separator's index */ int insertLineSeparator( int index = -1, int id = -1 ); /** * Inserts a user-defined widget. The widget @p must have this * toolbar as its parent. * * Widget must have a QWidget for base class. Widget can be * autosized to full width. If you forget about it, you can get a * pointer to this widget with @ref getWidget(). * @see setItemAutoSized() * @return Item index. */ int insertWidget(int id, int width, QWidget *_widget, int index=-1); @@ -444,75 +452,75 @@ public: /** * Enables/disables item. */ void setItemEnabled( int id, bool enabled ); /** * Sets the icon for a button. * * Can be used while button is visible. */ void setButtonIcon( int id, const QString& _icon ); /** * Sets button pixmap. * * Can be used while button is visible. */ void setButtonPixmap( int id, const QPixmap& _pixmap ); /** * Sets a button icon from a QIconSet. * * Can be used while button is visible. */ - void setButtonIconSet( int id, const QIconSet& iconset ); + void setButtonIconSet( int id, const QIcon& iconset ); /** * Sets a delayed popup for a button. * * Delayed popup is what you see in * Netscape Navigator's Previous and Next buttons: If you click them you * go back * or forth. If you press them long enough, you get a history-menu. * This is exactly what we do here. * * You will insert normal a button with connection (or use signals from * toolbar): * <pre> * bar->insertButton(icon, id, SIGNAL(clicked ()), this, * SLOT (slotClick()), true, "click or wait for popup"); * </pre> And then add a delayed popup: * <pre> * bar->setDelayedPopup (id, historyPopup); </pre> * * Don't add delayed popups to buttons which have normal popups. * * You may add popups which are derived from @ref QPopupMenu. You may * add popups that are already in the menu bar or are submenus of * other popups. */ - void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); + void setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle = false); /** * Turns a button into an autorepeat button. * * Toggle buttons, buttons with menus, or * buttons with delayed menus cannot be made into autorepeat buttons. * Moreover, you can and will receive * only the signal clicked(), but not pressed() or released(). * When the user presses this button, you will receive the signal clicked(), * and if the button is still pressed after some time, * you will receive more clicked() signals separated by regular * intervals. Since this uses @ref QButton::setAutoRepeat() , * I can't quantify 'some'. */ void setAutoRepeat (int id, bool flag=true); /** * Turns button into a toggle button if @p flag is true. */ void setToggle (int id, bool flag = true); /** * Toggles a togglebutton. @@ -1039,72 +1047,72 @@ signals: * Used by KWidgetAction. * @since 3.2 */ void toolbarDestroyed(); public: /** * @return global setting for "Highlight buttons under mouse" */ void repaintMe(); static bool highlightSetting(); /** * @return global setting for "Toolbars transparent when moving" */ static bool transparentSetting(); /** * @return global setting for "Icon Text" */ static IconText iconTextSetting(); public slots: virtual void setIconText( const QString &txt ) - { QToolBar::setIconText( txt ); } + { Q3ToolBar::setIconText( txt ); } void slotRepaint(); protected: void mousePressEvent( QMouseEvent * ); void childEvent( QChildEvent *e ); void showEvent( QShowEvent *e ); void resizeEvent( QResizeEvent *e ); bool event( QEvent *e ); void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); QString settingsGroup(); private slots: void rebuildLayout(); void slotReadConfig (); void slotAppearanceChanged(); void slotIconChanged(int); - void toolBarPosChanged( QToolBar *tb ); + void toolBarPosChanged( Q3ToolBar *tb ); void slotContextAboutToShow(); void widgetDestroyed(); private: int sizeHintW; int sizeHintH; void init( bool readConfig = true, bool honorStyle = false ); void doConnections( KToolBarButton *button ); void insertWidgetInternal( QWidget *w, int &index, int id ); void removeWidgetInternal( QWidget *w ); void getAttributes( QString &position, QString &icontext, int &index ); //US KPopupMenu *contextMenu(); - QPopupMenu *contextMenu(); + Q3PopupMenu *contextMenu(); QMap<QWidget*, int > widget2id; typedef QMap<int, QWidget* > Id2WidgetMap; Id2WidgetMap id2widget; //US KPopupMenu *context; - QPopupMenu *context; - QPtrList<QWidget> widgets; + Q3PopupMenu *context; + Q3PtrList<QWidget> widgets; QTimer *layoutTimer; - QGuardedPtr<QWidget> stretchableWidget, rightAligned; + QPointer<QWidget> stretchableWidget, rightAligned; protected: virtual void virtual_hook( int id, void* data ); private: KToolBarPrivate *d; bool inshutdownprocess; }; #endif |