~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to lcl/interfaces/qt/qtwinapi.inc

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2013-06-22 13:31:45 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130622133145-kf2awlf322usnrfv
Tags: 1.0.10+dfsg-1
[ Abou Al Montacir ]
* New upstream maintenance release offering many fixes improving the IDE and
  the LCL stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch#Fixes_for_1.0.10
* Use compiler configuration file to pass debian custom compiler flags.
* Recover FTBFS on arm machines fix, dropped unintentionally when upgrading
  to 1.0.8. QT4 based LCL WS could not use QTOPIA. (Closes: Bug#712834)
* Update copyright notice to highlight that upstream source where repacked.

[ Paul Gevers ]
* Update Standard to 3.9.4 (no changes needed)
* Remove obsolete DM-Upload-Allowed
* Update lintian overrides
* Add myself to uploaders
* Update Vsc-Browser URL to the browse interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{%MainUnit qtint.pp}
2
 
{ $Id: qtwinapi.inc 40308 2013-02-13 19:32:31Z martin $ }
 
2
{ $Id: qtwinapi.inc 41438 2013-05-28 06:57:26Z zeljko $ }
3
3
{******************************************************************************
4
4
  All QT Winapi implementations.
5
5
  This are the implementations of the overrides of the QT Interface for the
74
74
  This function is Called:
75
75
  - Once on every OnPaint event
76
76
 ------------------------------------------------------------------------------}
77
 
function TQtWidgetSet.BeginPaint(Handle: hWnd; Var PS : TPaintStruct): hdc;
 
77
function TQtWidgetSet.BeginPaint(Handle: hWnd; var PS: TPaintStruct): hdc;
78
78
var
79
79
  Widget: TQtWidget;
80
80
  DC: TQtDeviceContext;
95
95
    // if current handle has paintdata information,
96
96
    // setup hdc with it
97
97
    //DC.DebugClipRect('BeginPaint: Before');
 
98
    if (QtVersionMajor = 4) and (QtVersionMinor > 6) then
 
99
      QPainter_setLayoutDirection(DC.Widget, QtLayoutDirectionAuto);
98
100
    if Widget.PaintData.ClipRegion <> nil then
99
101
    begin
100
102
      //Write('>>> Setting Paint ClipRegion: ');
1488
1490
 
1489
1491
  Use Ellipse to draw a filled circle or ellipse.
1490
1492
 ------------------------------------------------------------------------------}
1491
 
function TQtWidgetSet.Ellipse(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
 
1493
function TQtWidgetSet.Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean;
1492
1494
var
1493
1495
  R: TRect;
1494
1496
begin
2332
2334
  R: TRect;
2333
2335
  hasClipping: Boolean;
2334
2336
  QtDC: TQtDeviceContext;
 
2337
  APath: QPainterPathH;
 
2338
  APolyFH: QPolygonFH;
2335
2339
begin
2336
2340
  {$ifdef VerboseQtWinAPI}
2337
2341
    DebugLn('[WinAPI FillRgn Rgn=', dbgs(RegionHnd),' Brush=', dbghex(hbr));
2345
2349
 
2346
2350
  HasClipping := QtDC.getClipping;
2347
2351
  QtDC.save;
 
2352
 
2348
2353
  if HasClipping then
2349
 
    OldRgn := TQtRegion.Create(True);
 
2354
    OldRgn := TQtRegion.Create(True)
 
2355
  else
 
2356
    OldRgn := nil;
2350
2357
  try
2351
2358
    if HasClipping then
2352
2359
      QPainter_clipRegion(QtDC.Widget, OldRgn.FHandle);
 
2360
 
2353
2361
    if SelectClipRgn(DC, RegionHnd) <> ERROR then
2354
2362
    begin
2355
 
      R := TQtRegion(RegionHnd).getBoundingRect;
2356
 
      QtDC.fillRect(@R, TQtBrush(hbr).FHandle);
 
2363
      if TQtRegion(RegionHnd).IsPolyRegion then
 
2364
      begin
 
2365
        APath := QPainterPath_create();
 
2366
        APolyFH := QPolygonF_create(TQtRegion(RegionHnd).Polygon);
 
2367
        try
 
2368
          QPainterPath_addPolygon(APath, APolyFH);
 
2369
          QPainter_fillPath(QtDC.Widget, APath, TQtBrush(hbr).FHandle);
 
2370
        finally
 
2371
          QPainterPath_destroy(APath);
 
2372
          QPolygonF_destroy(APolyFH);
 
2373
        end;
 
2374
      end else
 
2375
      begin
 
2376
        R := TQtRegion(RegionHnd).getBoundingRect;
 
2377
        QtDC.fillRect(@R, TQtBrush(hbr).FHandle);
 
2378
      end;
2357
2379
      if HasClipping then
2358
2380
        SelectClipRgn(DC, HRGN(OldRgn));
2359
2381
      Result := True;
2363
2385
      OldRgn.Free;
2364
2386
    QtDC.restore;
2365
2387
  end;
2366
 
 
2367
2388
end;
2368
2389
 
2369
2390
{------------------------------------------------------------------------------
2373
2394
 
2374
2395
  Draws a 3d border in Qt native style.
2375
2396
 ------------------------------------------------------------------------------}
2376
 
function TQtWidgetSet.Frame3d(DC : HDC; var ARect : TRect;
2377
 
  const FrameWidth : integer; const Style : TBevelCut) : boolean;
 
2397
function TQtWidgetSet.Frame3d(DC: HDC; var ARect: TRect;
 
2398
  const FrameWidth: integer; const Style: TBevelCut): Boolean;
2378
2399
var
2379
2400
  QtDC: TQtDeviceContext;
2380
2401
begin
2954
2975
begin
2955
2976
  Result := 0;
2956
2977
 
 
2978
  {$IFDEF MSWINDOWS}
 
2979
  if (nVirtKey = VK_CONTROL) or (nVirtKey = VK_MENU) or
 
2980
    (nVirtKey = VK_LCONTROL) or (nVirtKey = VK_LMENU) then
 
2981
  begin
 
2982
    if (GetWinKeyState(VK_RMENU) < 0) and
 
2983
      (GetWinKeyState(VK_LCONTROL) < 0) then
 
2984
      exit;
 
2985
  end;
 
2986
  {$ENDIF}
 
2987
 
2957
2988
  case nVirtKey of
2958
2989
    VK_LSHIFT:   nVirtKey := VK_SHIFT;
2959
2990
    VK_LCONTROL: nVirtKey := VK_CONTROL;
2961
2992
  end;
2962
2993
 
2963
2994
  // where to track toggle state?
2964
 
 
2965
2995
  case nVirtKey of
2966
2996
    VK_LBUTTON:
2967
2997
      if (QApplication_mouseButtons and QtLeftButton) > 0 then
2990
3020
    VK_LWIN, VK_RWIN:
2991
3021
      if (QApplication_keyboardModifiers and QtMetaModifier) > 0 then
2992
3022
        Result := Result or StateDown;
 
3023
    VK_LCL_CAPSLOCK, VK_NUMLOCK:
 
3024
    begin
 
3025
      {$IFDEF MSWINDOWS}
 
3026
      Result := GetWinKeyState(nVirtKey);
 
3027
      {$ELSE}
 
3028
      {$IFDEF HASX11}
 
3029
      if GetKeyLockState(nVirtKey) then
 
3030
        Result := StateDown;
 
3031
      {$ENDIF}
 
3032
      {$ENDIF}
 
3033
    end;
2993
3034
   {$ifdef VerboseQtWinAPI}
2994
3035
    else
2995
3036
      DebugLn('TQtWidgetSet.GetKeyState TODO ', DbgSVKCode(Word(nVirtkey)));
3461
3502
  Returns: boolean
3462
3503
 
3463
3504
 ------------------------------------------------------------------------------}
3464
 
function TQtWidgetSet.GetScrollInfo(Handle: HWND; BarFlag: Integer; Var ScrollInfo: TScrollInfo): Boolean;
 
3505
function TQtWidgetSet.GetScrollInfo(Handle: HWND; BarFlag: Integer;
 
3506
  var ScrollInfo: TScrollInfo): Boolean;
3465
3507
var
3466
3508
  QtScrollBar: TQtScrollBar;
3467
3509
begin
4361
4403
 
4362
4404
  Retrieves the dimensions of the bounding rectangle of the specified window.
4363
4405
 ------------------------------------------------------------------------------}
4364
 
function TQtWidgetSet.GetWindowRect(Handle: HWND; var ARect: TRect): Integer;
 
4406
function TQtWidgetSet.GetWindowRect(Handle: hwnd; var ARect: TRect): Integer;
4365
4407
var
4366
4408
  APos: TQtPoint;
4367
4409
  R: TRect;
4390
4432
  returns the current widget Left, Top, relative to the client origin of its
4391
4433
  parent
4392
4434
 ------------------------------------------------------------------------------}
4393
 
function TQtWidgetSet.GetWindowRelativePosition(Handle: HWND; var Left, Top: integer): boolean;
 
4435
function TQtWidgetSet.GetWindowRelativePosition(Handle: hwnd; var Left,
 
4436
  Top: Integer): boolean;
4394
4437
var
4395
4438
  R: TRect;
4396
4439
begin
4412
4455
 
4413
4456
  Returns the current widget Width and Height
4414
4457
 ------------------------------------------------------------------------------}
4415
 
function TQtWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer): boolean;
 
4458
function TQtWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: Integer
 
4459
  ): boolean;
4416
4460
begin
4417
4461
  {$ifdef VerboseQtWinAPI}
4418
4462
    WriteLn('[WinAPI GetWindowSize]');
4451
4495
  Alpha/Transparency for more advanced Gradients.
4452
4496
 ------------------------------------------------------------------------------}
4453
4497
function TQtWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex;
4454
 
  NumVertices : Longint;
4455
 
  Meshes: Pointer; NumMeshes : Longint; Mode : Longint): boolean;
 
4498
  NumVertices: Longint; Meshes: Pointer; NumMeshes: Longint; Mode: Longint
 
4499
  ): Boolean;
4456
4500
 
4457
4501
  function DoFillTriangle: Boolean; inline;
4458
4502
  begin
4942
4986
  Returns: Nothing
4943
4987
 ------------------------------------------------------------------------------}
4944
4988
function TQtWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
4945
 
  Filled, Continuous: Boolean): Boolean;
 
4989
  Filled, Continuous: boolean): boolean;
4946
4990
begin
4947
4991
  {$ifdef VerboseQtWinAPI}
4948
4992
    WriteLn('[WinAPI PolyBezier] DC: ', dbghex(DC));
4956
5000
  Returns: Nothing
4957
5001
 ------------------------------------------------------------------------------}
4958
5002
function TQtWidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer;
4959
 
  Winding: Boolean): boolean;
 
5003
  Winding: boolean): boolean;
4960
5004
var
4961
5005
  QtPoints: PQtPoint;
4962
5006
  i: integer;
6531
6575
  Returns:
6532
6576
 
6533
6577
 ------------------------------------------------------------------------------}
6534
 
function TQtWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : PChar; Count: Integer) : Boolean;
 
6578
function TQtWidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: Pchar; Count: Integer
 
6579
  ): Boolean;
6535
6580
var
6536
6581
  WideStr: WideString;
6537
6582
begin