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 tqt_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(
"TDEStyleMenuDropShadow") != -1;
133 class TransparencyHandler :
public TQObject
136 TransparencyHandler(
TDEStyle* 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;
162 struct TDEStylePrivate
165 bool useFilledFrameWorkaround : 1;
166 bool etchDisabledText : 1;
167 bool scrollablePopupmenus : 1;
168 bool autoHideAccelerators : 1;
169 bool menuAltKeyNavigation : 1;
170 bool menuDropShadow : 1;
171 bool sloppySubMenus : 1;
172 bool semiTransparentRubberband : 1;
176 TransparencyEngine transparencyEngine;
178 TransparencyHandler* menuHandler;
182 TQBitmap *verticalLine;
183 TQBitmap *horizontalLine;
190 : TQCommonStyle(), d(new TDEStylePrivate)
195 d->scrollbarType = sbtype;
196 d->highcolor = TQPixmap::defaultDepth() > 8;
200 d->popupMenuDelay = settings.readNumEntry (
"/TDEStyle/Settings/PopupMenuDelay", 250);
201 d->sloppySubMenus = settings.readBoolEntry(
"/TDEStyle/Settings/SloppySubMenus",
false);
202 d->etchDisabledText = settings.readBoolEntry(
"/TDEStyle/Settings/EtchDisabledText",
true);
203 d->menuAltKeyNavigation = settings.readBoolEntry(
"/TDEStyle/Settings/MenuAltKeyNavigation",
true);
204 d->scrollablePopupmenus = settings.readBoolEntry(
"/TDEStyle/Settings/ScrollablePopupMenus",
false);
205 d->autoHideAccelerators = settings.readBoolEntry(
"/TDEStyle/Settings/AutoHideAccelerators",
false);
206 d->menuDropShadow = settings.readBoolEntry(
"/TDEStyle/Settings/MenuDropShadow",
false);
207 d->semiTransparentRubberband = settings.readBoolEntry(
"/TDEStyle/Settings/SemiTransparentRubberband",
false);
208 d->menuHandler = NULL;
210 if (useMenuTransparency) {
211 TQString effectEngine = settings.readEntry(
"/TDEStyle/Settings/MenuTransparencyEngine",
"Disabled");
214 if (effectEngine ==
"XRender")
215 d->transparencyEngine = XRender;
217 if (effectEngine ==
"XRender")
218 d->transparencyEngine = SoftwareBlend;
220 else if (effectEngine ==
"SoftwareBlend")
221 d->transparencyEngine = SoftwareBlend;
222 else if (effectEngine ==
"SoftwareTint")
223 d->transparencyEngine = SoftwareTint;
225 d->transparencyEngine = Disabled;
227 if (d->transparencyEngine != Disabled) {
229 d->menuOpacity = settings.readDoubleEntry(
"/TDEStyle/Settings/MenuOpacity", 0.90);
230 d->menuHandler =
new TransparencyHandler(
this, d->transparencyEngine,
231 d->menuOpacity, d->menuDropShadow);
236 d->horizontalLine = 0;
239 if (!d->menuHandler && d->menuDropShadow)
240 d->menuHandler =
new TransparencyHandler(
this, Disabled, 1.0, d->menuDropShadow);
246 delete d->verticalLine;
247 delete d->horizontalLine;
249 delete d->menuHandler;
251 d->menuHandler = NULL;
258 if (TQPixmap::defaultDepth() > 8)
259 return TQString(
"plastik");
261 return TQString(
"light, 3rd revision");
264 void TDEStyle::polish(
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
void *ptr )
266 if (ceData.widgetObjectTypes.contains(
"TQWidget")) {
267 TQWidget* widget =
reinterpret_cast<TQWidget*
>(ptr);
268 if ( d->useFilledFrameWorkaround )
270 if ( TQFrame *frame = ::tqt_cast< TQFrame* >( widget ) ) {
271 TQFrame::Shape shape = frame->frameShape();
272 if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
273 widget->installEventFilter(
this);
276 if (widget->isTopLevel())
278 if (!d->menuHandler && useDropShadow(widget))
279 d->menuHandler =
new TransparencyHandler(
this, Disabled, 1.0,
false);
281 if (d->menuHandler && useDropShadow(widget))
282 widget->installEventFilter(d->menuHandler);
288 void TDEStyle::unPolish(
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
void *ptr )
290 if (ceData.widgetObjectTypes.contains(
"TQWidget")) {
291 TQWidget* widget =
reinterpret_cast<TQWidget*
>(ptr);
292 if ( d->useFilledFrameWorkaround )
294 if ( TQFrame *frame = ::tqt_cast< TQFrame* >( widget ) ) {
295 TQFrame::Shape shape = frame->frameShape();
296 if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
297 widget->removeEventFilter(
this);
300 if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
301 widget->removeEventFilter(d->menuHandler);
307 void TDEStyle::polishPopupMenu(
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
void *ptr )
309 if ( !(ceData.windowState & WState_Polished ) ) {
310 widgetActionRequest(ceData, elementFlags, ptr, WAR_SetCheckable);
313 if (ceData.widgetObjectTypes.contains(
"TQWidget")) {
314 TQWidget* widget =
reinterpret_cast<TQWidget*
>(ptr);
315 TQPopupMenu *p =
dynamic_cast<TQPopupMenu*
>(widget);
318 if ( d->menuHandler && (strcmp(p->name(),
"tear off menu") != 0)) {
319 p->installEventFilter(d->menuHandler);
332 d->scrollbarType = sbtype;
341 const TQPopupMenu* )
const
343 pix.fill(cg.button());
346 void TDEStyle::drawTDEStylePrimitive( TDEStylePrimitive kpe,
348 const TQWidget* widget,
350 const TQColorGroup &cg,
352 const TQStyleOption &opt )
const
354 const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption());
355 drawTDEStylePrimitive(kpe, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, cg, flags, opt);
360 const TQStyleControlElementData &ceData,
361 ControlElementFlags elementFlags,
363 const TQColorGroup &cg,
365 const TQStyleOption&,
366 const TQWidget* widget )
const
373 case KPE_DockWindowHandle: {
376 TQWidget* wid =
const_cast<TQWidget*
>(widget);
377 bool horizontal = flags & Style_Horizontal;
380 r.rect( &x, &y, &w, &h );
381 if ((w <= 2) || (h <= 2)) {
382 p->fillRect(r, cg.highlight());
391 fnt = TQApplication::font(wid);
392 fnt.setPointSize( fnt.pointSize()-2 );
399 pix.resize( h-2, w-2 );
401 pix.resize( w-2, h-2 );
403 TQString title = wid->parentWidget()->caption();
406 p2.fillRect(pix.rect(), cg.brush(TQColorGroup::Highlight));
407 p2.setPen(cg.highlightedText());
409 p2.drawText(pix.rect(), AlignCenter, title);
413 p->setPen(cg.dark());
414 p->drawLine(x, y, x2, y);
415 p->drawLine(x, y, x, y2);
416 p->setPen(cg.light());
417 p->drawLine(x+1, y2, x2, y2);
418 p->drawLine(x2, y+1, x2, y2);
423 TQPixmap vpix = pix.xForm(m);
424 bitBlt(wid, r.x()+1, r.y()+1, &vpix);
426 bitBlt(wid, r.x()+1, r.y()+1, &pix);
438 case KPE_ListViewExpander: {
440 int radius = (r.width() - 4) / 2;
441 int centerx = r.x() + r.width()/2;
442 int centery = r.y() + r.height()/2;
445 p->setPen( cg.mid() );
449 p->setPen( cg.text() );
450 p->drawLine( centerx - radius, centery, centerx + radius, centery );
451 if ( flags & Style_On )
452 p->drawLine( centerx, centery - radius, centerx, centery + radius );
456 case KPE_ListViewBranch: {
460 if ( !d->verticalLine )
464 d->verticalLine =
new TQBitmap( 1, 129,
true );
465 d->horizontalLine =
new TQBitmap( 128, 1,
true );
466 TQPointArray a( 64 );
468 p2.begin( d->verticalLine );
471 for( i=0; i < 64; i++ )
472 a.setPoint( i, 0, i*2+1 );
476 TQApplication::flushX();
477 d->verticalLine->setMask( *d->verticalLine );
479 p2.begin( d->horizontalLine );
480 for( i=0; i < 64; i++ )
481 a.setPoint( i, i*2+1, 0 );
485 TQApplication::flushX();
486 d->horizontalLine->setMask( *d->horizontalLine );
489 p->setPen( cg.text() );
491 if (flags & Style_Horizontal)
495 int end = r.x()+r.width();
496 int thickness = r.height();
503 p->drawPixmap( point, other, *d->horizontalLine, 0, 0, i, thickness );
510 int end = r.y()+r.height();
511 int thickness = r.width();
512 int pixmapoffset = (flags & Style_NoChange) ? 0 : 1;
519 p->drawPixmap( other, point, *d->verticalLine, 0, pixmapoffset, thickness, i );
529 case KPE_ToolBarHandle:
530 case KPE_GeneralHandle:
531 case KPE_SliderHandle:
532 p->fillRect(r, cg.light());
535 case KPE_SliderGroove:
536 p->fillRect(r, cg.dark());
540 p->fillRect(r, TQt::yellow);
546 int TDEStyle::kPixelMetric( TDEStylePixelMetric kpm,
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
const TQWidget* )
const
551 case KPM_ListViewBranchThickness:
555 case KPM_MenuItemSeparatorHeight:
556 case KPM_MenuItemHMargin:
557 case KPM_MenuItemVMargin:
558 case KPM_MenuItemHFrame:
559 case KPM_MenuItemVFrame:
560 case KPM_MenuItemCheckMarkHMargin:
561 case KPM_MenuItemArrowHMargin:
562 case KPM_MenuItemTabSpacing:
572 void TDEStyle::drawPrimitive( PrimitiveElement pe,
574 const TQStyleControlElementData &ceData,
575 ControlElementFlags elementFlags,
577 const TQColorGroup &cg,
579 const TQStyleOption& opt )
const
583 if (pe == PE_DockWindowHandle)
586 TQWidget *widget, *parent;
588 if (p && p->device()->devType() == TQInternal::Widget) {
589 widget =
static_cast<TQWidget*
>(p->device());
590 parent = widget->parentWidget();
596 (parent->inherits(
"TQToolBar") ||
597 (parent->inherits(
"TQMainWindow")) ))
600 drawTDEStylePrimitive( KPE_ToolBarHandle, p, ceData, elementFlags, r, cg, flags, opt, widget );
602 else if (ceData.widgetObjectTypes.contains(
"TQDockWindowHandle"))
605 drawTDEStylePrimitive( KPE_DockWindowHandle, p, ceData, elementFlags, r, cg, flags, opt, widget );
609 drawTDEStylePrimitive( KPE_GeneralHandle, p, ceData, elementFlags, r, cg, flags, opt, widget );
610 #if TQT_VERSION >= 0x030300
612 }
else if ( d->semiTransparentRubberband && pe == TQStyle::PE_RubberBand ) {
613 TQRect rect = r.normalize();
615 point = p->xForm( point );
617 static XRenderColor clr = { 0, 0, 0, 0 };
618 static unsigned long fillColor = 0;
619 if ( fillColor != cg.highlight().rgb() ) {
620 fillColor = cg.highlight().rgb();
622 unsigned long color = fillColor << 8 | 0x40;
624 int red = (color >> 24) & 0xff;
625 int green = (color >> 16) & 0xff;
626 int blue = (color >> 8) & 0xff;
627 int alpha = (color >> 0) & 0xff;
629 red = red * alpha / 255;
630 green = green * alpha / 255;
631 blue = blue * alpha / 255;
633 clr.red = (red << 8) + red;
634 clr.green = (green << 8) + green;
635 clr.blue = (blue << 8) + blue;
636 clr.alpha = (alpha << 8) + alpha;
639 XRenderFillRectangle(
640 p->device()->x11Display(),
642 p->device()->x11RenderHandle(),
644 rect.x() + point.x(),
645 rect.y() + point.y(),
650 p->setRasterOp( TQt::CopyROP );
651 p->setPen( TQPen( cg.highlight().dark( 160 ), 1 ) );
652 p->setBrush( NoBrush );
654 rect.x() + point.x(),
655 rect.y() + point.y(),
662 TQCommonStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
667 void TDEStyle::drawControl( ControlElement element,
669 const TQStyleControlElementData &ceData,
670 ControlElementFlags elementFlags,
672 const TQColorGroup &cg,
674 const TQStyleOption &opt,
675 const TQWidget* widget )
const
682 TQTabBar::Shape tbs = ceData.tabBarData.shape;
683 bool selected = flags & Style_Selected;
684 int x = r.x(), y=r.y(), bottom=r.bottom(), right=r.right();
688 case TQTabBar::RoundedAbove: {
691 p->setPen(selected ? cg.light() : cg.shadow());
692 p->drawLine(x, y+4, x, bottom);
693 p->drawLine(x, y+4, x+4, y);
694 p->drawLine(x+4, y, right-1, y);
696 p->setPen(cg.shadow());
697 p->drawLine(right, y+1, right, bottom);
699 p->setPen(cg.midlight());
700 p->drawLine(x+1, y+4, x+1, bottom);
701 p->drawLine(x+1, y+4, x+4, y+1);
702 p->drawLine(x+5, y+1, right-2, y+1);
706 p->drawLine(right-1, y+1, right-1, bottom);
709 p->drawPoint(right-1, y+1);
710 p->drawLine(x+4, y+2, right-1, y+2);
711 p->drawLine(x+3, y+3, right-1, y+3);
712 p->fillRect(x+2, y+4, r.width()-3, r.height()-6, cg.mid());
714 p->setPen(cg.light());
715 p->drawLine(x, bottom-1, right, bottom-1);
721 case TQTabBar::RoundedBelow: {
724 p->setPen(selected ? cg.light() : cg.shadow());
725 p->drawLine(x, bottom-4, x, y);
728 p->drawLine(x, bottom-4, x+4, bottom);
730 p->setPen(cg.shadow());
731 p->drawLine(x+4, bottom, right-1, bottom);
732 p->drawLine(right, bottom-1, right, y);
734 p->setPen(cg.midlight());
735 p->drawLine(x+1, bottom-4, x+1, y);
736 p->drawLine(x+1, bottom-4, x+4, bottom-1);
737 p->drawLine(x+5, bottom-1, right-2, bottom-1);
741 p->drawLine(right-1, y, right-1, bottom-1);
744 p->drawPoint(right-1, bottom-1);
745 p->drawLine(x+4, bottom-2, right-1, bottom-2);
746 p->drawLine(x+3, bottom-3, right-1, bottom-3);
747 p->fillRect(x+2, y+2, r.width()-3, r.height()-6, cg.mid());
749 p->setPen(cg.dark());
750 p->drawLine(x, y, right, y);
755 case TQTabBar::TriangularAbove: {
758 p->setPen(selected ? cg.light() : cg.shadow());
759 p->drawLine(x, bottom, x, y+6);
760 p->drawLine(x, y+6, x+6, y);
761 p->drawLine(x+6, y, right-6, y);
764 p->drawLine(right-5, y+1, right-1, y+5);
765 p->setPen(cg.shadow());
766 p->drawLine(right, y+6, right, bottom);
768 p->setPen(cg.midlight());
769 p->drawLine(x+1, bottom, x+1, y+6);
770 p->drawLine(x+1, y+6, x+6, y+1);
771 p->drawLine(x+6, y+1, right-6, y+1);
772 p->drawLine(right-5, y+2, right-2, y+5);
774 p->drawLine(right-1, y+6, right-1, bottom);
777 a.setPoint(0, x+2, bottom);
778 a.setPoint(1, x+2, y+7);
779 a.setPoint(2, x+7, y+2);
780 a.setPoint(3, right-7, y+2);
781 a.setPoint(4, right-2, y+7);
782 a.setPoint(5, right-2, bottom);
783 p->setPen (selected ? cg.background() : cg.mid());
784 p->setBrush(selected ? cg.background() : cg.mid());
786 p->setBrush(NoBrush);
789 p->setPen(cg.light());
790 p->drawLine(x, bottom, right, bottom);
798 p->setPen(selected ? cg.light() : cg.shadow());
799 p->drawLine(x, y, x, bottom-6);
802 p->drawLine(x, bottom-6, x+6, bottom);
804 p->setPen(cg.shadow());
805 p->drawLine(x+6, bottom, right-6, bottom);
806 p->drawLine(right-5, bottom-1, right-1, bottom-5);
808 p->setPen(cg.shadow());
809 p->drawLine(right, bottom-6, right, y);
811 p->setPen(cg.midlight());
812 p->drawLine(x+1, y, x+1, bottom-6);
813 p->drawLine(x+1, bottom-6, x+6, bottom-1);
814 p->drawLine(x+6, bottom-1, right-6, bottom-1);
815 p->drawLine(right-5, bottom-2, right-2, bottom-5);
817 p->drawLine(right-1, bottom-6, right-1, y);
820 a.setPoint(0, x+2, y);
821 a.setPoint(1, x+2, bottom-7);
822 a.setPoint(2, x+7, bottom-2);
823 a.setPoint(3, right-7, bottom-2);
824 a.setPoint(4, right-2, bottom-7);
825 a.setPoint(5, right-2, y);
826 p->setPen (selected ? cg.background() : cg.mid());
827 p->setBrush(selected ? cg.background() : cg.mid());
829 p->setBrush(NoBrush);
832 p->setPen(cg.dark());
833 p->drawLine(x, y, right, y);
844 case CE_PopupMenuScroller: {
845 p->fillRect(r, cg.background());
846 drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, r, cg, Style_Enabled);
847 drawPrimitive((flags & Style_Up) ? PE_ArrowUp : PE_ArrowDown, p, ceData, elementFlags, r, cg, Style_Enabled);
854 case CE_ProgressBarGroove: {
855 TQRect fr = subRect(SR_ProgressBarGroove, ceData, elementFlags, widget);
856 drawPrimitive(PE_Panel, p, ceData, elementFlags, fr, cg, Style_Sunken, TQStyleOption::Default);
860 case CE_ProgressBarContents: {
862 TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
863 double progress = ceData.currentStep;
864 bool reverse = TQApplication::reverseLayout();
865 int steps = ceData.totalSteps;
871 if (progress > 0 || steps == 0) {
872 double pg = (steps == 0) ? 0.1 : progress / steps;
873 int width = TQMIN(cr.width(), (
int)(pg * cr.width()));
876 if (width < 1) width = 1;
878 int remWidth = cr.width() - width;
879 if (remWidth <= 0) remWidth = 1;
881 int pstep = int(progress) % ( 2 * remWidth );
883 if ( pstep > remWidth ) {
886 pstep = - (pstep - 2 * remWidth );
890 p->fillRect(cr.x() + cr.width() - width - pstep, cr.y(), width, cr.height(),
891 cg.brush(TQColorGroup::Highlight));
893 p->fillRect(cr.x() + pstep, cr.y(), width, cr.height(),
894 cg.brush(TQColorGroup::Highlight));
902 TQColor c(cg.highlight());
904 pix.resize(cr.width(), cr.height());
906 reverse ? c.dark(150) : c.light(150),
907 KPixmapEffect::HorizontalGradient);
909 p->drawPixmap(cr.x()+(cr.width()-width), cr.y(), pix,
910 cr.width()-width, 0, width, cr.height());
912 p->drawPixmap(cr.x(), cr.y(), pix, 0, 0, width, cr.height());
915 p->fillRect(cr.x()+(cr.width()-width), cr.y(), width, cr.height(),
916 cg.brush(TQColorGroup::Highlight));
918 p->fillRect(cr.x(), cr.y(), width, cr.height(),
919 cg.brush(TQColorGroup::Highlight));
924 case CE_ProgressBarLabel: {
925 TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
926 double progress = ceData.currentStep;
927 bool reverse = TQApplication::reverseLayout();
928 int steps = ceData.totalSteps;
933 TQFont font = p->font();
938 if (progress > 0 || steps == 0) {
939 double pg = (steps == 0) ? 1.0 : progress / steps;
940 int width = TQMIN(cr.width(), (
int)(pg * cr.width()));
943 crect.setRect(cr.x()+(cr.width()-width), cr.y(), cr.width(), cr.height());
945 crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height());
948 p->setPen((elementFlags & CEF_IsEnabled) ? (reverse ? cg.text() : cg.highlightedText()) : cg.text());
949 p->drawText(r, AlignCenter, ceData.progressText);
950 p->setClipRect(crect);
951 p->setPen(reverse ? cg.highlightedText() : cg.text());
952 p->drawText(r, AlignCenter, ceData.progressText);
956 p->setPen(cg.text());
957 p->drawText(r, AlignCenter, ceData.progressText);
964 TQCommonStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
969 TQRect TDEStyle::subRect(SubRect r,
const TQStyleControlElementData &ceData,
const ControlElementFlags elementFlags,
const TQWidget* widget)
const
975 case SR_ProgressBarGroove:
978 case SR_ProgressBarContents:
979 case SR_ProgressBarLabel: {
981 TQRect rt = ceData.rect;
982 return TQRect(rt.x()+2, rt.y()+2, rt.width()-4, rt.height()-4);
986 return TQCommonStyle::subRect(r, ceData, elementFlags, widget);
991 int TDEStyle::pixelMetric(PixelMetric m,
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
const TQWidget* widget)
const
997 case PM_ButtonShiftHorizontal:
998 case PM_ButtonShiftVertical:
1001 case PM_DockWindowHandleExtent:
1006 && !(ceData.parentWidgetData.widgetObjectTypes.contains(
"TQToolBar"))
1007 && !(ceData.parentWidgetData.widgetObjectTypes.contains(
"TQMainWindow"))
1008 && (ceData.widgetObjectTypes.contains(
"TQDockWindowHandle")) )
1009 return widget->fontMetrics().lineSpacing();
1011 return TQCommonStyle::pixelMetric(m, ceData, elementFlags, widget);
1016 case PM_TabBarTabHSpace:
1019 case PM_TabBarTabVSpace: {
1020 if ( ceData.tabBarData.shape == TQTabBar::RoundedAbove ||
1021 ceData.tabBarData.shape == TQTabBar::RoundedBelow )
1027 case PM_TabBarTabOverlap: {
1028 TQTabBar::Shape tbs = ceData.tabBarData.shape;
1030 if ( (tbs == TQTabBar::RoundedAbove) ||
1031 (tbs == TQTabBar::RoundedBelow) )
1039 case PM_SliderLength:
1042 case PM_SliderThickness:
1047 case PM_SliderControlThickness: {
1048 TQSlider::TickSetting ts = (TQSlider::TickSetting)ceData.tickMarkSetting;
1049 int thickness = (ceData.orientation == TQt::Horizontal) ?
1050 ceData.rect.height() : ceData.rect.width();
1052 case TQSlider::NoMarks:
1054 case TQSlider::Both:
1055 thickness = (thickness/2) + 3;
1058 thickness = ((thickness*2)/3) + 3;
1066 case PM_SplitterWidth:
1067 if (ceData.widgetObjectTypes.contains(
"TQDockWindowResizeHandle"))
1074 case PM_MenuBarFrameWidth:
1077 case PM_DockWindowFrameWidth:
1082 case PM_MaximumDragDistance:
1085 case PM_MenuBarItemSpacing:
1088 case PM_ToolBarItemSpacing:
1091 case PM_PopupMenuScrollerHeight:
1092 return pixelMetric( PM_ScrollBarExtent, ceData, elementFlags, 0);
1095 return TQCommonStyle::pixelMetric( m, ceData, elementFlags, widget );
1100 static TQListViewItem* nextVisibleSibling(TQListViewItem* item)
1102 TQListViewItem* sibling = item;
1105 sibling = sibling->nextSibling();
1107 while (sibling && !sibling->isVisible());
1112 void TDEStyle::drawComplexControl( ComplexControl control,
1114 const TQStyleControlElementData &ceData,
1115 ControlElementFlags elementFlags,
1117 const TQColorGroup &cg,
1121 const TQStyleOption &opt,
1122 const TQWidget* widget )
const
1128 case CC_ScrollBar: {
1132 bool maxedOut = (ceData.minSteps == ceData.maxSteps);
1133 bool horizontal = (ceData.orientation == TQt::Horizontal);
1134 SFlags sflags = ((horizontal ? Style_Horizontal : Style_Default) |
1135 (maxedOut ? Style_Default : Style_Enabled));
1137 TQRect addline, subline, subline2, addpage, subpage, slider, first, last;
1138 subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, opt, widget);
1139 addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, opt, widget);
1140 subpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget);
1141 addpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget);
1142 slider = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSlider, opt, widget);
1143 first = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarFirst, opt, widget);
1144 last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, opt, widget);
1147 if ( useThreeButtonScrollBar ) {
1149 subline2.moveBy(-addline.width(), 0);
1152 subline2.moveBy(0, -addline.height());
1157 if ((controls & SC_ScrollBarSubLine) && subline.isValid()) {
1158 drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
1159 sflags | (active == SC_ScrollBarSubLine ?
1160 Style_Down : Style_Default));
1162 if (useThreeButtonScrollBar && subline2.isValid())
1163 drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg,
1164 sflags | (active == SC_ScrollBarSubLine ?
1165 Style_Down : Style_Default));
1168 if ((controls & SC_ScrollBarAddLine) && addline.isValid())
1169 drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
1170 sflags | ((active == SC_ScrollBarAddLine) ?
1171 Style_Down : Style_Default));
1173 if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
1174 drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg,
1175 sflags | ((active == SC_ScrollBarSubPage) ?
1176 Style_Down : Style_Default));
1178 if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
1179 drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg,
1180 sflags | ((active == SC_ScrollBarAddPage) ?
1181 Style_Down : Style_Default));
1183 if ((controls & SC_ScrollBarFirst) && first.isValid())
1184 drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg,
1185 sflags | ((active == SC_ScrollBarFirst) ?
1186 Style_Down : Style_Default));
1188 if ((controls & SC_ScrollBarLast) && last.isValid())
1189 drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg,
1190 sflags | ((active == SC_ScrollBarLast) ?
1191 Style_Down : Style_Default));
1193 if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
1194 drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
1195 sflags | ((active == SC_ScrollBarSlider) ?
1196 Style_Down : Style_Default));
1198 if (elementFlags & CEF_HasFocus) {
1199 TQRect fr(slider.x() + 2, slider.y() + 2,
1200 slider.width() - 5, slider.height() - 5);
1201 drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default);
1211 TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, opt, widget);
1212 TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, opt, widget);
1215 TQPixmap pix(ceData.rect.size());
1219 if ( (elementFlags & CEF_HasParentWidget) &&
1220 !ceData.parentWidgetData.bgPixmap.isNull() ) {
1221 TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
1222 p2.drawTiledPixmap(r, pixmap, ceData.pos);
1224 pix.fill(cg.background());
1227 if ((controls & SC_SliderGroove) && groove.isValid()) {
1228 drawTDEStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, flags, opt, widget );
1231 if (elementFlags & CEF_HasFocus) {
1232 drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg);
1237 if (controls & SC_SliderTickmarks)
1238 TQCommonStyle::drawComplexControl(control, &p2, ceData, elementFlags,
1239 r, cg, flags, SC_SliderTickmarks, active, opt, widget);
1242 if ((controls & SC_SliderHandle) && handle.isValid()) {
1243 if (active == SC_SliderHandle)
1244 flags |= Style_Active;
1245 drawTDEStylePrimitive( KPE_SliderHandle, &p2, ceData, elementFlags, handle, cg, flags, opt, widget );
1250 TQPaintDevice* ppd = p->device();
1251 if (ppd->isExtDev()) {
1252 p->drawPixmap(0, 0, pix);
1255 bitBlt((TQWidget*)widget, r.x(), r.y(), &pix);
1270 if ( controls & SC_ListView )
1271 TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
1274 if ( controls & (SC_ListViewBranch | SC_ListViewExpand) )
1277 if (opt.isDefault())
1280 TQListViewItem *item = opt.listViewItem();
1281 TQListViewItem *child = item->firstChild();
1286 TQPointArray dotlines;
1288 if ( active == SC_All && controls == SC_ListViewExpand ) {
1292 dotlines[0] = TQPoint( r.right(), r.top() );
1293 dotlines[1] = TQPoint( r.right(), r.bottom() );
1297 int linetop = 0, linebot = 0;
1299 dotoffset = (item->itemPos() + item->height() - y) % 2;
1300 dotlines.resize( item->childCount() * 4 );
1304 while ( child && y + child->height() <= 0 )
1306 y += child->totalHeight();
1307 child = nextVisibleSibling(child);
1310 int bx = r.width() / 2;
1313 TQListView* v = item->listView();
1314 int lh = TQMAX( p->fontMetrics().height() + 2 * v->itemMargin(),
1315 TQApplication::globalStrut().height() );
1321 TQStyle::StyleFlags boxflags;
1322 while ( child && y < r.height() )
1325 if ( (child->isExpandable() || child->childCount()) &&
1326 (child->height() > 0) )
1329 boxrect = TQRect( bx-4, linebot-4, 9, 9 );
1330 boxflags = child->isOpen() ? TQStyle::Style_Off : TQStyle::Style_On;
1333 drawTDEStylePrimitive( KPE_ListViewExpander, p, ceData, elementFlags, boxrect, cg, boxflags, opt, NULL );
1336 p->setPen( cg.mid() );
1337 dotlines[c++] = TQPoint( bx, linetop );
1338 dotlines[c++] = TQPoint( bx, linebot - 5 );
1339 dotlines[c++] = TQPoint( bx + 5, linebot );
1340 dotlines[c++] = TQPoint( r.width(), linebot );
1341 linetop = linebot + 5;
1344 dotlines[c++] = TQPoint( bx+1, linebot );
1345 dotlines[c++] = TQPoint( r.width(), linebot );
1348 y += child->totalHeight();
1349 child = nextVisibleSibling(child);
1353 linebot = r.height();
1355 if ( linetop < linebot )
1357 dotlines[c++] = TQPoint( bx, linetop );
1358 dotlines[c++] = TQPoint( bx, linebot );
1363 static int thickness = kPixelMetric( KPM_ListViewBranchThickness, ceData, elementFlags );
1366 TQStyle::StyleFlags branchflags;
1367 for( line = 0; line < c; line += 2 )
1376 if ( dotlines[line].y() == dotlines[line+1].y() )
1379 int end = dotlines[line+1].x();
1380 int point = dotlines[line].x();
1381 int other = dotlines[line].y();
1383 branchrect = TQRect( point, other-(thickness/2), end-point, thickness );
1384 branchflags = TQStyle::Style_Horizontal;
1387 drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL );
1391 int end = dotlines[line+1].y();
1392 int point = dotlines[line].y();
1393 int other = dotlines[line].x();
1394 int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
1396 branchrect = TQRect( other-(thickness/2), point, thickness, end-point );
1398 branchflags = TQStyle::Style_NoChange;
1400 branchflags = TQStyle::Style_Default;
1403 drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL );
1411 TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg,
1412 flags, controls, active, opt, widget );
1418 TQStyle::SubControl TDEStyle::querySubControl( ComplexControl control,
1419 const TQStyleControlElementData &ceData,
1420 ControlElementFlags elementFlags,
1422 const TQStyleOption &opt,
1423 const TQWidget* widget )
const
1425 TQStyle::SubControl ret = TQCommonStyle::querySubControl(control, ceData, elementFlags, pos, opt, widget);
1429 if (control == CC_ScrollBar && ret == SC_None)
1430 ret = SC_ScrollBarSubLine;
1436 TQRect TDEStyle::querySubControlMetrics( ComplexControl control,
1437 const TQStyleControlElementData &ceData,
1438 ControlElementFlags elementFlags,
1440 const TQStyleOption &opt,
1441 const TQWidget* widget )
const
1445 if (control == CC_ScrollBar)
1451 bool horizontal = ceData.orientation == TQt::Horizontal;
1452 int sliderstart = ceData.startStep;
1453 int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
1454 int maxlen = (horizontal ? ceData.rect.width() : ceData.rect.height())
1455 - (sbextent * (threeButtonScrollBar ? 3 : 2));
1459 if (ceData.maxSteps != ceData.minSteps)
1461 uint range = ceData.maxSteps - ceData.minSteps;
1462 sliderlen = (ceData.pageStep * maxlen) / (range + ceData.pageStep);
1464 int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
1465 if ( sliderlen < slidermin || range > INT_MAX / 2 )
1466 sliderlen = slidermin;
1467 if ( sliderlen > maxlen )
1475 case SC_ScrollBarSubLine: {
1477 if (platinumScrollBar) {
1479 ret.setRect(ceData.rect.width() - 2 * sbextent, 0, sbextent, sbextent);
1481 ret.setRect(0, ceData.rect.height() - 2 * sbextent, sbextent, sbextent);
1483 ret.setRect(0, 0, sbextent, sbextent);
1487 case SC_ScrollBarAddLine: {
1489 if (nextScrollBar) {
1491 ret.setRect(sbextent, 0, sbextent, sbextent);
1493 ret.setRect(0, sbextent, sbextent, sbextent);
1496 ret.setRect(ceData.rect.width() - sbextent, 0, sbextent, sbextent);
1498 ret.setRect(0, ceData.rect.height() - sbextent, sbextent, sbextent);
1503 case SC_ScrollBarSubPage: {
1505 if (platinumScrollBar) {
1507 ret.setRect(0, 0, sliderstart, sbextent);
1509 ret.setRect(0, 0, sbextent, sliderstart);
1510 }
else if (nextScrollBar) {
1512 ret.setRect(sbextent*2, 0, sliderstart-2*sbextent, sbextent);
1514 ret.setRect(0, sbextent*2, sbextent, sliderstart-2*sbextent);
1517 ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent);
1519 ret.setRect(0, sbextent, sbextent, sliderstart - sbextent);
1524 case SC_ScrollBarAddPage: {
1528 if (platinumScrollBar)
1530 else if (nextScrollBar)
1536 ret.setRect(sliderstart + sliderlen, 0,
1537 maxlen - sliderstart - sliderlen + fudge, sbextent);
1539 ret.setRect(0, sliderstart + sliderlen, sbextent,
1540 maxlen - sliderstart - sliderlen + fudge);
1544 case SC_ScrollBarGroove: {
1545 int multi = threeButtonScrollBar ? 3 : 2;
1548 if (platinumScrollBar)
1550 else if (nextScrollBar)
1556 ret.setRect(fudge, 0, ceData.rect.width() - sbextent * multi, ceData.rect.height());
1558 ret.setRect(0, fudge, ceData.rect.width(), ceData.rect.height() - sbextent * multi);
1562 case SC_ScrollBarSlider: {
1564 ret.setRect(sliderstart, 0, sliderlen, sbextent);
1566 ret.setRect(0, sliderstart, sbextent, sliderlen);
1571 ret = TQCommonStyle::querySubControlMetrics(control, ceData, elementFlags, sc, opt, widget);
1575 ret = TQCommonStyle::querySubControlMetrics(control, ceData, elementFlags, sc, opt, widget);
1580 static const char *
const tdestyle_close_xpm[] = {
1597 static const char *
const tdestyle_maximize_xpm[]={
1615 static const char *
const tdestyle_minimize_xpm[] = {
1632 static const char *
const tdestyle_normalizeup_xpm[] = {
1650 static const char *
const tdestyle_shade_xpm[] = {
1667 static const char *
const tdestyle_unshade_xpm[] = {
1684 static const char *
const dock_window_close_xpm[] = {
1704 static const char *
const information_xpm[]={
1711 "...........********.............",
1712 "........***aaaaaaaa***..........",
1713 "......**aaaaaaaaaaaaaa**........",
1714 ".....*aaaaaaaaaaaaaaaaaa*.......",
1715 "....*aaaaaaaabbbbaaaaaaaac......",
1716 "...*aaaaaaaabbbbbbaaaaaaaac.....",
1717 "..*aaaaaaaaabbbbbbaaaaaaaaac....",
1718 ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
1719 ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
1720 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
1721 "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
1722 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1723 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1724 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1725 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1726 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1727 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1728 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1729 "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
1730 "...caaaaaaabbbbbbbbbaaaaaac****.",
1731 "....caaaaaaaaaaaaaaaaaaaac****..",
1732 ".....caaaaaaaaaaaaaaaaaac****...",
1733 "......ccaaaaaaaaaaaaaacc****....",
1734 ".......*cccaaaaaaaaccc*****.....",
1735 "........***cccaaaac*******......",
1736 "..........****caaac*****........",
1737 ".............*caaac**...........",
1738 "...............caac**...........",
1739 "................cac**...........",
1740 ".................cc**...........",
1741 "..................***...........",
1742 "...................**..........."};
1744 static const char*
const warning_xpm[]={
1750 ".............***................",
1751 "............*aaa*...............",
1752 "...........*aaaaa*b.............",
1753 "...........*aaaaa*bb............",
1754 "..........*aaaaaaa*bb...........",
1755 "..........*aaaaaaa*bb...........",
1756 ".........*aaaaaaaaa*bb..........",
1757 ".........*aaaaaaaaa*bb..........",
1758 "........*aaaaaaaaaaa*bb.........",
1759 "........*aaaa***aaaa*bb.........",
1760 ".......*aaaa*****aaaa*bb........",
1761 ".......*aaaa*****aaaa*bb........",
1762 "......*aaaaa*****aaaaa*bb.......",
1763 "......*aaaaa*****aaaaa*bb.......",
1764 ".....*aaaaaa*****aaaaaa*bb......",
1765 ".....*aaaaaa*****aaaaaa*bb......",
1766 "....*aaaaaaaa***aaaaaaaa*bb.....",
1767 "....*aaaaaaaa***aaaaaaaa*bb.....",
1768 "...*aaaaaaaaa***aaaaaaaaa*bb....",
1769 "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
1770 "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
1771 "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
1772 ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
1773 ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
1774 "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
1775 "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
1776 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1777 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1778 ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
1779 "..*************************bbbbb",
1780 "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
1781 ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
1783 static const char*
const critical_xpm[]={
1789 "...........********.............",
1790 ".........************...........",
1791 ".......****************.........",
1792 "......******************........",
1793 ".....********************a......",
1794 "....**********************a.....",
1795 "...************************a....",
1796 "..*******b**********b*******a...",
1797 "..******bbb********bbb******a...",
1798 ".******bbbbb******bbbbb******a..",
1799 ".*******bbbbb****bbbbb*******a..",
1800 "*********bbbbb**bbbbb*********a.",
1801 "**********bbbbbbbbbb**********a.",
1802 "***********bbbbbbbb***********aa",
1803 "************bbbbbb************aa",
1804 "************bbbbbb************aa",
1805 "***********bbbbbbbb***********aa",
1806 "**********bbbbbbbbbb**********aa",
1807 "*********bbbbb**bbbbb*********aa",
1808 ".*******bbbbb****bbbbb*******aa.",
1809 ".******bbbbb******bbbbb******aa.",
1810 "..******bbb********bbb******aaa.",
1811 "..*******b**********b*******aa..",
1812 "...************************aaa..",
1813 "....**********************aaa...",
1814 "....a********************aaa....",
1815 ".....a******************aaa.....",
1816 "......a****************aaa......",
1817 ".......aa************aaaa.......",
1818 ".........aa********aaaaa........",
1819 "...........aaaaaaaaaaa..........",
1820 ".............aaaaaaa............"};
1822 TQPixmap TDEStyle::stylePixmap( StylePixmap stylepixmap,
1823 const TQStyleControlElementData &ceData,
1824 ControlElementFlags elementFlags,
1825 const TQStyleOption& opt,
1826 const TQWidget* widget)
const
1828 switch (stylepixmap) {
1829 case SP_TitleBarShadeButton:
1830 return TQPixmap(
const_cast<const char**
>(tdestyle_shade_xpm));
1831 case SP_TitleBarUnshadeButton:
1832 return TQPixmap(
const_cast<const char**
>(tdestyle_unshade_xpm));
1833 case SP_TitleBarNormalButton:
1834 return TQPixmap(
const_cast<const char**
>(tdestyle_normalizeup_xpm));
1835 case SP_TitleBarMinButton:
1836 return TQPixmap(
const_cast<const char**
>(tdestyle_minimize_xpm));
1837 case SP_TitleBarMaxButton:
1838 return TQPixmap(
const_cast<const char**
>(tdestyle_maximize_xpm));
1839 case SP_TitleBarCloseButton:
1840 return TQPixmap(
const_cast<const char**
>(tdestyle_close_xpm));
1841 case SP_DockWindowCloseButton:
1842 return TQPixmap(
const_cast<const char**
>(dock_window_close_xpm ));
1843 case SP_MessageBoxInformation:
1844 return TQPixmap(
const_cast<const char**
>(information_xpm));
1845 case SP_MessageBoxWarning:
1846 return TQPixmap(
const_cast<const char**
>(warning_xpm));
1847 case SP_MessageBoxCritical:
1848 return TQPixmap(
const_cast<const char**
>(critical_xpm));
1852 return TQCommonStyle::stylePixmap(stylepixmap, ceData, elementFlags, opt, widget);
1856 int TDEStyle::styleHint( StyleHint sh,
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
1857 const TQStyleOption &opt, TQStyleHintReturn* shr,
const TQWidget* w)
const
1861 case SH_EtchDisabledText:
1862 return d->etchDisabledText ? 1 : 0;
1864 case SH_PopupMenu_Scrollable:
1865 return d->scrollablePopupmenus ? 1 : 0;
1867 case SH_HideUnderlineAcceleratorWhenAltUp:
1868 return d->autoHideAccelerators ? 1 : 0;
1870 case SH_MenuBar_AltKeyNavigation:
1871 return d->menuAltKeyNavigation ? 1 : 0;
1873 case SH_PopupMenu_SubMenuPopupDelay:
1874 if ( styleHint( SH_PopupMenu_SloppySubMenus, ceData, elementFlags, TQStyleOption::Default, 0, w ) )
1875 return TQMIN( 100, d->popupMenuDelay );
1877 return d->popupMenuDelay;
1879 case SH_PopupMenu_SloppySubMenus:
1880 return d->sloppySubMenus;
1882 case SH_ItemView_ChangeHighlightOnFocus:
1883 case SH_Slider_SloppyKeyEvents:
1884 case SH_MainWindow_SpaceBelowMenuBar:
1885 case SH_PopupMenu_AllowActiveAndDisabled:
1888 case SH_Slider_SnapToValue:
1889 case SH_PrintDialog_RightAlignButtons:
1890 case SH_FontDialog_SelectAssociatedText:
1891 case SH_MenuBar_MouseTracking:
1892 case SH_PopupMenu_MouseTracking:
1893 case SH_ComboBox_ListMouseTracking:
1894 case SH_ScrollBar_MiddleClickAbsolutePosition:
1896 case SH_LineEdit_PasswordCharacter:
1899 const TQFontMetrics &fm = w->fontMetrics();
1900 if (fm.inFont(TQChar(0x25CF))) {
1902 }
else if (fm.inFont(TQChar(0x2022))) {
1910 return TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, shr, w);
1915 bool TDEStyle::objectEventHandler(
const TQStyleControlElementData &ceData, ControlElementFlags elementFlags,
void* source, TQEvent *event )
1917 if (ceData.widgetObjectTypes.contains(
"TQObject")) {
1918 TQObject*
object =
reinterpret_cast<TQObject*
>(source);
1919 if ( d->useFilledFrameWorkaround )
1929 if (
event->type() == TQEvent::Paint
1930 && (frame = ::tqt_cast<TQFrame*>(
object)) )
1932 if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel)
1935 bool horizontal =
true;
1936 TQPaintEvent* pe = (TQPaintEvent*)event;
1937 TQToolBar *toolbar = ::tqt_cast< TQToolBar *>( frame );
1938 TQRect r = pe->rect();
1940 if (toolbar && toolbar->orientation() == TQt::Vertical)
1944 if ( r.height() == frame->height() )
1948 TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) );
1949 TQApplication::sendEvent( frame, &dummyPE );
1952 if ( r.width() == frame->width() )
1955 TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) );
1956 TQApplication::sendEvent( frame, &dummyPE );
1973 TransparencyHandler::TransparencyHandler(
TDEStyle* style,
1974 TransparencyEngine tEngine,
float menuOpacity,
bool useDropShadow )
1979 opacity = menuOpacity;
1980 dropShadow = useDropShadow;
1981 pix.setOptimization(TQPixmap::BestOptim);
1984 TransparencyHandler::~TransparencyHandler()
1988 bool TransparencyHandler::haveX11RGBASupport()
1991 if (TQPaintDevice::x11AppDepth() == 32) {
1999 #define REAL_ALPHA_STRENGTH 255.0
2002 void TransparencyHandler::rightShadow(TQImage& dst)
2004 bool have_composite = haveX11RGBASupport();
2006 if (dst.depth() != 32)
2007 dst = dst.convertDepth(32);
2010 int pixels = dst.width() * dst.height();
2011 #ifdef WORDS_BIGENDIAN
2012 unsigned char* data = dst.bits() + 1;
2014 unsigned char* data = dst.bits();
2016 for(
int i = 0; i < 16; i++) {
2017 if (have_composite) {
2021 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-top_right_corner[i])); data++;
2024 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
2025 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
2026 *data = (
unsigned char)((*data)*top_right_corner[i]); data++;
2033 for(
int i = 0; i < pixels; i++) {
2034 if (have_composite) {
2038 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-shadow_strip[c])); data++;
2041 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2042 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2043 *data = (
unsigned char)((*data)*shadow_strip[c]); data++;
2051 for(
int i = 0; i < 16; i++) {
2052 if (have_composite) {
2056 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-bottom_right_corner[i])); data++;
2059 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2060 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2061 *data = (
unsigned char)((*data)*bottom_right_corner[i]); data++;
2067 void TransparencyHandler::bottomShadow(TQImage& dst)
2069 bool have_composite = haveX11RGBASupport();
2071 if (dst.depth() != 32)
2072 dst = dst.convertDepth(32);
2075 int width = dst.width() - 4;
2076 double strip_data = shadow_strip[0];
2077 double* corner =
const_cast<double*
>(bottom_left_corner);
2079 #ifdef WORDS_BIGENDIAN
2080 unsigned char* data = dst.bits() + 1;
2082 unsigned char* data = dst.bits();
2085 for(
int y = 0; y < 4; y++)
2088 for(
int x = 0; x < 4; x++) {
2089 if (have_composite) {
2093 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-(*corner))); data++;
2096 *data = (
unsigned char)((*data)*(*corner)); data++;
2097 *data = (
unsigned char)((*data)*(*corner)); data++;
2098 *data = (
unsigned char)((*data)*(*corner)); data++;
2105 for(
int x = 0; x < width; x++) {
2106 if (have_composite) {
2110 *data = (
unsigned char)(REAL_ALPHA_STRENGTH*(1.0-strip_data)); data++;
2113 *data = (
unsigned char)((*data)*strip_data); data++;
2114 *data = (
unsigned char)((*data)*strip_data); data++;
2115 *data = (
unsigned char)((*data)*strip_data); data++;
2120 strip_data = shadow_strip[line++];
2124 TQImage TransparencyHandler::handleRealAlpha(TQImage img) {
2125 TQImage clearImage = img.convertDepth(32);
2126 clearImage.setAlphaBuffer(
true);
2128 int w = clearImage.width();
2129 int h = clearImage.height();
2131 for (
int y = 0; y < h; ++y) {
2132 TQRgb *ls = (TQRgb *)clearImage.scanLine( y );
2133 for (
int x = 0; x < w; ++x) {
2134 ls[x] = tqRgba( 0, 0, 0, 0 );
2142 void TransparencyHandler::createShadowWindows(
const TQWidget* p)
2145 int x2 = p->x()+p->width();
2146 int y2 = p->y()+p->height();
2147 TQRect shadow1(x2, p->y() + 4, 4, p->height());
2148 TQRect shadow2(p->x() + 4, y2, p->width() - 4, 4);
2150 bool have_composite = haveX11RGBASupport();
2154 se.w1 =
new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) );
2155 se.w2 =
new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) );
2156 se.w1->setGeometry(shadow1);
2157 se.w2->setGeometry(shadow2);
2158 XSelectInput(tqt_xdisplay(), se.w1->winId(), StructureNotifyMask );
2159 XSelectInput(tqt_xdisplay(), se.w2->winId(), StructureNotifyMask );
2162 shadowMap()[p] = se;
2165 TQPixmap pix_shadow1;
2166 TQPixmap pix_shadow2;
2167 if (have_composite) {
2168 pix_shadow1 = TQPixmap(shadow1.width(), shadow1.height());
2169 pix_shadow2 = TQPixmap(shadow2.width(), shadow2.height());
2172 pix_shadow1 = TQPixmap::grabWindow(tqt_xrootwin(),
2173 shadow1.x(), shadow1.y(), shadow1.width(), shadow1.height());
2174 pix_shadow2 = TQPixmap::grabWindow(tqt_xrootwin(),
2175 shadow2.x(), shadow2.y(), shadow2.width(), shadow2.height());
2179 img = pix_shadow1.convertToImage();
2180 if (have_composite) img = handleRealAlpha(img);
2182 pix_shadow1.convertFromImage(img);
2183 img = pix_shadow2.convertToImage();
2184 if (have_composite) img = handleRealAlpha(img);
2186 pix_shadow2.convertFromImage(img);
2189 se.w1->setErasePixmap(pix_shadow1);
2190 se.w2->setErasePixmap(pix_shadow2);
2194 XMapWindow(tqt_xdisplay(), se.w1->winId());
2195 XMapWindow(tqt_xdisplay(), se.w2->winId());
2201 void TransparencyHandler::removeShadowWindows(
const TQWidget* p)
2204 ShadowMap::iterator it = shadowMap().find(p);
2205 if (it != shadowMap().
end())
2207 ShadowElements se = it.data();
2208 XUnmapWindow(tqt_xdisplay(), se.w1->winId());
2209 XUnmapWindow(tqt_xdisplay(), se.w2->winId());
2210 XFlush(tqt_xdisplay());
2213 shadowMap().erase(it);
2220 bool TransparencyHandler::eventFilter( TQObject*
object, TQEvent* event )
2222 #if !defined TQ_WS_MAC && !defined TQ_WS_WIN
2227 TQWidget* p = (TQWidget*)
object;
2228 TQEvent::Type et =
event->type();
2230 if (et == TQEvent::Show)
2235 pix = TQPixmap::grabWindow(tqt_xrootwin(),
2236 p->x(), p->y(), p->width(), p->height());
2241 if (tqt_use_xrender) {
2242 XRenderBlendToPixmap(p);
2250 blendToPixmap(p->colorGroup(), p);
2255 blendToColor(p->colorGroup().button());
2258 p->setErasePixmap(pix);
2266 if ((dropShadow || useDropShadow(p))
2267 && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
2268 createShadowWindows(p);
2270 else if (et == TQEvent::Resize && p->isShown() && p->isTopLevel())
2273 if (dropShadow || useDropShadow(p))
2275 removeShadowWindows(p);
2276 createShadowWindows(p);
2279 else if (et == TQEvent::Hide)
2282 if (dropShadow || useDropShadow(p))
2283 removeShadowWindows(p);
2287 p->setErasePixmap(TQPixmap());
2296 void TransparencyHandler::blendToColor(
const TQColor &col)
2298 if (opacity < 0.0 || opacity > 1.0)
2301 TQImage img = pix.convertToImage();
2307 void TransparencyHandler::blendToPixmap(
const TQColorGroup &cg,
const TQWidget* p)
2309 if (opacity < 0.0 || opacity > 1.0)
2313 blendPix.resize( pix.width(), pix.height() );
2315 if (blendPix.width() != pix.width() ||
2316 blendPix.height() != pix.height())
2320 if (::tqt_cast<TQPopupMenu*>(p))
2321 tdestyle->renderMenuBlendPixmap( blendPix, cg, ::tqt_cast<TQPopupMenu*>(p) );
2323 blendPix.fill(cg.button());
2325 TQImage blendImg = blendPix.convertToImage();
2326 TQImage backImg = pix.convertToImage();
2336 void TransparencyHandler::XRenderBlendToPixmap(
const TQWidget* p)
2339 renderPix.resize( pix.width(), pix.height() );
2342 if (::tqt_cast<TQPopupMenu*>(p))
2343 tdestyle->renderMenuBlendPixmap( renderPix, p->colorGroup(),
2344 ::tqt_cast<TQPopupMenu*>(p) );
2346 renderPix.fill(p->colorGroup().button());
2348 Display* dpy = tqt_xdisplay();
2350 Picture alphaPicture;
2351 XRenderPictFormat Rpf;
2352 XRenderPictureAttributes Rpa;
2354 clr.alpha = ((
unsigned short)(255*opacity) << 8);
2356 Rpf.type = PictTypeDirect;
2358 Rpf.direct.alphaMask = 0xff;
2361 XRenderPictFormat* xformat = XRenderFindFormat(dpy,
2362 PictFormatType | PictFormatDepth | PictFormatAlphaMask, &Rpf, 0);
2364 alphaPixmap = XCreatePixmap(dpy, p->handle(), 1, 1, 8);
2365 alphaPicture = XRenderCreatePicture(dpy, alphaPixmap, xformat, CPRepeat, &Rpa);
2367 XRenderFillRectangle(dpy, PictOpSrc, alphaPicture, &clr, 0, 0, 1, 1);
2369 XRenderComposite(dpy, PictOpOver,
2370 renderPix.x11RenderHandle(), alphaPicture, pix.x11RenderHandle(),
2374 pix.width(), pix.height());
2376 XRenderFreePicture(dpy, alphaPicture);
2377 XFreePixmap(dpy, alphaPixmap);
2381 void TDEStyle::virtual_hook(
int,
void* )
2386 extern "C" TDE_EXPORT
2387 void kde_tdestyle_set_scrollbar_type_windows(
void* style )
2391 #include "tdestyle.moc"
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.
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.
Off-screen paint device with extended features.
bool convertFromImage(const TQImage &img, int conversion_flags)
Converts an image and sets this pixmap.
Simplifies and extends the TQStyle API to make style coding easier.
TDEStyleScrollBarType
TDEStyle ScrollBarType:
@ NextStyleScrollBar
two button, NeXT style
@ PlatinumStyleScrollBar
two button, platinum style
@ ThreeButtonScrollBar
three buttons, KDE style
@ WindowsStyleScrollBar
two button, windows style
TDEStyle(TDEStyleFlags flags=TDEStyle::Default, TDEStyleScrollBarType sbtype=TDEStyle::WindowsStyleScrollBar)
Constructs a TDEStyle object.
~TDEStyle()
Destructs the TDEStyle object.
@ AllowMenuTransparency
Internal transparency enabled.
@ FilledFrameWorkaround
Filled frames enabled.
uint TDEStyleFlags
TDEStyle Flags:
void setScrollBarType(TDEStyleScrollBarType sbtype)
Modifies the scrollbar type used by the style.
TDEStyleFlags styleFlags() const
Returns the TDEStyle flags used to initialize the style.
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...
static TQString defaultStyle()
Returns the default widget style depending on color depth.
TDEStylePrimitive
TDEStyle Primitive Elements:
int event(const TQString &message, const TQString &text=TQString::null) TDE_DEPRECATED
const TDEShortcut & end()