32 #include <tqapplication.h> 34 #include <tqmetaobject.h> 35 #include <tqcleanuphandler.h> 38 #include <tqlistview.h> 39 #include <tqmenubar.h> 40 #include <tqpainter.h> 42 #include <tqpopupmenu.h> 43 #include <tqprogressbar.h> 44 #include <tqscrollbar.h> 45 #include <tqsettings.h> 47 #include <tqstylefactory.h> 49 #include <tqtoolbar.h> 53 #include <kpixmapeffect.h> 54 #include <kimageeffect.h> 57 # include <X11/Xlib.h> 59 # include <X11/extensions/Xrender.h> 60 extern bool qt_use_xrender;
66 #ifdef HAVE_XCOMPOSITE 67 #include <X11/extensions/Xrender.h> 68 #include <X11/extensions/Xcomposite.h> 77 enum TransparencyEngine {
85 struct ShadowElements {
89 typedef TQMap<const TQWidget*,ShadowElements> ShadowMap;
90 static ShadowMap *_shadowMap = 0;
91 TQSingleCleanupHandler<ShadowMap> cleanupShadowMap;
92 ShadowMap &shadowMap() {
94 _shadowMap =
new ShadowMap;
95 cleanupShadowMap.set( &_shadowMap );
103 const double top_right_corner[16] =
104 { 0.949, 0.965, 0.980, 0.992,
105 0.851, 0.890, 0.945, 0.980,
106 0.706, 0.780, 0.890, 0.960,
107 0.608, 0.706, 0.851, 0.949 };
109 const double bottom_right_corner[16] =
110 { 0.608, 0.706, 0.851, 0.949,
111 0.706, 0.780, 0.890, 0.960,
112 0.851, 0.890, 0.945, 0.980,
113 0.949, 0.965, 0.980, 0.992 };
115 const double bottom_left_corner[16] =
116 { 0.949, 0.851, 0.706, 0.608,
117 0.965, 0.890, 0.780, 0.706,
118 0.980, 0.945, 0.890, 0.851,
119 0.992, 0.980, 0.960, 0.949 };
121 const double shadow_strip[4] =
122 { 0.565, 0.675, 0.835, 0.945 };
124 static bool useDropShadow(TQWidget* w)
126 return w && w->metaObject() &&
127 w->metaObject()->findProperty(
"KStyleMenuDropShadow") != -1;
133 class TransparencyHandler :
public TQObject
136 TransparencyHandler(
KStyle* style, TransparencyEngine tEngine,
137 float menuOpacity,
bool useDropShadow);
138 ~TransparencyHandler();
139 bool eventFilter(TQObject*
object, TQEvent* event);
142 void blendToColor(
const TQColor &col);
143 void blendToPixmap(
const TQColorGroup &cg,
const TQWidget* p);
145 void XRenderBlendToPixmap(
const TQWidget* p);
147 bool haveX11RGBASupport();
148 TQImage handleRealAlpha(TQImage);
149 void createShadowWindows(
const TQWidget* p);
150 void removeShadowWindows(
const TQWidget* p);
151 void rightShadow(TQImage& dst);
152 void bottomShadow(TQImage& dst);
158 TransparencyEngine te;
165 bool useFilledFrameWorkaround : 1;
166 bool etchDisabledText : 1;
167 bool scrollablePopupmenus : 1;
168 bool menuAltKeyNavigation : 1;
169 bool menuDropShadow : 1;
170 bool sloppySubMenus : 1;
171 bool semiTransparentRubberband : 1;
175 TransparencyEngine transparencyEngine;
177 TransparencyHandler* menuHandler;
181 TQBitmap *verticalLine;
182 TQBitmap *horizontalLine;
189 : TQCommonStyle(), d(new KStylePrivate)
194 d->scrollbarType = sbtype;
195 d->highcolor = TQPixmap::defaultDepth() > 8;
199 d->popupMenuDelay = settings.readNumEntry (
"/KStyle/Settings/PopupMenuDelay", 256);
200 d->sloppySubMenus = settings.readBoolEntry(
"/KStyle/Settings/SloppySubMenus",
false);
201 d->etchDisabledText = settings.readBoolEntry(
"/KStyle/Settings/EtchDisabledText",
true);
202 d->menuAltKeyNavigation = settings.readBoolEntry(
"/KStyle/Settings/MenuAltKeyNavigation",
true);
203 d->scrollablePopupmenus = settings.readBoolEntry(
"/KStyle/Settings/ScrollablePopupMenus",
false);
204 d->menuDropShadow = settings.readBoolEntry(
"/KStyle/Settings/MenuDropShadow",
false);
205 d->semiTransparentRubberband = settings.readBoolEntry(
"/KStyle/Settings/SemiTransparentRubberband",
false);
206 d->menuHandler = NULL;
208 if (useMenuTransparency) {
209 TQString effectEngine = settings.readEntry(
"/KStyle/Settings/MenuTransparencyEngine",
"Disabled");
212 if (effectEngine ==
"XRender")
213 d->transparencyEngine = XRender;
215 if (effectEngine ==
"XRender")
216 d->transparencyEngine = SoftwareBlend;
218 else if (effectEngine ==
"SoftwareBlend")
219 d->transparencyEngine = SoftwareBlend;
220 else if (effectEngine ==
"SoftwareTint")
221 d->transparencyEngine = SoftwareTint;
223 d->transparencyEngine = Disabled;
225 if (d->transparencyEngine != Disabled) {
227 d->menuOpacity = settings.readDoubleEntry(
"/KStyle/Settings/MenuOpacity", 0.90);
228 d->menuHandler =
new TransparencyHandler(
this, d->transparencyEngine,
229 d->menuOpacity, d->menuDropShadow);
234 d->horizontalLine = 0;
237 if (!d->menuHandler && d->menuDropShadow)
238 d->menuHandler =
new TransparencyHandler(
this, Disabled, 1.0, d->menuDropShadow);
244 delete d->verticalLine;
245 delete d->horizontalLine;
247 delete d->menuHandler;
249 d->menuHandler = NULL;
256 if (TQPixmap::defaultDepth() > 8)
257 return TQString(
"plastik");
259 return TQString(
"light, 3rd revision");
262 void KStyle::polish( TQWidget* widget )
264 if ( d->useFilledFrameWorkaround )
266 if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
267 TQFrame::Shape shape = frame->frameShape();
268 if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
269 widget->installEventFilter(
this);
272 if (widget->isTopLevel())
274 if (!d->menuHandler && useDropShadow(widget))
275 d->menuHandler =
new TransparencyHandler(
this, Disabled, 1.0,
false);
277 if (d->menuHandler && useDropShadow(widget))
278 widget->installEventFilter(d->menuHandler);
283 void KStyle::unPolish( TQWidget* widget )
285 if ( d->useFilledFrameWorkaround )
287 if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
288 TQFrame::Shape shape = frame->frameShape();
289 if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
290 widget->removeEventFilter(
this);
293 if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
294 widget->removeEventFilter(d->menuHandler);
299 void KStyle::polishPopupMenu( TQPopupMenu* p )
301 if (!p->testWState( WState_Polished ))
302 p->setCheckable(
true);
305 if ( d->menuHandler &&
306 (strcmp(p->name(),
"tear off menu") != 0))
307 p->installEventFilter(d->menuHandler);
317 d->scrollbarType = sbtype;
326 const TQPopupMenu* )
const 328 pix.fill(cg.button());
334 const TQWidget* widget,
336 const TQColorGroup &cg,
338 const TQStyleOption& )
const 345 case KPE_DockWindowHandle: {
348 TQWidget* wid =
const_cast<TQWidget*
>(widget);
349 bool horizontal = flags & Style_Horizontal;
352 r.rect( &x, &y, &w, &h );
353 if ((w <= 2) || (h <= 2)) {
354 p->fillRect(r, cg.highlight());
363 fnt = TQApplication::font(wid);
364 fnt.setPointSize( fnt.pointSize()-2 );
371 pix.resize( h-2, w-2 );
373 pix.resize( w-2, h-2 );
375 TQString title = wid->parentWidget()->caption();
378 p2.fillRect(pix.rect(), cg.brush(TQColorGroup::Highlight));
379 p2.setPen(cg.highlightedText());
381 p2.drawText(pix.rect(), AlignCenter, title);
385 p->setPen(cg.dark());
386 p->drawLine(x, y, x2, y);
387 p->drawLine(x, y, x, y2);
388 p->setPen(cg.light());
389 p->drawLine(x+1, y2, x2, y2);
390 p->drawLine(x2, y+1, x2, y2);
395 TQPixmap vpix = pix.xForm(m);
396 bitBlt(wid, r.x()+1, r.y()+1, &vpix);
398 bitBlt(wid, r.x()+1, r.y()+1, &pix);
410 case KPE_ListViewExpander: {
412 int radius = (r.width() - 4) / 2;
413 int centerx = r.x() + r.width()/2;
414 int centery = r.y() + r.height()/2;
417 p->setPen( cg.mid() );
421 p->setPen( cg.text() );
422 p->drawLine( centerx - radius, centery, centerx + radius, centery );
423 if ( flags & Style_On )
424 p->drawLine( centerx, centery - radius, centerx, centery + radius );
428 case KPE_ListViewBranch: {
432 if ( !d->verticalLine )
436 d->verticalLine =
new TQBitmap( 1, 129,
true );
437 d->horizontalLine =
new TQBitmap( 128, 1,
true );
438 TQPointArray a( 64 );
440 p2.begin( d->verticalLine );
443 for( i=0; i < 64; i++ )
444 a.setPoint( i, 0, i*2+1 );
448 TQApplication::flushX();
449 d->verticalLine->setMask( *d->verticalLine );
451 p2.begin( d->horizontalLine );
452 for( i=0; i < 64; i++ )
453 a.setPoint( i, i*2+1, 0 );
457 TQApplication::flushX();
458 d->horizontalLine->setMask( *d->horizontalLine );
461 p->setPen( cg.text() );
463 if (flags & Style_Horizontal)
467 int end = r.x()+r.width();
468 int thickness = r.height();
475 p->drawPixmap( point, other, *d->horizontalLine, 0, 0, i, thickness );
482 int end = r.y()+r.height();
483 int thickness = r.width();
484 int pixmapoffset = (flags & Style_NoChange) ? 0 : 1;
491 p->drawPixmap( other, point, *d->verticalLine, 0, pixmapoffset, thickness, i );
501 case KPE_ToolBarHandle:
502 case KPE_GeneralHandle:
503 case KPE_SliderHandle:
504 p->fillRect(r, cg.light());
507 case KPE_SliderGroove:
508 p->fillRect(r, cg.dark());
512 p->fillRect(r, Qt::yellow);
518 int KStyle::kPixelMetric( KStylePixelMetric kpm,
const TQWidget* )
const 523 case KPM_ListViewBranchThickness:
527 case KPM_MenuItemSeparatorHeight:
528 case KPM_MenuItemHMargin:
529 case KPM_MenuItemVMargin:
530 case KPM_MenuItemHFrame:
531 case KPM_MenuItemVFrame:
532 case KPM_MenuItemCheckMarkHMargin:
533 case KPM_MenuItemArrowHMargin:
534 case KPM_MenuItemTabSpacing:
564 void KStyle::tqdrawPrimitive( TQ_PrimitiveElement pe,
567 const TQColorGroup &cg,
569 const TQStyleOption& opt )
const 573 if (pe == PE_DockWindowHandle)
576 TQWidget *widget, *parent;
578 if (p && p->device()->devType() == TQInternal::Widget) {
579 widget =
static_cast<TQWidget*
>(p->device());
580 parent = widget->parentWidget();
586 (parent->inherits(TQTOOLBAR_OBJECT_NAME_STRING) ||
587 (parent->inherits(TQMAINWINDOW_OBJECT_NAME_STRING)) ))
592 else if ( widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) )
600 #if QT_VERSION >= 0x030300 602 }
else if ( d->semiTransparentRubberband && pe == TQStyle::PE_RubberBand ) {
603 TQRect rect = r.normalize();
605 point = p->xForm( point );
607 static XRenderColor clr = { 0, 0, 0, 0 };
608 static unsigned long fillColor = 0;
609 if ( fillColor != cg.highlight().rgb() ) {
610 fillColor = cg.highlight().rgb();
612 unsigned long color = fillColor << 8 | 0x40;
614 int red = (color >> 24) & 0xff;
615 int green = (color >> 16) & 0xff;
616 int blue = (color >> 8) & 0xff;
617 int alpha = (color >> 0) & 0xff;
619 red = red * alpha / 255;
620 green = green * alpha / 255;
621 blue = blue * alpha / 255;
623 clr.red = (red << 8) + red;
624 clr.green = (green << 8) + green;
625 clr.blue = (blue << 8) + blue;
626 clr.alpha = (alpha << 8) + alpha;
629 XRenderFillRectangle(
630 p->device()->x11Display(),
632 p->device()->x11RenderHandle(),
634 rect.x() + point.x(),
635 rect.y() + point.y(),
640 p->setRasterOp( TQt::CopyROP );
641 p->setPen( TQPen( cg.highlight().dark( 160 ), 1 ) );
642 p->setBrush( NoBrush );
644 rect.x() + point.x(),
645 rect.y() + point.y(),
652 TQCommonStyle::tqdrawPrimitive( pe, p, r, cg, flags, opt );
657 void KStyle::drawControl( TQ_ControlElement element,
659 const TQWidget* widget,
661 const TQColorGroup &cg,
663 const TQStyleOption &opt )
const 670 const TQTabBar* tb = (
const TQTabBar*) widget;
671 TQTabBar::Shape tbs = tb->shape();
672 bool selected = flags & Style_Selected;
673 int x = r.x(), y=r.y(), bottom=r.bottom(), right=r.right();
677 case TQTabBar::RoundedAbove: {
680 p->setPen(selected ? cg.light() : cg.shadow());
681 p->drawLine(x, y+4, x, bottom);
682 p->drawLine(x, y+4, x+4, y);
683 p->drawLine(x+4, y, right-1, y);
685 p->setPen(cg.shadow());
686 p->drawLine(right, y+1, right, bottom);
688 p->setPen(cg.midlight());
689 p->drawLine(x+1, y+4, x+1, bottom);
690 p->drawLine(x+1, y+4, x+4, y+1);
691 p->drawLine(x+5, y+1, right-2, y+1);
695 p->drawLine(right-1, y+1, right-1, bottom);
698 p->drawPoint(right-1, y+1);
699 p->drawLine(x+4, y+2, right-1, y+2);
700 p->drawLine(x+3, y+3, right-1, y+3);
701 p->fillRect(x+2, y+4, r.width()-3, r.height()-6, cg.mid());
703 p->setPen(cg.light());
704 p->drawLine(x, bottom-1, right, bottom-1);
710 case TQTabBar::RoundedBelow: {
713 p->setPen(selected ? cg.light() : cg.shadow());
714 p->drawLine(x, bottom-4, x, y);
717 p->drawLine(x, bottom-4, x+4, bottom);
719 p->setPen(cg.shadow());
720 p->drawLine(x+4, bottom, right-1, bottom);
721 p->drawLine(right, bottom-1, right, y);
723 p->setPen(cg.midlight());
724 p->drawLine(x+1, bottom-4, x+1, y);
725 p->drawLine(x+1, bottom-4, x+4, bottom-1);
726 p->drawLine(x+5, bottom-1, right-2, bottom-1);
730 p->drawLine(right-1, y, right-1, bottom-1);
733 p->drawPoint(right-1, bottom-1);
734 p->drawLine(x+4, bottom-2, right-1, bottom-2);
735 p->drawLine(x+3, bottom-3, right-1, bottom-3);
736 p->fillRect(x+2, y+2, r.width()-3, r.height()-6, cg.mid());
738 p->setPen(cg.dark());
739 p->drawLine(x, y, right, y);
744 case TQTabBar::TriangularAbove: {
747 p->setPen(selected ? cg.light() : cg.shadow());
748 p->drawLine(x, bottom, x, y+6);
749 p->drawLine(x, y+6, x+6, y);
750 p->drawLine(x+6, y, right-6, y);
753 p->drawLine(right-5, y+1, right-1, y+5);
754 p->setPen(cg.shadow());
755 p->drawLine(right, y+6, right, bottom);
757 p->setPen(cg.midlight());
758 p->drawLine(x+1, bottom, x+1, y+6);
759 p->drawLine(x+1, y+6, x+6, y+1);
760 p->drawLine(x+6, y+1, right-6, y+1);
761 p->drawLine(right-5, y+2, right-2, y+5);
763 p->drawLine(right-1, y+6, right-1, bottom);
766 a.setPoint(0, x+2, bottom);
767 a.setPoint(1, x+2, y+7);
768 a.setPoint(2, x+7, y+2);
769 a.setPoint(3, right-7, y+2);
770 a.setPoint(4, right-2, y+7);
771 a.setPoint(5, right-2, bottom);
772 p->setPen (selected ? cg.background() : cg.mid());
773 p->setBrush(selected ? cg.background() : cg.mid());
775 p->setBrush(NoBrush);
778 p->setPen(cg.light());
779 p->drawLine(x, bottom, right, bottom);
787 p->setPen(selected ? cg.light() : cg.shadow());
788 p->drawLine(x, y, x, bottom-6);
791 p->drawLine(x, bottom-6, x+6, bottom);
793 p->setPen(cg.shadow());
794 p->drawLine(x+6, bottom, right-6, bottom);
795 p->drawLine(right-5, bottom-1, right-1, bottom-5);
797 p->setPen(cg.shadow());
798 p->drawLine(right, bottom-6, right, y);
800 p->setPen(cg.midlight());
801 p->drawLine(x+1, y, x+1, bottom-6);
802 p->drawLine(x+1, bottom-6, x+6, bottom-1);
803 p->drawLine(x+6, bottom-1, right-6, bottom-1);
804 p->drawLine(right-5, bottom-2, right-2, bottom-5);
806 p->drawLine(right-1, bottom-6, right-1, y);
809 a.setPoint(0, x+2, y);
810 a.setPoint(1, x+2, bottom-7);
811 a.setPoint(2, x+7, bottom-2);
812 a.setPoint(3, right-7, bottom-2);
813 a.setPoint(4, right-2, bottom-7);
814 a.setPoint(5, right-2, y);
815 p->setPen (selected ? cg.background() : cg.mid());
816 p->setBrush(selected ? cg.background() : cg.mid());
818 p->setBrush(NoBrush);
821 p->setPen(cg.dark());
822 p->drawLine(x, y, right, y);
833 case CE_PopupMenuScroller: {
834 p->fillRect(r, cg.background());
835 tqdrawPrimitive(PE_ButtonTool, p, r, cg, Style_Enabled);
836 tqdrawPrimitive((flags & Style_Up) ? PE_ArrowUp : PE_ArrowDown, p, r, cg, Style_Enabled);
843 case CE_ProgressBarGroove: {
844 TQRect fr = subRect(SR_ProgressBarGroove, widget);
845 tqdrawPrimitive(PE_Panel, p, fr, cg, Style_Sunken, TQStyleOption::SO_Default);
849 case CE_ProgressBarContents: {
851 const TQProgressBar* pb = (
const TQProgressBar*)widget;
852 TQRect cr = subRect(SR_ProgressBarContents, widget);
853 double progress = pb->progress();
854 bool reverse = TQApplication::reverseLayout();
855 int steps = pb->totalSteps();
861 if (progress > 0 || steps == 0) {
862 double pg = (steps == 0) ? 0.1 : progress / steps;
863 int width = QMIN(cr.width(), (int)(pg * cr.width()));
866 if (width < 1) width = 1;
868 int remWidth = cr.width() - width;
869 if (remWidth <= 0) remWidth = 1;
871 int pstep = int(progress) % ( 2 * remWidth );
873 if ( pstep > remWidth ) {
876 pstep = - (pstep - 2 * remWidth );
880 p->fillRect(cr.x() + cr.width() - width - pstep, cr.y(), width, cr.height(),
881 cg.brush(TQColorGroup::Highlight));
883 p->fillRect(cr.x() + pstep, cr.y(), width, cr.height(),
884 cg.brush(TQColorGroup::Highlight));
892 TQColor c(cg.highlight());
894 pix.resize(cr.width(), cr.height());
896 reverse ? c.dark(150) : c.light(150),
897 KPixmapEffect::HorizontalGradient);
899 p->drawPixmap(cr.x()+(cr.width()-width), cr.y(), pix,
900 cr.width()-width, 0, width, cr.height());
902 p->drawPixmap(cr.x(), cr.y(), pix, 0, 0, width, cr.height());
905 p->fillRect(cr.x()+(cr.width()-width), cr.y(), width, cr.height(),
906 cg.brush(TQColorGroup::Highlight));
908 p->fillRect(cr.x(), cr.y(), width, cr.height(),
909 cg.brush(TQColorGroup::Highlight));
914 case CE_ProgressBarLabel: {
915 const TQProgressBar* pb = (
const TQProgressBar*)widget;
916 TQRect cr = subRect(SR_ProgressBarContents, widget);
917 double progress = pb->progress();
918 bool reverse = TQApplication::reverseLayout();
919 int steps = pb->totalSteps();
924 TQFont font = p->font();
929 if (progress > 0 || steps == 0) {
930 double pg = (steps == 0) ? 1.0 : progress / steps;
931 int width = QMIN(cr.width(), (int)(pg * cr.width()));
934 crect.setRect(cr.x()+(cr.width()-width), cr.y(), cr.width(), cr.height());
936 crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height());
939 p->setPen(pb->isEnabled() ? (reverse ? cg.text() : cg.highlightedText()) : cg.text());
940 p->drawText(r, AlignCenter, pb->progressString());
941 p->setClipRect(crect);
942 p->setPen(reverse ? cg.highlightedText() : cg.text());
943 p->drawText(r, AlignCenter, pb->progressString());
947 p->setPen(cg.text());
948 p->drawText(r, AlignCenter, pb->progressString());
955 TQCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
960 TQRect KStyle::subRect(SubRect r,
const TQWidget* widget)
const 966 case SR_ProgressBarGroove:
967 return widget->rect();
969 case SR_ProgressBarContents:
970 case SR_ProgressBarLabel: {
972 TQRect rt = widget->rect();
973 return TQRect(rt.x()+2, rt.y()+2, rt.width()-4, rt.height()-4);
977 return TQCommonStyle::subRect(r, widget);
982 int KStyle::pixelMetric(PixelMetric m,
const TQWidget* widget)
const 988 case PM_ButtonShiftHorizontal:
989 case PM_ButtonShiftVertical:
992 case PM_DockWindowHandleExtent:
994 TQWidget* parent = 0;
997 if (widget && (parent = widget->parentWidget() )
998 && !parent->inherits(TQTOOLBAR_OBJECT_NAME_STRING)
999 && !parent->inherits(TQMAINWINDOW_OBJECT_NAME_STRING)
1000 && widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) )
1001 return widget->fontMetrics().lineSpacing();
1003 return TQCommonStyle::pixelMetric(m, widget);
1008 case PM_TabBarTabHSpace:
1011 case PM_TabBarTabVSpace: {
1012 const TQTabBar * tb = (
const TQTabBar *) widget;
1013 if ( tb->shape() == TQTabBar::RoundedAbove ||
1014 tb->shape() == TQTabBar::RoundedBelow )
1020 case PM_TabBarTabOverlap: {
1021 const TQTabBar* tb = (
const TQTabBar*)widget;
1022 TQTabBar::Shape tbs = tb->shape();
1024 if ( (tbs == TQTabBar::RoundedAbove) ||
1025 (tbs == TQTabBar::RoundedBelow) )
1033 case PM_SliderLength:
1036 case PM_SliderThickness:
1041 case PM_SliderControlThickness: {
1042 const TQSlider* slider = (
const TQSlider*)widget;
1043 TQSlider::TickSetting ts = slider->tickmarks();
1044 int thickness = (slider->orientation() == Qt::Horizontal) ?
1045 slider->height() : slider->width();
1047 case TQSlider::NoMarks:
1049 case TQSlider::Both:
1050 thickness = (thickness/2) + 3;
1053 thickness = ((thickness*2)/3) + 3;
1061 case PM_SplitterWidth:
1062 if (widget && widget->inherits(
"QDockWindowResizeHandle"))
1069 case PM_MenuBarFrameWidth:
1072 case PM_DockWindowFrameWidth:
1077 case PM_MaximumDragDistance:
1080 case PM_MenuBarItemSpacing:
1083 case PM_ToolBarItemSpacing:
1086 case PM_PopupMenuScrollerHeight:
1087 return pixelMetric( PM_ScrollBarExtent, 0);
1090 return TQCommonStyle::pixelMetric( m, widget );
1095 static TQListViewItem* nextVisibleSibling(TQListViewItem* item)
1097 TQListViewItem* sibling = item;
1100 sibling = sibling->nextSibling();
1102 while (sibling && !sibling->isVisible());
1107 void KStyle::drawComplexControl( TQ_ComplexControl control,
1109 const TQWidget* widget,
1111 const TQColorGroup &cg,
1115 const TQStyleOption &opt )
const 1121 case CC_ScrollBar: {
1125 const TQScrollBar *sb = (
const TQScrollBar*)widget;
1126 bool maxedOut = (sb->minValue() == sb->maxValue());
1127 bool horizontal = (sb->orientation() == Qt::Horizontal);
1128 SFlags sflags = ((horizontal ? Style_Horizontal : Style_Default) |
1129 (maxedOut ? Style_Default : Style_Enabled));
1131 TQRect addline, subline, subline2, addpage, subpage, slider, first, last;
1132 subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt);
1133 addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt);
1134 subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt);
1135 addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt);
1136 slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt);
1137 first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt);
1138 last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt);
1141 if ( useThreeButtonScrollBar )
1143 subline2.moveBy(-addline.width(), 0);
1145 subline2.moveBy(0, -addline.height());
1148 if ((controls & SC_ScrollBarSubLine) && subline.isValid()) {
1149 tqdrawPrimitive(PE_ScrollBarSubLine, p, subline, cg,
1150 sflags | (active == SC_ScrollBarSubLine ?
1151 Style_Down : Style_Default));
1153 if (useThreeButtonScrollBar && subline2.isValid())
1154 tqdrawPrimitive(PE_ScrollBarSubLine, p, subline2, cg,
1155 sflags | (active == SC_ScrollBarSubLine ?
1156 Style_Down : Style_Default));
1159 if ((controls & SC_ScrollBarAddLine) && addline.isValid())
1160 tqdrawPrimitive(PE_ScrollBarAddLine, p, addline, cg,
1161 sflags | ((active == SC_ScrollBarAddLine) ?
1162 Style_Down : Style_Default));
1164 if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
1165 tqdrawPrimitive(PE_ScrollBarSubPage, p, subpage, cg,
1166 sflags | ((active == SC_ScrollBarSubPage) ?
1167 Style_Down : Style_Default));
1169 if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
1170 tqdrawPrimitive(PE_ScrollBarAddPage, p, addpage, cg,
1171 sflags | ((active == SC_ScrollBarAddPage) ?
1172 Style_Down : Style_Default));
1174 if ((controls & SC_ScrollBarFirst) && first.isValid())
1175 tqdrawPrimitive(PE_ScrollBarFirst, p, first, cg,
1176 sflags | ((active == SC_ScrollBarFirst) ?
1177 Style_Down : Style_Default));
1179 if ((controls & SC_ScrollBarLast) && last.isValid())
1180 tqdrawPrimitive(PE_ScrollBarLast, p, last, cg,
1181 sflags | ((active == SC_ScrollBarLast) ?
1182 Style_Down : Style_Default));
1184 if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
1185 tqdrawPrimitive(PE_ScrollBarSlider, p, slider, cg,
1186 sflags | ((active == SC_ScrollBarSlider) ?
1187 Style_Down : Style_Default));
1189 if (sb->hasFocus()) {
1190 TQRect fr(slider.x() + 2, slider.y() + 2,
1191 slider.width() - 5, slider.height() - 5);
1192 tqdrawPrimitive(PE_FocusRect, p, fr, cg, Style_Default);
1202 const TQSlider* slider = (
const TQSlider*)widget;
1203 TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt);
1204 TQRect handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt);
1207 TQPixmap pix(widget->size());
1211 if ( slider->parentWidget() &&
1212 slider->parentWidget()->backgroundPixmap() &&
1213 !slider->parentWidget()->backgroundPixmap()->isNull() ) {
1214 TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap());
1215 p2.drawTiledPixmap(r, pixmap, slider->pos());
1217 pix.fill(cg.background());
1220 if ((controls & SC_SliderGroove) && groove.isValid()) {
1224 if (slider->hasFocus())
1225 tqdrawPrimitive(PE_FocusRect, &p2, groove, cg);
1229 if (controls & SC_SliderTickmarks)
1230 TQCommonStyle::drawComplexControl(control, &p2, widget,
1231 r, cg, flags, SC_SliderTickmarks, active, opt);
1234 if ((controls & SC_SliderHandle) && handle.isValid()) {
1235 if (active == SC_SliderHandle)
1236 flags |= Style_Active;
1241 bitBlt((TQWidget*)widget, r.x(), r.y(), &pix);
1255 if ( controls & SC_ListView )
1256 TQCommonStyle::drawComplexControl( control, p, widget, r, cg, flags, controls, active, opt );
1259 if ( controls & (SC_ListViewBranch | SC_ListViewExpand) )
1262 if (opt.isDefault())
1265 TQListViewItem *item = opt.listViewItem();
1266 TQListViewItem *child = item->firstChild();
1271 TQPointArray dotlines;
1273 if ( active == SC_All && controls == SC_ListViewExpand ) {
1277 dotlines[0] = TQPoint( r.right(), r.top() );
1278 dotlines[1] = TQPoint( r.right(), r.bottom() );
1282 int linetop = 0, linebot = 0;
1284 dotoffset = (item->itemPos() + item->height() - y) % 2;
1285 dotlines.resize( item->childCount() * 4 );
1289 while ( child && y + child->height() <= 0 )
1291 y += child->totalHeight();
1292 child = nextVisibleSibling(child);
1295 int bx = r.width() / 2;
1298 TQListView* v = item->listView();
1299 int lh = QMAX( p->fontMetrics().height() + 2 * v->itemMargin(),
1300 TQApplication::globalStrut().height() );
1306 TQStyle::StyleFlags boxflags;
1307 while ( child && y < r.height() )
1310 if ( (child->isExpandable() || child->childCount()) &&
1311 (child->height() > 0) )
1314 boxrect = TQRect( bx-4, linebot-4, 9, 9 );
1315 boxflags = child->isOpen() ? TQStyle::Style_Off : TQStyle::Style_On;
1321 p->setPen( cg.mid() );
1322 dotlines[c++] = TQPoint( bx, linetop );
1323 dotlines[c++] = TQPoint( bx, linebot - 5 );
1324 dotlines[c++] = TQPoint( bx + 5, linebot );
1325 dotlines[c++] = TQPoint( r.width(), linebot );
1326 linetop = linebot + 5;
1329 dotlines[c++] = TQPoint( bx+1, linebot );
1330 dotlines[c++] = TQPoint( r.width(), linebot );
1333 y += child->totalHeight();
1334 child = nextVisibleSibling(child);
1338 linebot = r.height();
1340 if ( linetop < linebot )
1342 dotlines[c++] = TQPoint( bx, linetop );
1343 dotlines[c++] = TQPoint( bx, linebot );
1348 static int thickness = kPixelMetric( KPM_ListViewBranchThickness );
1351 TQStyle::StyleFlags branchflags;
1352 for( line = 0; line < c; line += 2 )
1361 if ( dotlines[line].y() == dotlines[line+1].y() )
1364 int end = dotlines[line+1].x();
1365 int point = dotlines[line].x();
1366 int other = dotlines[line].y();
1368 branchrect = TQRect( point, other-(thickness/2), end-point, thickness );
1369 branchflags = TQStyle::Style_Horizontal;
1376 int end = dotlines[line+1].y();
1377 int point = dotlines[line].y();
1378 int other = dotlines[line].x();
1379 int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
1381 branchrect = TQRect( other-(thickness/2), point, thickness, end-point );
1383 branchflags = TQStyle::Style_NoChange;
1385 branchflags = TQStyle::Style_Default;
1396 TQCommonStyle::drawComplexControl( control, p, widget, r, cg,
1397 flags, controls, active, opt );
1403 TQStyle::SubControl KStyle::querySubControl( TQ_ComplexControl control,
1404 const TQWidget* widget,
1406 const TQStyleOption &opt )
const 1408 TQStyle::SubControl ret = TQCommonStyle::querySubControl(control, widget, pos, opt);
1412 if (control == CC_ScrollBar && ret == SC_None)
1413 ret = SC_ScrollBarSubLine;
1419 TQRect KStyle::querySubControlMetrics( TQ_ComplexControl control,
1420 const TQWidget* widget,
1422 const TQStyleOption &opt )
const 1426 if (control == CC_ScrollBar)
1432 const TQScrollBar *sb = (
const TQScrollBar*)widget;
1433 bool horizontal = sb->orientation() == Qt::Horizontal;
1434 int sliderstart = sb->sliderStart();
1435 int sbextent = pixelMetric(PM_ScrollBarExtent, widget);
1436 int maxlen = (horizontal ? sb->width() : sb->height())
1437 - (sbextent * (threeButtonScrollBar ? 3 : 2));
1441 if (sb->maxValue() != sb->minValue())
1443 uint range = sb->maxValue() - sb->minValue();
1444 sliderlen = (sb->pageStep() * maxlen) / (range + sb->pageStep());
1446 int slidermin = pixelMetric( PM_ScrollBarSliderMin, widget );
1447 if ( sliderlen < slidermin || range > INT_MAX / 2 )
1448 sliderlen = slidermin;
1449 if ( sliderlen > maxlen )
1457 case SC_ScrollBarSubLine: {
1459 if (platinumScrollBar) {
1461 ret.setRect(sb->width() - 2 * sbextent, 0, sbextent, sbextent);
1463 ret.setRect(0, sb->height() - 2 * sbextent, sbextent, sbextent);
1465 ret.setRect(0, 0, sbextent, sbextent);
1469 case SC_ScrollBarAddLine: {
1471 if (nextScrollBar) {
1473 ret.setRect(sbextent, 0, sbextent, sbextent);
1475 ret.setRect(0, sbextent, sbextent, sbextent);
1478 ret.setRect(sb->width() - sbextent, 0, sbextent, sbextent);
1480 ret.setRect(0, sb->height() - sbextent, sbextent, sbextent);
1485 case SC_ScrollBarSubPage: {
1487 if (platinumScrollBar) {
1489 ret.setRect(0, 0, sliderstart, sbextent);
1491 ret.setRect(0, 0, sbextent, sliderstart);
1492 }
else if (nextScrollBar) {
1494 ret.setRect(sbextent*2, 0, sliderstart-2*sbextent, sbextent);
1496 ret.setRect(0, sbextent*2, sbextent, sliderstart-2*sbextent);
1499 ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent);
1501 ret.setRect(0, sbextent, sbextent, sliderstart - sbextent);
1506 case SC_ScrollBarAddPage: {
1510 if (platinumScrollBar)
1512 else if (nextScrollBar)
1518 ret.setRect(sliderstart + sliderlen, 0,
1519 maxlen - sliderstart - sliderlen + fudge, sbextent);
1521 ret.setRect(0, sliderstart + sliderlen, sbextent,
1522 maxlen - sliderstart - sliderlen + fudge);
1526 case SC_ScrollBarGroove: {
1527 int multi = threeButtonScrollBar ? 3 : 2;
1530 if (platinumScrollBar)
1532 else if (nextScrollBar)
1538 ret.setRect(fudge, 0, sb->width() - sbextent * multi, sb->height());
1540 ret.setRect(0, fudge, sb->width(), sb->height() - sbextent * multi);
1544 case SC_ScrollBarSlider: {
1546 ret.setRect(sliderstart, 0, sliderlen, sbextent);
1548 ret.setRect(0, sliderstart, sbextent, sliderlen);
1553 ret = TQCommonStyle::querySubControlMetrics(control, widget, sc, opt);
1557 ret = TQCommonStyle::querySubControlMetrics(control, widget, sc, opt);
1562 static const char *
const kstyle_close_xpm[] = {
1579 static const char *
const kstyle_maximize_xpm[]={
1597 static const char *
const kstyle_minimize_xpm[] = {
1614 static const char *
const kstyle_normalizeup_xpm[] = {
1632 static const char *
const kstyle_shade_xpm[] = {
1649 static const char *
const kstyle_unshade_xpm[] = {
1666 static const char *
const dock_window_close_xpm[] = {
1686 static const char *
const information_xpm[]={
1693 "...........********.............",
1694 "........***aaaaaaaa***..........",
1695 "......**aaaaaaaaaaaaaa**........",
1696 ".....*aaaaaaaaaaaaaaaaaa*.......",
1697 "....*aaaaaaaabbbbaaaaaaaac......",
1698 "...*aaaaaaaabbbbbbaaaaaaaac.....",
1699 "..*aaaaaaaaabbbbbbaaaaaaaaac....",
1700 ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
1701 ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
1702 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
1703 "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
1704 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1705 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1706 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1707 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1708 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1709 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1710 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1711 "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
1712 "...caaaaaaabbbbbbbbbaaaaaac****.",
1713 "....caaaaaaaaaaaaaaaaaaaac****..",
1714 ".....caaaaaaaaaaaaaaaaaac****...",
1715 "......ccaaaaaaaaaaaaaacc****....",
1716 ".......*cccaaaaaaaaccc*****.....",
1717 "........***cccaaaac*******......",
1718 "..........****caaac*****........",
1719 ".............*caaac**...........",
1720 "...............caac**...........",
1721 "................cac**...........",
1722 ".................cc**...........",
1723 "..................***...........",
1724 "...................**..........."};
1726 static const char*
const warning_xpm[]={
1732 ".............***................",
1733 "............*aaa*...............",
1734 "...........*aaaaa*b.............",
1735 "...........*aaaaa*bb............",
1736 "..........*aaaaaaa*bb...........",
1737 "..........*aaaaaaa*bb...........",
1738 ".........*aaaaaaaaa*bb..........",
1739 ".........*aaaaaaaaa*bb..........",
1740 "........*aaaaaaaaaaa*bb.........",
1741 "........*aaaa***aaaa*bb.........",
1742 ".......*aaaa*****aaaa*bb........",
1743 ".......*aaaa*****aaaa*bb........",
1744 "......*aaaaa*****aaaaa*bb.......",
1745 "......*aaaaa*****aaaaa*bb.......",
1746 ".....*aaaaaa*****aaaaaa*bb......",
1747 ".....*aaaaaa*****aaaaaa*bb......",
1748 "....*aaaaaaaa***aaaaaaaa*bb.....",
1749 "....*aaaaaaaa***aaaaaaaa*bb.....",
1750 "...*aaaaaaaaa***aaaaaaaaa*bb....",
1751 "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
1752 "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
1753 "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
1754 ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
1755 ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
1756 "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
1757 "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
1758 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1759 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1760 ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
1761 "..*************************bbbbb",
1762 "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
1763 ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
1765 static const char*
const critical_xpm[]={
1771 "...........********.............",
1772 ".........************...........",
1773 ".......****************.........",
1774 "......******************........",
1775 ".....********************a......",
1776 "....**********************a.....",
1777 "...************************a....",
1778 "..*******b**********b*******a...",
1779 "..******bbb********bbb******a...",
1780 ".******bbbbb******bbbbb******a..",
1781 ".*******bbbbb****bbbbb*******a..",
1782 "*********bbbbb**bbbbb*********a.",
1783 "**********bbbbbbbbbb**********a.",
1784 "***********bbbbbbbb***********aa",
1785 "************bbbbbb************aa",
1786 "************bbbbbb************aa",
1787 "***********bbbbbbbb***********aa",
1788 "**********bbbbbbbbbb**********aa",
1789 "*********bbbbb**bbbbb*********aa",
1790 ".*******bbbbb****bbbbb*******aa.",
1791 ".******bbbbb******bbbbb******aa.",
1792 "..******bbb********bbb******aaa.",
1793 "..*******b**********b*******aa..",
1794 "...************************aaa..",
1795 "....**********************aaa...",
1796 "....a********************aaa....",
1797 ".....a******************aaa.....",
1798 "......a****************aaa......",
1799 ".......aa************aaaa.......",
1800 ".........aa********aaaaa........",
1801 "...........aaaaaaaaaaa..........",
1802 ".............aaaaaaa............"};
1804 TQPixmap KStyle::stylePixmap( StylePixmap stylepixmap,
1805 const TQWidget* widget,
1806 const TQStyleOption& opt)
const 1808 switch (stylepixmap) {
1809 case SP_TitleBarShadeButton:
1810 return TQPixmap(const_cast<const char**>(kstyle_shade_xpm));
1811 case SP_TitleBarUnshadeButton:
1812 return TQPixmap(const_cast<const char**>(kstyle_unshade_xpm));
1813 case SP_TitleBarNormalButton:
1814 return TQPixmap(const_cast<const char**>(kstyle_normalizeup_xpm));
1815 case SP_TitleBarMinButton:
1816 return TQPixmap(const_cast<const char**>(kstyle_minimize_xpm));
1817 case SP_TitleBarMaxButton:
1818 return TQPixmap(const_cast<const char**>(kstyle_maximize_xpm));
1819 case SP_TitleBarCloseButton:
1820 return TQPixmap(const_cast<const char**>(kstyle_close_xpm));
1821 case SP_DockWindowCloseButton:
1822 return TQPixmap(const_cast<const char**>(dock_window_close_xpm ));
1823 case SP_MessageBoxInformation:
1824 return TQPixmap(const_cast<const char**>(information_xpm));
1825 case SP_MessageBoxWarning:
1826 return TQPixmap(const_cast<const char**>(warning_xpm));
1827 case SP_MessageBoxCritical:
1828 return TQPixmap(const_cast<const char**>(critical_xpm));
1832 return TQCommonStyle::stylePixmap(stylepixmap, widget, opt);
1836 int KStyle::styleHint( TQ_StyleHint sh,
const TQWidget* w,
1837 const TQStyleOption &opt, TQStyleHintReturn* shr)
const 1841 case SH_EtchDisabledText:
1842 return d->etchDisabledText ? 1 : 0;
1844 case SH_PopupMenu_Scrollable:
1845 return d->scrollablePopupmenus ? 1 : 0;
1847 case SH_MenuBar_AltKeyNavigation:
1848 return d->menuAltKeyNavigation ? 1 : 0;
1850 case SH_PopupMenu_SubMenuPopupDelay:
1851 if ( styleHint( SH_PopupMenu_SloppySubMenus, w ) )
1852 return QMIN( 100, d->popupMenuDelay );
1854 return d->popupMenuDelay;
1856 case SH_PopupMenu_SloppySubMenus:
1857 return d->sloppySubMenus;
1859 case SH_ItemView_ChangeHighlightOnFocus:
1860 case SH_Slider_SloppyKeyEvents:
1861 case SH_MainWindow_SpaceBelowMenuBar:
1862 case SH_PopupMenu_AllowActiveAndDisabled:
1865 case SH_Slider_SnapToValue:
1866 case SH_PrintDialog_RightAlignButtons:
1867 case SH_FontDialog_SelectAssociatedText:
1868 case SH_MenuBar_MouseTracking:
1869 case SH_PopupMenu_MouseTracking:
1870 case SH_ComboBox_ListMouseTracking:
1871 case SH_ScrollBar_MiddleClickAbsolutePosition:
1873 case SH_LineEdit_PasswordCharacter:
1876 const TQFontMetrics &fm = w->fontMetrics();
1877 if (fm.inFont(TQChar(0x25CF))) {
1879 }
else if (fm.inFont(TQChar(0x2022))) {
1887 return TQCommonStyle::styleHint(sh, w, opt, shr);
1892 bool KStyle::eventFilter( TQObject*
object, TQEvent* event )
1894 if ( d->useFilledFrameWorkaround )
1904 if ( event->type() == TQEvent::Paint
1905 && (frame = ::tqqt_cast<TQFrame*>(object)) )
1907 if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel)
1910 bool horizontal =
true;
1911 TQPaintEvent* pe = (TQPaintEvent*)event;
1912 TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame );
1913 TQRect r = pe->rect();
1915 if (toolbar && toolbar->orientation() == Qt::Vertical)
1919 if ( r.height() == frame->height() )
1923 TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) );
1924 TQApplication::sendEvent( frame, &dummyPE );
1927 if ( r.width() == frame->width() )
1930 TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) );
1931 TQApplication::sendEvent( frame, &dummyPE );
1947 TransparencyHandler::TransparencyHandler(
KStyle* style,
1948 TransparencyEngine tEngine,
float menuOpacity,
bool useDropShadow )
1953 opacity = menuOpacity;
1954 dropShadow = useDropShadow;
1955 pix.setOptimization(TQPixmap::BestOptim);
1958 TransparencyHandler::~TransparencyHandler()
1962 bool TransparencyHandler::haveX11RGBASupport()
1965 if (TQPaintDevice::x11AppDepth() == 32) {
1973 #define REAL_ALPHA_STRENGTH 255.0 1976 void TransparencyHandler::rightShadow(TQImage& dst)
1978 bool have_composite = haveX11RGBASupport();
1980 if (dst.depth() != 32)
1981 dst = dst.convertDepth(32);
1984 int pixels = dst.width() * dst.height();
1985 #ifdef WORDS_BIGENDIAN 1986 unsigned char* data = dst.bits() + 1;
1988 unsigned char* data = dst.bits();
1990 for(
int i = 0; i < 16; i++) {
1991 if (have_composite) {
1995 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-top_right_corner[i])); data++;
1998 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
1999 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
2000 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
2007 for(
int i = 0; i < pixels; i++) {
2008 if (have_composite) {
2012 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-shadow_strip[c])); data++;
2015 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2016 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2017 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2025 for(
int i = 0; i < 16; i++) {
2026 if (have_composite) {
2030 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-bottom_right_corner[i])); data++;
2033 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2034 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2035 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2041 void TransparencyHandler::bottomShadow(TQImage& dst)
2043 bool have_composite = haveX11RGBASupport();
2045 if (dst.depth() != 32)
2046 dst = dst.convertDepth(32);
2049 int width = dst.width() - 4;
2050 double strip_data = shadow_strip[0];
2051 double* corner =
const_cast<double*
>(bottom_left_corner);
2053 #ifdef WORDS_BIGENDIAN 2054 unsigned char* data = dst.bits() + 1;
2056 unsigned char* data = dst.bits();
2059 for(
int y = 0; y < 4; y++)
2062 for(
int x = 0; x < 4; x++) {
2063 if (have_composite) {
2067 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-(*corner))); data++;
2070 *data = (
unsigned char)((*data)*(*corner)); data++;
2071 *data = (
unsigned char)((*data)*(*corner)); data++;
2072 *data = (
unsigned char)((*data)*(*corner)); data++;
2079 for(
int x = 0; x < width; x++) {
2080 if (have_composite) {
2084 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-strip_data)); data++;
2087 *data = (
unsigned char)((*data)*strip_data); data++;
2088 *data = (
unsigned char)((*data)*strip_data); data++;
2089 *data = (
unsigned char)((*data)*strip_data); data++;
2094 strip_data = shadow_strip[line++];
2098 TQImage TransparencyHandler::handleRealAlpha(TQImage img) {
2099 TQImage clearImage = img.convertDepth(32);
2100 clearImage.setAlphaBuffer(
true);
2102 int w = clearImage.width();
2103 int h = clearImage.height();
2105 for (
int y = 0; y < h; ++y) {
2106 TQRgb *ls = (TQRgb *)clearImage.scanLine( y );
2107 for (
int x = 0; x < w; ++x) {
2109 ls[x] = tqRgba( 0, 0, 0, 0 );
2117 void TransparencyHandler::createShadowWindows(
const TQWidget* p)
2120 int x2 = p->x()+p->width();
2121 int y2 = p->y()+p->height();
2122 TQRect shadow1(x2, p->y() + 4, 4, p->height());
2123 TQRect shadow2(p->x() + 4, y2, p->width() - 4, 4);
2125 bool have_composite = haveX11RGBASupport();
2129 se.w1 =
new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) );
2130 se.w2 =
new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) );
2131 se.w1->setGeometry(shadow1);
2132 se.w2->setGeometry(shadow2);
2133 XSelectInput(qt_xdisplay(), se.w1->winId(), StructureNotifyMask );
2134 XSelectInput(qt_xdisplay(), se.w2->winId(), StructureNotifyMask );
2137 shadowMap()[p] = se;
2140 TQPixmap pix_shadow1;
2141 TQPixmap pix_shadow2;
2142 if (have_composite) {
2143 pix_shadow1 = TQPixmap(shadow1.width(), shadow1.height());
2144 pix_shadow2 = TQPixmap(shadow2.width(), shadow2.height());
2147 pix_shadow1 = TQPixmap::grabWindow(qt_xrootwin(),
2148 shadow1.x(), shadow1.y(), shadow1.width(), shadow1.height());
2149 pix_shadow2 = TQPixmap::grabWindow(qt_xrootwin(),
2150 shadow2.x(), shadow2.y(), shadow2.width(), shadow2.height());
2154 img = pix_shadow1.convertToImage();
2155 if (have_composite) img = handleRealAlpha(img);
2157 pix_shadow1.convertFromImage(img);
2158 img = pix_shadow2.convertToImage();
2159 if (have_composite) img = handleRealAlpha(img);
2161 pix_shadow2.convertFromImage(img);
2164 se.w1->setErasePixmap(pix_shadow1);
2165 se.w2->setErasePixmap(pix_shadow2);
2169 XMapWindow(qt_xdisplay(), se.w1->winId());
2170 XMapWindow(qt_xdisplay(), se.w2->winId());
2176 void TransparencyHandler::removeShadowWindows(
const TQWidget* p)
2179 ShadowMap::iterator it = shadowMap().find(p);
2180 if (it != shadowMap().end())
2182 ShadowElements se = it.data();
2183 XUnmapWindow(qt_xdisplay(), se.w1->winId());
2184 XUnmapWindow(qt_xdisplay(), se.w2->winId());
2185 XFlush(qt_xdisplay());
2188 shadowMap().erase(it);
2195 bool TransparencyHandler::eventFilter( TQObject*
object, TQEvent* event )
2197 #if !defined Q_WS_MAC && !defined Q_WS_WIN 2202 TQWidget* p = (TQWidget*)
object;
2203 TQEvent::Type et =
event->type();
2205 if (et == TQEvent::Show)
2210 pix = TQPixmap::grabWindow(qt_xrootwin(),
2211 p->x(), p->y(), p->width(), p->height());
2216 if (qt_use_xrender) {
2217 XRenderBlendToPixmap(p);
2225 blendToPixmap(p->colorGroup(), p);
2230 blendToColor(p->colorGroup().button());
2233 p->setErasePixmap(pix);
2241 if ((dropShadow || useDropShadow(p))
2242 && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
2243 createShadowWindows(p);
2245 else if (et == TQEvent::Resize && p->isShown() && p->isTopLevel())
2248 if (dropShadow || useDropShadow(p))
2250 removeShadowWindows(p);
2251 createShadowWindows(p);
2254 else if (et == TQEvent::Hide)
2257 if (dropShadow || useDropShadow(p))
2258 removeShadowWindows(p);
2262 p->setErasePixmap(TQPixmap());
2271 void TransparencyHandler::blendToColor(
const TQColor &col)
2273 if (opacity < 0.0 || opacity > 1.0)
2276 TQImage img = pix.convertToImage();
2278 pix.convertFromImage(img);
2282 void TransparencyHandler::blendToPixmap(
const TQColorGroup &cg,
const TQWidget* p)
2284 if (opacity < 0.0 || opacity > 1.0)
2288 blendPix.resize( pix.width(), pix.height() );
2290 if (blendPix.width() != pix.width() ||
2291 blendPix.height() != pix.height())
2295 if (::tqqt_cast<TQPopupMenu*>(p))
2296 kstyle->renderMenuBlendPixmap( blendPix, cg, ::tqqt_cast<TQPopupMenu*>(p) );
2298 blendPix.fill(cg.button());
2300 TQImage blendImg = blendPix.convertToImage();
2301 TQImage backImg = pix.convertToImage();
2303 pix.convertFromImage(backImg);
2311 void TransparencyHandler::XRenderBlendToPixmap(
const TQWidget* p)
2314 renderPix.resize( pix.width(), pix.height() );
2317 if (::tqqt_cast<TQPopupMenu*>(p))
2318 kstyle->renderMenuBlendPixmap( renderPix, p->colorGroup(),
2319 ::tqqt_cast<TQPopupMenu*>(p) );
2321 renderPix.fill(p->colorGroup().button());
2323 Display* dpy = qt_xdisplay();
2325 Picture alphaPicture;
2326 XRenderPictFormat Rpf;
2327 XRenderPictureAttributes Rpa;
2329 clr.alpha = ((
unsigned short)(255*opacity) << 8);
2331 Rpf.type = PictTypeDirect;
2333 Rpf.direct.alphaMask = 0xff;
2336 XRenderPictFormat* xformat = XRenderFindFormat(dpy,
2337 PictFormatType | PictFormatDepth | PictFormatAlphaMask, &Rpf, 0);
2339 alphaPixmap = XCreatePixmap(dpy, p->handle(), 1, 1, 8);
2340 alphaPicture = XRenderCreatePicture(dpy, alphaPixmap, xformat, CPRepeat, &Rpa);
2342 XRenderFillRectangle(dpy, PictOpSrc, alphaPicture, &clr, 0, 0, 1, 1);
2344 XRenderComposite(dpy, PictOpOver,
2345 renderPix.x11RenderHandle(), alphaPicture, pix.x11RenderHandle(),
2349 pix.width(), pix.height());
2351 XRenderFreePicture(dpy, alphaPicture);
2352 XFreePixmap(dpy, alphaPixmap);
2356 void KStyle::virtual_hook(
int,
void* )
2361 extern "C" KDE_EXPORT
2362 void kde_kstyle_set_scrollbar_type_windows(
void* style )
2370 #include "kstyle.moc" KStyleFlags styleFlags() const
Returns the KStyle flags used to initialize the style.
KStyleScrollBarType
KStyle ScrollBarType:
uint KStyleFlags
KStyle Flags:
Off-screen paint device with extended features.
~KStyle()
Destructs the KStyle object.
static TQString defaultStyle()
Returns the default widget style depending on color depth.
static KPixmap & gradient(KPixmap &pixmap, const TQColor &ca, const TQColor &cb, GradientType type, int ncols=3)
Creates a gradient from color a to color b of the specified type.
virtual void renderMenuBlendPixmap(KPixmap &pix, const TQColorGroup &cg, const TQPopupMenu *popup) const
This virtual function defines the pixmap used to blend between the popup menu and the background to c...
void setScrollBarType(KStyleScrollBarType sbtype)
Modifies the scrollbar type used by the style.
KStyle(KStyleFlags flags=KStyle::Default, KStyleScrollBarType sbtype=KStyle::WindowsStyleScrollBar)
Constructs a KStyle object.
Simplifies and extends the TQStyle API to make style coding easier.
KStylePrimitive
KStyle Primitive Elements:
two button, platinum style
two button, windows style
Internal transparency enabled.
static TQImage & blend(const TQColor &clr, TQImage &dst, float opacity)
Blends a color into the destination image, using an opacity value for blending one into another...
virtual void drawKStylePrimitive(KStylePrimitive kpe, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags flags=Style_Default, const TQStyleOption &=TQStyleOption::SO_Default) const
This function is identical to Qt's TQStyle::tqdrawPrimitive(), except that it adds one further parame...