Changeset 67 for branches/Independent


Ignore:
Timestamp:
Nov 2, 2024, 10:04:51 PM (3 weeks ago)
Author:
chronos
Message:
  • Modified: Apps split into separate units.
  • Modified: SystemApi moved into separate unit.
Location:
branches/Independent
Files:
6 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/Independent/Forms/FormScreen.pas

    r66 r67  
    3131var
    3232  I: Integer;
     33const
     34  TitleHeight = 40;
    3335begin
    3436  PaintBox1.Canvas.Brush.Color := clBlack;
     
    4547      PaintBox1.Canvas.Rectangle(Rect);
    4648      PaintBox1.Canvas.TextOut(Rect.Left + 20, Rect.Top + 5, Name);
     49      PaintBox1.Canvas.Line(Rect.Left, Rect.Top + TitleHeight, Rect.Right, Rect.Top + TitleHeight);
    4750    end;
    4851  end;
  • branches/Independent/Independent.lpi

    r66 r67  
    2424          <SearchPaths>
    2525            <IncludeFiles Value="$(ProjOutDir)"/>
    26             <OtherUnitFiles Value="Forms"/>
     26            <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test"/>
    2727            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    2828          </SearchPaths>
     
    8585      </Unit>
    8686      <Unit>
    87         <Filename Value="Apps.pas"/>
     87        <Filename Value="Apps/Test/AppTest.pas"/>
    8888        <IsPartOfProject Value="True"/>
    8989      </Unit>
     
    104104        <IsPartOfProject Value="True"/>
    105105        <ComponentName Value="FormConsole"/>
     106        <HasResources Value="True"/>
    106107        <ResourceBaseClass Value="Form"/>
    107108      </Unit>
     
    110111        <IsPartOfProject Value="True"/>
    111112        <ComponentName Value="FormScreen"/>
     113        <HasResources Value="True"/>
    112114        <ResourceBaseClass Value="Form"/>
     115      </Unit>
     116      <Unit>
     117        <Filename Value="Apps/Code/AppCode.pas"/>
     118        <IsPartOfProject Value="True"/>
     119      </Unit>
     120      <Unit>
     121        <Filename Value="SystemApi.pas"/>
     122        <IsPartOfProject Value="True"/>
    113123      </Unit>
    114124    </Units>
     
    121131    <SearchPaths>
    122132      <IncludeFiles Value="$(ProjOutDir)"/>
    123       <OtherUnitFiles Value="Forms"/>
     133      <OtherUnitFiles Value="Forms;Apps/Code;Apps/Test"/>
    124134      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    125135    </SearchPaths>
  • branches/Independent/Independent.lpr

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

    r66 r67  
    2222  TRunningApp = class
    2323  private
    24     AppThread: TAppThread;
    2524    FApp: TApp;
    2625    procedure SetApp(AValue: TApp);
    2726  public
    2827    Context: TAppContext;
     28    AppThread: TAppThread;
    2929    procedure Run;
    3030    constructor Create;
     
    3737  TRunningApps = class(TObjectList<TRunningApp>)
    3838    function AddNew(App: TApp; System: TSystem): TRunningApp;
    39   end;
    40 
    41   { TSystemApi }
    42 
    43   TSystemApi = class(TApi)
    44   private
    45     FName: string;
    46     FText: string;
    47     procedure WriteLineSync;
    48     procedure RunAppSync;
    49   public
    50     App: TRunningApp;
    51     System: TSystem;
    52     procedure WriteLine(Text: string); override;
    53     procedure RunApp(Name: string); override;
    54     procedure Sleep(Time: TDateTime); override;
    55     function CreateWindow: THandle; override;
    56     procedure SetWindowName(Handle: THandle; Name: string); override;
    57     procedure SetWindowRect(Handle: THandle; Rect: TRect); override;
    58     procedure SetWindowVisible(Handle: THandle; Visible: Boolean); override;
    5939  end;
    6040
     
    8060  private
    8161    FOnDraw: TNotifyEvent;
    82     procedure Redraw;
    8362  public
    8463    Console: TConsole;
     
    8867    Windows: TWindows;
    8968    Handles: THandles;
     69    procedure Redraw;
    9070    procedure RunApp(Name: string);
    9171    procedure Start;
     
    9575  end;
    9676
     77
    9778implementation
    9879
    9980uses
    100   Apps;
     81  AppCode, AppTest, SystemApi;
    10182
    10283{ TAppThread }
     
    151132end;
    152133
    153 { TSystemApi }
    154 
    155 procedure TSystemApi.WriteLineSync;
    156 begin
    157   System.Console.Write(App.App.Name + ': ' + FText);
    158 end;
    159 
    160 procedure TSystemApi.RunAppSync;
    161 begin
    162   System.RunApp(FName);
    163 end;
    164 
    165 procedure TSystemApi.WriteLine(Text: string);
    166 begin
    167   FText := Text;
    168   App.AppThread.Synchronize(WriteLineSync);
    169 end;
    170 
    171 procedure TSystemApi.RunApp(Name: string);
    172 begin
    173   FName := Name;
    174   App.AppThread.Synchronize(RunAppSync);
    175 end;
    176 
    177 procedure TSystemApi.Sleep(Time: TDateTime);
    178 begin
    179   App.AppThread.Sleep(Round(Time / OneMillisecond));
    180 end;
    181 
    182 function TSystemApi.CreateWindow: THandle;
    183 var
    184   Window: TWindow;
    185 begin
    186   Window := System.Windows.AddNew;
    187   Window.Handle := System.Handles.AddNew;
    188   Result := Window.Handle;
    189 end;
    190 
    191 procedure TSystemApi.SetWindowName(Handle: THandle; Name: string);
    192 var
    193   Window: TWindow;
    194 begin
    195   Window := System.Windows.SearchByHandle(Handle);
    196   if Assigned(Window) then begin
    197     Window.Name := Name;
    198     System.Redraw;
    199   end;
    200 end;
    201 
    202 procedure TSystemApi.SetWindowRect(Handle: THandle; Rect: TRect);
    203 var
    204   Window: TWindow;
    205 begin
    206   Window := System.Windows.SearchByHandle(Handle);
    207   if Assigned(Window) then begin
    208     Window.Rect := Rect;
    209     System.Redraw;
    210   end;
    211 end;
    212 
    213 procedure TSystemApi.SetWindowVisible(Handle: THandle; Visible: Boolean);
    214 var
    215   Window: TWindow;
    216 begin
    217   Window := System.Windows.SearchByHandle(Handle);
    218   if Assigned(Window) then begin
    219     Window.Visible := Visible;
    220     System.Redraw;
    221   end;
    222 end;
    223 
    224134{ TWindows }
    225135
Note: See TracChangeset for help on using the changeset viewer.