1 unit QtThemes;
2 
3 {$mode objfpc}{$H+}
4 
5 interface
6 
7 {$I qtdefines.inc}
8 
9 uses
10   // rtl
11   Types, Classes, SysUtils,
12   // qt bindings
13   qt4,
14   // lcl
15   LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema,
16   // widgetset
17   InterfaceBase, QtObjects
18   ;
19 
20 type
21   TQtDrawVariant =
22   (
23     qdvNone,
24     qdvPrimitive,
25     qdvControl,
26     qdvComplexControl,
27     qdvStandardPixmap
28   );
29   TQtDrawElement = record
30     case DrawVariant: TQtDrawVariant of
31       qdvPrimitive:
32         (PrimitiveElement: QStylePrimitiveElement);
33       qdvControl:
34         (ControlElement: QStyleControlElement);
35       qdvComplexControl:
36         (ComplexControl: QStyleComplexControl;
37          SubControls: QStyleSubControls;
38          Features: Cardinal);
39       qdvStandardPixmap:
40         (StandardPixmap: QStyleStandardPixmap);
41   end;
42 
43   { TQtThemeServices }
44 
45   TQtThemeServices = class(TThemeServices)
46   private
47     FStyle: QStyleH;
GetStylenull48     function GetStyle: QStyleH;
GetStyleNamenull49     function GetStyleName: WideString;
50   protected
InitThemesnull51     function InitThemes: Boolean; override;
UseThemesnull52     function UseThemes: Boolean; override;
ThemedControlsEnablednull53     function ThemedControlsEnabled: Boolean; override;
54     procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); override;
55 
GetControlStatenull56     function GetControlState(Details: TThemedElementDetails): QStyleState;
GetDrawElementnull57     function GetDrawElement(Details: TThemedElementDetails): TQtDrawElement;
58     property Style: QStyleH read GetStyle;
59     property StyleName: WideString read GetStyleName;
60   public
61     procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
62     procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
63     procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
64     procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); overload; override;
65     procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); overload; override;
GetDetailSizenull66     function GetDetailSize(Details: TThemedElementDetails): TSize; override;
GetStockImagenull67     function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
68 
ContentRectnull69     function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
HasTransparentPartsnull70     function HasTransparentParts(Details: TThemedElementDetails): Boolean; override;
71   end;
72 
73 implementation
74 uses qtint, qtproc;
75 
76 { TQtThemeServices }
77 
GetStylenull78 function TQtThemeServices.GetStyle: QStyleH;
79 begin
80   FStyle := QApplication_style();
81   Result := FStyle;
82 end;
83 
TQtThemeServices.GetStyleNamenull84 function TQtThemeServices.GetStyleName: WideString;
85 begin
86   QObject_objectName(Style, @Result);
87 end;
88 
TQtThemeServices.InitThemesnull89 function TQtThemeServices.InitThemes: Boolean;
90 begin
91   FStyle := nil;
92   Result := True;
93 end;
94 
UseThemesnull95 function TQtThemeServices.UseThemes: Boolean;
96 begin
97   Result := True;
98 end;
99 
ThemedControlsEnablednull100 function TQtThemeServices.ThemedControlsEnabled: Boolean;
101 begin
102   Result := True;
103 end;
104 
TQtThemeServices.ContentRectnull105 function TQtThemeServices.ContentRect(DC: HDC;
106   Details: TThemedElementDetails; BoundingRect: TRect): TRect;
107 begin
108   Result := BoundingRect;
109   InflateRect(Result, -1, -1);
110 end;
111 
112 procedure TQtThemeServices.DrawEdge(DC: HDC;
113   Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
114   AContentRect: PRect);
115 begin
116   DebugLn('WARNING: TQtThemeServices.DrawEdge is not implemented.');
117 end;
118 
119 procedure TQtThemeServices.DrawElement(DC: HDC;
120   Details: TThemedElementDetails; const R: TRect; ClipRect: PRect);
121 var
122   Context: TQtDeviceContext absolute DC;
123   opt: QStyleOptionH;
124   ARect: TRect;
125   AIcon: QIconH;
126   Element: TQtDrawElement;
127   Features: QStyleOptionButtonButtonFeatures;
128   Position: QStyleOptionHeaderSectionPosition;
129   Palette: QPaletteH;
130   ABrush: QBrushH;
131   Widget: QWidgetH;
132   AViewportPaint: Boolean;
133   StyleState: QStyleState;
134   {$IFDEF DARWIN}
135   ClipR: TRect; // fix branch indicators (treeviews)
136   {$ENDIF}
137   dx, dy: integer;
138   APalette: QPaletteH;
139   W: WideString;
140 
141   procedure DrawSplitterInternal;
142   var
143     lx, ly, d, lt, i: Integer;
144     r1: TRect;
145     AQtColor: QColorH;
146     ADarkColor, ALightColor: TQColor;
147     APalette: QPaletteH;
148     NumDots: integer;
149     APen: QPenH;
150   begin
151     r1 := ARect;
152     NumDots := 10;
153     APalette := QPalette_create;
154     try
155       QStyleOption_palette(opt, APalette);
156       AQtColor := QColor_create(QBrush_color(QPalette_background(APalette)));
157 
158       QColor_darker(AQtColor, @ADarkColor);
159       QColor_lighter(AQtColor, @ALightColor);
160 
161       if StyleState and QStyleState_Horizontal = 0 then
162       begin
163         if (r1.Right - r1.Left) <= (NumDots * 2) then
164           NumDots := (r1.Right - r1.Left) div 2;
165         lx := ((r1.Right - r1.Left) div 2) - (NumDots * 2);
166         d := (r1.Bottom - r1.Top - 2) div 2;
167         lt := r1.Top + d + 1;
168         APen := QPen_create(QPainter_pen(Context.Widget));
169         for i := 0 to NumDots - 1 do
170         begin
171           QPen_setColor(APen, PQColor(@ALightColor));
172           QPainter_setPen(Context.Widget, APen);
173           QPainter_drawPoint(Context.Widget, lx, lt);
174           QPen_setColor(APen, PQColor(@ADarkColor));
175           QPainter_setPen(Context.Widget, APen);
176           QPainter_drawPoint(Context.Widget, lx + 1, lt);
177           QPainter_drawPoint(Context.Widget, lx, lt + 1);
178           QPainter_drawPoint(Context.Widget, lx + 1, lt + 1);
179           lx := lx + 4;
180         end;
181         QPen_destroy(APen);
182       end else
183       begin
184         if (r1.Bottom - r1.Top) <= (NumDots * 2) then
185           NumDots := (r1.Bottom - r1.Top) div 2;
186         ly := ((r1.Bottom - r1.Top) div 2) + (NumDots * 2);
187         d := (r1.Right - r1.Left - 2) div 2;
188         lt := r1.Left + d + 1;
189         APen := QPen_create(QPainter_pen(Context.Widget));
190         for i := 0 to NumDots - 1 do
191         begin
192           QPen_setColor(APen, PQColor(@ALightColor));
193           QPainter_setPen(Context.Widget, APen);
194           QPainter_drawPoint(Context.Widget, lt, ly);
195           QPen_setColor(APen, PQColor(@ADarkColor));
196           QPainter_setPen(Context.Widget, APen);
197           QPainter_drawPoint(Context.Widget, lt + 1, ly);
198           QPainter_drawPoint(Context.Widget, lt, ly + 1);
199           QPainter_drawPoint(Context.Widget, lt + 1, ly + 1);
200           ly := ly - 4;
201         end;
202         QPen_destroy(APen);
203       end;
204     finally
205       QPalette_destroy(APalette);
206       QColor_destroy(AQtColor);
207     end;
208   end;
209 
210 begin
211   if (Context <> nil) and not IsRectEmpty(R) then
212   begin
213     AViewportPaint := False;
214     Context.save;
215     try
216       if Context.Parent <> nil then
217       begin
218         Widget := QWidget_parentWidget(Context.Parent);
219         if (Widget <> nil) and QObject_inherits(Widget,'QAbstractScrollArea') then
220         begin
221           {do not set any palette on QAbstractScrollArea viewport ! }
222           AViewportPaint := True;
223         end else
224         begin
225           Palette := QWidget_palette(Context.Parent);
226           QPainter_setBackground(Context.Widget, QPalette_background(Palette));
227         end;
228       end else
229       begin
230         Palette := QPalette_create();
231         QApplication_palette(Palette);
232         QPainter_setBackground(Context.Widget, QPalette_background(Palette));
233         QPalette_destroy(Palette);
234       end;
235 
236       if HasTransparentParts(Details) then
237         QPainter_setBackgroundMode(Context.Widget, QtTransparentMode);
238 
239       ARect := R;
240       Element := GetDrawElement(Details);
241       StyleState := GetControlState(Details);
242       case Element.DrawVariant of
243         qdvNone:
244           inherited DrawElement(DC, Details, R, ClipRect);
245         qdvControl:
246         begin
247           if (Element.ControlElement in [QStyleCE_ProgressBar, QStyleCE_ProgressBarContents,
248             QStyleCE_ProgressBarGroove]) then
249           begin
250             opt := QStyleOptionProgressBarV2_create;
251 
252             if Element.ControlElement <> QStyleCE_ProgressBarContents then
253             begin
254               QStyleOptionProgressBar_setMinimum(QStyleOptionProgressBarH(opt), 0);
255               QStyleOptionProgressBar_setMaximum(QStyleOptionProgressBarH(opt), 100);
256             end;
257 
258             if Element.Features = QtVertical then
259             begin
260               QStyleOptionProgressBarV2_setOrientation(QStyleOptionProgressBarV2H(opt), QtVertical);
261               QStyleOptionProgressBarV2_setInvertedAppearance(QStyleOptionProgressBarV2H(opt), True);
262               QStyleOptionProgressBarV2_setBottomToTop(QStyleOptionProgressBarV2H(opt), True);
263             end else
264               QStyleOptionProgressBarV2_setOrientation(QStyleOptionProgressBarV2H(opt), QtHorizontal);
265           end else
266           if (Element.ControlElement = QStyleCE_TabBarTabShape) then
267           begin
268             opt := QStyleOptionTab_create();
269             QStyleOptionTab_setShape(QStyleOptionTabH(opt), QTabBarShape(Element.Features));
270           end else
271           if (Element.ControlElement in [QStyleCE_PushButton, QStyleCE_RadioButton, QStyleCE_CheckBox]) then
272           begin
273             opt := QStyleOptionButton_create();
274             Features := QStyleOptionButtonNone;
275             if Details.Element = teToolBar then
276               Features := Features or QStyleOptionButtonFlat;
277             QStyleOptionButton_setFeatures(QStyleOptionButtonH(opt), Features);
278 
279             // workaround for qt QStyle bug. QStyle does not set disable flag (palette).
280             // see issue #24413,#26586
281             if Details.State in [CBS_UNCHECKEDDISABLED,CBS_CHECKEDDISABLED,CBS_MIXEDDISABLED] then
282             begin
283               APalette := QPalette_create();
284               try
285                 QStyleOption_palette(opt, APalette);
286                 QPalette_setCurrentColorGroup(APalette, QPaletteDisabled);
287                 QStyleOption_setPalette(opt, APalette);
288               finally
289                 QPalette_destroy(APalette);
290               end;
291             end;
292           end else
293           if (Element.ControlElement = QStyleCE_HeaderSection) then
294           begin
295             opt := QStyleOptionHeader_create();
296             case Details.Part of
297               HP_HEADERITEM: Position := QStyleOptionHeaderMiddle;
298               HP_HEADERITEMLEFT: Position := QStyleOptionHeaderBeginning;
299               HP_HEADERITEMRIGHT: Position := QStyleOptionHeaderEnd;
300             end;
301 
302             W := GetStyleName;
303             // fix for oxygen and breeze weird drawing of header sections. issue #23143
304             if ((W = 'oxygen') or (W = 'breeze')) and (Position = QStyleOptionHeaderMiddle) then
305             begin
306               // see if this is needed (in case of fixedRows in grids)
307               // if (ARect.Left > 0) or ((ARect.Left = 0) and (ARect.Top = 0)) then
308               Position := QStyleOptionHeaderBeginning;
309             end;
310 
311             QStyleOptionHeader_setPosition(QStyleOptionHeaderH(opt), Position);
312             QStyleOptionHeader_setOrientation(QStyleOptionHeaderH(opt), QtHorizontal);
313           end
314           else
315           if (Element.ControlElement = QStyleCE_ItemViewItem) then
316           begin
317             opt := QStyleOptionViewItemV4_create();
318             QStyleOptionViewItem_setShowDecorationSelected(QStyleOptionViewItemV4H(opt), True);
319           end
320           else
321           if (Element.ControlElement = QStyleCE_SizeGrip) then
322           begin
323             opt := QStyleOptionSizeGrip_create();
324             QStyleOptionSizeGrip_setCorner(QStyleOptionSizeGripH(opt), QtBottomRightCorner);
325             QStyleOption_setDirection(QStyleOptionH(opt), QtLeftToRight);
326           end
327           else
328             opt := QStyleOptionComplex_create(LongInt(QStyleOptionVersion), LongInt(QStyleOptionSO_Default));
329 
330           QStyleOption_setState(opt, StyleState);
331           dx := ARect.Left;
332           dy := ARect.Top;
333           Context.translate(dx, dy);
334           OffsetRect(ARect, -dx, -dy);
335           QStyleOption_setRect(opt, @ARect);
336 
337           // issue #27182 qt does not implement splitter grabber in some themes.
338           if (Element.ControlElement = QStyleCE_Splitter) and
339             ( (GetStyleName = 'windows') or (GetStyleName = 'breeze')
340               {$IFDEF MSWINDOWS} or true {$ENDIF}) then
341             drawSplitterInternal
342           else
343             QStyle_drawControl(Style, Element.ControlElement, opt, Context.Widget, Context.Parent);
344 
345           Context.translate(-dx, -dy);
346 
347           QStyleOption_Destroy(opt);
348         end;
349         qdvComplexControl:
350         begin
351           case Element.ComplexControl of
352             QStyleCC_GroupBox:
353             begin
354               opt := QStyleOptionGroupBox_create();
355               Context.translate(ARect.Left, ARect.Top);
356               OffsetRect(ARect, -ARect.Left, -ARect.Top);
357             end;
358             QStyleCC_ToolButton:
359             begin
360               opt := QStyleOptionToolButton_create();
361               QStyleOptionToolButton_setFeatures(QStyleOptionToolButtonH(opt),
362                 Element.Features);
363             end;
364             QStyleCC_ComboBox:
365             begin
366               opt := QStyleOptionComboBox_create();
367               if Element.Features = Ord(QtRightToLeft) then
368                 QStyleOption_setDirection(opt, QtRightToLeft);
369               if Details.State in [CBXS_DISABLED] then
370               begin
371                 APalette := QPalette_create();
372                 try
373                   QStyleOption_palette(opt, APalette);
374                   QPalette_setCurrentColorGroup(APalette, QPaletteDisabled);
375                   QStyleOption_setPalette(opt, APalette);
376                 finally
377                   QPalette_destroy(APalette);
378                 end;
379               end;
380             end;
381             QStyleCC_SpinBox:
382             begin
383               opt := QStyleOptionSpinBox_create;
384             end;
385             QStyleCC_TitleBar, QStyleCC_MdiControls:
386             begin
387               opt := QStyleOptionTitleBar_create();
388               if Element.SubControls = QStyleSC_TitleBarLabel then
389                 QStyleOptionTitleBar_setTitleBarFlags(QStyleOptionTitleBarH(opt),
390                   QtWindow or QtWindowTitleHint)
391               else
392                 QStyleOptionTitleBar_setTitleBarFlags(QStyleOptionTitleBarH(opt),
393                   QtWindow or QtWindowSystemMenuHint);
394               // workaround: qt has own minds about position of requested part -
395               // but we need a way to draw it at our position
396               Context.translate(ARect.Left, ARect.Top);
397               OffsetRect(ARect, -ARect.Left, -ARect.Top);
398             end;
399             QStyleCC_Slider, QStyleCC_ScrollBar:
400             begin
401               opt := QStyleOptionSlider_create();
402               QStyleOptionSlider_setMinimum(QStyleOptionSliderH(opt), 0);
403               QStyleOptionSlider_setMaximum(QStyleOptionSliderH(opt), 100);
404               if Element.ComplexControl = QStyleCC_Slider then
405               begin
406                 if Element.Features = QtVertical then
407                   QStyleOptionSlider_setOrientation(QStyleOptionSliderH(opt), QtVertical)
408                 else
409                   QStyleOptionSlider_setOrientation(QStyleOptionSliderH(opt), QtHorizontal);
410               end;
411             end;
412           else
413             opt := QStyleOptionComplex_create(LongInt(QStyleOptionVersion),
414               LongInt(QStyleOptionSO_Default));
415           end;
416 
417           if Element.SubControls > QStyleSC_None then
418             QStyleOptionComplex_setSubControls(QStyleOptionComplexH(opt),
419               Element.SubControls);
420 
421           QStyleOption_setState(opt, StyleState);
422           QStyleOption_setRect(opt, @ARect);
423           QStyle_drawComplexControl(Style, Element.ComplexControl,
424             QStyleOptionComplexH(opt), Context.Widget, Context.Parent);
425           QStyleOption_Destroy(opt);
426         end;
427         qdvPrimitive:
428         begin
429           case Element.PrimitiveElement of
430             QStylePE_FrameTabWidget:
431               begin
432                 opt := QStyleOptionTabWidgetFrame_create();
433                 // need widget to draw gradient
434               end;
435             QStylePE_FrameFocusRect:
436               begin
437                 opt := QStyleOptionFocusRect_create();
438               end;
439             QStylePE_PanelTipLabel:
440               begin
441                 opt := QStyleOptionFrame_create();
442               end;
443             QStylePE_FrameLineEdit:
444               begin
445                 opt := QStyleOptionFrame_create();
446               end;
447             QStylePE_IndicatorBranch:
448               begin
449 
450                 opt := QStyleOption_create(QStyleOptionVersion, QStyleOptionSO_Default);
451 
452                 QStyleOption_setState(opt, StyleState);
453                 if AViewPortPaint then
454                 begin
455                   {$IFDEF DARWIN}
456                   if (AnsiPos('macintosh', StyleName) > 0) and
457                     Context.getClipping then
458                   begin
459                     ClipR := Context.getClipRegion.getBoundingRect;
460                     if (ClipR.Left = 0) and (ClipR.Top = 0) and (ARect.Left > 0)
461                       and (ARect.Top > 0) then
462                     begin
463                       ClipR.Left := (ARect.Right - ARect.Left + 1) div 3;
464                       OffsetRect(ARect, -ClipR.Left, -1);
465                     end;
466                   end;
467                   {$ENDIF}
468                   Context.translate(-1, -1);
469                   ABrush := QBrush_create(QPainter_brush(Context.Widget));
470                   QBrush_setStyle(ABrush, QtNoBrush);
471                   QPainter_setBrush(Context.Widget, ABrush);
472                   QBrush_destroy(ABrush);
473                 end;
474               end;
475             else
476               opt := QStyleOption_create(QStyleOptionVersion, QStyleOptionSO_Default);
477           end;
478 
479           QStyleOption_setState(opt, StyleState);
480           QStyleOption_setRect(opt, @ARect);
481           QStyle_drawPrimitive(Style, Element.PrimitiveElement, opt, Context.Widget,
482             Context.Parent);
483           QStyleOption_Destroy(opt);
484         end;
485         qdvStandardPixmap:
486         begin
487           AIcon := QIcon_create();
488           if Element.StandardPixmap = QStyleSP_TitleBarCloseButton then
489           begin
490             opt := QStyleOptionDockWidget_create();
491             QStyle_standardIcon(Style, AIcon, Element.StandardPixmap, opt, Context.Parent);
492           end
493           else
494           begin
495             opt := QStyleOption_create(QStyleOptionVersion, QStyleOptionSO_Default);
496             QStyle_standardIcon(Style, AIcon, Element.StandardPixmap, opt);
497           end;
498           QIcon_paint(AIcon, Context.Widget, ARect.Left, ARect.Top,
499             ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
500           QIcon_destroy(AIcon);
501           QStyleOption_Destroy(opt);
502         end;
503       end;
504     finally
505       Context.restore;
506     end;
507   end;
508 end;
509 
510 procedure TQtThemeServices.DrawIcon(DC: HDC;
511   Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST;
512   Index: Integer);
513 begin
514   DebugLn('WARNING: TQtThemeServices.DrawIcon is not implemented.');
515 end;
516 
517 procedure TQtThemeServices.DrawText(ACanvas: TPersistent;
518   Details: TThemedElementDetails; const S: String; R: TRect; Flags,
519   Flags2: Cardinal);
520 var
521   AQColor, AOldColor: TQColor;
522   B: Boolean;
523   OldCanvasFontColor: TColor;
524   APalette: QPaletteH;
525 begin
526   B := False;
527 
528   // issue #25253
529   if (Details.Element in [teButton, teComboBox]) then
530   begin
531     B := True;
532     AOldColor := TQtDeviceContext(TCanvas(ACanvas).Handle).pen.getColor;
533     OldCanvasFontColor := TCanvas(ACanvas).Font.Color;
534 
535     // issue #25922
536     if IsDisabled(Details) then
537     begin
538       APalette := QPalette_create;
539       try
540         QApplication_palette(APalette,'QPushButton');
541         AQColor := QPalette_color(APalette, QPaletteDisabled, QPaletteButtonText)^;
542         TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AQColor);
543       finally
544         QPalette_destroy(APalette);
545       end;
546     end else
547     begin
548       if TCanvas(ACanvas).Font.Color = clDefault then
549         TCanvas(ACanvas).Font.Color := clBtnText;
550       ColorRefToTQColor(ColorToRGB(TCanvas(ACanvas).Font.Color), AQColor);
551       TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AQColor);
552     end;
553   end;
554 
555   DrawText(TCanvas(ACanvas).Handle, Details, S, R, Flags, Flags2);
556 
557   if B then
558   begin
559     TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AOldColor);
560     TCanvas(ACanvas).Font.Color := OldCanvasFontColor;
561   end;
562 end;
563 
564 procedure TQtThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails;
565   const S: String; R: TRect; Flags, Flags2: Cardinal);
566 var
567   Palette: QPaletteH;
568   Context: TQtDeviceContext;
569   Widget: QWidgetH;
570   W: WideString;
571   TextRect, SelRect: TRect;
572   AOldMode: Integer;
573   ATextPalette: Cardinal;
574   AQColor: TQColor;
575 begin
576   // DebugLn('TQtThemeServices.DrawText ');
577   Context := TQtDeviceContext(DC);
578   case Details.Element of
579     teToolTip:
580       begin
581         W := {%H-}S;
582         Context.save;
583         AOldMode := Context.SetBkMode(TRANSPARENT);
584         try
585           if Context.Parent <> nil then
586             Palette := QPalette_create(QWidget_palette(Context.Parent))
587           else
588             Palette := nil;
589 
590           if Palette = nil then
591           begin
592             inherited;
593             exit;
594           end;
595           QStyle_drawItemText(Style, Context.Widget, @R,
596             DTFlagsToQtFlags(Flags), Palette,
597             not IsDisabled(Details), @W, QPaletteToolTipText);
598           QPalette_destroy(Palette);
599         finally
600           Context.SetBkMode(AOldMode);
601           Context.restore;
602         end;
603 
604       end;
605     teTreeView, teListView:
606       begin
607         if Details.Part = TVP_TREEITEM then
608         begin
609           Palette := nil;
610           if Context.Parent <> nil then
611           begin
612             Widget := QWidget_parentWidget(Context.Parent);
613             if (Widget <> nil) and QObject_inherits(Widget,'QAbstractScrollArea') then
614               Palette := QPalette_create(QWidget_palette(Widget))
615             else
616               Palette := QPalette_create(QWidget_palette(Context.Parent));
617           end;
618 
619           if Palette = nil then
620           begin
621             inherited;
622             exit;
623           end;
624 
625           W := {%H-}S;
626           Context.save;
627           try
628             Context.SetBkMode(TRANSPARENT);
629             if Details.State = TREIS_DISABLED then
630               QPalette_setCurrentColorGroup(Palette, QPaletteDisabled)
631             else
632             if Details.State = TREIS_SELECTEDNOTFOCUS then
633               QPalette_setCurrentColorGroup(Palette, QPaletteInactive)
634             else
635               QPalette_setCurrentColorGroup(Palette, QPaletteActive);
636 
637             if Details.State in
638               [TREIS_SELECTED, TREIS_HOTSELECTED, TREIS_SELECTEDNOTFOCUS] then
639             begin
640               // fix qt motif style behaviour which does not fillrect
641               // when drawing itemview if it doesn't have text
642               // assigned via QStyleViewItemViewV4_setText()
643               if Details.State = TREIS_SELECTED then
644               begin
645                 if StyleName = 'motif' then
646                 begin
647                   TextRect := R;
648                   with TextRect do
649                   begin
650                     Left := Left + 2;
651                     Top := Top + 2;
652                     Right := Right - 2;
653                     Bottom := Bottom - 2;
654                   end;
655                   QPainter_fillRect(Context.Widget, @TextRect, QtSolidPattern);
656                 end;
657               end;
658 
659               QStyle_drawItemText(Style, Context.Widget, @R,
660                 DTFlagsToQtFlags(Flags), Palette,
661                 not IsDisabled(Details), @W, QPaletteHighlightedText)
662             end else
663               QStyle_drawItemText(Style, Context.Widget, @R,
664                 DTFlagsToQtFlags(Flags), Palette,
665                 not IsDisabled(Details), @W, QPaletteText);
666           finally
667             Context.restore;
668           end;
669           QPalette_destroy(Palette);
670         end else
671           inherited;
672       end;
673 
674     else
675     begin // default text drawing for all !
676       W := {%H-}S;
677       Context.save;
678       AOldMode := Context.SetBkMode(TRANSPARENT);
679       if Context.Parent <> nil then
680         Palette := QPalette_create(QWidget_palette(Context.Parent))
681       else
682       begin
683         Palette := QPalette_create;
684         QApplication_palette(Palette);
685       end;
686       try
687         if Details.Element in [teButton, teComboBox] then
688           AQColor := TQtDeviceContext(DC).pen.getColor; // issue #25253
689 
690         if Details.Element in [teEdit, teListView, teTreeView, teWindow] then
691           ATextPalette := QPaletteWindowText
692         else
693         if Details.Element in [teButton, teComboBox] then
694           ATextPalette := QPaletteButtonText
695         else
696           ATextPalette := QPaletteText;
697 
698         if Details.Element in [teButton, teComboBox] then
699           QPalette_setColor(Palette, ATextPalette, @AQColor); // issue #25253
700 
701         if Context.font.Angle <> 0 then
702         begin
703           Context.Translate(R.Left, R.Top);
704           Context.Rotate(-0.1 * Context.Font.Angle);
705           OffsetRect(R, -R.Left, -R.Top);
706         end;
707 
708         if (Details.Element = teEdit) then
709         begin
710           if IsDisabled(Details) then
711             QPalette_setCurrentColorGroup(Palette, QPaletteDisabled);
712           if GetControlState(Details) and QStyleState_Selected <> 0 then
713           begin
714             Context.font.Metrics.boundingRect(@SelRect, @R, DTFlagsToQtFlags(Flags), @W);
715             ColorRefToTQColor(ColorToRGB(clHighlight), AQColor);
716             QPainter_fillRect(Context.Widget, @SelRect,  PQColor(@AQColor));
717             ATextPalette := QPaletteHighlightedText;
718           end;
719         end;
720 
721         QStyle_drawItemText(Style, Context.Widget, @R,
722           DTFlagsToQtFlags(Flags), Palette,
723           not IsDisabled(Details), @W, ATextPalette);
724 
725         if Context.font.Angle <> 0 then
726         begin
727           Context.Translate(-R.Left, -R.Top);
728           Context.Rotate(0.1 * Context.Font.Angle);
729         end;
730         Context.SetBkMode(AOldMode);
731       finally
732         QPalette_destroy(Palette);
733         Context.restore;
734       end;
735     end;
736   end;
737 end;
738 
HasTransparentPartsnull739 function TQtThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;
740 begin
741   Result := True;
742 end;
743 
744 procedure TQtThemeServices.InternalDrawParentBackground(Window: HWND;
745   Target: HDC; Bounds: PRect);
746 begin
747   // ?
748 end;
749 
GetControlStatenull750 function TQtThemeServices.GetControlState(Details: TThemedElementDetails): QStyleState;
751 begin
752 {
753   QStyleState_None
754   QStyleState_Enabled
755   QStyleState_Raised
756   QStyleState_Sunken
757   QStyleState_Off
758   QStyleState_NoChange
759   QStyleState_On
760   QStyleState_DownArrow
761   QStyleState_Horizontal
762   QStyleState_HasFocus
763   QStyleState_Top
764   QStyleState_Bottom
765   QStyleState_FocusAtBorder
766   QStyleState_AutoRaise
767   QStyleState_MouseOver
768   QStyleState_UpArrow
769   QStyleState_Selected
770   QStyleState_Active
771   QStyleState_Open
772   QStyleState_Children
773   QStyleState_Item
774   QStyleState_Sibling
775   QStyleState_Editing
776   QStyleState_KeyboardFocusChange
777   QStyleState_ReadOnly
778 }
779   Result := QStyleState_None;
780 
781   if not IsDisabled(Details) then
782     Result := Result or QStyleState_Enabled;
783 
784   if IsHot(Details) then
785     Result := Result or QStyleState_MouseOver;
786 
787   if IsPushed(Details) then
788     Result := Result or QStyleState_Sunken;
789 
790   if IsMixed(Details) then
791     Result := Result or QStyleState_NoChange
792   else
793   if IsChecked(Details) then
794     Result := Result or QStyleState_On
795   else
796     Result := Result or QStyleState_Off;
797 
798 
799   if (Details.Element = teHeader) then
800   begin
801     if not IsPushed(Details) then
802       Result := Result or QStyleState_Raised;
803     if not IsDisabled(Details) and (Result and QStyleState_Off <> 0) then
804       Result := Result and not QStyleState_Off;
805   end;
806 
807   // specific states
808   {when toolbar = flat, toolbar buttons should be flat too.}
809   if (Details.Element = teToolBar) and
810      (Details.State in [TS_NORMAL, TS_DISABLED]) then
811     Result := QStyleState_AutoRaise;
812 
813   // define orientations
814   if ((Details.Element = teRebar) and (Details.Part = RP_GRIPPER)) or
815      ((Details.Element = teToolBar) and (Details.Part = TP_SEPARATOR)) or
816      ((Details.Element = teScrollBar) and (Details.Part in
817        [SBP_UPPERTRACKHORZ, SBP_LOWERTRACKHORZ, SBP_THUMBBTNHORZ, SBP_GRIPPERHORZ])) or
818      ((Details.Element = teTrackbar) and not (Details.Part in
819        [TKP_TRACKVERT, TKP_THUMBVERT])) then
820     Result := Result or QStyleState_Horizontal;
821 
822   if (Details.Element in [teTreeview, teListView]) then
823   begin
824     if (Details.Element = teTreeView) and
825       (Details.Part in [TVP_GLYPH, TVP_HOTGLYPH]) then
826     begin
827       Result := Result or QStyleState_Children;
828       if Details.State = GLPS_OPENED then
829         Result := Result or QStyleState_Open;
830     end else
831     if Details.Part in [TVP_TREEITEM] then
832     begin
833       Result := Result or QStyleState_Item;
834       case Details.State of
835         TREIS_SELECTED:
836           Result := Result or QStyleState_Selected or QStyleState_HasFocus or QStyleState_Active;
837         TREIS_SELECTEDNOTFOCUS:
838           Result := Result or QStyleState_Selected;
839         TREIS_HOTSELECTED:
840           Result := Result or QStyleState_Selected or QStyleState_MouseOver;
841         TREIS_HOT:
842           Result := Result or QStyleState_MouseOver;
843       end;
844     end;
845   end;
846   if (Details.Element = teTrackBar) then
847   begin
848     if Details.Part in [TKP_THUMB, TKP_THUMBVERT] then
849     begin
850       if Details.State in [TUS_PRESSED, TUS_HOT] then
851         Result := Result or QStyleState_Active or QStyleState_HasFocus or QStyleState_MouseOver;
852     end;
853   end;
854   if (Details.Element = teEdit) and (Details.Part in [EP_EDITTEXT, EP_BACKGROUND, EP_BACKGROUNDWITHBORDER]) then
855   begin
856     if Details.State = ETS_FOCUSED then
857       Result := Result or QStyleState_Active or QStyleState_Enabled or QStyleState_HasFocus;
858 
859     if Details.State = ETS_HOT then
860       Result := Result or QStyleState_MouseOver
861     else
862     if Details.State = ETS_READONLY then
863       Result := Result or QStyleState_ReadOnly
864     else
865     if Details.State = ETS_SELECTED then
866       Result := Result or QStyleState_Selected;
867   end;
868   if (Details.Element = teWindow) then
869   begin
870     if Details.Part in [WP_SMALLCAPTION,
871           WP_FRAMELEFT,
872           WP_FRAMERIGHT,
873           WP_FRAMEBOTTOM,
874           WP_SMALLFRAMELEFT,
875           WP_SMALLFRAMERIGHT,
876           WP_SMALLFRAMEBOTTOM] then
877     begin
878       if Details.State = FS_ACTIVE then
879         Result := Result or QStyleState_Active or QStyleState_HasFocus;
880     end;
881   end;
882 end;
883 
GetDetailSizenull884 function TQtThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
885 begin
886   case Details.Element of
887     teButton:
888       begin
889         if Details.Part = BP_CHECKBOX then
890         begin
891           Result.cy := QStyle_pixelMetric(Style, QStylePM_IndicatorHeight, nil, nil);
892           Result.cx := QStyle_pixelMetric(Style, QStylePM_IndicatorWidth, nil, nil);
893         end else
894         if Details.Part = BP_RADIOBUTTON then
895         begin
896           Result.cy := QStyle_pixelMetric(Style, QStylePM_ExclusiveIndicatorHeight, nil, nil);
897           Result.cx := QStyle_pixelMetric(Style, QStylePM_ExclusiveIndicatorWidth, nil, nil);
898         end else
899           Result := inherited;
900       end;
901     teRebar :
902       if Details.Part in [RP_GRIPPER, RP_GRIPPERVERT] then
903         Result := Size(-1, -1)
904       else
905         Result := inherited;
906     teTreeView:
907       begin
908         Result := inherited;
909         if Details.Part in [TVP_GLYPH, TVP_HOTGLYPH] then
910         begin
911           inc(Result.cx);
912           inc(Result.cy);
913         end;
914       end;
915     teToolBar:
916       if (Details.Part = TP_DROPDOWNBUTTON) or (Details.Part = TP_SPLITBUTTONDROPDOWN) then
917       begin
918         Result.cy := -1;
919         Result.cx := QStyle_pixelMetric(Style, QStylePM_MenuButtonIndicator, nil, nil);
920       end else
921         Result := inherited;
922     teHeader:
923       if Details.Part = HP_HEADERSORTARROW then
924         Result := Size(-1, -1) // not yet supported
925       else
926         Result := inherited;
927     else
928       Result := inherited;
929   end;
930 end;
931 
GetStockImagenull932 function TQtThemeServices.GetStockImage(StockID: LongInt; out Image,
933   Mask: HBitmap): Boolean;
934 var
935   APixmap: QPixmapH;
936   AImage: QImageH;
937   AScaledImage: QImageH;
938   AStdPixmap: QStyleStandardPixmap;
939   opt: QStyleOptionH;
940   IconSize: Integer;
941   AIcon: QIconH;
942   ASize: TSize;
943 begin
944   case StockID of
945     idButtonOk: AStdPixmap := QStyleSP_DialogOkButton;
946     idButtonCancel: AStdPixmap := QStyleSP_DialogCancelButton;
947     idButtonYes: AStdPixmap := QStyleSP_DialogYesButton;
948     idButtonYesToAll: AStdPixmap := QStyleSP_DialogYesButton;
949     idButtonNo: AStdPixmap := QStyleSP_DialogNoButton;
950     idButtonNoToAll: AStdPixmap := QStyleSP_DialogNoButton;
951     idButtonHelp: AStdPixmap := QStyleSP_DialogHelpButton;
952     idButtonClose: AStdPixmap := QStyleSP_DialogCloseButton;
953     idButtonAbort: AStdPixmap := QStyleSP_DialogResetButton;
954     idButtonAll: AStdPixmap := QStyleSP_DialogApplyButton;
955     idButtonIgnore: AStdPixmap := QStyleSP_DialogDiscardButton;
956     idButtonRetry: AStdPixmap := QStyleSP_BrowserReload; // ?
957     idButtonOpen: AStdPixmap := QStyleSP_DialogOpenButton;
958     idButtonSave: AStdPixmap := QStyleSP_DialogSaveButton;
959     idButtonShield: AStdPixmap := QStyleSP_VistaShield;
960 
961     idDialogWarning : AStdPixmap := QStyleSP_MessageBoxWarning;
962     idDialogError: AStdPixmap := QStyleSP_MessageBoxCritical;
963     idDialogInfo: AStdPixmap := QStyleSP_MessageBoxInformation;
964     idDialogConfirm: AStdPixmap := QStyleSP_MessageBoxQuestion;
965   else
966     begin
967        Result := inherited GetStockImage(StockID, Image, Mask);
968        Exit;
969     end;
970   end;
971 
972   opt := QStyleOption_create(QStyleOptionVersion, QStyleOptionSO_Default);
973   AIcon := QIcon_create();
974   if StockID in [idButtonOk..idButtonShield] then
975     IconSize := GetPixelMetric(QStylePM_ButtonIconSize, opt, nil)
976   else
977   if (StockID >= idDialogWarning) and (StockID <= idDialogShield) then
978     IconSize := GetPixelMetric(QStylePM_MessageBoxIconSize, opt, nil)
979   else
980     IconSize := 0;
981   QStyle_standardIcon(QApplication_style(), AIcon, AStdPixmap, opt);
982   QStyleOption_Destroy(opt);
983 
984   if QIcon_isNull(AIcon) then
985   begin
986     QIcon_destroy(AIcon);
987     Result := inherited GetStockImage(StockID, Image, Mask);
988     Exit;
989   end;
990 
991   // convert from what we have to QImageH
992   APixmap := QPixmap_create();
993   if IconSize > 0 then
994   begin
995     ASize.cx := IconSize;
996     ASize.cy := IconSize;
997   end else
998     QIcon_actualSize(AIcon, @ASize, @ASize);
999   QIcon_pixmap(AIcon, APixmap, PSize(@ASize));
1000   QIcon_destroy(AIcon);
1001   AImage := QImage_create();
1002   QPixmap_toImage(APixmap, AImage);
1003   QPixmap_destroy(APixmap);
1004 
1005   // we must respect theme size , qt is buggy somehow, some icons are 22 some 16px.
1006   if IconSize > 0 then
1007   begin
1008     if (QImage_width(AImage) > IconSize) and (QImage_height(AImage) > IconSize) then
1009     begin
1010       AScaledImage := QImage_create();
1011       QImage_scaled(AImage, AScaledImage, IconSize, IconSize, QtKeepAspectRatio, QtSmoothTransformation);
1012       QImage_destroy(AImage);
1013       AImage := QImage_create(AScaledImage);
1014       QImage_destroy(AScaledImage);
1015     end;
1016   end;
1017 
1018   Image := HBitmap(TQtImage.Create(AImage));
1019   Mask := 0;
1020   Result := True;
1021 end;
1022 
GetDrawElementnull1023 function TQtThemeServices.GetDrawElement(Details: TThemedElementDetails): TQtDrawElement;
1024 const
1025   ButtonMap: array[BP_PUSHBUTTON..BP_USERBUTTON] of QStyleControlElement =
1026   (
1027 {BP_PUSHBUTTON } QStyleCE_PushButton,
1028 {BP_RADIOBUTTON} QStyleCE_RadioButton,
1029 {BP_CHECKBOX   } QStyleCE_CheckBox,
1030 {BP_GROUPBOX   } QStyleCE_PushButton,
1031 {BP_USERBUTTON } QStyleCE_PushButton
1032   );
1033 begin
1034   Result.DrawVariant := qdvNone;
1035   case Details.Element of
1036     teButton:
1037       begin
1038         if Details.Part <> BP_GROUPBOX then
1039         begin
1040           Result.DrawVariant := qdvControl;
1041           Result.ControlElement := ButtonMap[Details.Part]
1042         end
1043         else
1044         begin
1045           Result.DrawVariant := qdvComplexControl;
1046           Result.ComplexControl := QStyleCC_GroupBox;
1047           Result.SubControls := QStyleSC_GroupBoxFrame;
1048         end;
1049       end;
1050     teComboBox:
1051       begin
1052         if Byte(Details.Part) in [CP_DROPDOWNBUTTON, CP_DROPDOWNBUTTONRIGHT, CP_DROPDOWNBUTTONLEFT] then
1053         begin
1054           Result.DrawVariant := qdvComplexControl;
1055           Result.ComplexControl := QStyleCC_ComboBox;
1056           Result.SubControls := QStyleSC_ComboBoxArrow;
1057           if Details.Part = CP_DROPDOWNBUTTONLEFT then
1058             Result.Features := Ord(QtRightToLeft)
1059           else
1060             Result.Features := 0;
1061         end else
1062         if not (Details.Part = CP_READONLY) then
1063         begin
1064           Result.DrawVariant := qdvComplexControl;
1065           Result.ComplexControl := QStyleCC_ComboBox;
1066           Result.SubControls := QStyleSC_ComboBoxEditField;
1067         end else
1068         if Byte(Details.Part) in [0, CP_BORDER] then
1069         begin
1070           Result.DrawVariant := qdvComplexControl;
1071           Result.ComplexControl := QStyleCC_ComboBox;
1072           Result.SubControls := QStyleSC_ComboBoxFrame;
1073         end;
1074       end;
1075     teHeader:
1076       begin
1077         case Details.Part of
1078           HP_HEADERITEM,
1079           HP_HEADERITEMLEFT,
1080           HP_HEADERITEMRIGHT:
1081             begin
1082               Result.DrawVariant := qdvControl;
1083               Result.ControlElement := QStyleCE_HeaderSection;
1084             end;
1085           HP_HEADERSORTARROW:
1086             begin
1087               Result.DrawVariant := qdvPrimitive;
1088               Result.PrimitiveElement := QStylePE_IndicatorHeaderArrow;
1089             end;
1090         end;
1091       end;
1092     teToolBar:
1093       begin
1094         case Details.Part of
1095           TP_BUTTON,
1096           TP_DROPDOWNBUTTON,
1097           TP_SPLITBUTTON: // there is another positibility to draw TP_SPLITBUTTON by CC_ToolButton
1098             begin
1099               Result.DrawVariant := qdvPrimitive;
1100               Result.PrimitiveElement := QStylePE_PanelButtonTool;
1101             end;
1102           TP_SPLITBUTTONDROPDOWN:
1103             begin
1104               Result.DrawVariant := qdvComplexControl;
1105               Result.ComplexControl := QStyleCC_ToolButton;
1106               Result.SubControls := QStyleSC_None;
1107               Result.Features := QStyleOptionToolButtonMenuButtonPopup;
1108             end;
1109           TP_SEPARATOR,
1110           TP_SEPARATORVERT:
1111             begin
1112               Result.DrawVariant := qdvPrimitive;
1113               Result.PrimitiveElement := QStylePE_IndicatorToolBarSeparator;
1114             end;
1115         end;
1116       end;
1117     teRebar:
1118       begin
1119         case Details.Part of
1120           RP_GRIPPER, RP_GRIPPERVERT: // used in splitter
1121             begin
1122               Result.DrawVariant := qdvControl;
1123               Result.ControlElement := QStyleCE_Splitter;
1124             end;
1125         end;
1126       end;
1127     teEdit:
1128       begin
1129         Result.DrawVariant := qdvPrimitive;
1130         if Details.Part in [0, EP_EDITTEXT, EP_CARET, EP_BACKGROUND, EP_BACKGROUNDWITHBORDER] then
1131           Result.PrimitiveElement := QStylePE_FrameLineEdit;
1132       end;
1133     teSpin:
1134       begin
1135         Result.DrawVariant := qdvComplexControl;
1136         Result.ComplexControl := QStyleCC_SpinBox;
1137         if Details.Part = 0 then
1138           Result.SubControls := QStyleSC_SpinBoxFrame
1139         else
1140         if Byte(Details.Part) in [SPNP_UP, SPNP_UPHORZ] then
1141           Result.SubControls := QStyleSC_SpinBoxUp
1142         else
1143         if Byte(Details.Part) in [SPNP_DOWN, SPNP_DOWNHORZ] then
1144           Result.SubControls := QStyleSC_SpinBoxDown;
1145         if Byte(Details.Part) in [SPNP_UPHORZ, SPNP_DOWNHORZ] then
1146           Result.Features := QtVertical;
1147       end;
1148     teWindow:
1149       begin
1150         case Details.Part of
1151           WP_FRAMELEFT,
1152           WP_FRAMERIGHT,
1153           WP_FRAMEBOTTOM,
1154           WP_SMALLFRAMELEFT,
1155           WP_SMALLFRAMERIGHT,
1156           WP_SMALLFRAMEBOTTOM:
1157           begin
1158             Result.PrimitiveElement := QStylePE_FrameWindow;
1159             Result.DrawVariant := qdvPrimitive;
1160             exit;
1161           end;
1162           WP_SMALLCLOSEBUTTON:
1163           begin
1164             Result.DrawVariant := qdvStandardPixmap;
1165             Result.StandardPixmap := QStyleSP_TitleBarCloseButton;
1166             exit;
1167           end;
1168 
1169           WP_SMALLCAPTION: Result.SubControls := QStyleSC_TitleBarLabel;
1170           WP_SYSBUTTON: Result.SubControls := QStyleSC_TitleBarSysMenu;
1171           WP_MINBUTTON: Result.SubControls := QStyleSC_TitleBarMinButton;
1172           WP_MAXBUTTON: Result.SubControls := QStyleSC_TitleBarMaxButton;
1173           WP_CLOSEBUTTON: Result.SubControls := QStyleSC_TitleBarCloseButton;
1174           WP_RESTOREBUTTON: Result.SubControls := QStyleSC_TitleBarNormalButton;
1175           WP_HELPBUTTON: Result.SubControls := QStyleSC_TitleBarContextHelpButton;
1176           WP_MDIHELPBUTTON: Result.SubControls := QStyleSC_TitleBarContextHelpButton;
1177           WP_MDIMINBUTTON: Result.SubControls := QStyleSC_MdiMinButton;
1178           WP_MDICLOSEBUTTON: Result.SubControls := QStyleSC_MdiCloseButton;
1179           WP_MDIRESTOREBUTTON: Result.SubControls := QStyleSC_MdiNormalButton;
1180         else
1181           Result.SubControls := QStyleSC_None;
1182         end;
1183 
1184         if Result.SubControls <= QStyleSC_MdiCloseButton then
1185           Result.ComplexControl := QStyleCC_MdiControls
1186         else
1187           Result.ComplexControl := QStyleCC_TitleBar;
1188 
1189         Result.DrawVariant := qdvComplexControl;
1190 {
1191         // maybe through icon
1192         Result.DrawVariant := qdvStandardPixmap;
1193         case Details.Part of
1194           WP_MINBUTTON: Result.StandardPixmap := QStyleSP_TitleBarMinButton;
1195           WP_MDIMINBUTTON: Result.StandardPixmap := QStyleSP_TitleBarMinButton;
1196           WP_MAXBUTTON: Result.StandardPixmap := QStyleSP_TitleBarMaxButton;
1197           WP_CLOSEBUTTON: Result.StandardPixmap := QStyleSP_TitleBarCloseButton;
1198           WP_SMALLCLOSEBUTTON: Result.StandardPixmap := QStyleSP_TitleBarCloseButton;
1199           WP_MDICLOSEBUTTON: Result.StandardPixmap := QStyleSP_TitleBarCloseButton;
1200           WP_RESTOREBUTTON: Result.StandardPixmap := QStyleSP_TitleBarNormalButton;
1201           WP_MDIRESTOREBUTTON: Result.StandardPixmap := QStyleSP_TitleBarNormalButton;
1202           WP_HELPBUTTON: Result.StandardPixmap := QStyleSP_TitleBarContextHelpButton;
1203           WP_MDIHELPBUTTON: Result.StandardPixmap := QStyleSP_TitleBarContextHelpButton;
1204         else
1205           Result.StandardPixmap := QStyleSP_TitleBarCloseButton;
1206         end;
1207 }
1208       end;
1209     teTab:
1210       begin
1211         if Byte(Details.Part) in [TABP_TABITEM, TABP_TABITEMLEFTEDGE, TABP_TABITEMRIGHTEDGE, TABP_TOPTABITEM] then
1212         begin
1213           Result.DrawVariant := qdvControl;
1214           Result.ControlElement := QStyleCE_TabBarTabShape;
1215           if Details.Part = TABP_TABITEM then
1216             Result.Features := Ord(QTabBarRoundedNorth)
1217           else
1218           if Details.Part = TABP_TABITEMLEFTEDGE then
1219             Result.Features := Ord(QTabBarRoundedWest)
1220           else
1221           if Details.Part = TABP_TABITEMRIGHTEDGE then
1222             Result.Features := Ord(QTabBarRoundedEast)
1223           else
1224             Result.Features := Ord(QTabBarRoundedNorth);
1225         end else
1226         if Details.Part = TABP_PANE then
1227         begin
1228           Result.DrawVariant := qdvPrimitive;
1229           Result.PrimitiveElement := QStylePE_FrameTabWidget;
1230         end else
1231         if Details.Part = TABP_BODY then
1232         begin
1233           Result.DrawVariant := qdvPrimitive;
1234           Result.PrimitiveElement := QStylePE_FrameTabBarBase;
1235         end;
1236       end;
1237     teProgress:
1238       begin
1239         Result.DrawVariant := qdvControl;
1240         case Details.Part of
1241           PP_CHUNK,PP_CHUNKVERT: Result.ControlElement := QStyleCE_ProgressBarContents;
1242           PP_FILL,PP_FILLVERT: Result.ControlElement := QStyleCE_ProgressBarGroove;
1243           else
1244             Result.ControlElement := QStyleCE_ProgressBar;
1245         end;
1246         if Byte(Details.Part) in [PP_BARVERT, PP_FILLVERT, PP_CHUNKVERT] then
1247           Result.Features := QtVertical;
1248       end;
1249     teScrollBar:
1250       begin
1251         Result.DrawVariant := qdvComplexControl;
1252         Result.ComplexControl := QStyleCC_ScrollBar;
1253         case Details.Part of
1254           SBP_ARROWBTN: Result.SubControls := QStyleSC_ScrollBarAddLine;
1255           SBP_THUMBBTNHORZ,
1256           SBP_THUMBBTNVERT,
1257           SBP_GRIPPERHORZ,
1258           SBP_GRIPPERVERT: Result.SubControls := QStyleSC_ScrollBarSlider;
1259           SBP_LOWERTRACKHORZ,
1260           SBP_LOWERTRACKVERT: Result.SubControls := QStyleSC_ScrollBarAddPage;
1261           SBP_UPPERTRACKHORZ,
1262           SBP_UPPERTRACKVERT: Result.SubControls := QStyleSC_ScrollBarSubPage;
1263         else
1264           Result.SubControls := QStyleSC_None;
1265         end;
1266       end;
1267     teTrackBar:
1268       begin
1269         Result.DrawVariant := qdvComplexControl;
1270         Result.ComplexControl := QStyleCC_Slider;
1271         if Details.Part in [TKP_TRACKVERT, TKP_THUMBVERT, TKP_TICSVERT] then
1272           Result.Features := QtVertical
1273         else
1274           Result.Features := QtHorizontal;
1275         case Details.Part of
1276           TKP_TRACK,
1277           TKP_TRACKVERT: Result.SubControls := QStyleSC_SliderGroove;
1278           TKP_THUMB,
1279           TKP_THUMBBOTTOM,
1280           TKP_THUMBTOP,
1281           TKP_THUMBVERT,
1282           TKP_THUMBLEFT,
1283           TKP_THUMBRIGHT: Result.SubControls := QStyleSC_SliderHandle;
1284           TKP_TICS,
1285           TKP_TICSVERT: Result.SubControls := QStyleSC_SliderTickmarks;
1286         end;
1287       end;
1288     teStatus:
1289       begin
1290         case Details.Part of
1291           SP_PANE:
1292             begin
1293               Result.DrawVariant := qdvPrimitive;
1294               Result.PrimitiveElement := QStylePE_FrameStatusBar;
1295             end;
1296           SP_GRIPPER:
1297             begin
1298               Result.DrawVariant := qdvControl;
1299               Result.ControlElement := QStyleCE_SizeGrip;
1300             end;
1301           SP_GRIPPERPANE:
1302             begin
1303               Result.DrawVariant := qdvPrimitive;
1304               Result.PrimitiveElement := QStylePE_FrameStatusBarItem;
1305             end;
1306         end;
1307       end;
1308     teTreeView, teListView:
1309       begin
1310         if (Details.Element = teTreeView) and
1311           (Details.Part in [TVP_GLYPH, TVP_HOTGLYPH]) then
1312         begin
1313           Result.DrawVariant := qdvPrimitive;
1314           Result.PrimitiveElement := QStylePE_IndicatorBranch;
1315         end else
1316         if Details.Part in [TVP_TREEITEM] then
1317         begin
1318           Result.DrawVariant := qdvControl;
1319           Result.ControlElement := QStyleCE_ItemViewItem;
1320         end;
1321       end;
1322     teToolTip:
1323       begin
1324         if Details.Part = TTP_STANDARD then
1325         begin
1326           Result.DrawVariant := qdvPrimitive;
1327           Result.PrimitiveElement := QStylePE_PanelTipLabel;
1328         end;
1329       end;
1330   end;
1331 end;
1332 
1333 end.
1334 
1335 
1336