📄 umfprogramoptions.pas
字号:
{ JADD - Just Another DelphiDoc: Documentation from Delphi Source Code
Copyright (C) 2002-2008 Gerold Veith
This file is part of JADD - Just Another DelphiDoc.
DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
DelphiDoc 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 License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit UMFProgramOptions;
{Contains a page to edit the options of the program, these are only if some
file extensions are associated with it. }
interface
uses Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls,
UCommandParameters,
UMainFormFrame,
UJADDState;
type
{A page to edit the options of the program, these are only if some file
extensions are associated with it.}
TMFProgramOptions = class(TMainFormFrame)
private
{$IFNDEF LINUX}
//the labels showing the state of the associations of the file extensions
FStateLabels: array[TDelphiDocFile] of TLabel;
//Shows the state of the associations of the file extensions.
procedure ShowRegisterState;
//Called when one of the button to register the association of a file
//extension with this program is clicked.
procedure ButtonRegisterClicked(Sender: TObject);
//Called when one of the button to unregister the association of a file
//extension with this program is clicked.
procedure ButtonUnRegisterClicked(Sender: TObject);
{$ENDIF}
protected
public
//Creates the components and shows the state of the associations.
constructor Create(Parent: TWinControl; State: TJADDState); override;
end;
implementation
{$R *.dfm}
uses SysUtils;
{Creates the components and shows the state of the associations.
~param Parent the component to show the frame in, preferably a TPanel or a
similar component
~param State the state of the program }
constructor TMFProgramOptions.Create(Parent: TWinControl; State: TJADDState);
{$IFNDEF LINUX}
//vertical position to create new components at
var Top :Integer;
//horizontal position to create new components at
Left :Integer;
Kind :TDelphiDocFile; //counter through the file types
Button :TButton; //the buttons to be created
ALabel :TLabel; //the labels to be created
{$ENDIF}
begin
inherited Create(Parent, State); //create the frame
{$IFNDEF LINUX}
//create the components under the memo witht he decription of the page
Top := MemoDescription.Top + MemoDescription.Height + 15;
for Kind := Low(Kind) to High(Kind) do //for each file association
begin //create the sets of components
Button := TButton.Create(Self); //create button to register it
Button.Parent := PanelEditor;
Button.Left := 10;
Button.Top := Top;
Button.Caption := 'Register';
Button.Tag := Ord(Kind); //save the kind of the file
// Button.HelpContext := HelpContext + 1;
Button.OnClick := ButtonRegisterClicked;
Button := TButton.Create(Self); //and a button to unregister it
Button.Parent := PanelEditor;
Button.Left := 10;
Button.Top := Top + 30;
Button.Caption := 'Unregister';
Button.Tag := Ord(Kind); //save the kind of the file
// Button.HelpContext := HelpContext + 2;
Button.OnClick := ButtonUnRegisterClicked;
ALabel := TLabel.Create(Self); //show the file type
ALabel.Parent := PanelEditor;
ALabel.Left := 10 + 10 + Button.Width;
ALabel.Top := Top + (Button.Height - ALabel.Height) div 2;
ALabel.Caption := DelphiDocFiles[Kind].Extension + ' - ' +
DelphiDocFiles[Kind].Description;
ALabel := TLabel.Create(Self); //just a simple label
ALabel.Parent := PanelEditor;
ALabel.Left := 10 + 10 + Button.Width;
ALabel.Top := Button.Top + (Button.Height - ALabel.Height) div 2;
ALabel.Caption := 'Current State:';
Left := ALabel.Left + ALabel.Width;
ALabel := TLabel.Create(Self); //for state of the association
ALabel.Parent := PanelEditor;
ALabel.Left := 10 + Left;
ALabel.Top := Button.Top + (Button.Height - ALabel.Height) div 2;
ALabel.Caption := 'Unknown';
FStateLabels[Kind] := ALabel; //save label for the state
Inc(Top, 70); //position of next set
end;
ShowRegisterState; //show state of the association of the file extensions
{$ENDIF}
end;
{$IFNDEF LINUX}
{Shows the state of the associations of the file extensions. }
procedure TMFProgramOptions.ShowRegisterState;
var Kind :TDelphiDocFile; //counter through the file types
Text :String; //status text of the association
begin
Text := '';
for Kind := Low(Kind) to High(Kind) do //for each file type
begin
GetFileExtRegisterState(Kind, Text); //get the state
FStateLabels[Kind].Caption := Text; //and show it
end;
end;
{Called when one of the button to register the association of a file extension
with this program is clicked.
~param Sender the sender of the event, of of the created buttons }
procedure TMFProgramOptions.ButtonRegisterClicked(Sender: TObject);
begin
if (Sender is TComponent) and //tag has to be a valid file kind
(TComponent(Sender).Tag >= Ord(Low(TDelphiDocFile))) and
(TComponent(Sender).Tag <= Ord(High(TDelphiDocFile))) then
begin //register the file type
RegisterExtension(TDelphiDocFile(TComponent(Sender).Tag));
ShowRegisterState; //and update the state
end;
end;
{Called when one of the button to unregister the association of a file
extension with this program is clicked.
~param Sender the sender of the event, of of the created buttons }
procedure TMFProgramOptions.ButtonUnRegisterClicked(Sender: TObject);
begin
if (Sender is TComponent) and //tag has to be a valid file kind
(TComponent(Sender).Tag >= Ord(Low(TDelphiDocFile))) and
(TComponent(Sender).Tag <= Ord(High(TDelphiDocFile))) then
begin //unregister the file type
UnregisterExtension(TDelphiDocFile(TComponent(Sender).Tag));
ShowRegisterState; //and update the state
end;
end;
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -