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

Legend:

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

    r412 r463  
    88
    99type
    10   TShowNewContent = procedure (NewMode: Integer; HelpContext: string) of object;
     10  TWindowMode = (wmNone, wmModal, wmPersistent, wmSubmodal);
     11  TShowNewContent = procedure (NewMode: TWindowMode; HelpContext: string) of object;
    1112
    1213  { TBufferedDrawDlg }
    1314
    1415  TBufferedDrawDlg = class(TDrawDlg)
     16  protected
     17    FWindowMode: TWindowMode;
     18    ModalFrameIndent: Integer;
     19    HelpContext: string;
     20    procedure ShowNewContent(NewMode: TWindowMode; ForceClose: Boolean = False);
     21    procedure MarkUsedOffscreen(xMax, yMax: Integer);
     22    procedure OffscreenPaint; virtual;
     23    procedure VPaint; virtual;
    1524  public
    1625    UserLeft: Integer;
    1726    UserTop: Integer;
     27    UsedOffscreenWidth: Integer;
     28    UsedOffscreenHeight: Integer;
     29    Offscreen: TDpiBitmap;
     30    OffscreenUser: TDpiForm;
    1831    constructor Create(AOwner: TComponent); override;
    1932    destructor Destroy; override;
     
    2235    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2336    procedure FormDeactivate(Sender: TObject);
    24     procedure SmartUpdateContent(ImmUpdate: Boolean = false);
     37    procedure SmartUpdateContent(ImmUpdate: Boolean = False);
    2538    procedure StayOnTop_Workaround;
    26   protected
    27     FWindowMode: Integer;
    28     ModalFrameIndent: Integer;
    29     HelpContext: string;
    30     procedure ShowNewContent(NewMode: Integer; ForceClose: Boolean = False);
    31     procedure MarkUsedOffscreen(xMax, yMax: Integer);
    32     procedure OffscreenPaint; virtual;
    33     procedure VPaint; virtual;
    34   public
    35     UsedOffscreenWidth: Integer;
    36     UsedOffscreenHeight: Integer;
    37     Offscreen: TDpiBitmap;
    38     OffscreenUser: TDpiForm;
    39     property WindowMode: integer read FWindowMode;
     39    property WindowMode: TWindowMode read FWindowMode;
    4040  end;
    4141
    4242  TFramedDlg = class(TBufferedDrawDlg)
    43   public
    44     constructor Create(AOwner: TComponent); override;
    45     procedure FormCreate(Sender: TObject);
    46     procedure SmartInvalidate; override;
    4743  protected
    4844    CaptionLeft: Integer;
    4945    CaptionRight: Integer;
    5046    InnerWidth: Integer;
    51     InnerHeight: integer;
     47    InnerHeight: Integer;
    5248    WideBottom: Boolean;
    5349    FullCaption: Boolean;
     
    5753    procedure VPaint; override;
    5854    procedure FillOffscreen(Left, Top, Width, Height: Integer);
     55  public
     56    constructor Create(AOwner: TComponent); override;
     57    procedure FormCreate(Sender: TObject);
     58    procedure SmartInvalidate; override;
    5959  end;
    6060
     
    6464
    6565const
    66   // window modes
    67   wmNone = 0;
    68   wmModal = $1;
    69   wmPersistent = $2;
    70   wmSubmodal = $3;
    71 
    7266  yUnused = 161;
    7367  NarrowFrame = 11;
     
    7670
    7771procedure CreateOffscreen(var Offscreen: TDpiBitmap);
     72function WindowModeMakePersistent(Mode: TWindowMode): TWindowMode;
    7873procedure Register;
    7974
     
    8378uses
    8479  ButtonBase, Area;
     80
     81function WindowModeMakePersistent(Mode: TWindowMode): TWindowMode;
     82begin
     83  if Mode = wmModal then Result := wmSubmodal
     84    else Result := wmPersistent;
     85end;
    8586
    8687procedure Register;
     
    118119    UserTop := Top;
    119120  end;
    120   if OffscreenUser = self then
     121  if OffscreenUser = Self then
    121122    OffscreenUser := nil;
    122123end;
     
    124125procedure TBufferedDrawDlg.FormPaint(Sender: TObject);
    125126begin
    126   if OffscreenUser <> self then
     127  if OffscreenUser <> Self then
    127128    OffscreenPaint;
    128129  VPaint;
     
    142143  if Key = VK_F1 then begin
    143144    if Assigned(ShowNewContentProc) then
    144       ShowNewContentProc(FWindowMode or wmPersistent, HelpContext);
     145      ShowNewContentProc(WindowModeMakePersistent(FWindowMode), HelpContext);
    145146  end else
    146147  if FWindowMode = wmPersistent then begin
     
    165166procedure TBufferedDrawDlg.VPaint;
    166167begin
    167   DpiBitCanvas(Canvas, 0, 0, ClientWidth, ClientHeight, Offscreen.Canvas, 0, 0);
    168 end;
    169 
    170 procedure TBufferedDrawDlg.ShowNewContent(NewMode: Integer;
     168  DpiBitBltCanvas(Canvas, 0, 0, ClientWidth, ClientHeight, Offscreen.Canvas, 0, 0);
     169end;
     170
     171procedure TBufferedDrawDlg.ShowNewContent(NewMode: TWindowMode;
    171172  ForceClose: Boolean);
    172173begin
     
    178179      UserLeft := Left;
    179180      UserTop := Top;
    180       Visible := false;
     181      Visible := False;
    181182      FWindowMode := NewMode;
    182183      ShowModal;
     
    184185    else if forceclose then
    185186    begin // make modal
    186       Visible := false;
     187      Visible := False;
    187188      FWindowMode := NewMode;
    188189      Left := UserLeft;
     
    204205    Left := UserLeft;
    205206    Top := UserTop;
    206     if FWindowMode = wmModal then
    207       ShowModal
     207    if FWindowMode = wmModal then begin
     208      Gtk2Fix;
     209      ShowModal;
     210    end
    208211    else
    209212      Show;
     
    268271procedure TFramedDlg.SmartInvalidate;
    269272var
    270   i, BottomFrame: integer;
     273  I, BottomFrame: Integer;
    271274  r0, r1: HRgn;
    272275begin
     
    277280  r0 := DpiCreateRectRgn(SideFrame, TitleHeight, ClientWidth - SideFrame,
    278281    ClientHeight - BottomFrame);
    279   for i := 0 to ControlCount - 1 do
    280     if not(Controls[i] is TArea) and Controls[i].Visible then
     282  for I := 0 to ControlCount - 1 do
     283    if not(Controls[I] is TArea) and Controls[I].Visible then
    281284    begin
    282       with Controls[i].BoundsRect do
     285      with Controls[I].BoundsRect do
    283286        r1 := DpiCreateRectRgn(Left, Top, Right, Bottom);
    284287      CombineRgn(r0, r0, r1, RGN_DIFF);
     
    291294procedure TFramedDlg.VPaint;
    292295
    293   procedure CornerFrame(x0, y0, x1, y1: integer);
     296  procedure CornerFrame(x0, y0, x1, y1: Integer);
    294297  begin
    295298    Frame(Canvas, x0 + 1, y0 + 1, x1 - 2, y1 - 2, MainTexture.ColorBevelLight,
     
    304307
    305308var
    306   i, l, FrameTop, FrameBottom, InnerBottom, Cut, xTexOffset,
    307     yTexOffset: integer;
     309  I, L, FrameTop, FrameBottom, InnerBottom, Cut, xTexOffset,
     310    yTexOffset: Integer;
    308311  R: TRect;
    309312begin
     
    317320  end;
    318321  Canvas.Font.Assign(UniFont[ftCaption]);
    319   l := BiColorTextWidth(Canvas, Caption);
    320   Cut := (ClientWidth - l) div 2;
     322  L := BiColorTextWidth(Canvas, Caption);
     323  Cut := (ClientWidth - L) div 2;
    321324  xTexOffset := (Maintexture.Width - ClientWidth) div 2;
    322325  yTexOffset := (Maintexture.Height - ClientHeight) div 2;
     
    442445  RisedTextOut(Canvas, Cut - 1, 7, Caption);
    443446
    444   for i := 0 to ControlCount - 1 do
    445     if Controls[i].Visible and (Controls[i] is TButtonBase) then
     447  for I := 0 to ControlCount - 1 do
     448    if Controls[I].Visible and (Controls[I] is TButtonBase) then
    446449    begin
    447       R := Controls[i].BoundsRect;
     450      R := Controls[I].BoundsRect;
    448451      if (R.Bottom <= TitleHeight) or (R.Top >= InnerBottom) then
    449452        BtnFrame(Canvas, R, MainTexture);
    450453    end;
    451454
    452   DpiBitCanvas(Canvas, SideFrame, TitleHeight, ClientWidth - 2 * SideFrame,
     455  DpiBitBltCanvas(Canvas, SideFrame, TitleHeight, ClientWidth - 2 * SideFrame,
    453456    InnerBottom - TitleHeight, Offscreen.Canvas, 0, 0);
    454457end;
     
    459462begin
    460463  if FullCaption then
    461     exit;
     464    Exit;
    462465  r0 := DpiCreateRectRgn(0, 0, ClientWidth, ClientHeight);
    463466  r1 := DpiCreateRectRgn(0, 0, CaptionLeft, TitleHeight - NarrowFrame);
     
    509512MainFormKeyDown := nil;
    510513
    511 finalization
    512 
    513514end.
Note: See TracChangeset for help on using the changeset viewer.