1
/**********************************************************************
2
** Copyright (C) 2003 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
**********************************************************************/
27
#ifndef MENUBAREDITOR_H
28
#define MENUBAREDITOR_H
33
class PopupMenuEditor;
37
class MenuBarEditorItem : public QObject
41
friend class MenuBarEditor;
43
MenuBarEditorItem( MenuBarEditor * bar = 0, QObject * parent = 0, const char * name = 0 );
46
MenuBarEditorItem( PopupMenuEditor * menu, MenuBarEditor * bar,
47
QObject * parent = 0, const char * name = 0);
48
MenuBarEditorItem( QActionGroup * actionGroup, MenuBarEditor * bar,
49
QObject * parent = 0, const char * name = 0);
50
MenuBarEditorItem( MenuBarEditorItem * item,
51
QObject * parent = 0, const char * name = 0);
52
~MenuBarEditorItem() { };
54
PopupMenuEditor * menu() { return popupMenu; }
56
void setMenuText( const QString t ) { text = t; };
57
QString menuText() { return text; }
59
void setVisible( bool enable ) { visible = enable; }
60
bool isVisible() { return visible; }
62
void setRemovable( bool enable ) { removable = enable; }
63
bool isRemovable() { return removable; }
65
bool isSeparator() { return separator; }
67
void setSeparator( bool enable ) { separator = enable; }
70
MenuBarEditor * menuBar;
71
PopupMenuEditor * popupMenu;
81
class MenuBarEditor : public QMenuBar
86
MenuBarEditor( FormWindow * fw, QWidget * parent = 0, const char * name = 0 );
89
FormWindow * formWindow();
91
MenuBarEditorItem * createItem( int index = -1, bool addToCmdStack = TRUE );
92
void insertItem( MenuBarEditorItem * item, int index = -1 );
93
void insertItem( QString text, PopupMenuEditor * menu, int index = -1 );
94
void insertItem( QString text, QActionGroup * group, int index = -1 );
96
void insertSeparator( int index = -1 );
98
void removeItemAt( int index );
99
void removeItem( MenuBarEditorItem * item );
101
int findItem( MenuBarEditorItem * item );
102
int findItem( PopupMenuEditor * menu );
103
int findItem( QPoint & pos );
105
MenuBarEditorItem * item( int index = -1 );
110
void cut( int index );
111
void copy( int index );
112
void paste( int index );
113
void exchange( int a, int b );
115
void showLineEdit( int index = -1);
116
void showItem( int index = -1 );
117
void hideItem( int index = -1 );
118
void focusItem( int index = -1 );
119
void deleteItem( int index = -1 );
121
QSize sizeHint() const;
122
QSize minimumSize() const { return sizeHint(); }
123
QSize minimumSizeHint() const { return sizeHint(); }
124
int heightForWidth( int max_width ) const;
128
void checkAccels( QMap<QChar, QWidgetList > &accels );
136
bool eventFilter( QObject * o, QEvent * e );
137
void paintEvent( QPaintEvent * e );
138
void mousePressEvent( QMouseEvent * e );
139
void mouseDoubleClickEvent( QMouseEvent * e );
140
void mouseMoveEvent( QMouseEvent * e );
141
void dragEnterEvent( QDragEnterEvent * e );
142
void dragLeaveEvent( QDragLeaveEvent * e );
143
void dragMoveEvent( QDragMoveEvent * e );
144
void dropEvent( QDropEvent * e );
145
void keyPressEvent( QKeyEvent * e );
146
void focusOutEvent( QFocusEvent * e );
147
void resizeEvent( QResizeEvent * e ) { QFrame::resizeEvent( e ); }
149
void resizeInternals();
151
void drawItems( QPainter & p );
152
void drawItem( QPainter & p, MenuBarEditorItem * i, int idx, QPoint & pos );
153
void drawSeparator( QPainter & p, QPoint & pos );
155
QSize itemSize( MenuBarEditorItem * i );
156
void addItemSizeToCoords( MenuBarEditorItem * i, int & x, int & y, int w );
158
QPoint itemPos( int index );
159
QPoint snapToItem( const QPoint & pos );
160
void dropInPlace( MenuBarEditorItem * i, const QPoint & pos );
165
void navigateLeft( bool ctrl );
166
void navigateRight( bool ctrl );
167
void enterEditMode();
168
void leaveEditMode();
170
QPixmap createTextPixmap( const QString &text );
171
int borderSize() const { return margin() + 4; } // add 4 pixels to the margin
174
FormWindow * formWnd;
175
QLineEdit * lineEdit;
177
QPtrList<MenuBarEditorItem> itemList;
178
MenuBarEditorItem addItem;
179
MenuBarEditorItem addSeparator;
180
MenuBarEditorItem * draggedItem;
181
QPoint mousePressPos;
189
enum ClipboardOperation {
194
static int clipboardOperation;
195
static MenuBarEditorItem * clipboardItem;
198
#endif //MENUBAREDITOR_H