summaryrefslogtreecommitdiff
path: root/packages/ide/fpevalw.pas
blob: 9dc193f7d3ee935d46413574cdc5863e0332ae0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
    Copyright (c) 1997-2008 by the Daniel Mantione
   
    Debug expression evaluator dialog ? 
   
    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}
unit fpevalw;

{****************************************************************************}
                                  interface
{****************************************************************************}

uses fpdebug,dialogs,views,objects,fpconst,drivers;

type  Pevaluate_dialog=^Tevaluate_dialog;
      Tevaluate_dialog=object(Tdialog)
        watch:Pwatch;
        expr_input,expr_output:Pinputline;
        constructor init(var bounds:Trect);
        procedure evaluate;
        procedure handleevent(var event:Tevent);virtual;
        destructor done;
      end;

{****************************************************************************}
                                implementation
{****************************************************************************}

constructor Tevaluate_dialog.init(var bounds:Trect);

var r:Trect;
    l:Plabel;
    b:Pbutton;

begin
  inherited init(bounds,'Evaluate expression');
  options:=options or ofcentered;
  {watch is auto initialized to nil.}

  r.assign(2,3,size.x-20,4);
  new(expr_input,init(r,255));
  insert(expr_input);

  r.assign(size.x-20,3,size.x-18,4);
  insert(new(Phistory,init(r,expr_input,hidEvaluate)));

  r.assign(2,2,size.x-20,3);
  new(l,init(r,'E~x~pression:',expr_input));
  insert(l);

  r.assign(2,6,size.x-20,7);
  new(expr_output,init(r,255));
  insert(expr_output);

  r.assign(2,5,size.x-20,6);
  new(l,init(r,'~R~esult:',expr_output));
  insert(l);

  r.assign(size.x-14,3,size.x-3,5);
  new(b,init(r,'~E~valuate',cmEvaluate,bfDefault));
  insert(b);

  //r.assign(size.x-14,6,size.x-3,8);
  //new(b,init(r,'Help',cmHelp,bfNormal));
  //insert(b);

  expr_input^.select;
end;

procedure Tevaluate_dialog.evaluate;

begin
  if watch<>nil then
    dispose(watch,done);
  new(watch,init(expr_input^.data^));
  expr_output^.data^:=strpas(watch^.current_value);
  expr_output^.drawview;
end;

procedure Tevaluate_dialog.handleevent(var event:Tevent);

begin
  inherited handleevent(event);
  if event.what=evCommand then
    case event.command of
      cmEvaluate:
        evaluate;
    end;
end;

destructor Tevaluate_dialog.done;

begin
  if watch<>nil then
    dispose(watch,done);
end;

end.