-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index fc925b8..87b5488 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -459,2262 +459,2262 @@ void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, | |||
459 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr | 459 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr |
460 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl | 460 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl |
461 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br | 461 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br |
462 | // fills | 462 | // fills |
463 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 463 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
464 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 464 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
465 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 465 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
466 | p.end(); | 466 | p.end(); |
467 | tmpPix.setMask(btnMask); | 467 | tmpPix.setMask(btnMask); |
468 | /*if(autoDefault){ | 468 | /*if(autoDefault){ |
469 | if(supportPushDown && pushedDown){ | 469 | if(supportPushDown && pushedDown){ |
470 | painter->drawPixmap(x+3, y+3, tmpPix); | 470 | painter->drawPixmap(x+3, y+3, tmpPix); |
471 | } | 471 | } |
472 | else{ | 472 | else{ |
473 | painter->drawPixmap(x+2, y+2, tmpPix); | 473 | painter->drawPixmap(x+2, y+2, tmpPix); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | else */if(supportPushDown && pushedDown) | 476 | else */if(supportPushDown && pushedDown) |
477 | painter->drawPixmap(x+1, y+1, tmpPix); | 477 | painter->drawPixmap(x+1, y+1, tmpPix); |
478 | else | 478 | else |
479 | painter->drawPixmap(x, y, tmpPix); | 479 | painter->drawPixmap(x, y, tmpPix); |
480 | 480 | ||
481 | 481 | ||
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, | 486 | QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, |
487 | bool blend) | 487 | bool blend) |
488 | { | 488 | { |
489 | QImage img(qembed_findImage(label)); | 489 | QImage img(qembed_findImage(label)); |
490 | img.detach(); | 490 | img.detach(); |
491 | if(img.isNull()){ // shouldn't happen, been tested | 491 | if(img.isNull()){ // shouldn't happen, been tested |
492 | qWarning("Invalid embedded label %s", label); | 492 | qWarning("Invalid embedded label %s", label); |
493 | return(NULL); | 493 | return(NULL); |
494 | } | 494 | } |
495 | if(img.depth() != 32) | 495 | if(img.depth() != 32) |
496 | img = img.convertDepth(32); | 496 | img = img.convertDepth(32); |
497 | unsigned int *data = (unsigned int *)img.bits(); | 497 | unsigned int *data = (unsigned int *)img.bits(); |
498 | int total = img.width()*img.height(); | 498 | int total = img.width()*img.height(); |
499 | int current; | 499 | int current; |
500 | QColor c; | 500 | QColor c; |
501 | int oldH, oldS, oldV; | 501 | int oldH, oldS, oldV; |
502 | int alpha; | 502 | int alpha; |
503 | if(v < 235) | 503 | if(v < 235) |
504 | v += 20; | 504 | v += 20; |
505 | else | 505 | else |
506 | v = 255; | 506 | v = 255; |
507 | float intensity = v/255.0; | 507 | float intensity = v/255.0; |
508 | 508 | ||
509 | for(current=0; current<total; ++current){ | 509 | for(current=0; current<total; ++current){ |
510 | alpha = qAlpha(data[current]); | 510 | alpha = qAlpha(data[current]); |
511 | c.setRgb(data[current]); | 511 | c.setRgb(data[current]); |
512 | c.hsv(&oldH, &oldS, &oldV); | 512 | c.hsv(&oldH, &oldS, &oldV); |
513 | oldV = (int)(oldV*intensity); | 513 | oldV = (int)(oldV*intensity); |
514 | c.setHsv(h, s, oldV); | 514 | c.setHsv(h, s, oldV); |
515 | if(blend && alpha != 255 && alpha != 0){ | 515 | if(blend && alpha != 255 && alpha != 0){ |
516 | float srcPercent = ((float)alpha)/255.0; | 516 | float srcPercent = ((float)alpha)/255.0; |
517 | float destPercent = 1.0-srcPercent; | 517 | float destPercent = 1.0-srcPercent; |
518 | oldH = (int)((srcPercent*h) + (destPercent*bH)); | 518 | oldH = (int)((srcPercent*h) + (destPercent*bH)); |
519 | oldS = (int)((srcPercent*s) + (destPercent*bS)); | 519 | oldS = (int)((srcPercent*s) + (destPercent*bS)); |
520 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); | 520 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); |
521 | c.setHsv(oldH, oldS, oldV); | 521 | c.setHsv(oldH, oldS, oldV); |
522 | alpha = 255; | 522 | alpha = 255; |
523 | } | 523 | } |
524 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); | 524 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); |
525 | } | 525 | } |
526 | QPixmap *pix = new QPixmap; | 526 | QPixmap *pix = new QPixmap; |
527 | pix->convertFromImage(img); | 527 | pix->convertFromImage(img); |
528 | return(pix); | 528 | return(pix); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | 532 | ||
533 | 533 | ||
534 | QPixmap* LiquidStyle::getPixmap(BitmapData item) | 534 | QPixmap* LiquidStyle::getPixmap(BitmapData item) |
535 | { | 535 | { |
536 | 536 | ||
537 | if(pixmaps[item]) | 537 | if(pixmaps[item]) |
538 | return(pixmaps[item]); | 538 | return(pixmaps[item]); |
539 | 539 | ||
540 | switch(item){ | 540 | switch(item){ |
541 | case HTMLBtnBorder: | 541 | case HTMLBtnBorder: |
542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); | 542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); |
543 | break; | 543 | break; |
544 | case HTMLBtnBorderDown: | 544 | case HTMLBtnBorderDown: |
545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); | 545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); |
546 | break; | 546 | break; |
547 | case HTMLCB: | 547 | case HTMLCB: |
548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); | 548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); |
549 | break; | 549 | break; |
550 | case HTMLCBDown: | 550 | case HTMLCBDown: |
551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); | 551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); |
552 | break; | 552 | break; |
553 | case HTMLCBHover: | 553 | case HTMLCBHover: |
554 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); | 554 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); |
555 | break; | 555 | break; |
556 | case HTMLCBDownHover: | 556 | case HTMLCBDownHover: |
557 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", | 557 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", |
558 | btnHoverH, btnHoverS, | 558 | btnHoverH, btnHoverS, |
559 | btnHoverV); | 559 | btnHoverV); |
560 | break; | 560 | break; |
561 | case HTMLRadio: | 561 | case HTMLRadio: |
562 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); | 562 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); |
563 | case HTMLRadioDown: | 563 | case HTMLRadioDown: |
564 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); | 564 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); |
565 | case HTMLRadioHover: | 565 | case HTMLRadioHover: |
566 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); | 566 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); |
567 | case HTMLRadioDownHover: | 567 | case HTMLRadioDownHover: |
568 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", | 568 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", |
569 | btnHoverH, btnHoverS, | 569 | btnHoverH, btnHoverS, |
570 | btnHoverV); | 570 | btnHoverV); |
571 | case RadioOn: | 571 | case RadioOn: |
572 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); | 572 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); |
573 | break; | 573 | break; |
574 | case RadioOnHover: | 574 | case RadioOnHover: |
575 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, | 575 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, |
576 | btnHoverV, true); | 576 | btnHoverV, true); |
577 | break; | 577 | break; |
578 | case RadioOffHover: | 578 | case RadioOffHover: |
579 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); | 579 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); |
580 | break; | 580 | break; |
581 | case TabDown: | 581 | case TabDown: |
582 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); | 582 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); |
583 | break; | 583 | break; |
584 | case TabFocus: | 584 | case TabFocus: |
585 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, | 585 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, |
586 | btnHoverS, true); | 586 | btnHoverS, true); |
587 | break; | 587 | break; |
588 | case CBDown: | 588 | case CBDown: |
589 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); | 589 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); |
590 | break; | 590 | break; |
591 | case CBDownHover: | 591 | case CBDownHover: |
592 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, | 592 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, |
593 | btnHoverS, btnHoverV, true); | 593 | btnHoverS, btnHoverV, true); |
594 | break; | 594 | break; |
595 | case CBHover: | 595 | case CBHover: |
596 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); | 596 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); |
597 | break; | 597 | break; |
598 | case HSlider: | 598 | case HSlider: |
599 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 599 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
600 | break; | 600 | break; |
601 | case VSlider: | 601 | case VSlider: |
602 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 602 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
603 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); | 603 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); |
604 | break; | 604 | break; |
605 | case RadioOff: | 605 | case RadioOff: |
606 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); | 606 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); |
607 | break; | 607 | break; |
608 | case Tab: | 608 | case Tab: |
609 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); | 609 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); |
610 | break; | 610 | break; |
611 | case CB: | 611 | case CB: |
612 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); | 612 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); |
613 | break; | 613 | break; |
614 | case VSBSliderTop: | 614 | case VSBSliderTop: |
615 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 615 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
616 | break; | 616 | break; |
617 | case VSBSliderBtm: | 617 | case VSBSliderBtm: |
618 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 618 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
619 | break; | 619 | break; |
620 | case VSBSliderMid: | 620 | case VSBSliderMid: |
621 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 621 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
622 | break; | 622 | break; |
623 | case VSBSliderTopHover: | 623 | case VSBSliderTopHover: |
624 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 624 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
625 | break; | 625 | break; |
626 | case VSBSliderBtmHover: | 626 | case VSBSliderBtmHover: |
627 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 627 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
628 | break; | 628 | break; |
629 | case VSBSliderMidHover: | 629 | case VSBSliderMidHover: |
630 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 630 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
631 | break; | 631 | break; |
632 | 632 | ||
633 | case HSBSliderTop: | 633 | case HSBSliderTop: |
634 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 634 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
635 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); | 635 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); |
636 | break; | 636 | break; |
637 | case HSBSliderBtm: | 637 | case HSBSliderBtm: |
638 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 638 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
639 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); | 639 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); |
640 | break; | 640 | break; |
641 | case HSBSliderMid: | 641 | case HSBSliderMid: |
642 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 642 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
643 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); | 643 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); |
644 | break; | 644 | break; |
645 | case HSBSliderTopHover: | 645 | case HSBSliderTopHover: |
646 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 646 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
647 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); | 647 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); |
648 | break; | 648 | break; |
649 | case HSBSliderBtmHover: | 649 | case HSBSliderBtmHover: |
650 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 650 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
651 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); | 651 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); |
652 | break; | 652 | break; |
653 | case HSBSliderMidHover: | 653 | case HSBSliderMidHover: |
654 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 654 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
655 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); | 655 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); |
656 | break; | 656 | break; |
657 | case VSBSliderTopBg: | 657 | case VSBSliderTopBg: |
658 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 658 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
659 | break; | 659 | break; |
660 | case VSBSliderBtmBg: | 660 | case VSBSliderBtmBg: |
661 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 661 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
662 | break; | 662 | break; |
663 | case VSBSliderMidBg: | 663 | case VSBSliderMidBg: |
664 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 664 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
665 | break; | 665 | break; |
666 | case HSBSliderTopBg: | 666 | case HSBSliderTopBg: |
667 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 667 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
668 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); | 668 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); |
669 | break; | 669 | break; |
670 | case HSBSliderBtmBg: | 670 | case HSBSliderBtmBg: |
671 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 671 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
672 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); | 672 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); |
673 | break; | 673 | break; |
674 | case HSBSliderMidBg: | 674 | case HSBSliderMidBg: |
675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); | 676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); |
677 | break; | 677 | break; |
678 | default: | 678 | default: |
679 | break; | 679 | break; |
680 | } | 680 | } |
681 | return(pixmaps[item]); | 681 | return(pixmaps[item]); |
682 | } | 682 | } |
683 | 683 | ||
684 | void LiquidStyle::polish(QPalette &appPal) | 684 | void LiquidStyle::polish(QPalette &appPal) |
685 | { | 685 | { |
686 | 686 | ||
687 | int i; | 687 | int i; |
688 | for(i=0; i < BITMAP_ITEMS; ++i){ | 688 | for(i=0; i < BITMAP_ITEMS; ++i){ |
689 | if(pixmaps[i]){ | 689 | if(pixmaps[i]){ |
690 | delete pixmaps[i]; | 690 | delete pixmaps[i]; |
691 | pixmaps[i] = NULL; | 691 | pixmaps[i] = NULL; |
692 | } | 692 | } |
693 | } | 693 | } |
694 | QWidgetList *list = QApplication::allWidgets(); | 694 | QWidgetList *list = QApplication::allWidgets(); |
695 | QWidgetListIt it( *list ); | 695 | QWidgetListIt it( *list ); |
696 | QWidget *w; | 696 | QWidget *w; |
697 | while ((w=it.current()) != 0 ){ | 697 | while ((w=it.current()) != 0 ){ |
698 | ++it; | 698 | ++it; |
699 | if(w->inherits("QPushButton")){ | 699 | if(w->inherits("QPushButton")){ |
700 | unapplyCustomAttributes((QPushButton *)w); | 700 | unapplyCustomAttributes((QPushButton *)w); |
701 | } | 701 | } |
702 | } | 702 | } |
703 | 703 | ||
704 | loadCustomButtons(); | 704 | loadCustomButtons(); |
705 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; | 705 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; |
706 | btnDict.clear(); | 706 | btnDict.clear(); |
707 | btnBorderDict.clear(); | 707 | btnBorderDict.clear(); |
708 | bevelFillDict.clear(); | 708 | bevelFillDict.clear(); |
709 | smallBevelFillDict.clear(); | 709 | smallBevelFillDict.clear(); |
710 | 710 | ||
711 | Config config ( "qpe" ); | 711 | Config config ( "qpe" ); |
712 | config. setGroup ( "Liquid-Style" ); | 712 | config. setGroup ( "Liquid-Style" ); |
713 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); | 713 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); |
714 | if ( contrast < 0 ) | 714 | if ( contrast < 0 ) |
715 | contrast = 0; | 715 | contrast = 0; |
716 | else if ( contrast > 10 ) | 716 | else if ( contrast > 10 ) |
717 | contrast = 10; | 717 | contrast = 10; |
718 | 718 | ||
719 | QPalette pal = QApplication::palette(); | 719 | QPalette pal = QApplication::palette(); |
720 | 720 | ||
721 | // button color stuff | 721 | // button color stuff |
722 | config. setGroup ( "Appearance" ); | 722 | config. setGroup ( "Appearance" ); |
723 | QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); | 723 | QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); |
724 | if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { | 724 | if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { |
725 | // force button color to be different from background | 725 | // force button color to be different from background |
726 | QBrush btnBrush(QColor(200, 202, 228)); | 726 | QBrush btnBrush(QColor(200, 202, 228)); |
727 | appPal.setBrush(QColorGroup::Button, btnBrush); | 727 | appPal.setBrush(QColorGroup::Button, btnBrush); |
728 | } | 728 | } |
729 | c.hsv(&btnH, &btnS, &btnV); | 729 | c.hsv(&btnH, &btnS, &btnV); |
730 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); | 730 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); |
731 | 731 | ||
732 | // menu pixmap | 732 | // menu pixmap |
733 | if(!menuPix){ | 733 | if(!menuPix){ |
734 | menuPix = new QPixmap; | 734 | menuPix = new QPixmap; |
735 | menuPix->resize(64, 64); | 735 | menuPix->resize(64, 64); |
736 | } | 736 | } |
737 | QPainter painter; | 737 | QPainter painter; |
738 | menuPix->fill(c.rgb()); | 738 | menuPix->fill(c.rgb()); |
739 | painter.begin(menuPix); | 739 | painter.begin(menuPix); |
740 | painter.setPen(c.dark(105)); | 740 | painter.setPen(c.dark(105)); |
741 | for(i=0; i < 63; i+=4){ | 741 | for(i=0; i < 63; i+=4){ |
742 | painter.drawLine(0, i, 63, i); | 742 | painter.drawLine(0, i, 63, i); |
743 | painter.drawLine(0, i+1, 63, i+1); | 743 | painter.drawLine(0, i+1, 63, i+1); |
744 | }; | 744 | }; |
745 | painter.end(); | 745 | painter.end(); |
746 | menuBrush.setColor(c); | 746 | menuBrush.setColor(c); |
747 | menuBrush.setPixmap(*menuPix); | 747 | menuBrush.setPixmap(*menuPix); |
748 | 748 | ||
749 | // pager brush | 749 | // pager brush |
750 | c = c.dark(120); | 750 | c = c.dark(120); |
751 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 751 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
752 | if(!pix){ | 752 | if(!pix){ |
753 | int h, s, v; | 753 | int h, s, v; |
754 | c.hsv(&h, &s, &v); | 754 | c.hsv(&h, &s, &v); |
755 | pix = new QPixmap(*smallBevelFillPix); | 755 | pix = new QPixmap(*smallBevelFillPix); |
756 | adjustHSV(*pix, h, s, v); | 756 | adjustHSV(*pix, h, s, v); |
757 | smallBevelFillDict.insert(c.rgb(), pix); | 757 | smallBevelFillDict.insert(c.rgb(), pix); |
758 | } | 758 | } |
759 | pagerHoverBrush.setColor(c); | 759 | pagerHoverBrush.setColor(c); |
760 | pagerHoverBrush.setPixmap(*pix); | 760 | pagerHoverBrush.setPixmap(*pix); |
761 | 761 | ||
762 | c = c.dark(120); | 762 | c = c.dark(120); |
763 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 763 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
764 | if(!pix){ | 764 | if(!pix){ |
765 | int h, s, v; | 765 | int h, s, v; |
766 | c.hsv(&h, &s, &v); | 766 | c.hsv(&h, &s, &v); |
767 | pix = new QPixmap(*smallBevelFillPix); | 767 | pix = new QPixmap(*smallBevelFillPix); |
768 | adjustHSV(*pix, h, s, v); | 768 | adjustHSV(*pix, h, s, v); |
769 | smallBevelFillDict.insert(c.rgb(), pix); | 769 | smallBevelFillDict.insert(c.rgb(), pix); |
770 | } | 770 | } |
771 | pagerBrush.setColor(c); | 771 | pagerBrush.setColor(c); |
772 | pagerBrush.setPixmap(*pix); | 772 | pagerBrush.setPixmap(*pix); |
773 | 773 | ||
774 | // background color stuff | 774 | // background color stuff |
775 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); | 775 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); |
776 | c.hsv(&bH, &bS, &bV); | 776 | c.hsv(&bH, &bS, &bV); |
777 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 777 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
778 | 778 | ||
779 | // FIXME? | 779 | // FIXME? |
780 | if(vsbSliderFillPix) | 780 | if(vsbSliderFillPix) |
781 | delete vsbSliderFillPix; | 781 | delete vsbSliderFillPix; |
782 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 782 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
783 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 783 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
784 | 784 | ||
785 | // background brush | 785 | // background brush |
786 | QPixmap wallPaper(32, 32); | 786 | QPixmap wallPaper(32, 32); |
787 | wallPaper.fill(c.rgb()); | 787 | wallPaper.fill(c.rgb()); |
788 | painter.begin(&wallPaper); | 788 | painter.begin(&wallPaper); |
789 | for(i=0; i < 32; i+=4){ | 789 | for(i=0; i < 32; i+=4){ |
790 | painter.setPen(c.dark(100 + contrast)); | 790 | painter.setPen(c.dark(100 + contrast)); |
791 | painter.drawLine(0, i, 32, i); | 791 | painter.drawLine(0, i, 32, i); |
792 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 792 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
793 | painter.drawLine(0, i+1, 32, i+1); | 793 | painter.drawLine(0, i+1, 32, i+1); |
794 | }; | 794 | }; |
795 | painter.end(); | 795 | painter.end(); |
796 | bgBrush.setColor(c); | 796 | bgBrush.setColor(c); |
797 | bgBrush.setPixmap(wallPaper); | 797 | bgBrush.setPixmap(wallPaper); |
798 | appPal.setBrush(QColorGroup::Background, bgBrush); | 798 | appPal.setBrush(QColorGroup::Background, bgBrush); |
799 | 799 | ||
800 | // lineedits | 800 | // lineedits |
801 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); | 801 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); |
802 | QPixmap basePix; | 802 | QPixmap basePix; |
803 | basePix.resize(32, 32); | 803 | basePix.resize(32, 32); |
804 | basePix.fill(c.rgb()); | 804 | basePix.fill(c.rgb()); |
805 | painter.begin(&basePix); | 805 | painter.begin(&basePix); |
806 | painter.setPen(c.dark(105)); | 806 | painter.setPen(c.dark(105)); |
807 | for(i=0; i < 32; i+=4){ | 807 | for(i=0; i < 32; i+=4){ |
808 | painter.drawLine(0, i, 32, i); | 808 | painter.drawLine(0, i, 32, i); |
809 | painter.drawLine(0, i+1, 32, i+1); | 809 | painter.drawLine(0, i+1, 32, i+1); |
810 | }; | 810 | }; |
811 | painter.end(); | 811 | painter.end(); |
812 | baseBrush.setColor(c); | 812 | baseBrush.setColor(c); |
813 | baseBrush.setPixmap(basePix); | 813 | baseBrush.setPixmap(basePix); |
814 | it.toFirst(); | 814 | it.toFirst(); |
815 | while ((w=it.current()) != 0 ){ | 815 | while ((w=it.current()) != 0 ){ |
816 | ++it; | 816 | ++it; |
817 | if(w->inherits("QLineEdit")){ | 817 | if(w->inherits("QLineEdit")){ |
818 | QPalette pal = w->palette(); | 818 | QPalette pal = w->palette(); |
819 | pal.setBrush(QColorGroup::Base, baseBrush); | 819 | pal.setBrush(QColorGroup::Base, baseBrush); |
820 | w->setPalette(pal); | 820 | w->setPalette(pal); |
821 | } | 821 | } |
822 | else if(w->inherits("QPushButton")){ | 822 | else if(w->inherits("QPushButton")){ |
823 | applyCustomAttributes((QPushButton *)w); | 823 | applyCustomAttributes((QPushButton *)w); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | 826 | ||
827 | } | 827 | } |
828 | 828 | ||
829 | void LiquidStyle::polish(QWidget *w) | 829 | void LiquidStyle::polish(QWidget *w) |
830 | { | 830 | { |
831 | if(w->inherits("QMenuBar")){ | 831 | if(w->inherits("QMenuBar")){ |
832 | //((QFrame*)w)->setLineWidth(0); | 832 | //((QFrame*)w)->setLineWidth(0); |
833 | w->setBackgroundMode(QWidget::PaletteBackground); | 833 | w->setBackgroundMode(QWidget::PaletteBackground); |
834 | return; | 834 | return; |
835 | } | 835 | } |
836 | if(w->inherits("QPopupMenu")) | 836 | if(w->inherits("QPopupMenu")) |
837 | w->setBackgroundMode(QWidget::NoBackground); | 837 | w->setBackgroundMode(QWidget::NoBackground); |
838 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 838 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
839 | w->installEventFilter(menuHandler); | 839 | w->installEventFilter(menuHandler); |
840 | } | 840 | } |
841 | 841 | ||
842 | if(w->isTopLevel()){ | 842 | if(w->isTopLevel()){ |
843 | return; | 843 | return; |
844 | } | 844 | } |
845 | 845 | ||
846 | 846 | ||
847 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) | 847 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) |
848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | 848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); |
849 | 849 | ||
850 | if(w->inherits("QComboBox") || | 850 | if(w->inherits("QComboBox") || |
851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
853 | w->installEventFilter(this); | 853 | w->installEventFilter(this); |
854 | } | 854 | } |
855 | if(w->inherits("QLineEdit")){ | 855 | if(w->inherits("QLineEdit")){ |
856 | QPalette pal = w->palette(); | 856 | QPalette pal = w->palette(); |
857 | pal.setBrush(QColorGroup::Base, baseBrush); | 857 | pal.setBrush(QColorGroup::Base, baseBrush); |
858 | w->setPalette(pal); | 858 | w->setPalette(pal); |
859 | } | 859 | } |
860 | if(w->inherits("QPushButton")){ | 860 | if(w->inherits("QPushButton")){ |
861 | applyCustomAttributes((QPushButton *)w); | 861 | applyCustomAttributes((QPushButton *)w); |
862 | w->installEventFilter(this); | 862 | w->installEventFilter(this); |
863 | } | 863 | } |
864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
866 | } | 866 | } |
867 | 867 | ||
868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
870 | bool isViewportChild = w->parent() && | 870 | bool isViewportChild = w->parent() && |
871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
873 | 873 | ||
874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
875 | w->setBackgroundMode(QWidget::X11ParentRelative); | 875 | w->setBackgroundMode(QWidget::X11ParentRelative); |
876 | return; | 876 | return; |
877 | } | 877 | } |
878 | if(isViewportChild){ | 878 | if(isViewportChild){ |
879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) | 880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) |
881 | if(w->parent()->parent()){ | 881 | if(w->parent()->parent()){ |
882 | if(w->parent()->parent()->parent() && | 882 | if(w->parent()->parent()->parent() && |
883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ | 883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ |
884 | w->setAutoMask(true); | 884 | w->setAutoMask(true); |
885 | w->setBackgroundMode(QWidget::NoBackground); | 885 | w->setBackgroundMode(QWidget::NoBackground); |
886 | } | 886 | } |
887 | } | 887 | } |
888 | } | 888 | } |
889 | return; | 889 | return; |
890 | } | 890 | } |
891 | } | 891 | } |
892 | if(w->inherits("QHeader")){ | 892 | if(w->inherits("QHeader")){ |
893 | w->setMouseTracking(true); | 893 | w->setMouseTracking(true); |
894 | w->installEventFilter(this); | 894 | w->installEventFilter(this); |
895 | } | 895 | } |
896 | if(w-> inherits("QToolButton")) { | 896 | if(w-> inherits("QToolButton")) { |
897 | ((QToolButton*)w)->setAutoRaise (false); | 897 | ((QToolButton*)w)->setAutoRaise (false); |
898 | } | 898 | } |
899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
900 | return; | 900 | return; |
901 | } | 901 | } |
902 | 902 | ||
903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
904 | palette().active().brush(QColorGroup::Background).pixmap()){ | 904 | palette().active().brush(QColorGroup::Background).pixmap()){ |
905 | qWarning("No parent pixmap for child widget %s", w->className()); | 905 | qWarning("No parent pixmap for child widget %s", w->className()); |
906 | return; | 906 | return; |
907 | } | 907 | } |
908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
910 | if(w->backgroundMode() == QWidget::PaletteBackground || | 910 | if(w->backgroundMode() == QWidget::PaletteBackground || |
911 | w->backgroundMode() == QWidget::PaletteButton){ | 911 | w->backgroundMode() == QWidget::PaletteButton){ |
912 | w->setBackgroundMode(QWidget::X11ParentRelative); | 912 | w->setBackgroundMode(QWidget::X11ParentRelative); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | if(w->inherits("QToolBar")){ | 915 | if(w->inherits("QToolBar")){ |
916 | w->installEventFilter(this); | 916 | w->installEventFilter(this); |
917 | w->setBackgroundMode(QWidget::PaletteBackground); | 917 | w->setBackgroundMode(QWidget::PaletteBackground); |
918 | return; | 918 | return; |
919 | } | 919 | } |
920 | 920 | ||
921 | } | 921 | } |
922 | 922 | ||
923 | void LiquidStyle::unPolish(QWidget *w) | 923 | void LiquidStyle::unPolish(QWidget *w) |
924 | { | 924 | { |
925 | if(w->inherits("QMenuBar")){ | 925 | if(w->inherits("QMenuBar")){ |
926 | ((QFrame *)w)->setLineWidth(1); | 926 | ((QFrame *)w)->setLineWidth(1); |
927 | w->setBackgroundMode(QWidget::PaletteBackground); | 927 | w->setBackgroundMode(QWidget::PaletteBackground); |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | 930 | ||
931 | if(w->inherits("QPopupMenu")) | 931 | if(w->inherits("QPopupMenu")) |
932 | w->setBackgroundMode(QWidget::PaletteButton); | 932 | w->setBackgroundMode(QWidget::PaletteButton); |
933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
934 | w->removeEventFilter(menuHandler); | 934 | w->removeEventFilter(menuHandler); |
935 | } | 935 | } |
936 | 936 | ||
937 | if(w->isTopLevel()) | 937 | if(w->isTopLevel()) |
938 | return; | 938 | return; |
939 | 939 | ||
940 | // for viewport children, don't just check for NoBackground.... | 940 | // for viewport children, don't just check for NoBackground.... |
941 | bool isViewportChild = w->parent() && | 941 | bool isViewportChild = w->parent() && |
942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
944 | 944 | ||
945 | w->setPalette(QApplication::palette()); | 945 | w->setPalette(QApplication::palette()); |
946 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 946 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
947 | if(w->inherits("QPushButton")) | 947 | if(w->inherits("QPushButton")) |
948 | w->setBackgroundMode(QWidget::PaletteButton); | 948 | w->setBackgroundMode(QWidget::PaletteButton); |
949 | else | 949 | else |
950 | w->setBackgroundMode(QWidget::PaletteBackground); | 950 | w->setBackgroundMode(QWidget::PaletteBackground); |
951 | } | 951 | } |
952 | 952 | ||
953 | if(isViewportChild) | 953 | if(isViewportChild) |
954 | w->setAutoMask(false); | 954 | w->setAutoMask(false); |
955 | 955 | ||
956 | if(w->inherits("QPushButton")){ | 956 | if(w->inherits("QPushButton")){ |
957 | unapplyCustomAttributes((QPushButton *)w); | 957 | unapplyCustomAttributes((QPushButton *)w); |
958 | w->removeEventFilter(this); | 958 | w->removeEventFilter(this); |
959 | } | 959 | } |
960 | /* | 960 | /* |
961 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 961 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
962 | w-> setBackgroundMode ( PaletteBackground ); | 962 | w-> setBackgroundMode ( PaletteBackground ); |
963 | } | 963 | } |
964 | */ | 964 | */ |
965 | if(w->inherits("QComboBox") || | 965 | if(w->inherits("QComboBox") || |
966 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 966 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
967 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 967 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
968 | w->removeEventFilter(this); | 968 | w->removeEventFilter(this); |
969 | } | 969 | } |
970 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 970 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
971 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ | 971 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ |
972 | w->setAutoMask(false); | 972 | w->setAutoMask(false); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | if(w->inherits("QToolBar")){ | 975 | if(w->inherits("QToolBar")){ |
976 | w->removeEventFilter(this); | 976 | w->removeEventFilter(this); |
977 | w->setBackgroundMode(QWidget::PaletteBackground); | 977 | w->setBackgroundMode(QWidget::PaletteBackground); |
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | if(w->inherits("QHeader")){ | 980 | if(w->inherits("QHeader")){ |
981 | w->setMouseTracking(false); | 981 | w->setMouseTracking(false); |
982 | w->removeEventFilter(this); | 982 | w->removeEventFilter(this); |
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | void LiquidStyle::polish(QApplication *app) | 986 | void LiquidStyle::polish(QApplication *app) |
987 | { | 987 | { |
988 | 988 | ||
989 | QWindowsStyle::polish(app); | 989 | QWindowsStyle::polish(app); |
990 | menuAni = app->isEffectEnabled(UI_AnimateMenu); | 990 | menuAni = app->isEffectEnabled(UI_AnimateMenu); |
991 | menuFade = app->isEffectEnabled(UI_FadeMenu); | 991 | menuFade = app->isEffectEnabled(UI_FadeMenu); |
992 | if(menuAni) | 992 | if(menuAni) |
993 | app->setEffectEnabled(UI_AnimateMenu, false); | 993 | app->setEffectEnabled(UI_AnimateMenu, false); |
994 | if(menuFade) | 994 | if(menuFade) |
995 | app->setEffectEnabled(UI_FadeMenu, false); | 995 | app->setEffectEnabled(UI_FadeMenu, false); |
996 | 996 | ||
997 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); | 997 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); |
998 | 998 | ||
999 | Config config ( "qpe" ); | 999 | Config config ( "qpe" ); |
1000 | config. setGroup ( "Liquid-Style" ); | 1000 | config. setGroup ( "Liquid-Style" ); |
1001 | 1001 | ||
1002 | if ( config. readBoolEntry ( "WinDecoration", true )) | 1002 | if ( config. readBoolEntry ( "WinDecoration", true )) |
1003 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | 1003 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | void LiquidStyle::unPolish(QApplication *app) | 1006 | void LiquidStyle::unPolish(QApplication *app) |
1007 | { | 1007 | { |
1008 | QWindowsStyle::unPolish(app); | 1008 | QWindowsStyle::unPolish(app); |
1009 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 1009 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
1010 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 1010 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
1011 | 1011 | ||
1012 | qt_set_draw_menu_bar_impl ( 0 ); | 1012 | qt_set_draw_menu_bar_impl ( 0 ); |
1013 | 1013 | ||
1014 | QApplication::qwsSetDecoration ( new QPEDecoration ( )); | 1014 | QApplication::qwsSetDecoration ( new QPEDecoration ( )); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | /* | 1017 | /* |
1018 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1018 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1019 | * force everything to erase and repaint on resize. This is going away, I'm | 1019 | * force everything to erase and repaint on resize. This is going away, I'm |
1020 | * trying to get shaped widgets to work right without masking. QPushButton, | 1020 | * trying to get shaped widgets to work right without masking. QPushButton, |
1021 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1021 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1022 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1022 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1023 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1023 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1024 | * caches them in QPixmapCache, which is bad for doing things like hover | 1024 | * caches them in QPixmapCache, which is bad for doing things like hover |
1025 | * because the style methods aren't called in paintEvents if everything | 1025 | * because the style methods aren't called in paintEvents if everything |
1026 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1026 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1027 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1027 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1028 | * modifications. For QHeader, different header items are actually one widget | 1028 | * modifications. For QHeader, different header items are actually one widget |
1029 | * that draws multiple items, so we need to check which ID is hightlighted | 1029 | * that draws multiple items, so we need to check which ID is hightlighted |
1030 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1030 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1031 | * since if it's inside a combobox we want to highlight the combobox during | 1031 | * since if it's inside a combobox we want to highlight the combobox during |
1032 | * hovering in the edit. | 1032 | * hovering in the edit. |
1033 | */ | 1033 | */ |
1034 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1034 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1035 | { | 1035 | { |
1036 | if(obj->inherits("QToolBar")){ | 1036 | if(obj->inherits("QToolBar")){ |
1037 | if(ev->type() == QEvent::Resize){ | 1037 | if(ev->type() == QEvent::Resize){ |
1038 | const QObjectList *tbChildList = obj->children(); | 1038 | const QObjectList *tbChildList = obj->children(); |
1039 | QObjectListIt it(*tbChildList); | 1039 | QObjectListIt it(*tbChildList); |
1040 | QObject *child; | 1040 | QObject *child; |
1041 | while((child = it.current()) != NULL){ | 1041 | while((child = it.current()) != NULL){ |
1042 | ++it; | 1042 | ++it; |
1043 | if(child->isWidgetType()) | 1043 | if(child->isWidgetType()) |
1044 | ((QWidget *)child)->repaint(true); | 1044 | ((QWidget *)child)->repaint(true); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ | 1049 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ |
1050 | QWidget *btn = (QWidget *)obj; | 1050 | QWidget *btn = (QWidget *)obj; |
1051 | if(ev->type() == QEvent::Enter){ | 1051 | if(ev->type() == QEvent::Enter){ |
1052 | if(btn->isEnabled()){ | 1052 | if(btn->isEnabled()){ |
1053 | highlightWidget = btn; | 1053 | highlightWidget = btn; |
1054 | btn->repaint(false); | 1054 | btn->repaint(false); |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | else if(ev->type() == QEvent::Leave){ | 1057 | else if(ev->type() == QEvent::Leave){ |
1058 | if(btn == highlightWidget){ | 1058 | if(btn == highlightWidget){ |
1059 | highlightWidget = NULL; | 1059 | highlightWidget = NULL; |
1060 | btn->repaint(false); | 1060 | btn->repaint(false); |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | else if(obj->inherits("QToolButton")){ | 1064 | else if(obj->inherits("QToolButton")){ |
1065 | QToolButton *btn = (QToolButton *)btn; | 1065 | QToolButton *btn = (QToolButton *)btn; |
1066 | if(!btn->autoRaise()){ | 1066 | if(!btn->autoRaise()){ |
1067 | if(btn->isEnabled()){ | 1067 | if(btn->isEnabled()){ |
1068 | highlightWidget = btn; | 1068 | highlightWidget = btn; |
1069 | btn->repaint(false); | 1069 | btn->repaint(false); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | else if(ev->type() == QEvent::Leave){ | 1072 | else if(ev->type() == QEvent::Leave){ |
1073 | QWidget *btn = (QWidget *)obj; | 1073 | QWidget *btn = (QWidget *)obj; |
1074 | if(btn == highlightWidget){ | 1074 | if(btn == highlightWidget){ |
1075 | highlightWidget = NULL; | 1075 | highlightWidget = NULL; |
1076 | btn->repaint(false); | 1076 | btn->repaint(false); |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | else | 1079 | else |
1080 | highlightWidget = NULL; | 1080 | highlightWidget = NULL; |
1081 | } | 1081 | } |
1082 | else if(obj->inherits("QScrollBar")){ | 1082 | else if(obj->inherits("QScrollBar")){ |
1083 | QScrollBar *sb = (QScrollBar *)obj; | 1083 | QScrollBar *sb = (QScrollBar *)obj; |
1084 | if(ev->type() == QEvent::Enter){ | 1084 | if(ev->type() == QEvent::Enter){ |
1085 | if(sb->isEnabled()){ | 1085 | if(sb->isEnabled()){ |
1086 | highlightWidget = sb; | 1086 | highlightWidget = sb; |
1087 | sb->repaint(false); | 1087 | sb->repaint(false); |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | else if(ev->type() == QEvent::Leave){ | 1090 | else if(ev->type() == QEvent::Leave){ |
1091 | if(sb == highlightWidget && !sb->draggingSlider()){ | 1091 | if(sb == highlightWidget && !sb->draggingSlider()){ |
1092 | highlightWidget = NULL; | 1092 | highlightWidget = NULL; |
1093 | sb->repaint(false); | 1093 | sb->repaint(false); |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | else if(ev->type() == QEvent::MouseButtonRelease){ | 1096 | else if(ev->type() == QEvent::MouseButtonRelease){ |
1097 | QMouseEvent *me = (QMouseEvent *)ev; | 1097 | QMouseEvent *me = (QMouseEvent *)ev; |
1098 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ | 1098 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ |
1099 | highlightWidget = NULL; | 1099 | highlightWidget = NULL; |
1100 | sb->repaint(false); | 1100 | sb->repaint(false); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | else if(obj->inherits("QLineEdit")){ | 1104 | else if(obj->inherits("QLineEdit")){ |
1105 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ | 1105 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ |
1106 | QWidget *btn = (QComboBox *)obj->parent(); | 1106 | QWidget *btn = (QComboBox *)obj->parent(); |
1107 | if(ev->type() == QEvent::Enter){ | 1107 | if(ev->type() == QEvent::Enter){ |
1108 | if (btn->isEnabled()){ | 1108 | if (btn->isEnabled()){ |
1109 | highlightWidget = btn; | 1109 | highlightWidget = btn; |
1110 | btn->repaint(false); | 1110 | btn->repaint(false); |
1111 | } | 1111 | } |
1112 | } | 1112 | } |
1113 | else if(ev->type() == QEvent::Leave){ | 1113 | else if(ev->type() == QEvent::Leave){ |
1114 | if (btn == highlightWidget) | 1114 | if (btn == highlightWidget) |
1115 | highlightWidget = NULL; | 1115 | highlightWidget = NULL; |
1116 | btn->repaint(false); | 1116 | btn->repaint(false); |
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1121 | QButton *btn = (QButton *)obj; | 1121 | QButton *btn = (QButton *)obj; |
1122 | bool isRadio = obj->inherits("QRadioButton"); | 1122 | bool isRadio = obj->inherits("QRadioButton"); |
1123 | if(ev->type() == QEvent::Paint){ | 1123 | if(ev->type() == QEvent::Paint){ |
1124 | //if(btn->autoMask()) | 1124 | //if(btn->autoMask()) |
1125 | btn->erase(); | 1125 | btn->erase(); |
1126 | QPainter p; | 1126 | QPainter p; |
1127 | p.begin(btn); | 1127 | p.begin(btn); |
1128 | QFontMetrics fm = btn->fontMetrics(); | 1128 | QFontMetrics fm = btn->fontMetrics(); |
1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1130 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1130 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1131 | : indicatorSize(); | 1131 | : indicatorSize(); |
1132 | 1132 | ||
1133 | if(btn->hasFocus()){ | 1133 | if(btn->hasFocus()){ |
1134 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1134 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1135 | p.setPen(btn->colorGroup().button().dark(140)); | 1135 | p.setPen(btn->colorGroup().button().dark(140)); |
1136 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1136 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1137 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1137 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1138 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1138 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1139 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1139 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1140 | } | 1140 | } |
1141 | int x = 0; | 1141 | int x = 0; |
1142 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1142 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1143 | if(isRadio) | 1143 | if(isRadio) |
1144 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1144 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1145 | btn->colorGroup(), btn->isOn(), | 1145 | btn->colorGroup(), btn->isOn(), |
1146 | btn->isDown(), btn->isEnabled()); | 1146 | btn->isDown(), btn->isEnabled()); |
1147 | else | 1147 | else |
1148 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1148 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1149 | btn->colorGroup(), btn->state(), btn->isDown(), | 1149 | btn->colorGroup(), btn->state(), btn->isDown(), |
1150 | btn->isEnabled()); | 1150 | btn->isEnabled()); |
1151 | x = sz.width() + 6; | 1151 | x = sz.width() + 6; |
1152 | y = 0; | 1152 | y = 0; |
1153 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1153 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1154 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1154 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1155 | btn->colorGroup(), btn->isEnabled(), | 1155 | btn->colorGroup(), btn->isEnabled(), |
1156 | btn->pixmap(), btn->text()); | 1156 | btn->pixmap(), btn->text()); |
1157 | p.end(); | 1157 | p.end(); |
1158 | return(true); | 1158 | return(true); |
1159 | } | 1159 | } |
1160 | // for hover, just redraw the indicator (not the text) | 1160 | // for hover, just redraw the indicator (not the text) |
1161 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || | 1161 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || |
1162 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ | 1162 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ |
1163 | QButton *btn = (QButton *)obj; | 1163 | QButton *btn = (QButton *)obj; |
1164 | bool isRadio = obj->inherits("QRadioButton"); | 1164 | bool isRadio = obj->inherits("QRadioButton"); |
1165 | 1165 | ||
1166 | if(ev->type() == QEvent::Enter) | 1166 | if(ev->type() == QEvent::Enter) |
1167 | highlightWidget = btn; | 1167 | highlightWidget = btn; |
1168 | else | 1168 | else |
1169 | highlightWidget = NULL; | 1169 | highlightWidget = NULL; |
1170 | QFontMetrics fm = btn->fontMetrics(); | 1170 | QFontMetrics fm = btn->fontMetrics(); |
1171 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1171 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1172 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1172 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1173 | : indicatorSize(); | 1173 | : indicatorSize(); |
1174 | int x = 0; | 1174 | int x = 0; |
1175 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1175 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1176 | //if(btn->autoMask()) | 1176 | //if(btn->autoMask()) |
1177 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); | 1177 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); |
1178 | QPainter p; | 1178 | QPainter p; |
1179 | p.begin(btn); | 1179 | p.begin(btn); |
1180 | if(isRadio) | 1180 | if(isRadio) |
1181 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1181 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1182 | btn->colorGroup(), btn->isOn(), | 1182 | btn->colorGroup(), btn->isOn(), |
1183 | btn->isDown(), btn->isEnabled()); | 1183 | btn->isDown(), btn->isEnabled()); |
1184 | else | 1184 | else |
1185 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1185 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1186 | btn->colorGroup(), btn->state(), btn->isDown(), | 1186 | btn->colorGroup(), btn->state(), btn->isDown(), |
1187 | btn->isEnabled()); | 1187 | btn->isEnabled()); |
1188 | p.end(); | 1188 | p.end(); |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | else if(obj->inherits("QHeader")){ | 1191 | else if(obj->inherits("QHeader")){ |
1192 | QHeader *hw = (QHeader *)obj; | 1192 | QHeader *hw = (QHeader *)obj; |
1193 | if(ev->type() == QEvent::Enter){ | 1193 | if(ev->type() == QEvent::Enter){ |
1194 | currentHeader = hw; | 1194 | currentHeader = hw; |
1195 | headerHoverID = -1; | 1195 | headerHoverID = -1; |
1196 | } | 1196 | } |
1197 | else if(ev->type() == QEvent::Leave){ | 1197 | else if(ev->type() == QEvent::Leave){ |
1198 | currentHeader = NULL; | 1198 | currentHeader = NULL; |
1199 | if(headerHoverID != -1){ | 1199 | if(headerHoverID != -1){ |
1200 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1200 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1201 | hw->sectionSize(headerHoverID), hw->height()); | 1201 | hw->sectionSize(headerHoverID), hw->height()); |
1202 | } | 1202 | } |
1203 | headerHoverID = -1; | 1203 | headerHoverID = -1; |
1204 | } | 1204 | } |
1205 | else if(ev->type() == QEvent::MouseMove){ | 1205 | else if(ev->type() == QEvent::MouseMove){ |
1206 | QMouseEvent *me = (QMouseEvent *)ev; | 1206 | QMouseEvent *me = (QMouseEvent *)ev; |
1207 | int oldHeader = headerHoverID; | 1207 | int oldHeader = headerHoverID; |
1208 | headerHoverID = hw->sectionAt(me->x()); | 1208 | headerHoverID = hw->sectionAt(me->x()); |
1209 | if(oldHeader != headerHoverID){ | 1209 | if(oldHeader != headerHoverID){ |
1210 | // reset old header | 1210 | // reset old header |
1211 | if(oldHeader != -1){ | 1211 | if(oldHeader != -1){ |
1212 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1212 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1213 | hw->sectionSize(oldHeader), hw->height()); | 1213 | hw->sectionSize(oldHeader), hw->height()); |
1214 | } | 1214 | } |
1215 | if(headerHoverID != -1){ | 1215 | if(headerHoverID != -1){ |
1216 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1216 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1217 | hw->sectionSize(headerHoverID), hw->height()); | 1217 | hw->sectionSize(headerHoverID), hw->height()); |
1218 | } | 1218 | } |
1219 | } | 1219 | } |
1220 | } | 1220 | } |
1221 | } | 1221 | } |
1222 | return(false); | 1222 | return(false); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1225 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1226 | const QColorGroup &g, bool sunken, | 1226 | const QColorGroup &g, bool sunken, |
1227 | const QBrush *) | 1227 | const QBrush *) |
1228 | { | 1228 | { |
1229 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1229 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1230 | x, y, w, h); | 1230 | x, y, w, h); |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1233 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1234 | const QColorGroup &g, bool sunken, | 1234 | const QColorGroup &g, bool sunken, |
1235 | const QBrush *) | 1235 | const QBrush *) |
1236 | { | 1236 | { |
1237 | if(p->device()->devType() != QInternal::Widget){ | 1237 | if(p->device()->devType() != QInternal::Widget){ |
1238 | // drawing into a temp pixmap, don't use mask | 1238 | // drawing into a temp pixmap, don't use mask |
1239 | QColor c = sunken ? g.button() : g.background(); | 1239 | QColor c = sunken ? g.button() : g.background(); |
1240 | p->setPen(c.dark(130)); | 1240 | p->setPen(c.dark(130)); |
1241 | p->drawRect(x, y, w, h); | 1241 | p->drawRect(x, y, w, h); |
1242 | p->setPen(c.light(105)); | 1242 | p->setPen(c.light(105)); |
1243 | p->drawRect(x+1, y+1, w-2, h-2); | 1243 | p->drawRect(x+1, y+1, w-2, h-2); |
1244 | 1244 | ||
1245 | 1245 | ||
1246 | // fill | 1246 | // fill |
1247 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1247 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1248 | if(!pix){ | 1248 | if(!pix){ |
1249 | int h, s, v; | 1249 | int h, s, v; |
1250 | c.hsv(&h, &s, &v); | 1250 | c.hsv(&h, &s, &v); |
1251 | pix = new QPixmap(*bevelFillPix); | 1251 | pix = new QPixmap(*bevelFillPix); |
1252 | adjustHSV(*pix, h, s, v); | 1252 | adjustHSV(*pix, h, s, v); |
1253 | bevelFillDict.insert(c.rgb(), pix); | 1253 | bevelFillDict.insert(c.rgb(), pix); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1256 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1257 | } | 1257 | } |
1258 | else{ | 1258 | else{ |
1259 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1259 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1260 | highlightWidget == p->device() ? g.button().light(110) : | 1260 | highlightWidget == p->device() ? g.button().light(110) : |
1261 | g.background(), g.background()); | 1261 | g.background(), g.background()); |
1262 | } | 1262 | } |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1265 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1266 | { | 1266 | { |
1267 | QRect r = btn->rect(); | 1267 | QRect r = btn->rect(); |
1268 | bool sunken = btn->isOn() || btn->isDown(); | 1268 | bool sunken = btn->isOn() || btn->isDown(); |
1269 | QColorGroup g = btn->colorGroup(); | 1269 | QColorGroup g = btn->colorGroup(); |
1270 | 1270 | ||
1271 | 1271 | ||
1272 | //int dw = buttonDefaultIndicatorWidth(); | 1272 | //int dw = buttonDefaultIndicatorWidth(); |
1273 | if(btn->hasFocus() || btn->isDefault()){ | 1273 | if(btn->hasFocus() || btn->isDefault()){ |
1274 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 1274 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
1275 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1275 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1276 | if(!pix){ | 1276 | if(!pix){ |
1277 | int h, s, v; | 1277 | int h, s, v; |
1278 | c.hsv(&h, &s, &v); | 1278 | c.hsv(&h, &s, &v); |
1279 | pix = new QPixmap(*bevelFillPix); | 1279 | pix = new QPixmap(*bevelFillPix); |
1280 | adjustHSV(*pix, h, s, v); | 1280 | adjustHSV(*pix, h, s, v); |
1281 | bevelFillDict.insert(c.rgb(), pix); | 1281 | bevelFillDict.insert(c.rgb(), pix); |
1282 | } | 1282 | } |
1283 | p->setPen(c.dark(150)); | 1283 | p->setPen(c.dark(150)); |
1284 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1284 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1285 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1285 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1286 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1286 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1287 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1287 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1288 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1288 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | QColor newColor = btn == highlightWidget || sunken ? | 1291 | QColor newColor = btn == highlightWidget || sunken ? |
1292 | g.button().light(120) : g.button(); | 1292 | g.button().light(120) : g.button(); |
1293 | 1293 | ||
1294 | drawRoundButton(p, newColor, g.background(), | 1294 | drawRoundButton(p, newColor, g.background(), |
1295 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), | 1295 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), |
1296 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), | 1296 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), |
1297 | btn->autoMask()); | 1297 | btn->autoMask()); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) | 1300 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) |
1301 | { | 1301 | { |
1302 | int x1, y1, x2, y2, w, h; | 1302 | int x1, y1, x2, y2, w, h; |
1303 | btn->rect().coords(&x1, &y1, &x2, &y2); | 1303 | btn->rect().coords(&x1, &y1, &x2, &y2); |
1304 | w = btn->width(); | 1304 | w = btn->width(); |
1305 | h = btn->height(); | 1305 | h = btn->height(); |
1306 | 1306 | ||
1307 | bool act = btn->isOn() || btn->isDown(); | 1307 | bool act = btn->isOn() || btn->isDown(); |
1308 | if(act){ | 1308 | if(act){ |
1309 | ++x1, ++y1; | 1309 | ++x1, ++y1; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | // Draw iconset first, if any | 1312 | // Draw iconset first, if any |
1313 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) | 1313 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) |
1314 | { | 1314 | { |
1315 | QIconSet::Mode mode = btn->isEnabled() | 1315 | QIconSet::Mode mode = btn->isEnabled() |
1316 | ? QIconSet::Normal : QIconSet::Disabled; | 1316 | ? QIconSet::Normal : QIconSet::Disabled; |
1317 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1317 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1318 | mode = QIconSet::Active; | 1318 | mode = QIconSet::Active; |
1319 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 1319 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
1320 | int pixw = pixmap.width(); | 1320 | int pixw = pixmap.width(); |
1321 | int pixh = pixmap.height(); | 1321 | int pixh = pixmap.height(); |
1322 | 1322 | ||
1323 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); | 1323 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); |
1324 | x1 += pixw + 8; | 1324 | x1 += pixw + 8; |
1325 | w -= pixw + 8; | 1325 | w -= pixw + 8; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | if(act){ | 1328 | if(act){ |
1329 | QFont font = btn->font(); | 1329 | QFont font = btn->font(); |
1330 | font.setBold(true); | 1330 | font.setBold(true); |
1331 | p->setFont(font); | 1331 | p->setFont(font); |
1332 | QColor shadow(btn->colorGroup().button().dark(130)); | 1332 | QColor shadow(btn->colorGroup().button().dark(130)); |
1333 | drawItem( p, x1+1, y1+1, w, h, | 1333 | drawItem( p, x1+1, y1+1, w, h, |
1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1335 | btn->pixmap(), btn->text(), -1, | 1335 | btn->pixmap(), btn->text(), -1, |
1336 | &shadow); | 1336 | &shadow); |
1337 | 1337 | ||
1338 | drawItem( p, x1, y1, w, h, | 1338 | drawItem( p, x1, y1, w, h, |
1339 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1339 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1340 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); | 1340 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); |
1341 | } | 1341 | } |
1342 | else{ | 1342 | else{ |
1343 | /* Too blurry | 1343 | /* Too blurry |
1344 | drawItem( p, x1+1, y1+1, w, h, | 1344 | drawItem( p, x1+1, y1+1, w, h, |
1345 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1345 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1346 | btn->pixmap(), btn->text(), -1, | 1346 | btn->pixmap(), btn->text(), -1, |
1347 | &btn->colorGroup().button().dark(115)); | 1347 | &btn->colorGroup().button().dark(115)); |
1348 | */ | 1348 | */ |
1349 | drawItem( p, x1, y1, w, h, | 1349 | drawItem( p, x1, y1, w, h, |
1350 | AlignCenter | ShowPrefix, | 1350 | AlignCenter | ShowPrefix, |
1351 | btn->colorGroup(), btn->isEnabled(), | 1351 | btn->colorGroup(), btn->isEnabled(), |
1352 | btn->pixmap(), btn->text(), -1, | 1352 | btn->pixmap(), btn->text(), -1, |
1353 | &btn->colorGroup().buttonText()); | 1353 | &btn->colorGroup().buttonText()); |
1354 | } | 1354 | } |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) | 1357 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) |
1358 | { | 1358 | { |
1359 | int x2 = x+w-1; | 1359 | int x2 = x+w-1; |
1360 | int y2 = y+h-1; | 1360 | int y2 = y+h-1; |
1361 | 1361 | ||
1362 | p->setPen(Qt::color1); | 1362 | p->setPen(Qt::color1); |
1363 | p->fillRect(x, y, w, h, Qt::color0); | 1363 | p->fillRect(x, y, w, h, Qt::color0); |
1364 | if(w < 21 || h < 21){ | 1364 | if(w < 21 || h < 21){ |
1365 | // outer rect | 1365 | // outer rect |
1366 | p->drawLine(x, y+2, x, y2-2); // l | 1366 | p->drawLine(x, y+2, x, y2-2); // l |
1367 | p->drawLine(x2, y+2, x2, y2-2); // r | 1367 | p->drawLine(x2, y+2, x2, y2-2); // r |
1368 | p->drawLine(x+2, y, x2-2, y); // t | 1368 | p->drawLine(x+2, y, x2-2, y); // t |
1369 | p->drawLine(x+2, y2, x2-2, y2); // b | 1369 | p->drawLine(x+2, y2, x2-2, y2); // b |
1370 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line | 1370 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line |
1371 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line | 1371 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line |
1372 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); | 1372 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); |
1373 | } | 1373 | } |
1374 | else{ | 1374 | else{ |
1375 | int x2 = x+w-1; | 1375 | int x2 = x+w-1; |
1376 | int y2 = y+h-1; | 1376 | int y2 = y+h-1; |
1377 | int bx2 = htmlBtnMaskBmp.width()-1; | 1377 | int bx2 = htmlBtnMaskBmp.width()-1; |
1378 | int by2 = htmlBtnMaskBmp.height()-1; | 1378 | int by2 = htmlBtnMaskBmp.height()-1; |
1379 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl | 1379 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl |
1380 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr | 1380 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr |
1381 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl | 1381 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl |
1382 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br | 1382 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br |
1383 | // fills | 1383 | // fills |
1384 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top | 1384 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top |
1385 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1385 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1386 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle | 1386 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, | 1390 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, |
1391 | const QColorGroup &g, bool sunken, | 1391 | const QColorGroup &g, bool sunken, |
1392 | const QBrush */*fill*/) | 1392 | const QBrush */*fill*/) |
1393 | { | 1393 | { |
1394 | if(currentHeader && p->device() == currentHeader){ | 1394 | if(currentHeader && p->device() == currentHeader){ |
1395 | int id = currentHeader->sectionAt(x); | 1395 | int id = currentHeader->sectionAt(x); |
1396 | bool isHeaderHover = id != -1 && id == headerHoverID; | 1396 | bool isHeaderHover = id != -1 && id == headerHoverID; |
1397 | drawClearBevel(p, x, y, w, h, sunken ? | 1397 | drawClearBevel(p, x, y, w, h, sunken ? |
1398 | g.button() : isHeaderHover ? g.button().light(110) : | 1398 | g.button() : isHeaderHover ? g.button().light(110) : |
1399 | g.background(), g.background()); | 1399 | g.background(), g.background()); |
1400 | } | 1400 | } |
1401 | else | 1401 | else |
1402 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), | 1402 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), |
1403 | g.background()); | 1403 | g.background()); |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) | 1406 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) |
1407 | { | 1407 | { |
1408 | return(QRect(x+5, y+5, w-10, h-10)); | 1408 | return(QRect(x+5, y+5, w-10, h-10)); |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | 1411 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, |
1412 | const QColorGroup &g, bool sunken, | 1412 | const QColorGroup &g, bool sunken, |
1413 | bool edit, bool, const QBrush *) | 1413 | bool edit, bool, const QBrush *) |
1414 | { | 1414 | { |
1415 | bool isHover = highlightWidget == painter->device(); | 1415 | bool isHover = highlightWidget == painter->device(); |
1416 | bool isMasked = false; | 1416 | bool isMasked = false; |
1417 | if(painter->device()->devType() == QInternal::Widget) | 1417 | if(painter->device()->devType() == QInternal::Widget) |
1418 | isMasked = ((QWidget*)painter->device())->autoMask(); | 1418 | isMasked = ((QWidget*)painter->device())->autoMask(); |
1419 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap | 1419 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap |
1420 | QPixmap tmpPix(w, h); | 1420 | QPixmap tmpPix(w, h); |
1421 | QPainter p(&tmpPix); | 1421 | QPainter p(&tmpPix); |
1422 | 1422 | ||
1423 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, | 1423 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, |
1424 | sunken, false, isMasked); | 1424 | sunken, false, isMasked); |
1425 | if(!isHover){ | 1425 | if(!isHover){ |
1426 | p.setClipRect(0, 0, w-17, h); | 1426 | p.setClipRect(0, 0, w-17, h); |
1427 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, | 1427 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, |
1428 | sunken, false, isMasked); | 1428 | sunken, false, isMasked); |
1429 | } | 1429 | } |
1430 | p.end(); | 1430 | p.end(); |
1431 | int x2 = x+w-1; | 1431 | int x2 = x+w-1; |
1432 | int y2 = y+h-1; | 1432 | int y2 = y+h-1; |
1433 | int bx2 = btnMaskBmp.width()-1; | 1433 | int bx2 = btnMaskBmp.width()-1; |
1434 | int by2 = btnMaskBmp.height()-1; | 1434 | int by2 = btnMaskBmp.height()-1; |
1435 | QBitmap btnMask(w, h); | 1435 | QBitmap btnMask(w, h); |
1436 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 1436 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
1437 | p.begin(&btnMask); | 1437 | p.begin(&btnMask); |
1438 | p.fillRect(0, 0, w, h, Qt::color0); | 1438 | p.fillRect(0, 0, w, h, Qt::color0); |
1439 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl | 1439 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl |
1440 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr | 1440 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr |
1441 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl | 1441 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl |
1442 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br | 1442 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br |
1443 | // fills | 1443 | // fills |
1444 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 1444 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
1445 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1445 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1446 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 1446 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
1447 | p.end(); | 1447 | p.end(); |
1448 | tmpPix.setMask(btnMask); | 1448 | tmpPix.setMask(btnMask); |
1449 | 1449 | ||
1450 | painter->drawPixmap(x, y, tmpPix); | 1450 | painter->drawPixmap(x, y, tmpPix); |
1451 | 1451 | ||
1452 | painter->setPen(g.button().dark(120)); | 1452 | painter->setPen(g.button().dark(120)); |
1453 | painter->drawLine(x2-16, y+1, x2-16, y2-1); | 1453 | painter->drawLine(x2-16, y+1, x2-16, y2-1); |
1454 | 1454 | ||
1455 | if(edit){ | 1455 | if(edit){ |
1456 | painter->setPen(g.mid()); | 1456 | painter->setPen(g.mid()); |
1457 | painter->drawRect(x+8, y+2, w-25, h-4); | 1457 | painter->drawRect(x+8, y+2, w-25, h-4); |
1458 | } | 1458 | } |
1459 | int arrow_h = h / 3; | 1459 | int arrow_h = h / 3; |
1460 | int arrow_w = arrow_h; | 1460 | int arrow_w = arrow_h; |
1461 | int arrow_x = w - arrow_w - 6; | 1461 | int arrow_x = w - arrow_w - 6; |
1462 | int arrow_y = (h - arrow_h) / 2; | 1462 | int arrow_y = (h - arrow_h) / 2; |
1463 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); | 1463 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) | 1466 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) |
1467 | { | 1467 | { |
1468 | drawButtonMask(p, x, y, w, h); | 1468 | drawButtonMask(p, x, y, w, h); |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) | 1471 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) |
1472 | { | 1472 | { |
1473 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); | 1473 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); |
1474 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); | 1474 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) | 1477 | QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) |
1478 | { | 1478 | { |
1479 | return(QRect(x+5, y+3, w-(h/3)-13, h-5)); | 1479 | return(QRect(x+5, y+3, w-(h/3)-13, h-5)); |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | 1482 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, |
1483 | int sliderStart, uint controls, | 1483 | int sliderStart, uint controls, |
1484 | uint activeControl) | 1484 | uint activeControl) |
1485 | { | 1485 | { |
1486 | bool isHover = highlightWidget == p->device(); | 1486 | bool isHover = highlightWidget == p->device(); |
1487 | int sliderMin, sliderMax, sliderLength, buttonDim; | 1487 | int sliderMin, sliderMax, sliderLength, buttonDim; |
1488 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1488 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1489 | 1489 | ||
1490 | if (sliderStart > sliderMax) | 1490 | if (sliderStart > sliderMax) |
1491 | sliderStart = sliderMax; | 1491 | sliderStart = sliderMax; |
1492 | 1492 | ||
1493 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1493 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1494 | QColorGroup g = sb->colorGroup(); | 1494 | QColorGroup g = sb->colorGroup(); |
1495 | QRect addB, subHC, subB; | 1495 | QRect addB, subHC, subB; |
1496 | QRect addPageR, subPageR, sliderR; | 1496 | QRect addPageR, subPageR, sliderR; |
1497 | int addX, addY, subX, subY; | 1497 | int addX, addY, subX, subY; |
1498 | int len = horiz ? sb->width() : sb->height(); | 1498 | int len = horiz ? sb->width() : sb->height(); |
1499 | int extent = horiz ? sb->height() : sb->width(); | 1499 | int extent = horiz ? sb->height() : sb->width(); |
1500 | 1500 | ||
1501 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar | 1501 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar |
1502 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. | 1502 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. |
1503 | bool brokenApp; | 1503 | bool brokenApp; |
1504 | if(extent == 16) | 1504 | if(extent == 16) |
1505 | brokenApp = true; | 1505 | brokenApp = true; |
1506 | else | 1506 | else |
1507 | brokenApp = false; | 1507 | brokenApp = false; |
1508 | 1508 | ||
1509 | if (horiz) { | 1509 | if (horiz) { |
1510 | subY = addY = ( extent - buttonDim ) / 2; | 1510 | subY = addY = ( extent - buttonDim ) / 2; |
1511 | subX = 0; | 1511 | subX = 0; |
1512 | addX = len - buttonDim; | 1512 | addX = len - buttonDim; |
1513 | if(sbBuffer.size() != sb->size()) | 1513 | if(sbBuffer.size() != sb->size()) |
1514 | sbBuffer.resize(sb->size()); | 1514 | sbBuffer.resize(sb->size()); |
1515 | } | 1515 | } |
1516 | else { | 1516 | else { |
1517 | subX = addX = ( extent - buttonDim ) / 2; | 1517 | subX = addX = ( extent - buttonDim ) / 2; |
1518 | subY = 0; | 1518 | subY = 0; |
1519 | addY = len - buttonDim; | 1519 | addY = len - buttonDim; |
1520 | if(sbBuffer.size() != sb->size()) | 1520 | if(sbBuffer.size() != sb->size()) |
1521 | sbBuffer.resize(sb->size()); | 1521 | sbBuffer.resize(sb->size()); |
1522 | } | 1522 | } |
1523 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); | 1523 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); |
1524 | addB.setRect( addX,addY,buttonDim,buttonDim ); | 1524 | addB.setRect( addX,addY,buttonDim,buttonDim ); |
1525 | if(horiz) | 1525 | if(horiz) |
1526 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); | 1526 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); |
1527 | else | 1527 | else |
1528 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); | 1528 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); |
1529 | 1529 | ||
1530 | int sliderEnd = sliderStart + sliderLength; | 1530 | int sliderEnd = sliderStart + sliderLength; |
1531 | int sliderW = extent; | 1531 | int sliderW = extent; |
1532 | 1532 | ||
1533 | if (horiz) { | 1533 | if (horiz) { |
1534 | subPageR.setRect( subB.right() + 1, 0, | 1534 | subPageR.setRect( subB.right() + 1, 0, |
1535 | sliderStart - subB.right() - 1 , sliderW ); | 1535 | sliderStart - subB.right() - 1 , sliderW ); |
1536 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); | 1536 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); |
1537 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); | 1537 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); |
1538 | } | 1538 | } |
1539 | else { | 1539 | else { |
1540 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, | 1540 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, |
1541 | sliderStart - subB.bottom() - 1 ); | 1541 | sliderStart - subB.bottom() - 1 ); |
1542 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); | 1542 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); |
1543 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); | 1543 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); |
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | bool maxed = sb->maxValue() == sb->minValue(); | 1546 | bool maxed = sb->maxValue() == sb->minValue(); |
1547 | 1547 | ||
1548 | QPainter painter; | 1548 | QPainter painter; |
1549 | if(!horiz){ | 1549 | if(!horiz){ |
1550 | painter.begin(&sbBuffer); | 1550 | painter.begin(&sbBuffer); |
1551 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); | 1551 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); |
1552 | if(sliderR.height() >= 8){ | 1552 | if(sliderR.height() >= 8){ |
1553 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, | 1553 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, |
1554 | 13, 8); | 1554 | 13, 8); |
1555 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); | 1555 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); |
1556 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, | 1556 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, |
1557 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); | 1557 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); |
1558 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, | 1558 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, |
1559 | 0, 0, 13, 8); | 1559 | 0, 0, 13, 8); |
1560 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); | 1560 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); |
1561 | } | 1561 | } |
1562 | else{ | 1562 | else{ |
1563 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), | 1563 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), |
1564 | *getPixmap(VSBSliderMidBg)); | 1564 | *getPixmap(VSBSliderMidBg)); |
1565 | painter.setPen(g.background().dark(210)); | 1565 | painter.setPen(g.background().dark(210)); |
1566 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); | 1566 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); |
1567 | painter.setPen(g.mid()); | 1567 | painter.setPen(g.mid()); |
1568 | painter.drawPoint(bgR.x()+1, bgR.y()); | 1568 | painter.drawPoint(bgR.x()+1, bgR.y()); |
1569 | painter.drawPoint(bgR.x()+13, bgR.y()); | 1569 | painter.drawPoint(bgR.x()+13, bgR.y()); |
1570 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); | 1570 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); |
1571 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); | 1571 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); |
1572 | } | 1572 | } |
1573 | if(controls & Slider){ | 1573 | if(controls & Slider){ |
1574 | if(sliderR.height() >= 16){ | 1574 | if(sliderR.height() >= 16){ |
1575 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), | 1575 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), |
1576 | isHover ? *getPixmap(VSBSliderTopHover): | 1576 | isHover ? *getPixmap(VSBSliderTopHover): |
1577 | *getPixmap(VSBSliderTop)); | 1577 | *getPixmap(VSBSliderTop)); |
1578 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, | 1578 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, |
1579 | sliderR.height()-16, isHover ? | 1579 | sliderR.height()-16, isHover ? |
1580 | *getPixmap(VSBSliderMidHover) : | 1580 | *getPixmap(VSBSliderMidHover) : |
1581 | *getPixmap(VSBSliderMid)); | 1581 | *getPixmap(VSBSliderMid)); |
1582 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, | 1582 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, |
1583 | isHover ? *getPixmap(VSBSliderBtmHover) : | 1583 | isHover ? *getPixmap(VSBSliderBtmHover) : |
1584 | *getPixmap(VSBSliderBtm)); | 1584 | *getPixmap(VSBSliderBtm)); |
1585 | } | 1585 | } |
1586 | else if(sliderR.height() >= 8){ | 1586 | else if(sliderR.height() >= 8){ |
1587 | int m = sliderR.height()/2; | 1587 | int m = sliderR.height()/2; |
1588 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), | 1588 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), |
1589 | isHover ? *getPixmap(VSBSliderTopHover): | 1589 | isHover ? *getPixmap(VSBSliderTopHover): |
1590 | *getPixmap(VSBSliderTop), 0, 0, 13, m); | 1590 | *getPixmap(VSBSliderTop), 0, 0, 13, m); |
1591 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, | 1591 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, |
1592 | isHover ? *getPixmap(VSBSliderBtmHover): | 1592 | isHover ? *getPixmap(VSBSliderBtmHover): |
1593 | *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); | 1593 | *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); |
1594 | } | 1594 | } |
1595 | else{ | 1595 | else{ |
1596 | painter.setPen(g.button().dark(210)); | 1596 | painter.setPen(g.button().dark(210)); |
1597 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), | 1597 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), |
1598 | 13, sliderR.height()); | 1598 | 13, sliderR.height()); |
1599 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, | 1599 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, |
1600 | 11, sliderR.height()-2, | 1600 | 11, sliderR.height()-2, |
1601 | isHover ? *getPixmap(VSBSliderMidHover) : | 1601 | isHover ? *getPixmap(VSBSliderMidHover) : |
1602 | *getPixmap(VSBSliderMid), 1, 0); | 1602 | *getPixmap(VSBSliderMid), 1, 0); |
1603 | } | 1603 | } |
1604 | } | 1604 | } |
1605 | painter.setPen(g.mid()); | 1605 | painter.setPen(g.mid()); |
1606 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); | 1606 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); |
1607 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); | 1607 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); |
1608 | if(brokenApp && (controls & Slider)){ | 1608 | if(brokenApp && (controls & Slider)){ |
1609 | painter.setPen(g.background()); | 1609 | painter.setPen(g.background()); |
1610 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, | 1610 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, |
1611 | bgR.bottom()); | 1611 | bgR.bottom()); |
1612 | } | 1612 | } |
1613 | painter.end(); | 1613 | painter.end(); |
1614 | } | 1614 | } |
1615 | else{ | 1615 | else{ |
1616 | painter.begin(&sbBuffer); | 1616 | painter.begin(&sbBuffer); |
1617 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); | 1617 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); |
1618 | if(sliderR.width() >= 8){ | 1618 | if(sliderR.width() >= 8){ |
1619 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, | 1619 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, |
1620 | 8, 13); | 1620 | 8, 13); |
1621 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); | 1621 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); |
1622 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, | 1622 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, |
1623 | 13, *getPixmap(HSBSliderMidBg)); | 1623 | 13, *getPixmap(HSBSliderMidBg)); |
1624 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, | 1624 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, |
1625 | 0, 0, 8, 13); | 1625 | 0, 0, 8, 13); |
1626 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); | 1626 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); |
1627 | } | 1627 | } |
1628 | else{ | 1628 | else{ |
1629 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, | 1629 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, |
1630 | *getPixmap(HSBSliderMidBg)); | 1630 | *getPixmap(HSBSliderMidBg)); |
1631 | painter.setPen(g.background().dark(210)); | 1631 | painter.setPen(g.background().dark(210)); |
1632 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); | 1632 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); |
1633 | painter.setPen(g.mid()); | 1633 | painter.setPen(g.mid()); |
1634 | painter.drawPoint(bgR.x(), bgR.y()+1); | 1634 | painter.drawPoint(bgR.x(), bgR.y()+1); |
1635 | painter.drawPoint(bgR.x(), bgR.bottom()-1); | 1635 | painter.drawPoint(bgR.x(), bgR.bottom()-1); |
1636 | painter.drawPoint(bgR.right()-1, bgR.y()+1); | 1636 | painter.drawPoint(bgR.right()-1, bgR.y()+1); |
1637 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); | 1637 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); |
1638 | } | 1638 | } |
1639 | if(controls & Slider){ | 1639 | if(controls & Slider){ |
1640 | if(sliderR.width() >= 16){ | 1640 | if(sliderR.width() >= 16){ |
1641 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1641 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1642 | isHover ? *getPixmap(HSBSliderTopHover) : | 1642 | isHover ? *getPixmap(HSBSliderTopHover) : |
1643 | *getPixmap(HSBSliderTop)); | 1643 | *getPixmap(HSBSliderTop)); |
1644 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, | 1644 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, |
1645 | 13, isHover ? *getPixmap(HSBSliderMidHover) : | 1645 | 13, isHover ? *getPixmap(HSBSliderMidHover) : |
1646 | *getPixmap(HSBSliderMid)); | 1646 | *getPixmap(HSBSliderMid)); |
1647 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? | 1647 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? |
1648 | *getPixmap(HSBSliderBtmHover) : | 1648 | *getPixmap(HSBSliderBtmHover) : |
1649 | *getPixmap(HSBSliderBtm)); | 1649 | *getPixmap(HSBSliderBtm)); |
1650 | } | 1650 | } |
1651 | else if(sliderR.width() >= 8){ | 1651 | else if(sliderR.width() >= 8){ |
1652 | int m = sliderR.width()/2; | 1652 | int m = sliderR.width()/2; |
1653 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1653 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1654 | isHover ? *getPixmap(HSBSliderTopHover) : | 1654 | isHover ? *getPixmap(HSBSliderTopHover) : |
1655 | *getPixmap(HSBSliderTop), 0, 0, m, 13); | 1655 | *getPixmap(HSBSliderTop), 0, 0, m, 13); |
1656 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? | 1656 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? |
1657 | *getPixmap(HSBSliderBtmHover) : | 1657 | *getPixmap(HSBSliderBtmHover) : |
1658 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); | 1658 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); |
1659 | } | 1659 | } |
1660 | else{ | 1660 | else{ |
1661 | painter.setPen(g.button().dark(210)); | 1661 | painter.setPen(g.button().dark(210)); |
1662 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, | 1662 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, |
1663 | sliderR.width(), 13); | 1663 | sliderR.width(), 13); |
1664 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, | 1664 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, |
1665 | sliderR.width()-2, 11, isHover ? | 1665 | sliderR.width()-2, 11, isHover ? |
1666 | *getPixmap(HSBSliderMidHover) : | 1666 | *getPixmap(HSBSliderMidHover) : |
1667 | *getPixmap(HSBSliderMid), 0, 1); | 1667 | *getPixmap(HSBSliderMid), 0, 1); |
1668 | } | 1668 | } |
1669 | } | 1669 | } |
1670 | painter.setPen(g.mid()); | 1670 | painter.setPen(g.mid()); |
1671 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); | 1671 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); |
1672 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); | 1672 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); |
1673 | if(brokenApp && (controls & Slider)){ | 1673 | if(brokenApp && (controls & Slider)){ |
1674 | painter.setPen(g.background()); | 1674 | painter.setPen(g.background()); |
1675 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), | 1675 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), |
1676 | bgR.bottom()-1); | 1676 | bgR.bottom()-1); |
1677 | } | 1677 | } |
1678 | painter.end(); | 1678 | painter.end(); |
1679 | } | 1679 | } |
1680 | 1680 | ||
1681 | if ( controls & AddLine ) { | 1681 | if ( controls & AddLine ) { |
1682 | drawSBButton(p, addB, g, activeControl == AddLine); | 1682 | drawSBButton(p, addB, g, activeControl == AddLine); |
1683 | drawArrow( p, horiz ? RightArrow : DownArrow, | 1683 | drawArrow( p, horiz ? RightArrow : DownArrow, |
1684 | false, addB.x()+4, addB.y()+4, | 1684 | false, addB.x()+4, addB.y()+4, |
1685 | addB.width()-8, addB.height()-8, g, !maxed); | 1685 | addB.width()-8, addB.height()-8, g, !maxed); |
1686 | } | 1686 | } |
1687 | if ( controls & SubLine ) { | 1687 | if ( controls & SubLine ) { |
1688 | // drawSBButton(p, subB, g, activeControl == SubLine); | 1688 | // drawSBButton(p, subB, g, activeControl == SubLine); |
1689 | // drawArrow( p, horiz ? LeftArrow : UpArrow, | 1689 | // drawArrow( p, horiz ? LeftArrow : UpArrow, |
1690 | // false, subB.x()+4, subB.y()+4, | 1690 | // false, subB.x()+4, subB.y()+4, |
1691 | // subB.width()-8, subB.height()-8, g, !maxed); | 1691 | // subB.width()-8, subB.height()-8, g, !maxed); |
1692 | drawSBButton(p, subHC, g, activeControl == SubLine); | 1692 | drawSBButton(p, subHC, g, activeControl == SubLine); |
1693 | drawArrow( p, horiz ? LeftArrow : UpArrow, | 1693 | drawArrow( p, horiz ? LeftArrow : UpArrow, |
1694 | false, subHC.x()+4, subHC.y()+4, | 1694 | false, subHC.x()+4, subHC.y()+4, |
1695 | subHC.width()-8, subHC.height()-8, g, !maxed); | 1695 | subHC.width()-8, subHC.height()-8, g, !maxed); |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | if(controls & AddPage){ | 1698 | if(controls & AddPage){ |
1699 | if(addPageR.width()){ | 1699 | if(addPageR.width()){ |
1700 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, | 1700 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, |
1701 | addPageR.x(), addPageR.y(), addPageR.width(), | 1701 | addPageR.x(), addPageR.y(), addPageR.width(), |
1702 | addPageR.height()); | 1702 | addPageR.height()); |
1703 | } | 1703 | } |
1704 | } | 1704 | } |
1705 | if(controls & SubPage){ | 1705 | if(controls & SubPage){ |
1706 | if(subPageR.height()){ | 1706 | if(subPageR.height()){ |
1707 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, | 1707 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, |
1708 | subPageR.x(), subPageR.y(), subPageR.width(), | 1708 | subPageR.x(), subPageR.y(), subPageR.width(), |
1709 | subPageR.height()); | 1709 | subPageR.height()); |
1710 | } | 1710 | } |
1711 | } | 1711 | } |
1712 | if ( controls & Slider ) { | 1712 | if ( controls & Slider ) { |
1713 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, | 1713 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, |
1714 | sliderR.x(), sliderR.y(), sliderR.width(), | 1714 | sliderR.x(), sliderR.y(), sliderR.width(), |
1715 | sliderR.height()); | 1715 | sliderR.height()); |
1716 | } | 1716 | } |
1717 | } | 1717 | } |
1718 | 1718 | ||
1719 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, | 1719 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, |
1720 | bool down, bool /*fast*/) | 1720 | bool down, bool /*fast*/) |
1721 | { | 1721 | { |
1722 | p->setPen(g.mid()); | 1722 | p->setPen(g.mid()); |
1723 | p->drawRect(r); | 1723 | p->drawRect(r); |
1724 | QColor c(down ? g.button() : g.background()); | 1724 | QColor c(down ? g.button() : g.background()); |
1725 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1725 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1726 | if(!pix){ | 1726 | if(!pix){ |
1727 | int h, s, v; | 1727 | int h, s, v; |
1728 | c.hsv(&h, &s, &v); | 1728 | c.hsv(&h, &s, &v); |
1729 | pix = new QPixmap(*bevelFillPix); | 1729 | pix = new QPixmap(*bevelFillPix); |
1730 | adjustHSV(*pix, h, s, v); | 1730 | adjustHSV(*pix, h, s, v); |
1731 | bevelFillDict.insert(c.rgb(), pix); | 1731 | bevelFillDict.insert(c.rgb(), pix); |
1732 | } | 1732 | } |
1733 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1733 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1734 | 1734 | ||
1735 | } | 1735 | } |
1736 | 1736 | ||
1737 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, | 1737 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, |
1738 | bool horiz) | 1738 | bool horiz) |
1739 | { | 1739 | { |
1740 | if(horiz){ | 1740 | if(horiz){ |
1741 | if(r.width() >= 15){ | 1741 | if(r.width() >= 15){ |
1742 | int y = r.y()+3; | 1742 | int y = r.y()+3; |
1743 | int x = r.x() + (r.width()-7)/2; | 1743 | int x = r.x() + (r.width()-7)/2; |
1744 | int y2 = r.bottom()-3; | 1744 | int y2 = r.bottom()-3; |
1745 | p->setPen(g.light()); | 1745 | p->setPen(g.light()); |
1746 | p->drawLine(x, y, x, y2); | 1746 | p->drawLine(x, y, x, y2); |
1747 | p->drawLine(x+3, y, x+3, y2); | 1747 | p->drawLine(x+3, y, x+3, y2); |
1748 | p->drawLine(x+6, y, x+6, y2); | 1748 | p->drawLine(x+6, y, x+6, y2); |
1749 | 1749 | ||
1750 | p->setPen(g.mid()); | 1750 | p->setPen(g.mid()); |
1751 | p->drawLine(x+1, y, x+1, y2); | 1751 | p->drawLine(x+1, y, x+1, y2); |
1752 | p->drawLine(x+4, y, x+4, y2); | 1752 | p->drawLine(x+4, y, x+4, y2); |
1753 | p->drawLine(x+7, y, x+7, y2); | 1753 | p->drawLine(x+7, y, x+7, y2); |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | else{ | 1756 | else{ |
1757 | if(r.height() >= 15){ | 1757 | if(r.height() >= 15){ |
1758 | int x = r.x()+3; | 1758 | int x = r.x()+3; |
1759 | int y = r.y() + (r.height()-7)/2; | 1759 | int y = r.y() + (r.height()-7)/2; |
1760 | int x2 = r.right()-3; | 1760 | int x2 = r.right()-3; |
1761 | p->setPen(g.light()); | 1761 | p->setPen(g.light()); |
1762 | p->drawLine(x, y, x2, y); | 1762 | p->drawLine(x, y, x2, y); |
1763 | p->drawLine(x, y+3, x2, y+3); | 1763 | p->drawLine(x, y+3, x2, y+3); |
1764 | p->drawLine(x, y+6, x2, y+6); | 1764 | p->drawLine(x, y+6, x2, y+6); |
1765 | 1765 | ||
1766 | p->setPen(g.mid()); | 1766 | p->setPen(g.mid()); |
1767 | p->drawLine(x, y+1, x2, y+1); | 1767 | p->drawLine(x, y+1, x2, y+1); |
1768 | p->drawLine(x, y+4, x2, y+4); | 1768 | p->drawLine(x, y+4, x2, y+4); |
1769 | p->drawLine(x, y+7, x2, y+7); | 1769 | p->drawLine(x, y+7, x2, y+7); |
1770 | } | 1770 | } |
1771 | } | 1771 | } |
1772 | 1772 | ||
1773 | } | 1773 | } |
1774 | 1774 | ||
1775 | 1775 | ||
1776 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, | 1776 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, |
1777 | int &sliderMax, int &sliderLength, | 1777 | int &sliderMax, int &sliderLength, |
1778 | int &buttonDim) | 1778 | int &buttonDim) |
1779 | { | 1779 | { |
1780 | 1780 | ||
1781 | int maxLength; | 1781 | int maxLength; |
1782 | int b = 0; | 1782 | int b = 0; |
1783 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1783 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1784 | int length = horiz ? sb->width() : sb->height(); | 1784 | int length = horiz ? sb->width() : sb->height(); |
1785 | int extent = horiz ? sb->height() : sb->width(); | 1785 | int extent = horiz ? sb->height() : sb->width(); |
1786 | 1786 | ||
1787 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) | 1787 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) |
1788 | buttonDim = extent - b*2; | 1788 | buttonDim = extent - b*2; |
1789 | else | 1789 | else |
1790 | buttonDim = ( length - b*2 )/2 - 1; | 1790 | buttonDim = ( length - b*2 )/2 - 1; |
1791 | 1791 | ||
1792 | sliderMin = b + 0; // buttonDim; | 1792 | sliderMin = b + 0; // buttonDim; |
1793 | maxLength = length - b*2 - buttonDim*2; // 3; | 1793 | maxLength = length - b*2 - buttonDim*2; // 3; |
1794 | 1794 | ||
1795 | if ( sb->maxValue() == sb->minValue() ) { | 1795 | if ( sb->maxValue() == sb->minValue() ) { |
1796 | sliderLength = maxLength; | 1796 | sliderLength = maxLength; |
1797 | } else { | 1797 | } else { |
1798 | sliderLength = (sb->pageStep()*maxLength)/ | 1798 | sliderLength = (sb->pageStep()*maxLength)/ |
1799 | (sb->maxValue()-sb->minValue()+sb->pageStep()); | 1799 | (sb->maxValue()-sb->minValue()+sb->pageStep()); |
1800 | uint range = sb->maxValue()-sb->minValue(); | 1800 | uint range = sb->maxValue()-sb->minValue(); |
1801 | if ( sliderLength < 9 || range > INT_MAX/2 ) | 1801 | if ( sliderLength < 9 || range > INT_MAX/2 ) |
1802 | sliderLength = 9; | 1802 | sliderLength = 9; |
1803 | if ( sliderLength > maxLength ) | 1803 | if ( sliderLength > maxLength ) |
1804 | sliderLength = maxLength; | 1804 | sliderLength = maxLength; |
1805 | } | 1805 | } |
1806 | sliderMax = sliderMin + maxLength - sliderLength; | 1806 | sliderMax = sliderMin + maxLength - sliderLength; |
1807 | 1807 | ||
1808 | } | 1808 | } |
1809 | 1809 | ||
1810 | QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, | 1810 | QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, |
1811 | int sliderStart, | 1811 | int sliderStart, |
1812 | const QPoint &p) | 1812 | const QPoint &p) |
1813 | { | 1813 | { |
1814 | if ( !sb->rect().contains( p ) ) | 1814 | if ( !sb->rect().contains( p ) ) |
1815 | return NoScroll; | 1815 | return NoScroll; |
1816 | int sliderMin, sliderMax, sliderLength, buttonDim, pos; | 1816 | int sliderMin, sliderMax, sliderLength, buttonDim, pos; |
1817 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1817 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1818 | pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); | 1818 | pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); |
1819 | if ( pos < sliderMin ) | 1819 | if ( pos < sliderMin ) |
1820 | return SubLine; | 1820 | return SubLine; |
1821 | if ( pos < sliderStart ) | 1821 | if ( pos < sliderStart ) |
1822 | return SubPage; | 1822 | return SubPage; |
1823 | if ( pos < sliderStart + sliderLength ) | 1823 | if ( pos < sliderStart + sliderLength ) |
1824 | return Slider; | 1824 | return Slider; |
1825 | if ( pos < sliderMax + sliderLength) | 1825 | if ( pos < sliderMax + sliderLength) |
1826 | return AddPage; | 1826 | return AddPage; |
1827 | if(pos > sliderMax + sliderLength + 16) | 1827 | if(pos > sliderMax + sliderLength + 16) |
1828 | return AddLine; | 1828 | return AddLine; |
1829 | 1829 | ||
1830 | return SubLine; | 1830 | return SubLine; |
1831 | } | 1831 | } |
1832 | 1832 | ||
1833 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 1833 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
1834 | 1834 | ||
1835 | 1835 | ||
1836 | QSize LiquidStyle::exclusiveIndicatorSize() const | 1836 | QSize LiquidStyle::exclusiveIndicatorSize() const |
1837 | { | 1837 | { |
1838 | return(QSize(16, 16)); | 1838 | return(QSize(16, 16)); |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, | 1841 | void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, |
1842 | int /*h*/, const QColorGroup &/*g*/, bool on, | 1842 | int /*h*/, const QColorGroup &/*g*/, bool on, |
1843 | bool down, bool) | 1843 | bool down, bool) |
1844 | { | 1844 | { |
1845 | bool isHover = highlightWidget == p->device(); | 1845 | bool isHover = highlightWidget == p->device(); |
1846 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget | 1846 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget |
1847 | && ((QWidget*)p->device())->autoMask(); | 1847 | && ((QWidget*)p->device())->autoMask(); |
1848 | 1848 | ||
1849 | if(isMasked){ | 1849 | if(isMasked){ |
1850 | if(on || down){ | 1850 | if(on || down){ |
1851 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : | 1851 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : |
1852 | *getPixmap(HTMLRadioDown)); | 1852 | *getPixmap(HTMLRadioDown)); |
1853 | } | 1853 | } |
1854 | else | 1854 | else |
1855 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : | 1855 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : |
1856 | *getPixmap(HTMLRadio)); | 1856 | *getPixmap(HTMLRadio)); |
1857 | 1857 | ||
1858 | } | 1858 | } |
1859 | else{ | 1859 | else{ |
1860 | if(on || down){ | 1860 | if(on || down){ |
1861 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : | 1861 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : |
1862 | *getPixmap(RadioOn)); | 1862 | *getPixmap(RadioOn)); |
1863 | } | 1863 | } |
1864 | else | 1864 | else |
1865 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : | 1865 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : |
1866 | *getPixmap(RadioOff)); | 1866 | *getPixmap(RadioOff)); |
1867 | } | 1867 | } |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, | 1870 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, |
1871 | int h, bool) | 1871 | int h, bool) |
1872 | { | 1872 | { |
1873 | p->fillRect(x, y, w, h, Qt::color0); | 1873 | p->fillRect(x, y, w, h, Qt::color0); |
1874 | p->setPen(Qt::color1); | 1874 | p->setPen(Qt::color1); |
1875 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); | 1875 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); |
1876 | } | 1876 | } |
1877 | 1877 | ||
1878 | 1878 | ||
1879 | QSize LiquidStyle::indicatorSize() const | 1879 | QSize LiquidStyle::indicatorSize() const |
1880 | { | 1880 | { |
1881 | return(QSize(20, 22)); | 1881 | return(QSize(20, 22)); |
1882 | } | 1882 | } |
1883 | 1883 | ||
1884 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1884 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
1885 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) | 1885 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) |
1886 | { | 1886 | { |
1887 | bool isHover = highlightWidget == p->device(); | 1887 | bool isHover = highlightWidget == p->device(); |
1888 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget | 1888 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget |
1889 | && ((QWidget*)p->device())->autoMask(); | 1889 | && ((QWidget*)p->device())->autoMask(); |
1890 | if(isMasked){ | 1890 | if(isMasked){ |
1891 | if(state != QButton::Off){ | 1891 | if(state != QButton::Off){ |
1892 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : | 1892 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : |
1893 | *getPixmap(HTMLCBDown)); | 1893 | *getPixmap(HTMLCBDown)); |
1894 | } | 1894 | } |
1895 | else | 1895 | else |
1896 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : | 1896 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : |
1897 | *getPixmap(HTMLCB)); | 1897 | *getPixmap(HTMLCB)); |
1898 | 1898 | ||
1899 | } | 1899 | } |
1900 | else{ | 1900 | else{ |
1901 | if(state != QButton::Off){ | 1901 | if(state != QButton::Off){ |
1902 | p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : | 1902 | p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : |
1903 | *getPixmap(CBDown)); | 1903 | *getPixmap(CBDown)); |
1904 | /* Todo - tristate | 1904 | /* Todo - tristate |
1905 | if(state == QButton::On){ | 1905 | if(state == QButton::On){ |
1906 | p->setPen(Qt::black); | 1906 | p->setPen(Qt::black); |
1907 | p->drawPixmap(3, 3, xBmp); | 1907 | p->drawPixmap(3, 3, xBmp); |
1908 | } | 1908 | } |
1909 | else{ | 1909 | else{ |
1910 | p->setPen(g.dark()); | 1910 | p->setPen(g.dark()); |
1911 | p->drawRect(x+2, y+2, w-4, h-4); | 1911 | p->drawRect(x+2, y+2, w-4, h-4); |
1912 | p->setPen(Qt::black); | 1912 | p->setPen(Qt::black); |
1913 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); | 1913 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); |
1914 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); | 1914 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); |
1915 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); | 1915 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); |
1916 | }*/ | 1916 | }*/ |
1917 | } | 1917 | } |
1918 | else | 1918 | else |
1919 | p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); | 1919 | p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); |
1920 | } | 1920 | } |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1923 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
1924 | int /*state*/) | 1924 | int /*state*/) |
1925 | { | 1925 | { |
1926 | // needed for some reason by KHtml, even tho it's all filled ;P | 1926 | // needed for some reason by KHtml, even tho it's all filled ;P |
1927 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); | 1927 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); |
1928 | 1928 | ||
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, | 1931 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, |
1932 | const QColorGroup &/*g*/, Orientation orient, | 1932 | const QColorGroup &/*g*/, Orientation orient, |
1933 | bool, bool) | 1933 | bool, bool) |
1934 | { | 1934 | { |
1935 | QWidget *parent = (QWidget *)p->device(); | 1935 | QWidget *parent = (QWidget *)p->device(); |
1936 | p->setBrushOrigin(parent->pos()); | 1936 | p->setBrushOrigin(parent->pos()); |
1937 | parent->erase(x, y, w, h); | 1937 | parent->erase(x, y, w, h); |
1938 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : | 1938 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : |
1939 | *getPixmap(VSlider)); | 1939 | *getPixmap(VSlider)); |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1942 | void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
1943 | Orientation orient, bool, bool) | 1943 | Orientation orient, bool, bool) |
1944 | { | 1944 | { |
1945 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : | 1945 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : |
1946 | *getPixmap(VSlider)->mask()); | 1946 | *getPixmap(VSlider)->mask()); |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | int LiquidStyle::sliderLength() const | 1949 | int LiquidStyle::sliderLength() const |
1950 | { | 1950 | { |
1951 | return(10); | 1951 | return(10); |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 1954 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
1955 | 1955 | ||
1956 | void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, | 1956 | void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, |
1957 | int y, int w, int h, const QColorGroup &g, | 1957 | int y, int w, int h, const QColorGroup &g, |
1958 | bool enabled, const QBrush *) | 1958 | bool enabled, const QBrush *) |
1959 | { | 1959 | { |
1960 | static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; | 1960 | static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; |
1961 | static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; | 1961 | static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; |
1962 | static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; | 1962 | static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; |
1963 | static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; | 1963 | static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; |
1964 | 1964 | ||
1965 | p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); | 1965 | p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); |
1966 | if(w > 8){ | 1966 | if(w > 8){ |
1967 | x = x + (w-8)/2; | 1967 | x = x + (w-8)/2; |
1968 | y = y + (h-8)/2; | 1968 | y = y + (h-8)/2; |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | QPointArray a; | 1971 | QPointArray a; |
1972 | switch(type){ | 1972 | switch(type){ |
1973 | case Qt::UpArrow: | 1973 | case Qt::UpArrow: |
1974 | a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); | 1974 | a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); |
1975 | break; | 1975 | break; |
1976 | case Qt::DownArrow: | 1976 | case Qt::DownArrow: |
1977 | a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); | 1977 | a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); |
1978 | break; | 1978 | break; |
1979 | case Qt::LeftArrow: | 1979 | case Qt::LeftArrow: |
1980 | a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); | 1980 | a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); |
1981 | break; | 1981 | break; |
1982 | default: | 1982 | default: |
1983 | a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); | 1983 | a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); |
1984 | break; | 1984 | break; |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | a.translate(x, y); | 1987 | a.translate(x, y); |
1988 | p->drawLineSegments(a); | 1988 | p->drawLineSegments(a); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | 1991 | ||
1992 | void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, | 1992 | void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, |
1993 | QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) | 1993 | QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) |
1994 | { | 1994 | { |
1995 | x -= 2; // Bug in Qt/E | 1995 | if(active){ |
1996 | y -= 2; | 1996 | x -= 2; // Bug in Qt/E |
1997 | w += 2; | 1997 | y -= 2; |
1998 | h += 2; | 1998 | w += 2; |
1999 | h += 2; | ||
2000 | } | ||
1999 | 2001 | ||
2000 | p-> fillRect ( x, y, w, h, g.brush(QColorGroup::Background)); | 2002 | p-> fillRect ( x, y, w, h, g.brush(QColorGroup::Background)); |
2001 | 2003 | ||
2002 | w -= 2; | ||
2003 | |||
2004 | if(menuHandler->useShadowText()){ | 2004 | if(menuHandler->useShadowText()){ |
2005 | QColor shadow; | 2005 | QColor shadow; |
2006 | if(p->device() && p->device()->devType() == QInternal::Widget && | 2006 | if(p->device() && p->device()->devType() == QInternal::Widget && |
2007 | ((QWidget *)p->device())->inherits("QMenuBar")){ | 2007 | ((QWidget *)p->device())->inherits("QMenuBar")){ |
2008 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : | 2008 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : |
2009 | g.background().dark(130); | 2009 | g.background().dark(130); |
2010 | } | 2010 | } |
2011 | else | 2011 | else |
2012 | shadow = g.background().dark(130); | 2012 | shadow = g.background().dark(130); |
2013 | 2013 | ||
2014 | if(active){ | 2014 | if(active){ |
2015 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); | 2015 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); |
2016 | QApplication::style().drawItem(p, x+1, y+1, w, h, | 2016 | QApplication::style().drawItem(p, x+1, y+1, w, h, |
2017 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2017 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2018 | g, mi->isEnabled(), NULL, mi->text(), | 2018 | g, mi->isEnabled(), NULL, mi->text(), |
2019 | -1, &shadow); | 2019 | -1, &shadow); |
2020 | QApplication::style().drawItem(p, x, y, w, h, | 2020 | QApplication::style().drawItem(p, x, y, w, h, |
2021 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2021 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2022 | g, mi->isEnabled(), NULL, mi->text(), | 2022 | g, mi->isEnabled(), NULL, mi->text(), |
2023 | -1, &g.text()); | 2023 | -1, &g.text()); |
2024 | } | 2024 | } |
2025 | else{ | 2025 | else{ |
2026 | QApplication::style().drawItem(p, x+1, y+1, w, h, | 2026 | QApplication::style().drawItem(p, x+1, y+1, w, h, |
2027 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2027 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2028 | g, mi->isEnabled(), NULL, mi->text(), | 2028 | g, mi->isEnabled(), NULL, mi->text(), |
2029 | -1, &shadow); | 2029 | -1, &shadow); |
2030 | QApplication::style().drawItem(p, x, y, w, h, | 2030 | QApplication::style().drawItem(p, x, y, w, h, |
2031 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2031 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2032 | g, mi->isEnabled(), NULL, mi->text(), | 2032 | g, mi->isEnabled(), NULL, mi->text(), |
2033 | -1, &g.text()); | 2033 | -1, &g.text()); |
2034 | } | 2034 | } |
2035 | } | 2035 | } |
2036 | else{ | 2036 | else{ |
2037 | if(active) | 2037 | if(active) |
2038 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); | 2038 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); |
2039 | QApplication::style().drawItem(p, x, y, w, h, | 2039 | QApplication::style().drawItem(p, x, y, w, h, |
2040 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2040 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2041 | g, mi->isEnabled(), NULL, mi->text(), | 2041 | g, mi->isEnabled(), NULL, mi->text(), |
2042 | -1, &g.text()); | 2042 | -1, &g.text()); |
2043 | } | 2043 | } |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, | 2046 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, |
2047 | const QColorGroup &g, int /*lineWidth*/, | 2047 | const QColorGroup &g, int /*lineWidth*/, |
2048 | const QBrush * /*fill*/) | 2048 | const QBrush * /*fill*/) |
2049 | { | 2049 | { |
2050 | QColor c; | 2050 | QColor c; |
2051 | switch(menuHandler->transType()){ | 2051 | switch(menuHandler->transType()){ |
2052 | case None: | 2052 | case None: |
2053 | case StippledBg: | 2053 | case StippledBg: |
2054 | case TransStippleBg: | 2054 | case TransStippleBg: |
2055 | c = g.background(); | 2055 | c = g.background(); |
2056 | break; | 2056 | break; |
2057 | case StippledBtn: | 2057 | case StippledBtn: |
2058 | case TransStippleBtn: | 2058 | case TransStippleBtn: |
2059 | c = g.button(); | 2059 | c = g.button(); |
2060 | break; | 2060 | break; |
2061 | default: | 2061 | default: |
2062 | c = menuHandler->bgColor(); | 2062 | c = menuHandler->bgColor(); |
2063 | } | 2063 | } |
2064 | p->setPen(c.dark(140)); | 2064 | p->setPen(c.dark(140)); |
2065 | p->drawRect(x, y, w, h); | 2065 | p->drawRect(x, y, w, h); |
2066 | p->setPen(c.light(120)); | 2066 | p->setPen(c.light(120)); |
2067 | p->drawRect(x+1, y+1, w-2, h-2); | 2067 | p->drawRect(x+1, y+1, w-2, h-2); |
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, | 2070 | void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, |
2071 | int tab, QMenuItem* mi, | 2071 | int tab, QMenuItem* mi, |
2072 | const QPalette& pal, bool act, | 2072 | const QPalette& pal, bool act, |
2073 | bool enabled, int x, int y, int w, int h) | 2073 | bool enabled, int x, int y, int w, int h) |
2074 | { | 2074 | { |
2075 | static const int motifItemFrame = 2; | 2075 | static const int motifItemFrame = 2; |
2076 | static const int motifItemHMargin = 3; | 2076 | static const int motifItemHMargin = 3; |
2077 | static const int motifItemVMargin = 2; | 2077 | static const int motifItemVMargin = 2; |
2078 | static const int motifArrowHMargin = 6; | 2078 | static const int motifArrowHMargin = 6; |
2079 | static const int windowsRightBorder = 12; | 2079 | static const int windowsRightBorder = 12; |
2080 | 2080 | ||
2081 | maxpmw = QMAX( maxpmw, 20 ); | 2081 | maxpmw = QMAX( maxpmw, 20 ); |
2082 | 2082 | ||
2083 | 2083 | ||
2084 | bool dis = !enabled; | 2084 | bool dis = !enabled; |
2085 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); | 2085 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); |
2086 | 2086 | ||
2087 | int checkcol = maxpmw; | 2087 | int checkcol = maxpmw; |
2088 | if(act){ | 2088 | if(act){ |
2089 | 2089 | ||
2090 | // FIXME | 2090 | // FIXME |
2091 | drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); | 2091 | drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); |
2092 | } | 2092 | } |
2093 | //else if(((QWidget*)p->device())->backgroundPixmap()){ | 2093 | //else if(((QWidget*)p->device())->backgroundPixmap()){ |
2094 | // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), | 2094 | // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), |
2095 | // x, y, w, h); | 2095 | // x, y, w, h); |
2096 | //} | 2096 | //} |
2097 | else{ | 2097 | else{ |
2098 | if(menuHandler->transType() == None){ | 2098 | if(menuHandler->transType() == None){ |
2099 | p->fillRect(x, y, w, h, pal.active().background()); | 2099 | p->fillRect(x, y, w, h, pal.active().background()); |
2100 | } | 2100 | } |
2101 | else if(menuHandler->transType() == StippledBg){ | 2101 | else if(menuHandler->transType() == StippledBg){ |
2102 | p->fillRect(x, y, w, h, bgBrush); | 2102 | p->fillRect(x, y, w, h, bgBrush); |
2103 | } | 2103 | } |
2104 | else if(menuHandler->transType() == StippledBtn){ | 2104 | else if(menuHandler->transType() == StippledBtn){ |
2105 | p->fillRect(x, y, w, h, menuBrush); | 2105 | p->fillRect(x, y, w, h, menuBrush); |
2106 | } | 2106 | } |
2107 | else{ | 2107 | else{ |
2108 | QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); | 2108 | QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); |
2109 | if(pix) | 2109 | if(pix) |
2110 | p->drawPixmap(x, y, *pix, x, y, w, h); | 2110 | p->drawPixmap(x, y, *pix, x, y, w, h); |
2111 | } | 2111 | } |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | if(!mi) | 2114 | if(!mi) |
2115 | return; | 2115 | return; |
2116 | 2116 | ||
2117 | QColor discol; | 2117 | QColor discol; |
2118 | if (dis) { | 2118 | if (dis) { |
2119 | discol = itemg.mid(); | 2119 | discol = itemg.mid(); |
2120 | p->setPen(discol); | 2120 | p->setPen(discol); |
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | QColorGroup cg2(itemg); | 2123 | QColorGroup cg2(itemg); |
2124 | 2124 | ||
2125 | if(menuHandler->transType() == Custom){ | 2125 | if(menuHandler->transType() == Custom){ |
2126 | cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); | 2126 | cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); |
2127 | cg2.setColor(QColorGroup::Text, menuHandler->textColor()); | 2127 | cg2.setColor(QColorGroup::Text, menuHandler->textColor()); |
2128 | cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); | 2128 | cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); |
2129 | cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); | 2129 | cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); |
2130 | } | 2130 | } |
2131 | else{ | 2131 | else{ |
2132 | cg2 = QColorGroup(discol, itemg.highlight(), black, black, | 2132 | cg2 = QColorGroup(discol, itemg.highlight(), black, black, |
2133 | dis ? discol : black, discol, black); | 2133 | dis ? discol : black, discol, black); |
2134 | } | 2134 | } |
2135 | 2135 | ||
2136 | if(mi->isSeparator()){ | 2136 | if(mi->isSeparator()){ |
2137 | QColor c; | 2137 | QColor c; |
2138 | switch(menuHandler->transType()){ | 2138 | switch(menuHandler->transType()){ |
2139 | case None: | 2139 | case None: |
2140 | case StippledBg: | 2140 | case StippledBg: |
2141 | case TransStippleBg: | 2141 | case TransStippleBg: |
2142 | c = QApplication::palette().active().background(); | 2142 | c = QApplication::palette().active().background(); |
2143 | break; | 2143 | break; |
2144 | case StippledBtn: | 2144 | case StippledBtn: |
2145 | case TransStippleBtn: | 2145 | case TransStippleBtn: |
2146 | c = QApplication::palette().active().button(); | 2146 | c = QApplication::palette().active().button(); |
2147 | break; | 2147 | break; |
2148 | default: | 2148 | default: |
2149 | c = menuHandler->bgColor(); | 2149 | c = menuHandler->bgColor(); |
2150 | } | 2150 | } |
2151 | p->setPen(c.dark(140)); | 2151 | p->setPen(c.dark(140)); |
2152 | p->drawLine(x, y, x+w, y ); | 2152 | p->drawLine(x, y, x+w, y ); |
2153 | p->setPen(c.light(115)); | 2153 | p->setPen(c.light(115)); |
2154 | p->drawLine(x, y+1, x+w, y+1 ); | 2154 | p->drawLine(x, y+1, x+w, y+1 ); |
2155 | return; | 2155 | return; |
2156 | } | 2156 | } |
2157 | if(mi->iconSet()) { | 2157 | if(mi->iconSet()) { |
2158 | QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; | 2158 | QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; |
2159 | if (!dis) | 2159 | if (!dis) |
2160 | mode = QIconSet::Active; | 2160 | mode = QIconSet::Active; |
2161 | QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); | 2161 | QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); |
2162 | int pixw = pixmap.width(); | 2162 | int pixw = pixmap.width(); |
2163 | int pixh = pixmap.height(); | 2163 | int pixh = pixmap.height(); |
2164 | QRect cr(x, y, checkcol, h); | 2164 | QRect cr(x, y, checkcol, h); |
2165 | QRect pmr(0, 0, pixw, pixh); | 2165 | QRect pmr(0, 0, pixw, pixh); |
2166 | pmr.moveCenter( cr.center() ); | 2166 | pmr.moveCenter( cr.center() ); |
2167 | p->setPen(itemg.highlightedText()); | 2167 | p->setPen(itemg.highlightedText()); |
2168 | p->drawPixmap(pmr.topLeft(), pixmap ); | 2168 | p->drawPixmap(pmr.topLeft(), pixmap ); |
2169 | 2169 | ||
2170 | } | 2170 | } |
2171 | else if(checkable) { | 2171 | else if(checkable) { |
2172 | int mw = checkcol + motifItemFrame; | 2172 | int mw = checkcol + motifItemFrame; |
2173 | int mh = h - 2*motifItemFrame; | 2173 | int mh = h - 2*motifItemFrame; |
2174 | if (mi->isChecked()){ | 2174 | if (mi->isChecked()){ |
2175 | drawCheckMark( p, x + motifItemFrame, | 2175 | drawCheckMark( p, x + motifItemFrame, |
2176 | y+motifItemFrame, mw, mh, cg2, act, dis ); | 2176 | y+motifItemFrame, mw, mh, cg2, act, dis ); |
2177 | } | 2177 | } |
2178 | } | 2178 | } |
2179 | if(menuHandler->transType() == Custom) | 2179 | if(menuHandler->transType() == Custom) |
2180 | p->setPen(menuHandler->textColor()); | 2180 | p->setPen(menuHandler->textColor()); |
2181 | else | 2181 | else |
2182 | p->setPen(itemg.text()); | 2182 | p->setPen(itemg.text()); |
2183 | 2183 | ||
2184 | 2184 | ||
2185 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 2185 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
2186 | QString s = mi->text(); | 2186 | QString s = mi->text(); |
2187 | if (!s.isNull()) { | 2187 | if (!s.isNull()) { |
2188 | int t = s.find( '\t' ); | 2188 | int t = s.find( '\t' ); |
2189 | int m = motifItemVMargin; | 2189 | int m = motifItemVMargin; |
2190 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; | 2190 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; |
2191 | QPen oldPen = p->pen(); | 2191 | QPen oldPen = p->pen(); |
2192 | if(menuHandler->useShadowText()){ | 2192 | if(menuHandler->useShadowText()){ |
2193 | if(menuHandler->transType() == Custom) | 2193 | if(menuHandler->transType() == Custom) |
2194 | p->setPen(menuHandler->bgColor().dark(130)); | 2194 | p->setPen(menuHandler->bgColor().dark(130)); |
2195 | else if(menuHandler->transType() == StippledBtn || | 2195 | else if(menuHandler->transType() == StippledBtn || |
2196 | menuHandler->transType() == TransStippleBtn) | 2196 | menuHandler->transType() == TransStippleBtn) |
2197 | p->setPen(itemg.button().dark(130)); | 2197 | p->setPen(itemg.button().dark(130)); |
2198 | else | 2198 | else |
2199 | p->setPen(bgBrush.color().dark(130)); | 2199 | p->setPen(bgBrush.color().dark(130)); |
2200 | 2200 | ||
2201 | if (t >= 0) { | 2201 | if (t >= 0) { |
2202 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, | 2202 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, |
2203 | y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); | 2203 | y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); |
2204 | } | 2204 | } |
2205 | p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); | 2205 | p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); |
2206 | } | 2206 | } |
2207 | p->setPen(oldPen); | 2207 | p->setPen(oldPen); |
2208 | if (t >= 0) { | 2208 | if (t >= 0) { |
2209 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, | 2209 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, |
2210 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); | 2210 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); |
2211 | } | 2211 | } |
2212 | p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); | 2212 | p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); |
2213 | 2213 | ||
2214 | } | 2214 | } |
2215 | else if (mi->pixmap()) { | 2215 | else if (mi->pixmap()) { |
2216 | QPixmap *pixmap = mi->pixmap(); | 2216 | QPixmap *pixmap = mi->pixmap(); |
2217 | if (pixmap->depth() == 1) | 2217 | if (pixmap->depth() == 1) |
2218 | p->setBackgroundMode(OpaqueMode); | 2218 | p->setBackgroundMode(OpaqueMode); |
2219 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); | 2219 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); |
2220 | if (pixmap->depth() == 1) | 2220 | if (pixmap->depth() == 1) |
2221 | p->setBackgroundMode(TransparentMode); | 2221 | p->setBackgroundMode(TransparentMode); |
2222 | } | 2222 | } |
2223 | if (mi->popup()) { | 2223 | if (mi->popup()) { |
2224 | int dim = (h-2*motifItemFrame) / 2; | 2224 | int dim = (h-2*motifItemFrame) / 2; |
2225 | drawArrow(p, RightArrow, true, | 2225 | drawArrow(p, RightArrow, true, |
2226 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 2226 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
2227 | dim, dim, cg2, TRUE); | 2227 | dim, dim, cg2, TRUE); |
2228 | } | 2228 | } |
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, | 2231 | int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, |
2232 | const QFontMetrics &fm) | 2232 | const QFontMetrics &fm) |
2233 | { | 2233 | { |
2234 | if (mi->isSeparator()) | 2234 | if (mi->isSeparator()) |
2235 | return 2; | 2235 | return 2; |
2236 | 2236 | ||
2237 | int h = 0; | 2237 | int h = 0; |
2238 | if (mi->pixmap()) | 2238 | if (mi->pixmap()) |
2239 | h = mi->pixmap()->height(); | 2239 | h = mi->pixmap()->height(); |
2240 | 2240 | ||
2241 | if (mi->iconSet()) | 2241 | if (mi->iconSet()) |
2242 | h = QMAX(mi->iconSet()-> | 2242 | h = QMAX(mi->iconSet()-> |
2243 | pixmap(QIconSet::Small, QIconSet::Normal).height(), h); | 2243 | pixmap(QIconSet::Small, QIconSet::Normal).height(), h); |
2244 | 2244 | ||
2245 | h = QMAX(fm.height() + 4, h); | 2245 | h = QMAX(fm.height() + 4, h); |
2246 | 2246 | ||
2247 | // we want a minimum size of 18 | 2247 | // we want a minimum size of 18 |
2248 | h = QMAX(h, 18); | 2248 | h = QMAX(h, 18); |
2249 | 2249 | ||
2250 | return h; | 2250 | return h; |
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | 2253 | ||
2254 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, | 2254 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, |
2255 | const QColorGroup &g, const QColor *c, | 2255 | const QColorGroup &g, const QColor *c, |
2256 | bool atBorder) | 2256 | bool atBorder) |
2257 | { | 2257 | { |
2258 | // are we painting a widget? | 2258 | // are we painting a widget? |
2259 | if(p->device()->devType() == QInternal::Widget){ | 2259 | if(p->device()->devType() == QInternal::Widget){ |
2260 | // if so does it use a special focus rectangle? | 2260 | // if so does it use a special focus rectangle? |
2261 | QWidget *w = (QWidget *)p->device(); | 2261 | QWidget *w = (QWidget *)p->device(); |
2262 | if(w->inherits("QPushButton") || w->inherits("QSlider")){ | 2262 | if(w->inherits("QPushButton") || w->inherits("QSlider")){ |
2263 | return; | 2263 | return; |
2264 | } | 2264 | } |
2265 | else{ | 2265 | else{ |
2266 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2266 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2267 | } | 2267 | } |
2268 | } | 2268 | } |
2269 | else | 2269 | else |
2270 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2270 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2271 | 2271 | ||
2272 | } | 2272 | } |
2273 | 2273 | ||
2274 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) | 2274 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) |
2275 | { | 2275 | { |
2276 | mnu->installEventFilter(menuHandler); | 2276 | mnu->installEventFilter(menuHandler); |
2277 | QWindowsStyle::polishPopupMenu(mnu); | 2277 | QWindowsStyle::polishPopupMenu(mnu); |
2278 | } | 2278 | } |
2279 | 2279 | ||
2280 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, | 2280 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, |
2281 | bool selected) | 2281 | bool selected) |
2282 | { | 2282 | { |
2283 | if(tabBar->shape() != QTabBar::RoundedAbove){ | 2283 | if(tabBar->shape() != QTabBar::RoundedAbove){ |
2284 | QWindowsStyle::drawTab(p, tabBar, tab, selected); | 2284 | QWindowsStyle::drawTab(p, tabBar, tab, selected); |
2285 | return; | 2285 | return; |
2286 | } | 2286 | } |
2287 | QPixmap tilePix; | 2287 | QPixmap tilePix; |
2288 | QRect r = tab->rect(); | 2288 | QRect r = tab->rect(); |
2289 | //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : | 2289 | //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : |
2290 | // pixmaps[TabDown] : pixmaps[Tab]; | 2290 | // pixmaps[TabDown] : pixmaps[Tab]; |
2291 | 2291 | ||
2292 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); | 2292 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); |
2293 | p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); | 2293 | p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); |
2294 | p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); | 2294 | p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); |
2295 | tilePix.resize(pix->width()-18, r.height()); | 2295 | tilePix.resize(pix->width()-18, r.height()); |
2296 | bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); | 2296 | bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); |
2297 | p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); | 2297 | p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); |
2298 | QColor c = tabBar->colorGroup().button(); | 2298 | QColor c = tabBar->colorGroup().button(); |
2299 | if(!selected){ | 2299 | if(!selected){ |
2300 | p->setPen(c.dark(130)); | 2300 | p->setPen(c.dark(130)); |
2301 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); | 2301 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); |
2302 | } | 2302 | } |
2303 | 2303 | ||
2304 | /* | 2304 | /* |
2305 | p->setPen(c.light(110)); | 2305 | p->setPen(c.light(110)); |
2306 | p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); | 2306 | p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); |
2307 | p->setPen(c); | 2307 | p->setPen(c); |
2308 | p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); | 2308 | p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); |
2309 | p->setPen(c.light(110)); | 2309 | p->setPen(c.light(110)); |
2310 | p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); | 2310 | p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); |
2311 | p->setPen(c.light(120)); | 2311 | p->setPen(c.light(120)); |
2312 | p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); | 2312 | p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); |
2313 | */ | 2313 | */ |
2314 | 2314 | ||
2315 | /* | 2315 | /* |
2316 | QColor c = tabBar->colorGroup().button(); | 2316 | QColor c = tabBar->colorGroup().button(); |
2317 | pix = bevelFillDict.find(c.rgb()); | 2317 | pix = bevelFillDict.find(c.rgb()); |
2318 | if(!pix){ | 2318 | if(!pix){ |
2319 | int h, s, v; | 2319 | int h, s, v; |
2320 | c.hsv(&h, &s, &v); | 2320 | c.hsv(&h, &s, &v); |
2321 | pix = new QPixmap(*bevelFillPix); | 2321 | pix = new QPixmap(*bevelFillPix); |
2322 | adjustHSV(*pix, h, s); | 2322 | adjustHSV(*pix, h, s); |
2323 | bevelFillDict.insert(c.rgb(), pix); | 2323 | bevelFillDict.insert(c.rgb(), pix); |
2324 | }*/ | 2324 | }*/ |
2325 | 2325 | ||
2326 | /* | 2326 | /* |
2327 | QRect r = tab->rect(); | 2327 | QRect r = tab->rect(); |
2328 | QColorGroup g = tabBar->colorGroup(); | 2328 | QColorGroup g = tabBar->colorGroup(); |
2329 | if(!selected){ | 2329 | if(!selected){ |
2330 | r.setY(r.y()+1); | 2330 | r.setY(r.y()+1); |
2331 | p->setPen(g.dark()); | 2331 | p->setPen(g.dark()); |
2332 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); | 2332 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); |
2333 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); | 2333 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); |
2334 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); | 2334 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); |
2335 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); | 2335 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); |
2336 | 2336 | ||
2337 | p->setPen(g.midlight()); | 2337 | p->setPen(g.midlight()); |
2338 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); | 2338 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); |
2339 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); | 2339 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); |
2340 | p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); | 2340 | p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); |
2341 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); | 2341 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); |
2342 | 2342 | ||
2343 | p->setPen(g.mid()); | 2343 | p->setPen(g.mid()); |
2344 | p->drawPoint(r.right()-1, r.y()+1); | 2344 | p->drawPoint(r.right()-1, r.y()+1); |
2345 | p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); | 2345 | p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); |
2346 | p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); | 2346 | p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); |
2347 | 2347 | ||
2348 | p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, | 2348 | p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, |
2349 | g.brush(QColorGroup::Mid)); | 2349 | g.brush(QColorGroup::Mid)); |
2350 | 2350 | ||
2351 | p->setPen(g.light()); | 2351 | p->setPen(g.light()); |
2352 | p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); | 2352 | p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); |
2353 | 2353 | ||
2354 | } | 2354 | } |
2355 | else{ | 2355 | else{ |
2356 | p->setPen(g.light()); | 2356 | p->setPen(g.light()); |
2357 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); | 2357 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); |
2358 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); | 2358 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); |
2359 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); | 2359 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); |
2360 | p->setPen(g.dark()); | 2360 | p->setPen(g.dark()); |
2361 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); | 2361 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); |
2362 | 2362 | ||
2363 | p->setPen(g.midlight()); | 2363 | p->setPen(g.midlight()); |
2364 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); | 2364 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); |
2365 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); | 2365 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); |
2366 | p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); | 2366 | p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); |
2367 | p->setPen(g.mid()); | 2367 | p->setPen(g.mid()); |
2368 | p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); | 2368 | p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); |
2369 | }*/ | 2369 | }*/ |
2370 | 2370 | ||
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | 2373 | ||
2374 | 2374 | ||
2375 | void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, | 2375 | void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, |
2376 | bool selected) | 2376 | bool selected) |
2377 | 2377 | ||
2378 | 2378 | ||
2379 | { | 2379 | { |
2380 | //p->fillRect(tab->rect(), Qt::color1); | 2380 | //p->fillRect(tab->rect(), Qt::color1); |
2381 | QRect r = tab->rect(); | 2381 | QRect r = tab->rect(); |
2382 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); | 2382 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); |
2383 | p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); | 2383 | p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); |
2384 | p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); | 2384 | p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); |
2385 | p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); | 2385 | p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); |
2386 | } | 2386 | } |
2387 | 2387 | ||
2388 | void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, | 2388 | void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, |
2389 | int &overlap) | 2389 | int &overlap) |
2390 | { | 2390 | { |
2391 | if(t->shape() == QTabBar::RoundedAbove){ | 2391 | if(t->shape() == QTabBar::RoundedAbove){ |
2392 | overlap = 1; | 2392 | overlap = 1; |
2393 | hFrame = 18; // was 24 | 2393 | hFrame = 18; // was 24 |
2394 | vFrame = 8; // was 10 | 2394 | vFrame = 8; // was 10 |
2395 | } | 2395 | } |
2396 | else | 2396 | else |
2397 | QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); | 2397 | QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | 2400 | ||
2401 | 2401 | ||
2402 | void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, | 2402 | void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, |
2403 | const QColorGroup &g, Orientation) | 2403 | const QColorGroup &g, Orientation) |
2404 | { | 2404 | { |
2405 | drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? | 2405 | drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? |
2406 | g.button().light(120) : g.button(), g.background()); | 2406 | g.button().light(120) : g.button(), g.background()); |
2407 | } | 2407 | } |
2408 | 2408 | ||
2409 | 2409 | ||
2410 | void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, | 2410 | void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, |
2411 | const QColorGroup &g, bool sunken, | 2411 | const QColorGroup &g, bool sunken, |
2412 | int lineWidth, const QBrush *fill) | 2412 | int lineWidth, const QBrush *fill) |
2413 | { | 2413 | { |
2414 | if(p->device()->devType() == QInternal::Widget && | 2414 | if(p->device()->devType() == QInternal::Widget && |
2415 | ((QWidget *)p->device())->inherits("QLineEdit")){ | 2415 | ((QWidget *)p->device())->inherits("QLineEdit")){ |
2416 | int x2 = x+w-1; | 2416 | int x2 = x+w-1; |
2417 | int y2 = y+h-1; | 2417 | int y2 = y+h-1; |
2418 | p->setPen(g.dark()); | 2418 | p->setPen(g.dark()); |
2419 | p->drawRect(x, y, w, h); | 2419 | p->drawRect(x, y, w, h); |
2420 | p->setPen(g.mid()); | 2420 | p->setPen(g.mid()); |
2421 | p->drawLine(x+1, y+1, x2-2, y+1); | 2421 | p->drawLine(x+1, y+1, x2-2, y+1); |
2422 | p->drawLine(x+1, y+1, x+1, y2-1); | 2422 | p->drawLine(x+1, y+1, x+1, y2-1); |
2423 | } | 2423 | } |
2424 | else if(lineWidth != 2 || !sunken) | 2424 | else if(lineWidth != 2 || !sunken) |
2425 | QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); | 2425 | QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); |
2426 | else{ | 2426 | else{ |
2427 | QPen oldPen = p->pen(); | 2427 | QPen oldPen = p->pen(); |
2428 | int x2 = x+w-1; | 2428 | int x2 = x+w-1; |
2429 | int y2 = y+h-1; | 2429 | int y2 = y+h-1; |
2430 | p->setPen(g.light()); | 2430 | p->setPen(g.light()); |
2431 | p->drawLine(x, y2, x2, y2); | 2431 | p->drawLine(x, y2, x2, y2); |
2432 | p->drawLine(x2, y, x2, y2); | 2432 | p->drawLine(x2, y, x2, y2); |
2433 | p->setPen(g.mid()); | 2433 | p->setPen(g.mid()); |
2434 | p->drawLine(x, y, x2, y); | 2434 | p->drawLine(x, y, x2, y); |
2435 | p->drawLine(x, y, x, y2); | 2435 | p->drawLine(x, y, x, y2); |
2436 | 2436 | ||
2437 | p->setPen(g.midlight()); | 2437 | p->setPen(g.midlight()); |
2438 | p->drawLine(x+1, y2-1, x2-1, y2-1); | 2438 | p->drawLine(x+1, y2-1, x2-1, y2-1); |
2439 | p->drawLine(x2-1, y+1, x2-1, y2-1); | 2439 | p->drawLine(x2-1, y+1, x2-1, y2-1); |
2440 | p->setPen(g.dark()); | 2440 | p->setPen(g.dark()); |
2441 | p->drawLine(x+1, y+1, x2-1, y+1); | 2441 | p->drawLine(x+1, y+1, x2-1, y+1); |
2442 | p->drawLine(x+1, y+1, x+1, y2-1); | 2442 | p->drawLine(x+1, y+1, x+1, y2-1); |
2443 | p->setPen(oldPen); | 2443 | p->setPen(oldPen); |
2444 | if(fill){ | 2444 | if(fill){ |
2445 | // I believe here we are only supposed to fill if there is a | 2445 | // I believe here we are only supposed to fill if there is a |
2446 | // specified fill brush... | 2446 | // specified fill brush... |
2447 | p->fillRect(x+2, y+2, w-4, h-4, *fill); | 2447 | p->fillRect(x+2, y+2, w-4, h-4, *fill); |
2448 | } | 2448 | } |
2449 | } | 2449 | } |
2450 | } | 2450 | } |
2451 | 2451 | ||
2452 | 2452 | ||
2453 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) | 2453 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) |
2454 | { | 2454 | { |
2455 | QBitmap *maskBmp = NULL; | 2455 | QBitmap *maskBmp = NULL; |
2456 | if(pix.mask()) | 2456 | if(pix.mask()) |
2457 | maskBmp = new QBitmap(*pix.mask()); | 2457 | maskBmp = new QBitmap(*pix.mask()); |
2458 | QImage img = pix.convertToImage(); | 2458 | QImage img = pix.convertToImage(); |
2459 | if(img.depth() != 32) | 2459 | if(img.depth() != 32) |
2460 | img = img.convertDepth(32); | 2460 | img = img.convertDepth(32); |
2461 | unsigned int *data = (unsigned int *)img.bits(); | 2461 | unsigned int *data = (unsigned int *)img.bits(); |
2462 | int total = img.width()*img.height(); | 2462 | int total = img.width()*img.height(); |
2463 | int current; | 2463 | int current; |
2464 | QColor c; | 2464 | QColor c; |
2465 | int oldH, oldS, oldV; | 2465 | int oldH, oldS, oldV; |
2466 | if(v < 235) | 2466 | if(v < 235) |
2467 | v += 20; | 2467 | v += 20; |
2468 | else | 2468 | else |
2469 | v = 255; | 2469 | v = 255; |
2470 | float intensity = v/255.0; | 2470 | float intensity = v/255.0; |
2471 | 2471 | ||
2472 | for(current=0; current<total; ++current){ | 2472 | for(current=0; current<total; ++current){ |
2473 | c.setRgb(data[current]); | 2473 | c.setRgb(data[current]); |
2474 | c.hsv(&oldH, &oldS, &oldV); | 2474 | c.hsv(&oldH, &oldS, &oldV); |
2475 | oldV = (int)(oldV*intensity); | 2475 | oldV = (int)(oldV*intensity); |
2476 | c.setHsv(h, s, oldV); | 2476 | c.setHsv(h, s, oldV); |
2477 | data[current] = c.rgb(); | 2477 | data[current] = c.rgb(); |
2478 | } | 2478 | } |
2479 | pix.convertFromImage(img); | 2479 | pix.convertFromImage(img); |
2480 | if(maskBmp) | 2480 | if(maskBmp) |
2481 | pix.setMask(*maskBmp); | 2481 | pix.setMask(*maskBmp); |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | void LiquidStyle::intensity(QPixmap &pix, float percent) | 2484 | void LiquidStyle::intensity(QPixmap &pix, float percent) |
2485 | { | 2485 | { |
2486 | QImage image = pix.convertToImage(); | 2486 | QImage image = pix.convertToImage(); |
2487 | int i, tmp, r, g, b; | 2487 | int i, tmp, r, g, b; |
2488 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 2488 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
2489 | unsigned char *segTbl = new unsigned char[segColors]; | 2489 | unsigned char *segTbl = new unsigned char[segColors]; |
2490 | int pixels = image.depth() > 8 ? image.width()*image.height() : | 2490 | int pixels = image.depth() > 8 ? image.width()*image.height() : |
2491 | image.numColors(); | 2491 | image.numColors(); |
2492 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : | 2492 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : |
2493 | (unsigned int *)image.colorTable(); | 2493 | (unsigned int *)image.colorTable(); |
2494 | 2494 | ||
2495 | bool brighten = (percent >= 0); | 2495 | bool brighten = (percent >= 0); |
2496 | if(percent < 0) | 2496 | if(percent < 0) |
2497 | percent = -percent; | 2497 | percent = -percent; |
2498 | 2498 | ||
2499 | if(brighten){ // keep overflow check out of loops | 2499 | if(brighten){ // keep overflow check out of loops |
2500 | for(i=0; i < segColors; ++i){ | 2500 | for(i=0; i < segColors; ++i){ |
2501 | tmp = (int)(i*percent); | 2501 | tmp = (int)(i*percent); |
2502 | if(tmp > 255) | 2502 | if(tmp > 255) |
2503 | tmp = 255; | 2503 | tmp = 255; |
2504 | segTbl[i] = tmp; | 2504 | segTbl[i] = tmp; |
2505 | } | 2505 | } |
2506 | } | 2506 | } |
2507 | else{ | 2507 | else{ |
2508 | for(i=0; i < segColors; ++i){ | 2508 | for(i=0; i < segColors; ++i){ |
2509 | tmp = (int)(i*percent); | 2509 | tmp = (int)(i*percent); |
2510 | if(tmp < 0) | 2510 | if(tmp < 0) |
2511 | tmp = 0; | 2511 | tmp = 0; |
2512 | segTbl[i] = tmp; | 2512 | segTbl[i] = tmp; |
2513 | } | 2513 | } |
2514 | } | 2514 | } |
2515 | 2515 | ||
2516 | if(brighten){ // same here | 2516 | if(brighten){ // same here |
2517 | for(i=0; i < pixels; ++i){ | 2517 | for(i=0; i < pixels; ++i){ |
2518 | r = qRed(data[i]); | 2518 | r = qRed(data[i]); |
2519 | g = qGreen(data[i]); | 2519 | g = qGreen(data[i]); |
2520 | b = qBlue(data[i]); | 2520 | b = qBlue(data[i]); |
2521 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; | 2521 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; |
2522 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; | 2522 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; |
2523 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; | 2523 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; |
2524 | data[i] = qRgb(r, g, b); | 2524 | data[i] = qRgb(r, g, b); |
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | else{ | 2527 | else{ |
2528 | for(i=0; i < pixels; ++i){ | 2528 | for(i=0; i < pixels; ++i){ |
2529 | r = qRed(data[i]); | 2529 | r = qRed(data[i]); |
2530 | g = qGreen(data[i]); | 2530 | g = qGreen(data[i]); |
2531 | b = qBlue(data[i]); | 2531 | b = qBlue(data[i]); |
2532 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; | 2532 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; |
2533 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; | 2533 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; |
2534 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; | 2534 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; |
2535 | data[i] = qRgb(r, g, b); | 2535 | data[i] = qRgb(r, g, b); |
2536 | } | 2536 | } |
2537 | } | 2537 | } |
2538 | delete [] segTbl; | 2538 | delete [] segTbl; |
2539 | pix.convertFromImage(image); | 2539 | pix.convertFromImage(image); |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) | 2542 | void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) |
2543 | { | 2543 | { |
2544 | int x2 = x+w-1; | 2544 | int x2 = x+w-1; |
2545 | int y2 = y+h-1; | 2545 | int y2 = y+h-1; |
2546 | p->drawLine(x+1, y, x2-1, y); | 2546 | p->drawLine(x+1, y, x2-1, y); |
2547 | p->drawLine(x, y+1, x, y2-1); | 2547 | p->drawLine(x, y+1, x, y2-1); |
2548 | p->drawLine(x+1, y2, x2-1, y2); | 2548 | p->drawLine(x+1, y2, x2-1, y2); |
2549 | p->drawLine(x2, y+1, x2, y2-1); | 2549 | p->drawLine(x2, y+1, x2, y2-1); |
2550 | } | 2550 | } |
2551 | 2551 | ||
2552 | void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, | 2552 | void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, |
2553 | const QColorGroup &g, QCOORD, | 2553 | const QColorGroup &g, QCOORD, |
2554 | Orientation orient) | 2554 | Orientation orient) |
2555 | { | 2555 | { |
2556 | bool isFocus = ((QWidget *)p->device())->hasFocus(); | 2556 | bool isFocus = ((QWidget *)p->device())->hasFocus(); |
2557 | QColor c = isFocus ? g.background().dark(120) : g.background(); | 2557 | QColor c = isFocus ? g.background().dark(120) : g.background(); |
2558 | if(orient == Qt::Horizontal){ | 2558 | if(orient == Qt::Horizontal){ |
2559 | int x2 = x+w-1; | 2559 | int x2 = x+w-1; |
2560 | y+=2; | 2560 | y+=2; |
2561 | p->setPen(c.dark(130)); | 2561 | p->setPen(c.dark(130)); |
2562 | p->drawLine(x+1, y, x2-1, y); | 2562 | p->drawLine(x+1, y, x2-1, y); |
2563 | p->setPen(c.dark(150)); | 2563 | p->setPen(c.dark(150)); |
2564 | p->drawLine(x, y+1, x2, y+1); | 2564 | p->drawLine(x, y+1, x2, y+1); |
2565 | p->setPen(c.dark(125)); | 2565 | p->setPen(c.dark(125)); |
2566 | p->drawLine(x, y+2, x2, y+2); | 2566 | p->drawLine(x, y+2, x2, y+2); |
2567 | p->setPen(c.dark(130)); | 2567 | p->setPen(c.dark(130)); |
2568 | p->drawLine(x, y+3, x2, y+3); | 2568 | p->drawLine(x, y+3, x2, y+3); |
2569 | p->setPen(c.dark(120)); | 2569 | p->setPen(c.dark(120)); |
2570 | p->drawLine(x, y+4, x2, y+4); | 2570 | p->drawLine(x, y+4, x2, y+4); |
2571 | p->setPen(c.light(110)); | 2571 | p->setPen(c.light(110)); |
2572 | p->drawLine(x+1, y+5, x2-1, y+5); | 2572 | p->drawLine(x+1, y+5, x2-1, y+5); |
2573 | } | 2573 | } |
2574 | else{ | 2574 | else{ |
2575 | int y2 = y+h-1; | 2575 | int y2 = y+h-1; |
2576 | x+=2; | 2576 | x+=2; |
2577 | p->setPen(c.dark(130)); | 2577 | p->setPen(c.dark(130)); |
2578 | p->drawLine(x, y+1, x, y2-1); | 2578 | p->drawLine(x, y+1, x, y2-1); |
2579 | p->setPen(c.dark(150)); | 2579 | p->setPen(c.dark(150)); |
2580 | p->drawLine(x+1, y, x+1, y2); | 2580 | p->drawLine(x+1, y, x+1, y2); |
2581 | p->setPen(c.dark(125)); | 2581 | p->setPen(c.dark(125)); |
2582 | p->drawLine(x+2, y, x+2, y2); | 2582 | p->drawLine(x+2, y, x+2, y2); |
2583 | p->setPen(c.dark(130)); | 2583 | p->setPen(c.dark(130)); |
2584 | p->drawLine(x+3, y, x+3, y2); | 2584 | p->drawLine(x+3, y, x+3, y2); |
2585 | p->setPen(c.dark(120)); | 2585 | p->setPen(c.dark(120)); |
2586 | p->drawLine(x+4, y, x+4, y2); | 2586 | p->drawLine(x+4, y, x+4, y2); |
2587 | p->setPen(c.light(110)); | 2587 | p->setPen(c.light(110)); |
2588 | p->drawLine(x+5, y+1, x+5, y2-1); | 2588 | p->drawLine(x+5, y+1, x+5, y2-1); |
2589 | } | 2589 | } |
2590 | //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); | 2590 | //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); |
2591 | 2591 | ||
2592 | } | 2592 | } |
2593 | 2593 | ||
2594 | void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, | 2594 | void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, |
2595 | int h, QCOORD, Orientation orient) | 2595 | int h, QCOORD, Orientation orient) |
2596 | { | 2596 | { |
2597 | p->fillRect(x, y, w, h, Qt::color0); | 2597 | p->fillRect(x, y, w, h, Qt::color0); |
2598 | p->setPen(Qt::color1); | 2598 | p->setPen(Qt::color1); |
2599 | if(orient == Qt::Horizontal){ | 2599 | if(orient == Qt::Horizontal){ |
2600 | int x2 = x+w-1; | 2600 | int x2 = x+w-1; |
2601 | y+=2; | 2601 | y+=2; |
2602 | p->drawLine(x+1, y, x2-1, y); | 2602 | p->drawLine(x+1, y, x2-1, y); |
2603 | p->fillRect(x, y+1, w, 4, Qt::color1); | 2603 | p->fillRect(x, y+1, w, 4, Qt::color1); |
2604 | p->drawLine(x+1, y+5, x2-1, y+5); | 2604 | p->drawLine(x+1, y+5, x2-1, y+5); |
2605 | } | 2605 | } |
2606 | else{ | 2606 | else{ |
2607 | int y2 = y+h-1; | 2607 | int y2 = y+h-1; |
2608 | x+=2; | 2608 | x+=2; |
2609 | p->drawLine(x, y+1, x, y2-1); | 2609 | p->drawLine(x, y+1, x, y2-1); |
2610 | p->fillRect(x+1, y, 4, h, Qt::color1); | 2610 | p->fillRect(x+1, y, 4, h, Qt::color1); |
2611 | p->drawLine(x+5, y+1, x+5, y2-1); | 2611 | p->drawLine(x+5, y+1, x+5, y2-1); |
2612 | } | 2612 | } |
2613 | } | 2613 | } |
2614 | 2614 | ||
2615 | // I'm debating if to use QValueList or QList here. I like QValueList better, | 2615 | // I'm debating if to use QValueList or QList here. I like QValueList better, |
2616 | // but QList handles pointers which is good for a lot of empty icons... | 2616 | // but QList handles pointers which is good for a lot of empty icons... |
2617 | 2617 | ||
2618 | void LiquidStyle::loadCustomButtons() | 2618 | void LiquidStyle::loadCustomButtons() |
2619 | { | 2619 | { |
2620 | return; // TODO | 2620 | return; // TODO |
2621 | customBtnColorList.clear(); | 2621 | customBtnColorList.clear(); |
2622 | customBtnIconList.clear(); | 2622 | customBtnIconList.clear(); |
2623 | customBtnLabelList.clear(); | 2623 | customBtnLabelList.clear(); |
2624 | 2624 | ||
2625 | // KConfig *config = KGlobal::config(); | 2625 | // KConfig *config = KGlobal::config(); |
2626 | // QString oldGrp = config->group(); | 2626 | // QString oldGrp = config->group(); |
2627 | // config->setGroup("MosfetButtons"); | 2627 | // config->setGroup("MosfetButtons"); |
2628 | 2628 | ||
2629 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors | 2629 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors |
2630 | iconList.setAutoDelete(true); | 2630 | iconList.setAutoDelete(true); |
2631 | colorList.setAutoDelete(true); | 2631 | colorList.setAutoDelete(true); |
2632 | // config->readListEntry("Labels", customBtnLabelList); | 2632 | // config->readListEntry("Labels", customBtnLabelList); |
2633 | // config->readListEntry("Icons", iconList); | 2633 | // config->readListEntry("Icons", iconList); |
2634 | // config->readListEntry("Colors", colorList); | 2634 | // config->readListEntry("Colors", colorList); |
2635 | 2635 | ||
2636 | const char *labelStr = customBtnLabelList.first(); | 2636 | const char *labelStr = customBtnLabelList.first(); |
2637 | const char *colorStr = colorList.first(); | 2637 | const char *colorStr = colorList.first(); |
2638 | const char *iconStr = iconList.first(); | 2638 | const char *iconStr = iconList.first(); |
2639 | 2639 | ||
2640 | // KIconLoader *ldr = KGlobal::iconLoader(); | 2640 | // KIconLoader *ldr = KGlobal::iconLoader(); |
2641 | while(labelStr != NULL){ | 2641 | while(labelStr != NULL){ |
2642 | QColor *c = new QColor; | 2642 | QColor *c = new QColor; |
2643 | c->setNamedColor(QString(colorStr)); | 2643 | c->setNamedColor(QString(colorStr)); |
2644 | customBtnColorList.append(c); | 2644 | customBtnColorList.append(c); |
2645 | 2645 | ||
2646 | QString tmpStr(iconStr); | 2646 | QString tmpStr(iconStr); |
2647 | if(!tmpStr.isEmpty()){ | 2647 | if(!tmpStr.isEmpty()){ |
2648 | QPixmap *pixmap = | 2648 | QPixmap *pixmap = |
2649 | new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); | 2649 | new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); |
2650 | if(pixmap->isNull()){ | 2650 | if(pixmap->isNull()){ |
2651 | delete pixmap; | 2651 | delete pixmap; |
2652 | customBtnIconList.append(NULL); | 2652 | customBtnIconList.append(NULL); |
2653 | } | 2653 | } |
2654 | else | 2654 | else |
2655 | customBtnIconList.append(pixmap); | 2655 | customBtnIconList.append(pixmap); |
2656 | } | 2656 | } |
2657 | else | 2657 | else |
2658 | customBtnIconList.append(NULL); | 2658 | customBtnIconList.append(NULL); |
2659 | 2659 | ||
2660 | labelStr = customBtnLabelList.next(); | 2660 | labelStr = customBtnLabelList.next(); |
2661 | colorStr = colorList.next(); | 2661 | colorStr = colorList.next(); |
2662 | iconStr = iconList.next(); | 2662 | iconStr = iconList.next(); |
2663 | } | 2663 | } |
2664 | } | 2664 | } |
2665 | 2665 | ||
2666 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) | 2666 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) |
2667 | { | 2667 | { |
2668 | return; // TODO | 2668 | return; // TODO |
2669 | QString str = btn->text(); | 2669 | QString str = btn->text(); |
2670 | if(str.isEmpty()) | 2670 | if(str.isEmpty()) |
2671 | return; | 2671 | return; |
2672 | while(str.contains('&') != 0) | 2672 | while(str.contains('&') != 0) |
2673 | str = str.remove(str.find('&'), 1); | 2673 | str = str.remove(str.find('&'), 1); |
2674 | 2674 | ||
2675 | const char *s; | 2675 | const char *s; |
2676 | int idx = 0; | 2676 | int idx = 0; |
2677 | for(s = customBtnLabelList.first(); s != NULL; | 2677 | for(s = customBtnLabelList.first(); s != NULL; |
2678 | ++idx, s = customBtnLabelList.next()){ | 2678 | ++idx, s = customBtnLabelList.next()){ |
2679 | if(qstricmp(s, str.latin1()) == 0){ | 2679 | if(qstricmp(s, str.latin1()) == 0){ |
2680 | QPalette pal = btn->palette(); | 2680 | QPalette pal = btn->palette(); |
2681 | pal.setColor(QColorGroup::Button, | 2681 | pal.setColor(QColorGroup::Button, |
2682 | *customBtnColorList.at(idx)); | 2682 | *customBtnColorList.at(idx)); |
2683 | btn->setPalette(pal); | 2683 | btn->setPalette(pal); |
2684 | /* | 2684 | /* |
2685 | if(customBtnIconList.at(idx) != NULL){ | 2685 | if(customBtnIconList.at(idx) != NULL){ |
2686 | QPixmap *pix = customBtnIconList.at(idx); | 2686 | QPixmap *pix = customBtnIconList.at(idx); |
2687 | btn->setIconSet(QIconSet(*pix)); | 2687 | btn->setIconSet(QIconSet(*pix)); |
2688 | }*/ | 2688 | }*/ |
2689 | break; | 2689 | break; |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | void LiquidStyle::unapplyCustomAttributes(QPushButton *btn) | 2694 | void LiquidStyle::unapplyCustomAttributes(QPushButton *btn) |
2695 | { | 2695 | { |
2696 | return; // TODO | 2696 | return; // TODO |
2697 | QString str = btn->text(); | 2697 | QString str = btn->text(); |
2698 | if(str.isEmpty()) | 2698 | if(str.isEmpty()) |
2699 | return; | 2699 | return; |
2700 | while(str.contains('&') != 0) | 2700 | while(str.contains('&') != 0) |
2701 | str = str.remove(str.find('&'), 1); | 2701 | str = str.remove(str.find('&'), 1); |
2702 | 2702 | ||
2703 | const char *s; | 2703 | const char *s; |
2704 | for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){ | 2704 | for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){ |
2705 | if(qstricmp(s, str.latin1()) == 0){ | 2705 | if(qstricmp(s, str.latin1()) == 0){ |
2706 | btn->setPalette(QApplication::palette()); | 2706 | btn->setPalette(QApplication::palette()); |
2707 | btn->setIconSet(QIconSet()); | 2707 | btn->setIconSet(QIconSet()); |
2708 | break; | 2708 | break; |
2709 | } | 2709 | } |
2710 | } | 2710 | } |
2711 | } | 2711 | } |
2712 | 2712 | ||
2713 | // #include "liquid.moc" | 2713 | // #include "liquid.moc" |
2714 | 2714 | ||
2715 | 2715 | ||
2716 | 2716 | ||
2717 | 2717 | ||
2718 | 2718 | ||
2719 | 2719 | ||
2720 | /* vim: set noet sw=8 ts=8: */ | 2720 | /* vim: set noet sw=8 ts=8: */ |