lmms
Cross-platform music production software
Loading...
Searching...
No Matches
TabWidget.h
Go to the documentation of this file.
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
25#ifndef LMMS_GUI_TAB_WIDGET_H
26#define LMMS_GUI_TAB_WIDGET_H
27
28#include <QWidget>
29#include <QMap>
30
31namespace lmms::gui
32{
33
34const int TEXT_TAB_HEIGHT = 14;
35const int GRAPHIC_TAB_HEIGHT = 17;
36
37class TabWidget : public QWidget
38{
39 Q_OBJECT
40public:
47 const QString& caption,
48 QWidget* parent,
49 bool usePixmap = false,
50 bool resizable = false
51 );
52 ~TabWidget() override = default;
53
54 void addTab(QWidget* w, const QString& name, const char* pixmap = nullptr, int idx = -1);
55
56 void setActiveTab(int idx);
57
58 int findTabAtPos(const QPoint& pos);
59
60 inline int activeTab() const
61 {
62 return(m_activeTab);
63 }
64
65 // Themeability
66 Q_PROPERTY(QColor tabText READ tabText WRITE setTabText)
67 Q_PROPERTY(QColor tabTitleText READ tabTitleText WRITE setTabTitleText)
68 Q_PROPERTY(QColor tabSelected READ tabSelected WRITE setTabSelected)
70 Q_PROPERTY(QColor tabBackground READ tabBackground WRITE setTabBackground)
71 Q_PROPERTY(QColor tabBorder READ tabBorder WRITE setTabBorder)
72
73 QColor tabText() const;
74 void setTabText(const QColor & c);
75 QColor tabTitleText() const;
76 void setTabTitleText(const QColor & c);
77 QColor tabSelected() const;
78 void setTabSelected(const QColor & c);
79 QColor tabTextSelected() const;
80 void setTabTextSelected(const QColor & c);
81 QColor tabBackground() const;
82 void setTabBackground(const QColor & c);
83 QColor tabBorder() const;
84 void setTabBorder(const QColor & c);
85
86protected:
87 bool event(QEvent* event) override;
88 void mousePressEvent(QMouseEvent* me) override;
89 void paintEvent(QPaintEvent* pe) override;
90 void resizeEvent(QResizeEvent* re) override;
91 void wheelEvent(QWheelEvent* we) override;
92 QSize minimumSizeHint() const override;
93 QSize sizeHint() const override;
94
95private:
97 {
98 QWidget* w; // ptr to widget
99 const char* pixmap; // artwork for the widget
100 QString name; // name for widget
101 int nwidth; // width of name when painting (only valid for text tab)
102 } ;
103 using widgetStack = QMap<int, widgetDesc>;
104
106
109 QString m_caption; // Tab caption, used as the tooltip text on icon tabs
110 quint8 m_tabbarHeight; // The height of the tab bar
111 quint8 m_tabheight; // The height of the tabs
112 bool m_usePixmap; // true if the tabs are to be displayed with icons. False for text tabs.
113
114 QColor m_tabText; // The color of the tabs' text.
115 QColor m_tabTitleText; // The color of the TabWidget's title text.
116 QColor m_tabSelected; // The highlighting color for the selected tab.
117 QColor m_tabTextSelected;// The text color for the selected tab.
118 QColor m_tabBackground; // The TabWidget's background color.
119 QColor m_tabBorder; // The TabWidget's borders color.
120} ;
121
122
123} // namespace lmms::gui
124
125#endif // LMMS_GUI_TAB_WIDGET_H
void setTabText(const QColor &c)
Definition TabWidget.cpp:383
bool m_usePixmap
Definition TabWidget.h:112
QSize minimumSizeHint() const override
Definition TabWidget.cpp:322
QColor m_tabSelected
Definition TabWidget.h:116
widgetStack m_widgets
Definition TabWidget.h:105
QColor tabText
Definition TabWidget.h:66
void paintEvent(QPaintEvent *pe) override
Definition TabWidget.cpp:212
QColor tabTextSelected
Definition TabWidget.h:69
QColor m_tabBorder
Definition TabWidget.h:119
QColor tabBorder
Definition TabWidget.h:71
~TabWidget() override=default
void setTabBorder(const QColor &c)
Definition TabWidget.cpp:431
quint8 m_tabheight
Definition TabWidget.h:111
int findTabAtPos(const QPoint &pos)
Definition TabWidget.cpp:126
QMap< int, widgetDesc > widgetStack
Definition TabWidget.h:103
void setTabTitleText(const QColor &c)
Definition TabWidget.cpp:371
quint8 m_tabbarHeight
Definition TabWidget.h:110
void setActiveTab(int idx)
Definition TabWidget.cpp:108
int m_activeTab
Definition TabWidget.h:108
TabWidget(const QString &caption, QWidget *parent, bool usePixmap=false, bool resizable=false)
Definition TabWidget.cpp:41
void setTabSelected(const QColor &c)
Definition TabWidget.cpp:395
void mousePressEvent(QMouseEvent *me) override
Definition TabWidget.cpp:181
bool event(QEvent *event) override
Definition TabWidget.cpp:151
QColor m_tabBackground
Definition TabWidget.h:118
QColor tabBackground
Definition TabWidget.h:70
void resizeEvent(QResizeEvent *re) override
Definition TabWidget.cpp:198
int activeTab() const
Definition TabWidget.h:60
QColor m_tabTitleText
Definition TabWidget.h:115
QSize sizeHint() const override
Definition TabWidget.cpp:343
void setTabTextSelected(const QColor &c)
Definition TabWidget.cpp:407
QColor tabTitleText
Definition TabWidget.h:67
void setTabBackground(const QColor &c)
Definition TabWidget.cpp:419
QString m_caption
Definition TabWidget.h:109
bool m_resizable
Definition TabWidget.h:107
QColor tabSelected
Definition TabWidget.h:68
void addTab(QWidget *w, const QString &name, const char *pixmap=nullptr, int idx=-1)
Definition TabWidget.cpp:71
void wheelEvent(QWheelEvent *we) override
Definition TabWidget.cpp:297
QColor m_tabTextSelected
Definition TabWidget.h:117
QColor m_tabText
Definition TabWidget.h:114
Definition AudioPortAudio.cpp:209
const int GRAPHIC_TAB_HEIGHT
Definition TabWidget.h:35
const int TEXT_TAB_HEIGHT
Definition TabWidget.h:34
Definition TabWidget.h:97
QString name
Definition TabWidget.h:100
const char * pixmap
Definition TabWidget.h:99
int nwidth
Definition TabWidget.h:101
QWidget * w
Definition TabWidget.h:98