Changeset 463 for branches/highdpi/Packages/CevoComponents/DrawDlg.pas
- Timestamp:
- Nov 29, 2023, 2:35:44 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/DrawDlg.pas
r413 r463 1 1 unit DrawDlg; 2 2 3 {$mode delphi}{$H+}4 5 3 interface 6 4 7 5 uses 8 UDpiControls, Classes, SysUtils, Forms, LCLIntf, LCLType, {$IFDEF LINUX}LMessages,{$ENDIF}6 UDpiControls, Classes, SysUtils, Forms, LCLIntf, LCLType, {$IFDEF UNIX}LMessages,{$ENDIF} 9 7 Messages, Graphics, Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools 10 8 {$IFDEF LCLGTK2}, Gtk2Globals{$ENDIF}; … … 48 46 Lines: Integer; 49 47 TopSpace: Integer; 50 procedure SplitText( preview: boolean);48 procedure SplitText(Preview: Boolean); 51 49 procedure CorrectHeight; 52 50 end; … … 76 74 MoveActive := False; 77 75 AddHandlerOnVisibleChanged(VisibleChangedHandler); 78 {$IFDEF LINUX}76 {$IFDEF UNIX} 79 77 OnDeactivate := DoDeactivate; 80 78 {$ENDIF} … … 102 100 else 103 101 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))); 106 104 if Pos.Y >= Top + TitleHeight then 107 105 Msg.Result := HTCLIENT … … 131 129 MousePos1: TPoint; 132 130 MousePos2: TPoint; 133 {$IFDEF LINUX}131 {$IFDEF UNIX} 134 132 MousePosNew: TPoint; 135 133 NewFormPos: TPoint; 136 134 {$ENDIF} 137 135 begin 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} 142 140 // Only if client is not doing own mouse move handling 143 141 if not Assigned(OnMouseDown) or not Assigned(OnMouseMove) or not Assigned(OnMouseUp) then begin 144 142 // HitTest is not supported under Linux GTK2 so use form inside move mechanizm 145 NewFormPos := ScreenToClient( DpiMouse.CursorPos);143 NewFormPos := ScreenToClient(Mouse.CursorPos); 146 144 if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and 147 145 (NewFormPos.Y >= 0) and (NewFormPos.Y < Height) and … … 149 147 MoveMousePos := ClientToScreen(Point(X, Y)); 150 148 MoveFormPos := Point(Left, Top); 151 MousePosNew := DpiMouse.CursorPos;149 MousePosNew := Mouse.CursorPos; 152 150 // Activate move only if mouse position was not changed during inherited call 153 151 if (MousePos1.X = MousePos2.X) and (MousePos1.Y = MousePos2.Y) then begin … … 197 195 {$IFDEF LCLGTK2} 198 196 // 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; 200 198 {$ENDIF} 201 199 end; … … 208 206 procedure TDrawDlg.InitButtons; 209 207 var 210 cix: integer;208 cix: Integer; 211 209 // ButtonDownSound, ButtonUpSound: string; 212 210 begin … … 230 228 procedure TDrawDlg.SmartInvalidate; 231 229 var 232 i: integer;230 i: Integer; 233 231 r0, r1: HRgn; 234 232 begin … … 242 240 DeleteObject(r1); 243 241 end; 244 InvalidateRgn(Handle, r0, false);242 InvalidateRgn(Handle, r0, False); 245 243 DeleteObject(r0); 246 244 end; … … 250 248 procedure TBaseMessgDlg.FormCreate(Sender: TObject); 251 249 begin 252 Left := ( DpiScreen.Width - Width) div 2;250 Left := (Screen.Width - Width) div 2; 253 251 Canvas.Font.Assign(UniFont[ftNormal]); 254 252 Canvas.Brush.Style := bsClear; 255 253 MessgText := ''; 256 254 TopSpace := 0; 257 TitleHeight := DpiScreen.Height;255 TitleHeight := Screen.Height; 258 256 if csDesigning in ComponentState then Exit; 259 257 InitButtons; … … 262 260 procedure TBaseMessgDlg.FormPaint(Sender: TObject); 263 261 var 264 i, cix: integer;262 i, cix: Integer; 265 263 begin 266 264 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), 268 266 ClientHeight - (6 + 2 * Border)); 269 267 for i := 0 to Border do … … 276 274 ClientHeight - (3 + Border), MainTexture.ColorBevelLight, 277 275 MainTexture.ColorBevelShade); 278 SplitText( false);276 SplitText(False); 279 277 280 278 for cix := 0 to ControlCount - 1 do … … 283 281 end; 284 282 285 procedure TBaseMessgDlg.SplitText( preview: boolean);286 var 287 Start, Stop, OrdinaryStop, LinesCount: integer;283 procedure TBaseMessgDlg.SplitText(Preview: Boolean); 284 var 285 Start, Stop, OrdinaryStop, LinesCount: Integer; 288 286 s: string; 289 287 begin … … 296 294 (BiColorTextWidth(Canvas, Copy(MessgText, Start, Stop - Start + 1)) < 297 295 ClientWidth - 56) do 298 inc(Stop);296 Inc(Stop); 299 297 if Stop <> Length(MessgText) then 300 298 begin … … 305 303 (MessgText[OrdinaryStop + 1] = '\'); 306 304 if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then 307 Stop := OrdinaryStop 308 end; 309 if not preview then305 Stop := OrdinaryStop; 306 end; 307 if not Preview then 310 308 begin 311 309 s := Copy(MessgText, Start, Stop - Start + 1); … … 315 313 end; 316 314 Start := Stop + 2; 317 inc(LinesCount) 318 end; 319 if preview then315 inc(LinesCount); 316 end; 317 if Preview then 320 318 Lines := LinesCount; 321 319 end; … … 323 321 procedure TBaseMessgDlg.CorrectHeight; 324 322 var 325 i: integer;323 i: Integer; 326 324 begin 327 325 ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing; 328 Top := ( DpiScreen.Height - ClientHeight) div 2;326 Top := (Screen.Height - ClientHeight) div 2; 329 327 for i := 0 to ControlCount - 1 do 330 328 Controls[i].Top := ClientHeight - (34 + Border); … … 333 331 end. 334 332 333 334
Note:
See TracChangeset
for help on using the changeset viewer.