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

📄 qmmenubutton.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmmenubutton.cpp * * $Id: qmmenubutton.cpp,v 1.14 2002/03/07 03:44:16 mariuss Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team.  See CREDITS file. * * 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 * of the License, 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#include "qmmenubutton.h"#include <iostream>#include <qevent.h>#include <qiconset.h>#include <qpainter.h>#include <qpopupmenu.h>#include <qstyle.h>/** * @file qmmenubutton.cpp * @brief For creating buttons in toolbars that open a popup menu*//*!  \class QmMenuButton qmmenubutton.h  \brief For creating buttons in toolbars that open a popup menu.  This class acts as a QToolButton, except that it adds a small down  arrow of the right of the text/icon.  Clicking the arrow will emit  menuClicked() signal, while clicking on the icon will emit  iconClicked().  By passing the menu object to the constructor, the menu will be  brought up by the button.*//*! \fn void QmMenuButton::menuClicked()  Emitted when the menu part is clicked.  This shouldn't typically  be needed to show the menu as the menu will be popped up  for you.*//*! \fn void QmMenuButton::iconClicked()  Emitted when the icon part is clicked.*//*!  Constructs a new menu button.*/QmMenuButton::QmMenuButton(	const QIconSet &s,	const QString &textLabel,	QWidget *parent,	QPopupMenu *menu,	const char *name)	: QToolButton(parent, name),	  m_MouseOver(false),	  m_pMenu(menu){#ifdef USING_QT3    setIconSet( s );#else    	setOnIconSet( s );#endif    	setTextLabel( textLabel );		m_PixmapWidth = s.pixmap(QIconSet::Small, QIconSet::Normal).width();	setFixedWidth( m_PixmapWidth + 19 ); // space + arrowwidth + space + border}/*!  Destroys the menu button.*/QmMenuButton::~QmMenuButton(){}/*!  Reimplemented to draw down arrow and separator between icon and arrow. */voidQmMenuButton::drawButton(	QPainter *p){#ifdef USING_QT3#else        style().drawToolButton( this, p );#endif		QPixmap pixmap = onIconSet().pixmap(QIconSet::Small, QIconSet::Normal);	p->drawPixmap(3, 3, pixmap);#ifdef USING_QT3    style().drawPrimitive(QStyle::PE_ArrowDown, p,                          QRect(pixmap.width() + 10, height() / 2 - 2,                                5, 5),                          colorGroup(),                          QStyle::Style_Enabled);#else    	style().drawArrow(p, DownArrow, true,					  pixmap.width() + 10,					  height() / 2 - 2, 5, 5,					  colorGroup(), isEnabled());#endif    		if(m_MouseOver)	{		if(isDown())		{			p->setPen(colorGroup().light());			p->drawLine(pixmap.width() + 5, 1, pixmap.width() + 5, height() - 2);			p->setPen(colorGroup().dark());			p->drawLine(pixmap.width() + 6, 1, pixmap.width() + 6, height() - 2);		}		else		{			p->setPen(colorGroup().dark());			p->drawLine(pixmap.width() + 5, 1, pixmap.width() + 5, height() - 2);			p->setPen(colorGroup().light());			p->drawLine(pixmap.width() + 6, 1, pixmap.width() + 6, height() - 2);		}	}}/*!  Keeps state so that the button is drawn correctly. */voidQmMenuButton::enterEvent(	QEvent *e){	m_MouseOver = true;	QToolButton::enterEvent(e);}/*!  Keeps state so that the button is drawn correctly. */voidQmMenuButton::leaveEvent(	QEvent *e){	m_MouseOver = false;	QToolButton::leaveEvent(e);}/*!  Emits menuClicked() is the arrow region was clicked.  If the  icon region was clicked, iconClicked() will be emitted. */voidQmMenuButton::mouseReleaseEvent(	QMouseEvent *e){	if(m_MouseOver)	{		if(e->x() > m_PixmapWidth + 6)		{			emit menuClicked();			m_pMenu->popup(mapToGlobal(QPoint(0, height())));		}		else			emit iconClicked();	}	QToolButton::mouseReleaseEvent(e);}

⌨️ 快捷键说明

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