Changeset 7


Ignore:
Timestamp:
May 9, 2015, 12:00:33 AM (10 years ago)
Author:
chronos
Message:
  • Added: Action to switch to full screen mode.
  • Added: Video driver registration.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Apps/UClock.pas

    r6 r7  
    2424var
    2525  Message: TIPCMessage;
     26  WindowId: Integer;
    2627begin
    2728  Message := TIPCMessage.Create;
     29  WindowId := API.WindowCreate;
     30  API.WindowSetAttr(300, 200, True);
    2831  while not Task.Terminated do begin
    2932    API.WriteText('test');
     33    API.DrawText(Point(10, 10), 'Text');
     34    API.DrawLine(Point(20, 20), Point(100, 100));
    3035    API.Sleep(OneSecond);
    3136    //API.ReadMessage(Message);
  • trunk/ChronOS.lpi

    r6 r7  
    7171      </Item1>
    7272    </RequiredPackages>
    73     <Units Count="14">
     73    <Units Count="15">
    7474      <Unit0>
    7575        <Filename Value="ChronOS.lpr"/>
     
    8585      </Unit1>
    8686      <Unit2>
    87         <Filename Value="UKernel.pas"/>
     87        <Filename Value="System/UKernel.pas"/>
    8888        <IsPartOfProject Value="True"/>
    8989        <UnitName Value="UKernel"/>
     
    105105      </Unit5>
    106106      <Unit6>
    107         <Filename Value="UAPI.pas"/>
     107        <Filename Value="System/UAPI.pas"/>
    108108        <IsPartOfProject Value="True"/>
    109109        <UnitName Value="UAPI"/>
     
    120120      </Unit8>
    121121      <Unit9>
    122         <Filename Value="UApp.pas"/>
     122        <Filename Value="System/UApp.pas"/>
    123123        <IsPartOfProject Value="True"/>
    124124        <UnitName Value="UApp"/>
     
    138138        <IsPartOfProject Value="True"/>
    139139        <ComponentName Value="FormTerminal"/>
     140        <HasResources Value="True"/>
    140141        <ResourceBaseClass Value="Form"/>
    141142        <UnitName Value="UFormTerminal"/>
     
    146147        <UnitName Value="UClasses"/>
    147148      </Unit13>
     149      <Unit14>
     150        <Filename Value="System/UGraphics.pas"/>
     151        <IsPartOfProject Value="True"/>
     152        <UnitName Value="UGraphics"/>
     153      </Unit14>
    148154    </Units>
    149155  </ProjectOptions>
     
    155161    <SearchPaths>
    156162      <IncludeFiles Value="$(ProjOutDir)"/>
    157       <OtherUnitFiles Value="Apps;Platform/Base;Forms"/>
     163      <OtherUnitFiles Value="Apps;Platform/Base;Forms;System"/>
    158164      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    159165    </SearchPaths>
  • trunk/ChronOS.lpr

    r6 r7  
    1010  {$ENDIF}
    1111  Interfaces, // this includes the LCL widgetset
    12   Forms, SysUtils, UFormMain, UKernel, UFileSystem, UClock, UMemoryManager, UAPI,
    13   UPlatformBase, UList, UApp, UThreadEx, UMemory, UFormTerminal, UClasses;
     12  Forms, SysUtils, UFormMain, UKernel, UFileSystem, UClock, UMemoryManager,
     13  UAPI, UPlatformBase, UList, UApp, UThreadEx, UMemory, UFormTerminal, UClasses,
     14  UGraphics;
    1415
    1516{$R *.res}
  • trunk/Forms/UFormMain.lfm

    r6 r7  
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
     12  OnKeyDown = FormKeyDown
    1213  OnShow = FormShow
    13   LCLVersion = '1.3'
     14  LCLVersion = '1.5'
    1415  object PaintBox1: TPaintBox
    1516    Left = 0
     
    1920    Align = alClient
    2021    OnClick = PaintBox1Click
     22    OnResize = PaintBox1Resize
    2123  end
    2224  object MainMenu1: TMainMenu
  • trunk/Forms/UFormMain.pas

    r6 r7  
    2929    procedure FormCreate(Sender: TObject);
    3030    procedure FormDestroy(Sender: TObject);
     31    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    3132    procedure FormShow(Sender: TObject);
    3233    procedure PaintBox1Click(Sender: TObject);
     34    procedure PaintBox1Resize(Sender: TObject);
    3335  private
    3436    SerialText: string;
     37    OriginalBounds: TRect;
     38    OriginalWindowState: TWindowState;
     39    ScreenBounds: TRect;
    3540    procedure SerialDeviceReceiveDataSync;
    3641    procedure SerialDeviceReceiveData(Data: TMemory);
     42    procedure VideoDeviceRedraw(Sender: TObject);
     43    procedure SwitchFullScreen;
    3744  public
    3845    Kernel: TKernel;
     
    5562  NewApp: TApp;
    5663  SerialDevice: TBaseSerialDevice;
    57   NewScreen: TScreen;
     64  VideoDevice: TBaseVideoDevice;
    5865begin
    5966  Kernel := TKernel.Create;
     
    6269  SerialDevice := TBaseSerialDevice.Create;
    6370  SerialDevice.Name := 'Serial0';
     71  SerialDevice.ClassName := 'Serial port';
    6472  SerialDevice.OnReceiveData := SerialDeviceReceiveData;
    6573  Kernel.Devices.Add(SerialDevice);
     74
     75  VideoDevice := TBaseVideoDevice.Create;
     76  VideoDevice.Name := 'Video0';
     77  VideoDevice.ClassName := 'Graphic card';
     78  VideoDevice.OnRedraw := VideoDeviceRedraw;
     79  VideoDevice.DPI := Screen.PixelsPerInch;
     80  VideoDevice.VideoMemorySize := Point(PaintBox1.Width, PaintBox1.Height);;
     81  Kernel.Devices.Add(VideoDevice);
     82
    6683  NewApp := TAppClock.Create;
    6784  Kernel.Apps.Add(NewApp);
    68   NewScreen := TScreen.Create;
    69   NewScreen.Size := Point(PaintBox1.Width, PaintBox1.Height);
    70   NewScreen.DPI := Screen.PixelsPerInch;
    71   Kernel.Screens.Add(NewScreen);
    7285end;
    7386
     
    7992procedure TFormMain.AFullscreenExecute(Sender: TObject);
    8093begin
    81 
     94  SwitchFullScreen;
     95{  AFullscreen.Checked := not AFullscreen.Checked;
     96  if AFullscreen.Checked then begin
     97    WindowState := wsFullScreen;
     98    BorderStyle := bsNone;
     99  end else begin
     100    BorderStyle := bsSingle;
     101    WindowState := wsNormal;
     102  end;
     103  }
    82104end;
    83105
     
    87109end;
    88110
     111procedure TFormMain.SwitchFullScreen;
     112begin
     113  if WindowState <> wsFullScreen then begin
     114    // To full screen
     115    OriginalWindowState := WindowState;
     116    OriginalBounds := BoundsRect;
     117
     118    WindowState := wsFullScreen;
     119  end else begin
     120    // From full screen
     121    WindowState := OriginalWindowState;
     122    BoundsRect := OriginalBounds;
     123    {$IFDEF MSWINDOWS}
     124    BorderStyle := bsSizeable;
     125    {$ENDIF}
     126    if OriginalWindowState = wsMaximized then
     127      WindowState := wsMaximized
     128    else
     129      with OriginalBounds do
     130        SetBounds(Left, Top, Right - Left, Bottom - Top) ;
     131    {$IFDEF LINUX}
     132    BorderStyle := bsSizeable;
     133    {$ENDIF}
     134  end;
     135end;
     136
    89137procedure TFormMain.FormDestroy(Sender: TObject);
    90138begin
    91139  Kernel.Free;
     140end;
     141
     142procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word;
     143  Shift: TShiftState);
     144begin
     145
    92146end;
    93147
     
    100154begin
    101155
     156end;
     157
     158procedure TFormMain.PaintBox1Resize(Sender: TObject);
     159begin
    102160end;
    103161
     
    114172end;
    115173
     174procedure TFormMain.VideoDeviceRedraw(Sender: TObject);
     175begin
     176
     177end;
     178
    116179end.
    117180
  • trunk/Forms/UFormTerminal.lfm

    r6 r7  
    11object FormTerminal: TFormTerminal
    2   Left = 327
     2  Left = 590
    33  Height = 240
    4   Top = 34
     4  Top = 496
    55  Width = 320
    66  Caption = 'FormTerminal'
    77  ClientHeight = 240
    88  ClientWidth = 320
    9   LCLVersion = '1.3'
     9  LCLVersion = '1.5'
    1010  object Memo1: TMemo
    1111    Left = 0
  • trunk/Platform/Base/UPlatformBase.pas

    r6 r7  
    5757  end;
    5858
     59  { TBaseVideoDevice }
     60
     61  TBaseVideoDevice = class(TDevice)
     62  private
     63    FOnRedraw: TNotifyEvent;
     64  public
     65    VideoMemory: PByte;
     66    VideoMemorySize: TPoint;
     67    DPI: Integer;
     68    constructor Create; override;
     69    destructor Destroy; override;
     70    procedure Service(Index: Integer; DataIn, DataOut: TMemory); override;
     71    property OnRedraw: TNotifyEvent read FOnRedraw write FOnRedraw;
     72  end;
     73
    5974implementation
     75
     76{ TBaseVideoDevice }
     77
     78constructor TBaseVideoDevice.Create;
     79begin
     80  inherited Create;
     81end;
     82
     83destructor TBaseVideoDevice.Destroy;
     84begin
     85  inherited Destroy;
     86end;
     87
     88procedure TBaseVideoDevice.Service(Index: Integer; DataIn, DataOut: TMemory);
     89begin
     90  if Index = 0 then begin
     91    // Redraw to screen
     92    if Assigned(FOnRedraw) then
     93      FOnRedraw(Self);
     94  end else
     95  if Index = 1 then begin
     96    // Get video memory
     97    VideoMemory := GetMem(VideoMemorySize.X * VideoMemorySize.Y * 4);
     98//    DataOut^ := VideoMemory;
     99//    DataOut^ := VideoMemory;
     100  end else inherited;
     101end;
    60102
    61103{ TBaseSerialDevice }
     
    76118procedure TBaseSerialDevice.Service(Index: Integer; DataIn, DataOut: TMemory);
    77119begin
    78   inherited Service(Index, DataIn, DataOut);
    79120  if Index = 0 then begin
    80121    Lock.Acquire;
     
    82123      FOnReceiveData(DataIn);
    83124    Lock.Release;
    84   end else raise Exception.Create('Unsupported service ' + IntToStr(Index) + ' for driver ''' + Name + '''');
     125  end else inherited;
    85126end;
    86127
Note: See TracChangeset for help on using the changeset viewer.