source: branches/Pascal Compiler/UMainForm.pas

Last change on this file was 15, checked in by george, 16 years ago
  • Přidáno: Další pokusný projekt překladače.
File size: 2.3 KB
Line 
1unit UMainForm;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ComCtrls, UVirtualMachine;
8
9type
10 TProgramEdit = class(TCustomControl)
11 Code: TStringList;
12 procedure Paint; override;
13 constructor Create(AOwner: TComponent); override;
14 destructor Destroy; override;
15 end;
16
17 TDirection = (drNorth, drEasy, drSouth, drWest);
18
19 TRobotKarel = class
20 Board: array [0..9, 0..9] of Boolean;
21 Position: TPoint;
22 Direction: TDirection;
23 end;
24
25 TMainForm = class(TForm)
26 RichEdit1: TRichEdit;
27 procedure FormShow(Sender: TObject);
28 procedure FormClose(Sender: TObject; var Action: TCloseAction);
29 procedure GridPanel1Click(Sender: TObject);
30 private
31 { Private declarations }
32 public
33 VirtualProcessor: TVirtualProcessor;
34 ProgramEdit: TProgramEdit;
35 end;
36
37var
38 MainForm: TMainForm;
39
40implementation
41
42{$R *.dfm}
43
44procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
45begin
46 //Memo1.Lines.SaveToFile('Sample.pas');
47end;
48
49procedure TMainForm.FormShow(Sender: TObject);
50begin
51 //Memo1.Lines.LoadFromFile('Sample.pas');
52 ProgramEdit := TProgramEdit.Create(Self);
53 with ProgramEdit do begin
54 Parent := Self;
55 Width := 500;
56 Height := 500;
57 Top := 100;
58 Left := 100;
59 with Code do begin
60 Add('begin');
61 Add(' WriteLn(''Test'')');
62 Add('end.');
63 end;
64 end;
65end;
66
67procedure TMainForm.GridPanel1Click(Sender: TObject);
68begin
69
70end;
71
72{ TProgramEdit }
73
74constructor TProgramEdit.Create(AOwner: TComponent);
75begin
76 inherited;
77 Code := TStringList.Create;
78end;
79
80destructor TProgramEdit.Destroy;
81begin
82 Code.Free;
83 inherited;
84end;
85
86procedure TProgramEdit.Paint;
87var
88 I: Integer;
89const
90 LeftMargin: Integer = 30;
91begin
92 with Canvas do begin
93 Brush.Color := clGray;
94 FillRect(Rect(0, 0, LeftMargin, Height));
95 Brush.Color := clWhite;
96 FillRect(Rect(LeftMargin, 0, Width, Height));
97 for I := 0 to Code.Count - 1 do begin
98 Brush.Color := clWhite;
99 Font.Color := clBlack;
100 TextOut(LeftMargin + 2, (Abs(Font.Height) + 2) * I, Code[I]);
101 Brush.Color := clGray;
102 Font.Color := clWhite;
103 TextOut(LeftMargin - 20, (Abs(Font.Height) + 2) * I, IntToStr(I));
104 end;
105 end;
106end;
107
108end.
Note: See TracBrowser for help on using the repository browser.