TabWidget.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * TabWidget.h - LMMS-tabwidget
  3. *
  4. * Copyright (c) 2005-2008 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 TAB_WIDGET_H
  25. #define TAB_WIDGET_H
  26. #include <QWidget>
  27. #include <QtCore/QMap>
  28. const int TEXT_TAB_HEIGHT = 14;
  29. const int GRAPHIC_TAB_HEIGHT = 17;
  30. class TabWidget : public QWidget
  31. {
  32. Q_OBJECT
  33. public:
  34. TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false );
  35. virtual ~TabWidget();
  36. void addTab( QWidget * w, const QString & name, const char *pixmap = NULL, int idx = -1 );
  37. void setActiveTab( int idx );
  38. int findTabAtPos( const QPoint *pos );
  39. inline int activeTab() const
  40. {
  41. return( m_activeTab );
  42. }
  43. // Themeability
  44. Q_PROPERTY( QColor tabText READ tabText WRITE setTabText)
  45. Q_PROPERTY( QColor tabTitleText READ tabTitleText WRITE setTabTitleText)
  46. Q_PROPERTY( QColor tabSelected READ tabSelected WRITE setTabSelected)
  47. Q_PROPERTY( QColor tabBackground READ tabBackground WRITE setTabBackground)
  48. Q_PROPERTY( QColor tabBorder READ tabBorder WRITE setTabBorder)
  49. QColor tabText() const;
  50. void setTabText( const QColor & c );
  51. QColor tabTitleText() const;
  52. void setTabTitleText( const QColor & c );
  53. QColor tabSelected() const;
  54. void setTabSelected( const QColor & c );
  55. QColor tabBackground() const;
  56. void setTabBackground( const QColor & c );
  57. QColor tabBorder() const;
  58. void setTabBorder( const QColor & c );
  59. protected:
  60. virtual bool event( QEvent * event );
  61. virtual void mousePressEvent( QMouseEvent * _me );
  62. virtual void paintEvent( QPaintEvent * _pe );
  63. virtual void resizeEvent( QResizeEvent * _re );
  64. virtual void wheelEvent( QWheelEvent * _we );
  65. private:
  66. struct widgetDesc
  67. {
  68. QWidget * w; // ptr to widget
  69. const char * pixmap; // artwork for the widget
  70. QString name; // name for widget
  71. int nwidth; // width of name when painting (only valid for text tab)
  72. } ;
  73. typedef QMap<int, widgetDesc> widgetStack;
  74. widgetStack m_widgets;
  75. int m_activeTab;
  76. QString m_caption; // Tab caption, used as the tooltip text on icon tabs
  77. quint8 m_tabbarHeight; // The height of the tab bar
  78. quint8 m_tabheight; // The height of the tabs
  79. bool m_usePixmap; // true if the tabs are to be displayed with icons. False for text tabs.
  80. QColor m_tabText; // The color of the tabs' text.
  81. QColor m_tabTitleText; // The color of the TabWidget's title text.
  82. QColor m_tabSelected; // The highlighting color for the selected tab.
  83. QColor m_tabBackground; // The TabWidget's background color.
  84. QColor m_tabBorder; // The TabWidget's borders color.
  85. } ;
  86. #endif