⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmenu.cpp

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 CPP
字号:
/***************************************************************************  CMenu.cpp  The Menu class  (c) 2000-2003 Beno顃 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.***************************************************************************/#define __CMENU_CPP#include <qapplication.h>#include <qmainwindow.h>#include <qmenubar.h>#include <qaccel.h>#include <qcursor.h>#include <qiconset.h>#include <qpixmap.h>#include "gambas.h"#include "CWidget.h"#include "CWindow.h"#include "CMenu.h"//#define DEBUG_MENUstatic void *CLASS_Menu;static void *CLASS_Window;DECLARE_EVENT(EVENT_Click);DECLARE_EVENT(EVENT_Show);static long menu_id = 0;static int check_menu(void *object){  return ((CMENU *)object)->deleted;}static void set_text(CMENU *item, char *text){#ifdef DEBUG_MENU  qDebug("set_text: item->text = '%s' text = '%s'", item->text, text);#endif  if (item->text)  {    GB.FreeString(&item->text);    item->text = NULL;  }  if (text)    GB.NewString(&item->text, text, 0);}static void hide_menu(CMENU *item){  if (!CWIDGET_test_flag(item, WF_VISIBLE))    return;#ifdef DEBUG_MENU  qDebug("hide_menu: item = %p (%d)", item, item->id);#endif  //index = item->container->indexOf(item->id);  //if (index >= 0)  item->container->removeItem(item->id);  if (CMENU_is_top(item))  {    if (item->container->count() == 0)      ((QMenuBar *)item->container)->hide();  }  CWIDGET_clear_flag(item, WF_VISIBLE);}static void show_menu(CMENU *item){  CMENU *parent;  int pos;  //bool change;  QIconSet icon;  QString text;  if (CWIDGET_test_flag(item, WF_VISIBLE))    return;#ifdef DEBUG_MENU  qDebug("show_menu: item = %p (%d) parent = %p (%d)", item, item->id, item->parent, item->parent ? item->parent->id : 0);#endif  parent = item->parent;  if (parent)  {    /*    if (QPOPUPMENU(parent) == 0)    {#ifdef DEBUG_MENU      qDebug("show_menu: add_popup");#endif      QPopupMenu *popup = new QPopupMenu(item->toplevel);      change = CMENU_is_visible(parent);      if (change)        hide_menu(parent);      QPOPUPMENU(parent) = popup;      //parent->dict = new QIntDict<CMENU>;      QObject::connect(popup, SIGNAL(activated(int)), &CMenu::manager, SLOT(activated(int)));      QObject::connect(popup, SIGNAL(aboutToShow()), &CMenu::manager, SLOT(shown()));      QObject::connect(popup, SIGNAL(destroyed()), &CMenu::manager, SLOT(destroy()));      // un popupmenu est r閒閞enc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -