1{%MainUnit ../interfacebase.pp}
2
3{ $Id$ }
4{******************************************************************************
5                                  TWidgetSet
6
7                                   WinApi stuff
8
9  !! In this file only winapi related code as defined in winapih.inc
10     Most routines implement only the default
11
12  !! Keep this alphabetical !!
13 ******************************************************************************
14
15 *****************************************************************************
16  This file is part of the Lazarus Component Library (LCL)
17
18  See the file COPYING.modifiedLGPL.txt, included in this distribution,
19  for details about the license.
20 *****************************************************************************
21}
22//##apiwiz##sps##   // Do not remove
23
24function TWidgetSet.Arc(DC: HDC;
25  Left, Top, Right, Bottom, Angle16Deg, Angle16DegLength: Integer): Boolean;
26var
27  Points : PPoint;
28  Count : Longint;
29begin
30  Result := False;
31  Points := nil;
32  Count := 0;
33  PolyBezierArcPoints(Left, Top, Right-Left, Bottom-Top, Angle16Deg, Angle16DegLength, 0,
34                      Points, Count);
35  Polyline(DC, Points, Count);
36  ReallocMem(Points, 0);
37  Result := True;
38end;
39
40function TWidgetSet.AngleChord(DC: HDC; x1, y1, x2, y2, angle1, angle2: Integer): Boolean;
41var
42  Points : PPoint;
43  Count : Longint;
44begin
45  Result := False;
46  Points := nil;
47  Count := 0;
48  PolyBezierArcPoints(x1, y1, x2-x1, y2-y1, Angle1, Angle2, 0, Points, Count);
49  Inc(Count);
50  ReallocMem(Points, Count*SizeOf(TPoint));
51  Points[Count - 1] := Points[0];
52  Polygon(DC, Points, Count, True);
53  ReallocMem(Points, 0);
54  Result := True;
55end;
56
57function TWidgetSet.BeginPaint(Handle: hwnd; var PS: TPaintStruct): hdc;
58begin
59  Result:=GetDC(Handle);
60end;
61
62function TWidgetSet.BitBlt(DestDC: HDC; X, Y, Width, Height: Integer;
63  SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
64begin
65  Result := False;
66end;
67
68function TWidgetSet.CallNextHookEx(hhk : HHOOK; ncode : Integer;
69  WParam: WParam; LParam: LParam) : Integer;
70begin
71  Result := 0;
72end;
73
74function TWidgetSet.CallWindowProc(lpPrevWndFunc: TFarProc; Handle: HWND;
75  Msg: UINT; WParam: WParam; LParam: LParam): Integer;
76begin
77  Result:=0;
78end;
79
80function TWidgetSet.ClientToScreen(Handle : HWND; var P : TPoint) : Boolean;
81begin
82  Result := False;
83end;
84
85function TWidgetSet.CombineRgn(Dest, Src1, Src2 : HRGN; fnCombineMode : Longint) : Longint;
86begin
87  Result := ERROR;
88end;
89
90function TWidgetSet.CreateBitmap(Width, Height: Integer;
91  Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP;
92begin
93  Result := 0;
94end;
95
96function TWidgetSet.CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader;
97  dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: UINT): HBITMAP;
98begin
99  Result := 0;
100end;
101
102function TWidgetSet.CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH;
103begin
104  Result := 0;
105end;
106
107function TWidgetSet.CreateBrushWithRadialGradient(const LogBrush: TLogRadialGradient): HBRUSH;
108begin
109  Result := 0;
110end;
111
112function TWidgetSet.CreateCaret(Handle : HWND; Bitmap : hBitmap; width, Height : Integer) : Boolean;
113begin
114  Result := False;
115end;
116
117function TWidgetSet.CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP;
118begin
119  Result := 0;
120end;
121
122function TWidgetSet.CreateCompatibleDC(DC: HDC): HDC;
123begin
124  Result := 0;
125end;
126
127function TWidgetSet.CreateDIBSection(DC: HDC;
128  const BitmapInfo: tagBitmapInfo; Usage: UINT;
129  var Bits: Pointer; SectionHandle: THandle; Offset: DWORD): HBITMAP;
130begin
131  Result := 0;
132end;
133
134function TWidgetSet.CreateEllipticRgn(X1, Y1, X2, Y2: Integer): HRGN;
135begin
136  Result:=ERROR;
137  DebugLn('WARNING: CreateEllipticRgn not yet implemented.');
138end;
139
140function TWidgetSet.CreateFontIndirect(const LogFont: TLogFont): HFONT;
141begin
142  Result := 0;
143end;
144
145function TWidgetSet.CreateFontIndirectEx(const LogFont: TLogFont;
146  const LongFontName: string): HFONT;
147begin
148  // this functions is needed, because the fontname in TLogFont is limited to
149  // 32 characters. If the interface does not support long font names, it can
150  // simple omit this function
151  Result := CreateFontIndirect(LogFont);
152end;
153
154function TWidgetSet.CreateIconIndirect(IconInfo: PIconInfo): HICON;
155begin
156  Result := 0;
157end;
158
159function TWidgetSet.CreatePalette(const LogPalette: TLogPalette): HPalette;
160begin
161  Result := 0;
162end;
163
164function TWidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
165begin
166  Result := 0;
167end;
168
169function TWidgetSet.CreatePenIndirect(const LogPen: TLogPen): HPEN;
170begin
171  Result := 0;
172end;
173
174function TWidgetSet.CreatePolygonRgn(Points: PPoint; NumPts: Integer;
175  FillMode: integer): HRGN;
176begin
177  Result := 0;
178end;
179
180function TWidgetSet.CreateRectRgn(X1,Y1,X2,Y2 : Integer): HRGN;
181begin
182  Result := 0;
183end;
184
185{
186  In each of the 4 corners an ellipse will be created which has the expected
187  nWidthEllipse and nHeightEllipse. Then we need to create a square in the
188  appropriate corner of the ellipse, according to where it will be placed.
189  CornerCutRgn = Execute AND between the rectangle and ellipse.
190  CornerCutRgn = Execute SUB between the CornerCutRgn and the rectangle. (To invert it)
191  Execute SUB between each r2 and the rectangle and get the final rounded rectangle.
192}
193function TWidgetSet.CreateRoundRectRgn(X1, Y1, X2, Y2, nWidthEllipse, nHeightEllipse: Integer): HRGN;
194var
195  RoundRgn, CornerSquareRgn, CornerCutRgn: HRGN;
196  nHalfX,nHalfY, tmp:integer;
197begin
198  if (X1 > X2) then begin
199    tmp := X1;
200    X1 := X2;
201    X2 := tmp;
202  end;
203
204  if (Y1 > Y2) then begin
205    tmp := Y1;
206    Y1 := Y2;
207    Y2 := tmp;
208  end;
209
210  // The resulting region
211  Result := CreateRectRgn(X1, Y1, X2, Y2);
212
213  if not ((nWidthEllipse = 0) and (nHeightEllipse = 0)) then
214  begin
215    nWidthEllipse := abs(nWidthEllipse);
216    nHeightEllipse := abs(nHeightEllipse);
217
218    if (nWidthEllipse > X2 - X1) then nWidthEllipse := X2 - X1;
219    if (nHeightEllipse > Y2 - Y1) then nHeightEllipse := Y2 - Y1;
220
221    nHalfX := nWidthEllipse div 2;
222    nHalfY := nHeightEllipse div 2;
223
224    // We create this region with dummy values just because
225    // CombineRgn requires an existing region to receive the result
226    CornerCutRgn := CreateRectRgn(0, 0, nWidthEllipse, nHeightEllipse);
227
228    // Top-left corner
229    RoundRgn := CreateEllipticRgn(X1, Y1, X1 + nWidthEllipse, Y1 + nHeightEllipse);
230    CornerSquareRgn := CreateRectRgn(X1, Y1, X1 + nHalfX, Y1 + nHalfY);
231    CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
232    CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
233    CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
234    DeleteObject(RoundRgn);
235    DeleteObject(CornerSquareRgn);
236
237    // Bottom-left corner
238    RoundRgn := CreateEllipticRgn(X1, Y2 - nHeightEllipse, X1 + nWidthEllipse, Y2);
239    CornerSquareRgn := CreateRectRgn(X1, Y2 - nHalfX, X1 + nHalfY, Y2);
240    CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
241    CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
242    CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
243    DeleteObject(RoundRgn);
244    DeleteObject(CornerSquareRgn);
245
246    // Top-Right corner
247    RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y1, X2, Y1 + nHeightEllipse);
248    CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y1, X2, Y1 + nHalfY);
249    CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
250    CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
251    CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
252    DeleteObject(RoundRgn);
253    DeleteObject(CornerSquareRgn);
254
255    // Bottom-Right corner
256    RoundRgn := CreateEllipticRgn(X2 - nWidthEllipse, Y2 - nHeightEllipse, X2, Y2);
257    CornerSquareRgn := CreateRectRgn(X2 - nHalfX, Y2 - nHalfY, X2, Y2);
258    CombineRgn(CornerCutRgn, RoundRgn, CornerSquareRgn, RGN_AND);
259    CombineRgn(CornerCutRgn, CornerSquareRgn, CornerCutRgn, RGN_DIFF);
260    CombineRgn(Result, Result, CornerCutRgn, RGN_DIFF);
261    DeleteObject(RoundRgn);
262    DeleteObject(CornerSquareRgn);
263
264    DeleteObject(CornerCutRgn);
265  end;
266end;
267
268procedure TWidgetSet.DeleteCriticalSection(var CritSection: TCriticalSection);
269begin
270  DebugLn('TWidgetSet.DeleteCriticalSection Not implemented yet');
271end;
272
273function TWidgetSet.DeleteDC(hDC: HDC): Boolean;
274begin
275  Result := False;
276end;
277
278function TWidgetSet.DeleteObject(GDIObject: HGDIOBJ): Boolean;
279begin
280  Result := False;
281end;
282
283function TWidgetSet.DestroyCaret(Handle : HWND): Boolean;
284begin
285  Result := False;
286end;
287
288function TWidgetSet.DestroyCursor(Handle: HCURSOR): Boolean;
289begin
290  Result := DestroyIcon(Handle);
291end;
292
293function TWidgetSet.DestroyIcon(Handle: HICON): Boolean;
294begin
295  Result := False;
296end;
297
298function TWidgetSet.DrawFrameControl(DC: HDC; const Rect : TRect; uType, uState : Cardinal) : Boolean;
299var
300  Details: TThemedElementDetails;
301  ButtonDetail: TThemedButton;
302  ToolBarDetail: TThemedToolBar;
303begin
304  if uType = DFC_BUTTON then
305  begin
306    ButtonDetail := tbButtonDontCare;
307    case (uState and $1F) of
308      DFCS_BUTTONCHECK:
309        if uState and DFCS_CHECKED <> 0 then
310          ButtonDetail := tbCheckBoxCheckedNormal
311        else
312          ButtonDetail := tbCheckBoxUncheckedNormal;
313      DFCS_BUTTONRADIO:
314        if uState and DFCS_CHECKED <> 0 then
315          ButtonDetail := tbRadioButtonCheckedNormal
316        else
317          ButtonDetail := tbRadioButtonUncheckedNormal;
318      DFCS_BUTTONPUSH:
319        ButtonDetail := tbPushButtonNormal;
320    end;
321
322    if (uState and DFCS_INACTIVE) <> 0 then
323      inc(ButtonDetail, 3)
324    else
325    if (uState and DFCS_PUSHED) <> 0 then
326      inc(ButtonDetail, 2)
327    else
328    if (uState and DFCS_HOT) <> 0 then
329      inc(ButtonDetail, 1);
330
331    if (uState and DFCS_BUTTONPUSH <> 0) and (uState and DFCS_FLAT <> 0) then
332    begin
333      ToolBarDetail := ttbButtonNormal;
334      inc(ToolBarDetail, Integer(ButtonDetail) - Integer(tbPushButtonNormal));
335      Details := ThemeServices.GetElementDetails(ToolBarDetail);
336    end
337    else
338      Details := ThemeServices.GetElementDetails(ButtonDetail);
339
340    ThemeServices.DrawElement(DC, Details, Rect);
341{    if uState and DFCS_ADJUSTRECT then
342      Rect := ThemeServices.ContentRect(DC, Details, Rect);
343}
344    Result := True;
345  end
346  else
347    Result := False;
348end;
349
350function TWidgetSet.DrawFocusRect(DC: HDC; const Rect: TRect): Boolean;
351begin
352  Result := false;
353end;
354
355function TWidgetSet.DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean;
356begin
357  Result := False;
358end;
359
360function TWidgetSet.DrawText(DC: HDC; Str: PChar; Count: Integer;
361  var Rect: TRect; Flags: Cardinal): Integer;
362var
363  AP : TSize;
364  TM : TTextmetric;
365  theRect     : TRect;
366  aLeft,aTop,
367  I       : Integer;
368  Lines : TStrings;
369  TDC : hDC;
370  tmpString,
371  AStr : String;
372  pIndex,
373  pX1, pX2, pY : Longint;
374  B, P : HGDIOBJ;
375  LogP : TLogPen;
376  MaxLength : Integer;
377  Pt : TPoint;
378
379  function LeftOffset : Longint;
380  begin
381    If (Flags and DT_Right) = DT_Right then
382      Result := DT_Right
383    else
384      If (Flags and DT_CENTER) = DT_CENTER then
385        Result := DT_CENTER
386    else
387      Result := DT_LEFT;
388  end;
389
390  function TopOffset : Longint;
391  begin
392    If (Flags and DT_BOTTOM) = DT_BOTTOM then
393      Result := DT_BOTTOM
394    else
395      If (Flags and DT_VCENTER) = DT_VCENTER then
396        Result := DT_VCENTER
397    else
398      Result := DT_Top;
399  end;
400
401  function SingleLine : Boolean;
402  begin
403    Result := (Flags and DT_SingleLine) = DT_SingleLine;
404  end;
405
406  function WordWrap : Boolean;
407  begin
408    Result := (Flags and DT_WordBreak) = DT_WordBreak;
409  end;
410
411  function CalcRect : Boolean;
412  begin
413    Result := (Flags and DT_CalcRect) = DT_CalcRect;
414  end;
415
416  function NOCLIP : Boolean;
417  begin
418    Result := (Flags and DT_NOCLIP) = DT_NOCLIP;
419  end;
420
421  function NoPrefix : Boolean;
422  begin
423    Result := (Flags and DT_NoPrefix) = DT_NoPrefix;
424  end;
425
426  function Breakable(Breaks : TIntegerList; Index : Integer) : Boolean;
427  begin
428    If not Assigned(Breaks) then
429      exit(false);
430    Result := Breaks.IndexOf(Index) <> -1;
431  end;
432
433  function NextBreakable(Breaks : TIntegerList; Index : Integer) : Integer;
434  begin
435    Result := -1;
436    If (not Assigned(Breaks)) or (not Breakable(Breaks,Index)) then
437      exit;
438    If Breaks.IndexOf(Index) >= Breaks.Count - 1 then
439      exit;
440    Result := Breaks[Breaks.IndexOf(Index) + 1];
441  end;
442
443  function GetBreakablePoints(const Source : String) : TIntegerList;
444  var
445    I : Integer;
446  begin
447    Result := TIntegerList.Create;
448    If Source = '' then
449      exit;
450    For I := 1 to Length(Source) do
451      If Source[I] = ' ' then
452        If not Breakable(Result, I) then
453          Result.Add(I);
454    If not Breakable(Result, Length(Source)) then
455      Result.Add(Length(Source));
456    If not Breakable(Result, 0) then
457      Result.Insert(0,-1);
458  end;
459
460  function TextExtent(Handle : hDC; const Source : String) : TSize;
461  var
462    pStr : PChar;
463  begin
464    pStr := StrAlloc(Length(Source)+1);
465    try
466      StrPCopy(pStr, Source);
467      GetTextExtentPoint(Handle, pStr, Length(Source), Result);
468    finally
469      StrDispose(PStr);
470    end;
471  end;
472
473  function GetStringLength(Handle : hDC; const Source : String;
474    FromPos, ToPos : Integer) : Integer;
475  var
476    Tmp : String;
477  begin
478    Tmp := Copy(Source,FromPos,ToPos - FromPos);
479    Result := TextExtent(Handle, Tmp).cX;
480    SetLength(Tmp,0);
481  end;
482
483  function GetStringHeight(Handle : hDC; const Source : String;
484    FromPos, ToPos : Integer) : Integer;
485  var
486    Tmp : String;
487  begin
488    Tmp := Copy(Source,FromPos,ToPos - FromPos);
489    Result := TextExtent(Handle,Tmp).cY;
490    SetLength(Tmp,0);
491  end;
492
493  function BreakString(const Source : String) : TStrings;
494  var
495    I, FromPos, ToPos : Integer;
496    Breaks : TIntegerList;
497  begin
498    Result := TStringList.Create;
499    Breaks := GetBreakablePoints(Source);
500    If Breaks.Count <= 0 then begin
501      Result.Append(Source);
502      Breaks.Free;
503      exit;
504    end;
505    FromPos := 1;
506    ToPos := 0;
507    I := 1;
508    Repeat
509      If Breakable(Breaks,I) then begin
510        If NextBreakable(Breaks,I) <> -1 then begin
511          TmpString := Copy(Source, FromPos, NextBreakable(Breaks,I) - FromPos + 1);
512          If not NoPrefix then
513            DeleteAmpersands(tmpString);
514          If TextExtent(DC, TmpString).cX > MaxLength
515          then begin
516            ToPos := I;
517            Result.Append(Copy(Source,FromPos,ToPos - FromPos + 1));
518            FromPos := ToPos + 1;
519            I := FromPos;
520          end
521          Else
522            I := NextBreakable(Breaks,I);
523        end
524        else begin
525          ToPos := I;
526          Result.Append(Copy(Source,FromPos,ToPos - FromPos + 1));
527          FromPos := ToPos + 1;
528          I := FromPos;
529        end;
530      end else
531        I := I + 1;
532    until I > Length(Source);
533    SetLength(TmpString,0);
534    Breaks.Free;
535  end;
536
537  function DoBreakString(const AStr : String) : TStrings;
538  var
539    TS : TStrings;
540    Num : Longint;
541    OldText, NewText : String;
542  begin
543    Result := TStringList.Create;
544    If not SingleLine then begin
545      OldText := AStr;
546      Num := pos(#10,OldText);
547      while Num > 0 do begin
548        NewText := Copy(OldText,1,Num);
549        Case OldText[Num] of
550          #13,#10 : Delete(NewText,Num,1);
551        end;
552        If Num -1 > 0 then
553          Case OldText[Num-1] of
554            #13,#10 : Delete(NewText,Num-1,1);
555          end;
556        If WordWrap then begin
557          TS := BreakString(Copy(NewText,1,Length(NewText)));
558          Result.AddStrings(TS);
559          TS.Free;
560        end
561        else
562          Result.Append(Copy(NewText,1,Length(NewText)));
563        Delete(OldText,1,Num);
564        Num := pos(#10,OldText);
565        SetLength(NewText,0);
566      end;
567      if OldText <> '' then
568        If WordWrap then begin
569          TS := BreakString(Copy(OldText,1,Length(OldText)));
570          Result.AddStrings(TS);
571          TS.Free;
572        end
573        else
574          Result.Append(Copy(OldText,1,Length(OldText)));
575    end
576    else
577      Result.Append(AStr);
578  end;
579
580  procedure CalcTextRect;
581  var
582    J, wT,hT : Integer;
583  begin
584    theRect:=Rect;
585    {Initialize text width/height}
586    wT := Tm.tmAveCharWidth*StrLen(Str);
587    hT := TM.tmHeight;
588
589    If Lines.Count = 1 then begin
590      {Get text width/height if only one line}
591      AStr := Lines[0];
592      If not NoPrefix then
593        DeleteAmpersands(aStr);
594      hT := TM.tmHeight;
595      wT := GetStringLength(DC, AStr,1, Length(AStr) + 1);
596    end
597    else begin
598      {Get text width/height if more than one line}
599      hT := hT* (Lines.Count);
600      wT := 0;
601      For J := 0 to Lines.Count - 1 do begin
602        AStr := Lines[J];
603        If not NoPrefix then
604          DeleteAmpersands(aStr);
605        If wT < GetStringLength(DC, AStr,1, Length(AStr) + 1)
606        then
607          wT := GetStringLength(DC, AStr,1, Length(AStr) + 1);
608      end;
609    end;
610
611    theRect.Right := theRect.Left + wT;
612    If not CalcRect then
613      Case LeftOffset of
614        DT_CENTER :
615          OffsetRect(theRect, (Rect.Right - theRect.Right) div 2, 0);
616        DT_Right :
617          OffsetRect(theRect, Rect.Right - theRect.Right, 0);
618      end;
619
620    theRect.Bottom := theRect.Top + hT;
621
622    {If SingleLine allow vertical offset}
623    If not CalcRect then
624      If SingleLine then
625        Case TopOffset of
626          DT_VCENTER :
627            OffsetRect(theRect, 0, (Rect.Bottom - theRect.Bottom) div 2);
628          DT_Bottom :
629            OffsetRect(theRect, 0, Rect.Bottom - theRect.Bottom);
630        end;
631  end;
632var
633  pStr: PChar;
634begin
635  Result := 0;
636  Lines := nil;
637
638  {Get accurate string length, if none was given}
639  If Count < 0 then
640    Count := StrLen(Str);
641
642  {Calculate # Lines, etc.}
643  if Count > 0 then
644  begin
645    pStr := StrAlloc(Count + 1);
646    try
647      StrLCopy(pStr, Str, Count);
648      pStr[Count] := #0;
649      AStr := String(pStr);
650    finally
651      StrDispose(pStr);
652    end;
653  end
654  else
655    AStr := '';
656
657  tmpString := Copy(AStr, 1, Length(AStr));
658
659  {Get font & string metrics}
660  GetTextMetrics(DC, TM);
661  If not NoPrefix then
662    DeleteAmpersands(tmpString);
663
664  If tmpString > '' then begin
665    AP:=TextExtent(DC, tmpString);
666    AP.cX := AP.cX div Length(tmpString);
667  end
668  else begin
669    AP.cY := TM.tmHeight;
670    AP.cX := TM.tmAveCharWidth;
671  end;
672
673  {Break string into individual lines}
674  MaxLength := (Rect.Right - Rect.Left);
675  Lines := DoBreakString(AStr);
676
677  {Error occcured...}
678  If Lines = nil then
679    exit;
680
681  {Calculate the text's bounding rect}
682  CalcTextRect;
683
684  {If just calculating rect, finish up here}
685  If CalcRect then begin
686    Rect:=theRect;
687    Lines.Free;
688    exit;
689  end;
690
691  {Backup device-context}
692  TDC := SaveDC(DC);
693
694  {Set clipping area if enabled}
695  If not NOCLIP then begin
696    If theRect.Right > Rect.Right then
697      theRect.Right := Rect.Right;
698    If theRect.Bottom > Rect.Bottom then
699      theRect.Bottom := Rect.Bottom;
700    IntersectClipRect(DC, theRect.Left, theRect.Top,
701      theRect.Right, theRect.Bottom);
702  end;
703
704  {Select NULL brush}
705  B := SelectObject(DC, GetStockObject(NULL_BRUSH));
706
707  {Create & select pen of font color}
708  LogP.lopnStyle := PS_SOLID;
709  LogP.lopnWidth.X := 1;
710  LogP.lopnColor := GetTextColor(DC);
711  P := SelectObject(DC, CreatePenIndirect(LogP));
712
713  for I := 0 to Lines.Count - 1 do begin
714    {Set vertical position for line}
715    aTop := theRect.Top + I*TM.tmHeight;
716
717    if (aTop >= Rect.Top) and (aTop <= Rect.Bottom)
718    then begin
719      AStr := Lines[I];
720
721      {Remove ampersands & get index of prefix}
722      If not NoPrefix then
723        pIndex := DeleteAmpersands(aStr)
724      else
725        pIndex := -1;
726
727      {Offset line according to orientation}
728      Case LeftOffset of
729        DT_Left:
730          aLeft := theRect.Left;
731        DT_Center:
732          aLeft := theRect.Left + (theRect.Right - theRect.Left) div 2
733                   - TextExtent(DC, aStr).cX div 2;
734        DT_Right:
735          aLeft := theRect.Right - TextExtent(DC, AStr).cX;
736      end;
737
738      {Draw line of Text}
739      TextOut(DC, aLeft, aTop, PChar(AStr), Length(AStr));
740
741      {Prefix drawing}
742      If pIndex > 0 then begin
743        {Get prefix line position}
744        pX1 := aLeft + GetStringLength(DC, AStr, 1, pIndex);
745        pX2 := pX1 + GetStringLength(DC, AStr, pIndex, pIndex + 1);
746        pY := aTop + tm.tmHeight - TM.tmDescent + 1;
747
748        {Draw prefix line}
749        MoveToEx(DC, pX1, PY, @Pt);
750        LineTo(DC, pX2, pY);
751
752        {Reset pen position}
753        MoveToEx(DC, Pt.X, Pt.Y, nil);
754      end;
755    end;
756  end;
757
758  {Reset brush}
759  SelectObject(DC, B);
760
761  {Reset pen}
762  DeleteObject(SelectObject(DC, P));
763
764  {Finalize Lines}
765  Lines.Free;
766
767  {Restore device-context}
768  RestoreDC(DC, TDC);
769
770  Result := 1;
771end;
772
773function TWidgetSet.DPtoLP(DC: HDC; var Points; Count: Integer): BOOL;
774begin
775  Result := False;
776end;
777
778function TWidgetSet.EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean;
779begin
780  Result := False;
781end;
782
783function TWidgetSet.EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean;
784begin
785  Result := False;
786end;
787
788function TWidgetSet.EndPaint(Handle : hwnd; var PS : TPaintStruct): Integer;
789begin
790  Result:=1;
791end;
792
793procedure TWidgetSet.EnterCriticalSection(var CritSection: TCriticalSection);
794begin
795  DebugLn('TWidgetSet.EnterCriticalSection Not implemented yet');
796end;
797
798function TWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool;
799begin
800  Result := False;
801end;
802
803function TWidgetSet.EnumFontFamilies(DC: HDC; Family: Pchar; EnumFontFamProc: FontEnumProc; LParam:Lparam):longint;
804begin
805  DebugLn('EnumFontFamilies is not yet implemented for this widgetset');
806  Result := 0;
807end;
808
809function TWidgetSet.EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont;
810  Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint;
811begin
812  DebugLn('EnumFontFamiliesEx is not yet implemented for this widgetset');
813  Result := 0;
814end;
815
816function TWidgetSet.Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean;
817var
818  Points : PPoint;
819  Count : Longint;
820  X, Y : Longint;
821begin
822  Result := False;
823  Points := nil;
824  Count := 0;
825  If X2 < X1 then begin
826    X := X2;
827    X2 := X1;
828    X1 := X;
829  end;
830  If Y2 < Y1 then begin
831    Y := Y2;
832    Y2 := Y1;
833    Y1 := Y;
834  end;
835  If (ABS(Y2 - Y1) > 0) and (ABS(X2 - X1) > 0) then begin
836    PolyBezierArcPoints(x1, y1, x2 - x1, y2 - y1,0,360*16,0,Points,Count);
837    Polygon(DC, Points, Count, True);
838    ReallocMem(Points, 0);
839  end;
840  Result := True;
841end;
842
843function TWidgetSet.EqualRgn(Rgn1: HRGN; Rgn2: HRGN): Boolean;
844begin
845  Result := False;
846end;
847
848function TWidgetSet.ExcludeClipRect(dc: hdc;
849  Left, Top, Right, Bottom : Integer) : Integer;
850var
851  RRGN : HRGN;
852  R : TRect;
853begin
854  // Convert from logical to device coordinate
855  R := Types.Rect(Left, Top, Right, Bottom);
856  LPtoDP(DC, R, 2);
857
858  If DCClipRegionValid(DC) then begin
859    //DebugLn('TWidgetSet.ExcludeClipRect A DC=',DbgS(DC),' Rect=',Left,',',Top,',',Right,',',Bottom);
860    // create the rectangle region, that should be excluded
861    RRGN := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
862    Result := ExtSelectClipRGN(DC, RRGN, RGN_DIFF);
863    //DebugLn('TWidgetSet.ExcludeClipRect B Result=',Result);
864    DeleteObject(RRGN);
865  end else
866    Result := ERROR;
867end;
868function TWidgetSet.ExtCreatePen(dwPenStyle, dwWidth: DWord;
869  const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
870var
871  ALogPen: TLogPen;
872begin
873  // if there is no widgetset implementation use this best match
874  ALogPen.lopnColor := lplb.lbColor;
875  ALogPen.lopnStyle := dwPenStyle;
876  ALogPen.lopnWidth := Point(dwWidth, 0);
877  Result := CreatePenIndirect(ALogPen);
878end;
879
880function TWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
881begin
882  Result := False;
883end;
884
885function TWidgetSet.ExtSelectClipRGN(dc: hdc; rgn: hrgn; Mode: Longint): Integer;
886var
887  OldC, Clip: hRGN;
888begin
889  OldC := CreateEmptyRegion;
890  GetClipRGN(DC, OldC);
891  Clip := CreateEmptyRegion;
892  //DebugLn('TWidgetSet.ExtSelectClipRGN A OldC=',DbgS(OldC),
893  //  ' Clip=',DbgS(Clip),8),' RGn=',DbgS(Cardinal(RGN),' Mode=',dbgs(Mode));
894  Result := CombineRGN(Clip, OldC, RGN, Mode);
895  //DebugLn('TWidgetSet.ExtSelectClipRGN B Result=',Result);
896  if Result <> ERROR then
897    Result := SelectClipRGN(DC, Clip);
898  DeleteObject(Clip);
899  DeleteObject(OldC);
900end;
901
902function TWidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean;
903begin
904  Result := False;
905end;
906
907function TWidgetSet.FloodFill(DC: HDC; X, Y: Integer;
908  Color: TGraphicsColor;
909  FillStyle: TGraphicsFillStyle;
910  Brush: HBRUSH): Boolean;
911begin
912  Result := false;
913end;
914
915function TWidgetSet.FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): BOOL;
916begin
917  Result := false;
918end;
919
920function TWidgetSet.FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH) : integer;
921begin
922  Result:= 0;
923end;
924
925function TWidgetSet.GetActiveWindow : HWND;
926begin
927  Result := 0;
928end;
929
930function TWidgetSet.GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint;
931begin
932  Result := 0;
933end;
934
935function TWidgetSet.GetBkColor(DC: HDC): TColorRef;
936begin
937  Result := 0;
938end;
939
940function TWidgetSet.GetCapture : HWND;
941begin
942  Result := 0;
943end;
944
945function TWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
946begin
947  Result := False;
948end;
949
950function TWidgetSet.GetCharABCWidths(DC: HDC; p2, p3: UINT; const ABCStructs): Boolean;
951begin
952  Result := False;
953end;
954
955function TWidgetSet.GetClientRect(handle : HWND; var Rect : TRect) : Boolean;
956begin
957  Result := False;
958end;
959
960function TWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
961begin
962  lpRect^ := Rect(0,0,0,0);
963  Result := SIMPLEREGION;
964end;
965
966function TWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN) : Longint;
967begin
968  Result := -1;
969end;
970
971function TWidgetSet.GetCurrentObject(DC: HDC; uObjectType: UINT): HGDIOBJ;
972begin
973  Result := 0;
974end;
975
976function TWidgetSet.GetCursorPos(var lpPoint: TPoint): Boolean;
977begin
978  Result := False;
979end;
980
981function TWidgetSet.GetDC(hWnd: HWND): HDC;
982begin
983  Result := 0;
984end;
985
986function TWidgetSet.GetDeviceCaps(DC: HDC; Index: Integer): Integer;
987begin
988  Result := 0;
989end;
990
991function TWidgetSet.GetDIBits(DC: HDC; Bitmap: HBitmap;
992  StartScan, NumScans: UINT; Bits: Pointer;
993  var BitInfo: BitmapInfo; Usage: UINT): Integer;
994begin
995  Result := 0;
996end;
997
998function TWidgetSet.GetDoubleClickTime: UINT;
999begin
1000  // use windows default
1001  Result := 500;
1002end;
1003
1004function TWidgetSet.GetFocus: HWND;
1005begin
1006  Result := 0;
1007end;
1008
1009function TWidgetSet.GetFontLanguageInfo(DC: HDC): DWord;
1010begin
1011  Result := 0;
1012end;
1013
1014function TWidgetSet.GetForegroundWindow: HWND;
1015begin
1016  Result := 0;
1017end;
1018
1019function TWidgetSet.GetIconInfo(AIcon: HICON; AIconInfo: PIconInfo): Boolean;
1020begin
1021  Result := False;
1022end;
1023
1024function TWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;
1025begin
1026  Result := 0;
1027end;
1028
1029function TWidgetSet.GetMapMode(DC: HDC): Integer;
1030begin
1031  Result := 0;
1032end;
1033
1034function TWidgetset.GetMonitorInfo(hMonitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
1035begin
1036  Result := False;
1037end;
1038
1039function TWidgetset.GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;
1040begin
1041  Result := S_FALSE;
1042end;
1043
1044function TWidgetSet.GetObject(GDIObject: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer;
1045begin
1046  Result := 0;
1047end;
1048
1049function TWidgetSet.GetPaletteEntries(Palette: HPALETTE;
1050  StartIndex, NumEntries: UINT; var PaletteEntries): UINT;
1051begin
1052  Result := 0;
1053end;
1054
1055function TWidgetSet.GetParent(Handle : HWND): HWND;
1056begin
1057  Result := 0;
1058end;
1059
1060function TWidgetSet.GetProp(Handle : hwnd; Str : PChar): Pointer;
1061begin
1062  Result := nil;
1063end;
1064
1065function TWidgetSet.GetRgnBox(RGN: HRGN; lpRect: PRect): Longint;
1066begin
1067  Result := SIMPLEREGION;
1068end;
1069
1070function TWidgetSet.GetROP2(DC: HDC): integer;
1071begin
1072  Result := 0;
1073end;
1074
1075function TWidgetSet.GetScrollInfo(Handle: HWND; SBStyle: Integer;
1076  var ScrollInfo: TScrollInfo): Boolean;
1077begin
1078  Result := False;
1079end;
1080
1081function TWidgetSet.GetStockObject(Value: Integer): THandle;
1082begin
1083  Result := 0;
1084end;
1085
1086function TWidgetSet.GetSysColor(nIndex: Integer): DWORD;
1087begin
1088  Result := 0;
1089end;
1090
1091function TWidgetSet.GetSysColorBrush(nIndex: Integer): HBrush;
1092var
1093  LogBrush: TLogBrush;
1094begin
1095  LogBrush.lbColor := GetSysColor(nIndex);
1096  LogBrush.lbStyle := 0; // BS_CLEAR
1097  LogBrush.lbHatch := 0;
1098  Result := CreateBrushIndirect(LogBrush);
1099end;
1100
1101function TWidgetSet.GetSystemMetrics(nIndex: Integer): Integer;
1102begin
1103  Result := 0;
1104  case nIndex of
1105  SM_CXEDGE: Result:=2;
1106  SM_CYEDGE: Result:=2;
1107  end;
1108end;
1109
1110function TWidgetSet.GetSystemPaletteEntries(DC: HDC;
1111  StartIndex, NumEntries: UINT; var PaletteEntries): UINT;
1112begin
1113  Result := 0;
1114end;
1115
1116function TWidgetSet.GetTextColor(DC: HDC) : TColorRef;
1117begin
1118  Result := 0;
1119end;
1120
1121{ Returns in MaxCount how many characters fit into a given MaxWidth
1122  It also returns the width of each character
1123
1124  MaxCount is given in the number of UTF-8 characters, not bytes
1125}
1126function TWidgetSet.GetTextExtentExPoint(DC: HDC; Str: PChar;
1127  Count, MaxWidth: Integer; MaxCount, PartialWidths: PInteger;
1128  var Size: TSize): Boolean;
1129var
1130  Utf8Len, CurLen, Left, Right, I: PtrInt;
1131  CurSize: TSize;
1132begin
1133  // First obtain the size information which duplicates GetTextExtentPoint
1134  if not GetTextExtentPoint(DC, Str, Count, Size) then
1135    Exit(False);
1136
1137  if MaxCount <> nil then
1138    MaxCount^ := 0
1139  else if PartialWidths = nil then
1140    Exit(True);
1141
1142  if Count = 0 then
1143    Exit(True);
1144  if (Count < -1) or (Str = nil) then
1145    Exit(False);
1146
1147  if Count = -1 then
1148    Count := Length(Str);
1149  Utf8Len := UTF8Length(Str, Count);
1150  if Utf8Len = 0 then
1151    Exit(True);
1152
1153  if PartialWidths = nil then
1154  begin
1155    if Size.cx <= MaxWidth then
1156      MaxCount^ := Utf8Len
1157    else
1158    begin
1159      Left := 0;
1160      Right := Utf8Len;
1161      while Left <= Right do
1162      begin
1163        I := (Left + Right) div 2;
1164        CurLen := UTF8CodepointToByteIndex(Str, Count, I);
1165        if not GetTextExtentPoint(DC, Str, CurLen, CurSize) then
1166          Exit(False);
1167        if CurSize.cx <= MaxWidth then
1168        begin
1169          MaxCount^ := I;
1170          Left := I + 1;
1171        end else
1172          Right := I - 1;
1173      end;
1174    end;
1175  end else
1176  begin
1177    CurLen := 0;
1178    for I := 1 to Utf8Len do
1179    begin
1180      Inc(CurLen, UTF8CodepointSize(@Str[CurLen]));
1181      if not GetTextExtentPoint(DC, Str, CurLen, CurSize) then
1182        Exit(False);
1183      if MaxCount <> nil then
1184      begin
1185        if CurSize.cx > MaxWidth then
1186          Break;
1187        MaxCount^ := I;
1188      end;
1189      PartialWidths[I - 1] := CurSize.cx;
1190    end;
1191  end;
1192
1193  Exit(True);
1194end;
1195
1196// Note that Count is the number of bytes in the utf-8 encoded string Str
1197function TWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer;
1198  var Size: TSize): Boolean;
1199begin
1200  Result := False;
1201end;
1202
1203function TWidgetSet.GetTextExtentPoint32(DC: HDC; Str: PChar;
1204  Count: Integer; var Size: TSize): Boolean;
1205begin
1206  Result := GetTextExtentPoint(DC,Str,Count,Size);
1207end;
1208
1209function TWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
1210begin
1211  Result := False;
1212end;
1213
1214function TWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer;
1215begin
1216  Result := 0;
1217end;
1218
1219function TWidgetSet.GetViewPortOrgEx(DC: HDC; P: PPoint): Integer;
1220begin
1221  Result := 0;
1222end;
1223
1224function TWidgetSet.GetWindowExtEx(DC: HDC; Size: PSize): Integer;
1225begin
1226  Result := 0;
1227end;
1228
1229function TWidgetSet.GetWindowLong(Handle : hwnd; int : Integer): PtrInt;
1230begin
1231  Result := 0;
1232end;
1233
1234function TWidgetSet.GetWindowOrgEx(dc: hdc; var P: TPoint): Integer;
1235begin
1236  Result := GetWindowOrgEx(dc, @P);
1237end;
1238
1239function TWidgetSet.GetWindowOrgEx(dc: hdc; P: PPoint): Integer;
1240begin
1241  Result := 0;
1242  if P <> nil then
1243    P^ := Point(0, 0);
1244end;
1245
1246function TWidgetSet.GetWindowRect(Handle : hwnd; var Rect : TRect): Integer;
1247{ After the call, ARect will be the control area in screen coordinates.
1248  That means, Left and Top will be the screen coordinate of the TopLeft pixel
1249  of the Handle object and Right and Bottom will be the screen coordinate of
1250  the BottomRight pixel. }
1251begin
1252  Result := 0;
1253end;
1254
1255{------------------------------------------------------------------------------
1256  Function: GradientFill
1257  Params: DC - DeviceContext to perform on
1258          Vertices - array of Points W/Color & Alpha
1259          NumVertices - Number of Vertices
1260          Meshes - array of Triangle or Rectangle Meshes,
1261                   each mesh representing one Gradient Fill
1262          NumMeshes - Number of Meshes
1263          Mode - Gradient Type, either Triangle,
1264                 Vertical Rect, Horizontal Rect
1265
1266  Returns: true on success
1267
1268  Performs multiple Gradient Fills, either a Three way Triangle Gradient,
1269  or a two way Rectangle Gradient, each Vertex point also supports optional
1270  Alpha/Transparency for more advanced Gradients.
1271 ------------------------------------------------------------------------------}
1272function TWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex; NumVertices: Longint;
1273  Meshes: Pointer; NumMeshes: Longint; Mode: Longint): Boolean;
1274
1275  function DoFillTriangle: Boolean; inline;
1276  begin
1277    Result := (Mode and GRADIENT_FILL_TRIANGLE) = GRADIENT_FILL_TRIANGLE;
1278  end;
1279
1280  function DoFillVRect: Boolean; inline;
1281  begin
1282    Result := (Mode and GRADIENT_FILL_RECT_V) = GRADIENT_FILL_RECT_V;
1283  end;
1284
1285  function CreateIntfImage(W, H: Integer; Clear: Boolean): TLazIntfImage;
1286  begin
1287    Result := TLazIntfImage.Create(W, H, [riqfRGB, riqfAlpha, riqfUpdate]);
1288    if Clear then
1289      Result.FillPixels(FPColor(0, 0, 0, $0000));
1290  end;
1291
1292  procedure DrawIntfImage(Image: TLazIntfImage; R: TRect);
1293  var
1294    Bmp, Mask, Old: HBitmap;
1295    BmpDC: HDC;
1296  begin
1297    Image.CreateBitmaps(Bmp, Mask, True);
1298    BmpDC := CreateCompatibleDC(0);
1299    Old := SelectObject(BmpDC, Bmp);
1300    MaskBlt(DC, R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, BmpDC, 0, 0, Mask, 0, 0);
1301    DeleteObject(SelectObject(BmpDC, Old));
1302    if Mask <> 0 then
1303      DeleteObject(Mask);
1304    DeleteDC(BmpDC);
1305  end;
1306
1307  function GetRectangleGradientColor(const BeginColor, EndColor: TFPColor; const Position, TotalSteps: Longint): TFPColor; inline;
1308  var
1309    A1: Word absolute BeginColor.alpha;
1310    R1: Word absolute BeginColor.red;
1311    G1: Word absolute BeginColor.green;
1312    B1: Word absolute BeginColor.blue;
1313    A2: Word absolute Endcolor.alpha;
1314    R2: Word absolute Endcolor.red;
1315    G2: Word absolute Endcolor.green;
1316    B2: Word absolute Endcolor.blue;
1317  begin
1318    Result.alpha := (A1 + (Position * (A2 - A1) div TotalSteps));
1319    Result.red := (R1 + (Position * (R2 - R1) div TotalSteps));
1320    Result.green := (G1 + (Position * (G2 - G1) div TotalSteps));
1321    Result.blue := (B1 + (Position * (B2 - B1) div TotalSteps));
1322  end;
1323
1324  function GetTriangleBounds(const v1, v2, v3: TTriVertex): TRect;
1325  begin
1326    with v1 do
1327    begin
1328      Result.Left := x;
1329      Result.Top := y;
1330      Result.BottomRight := Result.TopLeft;
1331    end;
1332    with v2 do
1333    begin
1334      if x < Result.Left then
1335        Result.Left := x;
1336      if x > Result.Right then
1337        Result.Right := x;
1338      if y < Result.Top then
1339        Result.Top := y;
1340      if y > Result.Bottom then
1341        Result.Bottom := y;
1342    end;
1343    with v3 do
1344    begin
1345      if x < Result.Left then
1346        Result.Left := x;
1347      if x > Result.Right then
1348        Result.Right := x;
1349      if y < Result.Top then
1350        Result.Top := y;
1351      if y > Result.Bottom then
1352        Result.Bottom := y;
1353    end;
1354  end;
1355
1356  {
1357    implementation of Arjen Nienhuis:
1358    http://www.winehq.org/pipermail/wine-patches/2003-June/006544.html
1359    Arjen has granted us the rights to include this code with our modified LGPL2 license
1360  }
1361
1362  procedure GradientFillTriangle(Image: TLazIntfImage; v1, v2, v3: TTriVertex);
1363  var
1364    t, v: TTriVertex;
1365    y, y2, dy, dy2: Integer;
1366    x, x1, x2, r1, r2, g1, g2, b1, b2: Integer;
1367    dx: Integer;
1368  begin
1369    if (v1.y > v2.y) then
1370    begin
1371      t := v1;
1372      v1 := v2;
1373      v2 := t;
1374    end;
1375
1376    if (v2.y > v3.y) then
1377    begin
1378      t := v2;
1379      v2 := v3;
1380      v3 := t;
1381      if (v1.y > v2.y) then
1382      begin
1383        t := v1;
1384        v1 := v2;
1385        v2 := t;
1386      end;
1387    end;
1388    // v1.y <= v2.y <= v3.y
1389    dy := v3.y - v1.y;
1390    for y := 0 to dy - 1 do
1391    begin
1392      // v1.y <= y < v3.y
1393      if y < (v2.y - v1.y) then
1394        v :=  v1
1395      else
1396        v := v3;
1397      // (v.y <= y < v2.y) || (v2.y <= y < v.y)
1398      dy2 := v2.y - v.y;
1399      y2 := y + v1.y - v.y;
1400      x1 := (v3.x     * y  + v1.x     * (dy  - y )) div dy;
1401      x2 := (v2.x     * y2 + v. x     * (dy2 - y2)) div dy2;
1402      r1 := (v3.Red   * y  + v1.Red   * (dy  - y )) div dy;
1403      r2 := (v2.Red   * y2 + v. Red   * (dy2 - y2)) div dy2;
1404      g1 := (v3.Green * y  + v1.Green * (dy  - y )) div dy;
1405      g2 := (v2.Green * y2 + v. Green * (dy2 - y2)) div dy2;
1406      b1 := (v3.Blue  * y  + v1.Blue  * (dy  - y )) div dy;
1407      b2 := (v2.Blue  * y2 + v. Blue  * (dy2 - y2)) div dy2;
1408      if (x1 < x2) then
1409      begin
1410        dx := x2 - x1;
1411        for x := 0 to dx - 1 do
1412          Image.Colors[x + x1, y + v1.y] := FPColor(
1413            (r1 * (dx - x) + r2 * x) div dx,
1414            (g1 * (dx - x) + g2 * x) div dx,
1415            (b1 * (dx - x) + b2 * x) div dx);
1416      end
1417      else
1418      begin
1419        dx := x1 - x2;
1420        for x := 0 to dx - 1 do
1421          Image.Colors[x + x2, y + v1.y] := FPColor(
1422            (r2 * (dx - x) + r1 * x) div dx,
1423            (g2 * (dx - x) + g1 * x) div dx,
1424            (b2 * (dx - x) + b1 * x) div dx);
1425      end;
1426    end;
1427  end;
1428
1429
1430  function FillTriMesh(Mesh: TGradientTriangle): Boolean;
1431  var
1432    v1, v2, v3: TTriVertex;
1433    R: TRect;
1434    Image: TLazIntfImage;
1435  begin
1436    with Mesh do
1437    begin
1438      Result :=
1439        (Vertex1 < Cardinal(NumVertices)) and
1440        (Vertex2 < Cardinal(NumVertices)) and
1441        (Vertex3 < Cardinal(NumVertices));
1442
1443      if (Vertex1 = Vertex2) or (Vertex1 = Vertex3) or (Vertex2 = Vertex3) or not Result then
1444        Exit;
1445    end;
1446
1447    v1 := Vertices[Mesh.Vertex1];
1448    v2 := Vertices[Mesh.Vertex2];
1449    v3 := Vertices[Mesh.Vertex3];
1450    R := GetTriangleBounds(v1, v2, v3);
1451    with R do
1452    begin
1453      dec(v1.x, Left);
1454      dec(v2.x, Left);
1455      dec(v3.x, Left);
1456
1457      dec(v1.y, Top);
1458      dec(v2.y, Top);
1459      dec(v3.y, Top);
1460    end;
1461
1462    Image := CreateIntfImage(R.Right - R.Left, R.Bottom - R.Top, True);
1463    GradientFillTriangle(Image, v1, v2, v3);
1464    DrawIntfImage(Image, R);
1465    Image.Free;
1466    Result := True;
1467  end;
1468
1469  function FillRectMesh(Mesh: TGradientRect): Boolean;
1470  var
1471    TL, BR: TTriVertex;
1472    StartColor, EndColor, CurColor: TFPColor;
1473    I, J: Longint;
1474    SwapColors: Boolean;
1475    Steps: Integer;
1476    Image: TLazIntfImage;
1477    R: TRect;
1478  begin
1479    with Mesh do
1480    begin
1481      Result := (UpperLeft < Cardinal(NumVertices)) and (LowerRight < Cardinal(NumVertices));
1482      if (LowerRight = UpperLeft) or not Result then
1483        Exit;
1484      TL := Vertices[UpperLeft];
1485      BR := Vertices[LowerRight];
1486      SwapColors := (BR.Y < TL.Y) and (BR.X < TL.X);
1487      if BR.X < TL.X then
1488      begin
1489        I := BR.X;
1490        BR.X := TL.X;
1491        TL.X := I;
1492      end;
1493      if BR.Y < TL.Y then
1494      begin
1495        I := BR.Y;
1496        BR.Y := TL.Y;
1497        TL.Y := I;
1498      end;
1499      StartColor := FPColor(TL.Red, TL.Green, TL.Blue);
1500      EndColor := FPColor(BR.Red, BR.Green, BR.Blue);
1501      if SwapColors then
1502      begin
1503        CurColor := StartColor;
1504        StartColor := EndColor;
1505        EndColor := CurColor;
1506      end;
1507
1508      R := Rect(TL.X, TL.Y, BR.X, BR.Y);
1509      dec(BR.X, TL.X);
1510      dec(BR.Y, TL.Y);
1511      TL.X := 0;
1512      TL.Y := 0;
1513      Image := CreateIntfImage(BR.X, BR.Y, False);
1514
1515      if DoFillVRect then
1516      begin
1517        Steps := BR.Y;
1518        for I := 0 to Steps - 1 do
1519        begin
1520          CurColor := GetRectangleGradientColor(StartColor, EndColor, I, Steps);
1521          for J := TL.X to BR.X - 1 do
1522            Image.Colors[J, I] := CurColor;
1523        end
1524      end
1525      else
1526      begin
1527        Steps := BR.X;
1528        for I := 0 to Steps - 1 do
1529        begin
1530          CurColor := GetRectangleGradientColor(StartColor, EndColor, I, Steps);
1531          for J := TL.Y to BR.Y - 1 do
1532            Image.Colors[I, J] := CurColor;
1533        end;
1534      end;
1535      DrawIntfImage(Image, R);
1536      Image.Free;
1537    end;
1538  end;
1539
1540const
1541  MeshSize: array[Boolean] of PtrUInt = (
1542    SizeOf(tagGradientRect),
1543    SizeOf(tagGradientTriangle)
1544  );
1545var
1546  I : Integer;
1547begin
1548  Result := Assigned(Meshes) and (NumMeshes >= 1) and (NumVertices >= 2) and Assigned(Vertices);
1549  if Result and DoFillTriangle then
1550    Result := NumVertices >= 3;
1551  if Result then
1552  begin
1553    Result := False;
1554
1555    //Sanity Checks For Vertices Size vs. Count
1556    if MemSize(Vertices) < PtrUInt(SizeOf(TTriVertex) * NumVertices) then
1557      Exit;
1558
1559    //Sanity Checks For Meshes Size vs. Count
1560    if MemSize(Meshes) < (MeshSize[DoFillTriangle] * Cardinal(NumMeshes)) then
1561      Exit;
1562
1563    for I := 0 to NumMeshes - 1 do
1564    begin
1565      if DoFillTriangle then
1566      begin
1567        if not FillTriMesh(PGradientTriangle(Meshes)[I]) then
1568          exit;
1569      end
1570      else
1571      begin
1572        if not FillRectMesh(PGradientRect(Meshes)[I]) then
1573          exit;
1574      end;
1575    end;
1576    Result := True;
1577  end;
1578end;
1579
1580function TWidgetSet.HideCaret(hWnd: HWND): Boolean;
1581begin
1582  Result := False;
1583end;
1584
1585function TWidgetSet.InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean;
1586begin
1587  Result := False;
1588end;
1589
1590function TWidgetSet.IsHelpKey(Key: Word; Shift: TShiftState): Boolean;
1591{ Asks if the passed key is determined by widgetset to show help }
1592begin
1593  Result := (Shift = []) and (Key = VK_F1);
1594end;
1595
1596procedure TWidgetSet.InitializeCriticalSection(var CritSection: TCriticalSection);
1597begin
1598  DebugLn('TWidgetSet.InitializeCriticalSection Not implemented yet');
1599end;
1600
1601function TWidgetSet.IntersectClipRect(DC: HDC; Left, Top, Right, Bottom: Integer): Integer;
1602var
1603  R: TRect;
1604  RRGN: hRGN;
1605begin
1606  R := Rect(Left, Top, Right, Bottom);
1607  LPtoDP(DC, R, 2);
1608  with R do
1609    RRGN := CreateRectRgn(Left, Top, Right, Bottom);
1610  if not DCClipRegionValid(DC) then
1611    Result := SelectClipRGN(DC, RRGN)
1612  else
1613    Result := ExtSelectClipRGN(DC, RRGN, RGN_AND);
1614  DeleteObject(RRGN);
1615end;
1616
1617function TWidgetSet.InvalidateRect(aHandle : HWND; ARect : pRect; bErase : Boolean) : Boolean;
1618begin
1619  Result := false;
1620end;
1621
1622function TWidgetSet.InvalidateRgn(Handle: HWND; Rgn: HRGN; Erase: Boolean): Boolean;
1623begin
1624  Result := False;
1625end;
1626
1627function TWidgetSet.IsDBCSLeadByte(TestChar: Byte): boolean;
1628begin
1629  Result := false;
1630end;
1631
1632function TWidgetSet.IsIconic(handle: HWND): boolean;
1633begin
1634  Result := False;
1635end;
1636
1637function TWidgetSet.IsWindow(handle: HWND): boolean;
1638begin
1639  Result := False;
1640end;
1641
1642function TWidgetSet.IsWindowEnabled(handle: HWND): boolean;
1643begin
1644  Result := false;
1645end;
1646
1647function TWidgetSet.IsWindowVisible(handle: HWND): boolean;
1648begin
1649  Result := false;
1650end;
1651
1652function TWidgetSet.IsZoomed(handle: HWND): boolean;
1653begin
1654  Result := False;
1655end;
1656
1657procedure TWidgetSet.LeaveCriticalSection(var CritSection: TCriticalSection);
1658begin
1659  DebugLn('TWidgetSet.LeaveCriticalSection Not implemented yet');
1660end;
1661
1662function TWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
1663begin
1664  Result := False;
1665end;
1666
1667function TWidgetSet.LoadBitmap(hInstance: THandle; lpBitmapName: PChar): HBitmap;
1668begin
1669  Result := LoadBitmapFunction(hInstance, lpBitmapName);
1670end;
1671
1672function TWidgetSet.LoadCursor(hInstance: THandle; lpCursorName: PChar): HCursor;
1673begin
1674  Result := LoadCursorFunction(hInstance, lpCursorName);
1675end;
1676
1677function TWidgetSet.LoadIcon(hInstance: THandle; lpIconName: PChar): HIcon;
1678begin
1679  Result := LoadIconFunction(hInstance, lpIconName);
1680end;
1681
1682function TWidgetSet.LPtoDP(DC: HDC; var Points; Count: Integer): BOOL;
1683begin
1684  Result := False;
1685end;
1686
1687function TWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar;
1688  uType : Cardinal): integer;
1689begin
1690  Result := 0;
1691end;
1692
1693function TWidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;
1694begin
1695  Result := MONITOR_UNIMPL;
1696end;
1697
1698function TWidgetSet.MonitorFromRect(lprcScreenCoords: PRect; dwFlags: DWord): HMONITOR;
1699begin
1700  Result := MONITOR_UNIMPL;
1701end;
1702
1703function TWidgetSet.MonitorFromWindow(hWnd: HWND; dwFlags: DWord): HMONITOR;
1704begin
1705  Result := MONITOR_UNIMPL;
1706end;
1707
1708function TWidgetSet.MaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
1709  SrcDC: HDC; XSrc, YSrc: Integer; Mask: HBITMAP; XMask, YMask: Integer;
1710  Rop: DWORD): Boolean;
1711begin
1712  Result := StretchMaskBlt(DestDC,X,Y,Width,Height,SrcDC,XSrc,YSrc,Width,Height,
1713                           Mask,XMask,YMask,ROp);
1714end;
1715
1716function TWidgetSet.MaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
1717  SrcDC: HDC; XSrc, YSrc: Integer; Mask: HBITMAP; XMask, YMask: Integer): Boolean;
1718begin
1719  Result := MaskBlt(DestDC,X,Y,Width,Height,SrcDC,XSrc,YSrc,
1720                    Mask,XMask,YMask,SRCCOPY);
1721end;
1722
1723function TWidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean;
1724begin
1725  Result := False;
1726end;
1727
1728function TWidgetSet.OffsetRgn(RGN: HRGN; nXOffset, nYOffset: Integer): Integer;
1729begin
1730  Result := Error;
1731end;
1732
1733function TWidgetSet.PaintRgn(DC: HDC; RGN: HRGN): Boolean;
1734begin
1735  Result := False;
1736end;
1737
1738function TWidgetSet.PeekMessage(var lpMsg : TMsg; Handle : HWND;
1739  wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean;
1740begin
1741  Result := False;
1742end;
1743
1744function TWidgetSet.Pie(DC: HDC; x1, y1, x2, y2,
1745                        sx, sy, ex, ey: Integer): Boolean;
1746var
1747  A1, A2: extended;
1748  A2i: integer;
1749begin
1750  Coords2Angles(x1, y1, x2-x1, y2-y1, sx, sy, ex, ey, A1, A2);
1751  A2i := RoundToInt(A2);
1752  if A2i = 0 then
1753    A2i := 5760;
1754  Result := RadialPie(DC, x1, y1, x2, y2, RoundToInt(A1), A2i);
1755end;
1756
1757function TWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
1758  Filled,Continuous: boolean): boolean;
1759var
1760  APoints : PPoint;
1761  ACount : Longint;
1762begin
1763  APoints := nil;
1764  ACount := 0;
1765  PolyBezier2Polyline(Points,NumPts,APoints,ACount,Continuous);
1766  If Filled then
1767    Result := Polygon(DC,APoints,ACount, False)
1768  else
1769    Result := Polyline(DC,APoints,ACount);
1770  ReallocMem(APoints,0);
1771End;
1772
1773function TWidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer;
1774  Winding: boolean): boolean;
1775begin
1776  Result := false;
1777end;
1778
1779function TWidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean;
1780begin
1781  Result := false;
1782end;
1783
1784function TWidgetSet.PostMessage(Handle: HWND; Msg: Cardinal;
1785  WParam: WParam; LParam: LParam): Boolean;
1786begin
1787  Result := False;
1788end;
1789
1790function TWidgetSet.PtInRegion(RGN: HRGN; X, Y: Integer): Boolean;
1791begin
1792  Result := false;
1793end;
1794
1795function TWidgetSet.RealizePalette(DC: HDC): Cardinal;
1796begin
1797  Result := 0;
1798end;
1799
1800function TWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
1801begin
1802  Result := False;
1803end;
1804
1805{------------------------------------------------------------------------------
1806  Determines if the specified rectangle is within the boundaries of a region.
1807  Default implementation, widgetsets will implement their own versions
1808 ------------------------------------------------------------------------------}
1809function TWidgetSet.RectInRegion(RGN: HRGN; ARect: TRect): Boolean;
1810var
1811  RectRgn, EmptyRgn: HRGN;
1812begin
1813  with ARect do
1814    RectRgn := CreateRectRgn(Left,Top,Right,Bottom);
1815  try
1816    EmptyRgn := CreateEmptyRegion;
1817    try
1818      Result := CombineRgn(EmptyRgn, RectRgn, RGN, RGN_AND) <> NULLREGION;
1819      if Result then
1820        Result := CombineRgn(EmptyRgn, EmptyRgn, RectRgn, RGN_XOR) = NULLREGION;
1821    finally
1822      DeleteObject(EmptyRgn);
1823    end;
1824  finally
1825    DeleteObject(RectRgn);
1826  end;
1827end;
1828
1829{------------------------------------------------------------------------------
1830  Function: RectVisible
1831  Params:  dc : hdc; ARect: TRect
1832  Returns: True if ARect is not completely clipped away.
1833 ------------------------------------------------------------------------------}
1834function TWidgetSet.RectVisible(DC: HDC; const ARect: TRect): Boolean;
1835var
1836  ClipRGN, RectRgn: hRGN;
1837  Intersection: hRGN;
1838  CombineResult: Integer;
1839begin
1840  Result := False;
1841  if (ARect.Left >= ARect.Right) or
1842     (ARect.Top >= ARect.Bottom) or
1843     not DCClipRegionValid(DC) then Exit;
1844
1845  ClipRGN := CreateEmptyRegion;
1846  if GetClipRGN(DC, ClipRGN) > 0 then
1847  begin
1848    RectRgn := CreateRectRGN(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
1849    Intersection := CreateEmptyRegion;
1850    //debugln(['TWidgetSet.RectVisible ARect=',dbgs(ARect)]);
1851    CombineResult := CombineRGN(Intersection, RectRGN, ClipRGN, RGN_AND);
1852    if CombineResult in [SimpleRegion, ComplexRegion] then
1853      Result := True;
1854    DeleteObject(Intersection);
1855    DeleteObject(RectRgn);
1856  end;
1857  DeleteObject(ClipRGN);
1858end;
1859
1860function TWidgetSet.RedrawWindow(Wnd: HWND; lprcUpdate: PRECT; hrgnUpdate: HRGN; flags: UINT): Boolean;
1861begin
1862  // check if validate flag is set, we have no default for it.
1863  if RDW_VALIDATE and flags <> 0 then Exit(False);
1864
1865  if hrgnUpdate = 0
1866  then Result := InvalidateRect(Wnd, lprcUpdate, RDW_ERASE and flags <> 0)
1867  else Result := InvalidateRgn(Wnd, hrgnUpdate, RDW_ERASE and flags <> 0)
1868end;
1869
1870function TWidgetSet.ReleaseCapture : Boolean;
1871begin
1872  Result := True;
1873end;
1874
1875function TWidgetSet.ReleaseDC(hWnd: HWND; DC: HDC): Integer;
1876begin
1877  Result := 0;
1878end;
1879
1880function TWidgetSet.RemoveProp(Handle: hwnd; Str: PChar): THandle;
1881begin
1882  Result := 0;
1883end;
1884
1885function TWidgetSet.RestoreDC(DC: HDC; SavedDC: Integer): Boolean;
1886begin
1887  Result := False;
1888end;
1889
1890function TWidgetSet.RoundRect(DC : hDC; X1, Y1, X2, Y2: Integer; RX,RY : Integer) : Boolean;
1891var
1892  T: Integer;
1893  Points: PPoint;
1894  Count: Integer;
1895
1896  procedure AddArcPoints(Left, Top, Right, Bottom, Angle1, Angle2: Integer);
1897  var
1898    P: PPoint;
1899    C: Integer;
1900    I: Integer;
1901  begin
1902    P := nil;
1903    try
1904      PolyBezierArcPoints(Left, Top, Right - Left, Bottom - Top, Angle1, Angle2,
1905        0, P, C);
1906
1907      ReallocMem(Points, (Count + C) * SizeOf(TPoint));
1908      for I := 0 to Pred(C) do
1909        Points[Count + Pred(C) - I] := P[I];
1910
1911      Inc(Count, C);
1912    finally
1913      FreeMem(P);
1914    end;
1915  end;
1916
1917begin
1918  Result := True;
1919
1920  if X2 < X1 then
1921  begin
1922    T := X1;
1923    X1 := X2;
1924    X2 := T;
1925  end;
1926
1927  if Y2 < Y1 then
1928  begin
1929    T := Y1;
1930    Y1 := Y2;
1931    Y2 := T;
1932  end;
1933
1934  if (X2 - X1 <= 0) or (Y2 - Y1 <= 0) then Exit;
1935
1936  Dec(X2);
1937  Dec(Y2);
1938
1939  if not ((RX <= 0) or (RY <= 0)) then
1940  begin
1941    if X2 - X1 < RX then RX := X2 - X1;
1942    if Y2 - Y1 < RY then RY := Y2 - Y1;
1943
1944    //debugln('TWidgetSet.RoundRect ',dbgs(Rect(X1,Y1,X2,Y2)),' ',dbgs(Point(RX,RY)));
1945    Points := nil;
1946    Count := 0;
1947    try
1948      AddArcPoints(X1, Y1, X1 + RX, Y1 + RY,  90 * 16, 90 * 16);
1949      AddArcPoints(X2 - RX, Y1, X2, Y1 + RY,   0 * 16, 90 * 16);
1950      AddArcPoints(X2 - RX, Y2 - RY, X2, Y2, 270 * 16, 90 * 16);
1951      AddArcPoints(X1, Y2 - RY, X1 + RX, Y2, 180 * 16, 90 * 16);
1952
1953      Polygon(DC, Points, Count, False);
1954    finally
1955      FreeMem(Points);
1956    end;
1957  end
1958  else
1959    Rectangle(DC, X1, Y1, X2, Y2);
1960end;
1961
1962function TWidgetSet.SaveDC(DC: HDC) : Integer;
1963begin
1964  Result := 0;
1965end;
1966
1967function TWidgetSet.ScreenToClient(Handle : HWND; var P : TPoint) : Integer;
1968begin
1969  Result := 0;
1970end;
1971
1972function TWidgetSet.ScrollWindowEx(hWnd: HWND; dx, dy: Integer; prcScroll, prcClip: PRect; hrgnUpdate: HRGN; prcUpdate: PRect; flags: UINT): Boolean;
1973begin
1974  Result := False;
1975end;
1976
1977function TWidgetSet.SelectClipRGN(DC : hDC; RGN : HRGN) : Longint;
1978begin
1979  Result := ERROR;
1980end;
1981
1982function TWidgetSet.SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
1983begin
1984  Result := 0;
1985end;
1986
1987function TWidgetSet.SelectPalette(DC: HDC; Palette: HPALETTE; ForceBackground: Boolean): HPALETTE;
1988begin
1989  Result := 0;
1990end;
1991
1992function TWidgetSet.SendMessage(HandleWnd: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LResult;
1993begin
1994  Result := 0;
1995end;
1996
1997function TWidgetSet.SetActiveWindow(Handle: HWND): HWND;
1998begin
1999  Result:=GetActiveWindow;
2000end;
2001
2002function TWidgetSet.SetBkColor(DC: HDC; Color: TColorRef): TColorRef; //pbd
2003begin
2004  Result := 0;
2005end;
2006
2007function TWidgetSet.SetBkMode(DC: HDC; bkMode : Integer): Integer;
2008begin
2009  Result := 0;
2010end;
2011
2012function TWidgetSet.SetCapture(AHandle: HWND): HWND;
2013begin
2014  Result := 0;
2015End;
2016
2017function TWidgetSet.SetCaretPos(X, Y: Integer): Boolean;
2018begin
2019  Result := False;
2020end;
2021
2022function TWidgetSet.SetCaretPosEx(handle: HWnd; X, Y: Integer): Boolean;
2023begin
2024  Result := False;
2025end;
2026
2027function TWidgetSet.SetCursor(hCursor: HICON): HCURSOR;
2028begin
2029  Result := 0;
2030end;
2031
2032function TWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
2033begin
2034  // Your default here
2035  Result := False;
2036end;
2037
2038function TWidgetSet.SetFocus(hWnd: HWND): HWND;
2039begin
2040  Result := 0;
2041end;
2042
2043function TWidgetSet.SetForegroundWindow(hWnd : HWND): Boolean;
2044begin
2045  Result := false;
2046end;
2047
2048function TWidgetSet.SetMapMode(DC: HDC; fnMapMode : Integer): Integer;
2049begin
2050  Result := 0;
2051end;
2052
2053function TWidgetSet.SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean;
2054begin
2055  Result := False;
2056end;
2057
2058function TWidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
2059begin
2060  Result := 0;
2061end;
2062
2063function TWidgetSet.SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean;
2064begin
2065  Result := True;
2066end;
2067
2068function TWidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean;
2069begin
2070  Result := False;
2071end;
2072
2073function TWidgetSet.SetROP2(DC: HDC; Mode: Integer): Integer;
2074begin
2075  Result := 0;
2076end;
2077
2078function TWidgetSet.SetScrollInfo(Handle : HWND; SBStyle : Integer;
2079  ScrollInfo: TScrollInfo; Redraw : Boolean): Integer;
2080begin
2081  Result := 0;
2082end;
2083
2084function TWidgetSet.SetStretchBltMode(DC: HDC; StretchMode: Integer): Integer;
2085begin
2086  Result := 0;
2087end;
2088
2089function TWidgetSet.SetSysColors(cElements: Integer; const lpaElements;
2090  const lpaRgbValues): Boolean;
2091begin
2092  Result := False;
2093end;
2094
2095function TWidgetSet.SetTextCharacterExtra(_hdc : hdc; nCharExtra : Integer):Integer;
2096begin
2097  Result := 0;
2098end;
2099
2100function TWidgetSet.SetTextColor(DC: HDC; Color: TColorRef): TColorRef;
2101begin
2102  Result := CLR_INVALID;
2103end;
2104
2105function TWidgetSet.SetViewPortExtEx(DC: HDC; XExtent, YExtent : Integer; OldSize: PSize): Boolean;
2106begin
2107  Result := False;
2108end;
2109
2110function TWidgetSet.SetViewPortOrgEx(DC: HDC; NewX, NewY: Integer; OldPoint: PPoint): Boolean;
2111begin
2112  Result := False;
2113end;
2114
2115function TWidgetSet.SetWindowExtEx(DC: HDC; XExtent, YExtent: Integer; OldSize: PSize): Boolean;
2116begin
2117  Result := False;
2118end;
2119
2120function TWidgetSet.SetWindowLong(Handle: HWND;
2121  Idx: Integer; NewLong : PtrInt): PtrInt;
2122begin
2123  Result := -1;
2124end;
2125
2126function TWidgetSet.SetWindowOrgEx(dc : hdc; NewX, NewY : Integer;
2127  OldPoint: PPoint) : Boolean;
2128begin
2129  Result := False;
2130end;
2131
2132function TWidgetSet.SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
2133       X, Y, cx, cy: Integer; uFlags: UINT): Boolean;
2134begin
2135  Result:=false;
2136end;
2137
2138function TWidgetset.SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean): longint;
2139begin
2140  Result := 0;
2141end;
2142
2143function TWidgetSet.ShowCaret(hWnd: HWND): Boolean;
2144begin
2145  Result := False;
2146end;
2147
2148function TWidgetSet.ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean;
2149begin
2150  Result := False;
2151end;
2152
2153function TWidgetSet.ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean;
2154begin
2155  Result:=false;
2156end;
2157
2158function TWidgetSet.StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer;
2159  SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Rop: Cardinal): Boolean;
2160begin
2161  Result := False;
2162end;
2163
2164function TWidgetSet.StretchDIBits(DC: HDC;
2165  DestX, DestY, DestWidth, DestHeight, SrcX, SrcY, SrcWidth, SrcHeight: Integer;
2166  Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT; Rop: DWORD): Integer;
2167begin
2168  Result := 0;
2169end;
2170
2171function TWidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool;
2172begin
2173  case uiAction of
2174    SPI_GETWHEELSCROLLLINES: begin
2175      PDword(pvPAram)^ := 3; // default value
2176      Result := True;
2177    end;
2178  else
2179    Result := False;
2180  end
2181end;
2182
2183function TWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean;
2184begin
2185  Result := false;
2186end;
2187
2188function TWidgetSet.UpdateWindow(Handle: HWND): Boolean;
2189begin
2190  Result := false;
2191end;
2192
2193function TWidgetSet.WindowFromPoint(Point : TPoint) : HWND;
2194begin
2195  Result := 0;
2196end;
2197
2198//##apiwiz##eps##   // Do not remove
2199