Files
lmms/include/combobox.h
Tobias Doerffel aa08d06068 * plugins and core: use new pluginPixmapLoader
* lmmsStyle-class: load stylesheet here
* comboBox/comboBoxModel: use pixmapLoader-pointers rather than QPixmap-pointers
* in plugin-descriptor, hold a pointer to pixmapLoader instead of QPixmap itself
* embed-framework: introduced pixmapLoader and pluginPixmapLoader-classes for abstracting QPixmap-instantiation - models can hold pixmapLoaders without actually instantiating a QPixmap-object and views can access the pixmap
* main-window: removed settings-menu and moved setup-dialog to edit-menu
* config-manager: removed all the obsolete first-startup-wizard-code



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@999 0778d3d1-df1d-0410-868b-ea421aaaa00d
2008-05-20 23:41:45 +00:00

132 lines
2.8 KiB
C++

/*
* combobox.h - class comboBox, a very cool combo-box
*
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.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 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _COMBOBOX_H
#define _COMBOBOX_H
#include <QtGui/QWidget>
#include <QtCore/QVector>
#include <QtGui/QMenu>
#include <QtCore/QPair>
#include "automatable_model.h"
#include "templates.h"
class pixmapLoader;
class comboBoxModel : public intModel
{
Q_OBJECT
public:
comboBoxModel( ::model * _parent = NULL ) :
automatableModel<int>( 0, 0, 0, defaultRelStep(), _parent )
{
}
void addItem( const QString & _item, pixmapLoader * _loader = NULL );
void clear( void );
int findText( const QString & _txt ) const;
inline const QString & currentText( void ) const
{
return( m_items[value()].first );
}
inline const pixmapLoader * currentData( void ) const
{
return( m_items[value()].second );
}
inline const QString & itemText( int _i ) const
{
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
first );
}
inline const pixmapLoader * itemPixmap( int _i ) const
{
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
second );
}
inline int size( void ) const
{
return( m_items.size() );
}
private:
typedef QPair<QString, pixmapLoader *> item;
QVector<item> m_items;
} ;
class comboBox : public QWidget, public intModelView
{
Q_OBJECT
public:
comboBox( QWidget * _parent, const QString & _name = QString::null );
virtual ~comboBox();
comboBoxModel * model( void )
{
return( castModel<comboBoxModel>() );
}
const comboBoxModel * model( void ) const
{
return( castModel<comboBoxModel>() );
}
protected:
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void mousePressEvent( QMouseEvent * _me );
virtual void paintEvent( QPaintEvent * _pe );
virtual void wheelEvent( QWheelEvent * _we );
private:
static QPixmap * s_background;
static QPixmap * s_arrow;
static QPixmap * s_arrowSelected;
QMenu m_menu;
bool m_pressed;
private slots:
void setItem( QAction * _item );
} ;
#endif