1{%MainUnit ../interfacebase.pp}
2
3{ $Id: intfbasewinapi.inc 58863 2018-09-04 21:58:29Z juha $ }
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;
852begin
853  If DCClipRegionValid(DC) then begin
854    //DebugLn('TWidgetSet.ExcludeClipRect A DC=',DbgS(DC),' Rect=',Left,',',Top,',',Right,',',Bottom);
855    // create the rectangle region, that should be excluded
856    RRGN := CreateRectRgn(Left,Top,Right,Bottom);
857    Result := ExtSelectClipRGN(DC, RRGN, RGN_DIFF);
858    //DebugLn('TWidgetSet.ExcludeClipRect B Result=',Result);
859    DeleteObject(RRGN);
860  end else
861    Result:=ERROR;
862end;
863
864function TWidgetSet.ExtCreatePen(dwPenStyle, dwWidth: DWord;
865  const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN;
866var
867  ALogPen: TLogPen;
868begin
869  // if there is no widgetset implementation use this best match
870  ALogPen.lopnColor := lplb.lbColor;
871  ALogPen.lopnStyle := dwPenStyle;
872  ALogPen.lopnWidth := Point(dwWidth, 0);
873  Result := CreatePenIndirect(ALogPen);
874end;
875
876function TWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
877begin
878  Result := False;
879end;
880
881function TWidgetSet.ExtSelectClipRGN(dc: hdc; rgn: hrgn; Mode: Longint): Integer;
882var
883  OldC, Clip: hRGN;
884begin
885  OldC := CreateEmptyRegion;
886  GetClipRGN(DC, OldC);
887  Clip := CreateEmptyRegion;
888  //DebugLn('TWidgetSet.ExtSelectClipRGN A OldC=',DbgS(OldC),
889  //  ' Clip=',DbgS(Clip),8),' RGn=',DbgS(Cardinal(RGN),' Mode=',dbgs(Mode));
890  Result := CombineRGN(Clip, OldC, RGN, Mode);
891  //DebugLn('TWidgetSet.ExtSelectClipRGN B Result=',Result);
892  if Result <> ERROR then
893    Result := SelectClipRGN(DC, Clip);
894  DeleteObject(Clip);
895  DeleteObject(OldC);
896end;
897
898function TWidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean;
899begin
900  Result := False;
901end;
902
903function TWidgetSet.FloodFill(DC: HDC; X, Y: Integer;
904  Color: TGraphicsColor;
905  FillStyle: TGraphicsFillStyle;
906  Brush: HBRUSH): Boolean;
907begin
908  Result := false;
909end;
910
911function TWidgetSet.FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): BOOL;
912begin
913  Result := false;
914end;
915
916function TWidgetSet.FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH) : integer;
917begin
918  Result:= 0;
919end;
920
921function TWidgetSet.GetActiveWindow : HWND;
922begin
923  Result := 0;
924end;
925
926function TWidgetSet.GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint;
927begin
928  Result := 0;
929end;
930
931function TWidgetSet.GetBkColor(DC: HDC): TColorRef;
932begin
933  Result := 0;
934end;
935
936function TWidgetSet.GetCapture : HWND;
937begin
938  Result := 0;
939end;
940
941function TWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
942begin
943  Result := False;
944end;
945
946function TWidgetSet.GetCharABCWidths(DC: HDC; p2, p3: UINT; const ABCStructs): Boolean;
947begin
948  Result := False;
949end;
950
951function TWidgetSet.GetClientRect(handle : HWND; var Rect : TRect) : Boolean;
952begin
953  Result := False;
954end;
955
956function TWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
957begin
958  lpRect^ := Rect(0,0,0,0);
959  Result := SIMPLEREGION;
960end;
961
962function TWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN) : Longint;
963begin
964  Result := -1;
965end;
966
967function TWidgetSet.GetCurrentObject(DC: HDC; uObjectType: UINT): HGDIOBJ;
968begin
969  Result := 0;
970end;
971
972function TWidgetSet.GetCursorPos(var lpPoint: TPoint): Boolean;
973begin
974  Result := False;
975end;
976
977function TWidgetSet.GetDC(hWnd: HWND): HDC;
978begin
979  Result := 0;
980end;
981
982function TWidgetSet.GetDeviceCaps(DC: HDC; Index: Integer): Integer;
983begin
984  Result := 0;
985end;
986
987function TWidgetSet.GetDIBits(DC: HDC; Bitmap: HBitmap;
988  StartScan, NumScans: UINT; Bits: Pointer;
989  var BitInfo: BitmapInfo; Usage: UINT): Integer;
990begin
991  Result := 0;
992end;
993
994function TWidgetSet.GetDoubleClickTime: UINT;
995begin
996  // use windows default
997  Result := 500;
998end;
999
1000function TWidgetSet.GetFocus: HWND;
1001begin
1002  Result := 0;
1003end;
1004
1005function TWidgetSet.GetFontLanguageInfo(DC: HDC): DWord;
1006begin
1007  Result := 0;
1008end;
1009
1010function TWidgetSet.GetForegroundWindow: HWND;
1011begin
1012  Result := 0;
1013end;
1014
1015function TWidgetSet.GetIconInfo(AIcon: HICON; AIconInfo: PIconInfo): Boolean;
1016begin
1017  Result := False;
1018end;
1019
1020function TWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;
1021begin
1022  Result := 0;
1023end;
1024
1025function TWidgetSet.GetMapMode(DC: HDC): Integer;
1026begin
1027  Result := 0;
1028end;
1029
1030function TWidgetset.GetMonitorInfo(hMonitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
1031begin
1032  Result := False;
1033end;
1034
1035function TWidgetset.GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;
1036begin
1037  Result := S_FALSE;
1038end;
1039
1040function TWidgetSet.GetObject(GDIObject: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer;
1041begin
1042  Result := 0;
1043end;
1044
1045function TWidgetSet.GetPaletteEntries(Palette: HPALETTE;
1046  StartIndex, NumEntries: UINT; var PaletteEntries): UINT;
1047begin
1048  Result := 0;
1049end;
1050
1051function TWidgetSet.GetParent(Handle : HWND): HWND;
1052begin
1053  Result := 0;
1054end;
1055
1056function TWidgetSet.GetProp(Handle : hwnd; Str : PChar): Pointer;
1057begin
1058  Result := nil;
1059end;
1060
1061function TWidgetSet.GetRgnBox(RGN: HRGN; lpRect: PRect): Longint;
1062begin
1063  Result := SIMPLEREGION;
1064end;
1065
1066function TWidgetSet.GetROP2(DC: HDC): integer;
1067begin
1068  Result := 0;
1069end;
1070
1071function TWidgetSet.GetScrollInfo(Handle: HWND; SBStyle: Integer;
1072  var ScrollInfo: TScrollInfo): Boolean;
1073begin
1074  Result := False;
1075end;
1076
1077function TWidgetSet.GetStockObject(Value: Integer): THandle;
1078begin
1079  Result := 0;
1080end;
1081
1082function TWidgetSet.GetSysColor(nIndex: Integer): DWORD;
1083begin
1084  Result := 0;
1085end;
1086
1087function TWidgetSet.GetSysColorBrush(nIndex: Integer): HBrush;
1088var
1089  LogBrush: TLogBrush;
1090begin
1091  LogBrush.lbColor := GetSysColor(nIndex);
1092  LogBrush.lbStyle := 0; // BS_CLEAR
1093  LogBrush.lbHatch := 0;
1094  Result := CreateBrushIndirect(LogBrush);
1095end;
1096
1097function TWidgetSet.GetSystemMetrics(nIndex: Integer): Integer;
1098begin
1099  Result := 0;
1100  case nIndex of
1101  SM_CXEDGE: Result:=2;
1102  SM_CYEDGE: Result:=2;
1103  end;
1104end;
1105
1106function TWidgetSet.GetSystemPaletteEntries(DC: HDC;
1107  StartIndex, NumEntries: UINT; var PaletteEntries): UINT;
1108begin
1109  Result := 0;
1110end;
1111
1112function TWidgetSet.GetTextColor(DC: HDC) : TColorRef;
1113begin
1114  Result := 0;
1115end;
1116
1117{ Returns in MaxCount how many characters fit into a given MaxWidth
1118  It also returns the width of each character
1119
1120  MaxCount is given in the number of UTF-8 characters, not bytes
1121}
1122function TWidgetSet.GetTextExtentExPoint(DC: HDC; Str: PChar;
1123  Count, MaxWidth: Integer; MaxCount, PartialWidths: PInteger;
1124  var Size: TSize): Boolean;
1125var
1126  Utf8Len, CurLen, Left, Right, I: PtrInt;
1127  CurSize: TSize;
1128begin
1129  // First obtain the size information which duplicates GetTextExtentPoint
1130  if not GetTextExtentPoint(DC, Str, Count, Size) then
1131    Exit(False);
1132
1133  if MaxCount <> nil then
1134    MaxCount^ := 0
1135  else if PartialWidths = nil then
1136    Exit(True);
1137
1138  if Count = 0 then
1139    Exit(True);
1140  if (Count < -1) or (Str = nil) then
1141    Exit(False);
1142
1143  if Count = -1 then
1144    Count := Length(Str);
1145  Utf8Len := UTF8Length(Str, Count);
1146  if Utf8Len = 0 then
1147    Exit(True);
1148
1149  if PartialWidths = nil then
1150  begin
1151    if Size.cx <= MaxWidth then
1152      MaxCount^ := Utf8Len
1153    else
1154    begin
1155      Left := 0;
1156      Right := Utf8Len;
1157      while Left <= Right do
1158      begin
1159        I := (Left + Right) div 2;
1160        CurLen := UTF8CodepointToByteIndex(Str, Count, I);
1161        if not GetTextExtentPoint(DC, Str, CurLen, CurSize) then
1162          Exit(False);
1163        if CurSize.cx <= MaxWidth then
1164        begin
1165          MaxCount^ := I;
1166          Left := I + 1;
1167        end else
1168          Right := I - 1;
1169      end;
1170    end;
1171  end else
1172  begin
1173    CurLen := 0;
1174    for I := 1 to Utf8Len do
1175    begin
1176      Inc(CurLen, UTF8CodepointSize(@Str[CurLen]));
1177      if not GetTextExtentPoint(DC, Str, CurLen, CurSize) then
1178        Exit(False);
1179      if MaxCount <> nil then
1180      begin
1181        if CurSize.cx > MaxWidth then
1182          Break;
1183        MaxCount^ := I;
1184      end;
1185      PartialWidths[I - 1] := CurSize.cx;
1186    end;
1187  end;
1188
1189  Exit(True);
1190end;
1191
1192// Note that Count is the number of bytes in the utf-8 encoded string Str
1193function TWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer;
1194  var Size: TSize): Boolean;
1195begin
1196  Result := False;
1197end;
1198
1199function TWidgetSet.GetTextExtentPoint32(DC: HDC; Str: PChar;
1200  Count: Integer; var Size: TSize): Boolean;
1201begin
1202  Result := GetTextExtentPoint(DC,Str,Count,Size);
1203end;
1204
1205function TWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
1206begin
1207  Result := False;
1208end;
1209
1210function TWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer;
1211begin
1212  Result := 0;
1213end;
1214
1215function TWidgetSet.GetViewPortOrgEx(DC: HDC; P: PPoint): Integer;
1216begin
1217  Result := 0;
1218end;
1219
1220function TWidgetSet.GetWindowExtEx(DC: HDC; Size: PSize): Integer;
1221begin
1222  Result := 0;
1223end;
1224
1225function TWidgetSet.GetWindowLong(Handle : hwnd; int : Integer): PtrInt;
1226begin
1227  Result := 0;
1228end;
1229
1230function TWidgetSet.GetWindowOrgEx(dc: hdc; var P: TPoint): Integer;
1231begin
1232  Result := GetWindowOrgEx(dc, @P);
1233end;
1234
1235function TWidgetSet.GetWindowOrgEx(dc: hdc; P: PPoint): Integer;
1236begin
1237  Result := 0;
1238  if P <> nil then
1239    P^ := Point(0, 0);
1240end;
1241
1242function TWidgetSet.GetWindowRect(Handle : hwnd; var Rect : TRect): Integer;
1243{ After the call, ARect will be the control area in screen coordinates.
1244  That means, Left and Top will be the screen coordinate of the TopLeft pixel
1245  of the Handle object and Right and Bottom will be the screen coordinate of
1246  the BottomRight pixel. }
1247begin
1248  Result := 0;
1249end;
1250
1251{------------------------------------------------------------------------------
1252  Function: GradientFill
1253  Params: DC - DeviceContext to perform on
1254          Vertices - array of Points W/Color & Alpha
1255          NumVertices - Number of Vertices
1256          Meshes - array of Triangle or Rectangle Meshes,
1257                   each mesh representing one Gradient Fill
1258          NumMeshes - Number of Meshes
1259          Mode - Gradient Type, either Triangle,
1260                 Vertical Rect, Horizontal Rect
1261
1262  Returns: true on success
1263
1264  Performs multiple Gradient Fills, either a Three way Triangle Gradient,
1265  or a two way Rectangle Gradient, each Vertex point also supports optional
1266  Alpha/Transparency for more advanced Gradients.
1267 ------------------------------------------------------------------------------}
1268function TWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex; NumVertices: Longint;
1269  Meshes: Pointer; NumMeshes: Longint; Mode: Longint): Boolean;
1270
1271  function DoFillTriangle: Boolean; inline;
1272  begin
1273    Result := (Mode and GRADIENT_FILL_TRIANGLE) = GRADIENT_FILL_TRIANGLE;
1274  end;
1275
1276  function DoFillVRect: Boolean; inline;
1277  begin
1278    Result := (Mode and GRADIENT_FILL_RECT_V) = GRADIENT_FILL_RECT_V;
1279  end;
1280
1281  function CreateIntfImage(W, H: Integer; Clear: Boolean): TLazIntfImage;
1282  begin
1283    Result := TLazIntfImage.Create(W, H, [riqfRGB, riqfAlpha, riqfUpdate]);
1284    Result.CreateData;
1285    if Clear then
1286      Result.FillPixels(FPColor(0, 0, 0, $0000));
1287  end;
1288
1289  procedure DrawIntfImage(Image: TLazIntfImage; R: TRect);
1290  var
1291    Bmp, Mask, Old: HBitmap;
1292    BmpDC: HDC;
1293  begin
1294    Image.CreateBitmaps(Bmp, Mask, True);
1295    BmpDC := CreateCompatibleDC(0);
1296    Old := SelectObject(BmpDC, Bmp);
1297    MaskBlt(DC, R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, BmpDC, 0, 0, Mask, 0, 0);
1298    DeleteObject(SelectObject(BmpDC, Old));
1299    if Mask <> 0 then
1300      DeleteObject(Mask);
1301    DeleteDC(BmpDC);
1302  end;
1303
1304  function GetRectangleGradientColor(const BeginColor, EndColor: TFPColor; const Position, TotalSteps: Longint): TFPColor; inline;
1305  var
1306    A1: Word absolute BeginColor.alpha;
1307    R1: Word absolute BeginColor.red;
1308    G1: Word absolute BeginColor.green;
1309    B1: Word absolute BeginColor.blue;
1310    A2: Word absolute Endcolor.alpha;
1311    R2: Word absolute Endcolor.red;
1312    G2: Word absolute Endcolor.green;
1313    B2: Word absolute Endcolor.blue;
1314  begin
1315    Result.alpha := (A1 + (Position * (A2 - A1) div TotalSteps));
1316    Result.red := (R1 + (Position * (R2 - R1) div TotalSteps));
1317    Result.green := (G1 + (Position * (G2 - G1) div TotalSteps));
1318    Result.blue := (B1 + (Position * (B2 - B1) div TotalSteps));
1319  end;
1320
1321  function GetTriangleBounds(const v1, v2, v3: TTriVertex): TRect;
1322  begin
1323    with v1 do
1324    begin
1325      Result.Left := x;
1326      Result.Top := y;
1327      Result.BottomRight := Result.TopLeft;
1328    end;
1329    with v2 do
1330    begin
1331      if x < Result.Left then
1332        Result.Left := x;
1333      if x > Result.Right then
1334        Result.Right := x;
1335      if y < Result.Top then
1336        Result.Top := y;
1337      if y > Result.Bottom then
1338        Result.Bottom := y;
1339    end;
1340    with v3 do
1341    begin
1342      if x < Result.Left then
1343        Result.Left := x;
1344      if x > Result.Right then
1345        Result.Right := x;
1346      if y < Result.Top then
1347        Result.Top := y;
1348      if y > Result.Bottom then
1349        Result.Bottom := y;
1350    end;
1351  end;
1352
1353  {
1354    implementation of Arjen Nienhuis:
1355    http://www.winehq.org/pipermail/wine-patches/2003-June/006544.html
1356    Arjen has granted us the rights to include this code with our modified LGPL2 license
1357  }
1358
1359  procedure GradientFillTriangle(Image: TLazIntfImage; v1, v2, v3: TTriVertex);
1360  var
1361    t, v: TTriVertex;
1362    y, y2, dy, dy2: Integer;
1363    x, x1, x2, r1, r2, g1, g2, b1, b2: Integer;
1364    dx: Integer;
1365  begin
1366    if (v1.y > v2.y) then
1367    begin
1368      t := v1;
1369      v1 := v2;
1370      v2 := t;
1371    end;
1372
1373    if (v2.y > v3.y) then
1374    begin
1375      t := v2;
1376      v2 := v3;
1377      v3 := t;
1378      if (v1.y > v2.y) then
1379      begin
1380        t := v1;
1381        v1 := v2;
1382        v2 := t;
1383      end;
1384    end;
1385    // v1.y <= v2.y <= v3.y
1386    dy := v3.y - v1.y;
1387    for y := 0 to dy - 1 do
1388    begin
1389      // v1.y <= y < v3.y
1390      if y < (v2.y - v1.y) then
1391        v :=  v1
1392      else
1393        v := v3;
1394      // (v.y <= y < v2.y) || (v2.y <= y < v.y)
1395      dy2 := v2.y - v.y;
1396      y2 := y + v1.y - v.y;
1397      x1 := (v3.x     * y  + v1.x     * (dy  - y )) div dy;
1398      x2 := (v2.x     * y2 + v. x     * (dy2 - y2)) div dy2;
1399      r1 := (v3.Red   * y  + v1.Red   * (dy  - y )) div dy;
1400      r2 := (v2.Red   * y2 + v. Red   * (dy2 - y2)) div dy2;
1401      g1 := (v3.Green * y  + v1.Green * (dy  - y )) div dy;
1402      g2 := (v2.Green * y2 + v. Green * (dy2 - y2)) div dy2;
1403      b1 := (v3.Blue  * y  + v1.Blue  * (dy  - y )) div dy;
1404      b2 := (v2.Blue  * y2 + v. Blue  * (dy2 - y2)) div dy2;
1405      if (x1 < x2) then
1406      begin
1407        dx := x2 - x1;
1408        for x := 0 to dx - 1 do
1409          Image.Colors[x + x1, y + v1.y] := FPColor(
1410            (r1 * (dx - x) + r2 * x) div dx,
1411            (g1 * (dx - x) + g2 * x) div dx,
1412            (b1 * (dx - x) + b2 * x) div dx);
1413      end
1414      else
1415      begin
1416        dx := x1 - x2;
1417        for x := 0 to dx - 1 do
1418          Image.Colors[x + x2, y + v1.y] := FPColor(
1419            (r2 * (dx - x) + r1 * x) div dx,
1420            (g2 * (dx - x) + g1 * x) div dx,
1421            (b2 * (dx - x) + b1 * x) div dx);
1422      end;
1423    end;
1424  end;
1425
1426
1427  function FillTriMesh(Mesh: TGradientTriangle): Boolean;
1428  var
1429    v1, v2, v3: TTriVertex;
1430    R: TRect;
1431    Image: TLazIntfImage;
1432  begin
1433    with Mesh do
1434    begin
1435      Result :=
1436        (Vertex1 < Cardinal(NumVertices)) and
1437        (Vertex2 < Cardinal(NumVertices)) and
1438        (Vertex3 < Cardinal(NumVertices));
1439
1440      if (Vertex1 = Vertex2) or (Vertex1 = Vertex3) or (Vertex2 = Vertex3) or not Result then
1441        Exit;
1442    end;
1443
1444    v1 := Vertices[Mesh.Vertex1];
1445    v2 := Vertices[Mesh.Vertex2];
1446    v3 := Vertices[Mesh.Vertex3];
1447    R := GetTriangleBounds(v1, v2, v3);
1448    with R do
1449    begin
1450      dec(v1.x, Left);
1451      dec(v2.x, Left);
1452      dec(v3.x, Left);
1453
1454      dec(v1.y, Top);
1455      dec(v2.y, Top);
1456      dec(v3.y, Top);
1457    end;
1458
1459    Image := CreateIntfImage(R.Right - R.Left, R.Bottom - R.Top, True);
1460    GradientFillTriangle(Image, v1, v2, v3);
1461    DrawIntfImage(Image, R);
1462    Image.Free;
1463    Result := True;
1464  end;
1465
1466  function FillRectMesh(Mesh: TGradientRect): Boolean;
1467  var
1468    TL, BR: TTriVertex;
1469    StartColor, EndColor, CurColor: TFPColor;
1470    I, J: Longint;
1471    SwapColors: Boolean;
1472    Steps: Integer;
1473    Image: TLazIntfImage;
1474    R: TRect;
1475  begin
1476    with Mesh do
1477    begin
1478      Result := (UpperLeft < Cardinal(NumVertices)) and (LowerRight < Cardinal(NumVertices));
1479      if (LowerRight = UpperLeft) or not Result then
1480        Exit;
1481      TL := Vertices[UpperLeft];
1482      BR := Vertices[LowerRight];
1483      SwapColors := (BR.Y < TL.Y) and (BR.X < TL.X);
1484      if BR.X < TL.X then
1485      begin
1486        I := BR.X;
1487        BR.X := TL.X;
1488        TL.X := I;
1489      end;
1490      if BR.Y < TL.Y then
1491      begin
1492        I := BR.Y;
1493        BR.Y := TL.Y;
1494        TL.Y := I;
1495      end;
1496      StartColor := FPColor(TL.Red, TL.Green, TL.Blue);
1497      EndColor := FPColor(BR.Red, BR.Green, BR.Blue);
1498      if SwapColors then
1499      begin
1500        CurColor := StartColor;
1501        StartColor := EndColor;
1502        EndColor := CurColor;
1503      end;
1504
1505      R := Rect(TL.X, TL.Y, BR.X, BR.Y);
1506      dec(BR.X, TL.X);
1507      dec(BR.Y, TL.Y);
1508      TL.X := 0;
1509      TL.Y := 0;
1510      Image := CreateIntfImage(BR.X, BR.Y, False);
1511
1512      if DoFillVRect then
1513      begin
1514        Steps := BR.Y;
1515        for I := 0 to Steps - 1 do
1516        begin
1517          CurColor := GetRectangleGradientColor(StartColor, EndColor, I, Steps);
1518          for J := TL.X to BR.X - 1 do
1519            Image.Colors[J, I] := CurColor;
1520        end
1521      end
1522      else
1523      begin
1524        Steps := BR.X;
1525        for I := 0 to Steps - 1 do
1526        begin
1527          CurColor := GetRectangleGradientColor(StartColor, EndColor, I, Steps);
1528          for J := TL.Y to BR.Y - 1 do
1529            Image.Colors[I, J] := CurColor;
1530        end;
1531      end;
1532      DrawIntfImage(Image, R);
1533      Image.Free;
1534    end;
1535  end;
1536
1537const
1538  MeshSize: array[Boolean] of PtrUInt = (
1539    SizeOf(tagGradientRect),
1540    SizeOf(tagGradientTriangle)
1541  );
1542var
1543  I : Integer;
1544begin
1545  Result := Assigned(Meshes) and (NumMeshes >= 1) and (NumVertices >= 2) and Assigned(Vertices);
1546  if Result and DoFillTriangle then
1547    Result := NumVertices >= 3;
1548  if Result then
1549  begin
1550    Result := False;
1551
1552    //Sanity Checks For Vertices Size vs. Count
1553    if MemSize(Vertices) < PtrUInt(SizeOf(TTriVertex) * NumVertices) then
1554      Exit;
1555
1556    //Sanity Checks For Meshes Size vs. Count
1557    if MemSize(Meshes) < (MeshSize[DoFillTriangle] * Cardinal(NumMeshes)) then
1558      Exit;
1559
1560    for I := 0 to NumMeshes - 1 do
1561    begin
1562      if DoFillTriangle then
1563      begin
1564        if not FillTriMesh(PGradientTriangle(Meshes)[I]) then
1565          exit;
1566      end
1567      else
1568      begin
1569        if not FillRectMesh(PGradientRect(Meshes)[I]) then
1570          exit;
1571      end;
1572    end;
1573    Result := True;
1574  end;
1575end;
1576
1577function TWidgetSet.HideCaret(hWnd: HWND): Boolean;
1578begin
1579  Result := False;
1580end;
1581
1582function TWidgetSet.InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean;
1583begin
1584  Result := False;
1585end;
1586
1587function TWidgetSet.IsHelpKey(Key: Word; Shift: TShiftState): Boolean;
1588{ Asks if the passed key is determined by widgetset to show help }
1589begin
1590  Result := (Shift = []) and (Key = VK_F1);
1591end;
1592
1593procedure TWidgetSet.InitializeCriticalSection(var CritSection: TCriticalSection);
1594begin
1595  DebugLn('TWidgetSet.InitializeCriticalSection Not implemented yet');
1596end;
1597
1598function TWidgetSet.IntersectClipRect(DC: HDC; Left, Top, Right, Bottom: Integer): Integer;
1599var
1600  R: TRect;
1601  RRGN: hRGN;
1602begin
1603  R := Rect(Left, Top, Right, Bottom);
1604  LPtoDP(DC, R, 2);
1605  with R do
1606    RRGN := CreateRectRgn(Left, Top, Right, Bottom);
1607  if not DCClipRegionValid(DC) then
1608    Result := SelectClipRGN(DC, RRGN)
1609  else
1610    Result := ExtSelectClipRGN(DC, RRGN, RGN_AND);
1611  DeleteObject(RRGN);
1612end;
1613
1614function TWidgetSet.InvalidateRect(aHandle : HWND; ARect : pRect; bErase : Boolean) : Boolean;
1615begin
1616  Result := false;
1617end;
1618
1619function TWidgetSet.InvalidateRgn(Handle: HWND; Rgn: HRGN; Erase: Boolean): Boolean;
1620begin
1621  Result := False;
1622end;
1623
1624function TWidgetSet.IsDBCSLeadByte(TestChar: Byte): boolean;
1625begin
1626  Result := false;
1627end;
1628
1629function TWidgetSet.IsIconic(handle: HWND): boolean;
1630begin
1631  Result := False;
1632end;
1633
1634function TWidgetSet.IsWindow(handle: HWND): boolean;
1635begin
1636  Result := False;
1637end;
1638
1639function TWidgetSet.IsWindowEnabled(handle: HWND): boolean;
1640begin
1641  Result := false;
1642end;
1643
1644function TWidgetSet.IsWindowVisible(handle: HWND): boolean;
1645begin
1646  Result := false;
1647end;
1648
1649function TWidgetSet.IsZoomed(handle: HWND): boolean;
1650begin
1651  Result := False;
1652end;
1653
1654procedure TWidgetSet.LeaveCriticalSection(var CritSection: TCriticalSection);
1655begin
1656  DebugLn('TWidgetSet.LeaveCriticalSection Not implemented yet');
1657end;
1658
1659function TWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
1660begin
1661  Result := False;
1662end;
1663
1664function TWidgetSet.LoadBitmap(hInstance: THandle; lpBitmapName: PChar): HBitmap;
1665begin
1666  Result := LoadBitmapFunction(hInstance, lpBitmapName);
1667end;
1668
1669function TWidgetSet.LoadCursor(hInstance: THandle; lpCursorName: PChar): HCursor;
1670begin
1671  Result := LoadCursorFunction(hInstance, lpCursorName);
1672end;
1673
1674function TWidgetSet.LoadIcon(hInstance: THandle; lpIconName: PChar): HIcon;
1675begin
1676  Result := LoadIconFunction(hInstance, lpIconName);
1677end;
1678
1679function TWidgetSet.LPtoDP(DC: HDC; var Points; Count: Integer): BOOL;
1680begin
1681  Result := False;
1682end;
1683
1684function TWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar;
1685  uType : Cardinal): integer;
1686begin
1687  Result := 0;
1688end;
1689
1690function TWidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;
1691begin
1692  Result := MONITOR_UNIMPL;
1693end;
1694
1695function TWidgetSet.MonitorFromRect(lprcScreenCoords: PRect; dwFlags: DWord): HMONITOR;
1696begin
1697  Result := MONITOR_UNIMPL;
1698end;
1699
1700function TWidgetSet.MonitorFromWindow(hWnd: HWND; dwFlags: DWord): HMONITOR;
1701begin
1702  Result := MONITOR_UNIMPL;
1703end;
1704
1705function TWidgetSet.MaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
1706  SrcDC: HDC; XSrc, YSrc: Integer; Mask: HBITMAP; XMask, YMask: Integer;
1707  Rop: DWORD): Boolean;
1708begin
1709  Result := StretchMaskBlt(DestDC,X,Y,Width,Height,SrcDC,XSrc,YSrc,Width,Height,
1710                           Mask,XMask,YMask,ROp);
1711end;
1712
1713function TWidgetSet.MaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
1714  SrcDC: HDC; XSrc, YSrc: Integer; Mask: HBITMAP; XMask, YMask: Integer): Boolean;
1715begin
1716  Result := MaskBlt(DestDC,X,Y,Width,Height,SrcDC,XSrc,YSrc,
1717                    Mask,XMask,YMask,SRCCOPY);
1718end;
1719
1720function TWidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean;
1721begin
1722  Result := False;
1723end;
1724
1725function TWidgetSet.OffsetRgn(RGN: HRGN; nXOffset, nYOffset: Integer): Integer;
1726begin
1727  Result := Error;
1728end;
1729
1730function TWidgetSet.PaintRgn(DC: HDC; RGN: HRGN): Boolean;
1731begin
1732  Result := False;
1733end;
1734
1735function TWidgetSet.PeekMessage(var lpMsg : TMsg; Handle : HWND;
1736  wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean;
1737begin
1738  Result := False;
1739end;
1740
1741function TWidgetSet.Pie(DC: HDC; x1, y1, x2, y2,
1742                        sx, sy, ex, ey: Integer): Boolean;
1743var
1744  A1, A2: extended;
1745  A2i: integer;
1746begin
1747  Coords2Angles(x1, y1, x2-x1, y2-y1, sx, sy, ex, ey, A1, A2);
1748  A2i := RoundToInt(A2);
1749  if A2i = 0 then
1750    A2i := 5760;
1751  Result := RadialPie(DC, x1, y1, x2, y2, RoundToInt(A1), A2i);
1752end;
1753
1754function TWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
1755  Filled,Continuous: boolean): boolean;
1756var
1757  APoints : PPoint;
1758  ACount : Longint;
1759begin
1760  APoints := nil;
1761  ACount := 0;
1762  PolyBezier2Polyline(Points,NumPts,APoints,ACount,Continuous);
1763  If Filled then
1764    Result := Polygon(DC,APoints,ACount, False)
1765  else
1766    Result := Polyline(DC,APoints,ACount);
1767  ReallocMem(APoints,0);
1768End;
1769
1770function TWidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer;
1771  Winding: boolean): boolean;
1772begin
1773  Result := false;
1774end;
1775
1776function TWidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean;
1777begin
1778  Result := false;
1779end;
1780
1781function TWidgetSet.PostMessage(Handle: HWND; Msg: Cardinal;
1782  WParam: WParam; LParam: LParam): Boolean;
1783begin
1784  Result := False;
1785end;
1786
1787function TWidgetSet.PtInRegion(RGN: HRGN; X, Y: Integer): Boolean;
1788begin
1789  Result := false;
1790end;
1791
1792function TWidgetSet.RealizePalette(DC: HDC): Cardinal;
1793begin
1794  Result := 0;
1795end;
1796
1797function TWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
1798begin
1799  Result := False;
1800end;
1801
1802{------------------------------------------------------------------------------
1803  Determines if the specified rectangle is within the boundaries of a region.
1804  Default implementation, widgetsets will implement their own versions
1805 ------------------------------------------------------------------------------}
1806function TWidgetSet.RectInRegion(RGN: HRGN; ARect: TRect): Boolean;
1807var
1808  RectRgn, EmptyRgn: HRGN;
1809begin
1810  with ARect do
1811    RectRgn := CreateRectRgn(Left,Top,Right,Bottom);
1812  try
1813    EmptyRgn := CreateEmptyRegion;
1814    try
1815      Result := CombineRgn(EmptyRgn, RectRgn, RGN, RGN_AND) <> NULLREGION;
1816      if Result then
1817        Result := CombineRgn(EmptyRgn, EmptyRgn, RectRgn, RGN_XOR) = NULLREGION;
1818    finally
1819      DeleteObject(EmptyRgn);
1820    end;
1821  finally
1822    DeleteObject(RectRgn);
1823  end;
1824end;
1825
1826{------------------------------------------------------------------------------
1827  Function: RectVisible
1828  Params:  dc : hdc; ARect: TRect
1829  Returns: True if ARect is not completely clipped away.
1830 ------------------------------------------------------------------------------}
1831function TWidgetSet.RectVisible(DC: HDC; const ARect: TRect): Boolean;
1832var
1833  ClipRGN, RectRgn: hRGN;
1834  Intersection: hRGN;
1835  CombineResult: Integer;
1836begin
1837  Result := False;
1838  if (ARect.Left >= ARect.Right) or
1839     (ARect.Top >= ARect.Bottom) or
1840     not DCClipRegionValid(DC) then Exit;
1841
1842  ClipRGN := CreateEmptyRegion;
1843  if GetClipRGN(DC, ClipRGN) > 0 then
1844  begin
1845    RectRgn := CreateRectRGN(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
1846    Intersection := CreateEmptyRegion;
1847    //debugln(['TWidgetSet.RectVisible ARect=',dbgs(ARect)]);
1848    CombineResult := CombineRGN(Intersection, RectRGN, ClipRGN, RGN_AND);
1849    if CombineResult in [SimpleRegion, ComplexRegion] then
1850      Result := True;
1851    DeleteObject(Intersection);
1852    DeleteObject(RectRgn);
1853  end;
1854  DeleteObject(ClipRGN);
1855end;
1856
1857function TWidgetSet.RedrawWindow(Wnd: HWND; lprcUpdate: PRECT; hrgnUpdate: HRGN; flags: UINT): Boolean;
1858begin
1859  // check if validate flag is set, we have no default for it.
1860  if RDW_VALIDATE and flags <> 0 then Exit(False);
1861
1862  if hrgnUpdate = 0
1863  then Result := InvalidateRect(Wnd, lprcUpdate, RDW_ERASE and flags <> 0)
1864  else Result := InvalidateRgn(Wnd, hrgnUpdate, RDW_ERASE and flags <> 0)
1865end;
1866
1867function TWidgetSet.ReleaseCapture : Boolean;
1868begin
1869  Result := True;
1870end;
1871
1872function TWidgetSet.ReleaseDC(hWnd: HWND; DC: HDC): Integer;
1873begin
1874  Result := 0;
1875end;
1876
1877function TWidgetSet.RemoveProp(Handle: hwnd; Str: PChar): THandle;
1878begin
1879  Result := 0;
1880end;
1881
1882function TWidgetSet.RestoreDC(DC: HDC; SavedDC: Integer): Boolean;
1883begin
1884  Result := False;
1885end;
1886
1887function TWidgetSet.RoundRect(DC : hDC; X1, Y1, X2, Y2: Integer; RX,RY : Integer) : Boolean;
1888var
1889  T: Integer;
1890  Points: PPoint;
1891  Count: Integer;
1892
1893  procedure AddArcPoints(Left, Top, Right, Bottom, Angle1, Angle2: Integer);
1894  var
1895    P: PPoint;
1896    C: Integer;
1897    I: Integer;
1898  begin
1899    P := nil;
1900    try
1901      PolyBezierArcPoints(Left, Top, Right - Left, Bottom - Top, Angle1, Angle2,
1902        0, P, C);
1903
1904      ReallocMem(Points, (Count + C) * SizeOf(TPoint));
1905      for I := 0 to Pred(C) do
1906        Points[Count + Pred(C) - I] := P[I];
1907
1908      Inc(Count, C);
1909    finally
1910      FreeMem(P);
1911    end;
1912  end;
1913
1914begin
1915  Result := True;
1916
1917  if X2 < X1 then
1918  begin
1919    T := X1;
1920    X1 := X2;
1921    X2 := T;
1922  end;
1923
1924  if Y2 < Y1 then
1925  begin
1926    T := Y1;
1927    Y1 := Y2;
1928    Y2 := T;
1929  end;
1930
1931  if (X2 - X1 <= 0) or (Y2 - Y1 <= 0) then Exit;
1932
1933  Dec(X2);
1934  Dec(Y2);
1935
1936  if not ((RX <= 0) or (RY <= 0)) then
1937  begin
1938    if X2 - X1 < RX then RX := X2 - X1;
1939    if Y2 - Y1 < RY then RY := Y2 - Y1;
1940
1941    //debugln('TWidgetSet.RoundRect ',dbgs(Rect(X1,Y1,X2,Y2)),' ',dbgs(Point(RX,RY)));
1942    Points := nil;
1943    Count := 0;
1944    try
1945      AddArcPoints(X1, Y1, X1 + RX, Y1 + RY,  90 * 16, 90 * 16);
1946      AddArcPoints(X2 - RX, Y1, X2, Y1 + RY,   0 * 16, 90 * 16);
1947      AddArcPoints(X2 - RX, Y2 - RY, X2, Y2, 270 * 16, 90 * 16);
1948      AddArcPoints(X1, Y2 - RY, X1 + RX, Y2, 180 * 16, 90 * 16);
1949
1950      Polygon(DC, Points, Count, False);
1951    finally
1952      FreeMem(Points);
1953    end;
1954  end
1955  else
1956    Rectangle(DC, X1, Y1, X2, Y2);
1957end;
1958
1959function TWidgetSet.SaveDC(DC: HDC) : Integer;
1960begin
1961  Result := 0;
1962end;
1963
1964function TWidgetSet.ScreenToClient(Handle : HWND; var P : TPoint) : Integer;
1965begin
1966  Result := 0;
1967end;
1968
1969function TWidgetSet.ScrollWindowEx(hWnd: HWND; dx, dy: Integer; prcScroll, prcClip: PRect; hrgnUpdate: HRGN; prcUpdate: PRect; flags: UINT): Boolean;
1970begin
1971  Result := False;
1972end;
1973
1974function TWidgetSet.SelectClipRGN(DC : hDC; RGN : HRGN) : Longint;
1975begin
1976  Result := ERROR;
1977end;
1978
1979function TWidgetSet.SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
1980begin
1981  Result := 0;
1982end;
1983
1984function TWidgetSet.SelectPalette(DC: HDC; Palette: HPALETTE; ForceBackground: Boolean): HPALETTE;
1985begin
1986  Result := 0;
1987end;
1988
1989function TWidgetSet.SendMessage(HandleWnd: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LResult;
1990begin
1991  Result := 0;
1992end;
1993
1994function TWidgetSet.SetActiveWindow(Handle: HWND): HWND;
1995begin
1996  Result:=GetActiveWindow;
1997end;
1998
1999function TWidgetSet.SetBkColor(DC: HDC; Color: TColorRef): TColorRef; //pbd
2000begin
2001  Result := 0;
2002end;
2003
2004function TWidgetSet.SetBkMode(DC: HDC; bkMode : Integer): Integer;
2005begin
2006  Result := 0;
2007end;
2008
2009function TWidgetSet.SetCapture(AHandle: HWND): HWND;
2010begin
2011  Result := 0;
2012End;
2013
2014function TWidgetSet.SetCaretPos(X, Y: Integer): Boolean;
2015begin
2016  Result := False;
2017end;
2018
2019function TWidgetSet.SetCaretPosEx(handle: HWnd; X, Y: Integer): Boolean;
2020begin
2021  Result := False;
2022end;
2023
2024function TWidgetSet.SetCursor(hCursor: HICON): HCURSOR;
2025begin
2026  Result := 0;
2027end;
2028
2029function TWidgetSet.SetCursorPos(X, Y: Integer): Boolean;
2030begin
2031  // Your default here
2032  Result := False;
2033end;
2034
2035function TWidgetSet.SetFocus(hWnd: HWND): HWND;
2036begin
2037  Result := 0;
2038end;
2039
2040function TWidgetSet.SetForegroundWindow(hWnd : HWND): Boolean;
2041begin
2042  Result := false;
2043end;
2044
2045function TWidgetSet.SetMapMode(DC: HDC; fnMapMode : Integer): Integer;
2046begin
2047  Result := 0;
2048end;
2049
2050function TWidgetSet.SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean;
2051begin
2052  Result := False;
2053end;
2054
2055function TWidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
2056begin
2057  Result := 0;
2058end;
2059
2060function TWidgetSet.SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean;
2061begin
2062  Result := True;
2063end;
2064
2065function TWidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean;
2066begin
2067  Result := False;
2068end;
2069
2070function TWidgetSet.SetROP2(DC: HDC; Mode: Integer): Integer;
2071begin
2072  Result := 0;
2073end;
2074
2075function TWidgetSet.SetScrollInfo(Handle : HWND; SBStyle : Integer;
2076  ScrollInfo: TScrollInfo; Redraw : Boolean): Integer;
2077begin
2078  Result := 0;
2079end;
2080
2081function TWidgetSet.SetStretchBltMode(DC: HDC; StretchMode: Integer): Integer;
2082begin
2083  Result := 0;
2084end;
2085
2086function TWidgetSet.SetSysColors(cElements: Integer; const lpaElements;
2087  const lpaRgbValues): Boolean;
2088begin
2089  Result := False;
2090end;
2091
2092function TWidgetSet.SetTextCharacterExtra(_hdc : hdc; nCharExtra : Integer):Integer;
2093begin
2094  Result := 0;
2095end;
2096
2097function TWidgetSet.SetTextColor(DC: HDC; Color: TColorRef): TColorRef;
2098begin
2099  Result := CLR_INVALID;
2100end;
2101
2102function TWidgetSet.SetViewPortExtEx(DC: HDC; XExtent, YExtent : Integer; OldSize: PSize): Boolean;
2103begin
2104  Result := False;
2105end;
2106
2107function TWidgetSet.SetViewPortOrgEx(DC: HDC; NewX, NewY: Integer; OldPoint: PPoint): Boolean;
2108begin
2109  Result := False;
2110end;
2111
2112function TWidgetSet.SetWindowExtEx(DC: HDC; XExtent, YExtent: Integer; OldSize: PSize): Boolean;
2113begin
2114  Result := False;
2115end;
2116
2117function TWidgetSet.SetWindowLong(Handle: HWND;
2118  Idx: Integer; NewLong : PtrInt): PtrInt;
2119begin
2120  Result := -1;
2121end;
2122
2123function TWidgetSet.SetWindowOrgEx(dc : hdc; NewX, NewY : Integer;
2124  OldPoint: PPoint) : Boolean;
2125begin
2126  Result := False;
2127end;
2128
2129function TWidgetSet.SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
2130       X, Y, cx, cy: Integer; uFlags: UINT): Boolean;
2131begin
2132  Result:=false;
2133end;
2134
2135function TWidgetset.SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean): longint;
2136begin
2137  Result := 0;
2138end;
2139
2140function TWidgetSet.ShowCaret(hWnd: HWND): Boolean;
2141begin
2142  Result := False;
2143end;
2144
2145function TWidgetSet.ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean;
2146begin
2147  Result := False;
2148end;
2149
2150function TWidgetSet.ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean;
2151begin
2152  Result:=false;
2153end;
2154
2155function TWidgetSet.StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer;
2156  SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Rop: Cardinal): Boolean;
2157begin
2158  Result := False;
2159end;
2160
2161function TWidgetSet.StretchDIBits(DC: HDC;
2162  DestX, DestY, DestWidth, DestHeight, SrcX, SrcY, SrcWidth, SrcHeight: Integer;
2163  Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT; Rop: DWORD): Integer;
2164begin
2165  Result := 0;
2166end;
2167
2168function TWidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool;
2169begin
2170  case uiAction of
2171    SPI_GETWHEELSCROLLLINES: begin
2172      PDword(pvPAram)^ := 3; // default value
2173      Result := True;
2174    end;
2175  else
2176    Result := False;
2177  end
2178end;
2179
2180function TWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean;
2181begin
2182  Result := false;
2183end;
2184
2185function TWidgetSet.UpdateWindow(Handle: HWND): Boolean;
2186begin
2187  Result := false;
2188end;
2189
2190function TWidgetSet.WindowFromPoint(Point : TPoint) : HWND;
2191begin
2192  Result := 0;
2193end;
2194
2195//##apiwiz##eps##   // Do not remove
2196