Шрифт:
H4: result:= 'H4';
H5: result:= 'H5';
Sub: result:= ' S';
Poem: result:= ' P';
Citat: result:= ' C';
None: result:= '-';
end; // case
end;
function SetStyle1(n: TmyStyle):string;
begin
result:= ' '+ SetStyle(n)+'| ';
end;
procedure ChangeStyle(LStyle: TmyStyle);
var
n, curIndex: integer;
S: string;
begin
with Form1.ListBox1 do
begin
curIndex:= ItemIndex;
if curIndex = -1 then exit;
S:= Items[curIndex];
n:= pos('|', s);
delete(S, 1, n+1);
Items[curIndex]:= SetStyle1(LStyle)+ S;
if ItemIndex < Items.Count - 1
then ItemIndex:= ItemIndex+1;
SetFocus;
end;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
ChangeStyle(TmyStyle(RG.itemindex));
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Form3.ListBox1.Items.Assign(GenresBox.Items);
Form3.ShowModal;
if Form3.ModalResult = mrOK then
begin
GenresBox.Items.Assign(Form3.ListBox1.Items);
end;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
Form2.ListBox1.Items.Assign(ListBox3.Items);
Form2.Button1Click(nil);
Form2.ShowModal;
if Form2.ModalResult = mrOK then
begin
ListBox3.Items.Assign(Form2.ListBox1.Items);
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Form2.ListBox1.Items.Assign(ListBox2.Items);
Form2.Button1Click(nil);
Form2.ShowModal;
if Form2.ModalResult = mrOK then
begin
ListBox2.Items.Assign(Form2.ListBox1.Items);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
Path:= ExtractFileDir(ParamStr(0)) + '\';
OpenDialog1.InitialDir:= Path;
for i:= 0 to maxL do
SLang.Items.Add(Lg[i][2]);
SLang.ItemIndex:= 0;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if FileExists(Path + 'EndNotes.txt')
then EndNotesList.Items.LoadFromFile(Path + 'EndNotes.txt');
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
if FileExists(Path + 'Annotation.txt') then
Annotation.Lines.LoadFromFile(Path + 'Annotation.txt');
end;
function ScanUpStyle(n: integer):TmyStyle;
var
i: integer;
LStyle: TmyStyle;
begin
with Form1.ListBox1 do
for i:= n downto 0 do
begin
GetStyle(Items[i], LStyle);
if LStyle in [H1..H5] then
begin
result:= LStyle;
exit;
end;
end;
result:= H1;
end;
procedure ShowHeadStyle(n: integer);
var
LStyle: TmyStyle;
begin
LStyle:= ScanUpStyle(n);
Form1.Button2.Caption:= SetStyle(LStyle);
Form1.Button2.Tag:= integer(LStyle);
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
var
S: string;
CurStyle: TmyStyle;
i, st: integer;
begin
st:= ListBox1.itemIndex;
S:= GetStyle(ListBox1.Items[st], CurStyle);
with EditSt do
begin
Memo1.WordWrap:= true;
Memo1.Clear;
Memo1.Lines.Add(S);
ShowModal;
if ModalResult = mrOK then
begin
ListBox1.Items.Delete(st);
Memo1.WordWrap:= false;
for i:= Memo1.Lines.Count - 1 downto 0 do
ListBox1.Items.Insert(st, SetStyle1(CurStyle)+Memo1.Lines[i]);
end;
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
ShowHeadStyle(ListBox1.itemIndex);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ChangeStyle(TmyStyle(Button2.Tag));