1
/**********************************************************************
2
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
4
** This file is part of Qt Designer.
6
** This file may be distributed and/or modified under the terms of the
7
** GNU General Public License version 2 as published by the Free Software
8
** Foundation and appearing in the file LICENSE.GPL included in the
9
** packaging of this file.
11
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12
** licenses may use this file in accordance with the Qt Commercial License
13
** Agreement provided with the Software.
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
** See http://www.trolltech.com/gpl/ for GPL licensing information.
19
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20
** information about Qt Commercial License Agreements.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
**********************************************************************/
31
#include <qdragobject.h>
35
#include <qpopupmenu.h>
38
#include <qguardedptr.h>
39
#include "../shared/widgetdatabase.h"
41
//class QDesignerPopupMenu;
42
class QDesignerIndicatorWidget;
46
class QDesignerIndicatorWidget : public QWidget
51
QDesignerIndicatorWidget( QWidget *p )
52
: QWidget( p, "qt_dockwidget_internal" ) {
53
setBackgroundColor( red );
58
class ActionDrag : public QStoredDrag
63
ActionDrag(const QString &type, QAction *action, QWidget *source);
64
ActionDrag(QAction *action, QWidget *source);
65
ActionDrag(QActionGroup *group, QWidget *source);
69
static bool canDecode(QDropEvent *e);
71
static QAction *action()
77
static QAction *the_action;
80
class QDesignerActionGroup : public QActionGroup
85
QDesignerActionGroup( QObject *parent )
86
: QActionGroup( ::qt_cast<QActionGroup*>(parent) ? parent : 0 ), wid( 0 ), idx( -1 ) { init(); }
90
QWidget *widget() const { return wid; }
91
QWidget *widget( QAction *a ) const { return *widgets.find( a ); }
92
int index() const { return idx; }
95
#if !defined(Q_NO_USING_KEYWORD)
96
using QActionGroup::addedTo;
98
void addedTo( QWidget *w, QWidget * ) {
101
void addedTo( QWidget *w, QWidget *, QAction *a ) {
102
widgets.insert( a, w );
104
void addedTo( int index, QPopupMenu * ) {
110
QMap<QAction *, QWidget *> widgets;
115
class QDesignerAction : public QAction
120
QDesignerAction( QObject *parent )
121
: QAction( ::qt_cast<QActionGroup*>(parent) ? parent : 0 ), wid( 0 ), idx( -1 ), widgetToInsert( 0 ) { init(); }
122
QDesignerAction( QWidget *w, QObject *parent )
123
: QAction( ::qt_cast<QActionGroup*>(parent) ? parent : 0 ), wid( 0 ), idx( -1 ), widgetToInsert( w ) { init(); }
127
QWidget *widget() const { return wid; }
128
int index() const { return idx; }
130
bool addTo( QWidget *w );
131
bool removeFrom( QWidget *w );
134
bool supportsMenu() const { return !widgetToInsert; }
137
void addedTo( QWidget *w, QWidget * ) {
140
void addedTo( int index, QPopupMenu * ) {
147
QWidget *widgetToInsert;
151
class QDesignerToolBarSeparator : public QWidget
156
QDesignerToolBarSeparator( Orientation, QToolBar *parent, const char* name=0 );
158
QSize sizeHint() const;
159
Orientation orientation() const { return orient; }
161
void setOrientation( Orientation );
163
void styleChange( QStyle& );
164
void paintEvent( QPaintEvent * );
170
class QSeparatorAction : public QAction
175
QSeparatorAction( QObject *parent );
177
bool addTo( QWidget *w );
178
bool removeFrom( QWidget *w );
179
QWidget *widget() const;
189
class QDesignerToolBar : public QToolBar
194
QDesignerToolBar( QMainWindow *mw );
195
QDesignerToolBar( QMainWindow *mw, Dock dock );
196
QPtrList<QAction> insertedActions() const { return actionList; }
197
void addAction( QAction *a );
200
void installEventFilters( QWidget *w );
201
void insertAction( QWidget *w, QAction *a ) { actionMap.insert( w, a ); }
202
void insertAction( int index, QAction *a ) { actionList.insert( index, a ); }
203
void appendAction( QAction *a ) { actionList.append( a ); }
204
void removeAction( QAction *a ) { actionList.remove( a ); }
206
void removeWidget( QWidget *w );
209
bool eventFilter( QObject *, QEvent * );
210
void paintEvent( QPaintEvent * );
211
#ifndef QT_NO_DRAGANDDROP
212
void dragEnterEvent( QDragEnterEvent * );
213
void dragMoveEvent( QDragMoveEvent * );
214
void dragLeaveEvent( QDragLeaveEvent * );
215
void dropEvent( QDropEvent * );
217
void contextMenuEvent( QContextMenuEvent *e );
218
void mousePressEvent( QMouseEvent *e );
219
void mouseReleaseEvent( QMouseEvent *e );
222
void actionRemoved();
225
void drawIndicator( const QPoint &pos );
226
QPoint calcIndicatorPos( const QPoint &pos );
227
void buttonContextMenuEvent( QContextMenuEvent *e, QObject *o );
228
void buttonMousePressEvent( QMouseEvent *e, QObject *o );
229
void buttonMouseMoveEvent( QMouseEvent *e, QObject *o );
230
void buttonMouseReleaseEvent( QMouseEvent *e, QObject *o );
231
void doInsertWidget( const QPoint &p );
232
void findFormWindow();
235
QPoint lastIndicatorPos;
236
QWidget *insertAnchor;
238
QPtrList<QAction> actionList;
239
QMap<QWidget*, QAction*> actionMap;
241
QDesignerIndicatorWidget *indicator;
242
bool widgetInserting;
243
FormWindow *formWindow;