-
Notifications
You must be signed in to change notification settings - Fork 22
/
page_pens.inc
207 lines (196 loc) · 6.86 KB
/
page_pens.inc
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// #############################################################################
// ############################ PENS GRID PAGE #################################
// #############################################################################
procedure TForm1.SgPensContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
SgPensDblClick(Sender);
end;
procedure TForm1.SgPensDblClick(Sender: TObject);
begin
SgEditorOff(SgPens);
FormParamAssist.ShowModal(SgPens.Row-1); // start dialog
JobToPenGridList; //update GUI
SgJobDefaults.Cells[1,4]:= string(Materials[Job.material].Name);
end;
procedure TForm1.SgPensDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var my_shape: Tshape;
aRect: TRect;
aStr: String;
my_tooltip: Integer;
begin
if ARow = 0 then with SgPens,Canvas do begin
Font.Style := [fsBold];
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end else with SgPens,Canvas do begin
// Draw the Band
Font.Color:=clblack;
if (ACol > 2) then begin
if not job.pens[aRow-1].enable then begin
Brush.Color := clBtnFace;
Font.Color:=clgrayText;
end;
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
end;
case ACol of
0: // Pen
begin
Font.Style := [fsBold];
Font.Color:=clblack;
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
1: // Color
begin
// InflateRect(Rect, -1, -1);
Brush.Color := clgray;
FrameRect(Rect);
Brush.Color := job.pens[aRow-1].color;
InflateRect(Rect, -1, -1);
FillRect(Rect);
Font.Color:=clwhite;
end;
2: // Enable
begin
Brush.Color := clgray;
Pen.Color := cl3Dlight;
inc(Rect.Left);
inc(Rect.Top);
FrameRect(Rect);
Brush.Color := cl3Dlight;
InflateRect(Rect, -1, -1);
if job.pens[aRow-1].used then begin
if job.pens[aRow-1].enable then
Font.Color:= clred
else
Font.Color:=clblack;
end else
Font.Color:=clwhite;
if job.pens[aRow-1].enable then
Font.Style := [fsBold];
FillRect(Rect);
aRect := Rect;
aStr:= Cells[ACol, ARow];
aRect.Top := aRect.Top + 1; // adjust top to center vertical
DrawText(Canvas.Handle, PChar(aStr), Length(aStr), aRect, DT_CENTER);
end;
9: // Shape
begin
Brush.Color := clgray;
Pen.Color := cl3Dlight;
inc(Rect.Left);
inc(Rect.Top);
FrameRect(Rect);
Brush.Color := cl3Dlight;
InflateRect(Rect, -1, -1);
FillRect(Rect);
aRect := Rect;
my_shape:= job.pens[aRow-1].shape;
Font.Color:= ShapeColorArray[ord(my_shape)];
aStr:= string(ShapeArray[ord(my_shape)]);
aRect.Top := aRect.Top + 1; // adjust top to center vertical
DrawText(Canvas.Handle, PChar(aStr), Length(aStr), aRect, DT_CENTER);
end;
11: // ATC, nicht aktiv
begin
if job.pens[aRow-1].enable and job.pens[aRow-1].used then begin
Brush.Color := clInactiveCaption;
Font.Color:=clblack;
Font.Style := [];
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end else begin
TextRect(Rect, Rect.Left + 2, Rect.Top + 2,'');
end;
end;
12: // Tooltip
begin
Brush.Color := clgray;
Pen.Color := cl3Dlight;
inc(Rect.Left);
inc(Rect.Top);
FrameRect(Rect);
Brush.Color := cl3Dlight;
InflateRect(Rect, -1, -1);
FillRect(Rect);
aRect := Rect;
my_tooltip:= job.pens[aRow-1].tooltip;
aStr:= string(ToolTipArray[my_tooltip]);
aRect.Top := aRect.Top + 1; // adjust top to center vertical
DrawText(Canvas.Handle, PChar(aStr), Length(aStr), aRect, DT_CENTER);
end;
end; //case
end;
end;
procedure TForm1.SgPensExit(Sender: TObject);
var c: integer;
begin
c:= SgPens.Col;
SgEditorOff(SgPens);
if c in [6,7,8] then OpenFilesInGrid
else begin
SgPens.Repaint;
PenGridListToJob;
apply_pen_change;
GLSneedsRedrawTimeout:= 2;
GLSneedsATCupdateTimeout:= 3;
end;
end;
procedure TForm1.SgPensKeyPress(Sender: TObject; var Key: Char);
begin
if Key in [#10, #13, #27] then SgPensExit(Sender);
end;
procedure TForm1.SgPensSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
var R: TRect;
org: TPoint;
begin
UnHilite;
with SgPens do begin // right col is for hide focus only
if ACol = ColCount-1 then begin CanSelect:= false; exit end;
SgEditorOff(SgPens);
case ACol of
1: // Color
begin
ColorDialog1.Color:= job.pens[ARow-1].color;
if not ColorDialog1.Execute then Exit;
Cells[1,ARow]:= IntToStr(ColorDialog1.Color);
job.pens[ARow-1].color:= ColorDialog1.Color;
OpenFilesInGrid; // in case of SVG the color inflence the
end; // relation between the path and the used pen!
2: // Enable
begin
job.pens[ARow-1].enable:= not job.pens[ARow-1].enable;
if job.pens[ARow-1].enable then
Cells[2,ARow]:= 'ON'
else
Cells[2,ARow]:= 'OFF';
end;
3, 4, 5, 6, 7, 8, 10, 13: // Diameter,Z,F,Xofs,Yofs,Scale,Z/Cycle,Blades
SgEditorOn(SgPens,ACol,ARow,true,true);
9: // Shapes
if ARow > 0 then begin
perform( WM_CANCELMODE, 0, 0 ); // verhindert Mausaktion in Stringgrid
uncheck_ms;
R := SgPens.CellRect(ACol, ARow);
org := self.ClientToScreen(R.BottomRight);
PopupMenuShape.Items[ord(job.pens[ARow-1].shape)].Checked:= true;
PopupMenuShape.Popup(org.X, org.Y);
end;
12: // Tooltip
if ARow > 0 then begin
perform( WM_CANCELMODE, 0, 0 ); // verhindert Mausaktion in Stringgrid
uncheck_mtt;
R := SgPens.CellRect(ACol, ARow);
org := self.ClientToScreen(R.BottomRight);
PopupMenuTooltip.Items[ord(job.pens[ARow-1].tooltip)].Checked:= true;
PopupMenuTooltip.Popup(org.X, org.Y);
end;
end; //case
PenGridListToJob;
apply_pen_change; // setzt Timeouts über ListBlocks auf 1
Repaint;
if (ACol = 1) or (ACol = 9) then begin
Form4.FormRefresh(nil); // sofortiges Update für Enable und Shape
end;
end;
end;