- Code: Select all
procedure TMain.UpdateInf;
var
EditorExist, TempValue: Boolean;
I: Word;
L: Integer;
CurrEdit: THMemo;
begin
CurrEdit:=CurrentEditor;
if State=hsReady then
begin
EditorExist:=(CurrEdit <> nil);
if EditorExist then
begin
with Main do
begin
ActiveControl:=CurrentEditor;
Caption:='HTEL - ['+pcFiles.ActivePage.Caption+']';
if ClipBoardPreview<>nil then
ClipBoardPreview.cvClipboardPreview.Font:=CurrEdit.Font;
end;
if pcFiles.PageCount=1 then
pcFiles.HideAllTabs:=True
else
begin
pcFiles.HideAllTabs:=False;
pcFiles.TabStop:=True;
end;
end
else
begin
Main.Caption:=Application.Title;
end;
//--Actions-Update--------------------------------------------------------------
//File Actions
if EditorExist then
TempValue:=CurrEdit.Modified
else
TempValue:=False;
actFileSave.Enabled:=EditorExist and TempValue;
actFileSaveAs.Enabled:=EditorExist;
if EditorExist then
begin
for I:=0 to pcFiles.PageCount-1 do
begin
TempValue:=TempValue or (pcFiles.Pages[I].Controls[0] as THMemo).Modified
end;
end
else
TempValue:=True;
actFileSaveAll.Enabled:=EditorExist and TempValue;
actFileClose.Enabled:=EditorExist;
actFileCloseOthers.Enabled:=EditorExist and (pcFiles.PageCount>1);
actFileCloseAll.Enabled:=EditorExist and (pcFiles.PageCount>1);
actFileSendMail.Enabled:=EditorExist;
{ TODO 1 -oJohnny_Bit -cActions : Trza jeszcze popracować przy actFilePrint i actFilePrintPreviev }
actFilePrintPreview.Enabled:=EditorExist and (Printer.Printers.Count>0);
//Edit Actions
if EditorExist then
TempValue:=CurrEdit.CanUndo
else
TempValue:=False;
actEditUndo.Enabled:=EditorExist and TempValue;
if EditorExist then
TempValue:=CurrEdit.SelLength>0
else
TempValue:=False;
actEditCut.Enabled:=EditorExist and TempValue;
actEditCopy.Enabled:=EditorExist and TempValue;
actEditPaste.Enabled:=EditorExist and (Clipboard.HasFormat(CF_TEXT));
actEditDelete.Enabled:=EditorExist and TempValue;
if EditorExist then
TempValue:=Length(CurrEdit.Text)>0
else
TempValue:=False;
actEditSelectAll.Enabled:=EditorExist and TempValue;
actEditFont.Enabled:=EditorExist;
actEditWordWrap.Enabled:=EditorExist;
if EditorExist then
TempValue:=CurrEdit.WordWrap
else
TempValue:=False;
actEditWordWrap.Checked:=TempValue;
actEditUpperCase.Enabled:=EditorExist;
actEditLowerCase.Enabled:=EditorExist;
actEditFirstsUpperCase.Enabled:=EditorExist;
actEditWin1250.Enabled:=EditorExist;
actEditISO_8859_2.Enabled:=EditorExist;
//Search Actions
if EditorExist then
TempValue:=Length(CurrEdit.Text)>0
else
TempValue:=False;
actSearchFind.Enabled:=EditorExist and TempValue;
actSearchFindNext.Enabled:=actSearchFind.Enabled and (fdFind.FindText<>'');
actSearchReplace.Enabled:=EditorExist and TempValue;
//Insert Actions
actInsertStdDate.Enabled:=EditorExist;
actInsertStdTime.Enabled:=EditorExist;
actInsertStdDateTime.Enabled:=EditorExist;
actInsertUsrDate.Enabled:=EditorExist;
actInsertUsrTime.Enabled:=EditorExist;
actInsertUsrDateTime.Enabled:=EditorExist;
actInsertInFormat.Enabled:=EditorExist;
actInsertFromFile.Enabled:=EditorExist;
//Viev Actions
sbStatus.Visible:=EditorExist;
actViewStatusBar.Checked:=sbStatus.Visible;
actViewStatusBar.Enabled:=EditorExist;
cbTopBar.Visible:=tlbrToolbar.ButtonCount>0;
//Help Actions
{No Help Actions enabel/disable}
//--StatusBar-Update------------------------------------------------------------
with sbStatus do
if Visible then //Little optimalization hehe
begin
for I:=0 to Panels.Count-1 do
Panels[I].Text:='';
if EditorExist then
Panels[0].ImageIndex:=pcFiles.ActivePage.ImageIndex;
Panels[1].Text:=Format('Col: %d; Row: %d', [CurrEdit.CaretPos.X, CurrEdit.CaretPos.Y]);
L:=Length(CurrEdit.Text);
case L of
0..1024: Panels[2].Text:=Format('%d B', [L]);
1025..1048576: Panels[2].Text:=Format('%3.2f KB', [L/1024])
else
Panels[2].Text:=Format('%3.2f MB', [L/1048576]);
end;
Panels[4].MinWidth:=Canvas.TextWidth('INS')+10;
Panels[4].MaxWidth:=Canvas.TextWidth('INS')+10;
case ksKeys.Insert of
True : Panels[4].Text:='INS';
False: Panels[4].Text:='';
end;
Panels[5].MinWidth:=Canvas.TextWidth('NUM')+10;
Panels[5].MaxWidth:=Canvas.TextWidth('NUM')+10;
case ksKeys.Numlock of
True : Panels[5].Text:='NUM';
False: Panels[5].Text:='';
end;
Panels[6].MinWidth:=Canvas.TextWidth('CAPS')+10;
Panels[6].MaxWidth:=Canvas.TextWidth('CAPS')+10;
case ksKeys.Capslock of
True : Panels[6].Text:='CAPS';
False: Panels[6].Text:='';
end;
Panels[7].MinWidth:=Canvas.TextWidth('SCROLL')+10;
Panels[7].MaxWidth:=Canvas.TextWidth('SCROLL')+10;
case ksKeys.Scrolllock of
True : Panels[7].Text:='SCROLL';
False: Panels[7].Text:='';
end;
for I:=0 to Panels.Count-1 do
with Panels[I] do
if not (AutoSize or AutoWidth) then
Width:=Canvas.TextWidth(Text)+10;
end;
if EditorExist then
if State=hsReady then
begin
if FindDocMenuItem(THFileInf(CurrEdit.Tag))<>nil then
FindDocMenuItem(THFileInf(CurrEdit.Tag)).Checked:=True;
end;
end;
end;
Don't you think thats HUGE? well I think that's huge, and I know, that it doesn't to be in one procedure. I wan't to divide it into few other procedures but I don't know witch part goes to witch procedure.. I could divide it as it's divided by comments, but thats not the way (some of this stuff really shouldnt been taken away from others, others simply got to be used onece or twice in program... can you help me with this?