ComboBox.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * ComboBox.h - class ComboBox, a combo box view for models
  3. *
  4. * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef COMBOBOX_H
  25. #define COMBOBOX_H
  26. #include <QMenu>
  27. #include <QWidget>
  28. #include "ComboBoxModel.h"
  29. #include "AutomatableModelView.h"
  30. class LMMS_EXPORT ComboBox : public QWidget, public IntModelView
  31. {
  32. Q_OBJECT
  33. public:
  34. ComboBox( QWidget* parent = NULL, const QString& name = QString() );
  35. virtual ~ComboBox();
  36. ComboBoxModel* model()
  37. {
  38. return castModel<ComboBoxModel>();
  39. }
  40. const ComboBoxModel* model() const
  41. {
  42. return castModel<ComboBoxModel>();
  43. }
  44. public slots:
  45. void selectNext();
  46. void selectPrevious();
  47. protected:
  48. void contextMenuEvent( QContextMenuEvent* event ) override;
  49. void mousePressEvent( QMouseEvent* event ) override;
  50. void paintEvent( QPaintEvent* event ) override;
  51. void wheelEvent( QWheelEvent* event ) override;
  52. private:
  53. static QPixmap* s_background;
  54. static QPixmap* s_arrow;
  55. static QPixmap* s_arrowSelected;
  56. QMenu m_menu;
  57. bool m_pressed;
  58. private slots:
  59. void setItem( QAction* item );
  60. } ;
  61. #endif