ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JDesigner/ufNodeProp.pas
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Dec 10 19:29:12 2001 UTC (14 years, 8 months ago) by hsauro
Branch: MAIN, hsauro
CVS Tags: V10, HEAD_NEW, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
no message

Line File contents
1 unit ufNodeProp;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, uCommon, uNodeList, ImgList;
8
9 type
10 TfrmNodeProp = class(TForm)
11 pnlBottom: TPanel;
12 BtnOK: TButton;
13 BtnCancel: TButton;
14 Panel1: TPanel;
15 Label1: TLabel;
16 Label2: TLabel;
17 EdtNodeName: TEdit;
18 Label3: TLabel;
19 Label4: TLabel;
20 EdtNodeValue: TEdit;
21 BtnNext: TButton;
22 BtnPrevious: TButton;
23 GroupBox1: TGroupBox;
24 rdoFloating: TRadioButton;
25 rdoFixed: TRadioButton;
26 BlobList: TListBox;
27 ImageList: TImageList;
28 chkUseBlob: TCheckBox;
29 GroupBox2: TGroupBox;
30 rdoRoundRect: TRadioButton;
31 rdoSquareRect: TRadioButton;
32 rdoNoRect: TRadioButton;
33 rdoCircle: TRadioButton;
34 procedure EdtNodeValueExit(Sender: TObject);
35 procedure BtnNextClick(Sender: TObject);
36 procedure BtnPreviousClick(Sender: TObject);
37 procedure EdtNodeNameExit(Sender: TObject);
38 procedure BtnOKClick(Sender: TObject);
39 procedure BlobListDrawItem(Control: TWinControl; Index: Integer;
40 Rect: TRect; State: TOwnerDrawState);
41 procedure chkUseBlobClick(Sender: TObject);
42 procedure BlobListClick(Sender: TObject);
43 private
44 { Private declarations }
45 function GetValue (str : string) : double;
46 public
47 { Public declarations }
48 value : double;
49 NodeList : TNodeList;
50 NodeId : integer;
51 end;
52
53 var
54 frmNodeProp: TfrmNodeProp;
55
56 implementation
57
58 uses uNetPanel;
59
60 {$R *.DFM}
61
62 function TfrmNodeProp.GetValue (str : string) : double;
63 begin
64 try
65 result := strtoFloat (EdtNodeValue.Text);
66 except
67 on Exception do
68 begin
69 showmessage ('Error in input node value, please reenter');
70 ModalResult := mrNone;
71 end;
72 end;
73 end;
74
75
76 procedure TfrmNodeProp.EdtNodeValueExit(Sender: TObject);
77 begin
78 value := GetValue (EdtNodeValue.Text);
79 NodeList[NodeId].Value := value;
80 end;
81
82
83 procedure TfrmNodeProp.BtnNextClick(Sender: TObject);
84 begin
85 // Only bother updating if something has changed
86 if frmNodeProp.EdtNodeName.Text <> NodeList[NodeId].Name then
87 NodeList[NodeId].Name := frmNodeProp.EdtNodeName.Text;
88
89 NodeList[NodeId].Value := GetValue (EdtNodeValue.Text);
90 if rdoFixed.checked then
91 NodeList[NodeId].Status := nsBoundary
92 else NodeList[NodeId].Status := nsFloating;
93
94 inc (NodeId);
95 if NodeId = NodeList.Count then
96 NodeId := 0;
97
98 EdtNodeName.Text := NodeList[NodeId].Name;
99 EdtNodeValue.Text := floattostr (NodeList[NodeId].Value);
100
101 if NodeList[NodeId].Status = nsBoundary then
102 rdoFixed.checked := True
103 else rdoFloating.checked := True;
104
105 case NodeList[NodeId].BorderType of
106 ntRound : rdoRoundRect.Checked := True;
107 ntSquare : rdoSquareRect.Checked := True;
108 ntCircle : rdoCircle.Checked := True;
109 ntNone : rdoNoRect.Checked := True;
110 end;
111
112 EdtNodeValue.setfocus;
113 end;
114
115
116 procedure TfrmNodeProp.BtnPreviousClick(Sender: TObject);
117 begin
118 // Only bother updating if something has changed
119 if frmNodeProp.EdtNodeName.Text <> NodeList[NodeId].Name then
120 NodeList[NodeId].Name := frmNodeProp.EdtNodeName.Text;
121
122 NodeList[NodeId].Value := GetValue (EdtNodeValue.Text);
123 if rdoFixed.checked then
124 NodeList[NodeId].Status := nsBoundary
125 else NodeList[NodeId].Status := nsFloating;
126
127
128 dec (NodeId);
129 if NodeId < 0 then
130 NodeId := NodeList.Count - 1;
131 EdtNodeName.Text := NodeList[NodeId].Name;
132 EdtNodeValue.Text := floattostr (NodeList[NodeId].Value);
133
134 if NodeList[NodeId].Status = nsBoundary then
135 rdoFixed.checked := True
136 else rdoFloating.checked := True;
137
138 case NodeList[NodeId].BorderType of
139 ntRound : rdoRoundRect.Checked := True;
140 ntSquare : rdoSquareRect.Checked := True;
141 ntCircle : rdoCircle.Checked := True;
142 ntNone : rdoNoRect.Checked := True;
143 end;
144
145 EdtNodeValue.setfocus;
146 end;
147
148
149 procedure TfrmNodeProp.EdtNodeNameExit(Sender: TObject);
150 begin
151 NodeList[NodeId].Name := EdtNodeName.Text;
152 end;
153
154
155 procedure TfrmNodeProp.BtnOKClick(Sender: TObject);
156 begin
157 if rdoFixed.checked then
158 NodeList[NodeId].Status := nsBoundary
159 else NodeList[NodeId].Status := nsFloating;
160
161 if rdoRoundRect.Checked then
162 NodeList[NodeId].BorderType := ntRound;
163 if rdoSquareRect.Checked then
164 NodeList[NodeId].BorderType := ntSquare;
165 if rdoCircle.Checked then
166 NodeList[NodeId].BorderType := ntCircle;
167 if rdoNoRect.Checked then
168 NodeList[NodeId].BorderType := ntNone;
169 end;
170
171
172 procedure TfrmNodeProp.BlobListDrawItem(Control: TWinControl;
173 Index: Integer; Rect: TRect; State: TOwnerDrawState);
174 var
175 Bitmap: TBitmap; // temporary variable for the itemís bitmap
176 Offset: Integer; // text offset width
177 begin
178 Bitmap := TBitmap.Create();
179 with (Control as TListBox).Canvas do { draw on control canvas, not on the form }
180 begin
181 FillRect(Rect); { clear the rectangle }
182 Offset := 2; { provide default offset }
183 ImageList.GetBitmap (Index, Bitmap);
184
185 if Bitmap <> nil then
186 begin
187 BrushCopy(Bounds(Rect.Left, Rect.Top, Bitmap.Width, Bitmap.Height),
188 Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clRed); {render bitmap}
189 if odSelected in State then
190 InvertRect (handle, rect);
191
192 //Offset := Bitmap.width + 6; { add four pixels between bitmap and text}
193 end;
194 //TextOut(Rect.Left + Offset, Rect.Top, (Control as TListBox).Items[Index]) { display the text }
195 end;
196 Bitmap.Free;
197 end;
198
199 procedure TfrmNodeProp.chkUseBlobClick(Sender: TObject);
200 begin
201 if chkUseBlob.checked then
202 BlobList.visible := True
203 else BlobList.visible := False;
204 end;
205
206
207 procedure TfrmNodeProp.BlobListClick(Sender: TObject);
208 begin
209 NodeList[NodeId].UseImage := True;
210 NodeList[NodeId].Image.Free;
211 NodeList[NodeId].Image := TBitmap.Create;
212 ImageList.GetBitmap (BlobList.ItemIndex, NodeList[NodeId].Image);
213 end;
214
215
216 end.