Changeset 68 for branches


Ignore:
Timestamp:
Dec 17, 2024, 11:10:31 PM (9 days ago)
Author:
chronos
Message:
  • Added: Mouse API support.
Location:
branches/Independent
Files:
4 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Independent/Api.pas

    r66 r68  
    2626    procedure SetWindowRect(Handle: THandle; Rect: TRect); virtual; abstract;
    2727    procedure SetWindowVisible(Handle: THandle; Visible: Boolean); virtual; abstract;
     28    function GetMousePosition: TPoint; virtual; abstract;
    2829  end;
    2930
     
    3637  TApp = class
    3738    Name: string;
     39    Terminated: Boolean;
    3840    procedure Run(Context: TAppContext); virtual; abstract;
    3941    constructor Create; virtual;
     
    8587end;
    8688
    87 
    8889end.
    8990
  • branches/Independent/Apps/Test/AppTest.pas

    r67 r68  
    2323var
    2424  Handle: THandle;
     25  Pos: TPoint;
    2526begin
    2627  with Context.Api do begin
     
    3738    SetWindowRect(Handle, Bounds(350, 150, 500, 300));
    3839    SetWindowVisible(Handle, True);
     40
     41    repeat
     42      Pos := GetMousePosition;
     43      SetWindowName(Handle, IntToStr(Pos.X) + ', ' + IntToStr(Pos.Y));
     44      Sleep(100 * OneMillisecond);
     45    until Terminated;
    3946  end;
    4047end;
  • branches/Independent/Forms/FormMain.lfm

    r66 r68  
    11object FormName: TFormName
    22  Left = 465
    3   Height = 535
     3  Height = 569
    44  Top = 352
    55  Width = 971
  • branches/Independent/Forms/FormMain.pas

    r66 r68  
    3434    procedure ConsoleWrite(Text: string);
    3535    function LoadFile(Name: string): string;
     36    function GetMousePosition: TPoint;
    3637  public
    3738    FormConsole: TFormConsole;
     
    5859  System.Console.OnWrite := ConsoleWrite;
    5960  System.FileSystem.OnLoadFile := LoadFile;
     61  System.Mouse.OnGetPosition := GetMousePosition;
    6062  System.OnDraw := FormScreen.Redraw;
    6163  FormScreen.System := System;
     
    115117end;
    116118
     119function TFormName.GetMousePosition: TPoint;
     120begin
     121  Result := Mouse.CursorPos;
     122end;
     123
    117124end.
    118125
  • branches/Independent/Independent.lpi

    r67 r68  
    2424          <SearchPaths>
    2525            <IncludeFiles Value="$(ProjOutDir)"/>
    26             <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test"/>
     26            <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test;Devices"/>
    2727            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    2828          </SearchPaths>
     
    9393      </Unit>
    9494      <Unit>
    95         <Filename Value="Console.pas"/>
     95        <Filename Value="Devices/Console.pas"/>
    9696        <IsPartOfProject Value="True"/>
    9797      </Unit>
    9898      <Unit>
    99         <Filename Value="FileSystem.pas"/>
     99        <Filename Value="Devices/FileSystem.pas"/>
    100100        <IsPartOfProject Value="True"/>
    101101      </Unit>
     
    122122        <IsPartOfProject Value="True"/>
    123123      </Unit>
     124      <Unit>
     125        <Filename Value="Devices/Mouse.pas"/>
     126        <IsPartOfProject Value="True"/>
     127      </Unit>
    124128    </Units>
    125129  </ProjectOptions>
     
    131135    <SearchPaths>
    132136      <IncludeFiles Value="$(ProjOutDir)"/>
    133       <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test"/>
     137      <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test;Devices"/>
    134138      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    135139    </SearchPaths>
  • branches/Independent/Independent.lpr

    r67 r68  
    99  {$ENDIF}
    1010  Interfaces, // this includes the LCL widgetset
    11   Forms, FormMain, FormScreen, SysUtils, AppCode, SystemApi
     11  Forms, FormMain, FormScreen, SysUtils, AppCode, SystemApi, Mouse
    1212  { you can add units after this };
    1313
  • branches/Independent/Os.pas

    r67 r68  
    44
    55uses
    6   Classes, SysUtils, Generics.Collections, DateUtils, Api, Console, FileSystem;
     6  Classes, SysUtils, Generics.Collections, DateUtils, Api, Console, FileSystem,
     7  Mouse;
    78
    89type
     
    6364    Console: TConsole;
    6465    FileSystem: TFileSystem;
     66    Mouse: TMouse;
    6567    Apps: TApps;
    6668    RunningApps: TRunningApps;
     
    187189  Windows := TWindows.Create;
    188190  Console := TConsole.Create;
     191  Mouse := TMouse.Create;
    189192  FileSystem := TFileSystem.Create;
    190193  RunningApps := TRunningApps.Create;
     
    197200  FreeAndNil(RunningApps);
    198201  FreeAndNil(Console);
     202  FreeAndNil(Mouse);
    199203  FreeAndNil(FileSystem);
    200204  FreeAndNil(Windows);
  • branches/Independent/SystemApi.pas

    r67 r68  
    2525    procedure SetWindowRect(Handle: THandle; Rect: TRect); override;
    2626    procedure SetWindowVisible(Handle: THandle; Visible: Boolean); override;
     27    function GetMousePosition: TPoint; override;
    2728  end;
    2829
     
    101102end;
    102103
     104function TSystemApi.GetMousePosition: TPoint;
     105begin
     106  Result := System.Mouse.GetPosition;
     107end;
     108
    103109end.
    104110
Note: See TracChangeset for help on using the changeset viewer.