6 ConstantsClass
, CustomViewClass
, FunctionsClass
, HardwareClass
,
7 OperandEditClass
, MemoryEditClass
, PrefixTreeClass
, ResourcesClass
,
9 Classes
, Controls
, Graphics
, Grids
, StdCtrls
, Menus
;
15 TMemoryView
= class(TCustomView
)
17 pOperandEdit
: TOperandEdit
;
18 procedure pCustomKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
); virtual;
19 procedure pCustomPopupAdd(Sender
: TObject
); virtual;
20 procedure pCustomPopupRemove(Sender
: TObject
); virtual;
21 procedure pOnSelectCell(Sender
: TObject
; ACol
, ARow
: Integer; var CanSelect
: Boolean); virtual;
22 procedure pOnOperand(Sender
: TObject
); virtual;
23 procedure pOnState(Sender
: TObject
); virtual;
25 constructor CreateMemoryView(AOwner
: TComponent
; Hw
: THardware
); virtual;
26 procedure ChangeMemory(Line
: Integer); virtual;
27 procedure OperandAdd
; virtual;
28 procedure OperandRemove(Line
: Integer); virtual;
33 // ************************************************************************** //
34 // * TMemoryView implementation * //
35 // ************************************************************************** //
37 procedure TMemoryView
.pCustomKeyDown(Sender
: TObject
; var Key
: Word;
42 lselect
:= Selection
.TopLeft
;
44 KEY_RETURN
, KEY_SPACE
:
45 ChangeMemory(lselect
.X
);
49 OperandRemove(lselect
.X
);
53 procedure TMemoryView
.pCustomPopupAdd(Sender
: TObject
);
58 pCustomKeyDown(Sender
, lkey
, []);
61 procedure TMemoryView
.pCustomPopupRemove(Sender
: TObject
);
66 pCustomKeyDown(Sender
, lkey
, []);
69 procedure TMemoryView
.pOnSelectCell(Sender
: TObject
; ACol
, ARow
: Integer;
70 var CanSelect
: Boolean);
72 if (ACol
= 0) or not(ARow
= 2) then CanSelect
:= False
73 else CanSelect
:= True;
76 procedure TMemoryView
.pOnOperand(Sender
: TObject
);
80 loperand
: POperandRecord
;
82 for i
:= 1 to (ColCount
- 1) do Objects
[i
, 0].Free
;
84 ltrees
:= Hardware
.Operands
.GetAllDescendants
;
85 for i
:= 0 to (Length(ltrees
) - 1) do
87 loperand
:= POperandRecord(ltrees
[i
].Data
);
88 if not(loperand
^.Default
= '') then
90 ColCount
:= ColCount
+ 1;
91 Objects
[ColCount
- 1, 0] := TMemoryEdit
.Create(Self
, loperand
);
97 procedure TMemoryView
.pOnState(Sender
: TObject
);
99 i
, j
, lwidth
: Integer;
101 Cells
[0, 0] := MEM_VIEW_NAME
;
102 Cells
[0, 1] := MEM_VIEW_TYPE
;
103 Cells
[0, 2] := MEM_VIEW_VALUE
;
104 for i
:= 1 to (ColCount
- 1) do
105 with TMemoryEdit(Objects
[i
, 0]) do
108 for j
:= 0 to (Length(sOperandTypes
) - 1) do
109 if (Operand
.OperandType
= sOperandTypes
[j
].OperandType
) then
111 Cells
[i
, 1] := sOperandTypes
[j
].Description
;
114 Cells
[i
, 2] := Value
;
117 lwidth
:= MaxOf(TextWidth(Cells
[i
, 0]), TextWidth(Cells
[i
, 1]));
118 lwidth
:= MaxOf(lwidth
, TextWidth(Cells
[i
, 2]));
119 ColWidths
[i
] := lwidth
+ TextWidth(' ');
124 constructor TMemoryView
.CreateMemoryView(AOwner
: TComponent
; Hw
: THardware
);
126 inherited CreateView(AOwner
, Hw
);
127 ScrollBars
:= ssHorizontal
;
131 OnKeyDown
:= pCustomKeyDown
;
132 OnOperand
:= pOnOperand
;
133 OnSelectCell
:= pOnSelectCell
;
135 pOperandEdit
:= TOperandEdit
.CreateBox(AOwner
);
136 PopupMenu
:= TPopupMenu
.Create(Self
);
139 Items
.Add(TMenuItem
.Create(PopupMenu
));
140 with Items
[Items
.Count
- 1] do
142 Caption
:= MEM_VIEW_EDIT
;
143 OnClick
:= OnDblClick
;
146 Items
.Add(TMenuItem
.Create(PopupMenu
));
147 Items
[Items
.Count
- 1].Caption
:= '-';
148 Items
.Add(TMenuItem
.Create(PopupMenu
));
149 with Items
[Items
.Count
- 1] do
151 Caption
:= MEM_VIEW_ADD
;
152 OnClick
:= pCustomPopupAdd
;
154 Items
.Add(TMenuItem
.Create(PopupMenu
));
155 with Items
[Items
.Count
- 1] do
157 Caption
:= MEM_VIEW_REMOVE
;
158 OnClick
:= pCustomPopupRemove
;
164 procedure TMemoryView
.ChangeMemory(Line
: Integer);
166 if (Line
< 1) or not(Line
< ColCount
) then Exit
;
167 with TMemoryEdit(Objects
[Line
, 0]) do
169 Edit
.Caption
:= MEM_VIEW_EDIT
+ ' ' + Name
;
175 procedure TMemoryView
.OperandAdd
;
177 pOperandEdit
.ShowBox(Hardware
);
180 procedure TMemoryView
.OperandRemove(Line
: Integer);
182 if (Line
< 1) or not(Line
< ColCount
) then Exit
;
183 Hardware
.OperandRemove(TMemoryEdit(Objects
[Line
, 0]).Name
);