forked from MakeMagazinDE/GRBLize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_pens.inc
207 lines (200 loc) · 6.44 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.SgPensDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
my_shape: Tshape;
aRect: TRect;
aStr: String;
my_tooltip: Integer;
begin
Rect.Left:= Rect.Left-4; // Workaround für XE8-Darstellung
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;
{
if (ACol = Col) and (ARow= Row) then begin
// statt schraffierter Umrandung, besser sichtbar
Brush.Color := clMenuHighlight;
FillRect(Rect);
Font.Color:=clwhite;
TextRect(Rect, Rect.Left + 2, Rect.Top + 1, cells[acol, arow]);
Font.Color:=clblack;
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:= 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:= 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.SgPensKeyPress(Sender: TObject; var Key: Char);
begin
if (Key = #13) or (Key = #10) then begin
SgPens.Repaint;
PenGridListToJob;
apply_pen_change;
GLSneedsRedrawTimeout:= 2;
GLSneedsATCupdateTimeout:= 3;
end;
end;
procedure TForm1.SgPensMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
my_shape: Tshape;
my_row, my_col: integer;
begin
SgPens.MouseToCell( X,Y, my_col, my_row );
if (my_row < 1) or (my_col < 1) then
exit;
SgPens.Col := my_col;
SgPens.Row := my_row;
UnHilite;
with SgPens do begin
Options:= Options - [goEditing, goAlwaysShowEditor];
case my_Col of
1: // Color
begin
Options:= Options - [goEditing];
ColorDialog1.Color:= job.pens[my_row-1].color;
if not ColorDialog1.Execute then Exit;
Cells[1,my_row]:= IntToStr(ColorDialog1.Color);
end;
2: // Enable
begin
Options:= Options - [goEditing];
job.pens[my_row-1].enable:= not job.pens[my_row-1].enable;
if job.pens[my_row-1].enable then
Cells[2,my_row]:= 'ON'
else
Cells[2,my_row]:= 'OFF';
end;
3: // F
begin
Options:= Options + [goEditing];
end;
4, 5, 6, 7, 10: // Xofs, Yofs, Z+
begin
Options:= Options + [goEditing];
end;
8: // Scale
begin
Options:= Options + [goEditing];
job.pens[my_row-1].Scale:= StrToFloatDef(Cells[8,my_row],100);
end;
9: // Shapes
if my_row > 0 then begin
perform( WM_CANCELMODE, 0, 0 ); // verhindert Mausaktion in Stringgrid
uncheck_ms;
PopupMenuShape.Items[ord(job.pens[Row-1].shape)].Checked:= true;
PopupMenuShape.Popup(X+left+Form1.left, Y+ top+Form1.top);
end;
12: // Tooltip
if my_row > 0 then begin
perform( WM_CANCELMODE, 0, 0 ); // verhindert Mausaktion in Stringgrid
uncheck_mtt;
PopupMenuTooltip.Items[ord(job.pens[Row-1].tooltip)].Checked:= true;
PopupMenuTooltip.Popup(X+left+Form1.left, Y+ top+Form1.top);
end;
end; //case
PenGridListToJob;
apply_pen_change; // setzt Timeouts über ListBlocks auf 1
Repaint;
if (my_Col = 1) or (my_Col = 9) then begin
Form4.FormRefresh(nil); // sofortiges Update für Enable und Shape
end;
end;
end;