2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
CMenu.h
|
|
|
|
|
|
|
|
The Menu class
|
|
|
|
|
|
|
|
(c) 2000-2007 Benoit Minisini <gambas@users.sourceforge.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 1, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CMENU_H
|
|
|
|
#define __CMENU_H
|
|
|
|
|
|
|
|
#include "gambas.h"
|
2008-04-29 15:40:55 +02:00
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
#include <QAction>
|
2008-04-29 15:40:55 +02:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QKeySequence>
|
|
|
|
#include <QList>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
#include "CWidget.h"
|
|
|
|
#include "CPicture.h"
|
|
|
|
|
|
|
|
#ifndef __CMENU_CPP
|
|
|
|
extern GB_DESC CMenuDesc[];
|
|
|
|
extern GB_DESC CMenuChildrenDesc[];
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define THIS OBJECT(CMENU)
|
2008-04-29 15:40:55 +02:00
|
|
|
//#define CONTROL OBJECT(CWIDGET)
|
|
|
|
#define ACTION ((QAction *)((CWIDGET *)_object)->widget)
|
2009-06-22 13:16:34 +02:00
|
|
|
#define PARENT_ACTION ((QAction *)((CWIDGET *)(THIS->parent))->widget)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
#define CMENU_is_toplevel(_menu) (GB.Is((_menu)->parent, CLASS_Window))
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-06-11 23:33:17 +02:00
|
|
|
#define GET_MENU_SENDER(_menu) CMENU *_menu = CMenu::dict[((QMenu *)sender())->menuAction()]
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct _CMENU {
|
|
|
|
CWIDGET widget;
|
2008-04-29 15:40:55 +02:00
|
|
|
void *parent;
|
|
|
|
//QList<struct _CMENU *> children;
|
|
|
|
//QMenu *parentMenu;
|
|
|
|
//QMenuBar *parentMenuBar;
|
2008-04-24 14:49:12 +02:00
|
|
|
QWidget *toplevel;
|
2008-04-29 15:40:55 +02:00
|
|
|
QMenu *menu;
|
2009-06-22 13:16:34 +02:00
|
|
|
QKeySequence *accel;
|
2008-04-29 15:40:55 +02:00
|
|
|
CPICTURE *picture;
|
2008-04-24 14:49:12 +02:00
|
|
|
unsigned deleted : 1;
|
|
|
|
unsigned toggle : 1;
|
2009-07-03 22:15:26 +02:00
|
|
|
//unsigned noshortcut : 1;
|
2009-01-03 23:24:02 +01:00
|
|
|
unsigned exec : 1;
|
2009-06-25 16:22:49 +02:00
|
|
|
unsigned checked : 1;
|
2009-06-27 17:25:11 +02:00
|
|
|
unsigned disabled : 1;
|
2009-07-04 14:38:56 +02:00
|
|
|
unsigned visible : 1;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
CMENU;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
QList<CMENU *> CMenuList;
|
|
|
|
|
|
|
|
|
|
|
|
class CMenu : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static CMenu manager;
|
2008-04-29 15:40:55 +02:00
|
|
|
static QHash<QAction *, CMENU *> dict;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-05-01 01:08:02 +02:00
|
|
|
//static void unrefChildren(QWidget *wid);
|
2009-07-03 22:15:26 +02:00
|
|
|
//static void enableAccel(CMENU *item, bool enable, bool rec = false);
|
2008-04-24 14:49:12 +02:00
|
|
|
static void hideSeparators(CMENU *item);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
void slotTriggered(QAction *);
|
|
|
|
void slotDestroyed();
|
|
|
|
void slotShown();
|
|
|
|
void slotHidden();
|
2008-04-24 14:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|