Ignore:
Timestamp:
Nov 29, 2023, 2:35:44 PM (12 months ago)
Author:
chronos
Message:
  • Modified: HighDpi branch updated to trunk version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/DrawDlg.pas

    r413 r463  
    11unit DrawDlg;
    22
    3 {$mode delphi}{$H+}
    4 
    53interface
    64
    75uses
    8   UDpiControls, Classes, SysUtils, Forms, LCLIntf, LCLType, {$IFDEF LINUX}LMessages,{$ENDIF}
     6  UDpiControls, Classes, SysUtils, Forms, LCLIntf, LCLType, {$IFDEF UNIX}LMessages,{$ENDIF}
    97  Messages, Graphics, Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools
    108  {$IFDEF LCLGTK2}, Gtk2Globals{$ENDIF};
     
    4846    Lines: Integer;
    4947    TopSpace: Integer;
    50     procedure SplitText(preview: boolean);
     48    procedure SplitText(Preview: Boolean);
    5149    procedure CorrectHeight;
    5250  end;
     
    7674  MoveActive := False;
    7775  AddHandlerOnVisibleChanged(VisibleChangedHandler);
    78   {$IFDEF LINUX}
     76  {$IFDEF UNIX}
    7977  OnDeactivate := DoDeactivate;
    8078  {$ENDIF}
     
    102100  else
    103101  begin
    104     Pos := ScalePointFromNative(Point(Integer(Msg.LParam and $ffff),
    105       Integer((Msg.LParam shr 16) and $ffff)));
     102    Pos := Point(ScaleFromNative(Integer(Msg.LParam and $ffff)),
     103      ScaleFromNative(Integer((Msg.LParam shr 16) and $ffff)));
    106104    if Pos.Y >= Top + TitleHeight then
    107105      Msg.Result := HTCLIENT
     
    131129  MousePos1: TPoint;
    132130  MousePos2: TPoint;
    133 {$IFDEF LINUX}
     131{$IFDEF UNIX}
    134132  MousePosNew: TPoint;
    135133  NewFormPos: TPoint;
    136134{$ENDIF}
    137135begin
    138   MousePos1 := DpiMouse.CursorPos;
    139   inherited;
    140   MousePos2 := DpiMouse.CursorPos;
    141   {$IFDEF LINUX}
     136  MousePos1 := Mouse.CursorPos;
     137  inherited;
     138  MousePos2 := Mouse.CursorPos;
     139  {$IFDEF UNIX}
    142140  // Only if client is not doing own mouse move handling
    143141  if not Assigned(OnMouseDown) or not Assigned(OnMouseMove) or not Assigned(OnMouseUp) then begin
    144142    // HitTest is not supported under Linux GTK2 so use form inside move mechanizm
    145     NewFormPos := ScreenToClient(DpiMouse.CursorPos);
     143    NewFormPos := ScreenToClient(Mouse.CursorPos);
    146144    if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and
    147145      (NewFormPos.Y >= 0) and (NewFormPos.Y < Height) and
     
    149147      MoveMousePos := ClientToScreen(Point(X, Y));
    150148      MoveFormPos := Point(Left, Top);
    151       MousePosNew := DpiMouse.CursorPos;
     149      MousePosNew := Mouse.CursorPos;
    152150      // Activate move only if mouse position was not changed during inherited call
    153151      if (MousePos1.X = MousePos2.X) and (MousePos1.Y = MousePos2.Y) then begin
     
    197195  {$IFDEF LCLGTK2}
    198196  // GTK2 bug workaround https://bugs.freepascal.org/view.php?id=35720
    199   if Visible then LastMouse.WinControl := Self.GetNativeForm;
     197  if Visible then LastMouse.WinControl := Self;
    200198  {$ENDIF}
    201199end;
     
    208206procedure TDrawDlg.InitButtons;
    209207var
    210   cix: integer;
     208  cix: Integer;
    211209  // ButtonDownSound, ButtonUpSound: string;
    212210begin
     
    230228procedure TDrawDlg.SmartInvalidate;
    231229var
    232   i: integer;
     230  i: Integer;
    233231  r0, r1: HRgn;
    234232begin
     
    242240      DeleteObject(r1);
    243241    end;
    244   InvalidateRgn(Handle, r0, false);
     242  InvalidateRgn(Handle, r0, False);
    245243  DeleteObject(r0);
    246244end;
     
    250248procedure TBaseMessgDlg.FormCreate(Sender: TObject);
    251249begin
    252   Left := (DpiScreen.Width - Width) div 2;
     250  Left := (Screen.Width - Width) div 2;
    253251  Canvas.Font.Assign(UniFont[ftNormal]);
    254252  Canvas.Brush.Style := bsClear;
    255253  MessgText := '';
    256254  TopSpace := 0;
    257   TitleHeight := DpiScreen.Height;
     255  TitleHeight := Screen.Height;
    258256  if csDesigning in ComponentState then Exit;
    259257  InitButtons;
     
    262260procedure TBaseMessgDlg.FormPaint(Sender: TObject);
    263261var
    264   i, cix: integer;
     262  i, cix: Integer;
    265263begin
    266264  if csDesigning in ComponentState then Exit;
    267   PaintBackground(self, 3 + Border, 3 + Border, ClientWidth - (6 + 2 * Border),
     265  PaintBackground(Self, 3 + Border, 3 + Border, ClientWidth - (6 + 2 * Border),
    268266    ClientHeight - (6 + 2 * Border));
    269267  for i := 0 to Border do
     
    276274    ClientHeight - (3 + Border), MainTexture.ColorBevelLight,
    277275    MainTexture.ColorBevelShade);
    278   SplitText(false);
     276  SplitText(False);
    279277
    280278  for cix := 0 to ControlCount - 1 do
     
    283281end;
    284282
    285 procedure TBaseMessgDlg.SplitText(preview: boolean);
    286 var
    287   Start, Stop, OrdinaryStop, LinesCount: integer;
     283procedure TBaseMessgDlg.SplitText(Preview: Boolean);
     284var
     285  Start, Stop, OrdinaryStop, LinesCount: Integer;
    288286  s: string;
    289287begin
     
    296294      (BiColorTextWidth(Canvas, Copy(MessgText, Start, Stop - Start + 1)) <
    297295      ClientWidth - 56) do
    298       inc(Stop);
     296      Inc(Stop);
    299297    if Stop <> Length(MessgText) then
    300298    begin
     
    305303        (MessgText[OrdinaryStop + 1] = '\');
    306304      if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then
    307         Stop := OrdinaryStop
    308     end;
    309     if not preview then
     305        Stop := OrdinaryStop;
     306    end;
     307    if not Preview then
    310308    begin
    311309      s := Copy(MessgText, Start, Stop - Start + 1);
     
    315313    end;
    316314    Start := Stop + 2;
    317     inc(LinesCount)
    318   end;
    319   if preview then
     315    inc(LinesCount);
     316  end;
     317  if Preview then
    320318    Lines := LinesCount;
    321319end;
     
    323321procedure TBaseMessgDlg.CorrectHeight;
    324322var
    325   i: integer;
     323  i: Integer;
    326324begin
    327325  ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing;
    328   Top := (DpiScreen.Height - ClientHeight) div 2;
     326  Top := (Screen.Height - ClientHeight) div 2;
    329327  for i := 0 to ControlCount - 1 do
    330328    Controls[i].Top := ClientHeight - (34 + Border);
     
    333331end.
    334332
     333
     334
Note: See TracChangeset for help on using the changeset viewer.