LMMS
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:
43 TabWidget(const QString& caption, QWidget* parent,
44 bool usePixmap = false, bool resizable = false);
45 ~TabWidget() override = default;
46
47 void addTab(QWidget* w, const QString& name, const char* pixmap = nullptr, int idx = -1);
48
49 void setActiveTab(int idx);
50
51 int findTabAtPos(const QPoint& pos);
52
53 inline int activeTab() const
54 {
55 return(m_activeTab);
56 }
57
58 // Themeability
59 Q_PROPERTY(QColor tabText READ tabText WRITE setTabText)
65
66 QColor tabText() const;
67 void setTabText(const QColor & c);
68 QColor tabTitleText() const;
69 void setTabTitleText(const QColor & c);
70 QColor tabSelected() const;
71 void setTabSelected(const QColor & c);
72 QColor tabTextSelected() const;
73 void setTabTextSelected(const QColor & c);
74 QColor tabBackground() const;
75 void setTabBackground(const QColor & c);
76 QColor tabBorder() const;
77 void setTabBorder(const QColor & c);
78
79protected:
80 bool event(QEvent* event) override;
81 void mousePressEvent(QMouseEvent* me) override;
82 void paintEvent(QPaintEvent* pe) override;
83 void resizeEvent(QResizeEvent* re) override;
84 void wheelEvent(QWheelEvent* we) override;
86 QSize sizeHint() const override;
87
88private:
90 {
91 QWidget* w; // ptr to widget
92 const char* pixmap; // artwork for the widget
93 QString name; // name for widget
94 int nwidth; // width of name when painting (only valid for text tab)
95 } ;
96 using widgetStack = QMap<int, widgetDesc>;
97
99
102 QString m_caption; // Tab caption, used as the tooltip text on icon tabs
103 quint8 m_tabbarHeight; // The height of the tab bar
104 quint8 m_tabheight; // The height of the tabs
105 bool m_usePixmap; // true if the tabs are to be displayed with icons. False for text tabs.
106
107 QColor m_tabText; // The color of the tabs' text.
108 QColor m_tabTitleText; // The color of the TabWidget's title text.
109 QColor m_tabSelected; // The highlighting color for the selected tab.
110 QColor m_tabTextSelected;// The text color for the selected tab.
111 QColor m_tabBackground; // The TabWidget's background color.
112 QColor m_tabBorder; // The TabWidget's borders color.
113} ;
114
115
116} // namespace lmms::gui
117
118#endif // LMMS_GUI_TAB_WIDGET_H
#define READ(addr)
Definition Ay_Cpu.cpp:92
#define WRITE(addr, data)
Definition Ay_Cpu.cpp:93
#define override
Definition DistrhoDefines.h:73
void setTabText(const QColor &c)
Definition TabWidget.cpp:383
bool m_usePixmap
Definition TabWidget.h:105
QSize minimumSizeHint() const override
Definition TabWidget.cpp:322
QColor m_tabSelected
Definition TabWidget.h:109
widgetStack m_widgets
Definition TabWidget.h:98
QColor tabText
Definition TabWidget.h:59
void paintEvent(QPaintEvent *pe) override
Definition TabWidget.cpp:212
QColor tabTextSelected
Definition TabWidget.h:62
QColor m_tabBorder
Definition TabWidget.h:112
QColor tabBorder
Definition TabWidget.h:64
~TabWidget() override=default
void setTabBorder(const QColor &c)
Definition TabWidget.cpp:431
quint8 m_tabheight
Definition TabWidget.h:104
int findTabAtPos(const QPoint &pos)
Definition TabWidget.cpp:126
QMap< int, widgetDesc > widgetStack
Definition TabWidget.h:96
void setTabTitleText(const QColor &c)
Definition TabWidget.cpp:371
quint8 m_tabbarHeight
Definition TabWidget.h:103
void setActiveTab(int idx)
Definition TabWidget.cpp:108
int m_activeTab
Definition TabWidget.h:101
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:111
QColor tabBackground
Definition TabWidget.h:63
void resizeEvent(QResizeEvent *re) override
Definition TabWidget.cpp:198
int activeTab() const
Definition TabWidget.h:53
QColor m_tabTitleText
Definition TabWidget.h:108
QSize sizeHint() const override
Definition TabWidget.cpp:343
void setTabTextSelected(const QColor &c)
Definition TabWidget.cpp:407
QColor tabTitleText
Definition TabWidget.h:60
void setTabBackground(const QColor &c)
Definition TabWidget.cpp:419
QString m_caption
Definition TabWidget.h:102
bool m_resizable
Definition TabWidget.h:100
QColor tabSelected
Definition TabWidget.h:61
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:110
QColor m_tabText
Definition TabWidget.h:107
UINT_D64 w
Definition inflate.c:942
static const char * name
Definition pugl.h:1582
static uintptr_t parent
Definition pugl.h:1644
static bool resizable
Definition pugl.h:1668
Definition AudioPortAudio.cpp:223
const int GRAPHIC_TAB_HEIGHT
Definition TabWidget.h:35
const int TEXT_TAB_HEIGHT
Definition TabWidget.h:34
Definition TabWidget.h:90
QString name
Definition TabWidget.h:93
const char * pixmap
Definition TabWidget.h:92
int nwidth
Definition TabWidget.h:94
QWidget * w
Definition TabWidget.h:91
return c
Definition crypt.c:175
#define const
Definition zconf.h:137