summaryrefslogtreecommitdiff
path: root/library/lightstyle.cpp
authorerik <erik>2007-01-10 17:24:23 (UTC)
committer erik <erik>2007-01-10 17:24:23 (UTC)
commite7d3e1d0f3c75979c01ea6373ed3c80d0c986000 (patch) (side-by-side diff)
tree34a6e8aa3de82f07c0531e59f375da216fbfb97a /library/lightstyle.cpp
parent51bd5e8d542372ad54898ce642fe9b82b8ba83f3 (diff)
downloadopie-e7d3e1d0f3c75979c01ea6373ed3c80d0c986000.zip
opie-e7d3e1d0f3c75979c01ea6373ed3c80d0c986000.tar.gz
opie-e7d3e1d0f3c75979c01ea6373ed3c80d0c986000.tar.bz2
All of the files in this commit have an inheritance member function
mismatch correction. None are serious, but all would have been improperly mislinked in the inheritance hierarchy if attempted to be used.
Diffstat (limited to 'library/lightstyle.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/lightstyle.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/library/lightstyle.cpp b/library/lightstyle.cpp
index c5073ca..3d5adfb 100644
--- a/library/lightstyle.cpp
+++ b/library/lightstyle.cpp
@@ -297,243 +297,243 @@ void LightStyle::drawPushButton(QPushButton *button, QPainter *p)
{
int x1, y1, x2, y2;
button->rect().coords(&x1, &y1, &x2, &y2);
if (button->isDefault()) {
p->save();
p->setPen(button->palette().active().color(QColorGroup::Highlight));
p->setBrush(button->palette().active().brush(QColorGroup::Highlight));
p->drawRoundRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 15, 15);
p->restore();
}
if (button->isDefault() || button->autoDefault()) {
x1 += buttonDefaultIndicatorWidth();
y1 += buttonDefaultIndicatorWidth();
x2 -= buttonDefaultIndicatorWidth();
y2 -= buttonDefaultIndicatorWidth();
if (button->isDefault()) {
QPointArray pa(8);
pa.setPoint(0, x1 + 2, y1 );
pa.setPoint(1, x2 - 1, y1 );
pa.setPoint(2, x2 + 1, y1 + 2);
pa.setPoint(3, x2 + 1, y2 - 2);
pa.setPoint(4, x2 - 2, y2 + 1);
pa.setPoint(5, x1 + 2, y2 + 1);
pa.setPoint(6, x1, y2 - 1);
pa.setPoint(7, x1, y1 + 2);
QRegion r(pa);
p->setClipRegion(r);
}
}
QBrush fill;
if (button->isDown() || button->isOn())
fill = button->colorGroup().brush(QColorGroup::Mid);
else
fill = button->colorGroup().brush(QColorGroup::Button);
if ( !button->isFlat() || button->isOn() || button->isDown() )
drawButton(p, x1, y1, x2 - x1 + 1, y2 - y1 + 1,
button->colorGroup(), button->isOn() || button->isDown(), &fill);
}
void LightStyle::drawButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g,
bool sunken, const QBrush *fill)
{
p->save();
if ( fill )
p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
else
p->fillRect(x + 2, y + 2, w - 4, h - 4,
QBrush(sunken ? g.mid() : g.button()));
// frame
p->setPen(g.dark());
p->drawLine(x, y + 2, x, y + h - 3); // left
p->drawLine(x + 2, y, x + w - 3, y); // top
p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right
p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom
p->drawPoint(x + 1, y + 1);
p->drawPoint(x + 1, y + h - 2);
p->drawPoint(x + w - 2, y + 1);
p->drawPoint(x + w - 2, y + h - 2);
// bevel
if (sunken)
p->setPen(g.mid());
else
p->setPen(g.light());
p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
if (sunken)
p->setPen(g.light());
else
p->setPen(g.mid());
p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1
p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1
p->restore();
}
void LightStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g,
bool sunken, const QBrush *fill)
{
drawButton(p, x, y, w, h, g, sunken, fill);
}
-void LightStyle::getButtonShift(int &x, int &y) const
+void LightStyle::getButtonShift(int &x, int &y)
{
x = y = 0;
}
void LightStyle::drawComboButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool,
bool editable, bool,
const QBrush *fill)
{
drawButton(p, x, y, w, h, g, FALSE, fill);
if (editable) {
QRect r = comboButtonRect(x, y, w, h);
qDrawShadePanel(p, r.x() - 1, r.y() - 1,
r.width() + defaultFrameWidth(),
r.height() + defaultFrameWidth(),
g, TRUE);
}
int indent = ((y + h) / 2) - 3;
int xpos = x;
#if QT_VERSION >= 0x030000
if( QApplication::reverseLayout() )
xpos += indent;
else
#endif
xpos += w - indent - 5;
drawArrow(p, Qt::DownArrow, TRUE, xpos, indent, 5, 5, g, TRUE, fill);
}
-QRect LightStyle::comboButtonRect( int x, int y, int w, int h ) const
+QRect LightStyle::comboButtonRect( int x, int y, int w, int h )
{
QRect r(x + 3, y + 3, w - 6, h - 6);
int indent = ((y + h) / 2) - 3;
r.setRight(r.right() - indent - 10);
#if QT_VERSION >= 0x030000
if( QApplication::reverseLayout() )
r.moveBy( indent + 10, 0 );
#endif
return r;
}
-QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h ) const
+QRect LightStyle::comboButtonFocusRect(int x, int y, int w, int h )
{
return comboButtonRect(x, y, w, h);
}
void LightStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
int lw, const QBrush *fill)
{
if (lw >= 2) {
if ( fill )
p->fillRect(x + 2, y + 2, w - 4, h - 4, *fill);
QPen oldpen = p->pen();
// frame
p->setPen(g.dark());
p->drawLine(x, y + 2, x, y + h - 3); // left
p->drawLine(x + 2, y, x + w - 3, y); // top
p->drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); // right
p->drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); // bottom
p->drawPoint(x + 1, y + 1);
p->drawPoint(x + 1, y + h - 2);
p->drawPoint(x + w - 2, y + 1);
p->drawPoint(x + w - 2, y + h - 2);
// bevel
if (sunken)
p->setPen(g.mid());
else
p->setPen(g.light());
p->drawLine(x + 1, y + 2, x + 1, y + h - 3); // left
p->drawLine(x + 2, y + 1, x + w - 3, y + 1); // top
if (sunken)
p->setPen(g.light());
else
p->setPen(g.mid());
p->drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); // right + 1
p->drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); // bottom + 1
// corners
p->setPen(g.background());
p->drawLine(x, y, x + 1, y);
p->drawLine(x, y + h - 1, x + 1, y + h - 1);
p->drawLine(x + w - 2, y, x + w - 1, y);
p->drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 1);
p->drawPoint(x, y + 1);
p->drawPoint(x, y + h - 2);
p->drawPoint(x + w - 1, y + 1);
p->drawPoint(x + w - 1, y + h - 2);
p->setPen(oldpen);
} else
qDrawShadePanel(p, x, y, w, h, g, sunken, lw, fill);
}
void LightStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h,
const QColorGroup &g, int state,
bool down, bool)
{
drawButton(p, x, y, w, h, g, TRUE,
&g.brush(down ? QColorGroup::Mid : QColorGroup::Base));
p->save();
p->setPen(g.foreground());
if (state == QButton::NoChange) {
p->drawLine(x + 3, y + h / 2, x + w - 4, y + h / 2);
p->drawLine(x + 3, y + 1 + h / 2, x + w - 4, y + 1 + h / 2);
p->drawLine(x + 3, y - 1 + h / 2, x + w - 4, y - 1 + h / 2);
} else if (state == QButton::On) {
p->drawLine(x + 4, y + 3, x + w - 4, y + h - 5);
p->drawLine(x + 3, y + 3, x + w - 4, y + h - 4);
p->drawLine(x + 3, y + 4, x + w - 5, y + h - 4);
p->drawLine(x + 3, y + h - 5, x + w - 5, y + 3);
p->drawLine(x + 3, y + h - 4, x + w - 4, y + 3);
p->drawLine(x + 4, y + h - 4, x + w - 4, y + 4);
}
p->restore();
}
void LightStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool on,
bool down, bool)
{
p->save();
p->fillRect(x, y, w, h, g.brush(QColorGroup::Background));
p->setPen(g.dark());
@@ -708,193 +708,193 @@ void LightStyle::drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab,
} else
p->drawLine(fr.left(), fr.bottom(), fr.right() + 2, fr.bottom());
if (fr.left() == 2) {
p->drawPoint(fr.left() - 1, fr.bottom() + 1);
p->drawPoint(fr.left() - 2, fr.bottom() + 2);
}
if (selected) {
p->setPen(g.mid());
p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 2);
}
p->setPen(g.light()); p->setPen(red);
p->drawLine(fr.left() + 1, fr.top() + 6, fr.left() + 1,
fr.bottom() - (selected ? 0 : 1));
p->drawLine(fr.left() + 1, fr.top() + 5, fr.left() + 5, fr.top() + 1);
p->drawLine(fr.left() + 6, fr.top() + 1, fr.right() - 3, fr.top() + 1);
if (selected) {
p->drawLine(fr.right() + 1, fr.bottom() + 1,
fr.right() + 2, fr.bottom() + 1);
p->drawLine(fr.left(), fr.bottom() + 1, fr.left() + 1, fr.bottom() + 1);
} else
p->drawLine(fr.left(), fr.bottom() + 1,
fr.right() + 2, fr.bottom() + 1);
} else if (tabbar->shape() == QTabBar::RoundedBelow) {
// "rounded" tabs on bottom
fr.setTop(fr.top() + 1);
p->setPen(g.dark());
p->drawLine(fr.left(), fr.top(), fr.left(), fr.bottom() - 1);
p->drawLine(fr.left() + 1, fr.bottom(), fr.right() - 1, fr.bottom());
p->drawLine(fr.right(), fr.top(), fr.right(), fr.bottom() - 1);
if (! selected)
p->drawLine(fr.left(), fr.top(), fr.right() + 3, fr.top());
else
p->drawLine(fr.right(), fr.top(), fr.right() + 3, fr.top());
p->setPen(g.mid());
if (selected)
p->drawLine(fr.right() - 1, fr.top() + 1, fr.right() - 1, fr.bottom() - 1);
else
p->drawLine(fr.left(), fr.top() - 1, fr.right() + 3, fr.top() - 1);
p->setPen(g.light());
p->drawLine(fr.left() + 1, fr.top() + (selected ? -1 : 2),
fr.left() + 1, fr.bottom() - 1);
} else {
// triangular drawing code
QCommonStyle::drawTab(p, tabbar, tab, selected);
}
p->restore();
}
#endif
void LightStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Qt::Orientation orientation,
bool above, bool below)
{
drawButton(p, x, y, w, h, g, FALSE, &g.brush(QColorGroup::Button));
if (orientation == Horizontal) {
if (above && below) {
drawArrow(p, Qt::UpArrow, FALSE, x + 1, y + 1, w, h / 2, g, TRUE);
drawArrow(p, Qt::DownArrow, FALSE, x + 1, y + (h / 2) - 1,
w, h / 2, g, TRUE);
} else
drawArrow(p, (above) ? Qt::UpArrow : Qt::DownArrow,
FALSE, x + 1, y, w, h, g, TRUE);
} else {
if (above && below) {
drawArrow(p, Qt::LeftArrow, FALSE, x + 1, y, w / 2, h, g, TRUE);
drawArrow(p, Qt::RightArrow, FALSE, x + (w / 2) - 2, y, w / 2, h, g, TRUE);
} else
drawArrow(p, (above) ? Qt::LeftArrow : Qt::RightArrow,
FALSE, x, y, w, h, g, TRUE);
}
}
void LightStyle::drawSliderGroove(QPainter *p, int x, int y, int w, int h,
const QColorGroup& g, QCOORD c,
Qt::Orientation orientation)
{
if (orientation == Horizontal)
drawButton(p, x, y+c - 3, w, 6, g, TRUE, &g.brush(QColorGroup::Mid));
else
drawButton(p, x+c - 3, y, 6, h, g, TRUE, &g.brush(QColorGroup::Mid));
}
void LightStyle::scrollBarMetrics(const QScrollBar *scrollbar,
int &sliderMin, int &sliderMax,
- int &sliderLength, int &buttonDim) const
+ int &sliderLength, int &buttonDim)
{
int maxLength;
int length = ((scrollbar->orientation() == Horizontal) ?
scrollbar->width() : scrollbar->height());
int extent = ((scrollbar->orientation() == Horizontal) ?
scrollbar->height() : scrollbar->width());
extent--;
if (length > (extent + defaultFrameWidth() - 1) * 2 + defaultFrameWidth())
buttonDim = extent - defaultFrameWidth();
else
buttonDim = (length - defaultFrameWidth()) / 2 - 1;
sliderMin = buttonDim;
maxLength = length - buttonDim * 3;
if (scrollbar->maxValue() != scrollbar->minValue()) {
uint range = scrollbar->maxValue() - scrollbar->minValue();
sliderLength = (scrollbar->pageStep() * maxLength) /
(range + scrollbar->pageStep());
if (sliderLength < buttonDim || range > INT_MAX / 2)
sliderLength = buttonDim;
if (sliderLength > maxLength)
sliderLength = maxLength;
} else
sliderLength = maxLength;
sliderMax = sliderMin + maxLength - sliderLength;
}
QStyle::ScrollControl LightStyle::scrollBarPointOver(const QScrollBar *scrollbar,
int sliderStart, const QPoint &p)
{
if (! scrollbar->rect().contains(p))
return NoScroll;
int sliderMin, sliderMax, sliderLength, buttonDim, pos;
scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim );
if (scrollbar->orientation() == Horizontal)
pos = p.x();
else
pos = p.y();
if (pos < buttonDim)
return SubLine;
if (pos < sliderStart)
return SubPage;
if (pos < sliderStart + sliderLength)
return Slider;
if (pos < sliderMax + sliderLength)
return AddPage;
if (pos < sliderMax + sliderLength + buttonDim)
return SubLine;
return AddLine;
}
void LightStyle::drawScrollBarControls( QPainter* p, const QScrollBar* scrollbar,
int sliderStart, uint controls,
uint activeControl )
{
QColorGroup g = scrollbar->colorGroup();
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( scrollbar, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax) { // sanity check
sliderStart = sliderMax;
}
QRect addR, subR, subR2, addPageR, subPageR, sliderR;
int length = ((scrollbar->orientation() == Horizontal) ?
scrollbar->width() : scrollbar->height());
int extent = ((scrollbar->orientation() == Horizontal) ?
scrollbar->height() : scrollbar->width());
int fudge = 3; //####disgusting hack
if (scrollbar->orientation() == Horizontal) {
subR.setRect(0, defaultFrameWidth(),
buttonDim + fudge, buttonDim);
subR2.setRect(length - (buttonDim * 2), defaultFrameWidth() ,
buttonDim, buttonDim);
addR.setRect(length - buttonDim, defaultFrameWidth(),
buttonDim, buttonDim);
} else {
subR.setRect(defaultFrameWidth() + 1, 0,
buttonDim, buttonDim + fudge);
subR2.setRect(defaultFrameWidth() + 1, length - (buttonDim * 2),
buttonDim, buttonDim);
addR.setRect(defaultFrameWidth() + 1, length - buttonDim,