gambas-source-code/gb.qt4/src/CMenu.h

105 lines
2.5 KiB
C
Raw Normal View History

/***************************************************************************
CMenu.h
(c) 2000-2012 Benoît 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 2, 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., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#ifndef __CMENU_H
#define __CMENU_H
#include "gambas.h"
#include <QAction>
#include <QMenu>
#include <QMenuBar>
#include <QKeySequence>
#include <QList>
#include <QPoint>
#include "CWidget.h"
#include "CPicture.h"
#ifndef __CMENU_CPP
extern GB_DESC CMenuDesc[];
extern GB_DESC CMenuChildrenDesc[];
#else
#define THIS OBJECT(CMENU)
//#define CONTROL OBJECT(CWIDGET)
#define ACTION ((QAction *)((CWIDGET *)_object)->widget)
[DEVELOPMENT ENVIRONMENT] * BUG: The button that switches between form and class editor is not shown anymore when a module or a class is edited. [GB.GTK] * BUG: Font management was redesigned. It does not leak memory anymore, and now behaves like in gb.qt. * BUG: Tristate CheckBox controls now work as expected. * BUG: Destroy pending deleted controls before entering the event loop, to avoid some memory leaks if the event loop is immediately aborted. * BUG: Detach destroyed controls from their event listener, as in gb.qt. * BUG: Now menu shortcuts are active even if the menu bar is hidden. But the menu must be visible. To create an hidden active top-level menu, just set its Text property to NULL, but keep it visible. * NEW: Top-level menus with a void Text property are not shown anymore. * BUG: Showing and hiding top-level menu now work correctly. [GB.QT] * BUG: Font properties are correctly inherited between containers and children controls. * BUG: Showing a tray icon does not eat focus events anymore. * NEW: Top-level menus with a void Text property are not shown anymore. [GB.QT4] * BUG: Font properties are correctly inherited between containers and children controls. * BUG: Shortcut management was fixed. * BUG: Now menu shortcuts are active even if the menu bar is hidden. But the menu must be visible. To create an hidden active top-level menu, just set its Text property to NULL, but keep it visible. * NEW: Top-level menus with a void Text property are not shown anymore. * BUG: Showing and hiding top-level menu now work correctly. git-svn-id: svn://localhost/gambas/trunk@2034 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2009-06-22 13:16:34 +02:00
#define PARENT_ACTION ((QAction *)((CWIDGET *)(THIS->parent))->widget)
#define CMENU_is_toplevel(_menu) (GB.Is((_menu)->parent, CLASS_Window))
#define GET_MENU_SENDER(_menu) CMENU *_menu = CMenu::dict[((QMenu *)sender())->menuAction()]
#endif
typedef
struct _CMENU {
CWIDGET widget;
void *parent;
//QList<struct _CMENU *> children;
//QMenu *parentMenu;
//QMenuBar *parentMenuBar;
QWidget *toplevel;
QMenu *menu;
[DEVELOPMENT ENVIRONMENT] * BUG: The button that switches between form and class editor is not shown anymore when a module or a class is edited. [GB.GTK] * BUG: Font management was redesigned. It does not leak memory anymore, and now behaves like in gb.qt. * BUG: Tristate CheckBox controls now work as expected. * BUG: Destroy pending deleted controls before entering the event loop, to avoid some memory leaks if the event loop is immediately aborted. * BUG: Detach destroyed controls from their event listener, as in gb.qt. * BUG: Now menu shortcuts are active even if the menu bar is hidden. But the menu must be visible. To create an hidden active top-level menu, just set its Text property to NULL, but keep it visible. * NEW: Top-level menus with a void Text property are not shown anymore. * BUG: Showing and hiding top-level menu now work correctly. [GB.QT] * BUG: Font properties are correctly inherited between containers and children controls. * BUG: Showing a tray icon does not eat focus events anymore. * NEW: Top-level menus with a void Text property are not shown anymore. [GB.QT4] * BUG: Font properties are correctly inherited between containers and children controls. * BUG: Shortcut management was fixed. * BUG: Now menu shortcuts are active even if the menu bar is hidden. But the menu must be visible. To create an hidden active top-level menu, just set its Text property to NULL, but keep it visible. * NEW: Top-level menus with a void Text property are not shown anymore. * BUG: Showing and hiding top-level menu now work correctly. git-svn-id: svn://localhost/gambas/trunk@2034 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2009-06-22 13:16:34 +02:00
QKeySequence *accel;
CPICTURE *picture;
char *action;
unsigned deleted : 1;
unsigned toggle : 1;
//unsigned noshortcut : 1;
[INFORMER] * BUG: The informer algorithm was redesigned. Now a sub-process is launched for each component that should be analyzed, and LD_PRELOAD is used to load the component shared library before the process is launched. Otherwise, some component may crash. [GB.DRAW] * BUG: Correctly initialize color properties of the Draw class at Draw.Begin(). * NEW: Draw.FillRect() is a new method to draw a filled rectangle with the specified color. * NEW: Draw.Clear() is a new method that clears the drawing device with its background color. [GB.FORM.MDI] * NEW: Do not use BackColor and ForeColor properties anymore. [GB.GTK] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * BUG: Desktop.Resolution now uses the accurate GTK+ API. * BUG: Setting the ListBox.List to NULL property does not lock the ListBox control anymore. * BUG: Fix the Font object management. Using Font properties should not crash anymore. * BUG: Image.Save() and Picture.Save() now understand the "~" shortcut in path names. [GB.QT] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * NEW: Do not check if we should quit too often. * NEW: Allow windows to be closed during a WAIT instruction as in other components. I do not know why it was forbidden before. * NEW: Prevent a crash in arrangement routines if a child widget is not associated with a Gambas control anymore. [GB.QT4] * NEW: Control.Backcolor and Control.Forecolor properties were removed. * NEW: The source code is now up to date with gb.qt. But many things do not work as expected! [GB.QT4.EXT] * NEW: The source code is now up to date with gb.qt.ext. But many things do not work as expected! git-svn-id: svn://localhost/gambas/trunk@1776 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2009-01-03 23:24:02 +01:00
unsigned exec : 1;
unsigned checked : 1;
unsigned disabled : 1;
unsigned visible : 1;
}
CMENU;
typedef
QList<CMENU *> CMenuList;
class CMenu : public QObject
{
Q_OBJECT
public:
static CMenu manager;
static QHash<QAction *, CMENU *> dict;
//static void unrefChildren(QWidget *wid);
//static void enableAccel(CMENU *item, bool enable, bool rec = false);
static void hideSeparators(CMENU *item);
public slots:
void slotTriggered(QAction *);
void slotDestroyed();
void slotShown();
void slotHidden();
};
void CMENU_popup(CMENU *_object, const QPoint &pos);
#endif