Ignore:
Timestamp:
Feb 19, 2012, 10:29:55 AM (13 years ago)
Author:
chronos
Message:
  • Modified: Used manual docked forms for better code separation.
  • Modified: Used tabbed layout with PageControl and TabSheets for better usability.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCPU.pas

    r37 r38  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, ComCtrls;
    10 
    11 const
    12   RowSize = 16;
     9  ExtCtrls;
    1310
    1411type
    1512
    16   { TInterpreterForm }
     13  { TFormCPU }
    1714
    18   TInterpreterForm = class(TForm)
    19     Label1: TLabel;
    20     Label2: TLabel;
     15  TFormCPU = class(TForm)
    2116    Label3: TLabel;
    2217    Label4: TLabel;
    23     Label6: TLabel;
     18    Label5: TLabel;
    2419    Label7: TLabel;
     20    LabelMemoryPointer: TLabel;
     21    LabelProgramPointer: TLabel;
    2522    LabelStepCounter: TLabel;
    26     LabelProgramPointer: TLabel;
    27     Label5: TLabel;
    28     LabelMemoryPointer: TLabel;
    2923    LabelStepSpeed: TLabel;
    30     ListViewMemory: TListView;
    31     MemoInput: TMemo;
    32     MemoOutput: TMemo;
    33     Panel1: TPanel;
    34     Panel2: TPanel;
    35     Panel3: TPanel;
    36     Panel4: TPanel;
    37     Splitter1: TSplitter;
    38     Splitter2: TSplitter;
    39     Timer1: TTimer;
    40     ToolBar1: TToolBar;
    41     ToolButton1: TToolButton;
    42     ToolButton2: TToolButton;
    43     ToolButton3: TToolButton;
    44     ToolButton4: TToolButton;
    45     ToolButton5: TToolButton;
    46     ToolButton6: TToolButton;
    47     ToolButton7: TToolButton;
    48     procedure FormHide(Sender: TObject);
    49     procedure FormShow(Sender: TObject);
    50     procedure ListViewMemoryData(Sender: TObject; Item: TListItem);
    51     procedure MemoInputKeyPress(Sender: TObject; var Key: char);
    52     procedure Timer1Timer(Sender: TObject);
    5324  private
    5425  public
    5526    LastStepCounter: Integer;
    56     procedure RefreshListViewMemory;
    57     procedure UpadateInterface;
     27    procedure Reload;
    5828  end;
    5929
    6030var
    61   InterpreterForm: TInterpreterForm;
     31  FormCPU: TFormCPU;
    6232
    6333implementation
     
    7141  SStepsPerSecond = ' steps/s';
    7242
    73 { TInterpreterForm }
     43{ TFormCPU }
    7444
    75 procedure TInterpreterForm.Timer1Timer(Sender: TObject);
     45procedure TFormCPU.Reload;
    7646begin
    7747  if MainForm.CurrentTarget is TTargetInterpretter then
     
    8252    LabelStepSpeed.Caption := IntToStr(StepCount - LastStepCounter) + SStepsPerSecond;
    8353    LastStepCounter := StepCount;
    84     MemoOutput.Lines.Text := Output;
    8554  end;
    86   RefreshListViewMemory;
    87 end;
    88 
    89 procedure TInterpreterForm.RefreshListViewMemory;
    90 begin
    91   if MainForm.CurrentTarget is TTargetInterpretter then
    92   with TTargetInterpretter(MainForm.CurrentTarget) do begin
    93     ListViewMemory.Items.Count := Trunc(Length(Memory) / RowSize);
    94     ListViewMemory.Refresh;
    95   end;
    96 end;
    97 
    98 procedure TInterpreterForm.UpadateInterface;
    99 begin
    100   MainForm.UpdateInterface;
    101 end;
    102 
    103 procedure TInterpreterForm.ListViewMemoryData(Sender: TObject; Item: TListItem);
    104 var
    105   Row: string;
    106   I: Integer;
    107 begin
    108   if MainForm.CurrentTarget is TTargetInterpretter then
    109   with TTargetInterpretter(MainForm.CurrentTarget) do
    110   if (Item.Index >= 0) and (Item.Index < Trunc(Length(Memory) / RowSize)) then begin
    111     Item.Caption := IntToHex(Item.Index * RowSize, 8);
    112     Row := '';
    113     for I := 0 to RowSize - 1 do
    114       Row := Row + ' ' + IntToHex(Memory[Item.Index * RowSize + I], 2);
    115     Item.SubItems.Add(Row);
    116   end;
    117 end;
    118 
    119 procedure TInterpreterForm.FormHide(Sender: TObject);
    120 begin
    121   Timer1.Enabled := False;
    122 end;
    123 
    124 procedure TInterpreterForm.FormShow(Sender: TObject);
    125 begin
    126   Timer1.Enabled := True;
    127 end;
    128 
    129 procedure TInterpreterForm.MemoInputKeyPress(Sender: TObject; var Key: char);
    130 begin
    131   if MainForm.CurrentTarget is TTargetInterpretter then
    132   with TTargetInterpretter(MainForm.CurrentTarget) do
    133     Input := Input + Key;
    13455end;
    13556
Note: See TracChangeset for help on using the changeset viewer.