2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
CMenu.h
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
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
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2008-04-24 14:49:12 +02:00
|
|
|
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
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#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>
|
2010-07-22 02:29:53 +02:00
|
|
|
#include <QPoint>
|
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;
|
2011-09-01 16:19:34 +02:00
|
|
|
char *action;
|
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
|
|
|
};
|
|
|
|
|
2010-07-22 02:29:53 +02:00
|
|
|
void CMENU_popup(CMENU *_object, const QPoint &pos);
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
#endif
|