]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxMenuButton.h
Salome HOME
62effa2da117c024ddbce6d04ab57e26c2ac746b
[modules/gui.git] / src / Qtx / QtxMenuButton.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 // File:      QtxMenuButton.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTXMENUBUTTON_H
23 #define QTXMENUBUTTON_H
24
25 #include "Qtx.h"
26
27 #include <qpushbutton.h>
28
29 class QIconSet;
30 class QPopupMenu;
31
32 class QTX_EXPORT QtxMenuButton : public QPushButton
33 {
34     Q_OBJECT
35
36     class PopupMenu;
37
38 public:
39     enum { Left, Right, Top, Bottom };
40
41 public:
42     QtxMenuButton( int, QWidget* = 0, const char* = 0 );
43         QtxMenuButton( const QString&, QWidget* = 0, const char* = 0 );
44         QtxMenuButton( int, const QString&, QWidget* = 0, const char* = 0 );
45         QtxMenuButton( QWidget* = 0, const char* = 0 );
46         virtual ~QtxMenuButton();
47
48         int           position() const;
49         void          setPosition( const int );
50
51     bool          isAlignWidth() const;
52     void          setAlignWidth( const bool );
53
54         bool          isArrowEnabled() const;
55         void          setArrowEnabled( const bool );
56
57         void          clear();
58         void          removeItem( int );
59         int           insertSeparator( int = -1 );
60         int           insertItem( const QString&, int = -1, int = -1 );
61         int           insertItem( const QIconSet&, const QString&, int = -1, int = -1 );
62
63         virtual QSize sizeHint() const;
64         virtual QSize minimumSizeHint() const;
65
66 signals:
67         void          activated( int );
68
69 private slots:
70         void          onShowPopup();
71
72 protected:
73     QPopupMenu*   popup() const;
74         virtual bool  event( QEvent* );
75         virtual void  resizeEvent( QResizeEvent* );
76         virtual void  drawButtonLabel( QPainter* );
77
78 private:
79     void          initialize();
80
81 private:
82         int           myPos;
83         bool          myArrow;
84     bool          myAlign;
85         QPopupMenu*   myPopup;
86 };
87
88 #endif