-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchat_unit.pas
More file actions
552 lines (387 loc) · 19.2 KB
/
chat_unit.pas
File metadata and controls
552 lines (387 loc) · 19.2 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
(*
================================================================================
This file is part of OpenTemplot2024, a computer program for the design of model railway track.
Copyright (C) 2024 Martin Wynne. email: martin@85a.uk
This program is free software: you may redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence, or
(at your option) any later version.
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.
See the GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program. See the file: licence.txt
Or if not, refer to the web site: https://www.gnu.org/licenses/
================================================================================
This file was saved from Delphi5
*)
unit chat_unit;
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, PrintersDlgs;
type
{ Tchat_form }
Tchat_form = class(TForm)
chat_exit_button: TButton;
datestamp_label: TLabel;
font_button: TButton;
chat_scrollbox: TScrollBox;
chat_box: TLabel;
blue_corner_panel: TPanel;
size_updown: TUpDown;
colour_panel: TPanel;
colour_patch: TImage;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure font_buttonClick(Sender: TObject);
procedure colour_patchClick(Sender: TObject);
procedure size_updownClick(Sender: TObject; Button: TUDBtnType);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
chat_form: Tchat_form;
procedure chat(msg_str:string);
procedure do_fkey_chart; // print function key chart.
//____________________________________________________________________________________________
implementation
{$BOOLEVAL ON}
{$R *.lfm}
uses Printers, math_unit, control_room, colour_unit, calibration_unit, alert_unit,
pad_unit, print_unit;
//_________________________________________________________________________________________
procedure chat(msg_str:string); // show message in chat box.
begin
chat_form.chat_box.Caption:=insert_crlf_str(msg_str+'||[]| ');
do_show_modal(chat_form); // 212a ShowModal
end;
//_________________________________________________________________________________________
procedure Tchat_form.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key=VK_PAUSE then Application.Minimize; // hide TEMPLOT on PAUSE key.
end;
//__________________________________________________________________________________________
procedure Tchat_form.font_buttonClick(Sender: TObject);
begin
chat_box.Font.Assign(get_font('choose a new font and text colour for the chat window',chat_box.Font,True));
end;
//_________________________________________________________________________________________
procedure Tchat_form.colour_patchClick(Sender: TObject);
begin
Color:=get_colour('choose a new colour for the chat box',Color);
end;
//___________________________________________________________________________________________
procedure Tchat_form.size_updownClick(Sender: TObject; Button: TUDBtnType);
begin
if size_updown.Position>size_updown.Tag // ! position goes up, size goes down.
then ScaleBy(9,10); // scale the form contents down.
if size_updown.Position<size_updown.Tag
then ScaleBy(10,9); // scale the form contents up.
ClientHeight:=VertScrollBar.Range; // allow 4 pixel right margin.
ClientWidth:=HorzScrollBar.Range+4; // don't need bottom margin - datestamp label provides this.
ClientHeight:=VertScrollBar.Range; // do this twice, as each affects the other.
size_updown.Tag:=size_updown.Position; // and save for the next click.
end;
//_______________________________________________________________________________________
procedure Tchat_form.FormShow(Sender: TObject);
begin
chat_scrollbox.VertScrollBar.Position:=0; // reset the scrollbar.
end;
//____________________________________________________________________________________
procedure do_fkey_chart; // print function key chart.
const // WINAPI GetDeviceCaps Constants
HORZRES = 8;
VERTRES = 10;
BITSPIXEL = 12;
LOGPIXELSX = 88;
LOGPIXELSY = 90;
var
n:extended;
width_dots:integer; // printer page-width in dots.
length_dots:integer; // printer page-length in dots.
width_dpi:integer; // reported dpi across width.
length_dpi:integer; // reported dpi down length.
save_po:TPrinterOrientation;
x,y,y0,y1,y2:extended;
str:string;
str_len:integer;
////////////////////////////////////////////////////////////////////
procedure do_text;
begin
with Printer.Canvas do TextOut(Round(x/25.4*width_dpi),Round(y/25.4*length_dpi),str);
end;
///////////////////////////////////////////////////////////////////
begin
if no_printer_available=True // 0.93.a
then begin
show_modal_message('No printer available.');
EXIT;
end;
with TPrintDialog.Create(nil) do begin // 0.93.a created in code because of startup error if no printer available.
try
if Execute=False then EXIT;
finally
Free;
end;//try
end;//with
//if chat_form.print_dialog.Execute=False then EXIT;
save_po:=Printer.Orientation;
Printer.Orientation:=poLandscape;
if Application.Terminated=False then Application.ProcessMessages;
// Templot0 getting printer resolution
width_dpi:=Printer.XDPI;
length_dpi:=Printer.YDPI;
// papersize dimensions
width_dots:=Printer.PaperSize.Width;
length_dots:=Printer.PaperSize.Height;
if (width_dpi<1) or (length_dpi<1) or (width_dots<1) or (length_dots<1) // division by zero, or negative.
then begin
alert(0,' printer software problem ..',
'|||Templot0 is unable to access your printer software.'
+'||Please check your printer installation.',
'','','','','cancel printing','',0);
Printer.Orientation:=save_po;
EXIT;
end;
with Printer do begin
with Canvas do begin
Font.Name:='Arial';
Font.Color:=clBlack;
Brush.Color:=clWhite; // text white background.
Brush.Style:=bsSolid;
Pen.Color:=clGray; // 0.97.a clBlack;
Pen.Mode:=pmCopy;
Pen.Style:=psSolid;
Pen.Width:=3;
// this chart has been limited to 266 mm long in order to fit US letter paper.
BeginDoc;
MoveTo(0,0);
LineTo(0,Round(120/25.4*length_dpi));
n:=20; // left margin
while n<270 do begin
MoveTo(Round(n/25.4*width_dpi),0); // vertical grid bar top.
LineTo(Round(n/25.4*width_dpi),Round(145/25.4*length_dpi)); // vertical grid bar bottom.
n:=n+20.5;
end;//while
n:=0;
while n<=120 do begin
MoveTo(0,Round(n/25.4*length_dpi)); // horizontal grid bar left.
LineTo(Round(266/25.4*width_dpi),Round(n/25.4*length_dpi)); // horizontal grid bar right.
n:=n+40;
end;//while
MoveTo(Round(20/25.4*width_dpi),Round(145/25.4*length_dpi));
LineTo(Round(266/25.4*width_dpi),Round(145/25.4*length_dpi));
Font.Size:=20;
Font.Style:=[fsBold];
x:=5;
y:=147;
x:=x+20.5; str:='F1'; do_text;
x:=x+20.5; str:='F2'; do_text;
x:=x+20.5; str:='F3'; do_text;
x:=x+20.5; str:='F4'; do_text;
x:=x+20.5; str:='F5'; do_text;
x:=x+20.5; str:='F6'; do_text;
x:=x+20.5; str:='F7'; do_text;
x:=x+20.5; str:='F8'; do_text;
x:=x+20.5; str:='F9'; do_text;
x:=x+20.5; str:='F10'; do_text;
x:=x+20.5; str:='F11'; do_text;
x:=x+20.5; str:='F12'; do_text;
Font.Size:=15;
x:=0.5;
y:=19; str:=' SHIFT'; do_text;
y:=25; str:='+CTRL'; do_text;
y:=65; str:=' SHIFT'; do_text;
y:=105; str:=' CTRL'; do_text;
Font.Size:=14;
Font.Style:=[];
x:=7.5;y:=121;str:='^'; do_text;
Font.Size:=11;
Font.Style:=[fsItalic];
x:=0;y:=125;str:='hold down';do_text;
x:=8;y:=149;str:='press >'; do_text;
//---------------------------------
x:=1;
y0:=124;
y1:=130;
y2:=136;
Font.Size:=13;
Font.Style:=[];
x:=x+20.5; y:=y2; str:=' help'; do_text; // F1
x:=x+20.5; y:=y1; str:=' info'; do_text; y:=y2; str:=' toggle'; do_text; // F2
Font.Style:=[fsBold,fsItalic]; // mouse actions...
x:=x+18; y:=y1; str:='approach';do_text;
x:=x+2.5; y:=y2; str:=' length'; do_text; // F3
x:=x+20.5; y:=y1; str:=' overall'; do_text;y:=y2; str:=' length'; do_text; // F4
x:=x+20.5; y:=y2; str:=' size'; do_text; // F5
x:=x+20.5; y:=y2; str:='curving'; do_text; // F6
x:=x+20.5; y:=y2; str:=' shift'; do_text; // F7
x:=x+20.5; y:=y2; str:=' rotate'; do_text; // F8
x:=x+20.5; y:=y2; str:='V-angle'; do_text; // F9
x:=x+20.5; y:=y2; str:='K-angle'; do_text; // F10
Font.Style:=[];
x:=x+20.5; y:=y0; str:=' print';do_text; y:=y1; str:=' control';do_text; y:=y2; str:='template'; do_text; // F11
x:=x+20.5; y:=y1; str:=' redraw'; do_text; y:=y2; str:=' & show'; do_text; // F12
//-----------------------------------
x:=1;
Font.Size:=13;
y0:=98;
y1:=104;
y2:=110;
Font.Style:=[fsBold,fsItalic]; // mouse actions...
x:=x+20.5; y:=y1; str:=' spot'; do_text; y:=y2; str:=' zoom'; do_text; // CTRL-F1
Font.Style:=[];
x:=x+20.5; y:=y0; str:=' zoom'; do_text; y:=y1; str:='and pan'; do_text; y:=y2; str:='controls'; do_text; // CTRL-F2
Font.Style:=[fsBold,fsItalic];
x:=x+19.5; y:=y1; str:='blanking'; do_text;
x:=x+1.0; y:=y2; str:=' length'; do_text; // CTRL-F3
x:=x+19.5; y:=y0; str:=' roll';do_text; y:=y1; str:='rails and';do_text; y:=y2; str:='sleepers'; do_text; // CTRL-F4
x:=x+1.0;
x:=x+20.5; y:=y2; str:=' orbit'; do_text; // CTRL-F5
x:=x+20.5; y:=y2; str:=' snake'; do_text; // CTRL-F6
x:=x+20.5; y:=y1; str:=' slew'; do_text; y:=y2; str:='amount'; do_text; // CTRL-F7
x:=x+20.5; y:=y1; str:=' move'; do_text; y:=y2; str:=' peg'; do_text; // CTRL-F8
x:=x+20.5; y:=y1; str:=' roam'; do_text; y:=y2; str:=' along'; do_text; // CTRL-F9
x:=x+20.5; y:=y2; str:=' swell'; do_text; // CTRL-F10
Font.Style:=[];
x:=x+20; y:=y0; str:=' print'; do_text; y:=y1; str:='backgnd'; do_text; y:=y2; str:='templates'; do_text; // CTRL-F11
Font.Style:=[fsBold,fsItalic];
x:=x+21.0; y:=y0; str:='turnout-road'; do_text; y:=y1; str:=' exit'; do_text; y:=y2; str:=' length'; do_text; // CTRL-F12 209a
Font.Size:=11;
Font.Style:=[fsBold];
x:=1;
y:=90;
x:=x+20.5; str:='or 1 key'; do_text;
x:=x+20.5; str:='or 2 key'; do_text;
x:=x+20.5; str:='or 3 key'; do_text;
x:=x+20.5; str:='or 4 key'; do_text;
x:=x+20.5; str:='or 5 key'; do_text;
x:=x+20.5; str:='or 6 key'; do_text;
x:=x+20.5; str:='or 7 key'; do_text;
x:=x+20.5; str:='or 8 key'; do_text;
x:=x+20.5; str:='or 9 key'; do_text;
x:=x+20.5; str:='or 0 key'; do_text;
x:=x+20.5;
x:=x+20.5;
//-----------------------------------
x:=1;
Font.Size:=13;
Font.Style:=[];
y0:=58;
y1:=64;
y2:=70;
x:=x+20.5; y:=y0; str:=' make'; do_text; y:=y1; str:='diamond'; do_text; y:=y2; str:='crossing'; do_text; // SHIFT-F1
x:=x+20.5; y:=y0; str:=' make'; do_text; y:=y1; str:=' cross-'; do_text; y:=y2; str:=' over'; do_text; // SHIFT-F2
x:=x+20.5; y:=y0; str:=' make'; do_text; y:=y1; str:='double-'; do_text; y:=y2; str:='track TS'; do_text; // SHIFT-F3
x:=x+20.5; y:=y0; str:=' make'; do_text; y:=y1; str:='double-'; do_text; y:=y2; str:='track MS'; do_text; // SHIFT-F4
x:=x+20.5; y:=y1; str:='calibrate'; do_text; y:=y2; str:=' printer'; do_text; // SHIFT-F5
x:=x+20.5; y:=y0; str:=' rotate'; do_text; y:=y1; str:=' group'; do_text; y:=y2; str:='180 deg'; do_text; // SHIFT-F6
x:=x+20.5; y:=y0; str:=' make'; do_text; y:=y1; str:=' branch'; do_text; y:=y2; str:=' track'; do_text; // SHIFT-F7
x:=x+20.5; y:=y0; str:=' rotate'; do_text; y:=y1; str:=' control'; do_text; y:=y2; str:='180 deg'; do_text; // SHIFT-F8
Font.Style:=[fsBold,fsItalic];
x:=x+20.5; y:=y2; str:=' slide'; do_text; // SHIFT-F9
Font.Style:=[];
x:=x+20.5; y:=y1; str:=' shove'; do_text; y:=y2; str:=' timbers'; do_text; // SHIFT-F10
Font.Style:=[fsBold,fsItalic];
x:=x+19.5; y:=y0; str:='crossing'; do_text; y:=y1; str:=' entry'; do_text; y:=y2; str:=' straight'; do_text; // SHIFT-F11
x:=x+22.0; y:=y1; str:=' gaunt'; do_text; y:=y2; str:=' offset'; do_text; // SHIFT-F12
Font.Size:=11;
Font.Style:=[fsBold];
x:=1+9*20.5;
{ y:=41; str:=' or'; do_text;
y:=46; str:=' decimal'; do_text;
y:=51; str:=' key'; do_text;
}
x:=x+20.5; y:=50; str:='or , key'; do_text;
{
x:=1+11*20.5; y:=41; str:=' or'; do_text;
y:=46; str:=' space'; do_text;
y:=51; str:=' bar'; do_text;
x:=x+20.5; y:=50; str:='or ` key'; do_text;
}
//-----------------------------------
x:=1;
Font.Size:=13;
Font.Style:=[];
y0:=18;
y1:=24;
y2:=30;
x:=x+20.5; y:=y0; str:=' 1st'; do_text; y:=y1; str:=' trans.'; do_text; y:=y2; str:=' radius'; do_text; // SHIFT-CTRL-F1
x:=x+20.5; y:=y0; str:=' 2nd'; do_text; y:=y1; str:=' trans.'; do_text; y:=y2; str:=' radius'; do_text; // SHIFT-CTRL-F2
Font.Style:=[fsBold,fsItalic]; // mouse actions...
x:=x+20.5; y:=y1; str:=' trans.'; do_text; y:=y2; str:=' start'; do_text; // SHIFT-CTRL-F3
x:=x+20.5; y:=y1; str:=' trans.'; do_text; y:=y2; str:=' length'; do_text; // SHIFT-CTRL-F4
x:=x+20.5; y:=y1; str:='slewing'; do_text; y:=y2; str:=' start'; do_text; // SHIFT-CTRL-F5
x:=x+20.5; y:=y1; str:='slewing'; do_text; y:=y2; str:=' length'; do_text; // SHIFT-CTRL-F6
x:=x+20.5; y:=y1; str:=' shift'; do_text; y:=y2; str:=' group'; do_text; // SHIFT-CTRL-F7
x:=x+20.5; y:=y1; str:=' rotate'; do_text; y:=y2; str:=' group'; do_text; // SHIFT-CTRL-F8
Font.Style:=[];
x:=x+20.5; y:=y0; str:=' adjust'; do_text; y:=y1; str:=' check'; do_text; y:=y2; str:=' rails'; do_text; // SHIFT-CTRL-F9
Font.Style:=[fsBold,fsItalic]; // mouse action
x:=x+20.5; y:=y0; str:=' move'; do_text; y:=y1; str:=' page'; do_text; y:=y2; str:=' origin'; do_text; // SHIFT-CTRL-F10
x:=x+20.5; y:=y0; str:=' track'; do_text; y:=y1; str:=' centres'; do_text; y:=y2; str:=' TS'; do_text; // SHIFT-CTRL-F11
Font.Style:=[];
x:=x+20.5; y:=y0; str:='skeleton'; do_text; y:=y1; str:=' mouse'; do_text; y:=y2; str:=' draw'; do_text; // SHIFT-CTRL-F12 toggle
Font.Size:=11;
Font.Style:=[fsBold];
x:=1;
y:=8;
x:=x+20.5; str:='or - key'; do_text;
x:=x+20.5; str:='or = key'; do_text;
x:=x+20.5; str:='or [ key'; do_text;
x:=x+20.5; str:='or ] key'; do_text;
x:=x+20.5; str:='or '' key'; do_text;
x:=x+20.5; str:='or # key'; do_text;
x:=x+20.5; str:='or \ key'; do_text;
x:=x+20.5; str:='or / key'; do_text;
x:=x+20.5; str:='or . key'; do_text;
x:=x+20.5;
x:=x+20.5;
x:=x+20.5; str:='or ; key toggle'; do_text;
//--------------------------------------
Font.Size:=15;
Font.Style:=[fsBold];
x:=96; y:=162; str:='OPENTEMPLOT FUNCTION KEY CHART'; do_text;
Font.Size:=11;
Font.Style:=[];
x:=36; y:=172;
str:='This chart is intended to be placed behind your keyboard, and shows only the menu shortcuts which use the function keys.'; do_text;
x:=45; y:=179;
str:='A full list of all the keyboard shortcuts is available in the HELP menu on the trackpad, and can be printed out.'; do_text;
Font.Style:=[fsBold,fsItalic];
x:=53; y:=186;
str:='Entries in bold italic are mouse actions.'; do_text;
str_len:=Printer.Canvas.TextWidth(str+' ');
Font.Style:=[fsItalic];
Font.Size:=10;
str:='(To adjust the length of plain track either F3 or F4 can be used.)';
with Printer.Canvas do TextOut(Round(x/25.4*width_dpi)+str_len,Round(y/25.4*length_dpi),str);
Font.Style:=[];
Font.Size:=11;
x:=97; y:=193;
str:='The alternative single-key shortcuts are also shown.'; do_text;
Font.Size:=6;
Font.Style:=[];
x:=0; y:=197;
str:='OPENTEMPLOT v:'+FormatFloat('0.00',program_version/100)+' © Martin Wynne'; do_text; // © = copyright symbol.
EndDoc;
end;//with Canvas
end;//with Printer
Printer.Orientation:=save_po; // restore his printer.
end;
//______________________________________________________________________________________
procedure Tchat_form.FormCreate(Sender: TObject);
begin
ClientWidth:=568;
ClientHeight:=330;
AutoScroll:=True;
end;
//________________________________________________________________________________________
end.