Changeset 40 for trunk/Forms


Ignore:
Timestamp:
Feb 19, 2012, 2:13:49 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Text message handling moved to UTarget unit as field of TTarget.
  • Modified: Messages are displayed as TListVIew rather then TMemo.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r39 r40  
    169169    procedure AProjectOpenRecentExecute(Sender: TObject);
    170170    procedure TargetStateChanged(Sender: TObject);
     171    procedure MessagesChanged(Sender: TObject);
    171172    procedure MenuItemTargetClick(Sender: TObject);
    172173    procedure ProjectOpen(FileName: string);
     
    191192  MainForm: TMainForm;
    192193
     194
    193195implementation
    194196
     
    204206  SNumberGeneration = 'Number generation';
    205207  SProgramExited = 'Program exited';
     208  SProgramStarted = 'Program started';
     209  SProgramStopped = 'Program stopped';
     210  SNewProject = 'New project';
    206211
    207212{ TMainForm }
     
    259264  if CurrentTarget.State = rsPaused then
    260265    AProgramShowExecutionPoint.Execute;
     266  if CurrentTarget.State = rsStopped then CurrentTarget.Messages.AddMessage(SProgramStopped);
     267end;
     268
     269procedure TMainForm.MessagesChanged(Sender: TObject);
     270begin
     271  FormMessages.Reload;
    261272end;
    262273
     
    275286procedure TMainForm.ProjectOpen(FileName: string);
    276287begin
     288  AProjectClose.Execute;
    277289  MemoSource.Lines.LoadFromFile(UTF8Decode(FileName));
    278290  LastOpenedList.AddItem(FileName);
     
    292304    TTarget(Targets[I]).OnChangeState := nil;
    293305  FCurrentTarget.OnChangeState := TargetStateChanged;
     306  FCurrentTarget.Messages.OnChange := MessagesChanged;
    294307  UpdateInterface;
    295308end;
     
    317330  FormMemory.Align := alClient;
    318331  FormMemory.Show;
    319   FormMesssages.ManualDock(TabSheetMessages, nil, alClient);
    320   FormMesssages.Align := alClient;
    321   FormMesssages.Show;
     332  FormMessages.ManualDock(TabSheetMessages, nil, alClient);
     333  FormMessages.Align := alClient;
     334  FormMessages.Show;
    322335  PageControlRight.Width := MainForm.Width div 2;
    323336  PageControlBottom.Height := MainForm.Height div 5;
     
    444457  if not CurrentTarget.Compiled then AProgramCompile.Execute;
    445458  CurrentTarget.Run;
     459  CurrentTarget.Messages.AddMessage(SProgramStarted);
    446460end;
    447461
     
    560574begin
    561575  with CurrentTarget do begin
    562     Stop;
     576    AProgramStop.Execute;
    563577    Optimization := coNormal;
    564578    SourceCode := MemoSource.Text;
    565579    ProgramName := ExtractFileNameOnly(ProjectFileName);
     580    CurrentTarget.Messages.AddMessage('Compiling...');
    566581    Compile;
     582    CurrentTarget.Messages.AppendMessage('done');
    567583    MemoTarget.Text := TargetCode;
    568584    UpdateInterface;
     
    645661procedure TMainForm.AProjectCloseExecute(Sender: TObject);
    646662begin
     663  AProgramStop.Execute;
    647664  Modified := False;
    648665  ProjectFileName := '';
     
    653670procedure TMainForm.AProjectNewExecute(Sender: TObject);
    654671begin
    655   ProjectFileName := 'Examples' + DirectorySeparator + 'Project.b';
     672  AProjectClose.Execute;
     673  ProjectFileName := 'Examples' + DirectorySeparator + SNewProject + '.b';
    656674  MemoSource.Clear;
    657675  Modified := False;
  • trunk/Forms/UFormMessages.lfm

    r39 r40  
    1 object FormMesssages: TFormMesssages
     1object FormMessages: TFormMessages
    22  Left = 256
    3   Height = 240
    4   Top = 32
    5   Width = 320
     3  Height = 225
     4  Top = 47
     5  Width = 492
    66  Caption = 'Messages'
    7   ClientHeight = 240
    8   ClientWidth = 320
     7  ClientHeight = 225
     8  ClientWidth = 492
     9  OnCreate = FormCreate
    910  LCLVersion = '0.9.31'
    10   object MemoMessages: TMemo
     11  object ListView1: TListView
    1112    Left = 0
    12     Height = 240
     13    Height = 225
    1314    Top = 0
    14     Width = 320
     15    Width = 492
    1516    Align = alClient
     17    Columns = <   
     18      item
     19        Width = 473
     20      end>
     21    OwnerData = True
     22    ReadOnly = True
     23    RowSelect = True
     24    ShowColumnHeaders = False
    1625    TabOrder = 0
     26    ViewStyle = vsReport
     27    OnData = ListView1Data
    1728  end
    1829end
  • trunk/Forms/UFormMessages.lrt

    r39 r40  
    1 TFORMMESSSAGES.CAPTION=Messages
     1TFORMMESSAGES.CAPTION=Messages
  • trunk/Forms/UFormMessages.pas

    r38 r40  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
     8  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
     9  ComCtrls;
    910
    1011type
    1112
    12   { TFormMesssages }
     13  { TFormMessages }
    1314
    14   TFormMesssages = class(TForm)
    15     MemoMessages: TMemo;
     15  TFormMessages = class(TForm)
     16    ListView1: TListView;
     17    procedure FormCreate(Sender: TObject);
     18    procedure ListView1Data(Sender: TObject; Item: TListItem);
    1619  private
    1720    { private declarations }
    1821  public
    19     { public declarations }
     22    procedure Reload;
    2023  end;
    2124
    2225var
    23   FormMesssages: TFormMesssages;
     26  FormMessages: TFormMessages;
    2427
    2528implementation
     
    2730{$R *.lfm}
    2831
     32uses
     33  UFormMain, UTarget;
     34
     35{ TFormMessages }
     36
     37procedure TFormMessages.ListView1Data(Sender: TObject; Item: TListItem);
     38begin
     39  with MainForm.CurrentTarget do
     40  if (Item.Index >= 0) and (Item.Index < Messages.Count) then
     41  with TMessage(Messages[Item.Index]) do begin
     42    Item.Caption := Text;
     43    Item.Data := Messages[Item.Index];
     44  end;
     45end;
     46
     47procedure TFormMessages.FormCreate(Sender: TObject);
     48begin
     49
     50end;
     51
     52procedure TFormMessages.Reload;
     53begin
     54  ListView1.Items.Count := MainForm.CurrentTarget.Messages.Count;
     55  ListView1.Refresh;
     56end;
     57
    2958end.
    3059
Note: See TracChangeset for help on using the changeset viewer.