summaryrefslogtreecommitdiff
authorsandman <sandman>2002-07-06 19:16:43 (UTC)
committer sandman <sandman>2002-07-06 19:16:43 (UTC)
commit2fa52f80f59249c3f838fa6fdbc2a890e4d96334 (patch) (side-by-side diff)
tree676cd870c02fad226755f0d6ddb95ed6147bfa4a
parent3a422983abc7342c9229dccac825d0608fca10f3 (diff)
downloadopie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.zip
opie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.tar.gz
opie-2fa52f80f59249c3f838fa6fdbc2a890e4d96334.tar.bz2
Use only two (instead of three) button controls on scrollbars due to space
constraints) -- will be configureable somtime ...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index acf0a42..67e53e9 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1475,265 +1475,265 @@ QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
}
QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h)
{
return(QRect(x+5, y+3, w-(h/3)-13, h-5));
}
void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
int sliderStart, uint controls,
uint activeControl)
{
bool isHover = highlightWidget == p->device();
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax)
sliderStart = sliderMax;
bool horiz = sb->orientation() == QScrollBar::Horizontal;
QColorGroup g = sb->colorGroup();
QRect addB, subHC, subB;
QRect addPageR, subPageR, sliderR;
int addX, addY, subX, subY;
int len = horiz ? sb->width() : sb->height();
int extent = horiz ? sb->height() : sb->width();
// a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
// extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
bool brokenApp;
if(extent == 16)
brokenApp = true;
else
brokenApp = false;
if (horiz) {
subY = addY = ( extent - buttonDim ) / 2;
subX = 0;
addX = len - buttonDim;
if(sbBuffer.size() != sb->size())
sbBuffer.resize(sb->size());
}
else {
subX = addX = ( extent - buttonDim ) / 2;
subY = 0;
addY = len - buttonDim;
if(sbBuffer.size() != sb->size())
sbBuffer.resize(sb->size());
}
- subB.setRect( subX,subY,buttonDim,buttonDim );
+ subB.setRect( subX,subY,0,0); // buttonDim,buttonDim );
addB.setRect( addX,addY,buttonDim,buttonDim );
if(horiz)
subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
else
subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
int sliderEnd = sliderStart + sliderLength;
int sliderW = extent;
if (horiz) {
subPageR.setRect( subB.right() + 1, 0,
sliderStart - subB.right() - 1 , sliderW );
addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
}
else {
subPageR.setRect( 0, subB.bottom() + 1, sliderW,
sliderStart - subB.bottom() - 1 );
addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
}
bool maxed = sb->maxValue() == sb->minValue();
QPainter painter;
if(!horiz){
painter.begin(&sbBuffer);
- QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1);
+ QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1);
if(sliderR.height() >= 8){
painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
13, 8);
painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
bgR.height()-16, *getPixmap(VSBSliderMidBg));
painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
0, 0, 13, 8);
painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
}
else{
painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
*getPixmap(VSBSliderMidBg));
painter.setPen(g.background().dark(210));
painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
painter.setPen(g.mid());
painter.drawPoint(bgR.x()+1, bgR.y());
painter.drawPoint(bgR.x()+13, bgR.y());
painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
}
if(controls & Slider){
if(sliderR.height() >= 16){
painter.drawPixmap(sliderR.x()+1, sliderR.y(),
isHover ? *getPixmap(VSBSliderTopHover):
*getPixmap(VSBSliderTop));
painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
sliderR.height()-16, isHover ?
*getPixmap(VSBSliderMidHover) :
*getPixmap(VSBSliderMid));
painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8,
isHover ? *getPixmap(VSBSliderBtmHover) :
*getPixmap(VSBSliderBtm));
}
else if(sliderR.height() >= 8){
int m = sliderR.height()/2;
painter.drawPixmap(sliderR.x()+1, sliderR.y(),
isHover ? *getPixmap(VSBSliderTopHover):
*getPixmap(VSBSliderTop), 0, 0, 13, m);
painter.drawPixmap(sliderR.x()+1, sliderR.y()+m,
isHover ? *getPixmap(VSBSliderBtmHover):
*getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
}
else{
painter.setPen(g.button().dark(210));
drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
13, sliderR.height());
painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
11, sliderR.height()-2,
isHover ? *getPixmap(VSBSliderMidHover) :
*getPixmap(VSBSliderMid), 1, 0);
}
}
painter.setPen(g.mid());
painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
if(brokenApp && (controls & Slider)){
painter.setPen(g.background());
painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
bgR.bottom());
}
painter.end();
}
else{
painter.begin(&sbBuffer);
- QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height());
+ QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height());
if(sliderR.width() >= 8){
painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
8, 13);
painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
13, *getPixmap(HSBSliderMidBg));
painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
0, 0, 8, 13);
painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
}
else{
painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
*getPixmap(HSBSliderMidBg));
painter.setPen(g.background().dark(210));
painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
painter.setPen(g.mid());
painter.drawPoint(bgR.x(), bgR.y()+1);
painter.drawPoint(bgR.x(), bgR.bottom()-1);
painter.drawPoint(bgR.right()-1, bgR.y()+1);
painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
}
if(controls & Slider){
if(sliderR.width() >= 16){
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
isHover ? *getPixmap(HSBSliderTopHover) :
*getPixmap(HSBSliderTop));
painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
13, isHover ? *getPixmap(HSBSliderMidHover) :
*getPixmap(HSBSliderMid));
painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
*getPixmap(HSBSliderBtmHover) :
*getPixmap(HSBSliderBtm));
}
else if(sliderR.width() >= 8){
int m = sliderR.width()/2;
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
isHover ? *getPixmap(HSBSliderTopHover) :
*getPixmap(HSBSliderTop), 0, 0, m, 13);
painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ?
*getPixmap(HSBSliderBtmHover) :
*getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
}
else{
painter.setPen(g.button().dark(210));
drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
sliderR.width(), 13);
painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
sliderR.width()-2, 11, isHover ?
*getPixmap(HSBSliderMidHover) :
*getPixmap(HSBSliderMid), 0, 1);
}
}
painter.setPen(g.mid());
painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
if(brokenApp && (controls & Slider)){
painter.setPen(g.background());
painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
bgR.bottom()-1);
}
painter.end();
}
if ( controls & AddLine ) {
drawSBButton(p, addB, g, activeControl == AddLine);
drawArrow( p, horiz ? RightArrow : DownArrow,
false, addB.x()+4, addB.y()+4,
addB.width()-8, addB.height()-8, g, !maxed);
}
if ( controls & SubLine ) {
- drawSBButton(p, subB, g, activeControl == SubLine);
- drawArrow( p, horiz ? LeftArrow : UpArrow,
- false, subB.x()+4, subB.y()+4,
- subB.width()-8, subB.height()-8, g, !maxed);
+ // drawSBButton(p, subB, g, activeControl == SubLine);
+ // drawArrow( p, horiz ? LeftArrow : UpArrow,
+ // false, subB.x()+4, subB.y()+4,
+ // subB.width()-8, subB.height()-8, g, !maxed);
drawSBButton(p, subHC, g, activeControl == SubLine);
drawArrow( p, horiz ? LeftArrow : UpArrow,
false, subHC.x()+4, subHC.y()+4,
subHC.width()-8, subHC.height()-8, g, !maxed);
}
if(controls & AddPage){
if(addPageR.width()){
p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
addPageR.x(), addPageR.y(), addPageR.width(),
addPageR.height());
}
}
if(controls & SubPage){
if(subPageR.height()){
p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
subPageR.x(), subPageR.y(), subPageR.width(),
subPageR.height());
}
}
if ( controls & Slider ) {
p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
sliderR.x(), sliderR.y(), sliderR.width(),
sliderR.height());
}
}
void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
bool down, bool /*fast*/)
{
p->setPen(g.mid());
p->drawRect(r);
QColor c(down ? g.button() : g.background());
QPixmap *pix = bevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(c.rgb(), pix);
}
p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
}
void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
bool horiz)
{
@@ -1744,98 +1744,98 @@ void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
int y2 = r.bottom()-3;
p->setPen(g.light());
p->drawLine(x, y, x, y2);
p->drawLine(x+3, y, x+3, y2);
p->drawLine(x+6, y, x+6, y2);
p->setPen(g.mid());
p->drawLine(x+1, y, x+1, y2);
p->drawLine(x+4, y, x+4, y2);
p->drawLine(x+7, y, x+7, y2);
}
}
else{
if(r.height() >= 15){
int x = r.x()+3;
int y = r.y() + (r.height()-7)/2;
int x2 = r.right()-3;
p->setPen(g.light());
p->drawLine(x, y, x2, y);
p->drawLine(x, y+3, x2, y+3);
p->drawLine(x, y+6, x2, y+6);
p->setPen(g.mid());
p->drawLine(x, y+1, x2, y+1);
p->drawLine(x, y+4, x2, y+4);
p->drawLine(x, y+7, x2, y+7);
}
}
}
void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
int &sliderMax, int &sliderLength,
int &buttonDim)
{
int maxLength;
int b = 0;
bool horiz = sb->orientation() == QScrollBar::Horizontal;
int length = horiz ? sb->width() : sb->height();
int extent = horiz ? sb->height() : sb->width();
if ( length > ( extent - b*2 - 1 )*2 + b*2 )
buttonDim = extent - b*2;
else
buttonDim = ( length - b*2 )/2 - 1;
- sliderMin = b + buttonDim;
- maxLength = length - b*2 - buttonDim*3;
+ sliderMin = b + 0; // buttonDim;
+ maxLength = length - b*2 - buttonDim*2; // 3;
if ( sb->maxValue() == sb->minValue() ) {
sliderLength = maxLength;
} else {
sliderLength = (sb->pageStep()*maxLength)/
(sb->maxValue()-sb->minValue()+sb->pageStep());
uint range = sb->maxValue()-sb->minValue();
if ( sliderLength < 9 || range > INT_MAX/2 )
sliderLength = 9;
if ( sliderLength > maxLength )
sliderLength = maxLength;
}
sliderMax = sliderMin + maxLength - sliderLength;
}
QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
int sliderStart,
const QPoint &p)
{
if ( !sb->rect().contains( p ) )
return NoScroll;
int sliderMin, sliderMax, sliderLength, buttonDim, pos;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y();
if ( pos < sliderMin )
return SubLine;
if ( pos < sliderStart )
return SubPage;
if ( pos < sliderStart + sliderLength )
return Slider;
if ( pos < sliderMax + sliderLength)
return AddPage;
if(pos > sliderMax + sliderLength + 16)
return AddLine;
return SubLine;
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
QSize LiquidStyle::exclusiveIndicatorSize() const
{
return(QSize(16, 16));
}
void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,