Changeset 463 for branches/highdpi/Packages/CevoComponents/BaseWin.pas
- Timestamp:
- Nov 29, 2023, 2:35:44 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/BaseWin.pas
r412 r463 8 8 9 9 type 10 TShowNewContent = procedure (NewMode: Integer; HelpContext: string) of object; 10 TWindowMode = (wmNone, wmModal, wmPersistent, wmSubmodal); 11 TShowNewContent = procedure (NewMode: TWindowMode; HelpContext: string) of object; 11 12 12 13 { TBufferedDrawDlg } 13 14 14 15 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; 15 24 public 16 25 UserLeft: Integer; 17 26 UserTop: Integer; 27 UsedOffscreenWidth: Integer; 28 UsedOffscreenHeight: Integer; 29 Offscreen: TDpiBitmap; 30 OffscreenUser: TDpiForm; 18 31 constructor Create(AOwner: TComponent); override; 19 32 destructor Destroy; override; … … 22 35 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 23 36 procedure FormDeactivate(Sender: TObject); 24 procedure SmartUpdateContent(ImmUpdate: Boolean = false);37 procedure SmartUpdateContent(ImmUpdate: Boolean = False); 25 38 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; 40 40 end; 41 41 42 42 TFramedDlg = class(TBufferedDrawDlg) 43 public44 constructor Create(AOwner: TComponent); override;45 procedure FormCreate(Sender: TObject);46 procedure SmartInvalidate; override;47 43 protected 48 44 CaptionLeft: Integer; 49 45 CaptionRight: Integer; 50 46 InnerWidth: Integer; 51 InnerHeight: integer;47 InnerHeight: Integer; 52 48 WideBottom: Boolean; 53 49 FullCaption: Boolean; … … 57 53 procedure VPaint; override; 58 54 procedure FillOffscreen(Left, Top, Width, Height: Integer); 55 public 56 constructor Create(AOwner: TComponent); override; 57 procedure FormCreate(Sender: TObject); 58 procedure SmartInvalidate; override; 59 59 end; 60 60 … … 64 64 65 65 const 66 // window modes67 wmNone = 0;68 wmModal = $1;69 wmPersistent = $2;70 wmSubmodal = $3;71 72 66 yUnused = 161; 73 67 NarrowFrame = 11; … … 76 70 77 71 procedure CreateOffscreen(var Offscreen: TDpiBitmap); 72 function WindowModeMakePersistent(Mode: TWindowMode): TWindowMode; 78 73 procedure Register; 79 74 … … 83 78 uses 84 79 ButtonBase, Area; 80 81 function WindowModeMakePersistent(Mode: TWindowMode): TWindowMode; 82 begin 83 if Mode = wmModal then Result := wmSubmodal 84 else Result := wmPersistent; 85 end; 85 86 86 87 procedure Register; … … 118 119 UserTop := Top; 119 120 end; 120 if OffscreenUser = self then121 if OffscreenUser = Self then 121 122 OffscreenUser := nil; 122 123 end; … … 124 125 procedure TBufferedDrawDlg.FormPaint(Sender: TObject); 125 126 begin 126 if OffscreenUser <> self then127 if OffscreenUser <> Self then 127 128 OffscreenPaint; 128 129 VPaint; … … 142 143 if Key = VK_F1 then begin 143 144 if Assigned(ShowNewContentProc) then 144 ShowNewContentProc( FWindowMode or wmPersistent, HelpContext);145 ShowNewContentProc(WindowModeMakePersistent(FWindowMode), HelpContext); 145 146 end else 146 147 if FWindowMode = wmPersistent then begin … … 165 166 procedure TBufferedDrawDlg.VPaint; 166 167 begin 167 DpiBit Canvas(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); 169 end; 170 171 procedure TBufferedDrawDlg.ShowNewContent(NewMode: TWindowMode; 171 172 ForceClose: Boolean); 172 173 begin … … 178 179 UserLeft := Left; 179 180 UserTop := Top; 180 Visible := false;181 Visible := False; 181 182 FWindowMode := NewMode; 182 183 ShowModal; … … 184 185 else if forceclose then 185 186 begin // make modal 186 Visible := false;187 Visible := False; 187 188 FWindowMode := NewMode; 188 189 Left := UserLeft; … … 204 205 Left := UserLeft; 205 206 Top := UserTop; 206 if FWindowMode = wmModal then 207 ShowModal 207 if FWindowMode = wmModal then begin 208 Gtk2Fix; 209 ShowModal; 210 end 208 211 else 209 212 Show; … … 268 271 procedure TFramedDlg.SmartInvalidate; 269 272 var 270 i, BottomFrame: integer;273 I, BottomFrame: Integer; 271 274 r0, r1: HRgn; 272 275 begin … … 277 280 r0 := DpiCreateRectRgn(SideFrame, TitleHeight, ClientWidth - SideFrame, 278 281 ClientHeight - BottomFrame); 279 for i:= 0 to ControlCount - 1 do280 if not(Controls[ i] is TArea) and Controls[i].Visible then282 for I := 0 to ControlCount - 1 do 283 if not(Controls[I] is TArea) and Controls[I].Visible then 281 284 begin 282 with Controls[ i].BoundsRect do285 with Controls[I].BoundsRect do 283 286 r1 := DpiCreateRectRgn(Left, Top, Right, Bottom); 284 287 CombineRgn(r0, r0, r1, RGN_DIFF); … … 291 294 procedure TFramedDlg.VPaint; 292 295 293 procedure CornerFrame(x0, y0, x1, y1: integer);296 procedure CornerFrame(x0, y0, x1, y1: Integer); 294 297 begin 295 298 Frame(Canvas, x0 + 1, y0 + 1, x1 - 2, y1 - 2, MainTexture.ColorBevelLight, … … 304 307 305 308 var 306 i, l, FrameTop, FrameBottom, InnerBottom, Cut, xTexOffset,307 yTexOffset: integer;309 I, L, FrameTop, FrameBottom, InnerBottom, Cut, xTexOffset, 310 yTexOffset: Integer; 308 311 R: TRect; 309 312 begin … … 317 320 end; 318 321 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; 321 324 xTexOffset := (Maintexture.Width - ClientWidth) div 2; 322 325 yTexOffset := (Maintexture.Height - ClientHeight) div 2; … … 442 445 RisedTextOut(Canvas, Cut - 1, 7, Caption); 443 446 444 for i:= 0 to ControlCount - 1 do445 if Controls[ i].Visible and (Controls[i] is TButtonBase) then447 for I := 0 to ControlCount - 1 do 448 if Controls[I].Visible and (Controls[I] is TButtonBase) then 446 449 begin 447 R := Controls[ i].BoundsRect;450 R := Controls[I].BoundsRect; 448 451 if (R.Bottom <= TitleHeight) or (R.Top >= InnerBottom) then 449 452 BtnFrame(Canvas, R, MainTexture); 450 453 end; 451 454 452 DpiBit Canvas(Canvas, SideFrame, TitleHeight, ClientWidth - 2 * SideFrame,455 DpiBitBltCanvas(Canvas, SideFrame, TitleHeight, ClientWidth - 2 * SideFrame, 453 456 InnerBottom - TitleHeight, Offscreen.Canvas, 0, 0); 454 457 end; … … 459 462 begin 460 463 if FullCaption then 461 exit;464 Exit; 462 465 r0 := DpiCreateRectRgn(0, 0, ClientWidth, ClientHeight); 463 466 r1 := DpiCreateRectRgn(0, 0, CaptionLeft, TitleHeight - NarrowFrame); … … 509 512 MainFormKeyDown := nil; 510 513 511 finalization512 513 514 end.
Note:
See TracChangeset
for help on using the changeset viewer.