1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 // File: QtxListAction.hxx
20 // Author: Sergey TELKOV (Based on code by Eugene AKSENOV)
22 #ifndef QTXLISTACTION_H
23 #define QTXLISTACTION_H
25 #include "QtxAction.h"
29 #include <qstringlist.h>
40 #pragma warning( disable:4251 )
43 class QTX_EXPORT QtxListAction : public QtxAction
47 Q_PROPERTY( QStringList names READ names WRITE addNames )
52 enum { Item, SubMenu } PopupMode;
55 QtxListAction( QObject* = 0, const char* = 0, bool = false );
56 QtxListAction( const QString&, const QIconSet&, const QString&, int, QObject*, const char* = 0, bool = false );
57 QtxListAction( const QString&, const QString&, int, QObject*, const char* = 0, bool = false );
58 virtual ~QtxListAction();
61 virtual bool addTo( QWidget* );
62 virtual bool addTo( QWidget*, const int );
64 virtual bool removeFrom( QWidget* );
65 virtual bool eventFilter( QObject*, QEvent* );
67 int popupMode() const;
68 void setPopupMode( const int );
70 QStringList names() const;
71 void addNames( const QStringList&, bool = true );
72 void setComment( const QString&, const QString& = QString::null );
74 void setMaxLines( int );
75 void setMaxLineChars( int );
78 void activated( int );
81 virtual void setEnabled( bool );
86 void onExpand( bool );
87 void onMultiple( int );
88 void onActivated( int );
89 void onDestroyed( QObject* );
92 virtual void addedTo( QWidget*, QWidget* );
96 QWidget* widget( QWidget* ) const;
97 QPopupMenu* listPopup( QWidget* ) const;
98 QToolButton* mainButton( QWidget* ) const;
99 QToolButton* dropButton( QWidget* ) const;
101 void controlDeleted( QWidget* );
104 typedef struct { int id; QPopupMenu* popup; } Popups;
105 typedef struct { QToolButton* main; QToolButton* drop; } Buttons;
106 typedef QMap<QWidget*, Popups> PopupsMap;
107 typedef QMap<QWidget*, Buttons> ButtonsMap;
111 QtxListFrame* myFrame;
114 ButtonsMap myButtons;
115 QToolTipGroup* myTipGroup;
117 friend class ToolButton;
118 friend class QtxListFrame;
124 class QtxListFrame : public QFrame
131 QtxListFrame( QtxListAction*, QWidget* parent, WFlags f = 0 );
132 virtual ~QtxListFrame();
135 const QStringList names() const;
136 void addNames( const QStringList& );
138 void setSingleComment( const QString& );
139 void setMultipleComment( const QString& );
141 int selected() const;
142 void setSelected( const int );
144 void setMaxLines( int );
145 void setMaxLineChars( int );
147 virtual bool event( QEvent* );
148 virtual bool eventFilter( QObject*, QEvent* );
150 void setOwner( QWidget* );
152 void updateComment();
156 void selected( int );
166 void onScroll( int, int );
169 void setNames( const QStringList& );
170 bool handleKeyEvent( QObject*, QKeyEvent* );
171 bool handleMouseEvent( QObject*, QMouseEvent* );
173 friend class QtxListAction;
179 QtxListAction* myAction;
182 QString mySingleComment;
183 QString myMultipleComment;
193 #pragma warning( default:4251 )