SideBarWidget.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * SideBarWidget.h - base-class for all side-bar-widgets
  3. *
  4. * Copyright (c) 2004-2009 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 SIDE_BAR_WIDGET_H
  25. #define SIDE_BAR_WIDGET_H
  26. #include <QPixmap>
  27. #include <QVBoxLayout>
  28. #include <QWidget>
  29. #include <QPushButton>
  30. class SideBarWidget : public QWidget
  31. {
  32. Q_OBJECT
  33. public:
  34. SideBarWidget( const QString & _title, const QPixmap & _icon,
  35. QWidget * _parent );
  36. virtual ~SideBarWidget();
  37. inline const QPixmap & icon() const
  38. {
  39. return m_icon;
  40. }
  41. inline const QString & title() const
  42. {
  43. return m_title;
  44. }
  45. signals:
  46. void closeButtonClicked();
  47. protected:
  48. void paintEvent( QPaintEvent * _pe ) override;
  49. void resizeEvent( QResizeEvent * _re ) override;
  50. void contextMenuEvent( QContextMenuEvent * ) override
  51. {
  52. }
  53. QWidget * contentParent()
  54. {
  55. return m_contents;
  56. }
  57. void addContentWidget( QWidget * _w )
  58. {
  59. m_layout->addWidget( _w );
  60. }
  61. void addContentLayout( QLayout * _l )
  62. {
  63. m_layout->addLayout( _l );
  64. }
  65. private:
  66. QWidget * m_contents;
  67. QVBoxLayout * m_layout;
  68. QString m_title;
  69. QPixmap m_icon;
  70. QPushButton * m_closeBtn;
  71. const QSize m_buttonSize;
  72. } ;
  73. #endif