Changeset 5


Ignore:
Timestamp:
Jun 2, 2013, 2:34:55 PM (11 years ago)
Author:
chronos
Message:
  • Added: Implemented sample desktop manager as simple application.
Location:
os/trunk
Files:
2 added
12 edited
6 moved

Legend:

Unmodified
Added
Removed
  • os/trunk

    • Property svn:ignore
      •  

        old new  
        11Win32
        22*.~dsk
         3__history
  • os/trunk/Applications/TestApplication.pas

    r3 r5  
    2020
    2121uses
    22   Xvcl.Kernel;
     22  LDOS.Kernel;
    2323
    2424{ TTestApplication }
     
    3232procedure TTestApplication.Run;
    3333begin
     34  Caption := 'TestApp';
    3435  Form1 := TForm.Create;
    3536  Form1.Bounds := TRectangle.Create(50, 80, 200, 120);
  • os/trunk/Drivers/Driver.KeyboardVCL.pas

    r3 r5  
    44
    55uses
    6   Vcl.Forms, Vcl.Controls, System.Classes, UFormMain, Xvcl.Classes, Xvcl.Kernel;
     6  Vcl.Forms, Vcl.Controls, System.Classes, UFormMain, Xvcl.Classes, LDOS.Kernel;
    77
    88type
  • os/trunk/Drivers/Driver.MouseVCL.pas

    r3 r5  
    44
    55uses
    6   Vcl.Forms, Vcl.Controls, System.Classes, UFormMain, Xvcl.Classes, Xvcl.Kernel;
     6  Vcl.Forms, Vcl.Controls, System.Classes, UFormMain, Xvcl.Classes, LDOS.Kernel;
    77
    88type
  • os/trunk/Drivers/Driver.SystemVCL.pas

    r3 r5  
    44
    55uses
    6   Vcl.Forms, Xvcl.Kernel;
     6  Vcl.Forms, LDOS.Kernel;
    77
    88type
  • os/trunk/Drivers/Driver.VideoVCL.pas

    r3 r5  
    44
    55uses
    6   Vcl.Forms, Vcl.Graphics, System.Types, UFormMain, Xvcl.Classes, Xvcl.Kernel,
     6  Vcl.Forms, Vcl.Graphics, System.Types, UFormMain, Xvcl.Classes, LDOS.Kernel,
    77  Xvcl.Graphics, Generics.Collections;
    88
     
    3636  (Image1.Height <> Image1.Picture.Bitmap.Height) then begin
    3737    Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
    38     Kernel.Screen.VideoDevice.Size := TPoint.Create(Form.Width, Form.Height);
    39     Kernel.Screen.Size := TPoint.Create(Form.Width, Form.Height);
     38    Kernel.Screen.VideoDevice.Size := TPoint.Create(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height);
     39    Kernel.Screen.Size := TPoint.Create(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height);
     40    Kernel.Screen.HandleResize;
    4041    Kernel.Screen.Paint;
    4142  end;
     
    111112procedure TVideoDeviceVCL.TextOut(Position: TPoint; Text: string);
    112113begin
     114 // CanvasVCL.Font.Color := ColorToVCL(
    113115  CanvasVCL.Brush.Style := bsClear;
    114116  CanvasVCL.TextOut(Position.X, Position.Y, Text);
  • os/trunk/System

    • Property svn:ignore set to
      __history
  • os/trunk/System/LDOS.Kernel.pas

    r3 r5  
    1 unit Xvcl.Kernel;
     1unit LDOS.Kernel;
    22
    33interface
     
    1717    Priority: Integer;
    1818    State: TProcessState;
     19    TimerExpire: TDateTime;
     20    Application: TApplication;
    1921    procedure Execute; virtual;
     22    procedure Terminate; virtual;
     23  end;
     24
     25  TTimer = class
     26  end;
     27
     28  TScheduler = class
     29    Kernel: TKernel;
     30    procedure Reschedule;
     31    constructor Create;
     32    destructor Destroy; override;
    2033  end;
    2134
     
    3346
    3447  TScreen = class(TComponent)
     48  private
     49  public
     50    Kernel: TKernel;
    3551    Canvas: TScreenCanvas;
    3652    Size: TPoint;
    3753    Forms: TList<TForm>;
    3854    VideoDevice: TVideoDevice;
     55    procedure HandleResize;
    3956    procedure Paint;
    4057    procedure FocusForm(Form: TForm);
     
    5774  end;
    5875
    59   TScheduler = class
    60     Kernel: TKernel;
    61     procedure Reschedule;
    62   end;
    63 
    6476  TKernel = class
    6577  private
    6678    FOnAfterDriverInit: TNotifyEvent;
    6779    FOnTick: TNotifyEvent;
     80    procedure HandleTaskList;
    6881  public
     82    Timers: TList<TTimer>;
    6983    Processes: TList<TProcess>;
    7084    Drivers: TList<TDriver>;
     
    7892    procedure PowerOff;
    7993    procedure Reboot;
     94    function GetProcessId: Integer;
     95    procedure RunApplication(App: TApplication);
    8096    constructor Create;
    8197    destructor Destroy; override;
     
    99115
    100116  for App in StartOnBoot do
    101     App.Run;
     117    RunApplication(App);
    102118
    103119  repeat
     
    113129begin
    114130  Processes := TList<TProcess>.Create;
     131  Timers := TList<TTimer>.Create;
    115132  Drivers := TList<TDriver>.Create;
    116133  Screen := TScreen.Create;
     134  Screen.Kernel := Self;
    117135  StartOnBoot := TList<TApplication>.Create;
    118136  Scheduler := TScheduler.Create;
     137  Scheduler.Kernel := Self;
    119138  Keyboard := TKeyboard.Create;
    120139  Keyboard.Kernel := Self;
     
    132151  Drivers.Destroy;
    133152  Processes.Destroy;
    134   inherited;
    135 end;
    136 
     153  Timers.Destroy;
     154  inherited;
     155end;
     156
     157
     158function TKernel.GetProcessId: Integer;
     159var
     160  I: Integer;
     161begin
     162  Result := 1;
     163  for I := 0 to Processes.Count - 1 do
     164    if Processes[I].Id > Result then Result := Processes[I].Id + 1;
     165end;
    137166
    138167procedure TKernel.PowerOff;
     
    144173begin
    145174
     175end;
     176
     177procedure TKernel.RunApplication(App: TApplication);
     178var
     179  NewProcess: TProcess;
     180  I: Integer;
     181begin
     182  NewProcess := TProcess.Create;
     183  NewProcess.Application := App;
     184  NewProcess.Id := GetProcessId;
     185  Processes.Add(NewProcess);
     186  App.Run;
     187  NewProcess.Name := App.Caption;
     188  HandleTaskList;
     189end;
     190
     191procedure TKernel.HandleTaskList;
     192var
     193  Form: TForm;
     194  NewMessage: TMessageTaskList;
     195  Process: TProcess;
     196begin
     197  NewMessage := TMessageTaskList.Create;
     198  try
     199    for Form in Screen.Forms do
     200      Form.HandleMessage(NewMessage);
     201    for Process in Processes do
     202      Process.Application.HandleMessage(NewMessage);
     203  finally
     204    NewMessage.Destroy;
     205  end;
    146206end;
    147207
     
    176236end;
    177237
     238procedure TScreen.HandleResize;
     239var
     240  Form: TForm;
     241  NewMessage: TMessageResize;
     242  Process: TProcess;
     243begin
     244  NewMessage := TMessageResize.Create;
     245  try
     246    for Form in Kernel.Screen.Forms do
     247      Form.HandleMessage(NewMessage);
     248    for Process in Kernel.Processes do
     249      Process.Application.HandleMessage(NewMessage);
     250  finally
     251    NewMessage.Destroy;
     252  end;
     253end;
     254
    178255procedure TScreen.Paint;
    179256var
     
    199276{ TScheduler }
    200277
     278constructor TScheduler.Create;
     279begin
     280  inherited;
     281end;
     282
     283destructor TScheduler.Destroy;
     284begin
     285
     286  inherited;
     287end;
     288
    201289procedure TScheduler.Reschedule;
    202290begin
     
    218306
    219307procedure TProcess.Execute;
     308begin
     309
     310end;
     311
     312procedure TProcess.Terminate;
    220313begin
    221314
  • os/trunk/UFormMain.dfm

    r3 r5  
    1212  Font.Style = []
    1313  OldCreateOrder = False
    14   WindowState = wsMaximized
    1514  PixelsPerInch = 96
    1615  TextHeight = 13
  • os/trunk/Xvcl

    • Property svn:ignore set to
      __history
  • os/trunk/Xvcl/Xvcl.Controls.pas

    r3 r5  
    2424  TMessageMouseUp = class(TMessageMouse);
    2525  TMessageMouseMove = class(TMessageMouse);
     26  TMessageResize = class(TMessage);
     27  TMessageTaskList = class(TMessage);
    2628
    2729  TKeyState = (ksShift, ksAlt, ksOS);
     
    186188  if FColor <> Value then begin
    187189    FColor := Value;
    188     Paint;
     190    if Visible then Paint;
    189191  end;
    190192end;
     
    225227  if FCaption <> Value then begin
    226228    FCaption := Value;
    227     Paint;
     229    if Visible then Paint;
    228230  end;
    229231end;
  • os/trunk/Xvcl/Xvcl.Forms.pas

    r3 r5  
    77
    88type
     9  TBorderStyle = (bsNormal, bsNone);
     10
    911  TForm = class(TWinControl)
    1012  private
    1113    FFocused: Boolean;
     14    FBorderStyle: TBorderStyle;
    1215    procedure SetFocused(const Value: Boolean);
     16    procedure SetBorderStyle(const Value: TBorderStyle);
    1317  protected
    1418    function GetVideoDevice: TVideoDevice; override;
     
    2226    procedure Paint; override;
    2327    property Focused: Boolean read FFocused write SetFocused;
     28    property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle;
     29  end;
     30
     31  TPanel = class(TWinControl)
     32    Caption: string;
     33    procedure Paint; override;
    2434  end;
    2535
    2636  TApplication = class(TComponent)
     37  protected
     38  public
     39    Caption: string;
    2740    Screen: TObject; // TScreen;
    2841    Forms: TList<TForm>;
    2942    MainForm: TForm;
     43    function HandleMessage(Message: TMessage): Boolean; virtual;
    3044    procedure Run; virtual;
    3145    procedure Terminate; virtual;
     
    3650
    3751uses
    38   Xvcl.Kernel;
     52  LDOS.Kernel;
    3953
    4054{ TApplication }
     55
     56function TApplication.HandleMessage(Message: TMessage): Boolean;
     57begin
     58
     59end;
    4160
    4261procedure TApplication.Run;
     
    6786    TitleBarBounds := TRectangle.Create(0, 0, Bounds.Width, TitleBarHeight);
    6887    Focused := True;
    69     if TitleBarBounds.Contains(ScreenToClient(Position)) then begin
     88    if (BorderStyle = bsNormal) and TitleBarBounds.Contains(ScreenToClient(Position)) then begin
    7089      Move.StartControlPos := Bounds.TopLeft;
    7190      Move.StartMousePos := Position;
     
    92111  inherited;
    93112  with Canvas do begin
    94     if Focused then Brush.Color := clLightBlue else
    95       Brush.Color := clSilver;
    96     FillRect(TRectangle.Create(0, 0, Bounds.Width - 1, TitleBarHeight));
    97     MoveTo(TPoint.Create(0, 0));
    98     LineTo(TPoint.Create(Bounds.Width - 1, 0));
    99     LineTo(TPoint.Create(Bounds.Width - 1, Bounds.Height - 1));
    100     LineTo(TPoint.Create(0, Bounds.Height - 1));
    101     LineTo(TPoint.Create(0, 0));
    102     MoveTo(TPoint.Create(0, TitleBarHeight));
    103     LineTo(TPoint.Create(Bounds.Width - 1, TitleBarHeight));
    104     TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2,
    105       (TitleBarHeight - GetTextSize(Caption).Y) div 2), Caption);
     113    if BorderStyle = bsNormal then begin
     114      if Focused then Brush.Color := clLightBlue else
     115        Brush.Color := clSilver;
     116      FillRect(TRectangle.Create(0, 0, Bounds.Width - 1, TitleBarHeight));
     117      MoveTo(TPoint.Create(0, 0));
     118      LineTo(TPoint.Create(Bounds.Width - 1, 0));
     119      LineTo(TPoint.Create(Bounds.Width - 1, Bounds.Height - 1));
     120      LineTo(TPoint.Create(0, Bounds.Height - 1));
     121      LineTo(TPoint.Create(0, 0));
     122      MoveTo(TPoint.Create(0, TitleBarHeight));
     123      LineTo(TPoint.Create(Bounds.Width - 1, TitleBarHeight));
     124      TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2,
     125        (TitleBarHeight - GetTextSize(Caption).Y) div 2), Caption);
     126    end;
    106127  end;
     128end;
     129
     130procedure TForm.SetBorderStyle(const Value: TBorderStyle);
     131begin
     132  FBorderStyle := Value;
    107133end;
    108134
     
    115141end;
    116142
     143{ TPanel }
     144
     145procedure TPanel.Paint;
     146begin
     147  inherited;
     148  with Canvas do begin
     149    MoveTo(TPoint.Create(0, 0));
     150    LineTo(TPoint.Create(Bounds.Width - 1, 0));
     151    LineTo(TPoint.Create(Bounds.Width - 1, Bounds.Height - 1));
     152    LineTo(TPoint.Create(0, Bounds.Height - 1));
     153    LineTo(TPoint.Create(0, 0));
     154    TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2,
     155      (Bounds.Height - GetTextSize(Caption).Y) div 2), Caption);
     156  end;
     157end;
     158
    117159end.
  • os/trunk/lddesktop.dpr

    r3 r5  
    44  Vcl.Forms,
    55  UFormMain in 'UFormMain.pas' {Form1},
    6   Xvcl.Controls in 'Xvcl.Controls.pas',
    7   TestApplication in 'Applications\TestApplication.pas',
    8   Xvcl.Classes in 'Xvcl.Classes.pas',
    9   Xvcl.Graphics in 'Xvcl.Graphics.pas',
    10   Xvcl.Forms in 'Xvcl.Forms.pas',
    11   Xvcl.Kernel in 'Xvcl.Kernel.pas',
    126  Driver.VideoVCL in 'Drivers\Driver.VideoVCL.pas',
    137  Driver.SystemVCL in 'Drivers\Driver.SystemVCL.pas',
    148  Driver.KeyboardVCL in 'Drivers\Driver.KeyboardVCL.pas',
    159  Driver.MouseVCL in 'Drivers\Driver.MouseVCL.pas',
    16   Xvcl.Generics in 'Xvcl.Generics.pas';
     10  Xvcl.Classes in 'Xvcl\Xvcl.Classes.pas',
     11  Xvcl.Controls in 'Xvcl\Xvcl.Controls.pas',
     12  Xvcl.Forms in 'Xvcl\Xvcl.Forms.pas',
     13  Xvcl.Generics in 'Xvcl\Xvcl.Generics.pas',
     14  Xvcl.Graphics in 'Xvcl\Xvcl.Graphics.pas',
     15  LDOS.Kernel in 'System\LDOS.Kernel.pas',
     16  LDOS.Task in 'System\LDOS.Task.pas',
     17  TestApplication in 'Applications\TestApplication.pas',
     18  UDesktop in 'Applications\UDesktop.pas';
    1719
    1820{$R *.res}
     
    2426  DriverKeyboard: TDriver;
    2527  DriverMouse: TDriver;
    26   TestApplication: TApplication;
     28  DesktopApp: TDesktopApp;
    2729begin
     30  ReportMemoryLeaksOnShutdown := DebugHook <> 0;
    2831  Kernel := TKernel.Create;
    2932  DriverSystem := TDriverSystemVCL.Create;
     
    3942  DriverMouse.Kernel := Kernel;
    4043  Kernel.Drivers.Add(DriverMouse);
    41   TestApplication := TTestApplication.Create;
    42   TestApplication.Screen := Kernel.Screen;
    43   Kernel.StartOnBoot.Add(TestApplication);
     44  DesktopApp := TDesktopApp.Create;
     45  DesktopApp.Screen := Kernel.Screen;
     46  Kernel.StartOnBoot.Add(DesktopApp);
    4447  Kernel.Boot;
    4548  Kernel.Destroy;
  • os/trunk/lddesktop.dproj

    r3 r5  
    8787            <FormType>dfm</FormType>
    8888        </DCCReference>
    89         <DCCReference Include="Xvcl.Controls.pas"/>
    90         <DCCReference Include="Applications\TestApplication.pas"/>
    91         <DCCReference Include="Xvcl.Classes.pas"/>
    92         <DCCReference Include="Xvcl.Graphics.pas"/>
    93         <DCCReference Include="Xvcl.Forms.pas"/>
    94         <DCCReference Include="Xvcl.Kernel.pas"/>
    9589        <DCCReference Include="Drivers\Driver.VideoVCL.pas"/>
    9690        <DCCReference Include="Drivers\Driver.SystemVCL.pas">
     
    9993        <DCCReference Include="Drivers\Driver.KeyboardVCL.pas"/>
    10094        <DCCReference Include="Drivers\Driver.MouseVCL.pas"/>
    101         <DCCReference Include="Xvcl.Generics.pas"/>
     95        <DCCReference Include="Xvcl\Xvcl.Classes.pas"/>
     96        <DCCReference Include="Xvcl\Xvcl.Controls.pas"/>
     97        <DCCReference Include="Xvcl\Xvcl.Forms.pas"/>
     98        <DCCReference Include="Xvcl\Xvcl.Generics.pas"/>
     99        <DCCReference Include="Xvcl\Xvcl.Graphics.pas"/>
     100        <DCCReference Include="System\LDOS.Kernel.pas"/>
     101        <DCCReference Include="System\LDOS.Task.pas"/>
     102        <DCCReference Include="Applications\TestApplication.pas"/>
     103        <DCCReference Include="Applications\UDesktop.pas"/>
    102104        <BuildConfiguration Include="Release">
    103105            <Key>Cfg_2</Key>
  • os/trunk/lddesktop.dproj.local

    r3 r5  
    22<BorlandProject>
    33        <Transactions>
    4     <Transaction>2013/05/05 12:48:11.000.546,C:\Users\george\Documents\RAD Studio\Projects\Unit1.dfm=C:\Projekty\LibreDevelop\Desktop\UFormMain.dfm</Transaction>
    5     <Transaction>2013/05/05 12:48:16.000.408,C:\Users\george\Documents\RAD Studio\Projects\Project1.dproj=C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj</Transaction>
    6     <Transaction>2013/05/05 14:41:42.000.034,C:\Projekty\LibreDevelop\Desktop\DesktopVCL.pas=C:\Projekty\LibreDevelop\Desktop\UDesktopVCL.pas</Transaction>
    7     <Transaction>2013/05/05 16:31:04.000.703,C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj=C:\Projekty\LibreDevelop\Desktop\Xvcl.Graphics.dproj</Transaction>
    8     <Transaction>2013/05/05 16:31:23.000.727,C:\Projekty\LibreDevelop\Desktop\Xvcl.Graphics.dproj=C:\Projekty\LibreDevelop\Desktop\lddektop.dproj</Transaction>
    9     <Transaction>2013/05/05 16:31:30.000.009,C:\Projekty\LibreDevelop\Desktop\UCommon.pas=C:\Projekty\LibreDevelop\Desktop\lddesktop.pas</Transaction>
    10     <Transaction>2013/05/05 16:32:07.000.379,C:\Projekty\LibreDevelop\Desktop\lddesktop.pas=C:\Projekty\LibreDevelop\Desktop\Xvcl.Controls.pas</Transaction>
    11     <Transaction>2013/05/05 17:10:43.000.905,C:\Projekty\LibreDevelop\Desktop\Xvcl.Desktop.pas=C:\Projekty\LibreDevelop\Desktop\Xvcl.Kernel.pas</Transaction>
    12     <Transaction>2013/05/05 17:28:07.000.437,C:\Projekty\LibreDevelop\Desktop\UDesktopVCL.pas=C:\Projekty\LibreDevelop\Desktop\Applications\TestApplication.pas</Transaction>
    13     <Transaction>2013/05/05 21:35:35.000.035,C:\Projekty\LibreDevelop\Desktop\lddektop.dproj=C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj</Transaction>
     4    <Transaction>2013/05/05 12:48:11.000.546,C:\Projekty\LibreDevelop\Desktop\UFormMain.dfm=C:\Users\george\Documents\RAD Studio\Projects\Unit1.dfm</Transaction>
     5    <Transaction>2013/05/05 12:48:16.000.408,C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj=C:\Users\george\Documents\RAD Studio\Projects\Project1.dproj</Transaction>
     6    <Transaction>2013/05/05 14:41:42.000.034,C:\Projekty\LibreDevelop\Desktop\UDesktopVCL.pas=C:\Projekty\LibreDevelop\Desktop\DesktopVCL.pas</Transaction>
     7    <Transaction>2013/05/05 16:31:04.000.703,C:\Projekty\LibreDevelop\Desktop\Xvcl.Graphics.dproj=C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj</Transaction>
     8    <Transaction>2013/05/05 16:31:23.000.727,C:\Projekty\LibreDevelop\Desktop\lddektop.dproj=C:\Projekty\LibreDevelop\Desktop\Xvcl.Graphics.dproj</Transaction>
     9    <Transaction>2013/05/05 16:31:30.000.009,C:\Projekty\LibreDevelop\Desktop\lddesktop.pas=C:\Projekty\LibreDevelop\Desktop\UCommon.pas</Transaction>
     10    <Transaction>2013/05/05 16:32:07.000.379,C:\Projekty\LibreDevelop\Desktop\Xvcl.Controls.pas=C:\Projekty\LibreDevelop\Desktop\lddesktop.pas</Transaction>
     11    <Transaction>2013/05/05 17:10:43.000.905,C:\Projekty\LibreDevelop\Desktop\Xvcl.Kernel.pas=C:\Projekty\LibreDevelop\Desktop\Xvcl.Desktop.pas</Transaction>
     12    <Transaction>2013/05/05 17:28:07.000.437,C:\Projekty\LibreDevelop\Desktop\Applications\TestApplication.pas=C:\Projekty\LibreDevelop\Desktop\UDesktopVCL.pas</Transaction>
     13    <Transaction>2013/05/05 21:35:35.000.035,C:\Projekty\LibreDevelop\Desktop\lddesktop.dproj=C:\Projekty\LibreDevelop\Desktop\lddektop.dproj</Transaction>
    1414  </Transactions>
    1515</BorlandProject>
Note: See TracChangeset for help on using the changeset viewer.