442 lines
13 KiB
ObjectPascal
442 lines
13 KiB
ObjectPascal
unit usetup;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ExtCtrls, StdCtrls, Spin, StrUtils, TntStdCtrls;
|
||
|
||
type
|
||
TForm2 = class(TForm)
|
||
Button1: TButton;
|
||
Button2: TButton;
|
||
Bevel1: TBevel;
|
||
fontpanel: TPanel;
|
||
Label3: TLabel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label6: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
ComboBox1: TComboBox;
|
||
SpinEdit1: TSpinEdit;
|
||
SpinEdit2: TSpinEdit;
|
||
tFontName: TComboBox;
|
||
RadioButton3: TRadioButton;
|
||
tFontsize: TSpinEdit;
|
||
RadioButton4: TRadioButton;
|
||
Panel1: TPanel;
|
||
Label7: TLabel;
|
||
Label8: TLabel;
|
||
Label_p: TTntLabel;
|
||
Edit1: TEdit;
|
||
ComboBox2: TComboBox;
|
||
bitmapPanel: TPanel;
|
||
Label10: TLabel;
|
||
Label11: TLabel;
|
||
Label12: TLabel;
|
||
SpinEdit3: TSpinEdit;
|
||
SpinEdit4: TSpinEdit;
|
||
Edit2: TEdit;
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure getfont;
|
||
procedure tFontNameChange(Sender: TObject);
|
||
procedure tFontsizeChange(Sender: TObject);
|
||
procedure RadioButton3Click(Sender: TObject);
|
||
procedure RadioButton4Click(Sender: TObject);
|
||
procedure Edit1Change(Sender: TObject);
|
||
procedure Button2Click(Sender: TObject);
|
||
procedure ComboBox2Change(Sender: TObject);
|
||
procedure Button1Click(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
|
||
private
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
Form2: TForm2;
|
||
|
||
implementation
|
||
uses umain;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TForm2.getfont;
|
||
var
|
||
k, n: integer;
|
||
s: TStringList;
|
||
begin
|
||
s := TStringList.Create;
|
||
s.AddStrings(Screen.Fonts);
|
||
n := s.Count;
|
||
for k := 0 to n - 1 do
|
||
begin
|
||
if AnsiContainsText(s.Strings[k], '@') = false then
|
||
begin
|
||
tFontName.Items.Add(s.Strings[k]);
|
||
end;
|
||
end;
|
||
s.Free;
|
||
tFontName.ItemIndex := tFontName.Items.IndexOf('Microsoft Sans Serif');
|
||
tFontsize.Value := 7;
|
||
end;
|
||
|
||
procedure TForm2.FormCreate(Sender: TObject);
|
||
var
|
||
i: integer;
|
||
begin
|
||
{ for i := 0 to 255 do
|
||
ComboBox1.Items.Add(inttostr(i));
|
||
ComboBox1.ItemIndex := 0;
|
||
|
||
|
||
for i := 0 to 255 do
|
||
ComboBox2.Items.Add(inttostr(i));
|
||
ComboBox2.ItemIndex := 0;
|
||
ComboBox2.Items.Add('All'); }
|
||
getfont;
|
||
|
||
|
||
{ for i := 0 to 255 do
|
||
TntComboBox1.Items.Add(chr(i));
|
||
TntComboBox1.ItemIndex := 0; }
|
||
|
||
tFontName.Enabled := true;
|
||
tFontsize.Enabled := true;
|
||
Edit1.Enabled := true;
|
||
ComboBox2.Enabled := true;
|
||
tFontsize.Color := clwhite;
|
||
tFontName.Color := clwhite;
|
||
Edit1.Color := clwhite;
|
||
ComboBox2.Color := clwhite;
|
||
tFontNameChange(sender);
|
||
end;
|
||
|
||
procedure TForm2.tFontNameChange(Sender: TObject);
|
||
begin
|
||
Label_p.Caption := Edit1.Text;
|
||
Label_p.Font.Name := tFontName.Text;
|
||
Label_p.Font.size := tFontsize.Value;
|
||
|
||
Label7.Caption := 'width:' + inttostr(Label_p.Width);
|
||
Label8.Caption := 'heihgt:' + inttostr(Label_p.height);
|
||
|
||
end;
|
||
|
||
procedure TForm2.tFontsizeChange(Sender: TObject);
|
||
begin
|
||
Label_p.Caption := edit1.Text;
|
||
Label_p.Font.Name := tFontName.Text;
|
||
Label_p.Font.size := tFontsize.Value;
|
||
|
||
Label7.Caption := 'width:' + inttostr(Label_p.Width);
|
||
Label8.Caption := 'heihgt:' + inttostr(Label_p.height);
|
||
end;
|
||
|
||
procedure TForm2.RadioButton3Click(Sender: TObject);
|
||
begin
|
||
ComboBox1.Enabled := false;
|
||
SpinEdit1.Enabled := false;
|
||
SpinEdit2.Enabled := false;
|
||
ComboBox1.Color := clBtnFace;
|
||
SpinEdit1.Color := clBtnFace;
|
||
SpinEdit2.Color := clBtnFace;
|
||
|
||
tFontName.Enabled := true;
|
||
tFontsize.Enabled := true;
|
||
Edit1.Enabled := true;
|
||
Edit1.Color := clwhite;
|
||
tFontsize.Color := clwhite;
|
||
tFontName.Color := clwhite;
|
||
ComboBox2.Enabled := true;
|
||
ComboBox2.Color := clwhite;
|
||
end;
|
||
|
||
procedure TForm2.RadioButton4Click(Sender: TObject);
|
||
begin
|
||
tFontName.Enabled := false;
|
||
tFontsize.Enabled := false;
|
||
Edit1.Enabled := false;
|
||
ComboBox2.Enabled := false;
|
||
ComboBox2.Color := clBtnFace;
|
||
tFontsize.Color := clBtnFace;
|
||
tFontName.Color := clBtnFace;
|
||
Edit1.Color := clBtnFace;
|
||
|
||
ComboBox1.Enabled := true;
|
||
SpinEdit1.Enabled := true;
|
||
SpinEdit2.Enabled := true;
|
||
ComboBox1.Color := clwhite;
|
||
SpinEdit1.Color := clwhite;
|
||
SpinEdit2.Color := clwhite;
|
||
end;
|
||
|
||
procedure TForm2.Edit1Change(Sender: TObject);
|
||
begin
|
||
Label_p.Caption := Edit1.Text;
|
||
Label_p.Font.Name := tFontName.Text;
|
||
Label_p.Font.size := tFontsize.Value;
|
||
|
||
Label7.Caption := 'width:' + inttostr(Label_p.Width);
|
||
Label8.Caption := 'heihgt:' + inttostr(Label_p.height);
|
||
end;
|
||
|
||
procedure TForm2.Button2Click(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TForm2.ComboBox2Change(Sender: TObject);
|
||
begin
|
||
{if ComboBox2.Text <> 'All' then
|
||
Edit1.Text := chr(ComboBox2.ItemIndex) else
|
||
Edit1.Text := ''; }
|
||
end;
|
||
|
||
procedure TForm2.Button1Click(Sender: TObject);
|
||
var
|
||
bmp: tbitmap;
|
||
i, w, h, co: integer;
|
||
begin
|
||
if fontpanel.Visible = true then
|
||
begin
|
||
Form1.editmode := 1;
|
||
Form1.StatusBar1.Panels[2].Text:='mode:font';
|
||
Form1.ToolButton1.Enabled:=true;
|
||
Form1.ToolButton7.Enabled:=true;
|
||
Form1.ToolButton8.Enabled:=false;
|
||
Form1.ToolButton10.Enabled:=false;
|
||
Form1.ToolButton11.Enabled:=false;
|
||
Form1.ToolButton18.Enabled:=False;
|
||
Form1.ToolButton19.Enabled:=False;
|
||
Form1.ToolButton20.Enabled:=False;
|
||
bmp := TBitmap.Create;
|
||
bmp.PixelFormat := pf4bit;
|
||
|
||
if RadioButton3.Checked then
|
||
begin
|
||
case ComboBox2.ItemIndex of
|
||
0: co := 128;
|
||
1: co := 256;
|
||
end;
|
||
Form1.AdvStringGrid2.RowCount := co + 1;
|
||
Form1.listcount := co;
|
||
bmp.Canvas.Font.Name := tFontName.Text;
|
||
bmp.Canvas.Font.Size := tFontsize.Value;
|
||
for i := 0 to co - 1 do
|
||
begin
|
||
w := bmp.Canvas.TextWidth(chr(i));
|
||
h := bmp.Canvas.TextHeight(chr(i));
|
||
Form1.fontlist[i].id := i;
|
||
Form1.fontlist[i].width := w;
|
||
Form1.fontlist[i].height := h;
|
||
|
||
if Form1.fontlist[i].bmplist <> nil then
|
||
Form1.fontlist[i].bmplist.Free;
|
||
|
||
Form1.fontlist[i].bmplist := TBitmap.Create;
|
||
Form1.fontlist[i].bmplist.PixelFormat := pf4bit;
|
||
Form1.fontlist[i].bmplist.Width := w;
|
||
Form1.fontlist[i].bmplist.height := h;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Color := clred;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Name := tFontName.Text;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Size := tFontsize.Value;
|
||
Form1.fontlist[i].bmplist.Canvas.Brush.Color := clblack;
|
||
Form1.fontlist[i].bmplist.Canvas.FillRect(Rect(0, 0, w, h));
|
||
Form1.fontlist[i].bmplist.Canvas.TextOut(0, 0, chr(i));
|
||
Form1.AdvStringGrid2.Cells[1, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[2, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[3, i + 1] := inttostr(w);
|
||
Form1.AdvStringGrid2.Cells[4, i + 1] := inttostr(h);
|
||
Form1.idlist.Add(chr(i) + '=' + inttostr(i));
|
||
end { else
|
||
begin
|
||
i := strtoint(ComboBox2.Text);
|
||
bmp.Canvas.Font.Name := tFontName.Text;
|
||
bmp.Canvas.Font.Size := tFontsize.Value;
|
||
w := bmp.Canvas.TextWidth(chr(i));
|
||
h := bmp.Canvas.TextHeight(chr(i));
|
||
Form1.fontlist[i].id := i;
|
||
Form1.fontlist[i].width := w;
|
||
Form1.fontlist[i].height := h;
|
||
|
||
if Form1.fontlist[i].bmplist <> nil then
|
||
Form1.fontlist[i].bmplist.Free;
|
||
|
||
Form1.fontlist[i].bmplist := TBitmap.Create;
|
||
Form1.fontlist[i].bmplist.PixelFormat := pf24bit;
|
||
Form1.fontlist[i].bmplist.Width := w;
|
||
Form1.fontlist[i].bmplist.height := h;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Color := clred;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Name := tFontName.Text;
|
||
Form1.fontlist[i].bmplist.Canvas.Font.Size := tFontsize.Value;
|
||
Form1.fontlist[i].bmplist.Canvas.Brush.Color := clblack;
|
||
Form1.fontlist[i].bmplist.Canvas.FillRect(Rect(0, 0, w, h));
|
||
Form1.fontlist[i].bmplist.Canvas.TextOut(0, 0, chr(i));
|
||
Form1.AdvStringGrid2.Cells[2, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[3, i + 1] := inttostr(w);
|
||
Form1.AdvStringGrid2.Cells[4, i + 1] := inttostr(h);
|
||
Form1.listcount := Form1.listcount + 1;
|
||
Form1.idlist.Strings[i] := inttostr(i);
|
||
end; }
|
||
end else
|
||
begin
|
||
case ComboBox1.ItemIndex of
|
||
0: co := 128;
|
||
1: co := 256;
|
||
end;
|
||
Form1.AdvStringGrid2.RowCount := co + 1;
|
||
Form1.listcount := co;
|
||
for i := 0 to co - 1 do
|
||
begin
|
||
w := SpinEdit1.Value;
|
||
h := SpinEdit2.Value;
|
||
Form1.fontlist[i].id := i;
|
||
Form1.fontlist[i].width := w;
|
||
Form1.fontlist[i].height := h;
|
||
|
||
if Form1.fontlist[i].bmplist <> nil then
|
||
Form1.fontlist[i].bmplist.Free;
|
||
|
||
Form1.fontlist[i].bmplist := TBitmap.Create;
|
||
Form1.fontlist[i].bmplist.PixelFormat := pf4bit;
|
||
Form1.fontlist[i].bmplist.Width := w;
|
||
Form1.fontlist[i].bmplist.height := h;
|
||
Form1.fontlist[i].bmplist.Canvas.Brush.Color := clblack;
|
||
Form1.fontlist[i].bmplist.Canvas.FillRect(Rect(0, 0, w, h));
|
||
Form1.AdvStringGrid2.Cells[1, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[2, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[3, i + 1] := inttostr(w);
|
||
Form1.AdvStringGrid2.Cells[4, i + 1] := inttostr(h);
|
||
Form1.idlist.Add(chr(i) + '=' + inttostr(i));
|
||
end { else
|
||
begin
|
||
i := strtoint(ComboBox1.text);
|
||
w := SpinEdit1.Value;
|
||
h := SpinEdit2.Value;
|
||
Form1.fontlist[i].id := i;
|
||
Form1.fontlist[i].width := w;
|
||
Form1.fontlist[i].height := h;
|
||
|
||
if Form1.fontlist[i].bmplist <> nil then
|
||
Form1.fontlist[i].bmplist.Free;
|
||
|
||
Form1.fontlist[i].bmplist := TBitmap.Create;
|
||
Form1.fontlist[i].bmplist.PixelFormat := pf4bit;
|
||
Form1.fontlist[i].bmplist.Width := w;
|
||
Form1.fontlist[i].bmplist.height := h;
|
||
Form1.fontlist[i].bmplist.Canvas.Brush.Color := clblack;
|
||
Form1.fontlist[i].bmplist.Canvas.FillRect(Rect(0, 0, w, h));
|
||
Form1.AdvStringGrid2.Cells[2, i + 1] := inttostr(i);
|
||
Form1.AdvStringGrid2.Cells[3, i + 1] := inttostr(w);
|
||
Form1.AdvStringGrid2.Cells[4, i + 1] := inttostr(h);
|
||
Form1.listcount := Form1.listcount + 1;
|
||
Form1.idlist.Strings[i] := inttostr(i);
|
||
end; }
|
||
end;
|
||
bmp.Free;
|
||
end else //<2F><><EFBFBD><EFBFBD>BMP
|
||
begin
|
||
if Trim(edit2.Text)='' then //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2>ܹ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
||
begin
|
||
ShowMessage('Please input your bitmap name!');
|
||
exit;
|
||
end;
|
||
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2>ܹ<EFBFBD>Ϊ<EFBFBD>ظ<EFBFBD>
|
||
if (Form1.bmpidlist.Count>0)and(Form1.bmpidlist.Values[edit2.Text]<>'') then
|
||
begin
|
||
ShowMessage('Please input exclusive bitmap name!');
|
||
edit2.Text:='';
|
||
exit;
|
||
end;
|
||
form1.editmode := 2;
|
||
Form1.StatusBar1.Panels[2].Text:='mode:bitmap';
|
||
Form1.ToolButton1.Enabled:=true;
|
||
Form1.ToolButton7.Enabled:=true;
|
||
Form1.ToolButton8.Enabled:=true;
|
||
Form1.ToolButton10.Enabled:=true;
|
||
Form1.ToolButton11.Enabled:=true;
|
||
Form1.ToolButton18.Enabled:=True;
|
||
Form1.ToolButton19.Enabled:=True;
|
||
Form1.ToolButton20.Enabled:=True;
|
||
|
||
|
||
if Form1.bmplistcount>0 then
|
||
Form1.AdvStringGrid2.RowCount:= Form1.AdvStringGrid2.RowCount+1;
|
||
|
||
bmp := TBitmap.Create;
|
||
bmp.PixelFormat := pf4bit;
|
||
|
||
co := Form1.bmplistcount;
|
||
setlength(Form1.bitmaplist, co+1);
|
||
Form1.bitmaplist[co].name := Edit2.Text;
|
||
Form1.bitmaplist[co].width := SpinEdit3.Value;
|
||
Form1.bitmaplist[co].height := SpinEdit4.Value;
|
||
|
||
if Form1.bitmaplist[co].bmplist <> nil then
|
||
Form1.bitmaplist[co].bmplist.Free;
|
||
|
||
Form1.bitmaplist[co].bmplist := TBitmap.Create;
|
||
Form1.bitmaplist[co].bmplist.PixelFormat := pf4bit;
|
||
Form1.bitmaplist[co].bmplist.Width := SpinEdit3.Value;
|
||
Form1.bitmaplist[co].bmplist.height := SpinEdit4.Value;
|
||
Form1.bitmaplist[co].bmplist.Canvas.Brush.Color := clblack;
|
||
Form1.bitmaplist[co].bmplist.Canvas.FillRect(Rect(0, 0, SpinEdit3.Value, SpinEdit4.Value));
|
||
Form1.AdvStringGrid2.Cells[2, co + 1] := Edit2.Text;
|
||
Form1.AdvStringGrid2.Cells[3, co + 1] := inttostr(SpinEdit3.Value);
|
||
Form1.AdvStringGrid2.Cells[4, co + 1] := inttostr(SpinEdit4.Value);
|
||
Form1.bmpidlist.Add(Edit2.Text+'='+inttostr(co));
|
||
Form1.bmplistcount:=Form1.bmplistcount+1;
|
||
end;
|
||
close;
|
||
end;
|
||
|
||
procedure TForm2.FormShow(Sender: TObject);
|
||
var
|
||
i, k: integer;
|
||
begin
|
||
{ComboBox1.Clear;
|
||
if Form1.idlist.Count > 0 then
|
||
begin
|
||
for i := 0 to 255 do
|
||
begin
|
||
if Form1.idlist.Strings[i] <> inttostr(i) then
|
||
ComboBox1.Items.Add(inttostr(i));
|
||
end;
|
||
ComboBox1.Items.Add('All');
|
||
ComboBox1.ItemIndex := 0;
|
||
|
||
ComboBox2.Clear;
|
||
for i := 0 to 255 do
|
||
begin
|
||
if Form1.idlist.Strings[i] <> inttostr(i) then
|
||
ComboBox2.Items.Add(inttostr(i));
|
||
end;
|
||
ComboBox2.Items.Add('All');
|
||
ComboBox2.ItemIndex := 0;
|
||
end else
|
||
begin
|
||
for i := 0 to 255 do
|
||
ComboBox1.Items.Add(inttostr(i));
|
||
ComboBox1.ItemIndex := 0;
|
||
ComboBox1.Items.Add('All');
|
||
|
||
for i := 0 to 255 do
|
||
ComboBox2.Items.Add(inttostr(i));
|
||
ComboBox2.ItemIndex := 0;
|
||
ComboBox2.Items.Add('All');
|
||
end; }
|
||
end;
|
||
|
||
procedure TForm2.Edit2KeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if (ord(key) > 128) then //<2F><><EFBFBD><EFBFBD>
|
||
key := #0;
|
||
end;
|
||
|
||
end.
|
||
|