1 unit ExceptionViewClass
;
6 ConstantsClass
, CustomViewClass
, HardwareClass
, ResourcesClass
, TypesClass
,
13 TExceptionView
= class(TCustomView
)
15 function pGetWidth
: Integer; virtual;
16 procedure pCustomKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
); virtual;
17 procedure pOnSelectCell(Sender
: TObject
; ACol
, ARow
: Integer; var CanSelect
: Boolean); virtual;
18 procedure pOnState(Sender
: TObject
); virtual;
19 procedure pSetWidth(Width
: Integer); virtual;
21 constructor CreateExceptionView(AOwner
: TComponent
; Hw
: THardware
); virtual;
22 procedure ToggleException(Line
: Integer); virtual;
23 procedure ToggleMask(Line
: Integer); virtual;
24 property Width read pGetWidth write pSetWidth
;
29 // ************************************************************************** //
30 // * TExceptionView implementation * //
31 // ************************************************************************** //
33 function TExceptionView
.pGetWidth
: Integer;
35 Result
:= inherited Width
;
38 procedure TExceptionView
.pCustomKeyDown(Sender
: TObject
; var Key
: Word;
43 lselect
:= Selection
.TopLeft
;
45 KEY_RETURN
, KEY_SPACE
:
47 1: ToggleException(lselect
.Y
);
48 2: ToggleMask(lselect
.Y
);
53 procedure TExceptionView
.pOnSelectCell(Sender
: TObject
; ACol
, ARow
: Integer;
54 var CanSelect
: Boolean);
57 if (ACol
= 0) or (ARow
= 0) then Exit
;
58 if (ACol
= 2) and ((ARow
= 1) or (ARow
= 2)) then Exit
;
62 procedure TExceptionView
.pOnState(Sender
: TObject
);
66 Cells
[0, 0] := EXC_VIEW_TYPE
;
67 Cells
[1, 0] := EXC_VIEW_EXC
;
68 Cells
[2, 0] := EXC_VIEW_MASK
;
71 Changes
[1, i
] := not CompareStateException(Hardware
, 8 - i
);
72 Changes
[2, i
] := not CompareStateMask(Hardware
, 8 - i
);
73 Cells
[0, i
] := DESC_EXCE
[i
- 1];
74 if GetException(Hardware
.State
, 8 - i
) then Cells
[1, i
] := EXC_VIEW_TRUE
75 else Cells
[1, i
] := EXC_VIEW_FALSE
;
77 if GetMask(Hardware
.State
, 8 - i
) then Cells
[2, i
] := EXC_VIEW_TRUE
78 else Cells
[2, i
] := EXC_VIEW_FALSE
79 else Cells
[2, i
] := '';
83 procedure TExceptionView
.pSetWidth(Width
: Integer);
85 inherited Width
:= Width
;
86 ColWidths
[1] := Canvas
.TextWidth(EXC_VIEW_EXC
+ ' ');
87 ColWidths
[2] := Canvas
.TextWidth(EXC_VIEW_MASK
+ ' ');
88 ColWidths
[0] := ClientWidth
- ColWidths
[1] - ColWidths
[2];
91 constructor TExceptionView
.CreateExceptionView(AOwner
: TComponent
;
94 inherited CreateView(AOwner
, Hw
);
97 OnKeyDown
:= pCustomKeyDown
;
99 OnSelectCell
:= pOnSelectCell
;
100 PopupMenu
:= TPopupMenu
.Create(Self
);
103 Items
.Add(TMenuItem
.Create(PopupMenu
));
104 with Items
[Items
.Count
- 1] do
106 Caption
:= EXC_VIEW_TOGGLE
;
107 OnClick
:= OnDblClick
;
114 procedure TExceptionView
.ToggleException(Line
: Integer);
116 lstate
: THardwareState
;
118 if not(Line
> 0) then Exit
;
120 lstate
:= Hardware
.State
;
121 SetException(lstate
, Line
, not GetException(lstate
, Line
));
122 Hardware
.State
:= lstate
;
125 procedure TExceptionView
.ToggleMask(Line
: Integer);
127 lstate
: THardwareState
;
129 if not(Line
> 2) then Exit
;
131 lstate
:= Hardware
.State
;
132 SetMask(lstate
, Line
, not GetMask(lstate
, Line
));
133 Hardware
.State
:= lstate
;