ktoolbar.h
/* This file is part of the KDE libraries
Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org)
(C) 1997, 1998 Stephan Kulow (coolo@kde.org)
(C) 1997, 1998 Sven Radej (radej@kde.org)
(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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KTOOLBAR_H
#define KTOOLBAR_H
#include <qtoolbar.h>
#include <qmainwindow.h>
#include <qcombobox.h>
#include <qmap.h>
#include <qptrlist.h>
#include <qguardedptr.h>
#include <qframe.h>
#include <qiconset.h>
#include <kglobal.h>
class QDomElement;
class QSize;
class QPixmap;
class QPopupMenu;
class QStringList;
class QDomDocument;
class QTimer;
class KLineEdit;
class KToolBar;
class KToolBarButton;
class KToolBoxManager;
class KAnimWidget;
class KPopupMenu;
class KInstance;
class KComboBox;
class KXMLGUIClient;
class KToolBarPrivate;
class KDEUI_EXPORT KToolBarSeparator : public QFrame
{
Q_OBJECT
public:
KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 );
QSize sizeHint() const;
Orientation orientation() const { return orient; }
QSizePolicy sizePolicy() const;
bool showLine() const { return line; }
public slots:
void setOrientation( Orientation );
protected:
void styleChange( QStyle& );
void drawContents( QPainter* );
private:
Orientation orient;
bool line;
};
class KDEUI_EXPORT KToolBar : public QToolBar
{
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 )
public:
enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom};
enum BarStatus{Toggle, Show, Hide};
enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat};
KToolBar( QWidget *parent, const char *name = 0, bool honorStyle = false, bool readConfig = true );
KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false,
const char *name = 0, bool honorStyle = false, bool readConfig = true );
KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false,
const char *name = 0, bool honorStyle = false, bool readConfig = true );
virtual ~KToolBar();
int insertButton(const QString& icon, int id, bool enabled = true,
const QString& text = QString::null, int index=-1,
KInstance *_instance = KGlobal::instance());
int insertButton(const QString& icon, int id, const char *signal,
const QObject *receiver, const char *slot,
bool enabled = true, const QString& text = QString::null,
int index=-1, KInstance *_instance = KGlobal::instance() );
int insertButton(const QPixmap& pixmap, int id, bool enabled = true,
const QString& text = QString::null, int index=-1 );
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 );
int insertButton(const QString& icon, int id, QPopupMenu *popup,
bool enabled, const QString&_text, int index=-1);
int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
bool enabled, const QString&_text, int index=-1);
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);
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);
int insertCombo (const QString& text, int id, bool writable,
const char *signal, QObject *receiver,
const char *slot, bool enabled=true,
const QString& tooltiptext=QString::null,
int size=70, int index=-1,
QComboBox::Policy policy = QComboBox::AtBottom);
int insertSeparator( int index = -1, int id = -1 );
int insertLineSeparator( int index = -1, int id = -1 );
int insertWidget(int id, int width, QWidget *_widget, int index=-1);
int insertAnimatedWidget(int id, QObject *receiver, const char *slot,
const QString& icons, int index = -1);
KAnimWidget *animatedWidget( int id );
void addConnection (int id, const char *signal,
const QObject *receiver, const char *slot);
void setItemEnabled( int id, bool enabled );
void setButtonIcon( int id, const QString& _icon );
void setButtonPixmap( int id, const QPixmap& _pixmap );
void setButtonIconSet( int id, const QIconSet& iconset );
void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false);
void setAutoRepeat (int id, bool flag=true);
void setToggle (int id, bool flag = true);
void toggleButton (int id);
void setButton (int id, bool flag);
bool isButtonOn (int id) const;
void setLinedText (int id, const QString& text);
QString getLinedText (int id) const;
void insertComboItem (int id, const QString& text, int index);
void insertComboList (int id, const QStringList &list, int index);
void removeComboItem (int id, int index);
void setCurrentComboItem (int id, int index);
void changeComboItem (int id, const QString& text, int index=-1);
void clearCombo (int id);
QString getComboItem (int id, int index=-1) const;
KComboBox * getCombo(int id);
KLineEdit * getLined (int id);
KToolBarButton * getButton (int id);
void alignItemRight (int id, bool right = true);
QWidget *getWidget (int id); // ### KDE4: make this const!
void setItemAutoSized (int id, bool yes = true);
void clear ();
void removeItem (int id);
void removeItemDelayed (int id);
void hideItem (int id);
void showItem (int id);
int itemIndex (int id); // ### KDE4: make this const!
int idAt(int index); // ### KDE4: make this const!
void setFullSize(bool flag = true);
bool fullSize() const;
void enableMoving(bool flag = true) KDE_DEPRECATED;
void setBarPos (BarPosition bpos);
BarPosition barPos() const;
bool enable(BarStatus stat) KDE_DEPRECATED;
void setMaxHeight (int h) KDE_DEPRECATED; // Set max height for vertical toolbars
int maxHeight() KDE_DEPRECATED;
void setMaxWidth (int dw) KDE_DEPRECATED;
int maxWidth() KDE_DEPRECATED;
void setTitle (const QString& _title);
void enableFloating (bool flag) KDE_DEPRECATED;
void setIconText(IconText it);
// Note: don't merge with the next one, it breaks Qt properties
void setIconText(IconText it, bool update);
IconText iconText() const;
void setIconSize(int size);
// Note: don't merge with the next one, it breaks Qt properties
void setIconSize(int size, bool update);
int iconSize() const;
int iconSizeDefault() const;
void setEnableContextMenu(bool enable = true);
bool contextMenuEnabled() const;
void setItemNoStyle(int id, bool no_style = true);
void setFlat (bool flag);
int count() const;
void saveState(); // BIC: remove for KDE4? This doesn't appear to be used internally,
// and apps use saveMainWindowSettings in KMainWindow anyway.
void saveSettings(KConfig *config, const QString &configGroup);
void applySettings(KConfig *config, const QString &configGroup,bool force);
// KDE4 merge with force=false
void applySettings(KConfig *config, const QString &configGroup);
/*
* Tell the toolbar what XML-GUI resource file it should use to save
* it's state. The state of the toolbar (position, size, etc) is
* saved in KConfig files if the application does not use XML-GUI
* but if the app does, then it's saved the XML file. This function
* allows this to happen.
*
* @param xmlfile The XML-GUI resource file to write to
* @param xml The DOM document for the XML-GUI building
* @internal
*/
// void setXML(const QString& xmlfile, const QDomDocument& xml);
void setXMLGUIClient( KXMLGUIClient *client );
void setText( const QString & txt );
QString text() const;
void setStretchableWidget( QWidget *w );
QSizePolicy sizePolicy() const;
bool highlight() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
QSize minimumSize() const;
void hide();
void show();
void updateRects( bool = false ) {}
void loadState( const QDomElement &e );
/*
* Save state into an XML element, called by KXMLGUIBuilder
*/
void saveState( QDomElement &e );
void positionYourself( bool force = false);
signals:
void clicked(int id);
void doubleClicked (int id);
void pressed(int);
void released(int);
void toggled(int);
void highlighted(int id, bool isHighlighted);
void highlighted(int id );
void moved( BarPosition );
void modechange ();
void toolbarDestroyed();
public:
static bool highlightSetting();
static bool transparentSetting();
static IconText iconTextSetting();
public slots:
virtual void setIconText( const QString &txt )
{ QToolBar::setIconText( txt ); }
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() const;
private slots:
void rebuildLayout();
void slotReadConfig ();
void slotAppearanceChanged();
void slotIconChanged(int);
void slotRepaint();
void toolBarPosChanged( QToolBar *tb );
void slotContextAboutToShow();
void slotContextAboutToHide();
void widgetDestroyed();
private:
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 );
int dockWindowIndex();
KPopupMenu *contextMenu();
void doModeChange();
QMap<QWidget*, int > widget2id;
typedef QMap<int, QWidget* > Id2WidgetMap;
Id2WidgetMap id2widget;
KPopupMenu *context;
QPtrList<QWidget> widgets;
QTimer *layoutTimer;
QGuardedPtr<QWidget> stretchableWidget, rightAligned;
protected:
virtual void virtual_hook( int id, void* data );
private:
KToolBarPrivate *d;
};
#endif
KAnimWidget
Standard "About KDE" dialog box.
Definition: kanimwidget.h:55
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document...
Definition: kxmlguiclient.h:43
KToolBar::BarPosition
BarPosition
Possible bar positions.
Definition: ktoolbar.h:123
KToolBarButton
A toolbar button.
Definition: ktoolbarbutton.h:44
KInstance
KGlobal::instance
static KInstance * instance()
KConfig
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:145
KToolBar
Floatable toolbar with auto resize.
Definition: ktoolbar.h:103
KToolBar::BarStatus
BarStatus
The state of the status bar.
Definition: ktoolbar.h:119
KComboBox
An enhanced combo box.
Definition: kcombobox.h:144
KNotifyClient::event
int event(const QString &message, const QString &text=QString::null) KDE_DEPRECATED

KDE Home | KDE Accessibility Home | Description of Access Keys