home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qaction.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  6KB  |  182 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qaction.h   3.0.0   edited Sep 25 11:04 $
  3. **
  4. ** Definition of QAction class
  5. **
  6. ** Created : 000000
  7. **
  8. ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QACTION_H
  39. #define QACTION_H
  40.  
  41. #ifndef QT_H
  42. #include "qobject.h"
  43. #include "qiconset.h"
  44. #include "qstring.h"
  45. #include "qkeysequence.h"
  46. #endif // QT_H
  47.  
  48. #ifndef QT_NO_ACTION
  49.  
  50. class QActionPrivate;
  51. class QActionGroupPrivate;
  52. class QStatusBar;
  53. class QPopupMenu;
  54.  
  55. class Q_EXPORT QAction : public QObject
  56. {
  57.     Q_OBJECT
  58.     Q_PROPERTY( bool toggleAction READ isToggleAction WRITE setToggleAction)
  59.     Q_PROPERTY( bool on READ isOn WRITE setOn )
  60.     Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
  61.     Q_PROPERTY( QIconSet iconSet READ iconSet WRITE setIconSet )
  62.     Q_PROPERTY( QString text READ text WRITE setText )
  63.     Q_PROPERTY( QString menuText READ menuText WRITE setMenuText )
  64.     Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
  65.     Q_PROPERTY( QString statusTip READ statusTip WRITE setStatusTip )
  66.     Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
  67.     Q_PROPERTY( QKeySequence accel READ accel WRITE setAccel )
  68.  
  69. public:
  70.     QAction( QObject* parent, const char* name = 0, bool toggle = FALSE  );
  71.     QAction( const QString& text, const QIconSet& icon, const QString& menuText, QKeySequence accel,
  72.          QObject* parent, const char* name = 0, bool toggle = FALSE );
  73.     QAction( const QString& text, const QString& menuText, QKeySequence accel, QObject* parent,
  74.          const char* name = 0, bool toggle = FALSE );
  75.     ~QAction();
  76.  
  77.     virtual void setIconSet( const QIconSet& );
  78.     QIconSet iconSet() const;
  79.     virtual void setText( const QString& );
  80.     QString text() const;
  81.     virtual void setMenuText( const QString& );
  82.     QString menuText() const;
  83.     virtual void setToolTip( const QString& );
  84.     QString toolTip() const;
  85.     virtual void setStatusTip( const QString& );
  86.     QString statusTip() const;
  87.     virtual void setWhatsThis( const QString& );
  88.     QString whatsThis() const;
  89.     virtual void setAccel( const QKeySequence& key );
  90.     QKeySequence accel() const;
  91.     virtual void setToggleAction( bool );
  92.     bool isToggleAction() const;
  93.     bool isOn() const;
  94.     bool isEnabled() const;
  95.     virtual bool addTo( QWidget* );
  96.     virtual bool removeFrom( QWidget* );
  97.  
  98. protected:
  99.     virtual void addedTo( QWidget *actionWidget, QWidget *container );
  100.     virtual void addedTo( int index, QPopupMenu *menu );
  101.  
  102. public slots:
  103.     void toggle();
  104.     virtual void setOn( bool );
  105.     virtual void setEnabled( bool );
  106.  
  107. signals:
  108.     void activated();
  109.     void toggled( bool );
  110.  
  111. private slots:
  112.     void internalActivation();
  113.     void toolButtonToggled( bool );
  114.     void objectDestroyed();
  115.     void menuStatusText( int id );
  116.     void showStatusText( const QString& );
  117.     void clearStatusText();
  118.  
  119. private:
  120.     void init();
  121.  
  122.     QActionPrivate* d;
  123.  
  124. };
  125.  
  126. class Q_EXPORT QActionGroup : public QAction
  127. {
  128.     Q_OBJECT
  129.     Q_PROPERTY( bool exclusive READ isExclusive WRITE setExclusive )
  130.     Q_PROPERTY( bool usesDropDown READ usesDropDown WRITE setUsesDropDown )
  131.  
  132. public:
  133.     QActionGroup( QObject* parent, const char* name = 0, bool exclusive = TRUE );
  134.     ~QActionGroup();
  135.     void setExclusive( bool );
  136.     bool isExclusive() const;
  137.     void add( QAction* a);
  138.     void addSeparator();
  139.     bool addTo( QWidget* );
  140.     bool removeFrom( QWidget* );
  141.     void setEnabled( bool );
  142.  
  143.     void setUsesDropDown( bool enable );
  144.     bool usesDropDown() const;
  145.  
  146.     void setIconSet( const QIconSet& );
  147.     void setText( const QString& );
  148.     void setMenuText( const QString& );
  149.     void setToolTip( const QString& );
  150.     void setWhatsThis( const QString& );
  151.  
  152. protected:
  153.     void childEvent( QChildEvent* );
  154.     virtual void addedTo( QWidget *actionWidget, QWidget *container, QAction *a );
  155.     virtual void addedTo( int index, QPopupMenu *menu, QAction *a );
  156.     virtual void addedTo( QWidget *actionWidget, QWidget *container );
  157.     virtual void addedTo( int index, QPopupMenu *menu );
  158.  
  159. signals:
  160.     void selected( QAction* );
  161.  
  162. private slots:
  163.     void childToggled( bool );
  164.     void childDestroyed();
  165.     void internalComboBoxActivated( int );
  166.     void internalToggle( QAction* );
  167.     void objectDestroyed();
  168.  
  169. private:
  170.     QActionGroupPrivate* d;
  171.  
  172. #ifndef QT_NO_COMPAT
  173. public:
  174.     void insert( QAction* a ) { add( a ); }
  175. #endif
  176.  
  177. };
  178.  
  179. #endif
  180.  
  181. #endif
  182.