Changeset 8 for trunk/Forms
- Timestamp:
- May 9, 2015, 1:32:38 AM (10 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r7 r8 20 20 Align = alClient 21 21 OnClick = PaintBox1Click 22 OnPaint = PaintBox1Paint 22 23 OnResize = PaintBox1Resize 23 24 end -
trunk/Forms/UFormMain.pas
r7 r8 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, Menus, ActnList, UKernel, UMemory ;9 ExtCtrls, Menus, ActnList, UKernel, UMemory, UDevice, UPlatformBase, LCLType; 10 10 11 11 type … … 32 32 procedure FormShow(Sender: TObject); 33 33 procedure PaintBox1Click(Sender: TObject); 34 procedure PaintBox1Paint(Sender: TObject); 34 35 procedure PaintBox1Resize(Sender: TObject); 35 36 private 37 VideoDevice: TDeviceVideoBase; 38 SerialDevice: TBaseSerialDevice; 36 39 SerialText: string; 37 40 OriginalBounds: TRect; … … 39 42 ScreenBounds: TRect; 40 43 procedure SerialDeviceReceiveDataSync; 41 procedure SerialDeviceReceiveData( Data: TMemory);44 procedure SerialDeviceReceiveData(Text: string); 42 45 procedure VideoDeviceRedraw(Sender: TObject); 46 procedure VideoDeviceRedrawSync; 43 47 procedure SwitchFullScreen; 48 procedure EraseBackground(DC: HDC); override; 44 49 public 45 50 Kernel: TKernel; … … 52 57 53 58 uses 54 UList, UApp, UAPI, UClock, U PlatformBase, UThreadEx, UFormTerminal;59 UList, UApp, UAPI, UClock, UThreadEx, UFormTerminal; 55 60 56 61 {$R *.lfm} … … 61 66 var 62 67 NewApp: TApp; 63 SerialDevice: TBaseSerialDevice; 64 VideoDevice: TBaseVideoDevice;65 begin 68 begin 69 PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque]; 70 66 71 Kernel := TKernel.Create; 67 72 Kernel.SchedulerClass := TBaseScheduler; 68 73 Kernel.FileSystemClass := TBaseFileSystem; 74 69 75 SerialDevice := TBaseSerialDevice.Create; 70 76 SerialDevice.Name := 'Serial0'; … … 73 79 Kernel.Devices.Add(SerialDevice); 74 80 75 VideoDevice := T BaseVideoDevice.Create;81 VideoDevice := TDeviceVideoBase.Create; 76 82 VideoDevice.Name := 'Video0'; 77 83 VideoDevice.ClassName := 'Graphic card'; 78 84 VideoDevice.OnRedraw := VideoDeviceRedraw; 79 85 VideoDevice.DPI := Screen.PixelsPerInch; 80 VideoDevice.VideoMemorySize := Point(PaintBox1.Width, PaintBox1.Height);; 86 VideoDevice.VideoMemorySize := Point(PaintBox1.Width, PaintBox1.Height); 87 VideoDevice.OnModeChanged := VideoDeviceRedraw; 81 88 Kernel.Devices.Add(VideoDevice); 82 89 … … 135 142 end; 136 143 144 procedure TFormMain.EraseBackground(DC: HDC); 145 begin 146 //inherited EraseBackground(DC); 147 end; 148 137 149 procedure TFormMain.FormDestroy(Sender: TObject); 138 150 begin … … 156 168 end; 157 169 170 procedure TFormMain.PaintBox1Paint(Sender: TObject); 171 var 172 X, Y: Integer; 173 Bitmap: TBitmap; 174 begin 175 try 176 Bitmap := TBitmap.Create; 177 Bitmap.BeginUpdate; 178 Bitmap.SetSize(PaintBox1.Width, PaintBox1.Height); 179 180 if Assigned(VideoDevice.VideoMemory) then begin 181 for Y := 0 to VideoDevice.VideoMode.Size.Y - 1 do 182 for X := 0 to VideoDevice.VideoMode.Size.X - 1 do begin 183 Bitmap.Canvas.Pixels[X, Y] := PInteger(VideoDevice.VideoMemory + X * VideoDevice.VideoMode.GetBytesPerPixel + 184 Y * VideoDevice.VideoMode.GetBytesPerLine)^ and $ffffff; 185 end; 186 end; 187 finally 188 PaintBox1.Canvas.Draw(0, 0, Bitmap); 189 Bitmap.EndUpdate; 190 Bitmap.Free; 191 end; 192 end; 193 158 194 procedure TFormMain.PaintBox1Resize(Sender: TObject); 159 195 begin … … 165 201 end; 166 202 167 procedure TFormMain.SerialDeviceReceiveData(Data: TMemory); 168 begin 169 SetLength(SerialText, Data.Size); 170 Move(Data.Data^, SerialText[1], Data.Size); 203 procedure TFormMain.SerialDeviceReceiveData(Text: string); 204 begin 205 SerialText := Text; 171 206 TThreadEx.Synchronize(TThreadEx.CurrentThread, SerialDeviceReceiveDataSync); 172 207 end; … … 174 209 procedure TFormMain.VideoDeviceRedraw(Sender: TObject); 175 210 begin 176 211 TThreadEx.Synchronize(TThreadEx.CurrentThread, VideoDeviceRedrawSync); 212 end; 213 214 procedure TFormMain.VideoDeviceRedrawSync; 215 begin 216 PaintBox1.Refresh; 177 217 end; 178 218 -
trunk/Forms/UFormTerminal.lfm
r7 r8 14 14 Width = 320 15 15 Align = alClient 16 ReadOnly = True 17 ScrollBars = ssAutoBoth 16 18 TabOrder = 0 17 19 end
Note:
See TracChangeset
for help on using the changeset viewer.