1
/* Mpcgui for SMPlayer.
2
Copyright (C) 2008 matt_ <matt@endboss.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include "mpcstyles.h"
21
#include <QWindowsStyle>
22
#include <QStyleOptionToolBar>
28
MpcToolbarStyle::drawControl(ControlElement control, const QStyleOption *option,
29
QPainter *painter, const QWidget *widget) const
31
if(control == CE_ToolBar)
33
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
34
QRect rect = option->rect;
36
if( toolbar->toolBarArea == Qt::BottomToolBarArea &&
37
toolbar->positionOfLine == QStyleOptionToolBar::End )
39
painter->setPen(QPen(option->palette.light().color()));
40
painter->drawLine(rect.topLeft().x(),
45
painter->setPen(QPen(option->palette.light().color()));
46
painter->drawLine(rect.topLeft().x(),
48
rect.bottomLeft().x(),
49
rect.bottomLeft().y());
51
painter->setPen(QPen(option->palette.dark().color()));
52
painter->drawLine(rect.topRight().x(),
54
rect.bottomRight().x(),
55
rect.bottomRight().y());
58
else if( toolbar->toolBarArea == Qt::BottomToolBarArea &&
59
toolbar->positionOfLine == QStyleOptionToolBar::Beginning )
61
painter->setPen(QPen(option->palette.light().color()));
62
painter->drawLine(rect.topLeft().x(),
64
rect.bottomLeft().x(),
65
rect.bottomLeft().y());
67
painter->setPen(QPen(option->palette.dark().color()));
68
painter->drawLine(rect.topRight().x(),
70
rect.bottomRight().x(),
71
rect.bottomRight().y());
73
painter->setPen(QPen(option->palette.dark().color()));
74
painter->drawLine(rect.bottomLeft().x(),
75
rect.bottomLeft().y(),
76
rect.bottomRight().x(),
77
rect.bottomRight().y());
81
QWindowsStyle::drawControl(control,toolbar, painter, widget);
87
QWindowsStyle::drawControl(control,option, painter, widget);
91
// draw custom slider + handle for volume widget
92
void MpcVolumeSlideStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
93
QPainter *p, const QWidget *widget) const
97
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
98
QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
99
QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
101
if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
103
p->setPen(slider->palette.shadow().color());
104
if (slider->orientation == Qt::Horizontal) {
105
static QPoint points[3] = {
106
QPoint(groove.x() , groove.y() + slider->rect.height() ),
107
QPoint(groove.x() + groove.width() -2 , groove.y() + slider->rect.height() ),
108
QPoint(groove.x() + groove.width() -2 , groove.y() ),
110
QPen oldPen = p->pen();
112
p->setPen(slider->palette.dark().color());
113
p->drawLine(QPoint(points[0].x(), points[0].y() -2 ),QPoint(points[2].x(), points[2].y()));
115
QPoint b[3] = { QPoint(points[0].x(),points[0].y()-1), QPoint(points[1].x()-1, points[1].y()-1), QPoint(points[2].x()-1,points[2].y()) };
116
p->setPen(slider->palette.light().color());
117
p->drawPolyline(b, 3);
123
if (slider->subControls & SC_SliderTickmarks) {
124
QStyleOptionSlider tmpSlider = *slider;
125
tmpSlider.subControls = SC_SliderTickmarks;
126
QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
129
if (slider->subControls & SC_SliderHandle) {
130
const QColor c0 = slider->palette.shadow().color();
131
const QColor c1 = slider->palette.dark().color();
132
// const QColor c2 = g.button();
133
const QColor c3 = slider->palette.midlight().color();
134
const QColor c4 = slider->palette.light().color();
137
if (slider->state & State_Enabled) {
138
handleBrush = slider->palette.color(QPalette::Button);
140
handleBrush = QBrush(slider->palette.color(QPalette::Button),
145
int x = handle.x() , y = handle.y(),
146
wi = handle.width() - 2, he = slider->rect.height();
148
if (slider->state & State_HasFocus) {
149
QStyleOptionFocusRect fropt;
150
fropt.QStyleOption::operator=(*slider);
151
fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
152
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
155
Qt::BGMode oldMode = p->backgroundMode();
156
p->setBackgroundMode(Qt::OpaqueMode);
157
qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
159
p->setBackgroundMode(oldMode);
166
QWindowsStyle::drawComplexControl(cc,opt,p,widget);
170
// draw custom slider + handle for timeslide widget
171
void MpcTimeSlideStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
172
QPainter *p, const QWidget *widget) const
174
if( cc == CC_Slider )
176
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
177
QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
178
QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
180
if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
181
if (slider->orientation == Qt::Horizontal) {
182
int x = groove.x() + 2;
183
int y = slider->rect.height() / 2 - 4;
184
int w = groove.width() - 4;
186
qDrawShadeRect (p,x,y,w,h, slider->palette, true,1,0,
187
&slider->palette.brush(QPalette::Light));
192
if (slider->subControls & SC_SliderTickmarks) {
193
QStyleOptionSlider tmpSlider = *slider;
194
tmpSlider.subControls = SC_SliderTickmarks;
195
QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
198
if (slider->subControls & SC_SliderHandle) {
199
const QColor c0 = slider->palette.shadow().color();
200
const QColor c1 = slider->palette.dark().color();
201
// const QColor c2 = g.button();
202
const QColor c3 = slider->palette.midlight().color();
203
const QColor c4 = slider->palette.light().color();
206
if (slider->state & State_Enabled) {
207
handleBrush = slider->palette.color(QPalette::Button);
209
handleBrush = QBrush(slider->palette.color(QPalette::Button),
214
int x = handle.x() , y = handle.y() + 1,
217
if (slider->state & State_HasFocus) {
218
QStyleOptionFocusRect fropt;
219
fropt.QStyleOption::operator=(*slider);
220
fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
221
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
224
Qt::BGMode oldMode = p->backgroundMode();
225
p->setBackgroundMode(Qt::OpaqueMode);
226
qDrawWinPanel(p, QRect(x, y, wi, he), slider->palette, false,
228
qDrawShadeRect (p, QRect(x+2,y+3, wi-4, he-6), slider->palette, true,1,0,
229
&slider->palette.brush(QPalette::Light));
230
p->setBackgroundMode(oldMode);
236
QWindowsStyle::drawComplexControl(cc,opt,p,widget);