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.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls, Grids, Menus,inifiles;
type
TForm1 = class(TForm)
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
mm1: TMainMenu;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Button1: TButton;
BMP1: TMenuItem;
Label7: TLabel;
ColorDialog1: TColorDialog;
Button2: TButton;
Label8: TLabel;
Edit3: TEdit;
Label3: TLabel;
ComboBox2: TComboBox;
N5: TMenuItem;
Label4: TLabel;
btn1: TButton;
Label5: TLabel;
TrackBar3: TTrackBar;
TrackBar4: TTrackBar;
Label6: TLabel;
Edit1: TEdit;
mmo1: TMemo;
btn2: TButton;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure TrackBar2Change(Sender: TObject);
procedure TrackBar3Change(Sender: TObject);
procedure TrackBar4Change(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BMP1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
Infile = record
num: integer;
name: string[12];
size: longint;
end;
type rt=object
mytext:string;
x1:integer;
y1:integer;
x2:integer;
y2:integer;
align:string;
lc:Tcolor;
linecount:integer;
symbcount:Integer;
constructor Init(amytext:string;ax1,ay1,ax2,ay2:Integer;aalign:string;alc:Tcolor;alinecount,asymbcount:integer);
procedure outrt(amytext:string;ax1,ay1,ax2,ay2:Integer;aalign:string;alc:Tcolor;alinecount,asymbcount:integer);
end;
var
actual:rt;
x1,x2,y1,y2,linecount,symbcount,code:integer;
lc,fc:Tcolor;
i,t,o,d:integer;
Ini: Tinifile;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor rt.Init;
begin
x1:=ax1; y1:=ay1; x2:=ax2; y2:=ay2; linecount:=alinecount; symbcount:=asymbcount; align:=aalign;
end;
procedure zz;
var s:string;
Flag: Cardinal;
Rect:TRect;
begin
s := actual.mytext;
Rect.Left:=10;
Rect.Top:=10;
Rect.Right:=100;
Rect.Bottom:=100;
Case (Form1.ComboBox2.ItemIndex+1) of
1: Flag := DT_LEFT;
3: Flag := DT_CENTER;
else
Flag := DT_RIGHT;
end;
Flag := Flag or DT_WORDBREAK;
DrawText(Form1.Handle,PChar(s), length(s),Rect,Flag);
end;
procedure rt.outrt;
var gm,gd:integer;
k,i,j:integer;
adstr:string;
fg:word;
var s:string;
Flag: Cardinal;
Rect:TRect;
begin
x1:=ax1; y1:=ay1; x2:=ax2; y2:=ay2; linecount:=alinecount; symbcount:=asymbcount; align:=aalign;
if (actual.y2-actual.y1)<10 then begin actual.y2:=actual.y2+25; actual.y1:=actual.y1-5; end;
actual.linecount:=Form1.mmo1.lines.Count;
Form1.Image1.Canvas.Brush.Color:=clWhite;
Form1.Image1.Canvas.Rectangle (0,0,1000,1000);
Form1.Image1.Canvas.FloodFill(0,0,actual.lc,fsSurface);
Form1.Image1.Canvas.Rectangle (actual.x1-1,actual.y1-1,actual.x2,actual.y2);
Form1.Image1.Canvas.FloodFill(actual.x1+1,actual.y1+1,actual.lc,fsSurface);
Rect.Left:=actual.x1;
Rect.Top:=actual.y1;
Rect.Right:=actual.x2;
Rect.Bottom:=actual.y2;
Rect.Left:=10;
Rect.Top:=10;
Rect.Right:=100;
Rect.Bottom:=100;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
tsr : tsearchrec;
i:integer;
align,mytext:string;
linecount,symbcount,x1,y1,x2,y2:Integer;
begin
i:=0;
x1:=Form1.TrackBar1.Position; y1:=Form1.TrackBar2.Position;
actual.init(mytext,x1,y1,x2,y2,align,lc,linecount,symbcount);
mmo1.Text:=Edit3.Text;
Form1.Refresh;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
actual.x1:=TrackBar1.Position;
Form1.Refresh;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Flag: Cardinal;
Rect:TRect;
Procedure Swap(var a,b:integer);
var x:integer;
s:string;
begin
x:=a;
a:=b;
b:=x;
end;
begin
Form1.Image1.Picture:= nil;
Form1.Image1.Canvas.Pen.Color:=actual.lc;
Form1.Image1.Canvas.Brush.Color:=actual.lc;
Form1.Image1.Canvas.Rectangle(actual.x1,actual.y1,actual.x2,actual.y2);
actual.linecount:=mmo1.Lines.Count;
Edit1.Text:=IntToStr(actual.linecount);
Rect.Left:=actual.x1;
Rect.Top:=actual.y1;
Rect.Right:=actual.x2;
Rect.Bottom:=actual.y2;
Case (Form1.ComboBox2.ItemIndex+1) of
1: Flag := DT_LEFT;
3: Flag := DT_CENTER;
else
Flag := DT_RIGHT;
end;
Flag := Flag or DT_WORDBREAK;
DrawText(Form1.Image1.Canvas.Handle,PChar(Edit3.text), length(Edit3.text),Rect,Flag);
actual.x1:=Form1.TrackBar1.Position;
actual.y1:=Form1.TrackBar2.Position;
actual.x2:=Form1.TrackBar3.Position;
actual.y2:=Form1.TrackBar4.Position;
Form1.TrackBar1.Position:=actual.x1;
Form1.TrackBar2.Position:=actual.y1;
Form1.TrackBar3.Position:=actual.x2;
Form1.TrackBar4.Position:=actual.y2;
actual.mytext:=Edit3.Text;
actual.linecount:=StrToInt(Edit1.Text);
actual.lc:=ColorDialog1.Color;
label4.Caption:='Длина:'+inttostr(length(actual.mytext));
end;
procedure TForm1.TrackBar2Change(Sender: TObject);
begin
actual.y1:=TrackBar2.Position;
Form1.Refresh;
end;
procedure TForm1.TrackBar3Change(Sender: TObject);
begin
actual.x2:=TrackBar3.Position;
Form1.Refresh;
end;
procedure TForm1.TrackBar4Change(Sender: TObject);
begin
actual.y2:=TrackBar4.Position;
Form1.Refresh;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
Form1.Close;
end;
procedure saveini;
var
Ini: Tinifile;
i:Integer;
begin
try
If form1.opendialog1.execute then Ini:=TiniFile.Create(form1.opendialog1.filename);
Ini.WriteInteger('xy','x1',actual.x1);
Ini.WriteInteger('xy','y1',actual.y1);
Ini.WriteInteger('xy','x2',actual.x2);
Ini.WriteInteger('xy','y2',actual.y2);
Ini.WriteString('Mytext','String',actual.mytext);
Ini.WriteString('Mytext','Align',actual.align);
Ini.WriteInteger('Mytext','Linecount',actual.linecount);
Ini.WriteInteger('Mytext','Symbcount',actual.Symbcount);
Ini.WriteString('Colors','Forecolor',ColorToString(actual.lc));
Ini.Free;
except
actual.mytext:='```';
end;
end;
procedure openini;
var
Ini: Tinifile;
i,j:integer;
begin
try
begin
if form1.opendialog1.execute then Ini:=TiniFile.Create(form1.opendialog1.filename);
actual.x1:=Ini.ReadInteger('xy','x1',1);
actual.y1:=Ini.ReadInteger('xy','y1',1);
actual.x1:=Ini.ReadInteger('xy','x2',10);
actual.y1:=Ini.ReadInteger('xy','y2',10);
actual.mytext:=Ini.ReadString('Mytext','String','abrakadabra');
actual.align:=Ini.ReadString('Mytext','Align','left');
actual.linecount:=Ini.ReadInteger('Mytext','Linecount',1);
actual.symbcount:=Ini.ReadInteger('Mytext','Symbcount',1);
actual.lc:=StringToColor(Ini.ReadString('Colors','Forecolor','clGreen'));
Form1.TrackBar1.Position:=actual.x1;
Form1.TrackBar2.Position:=actual.y1;
Form1.TrackBar3.Position:=actual.x2;
Form1.TrackBar4.Position:=actual.y2;
Form1.Edit3.Text:=actual.mytext;
Form1.Edit1.Text:=IntToStr(actual.linecount);
if actual.align='left' then Form1.ComboBox2.ItemIndex:=0;
if actual.align='right' then Form1.ComboBox2.ItemIndex:=1;
if actual.align='center' then Form1.ComboBox2.ItemIndex:=2;
Form1.ColorDialog1.Color:=actual.lc;
Ini.Free;
end
except
actual.mytext:='error';
end;
Form1.Show;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
saveini;
end;
procedure TForm1.N6Click(Sender: TObject);
begin
Timer1.Enabled:=false;
end;
procedure TForm1.N7Click(Sender: TObject);
begin
Timer1.Enabled:=True;
end;
procedure TForm1.N8Click(Sender: TObject);
begin
Form1.Close;
end;
procedure TForm1.N3Click(Sender: TObject);
begin
openini;
end;
procedure bmpsave;
begin
try
if Form1.SaveDialog1.Execute then Form1.Image1.Picture.SaveToFile(Form1.SaveDialog1.FileName);
except
Form1.Image1.Picture.SaveToFile('default.bmp');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
bmpsave;
end;
procedure TForm1.BMP1Click(Sender: TObject);
begin
bmpsave;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
if ColorDialog1.Execute then actual.lc:=ColorDialog1.Color;
except
actual.lc:=clgreen;
end;
end;
procedure TForm1.Edit3Change(Sender: TObject);
begin
actual.mytext:=Edit3.Text;
end;
procedure TForm1.N5Click(Sender: TObject);
begin
Form1.Close;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
If OpenDialog1.Execute then begin mmo1.Lines.LoadFromFile(OpenDialog1.FileName); Edit3.Text:=mmo1.Text; actual.linecount:=mmo1.Lines.Count; actual.mytext:=Edit3.Text;end;
mmo1.Alignment:=taCenter;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
Form1.Refresh;
end;
end.