mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 07:19:35 +02:00
+ initial implementation
This commit is contained in:
parent
089c57f91c
commit
32c9496a2f
13
utils/fpdoc/fpde/fpde.pp
Normal file
13
utils/fpdoc/fpde/fpde.pp
Normal file
@ -0,0 +1,13 @@
|
||||
program fpde;
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
{ $apptype gui}
|
||||
|
||||
uses fpgtk,fpglib,fpgtkext,frmmain,pgeditor;
|
||||
|
||||
begin
|
||||
application := TFPgtkApplication.Create;
|
||||
application.MainWindow := TMainForm.Create;
|
||||
application.Run;
|
||||
application.Free;
|
||||
end.
|
142
utils/fpdoc/fpde/fpdemsg.pp
Normal file
142
utils/fpdoc/fpde/fpdemsg.pp
Normal file
@ -0,0 +1,142 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit fpdemsg;
|
||||
|
||||
interface
|
||||
|
||||
ResourceString
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Strings which appear in the program
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
|
||||
SFPDE = 'Free Pascal documentation editor';
|
||||
SName = 'Name';
|
||||
SOK = ' OK ';
|
||||
SCancel = ' Cancel ';
|
||||
SNewDocument = 'New document';
|
||||
SNew = 'New';
|
||||
SInsertLink = 'Insert link';
|
||||
SInsertTable = 'Insert table';
|
||||
SForFile = ' in file ';
|
||||
SForPackage = ' in package ';
|
||||
SForModule = ' in module ';
|
||||
SLinkTarget = 'Link target';
|
||||
SLinkText = 'Link text';
|
||||
STableRows = 'Rows';
|
||||
STableCols = 'Columns';
|
||||
STableHeader = 'Use header row';
|
||||
SFileModified = 'Document "%s" was modified, would you like to save it?';
|
||||
SDeletePackage = 'Are you sure you want to delete package "%s" ?';
|
||||
SDeleteModule = 'Are you sure you want to delete module "%s" ?';
|
||||
SDeleteElement = 'Are you sure you want to delete element "%s" ?';
|
||||
SRenamePackage = 'Rename package';
|
||||
SRenameModule = 'Rename module';
|
||||
SRenameElement = 'Rename element';
|
||||
SNoElement = 'No element selected';
|
||||
SDataForElement = 'Documentation for element "%s":';
|
||||
SShortDescription = 'Short';
|
||||
SDescription = 'Description';
|
||||
SErrors = 'Errors';
|
||||
SSeeAlso = 'See Also';
|
||||
SMakeSkelFromSource = 'Make new document from source file';
|
||||
SSkelErrorWithFile = 'makeskel reported an error (%d). Try to load produced file anyway ?';
|
||||
SSkelErrorWithoutFile = 'makeskel reported an error (%d) and produced no file.';
|
||||
SOptConfirmDelete = 'Confirm node deletion';
|
||||
SOptCreateBackup = 'Backup existing files';
|
||||
SOptSkipEmptyNodes = 'Do not create empty nodes';
|
||||
SOptBackupExtension = 'Backup file extension';
|
||||
SOptDefaultExtension = 'Default extension for new files';
|
||||
SOptMaxRecentUsed = 'Items in MRU list';
|
||||
SAboutText = 'fpdoc editor 1.0'#10'(c) 2002 Michael Van Canneyt'#10+
|
||||
'See http://www.freepascal.org/';
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Menu strings
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
SMenuOpen = '_Open';
|
||||
SMenuNew = '_New';
|
||||
SMenuNewFromSource = 'New from so_urce';
|
||||
SMenuSave = '_Save';
|
||||
SMenuSaveAs = 'Save _as';
|
||||
SMenuRecent = '_Recent';
|
||||
SMenuClose = '_Close';
|
||||
SMenuExit = 'E_xit';
|
||||
SMenuFile = 'File';
|
||||
|
||||
SMenuInsert = 'Insert';
|
||||
SMenuInsertPackage = '_Package';
|
||||
SMenuInsertModule = '_Module';
|
||||
SMenuInsertElement = '_Element';
|
||||
SMenuInsertLink = '_Link';
|
||||
SMenuInsertTable = '_Table';
|
||||
|
||||
SMenuFormat = 'Format';
|
||||
SMenuFormatBold = '_Bold';
|
||||
SMenuFormatUnderLine = '_Underline';
|
||||
SMenuFormatItalics = '_Italic';
|
||||
SMenuformatVariable = '_Variable';
|
||||
SMenuFormatRemark = '_Remark';
|
||||
SMenuFormatParaGraph = '_Paragraph';
|
||||
SMenuFormatCode = '_Code';
|
||||
SMenuFormatFile = '_File';
|
||||
|
||||
SMenuRename = 'Rename';
|
||||
SMenuDelete = 'Delete';
|
||||
|
||||
SMenuExtra = 'Extra';
|
||||
SMenuExtraoptions = 'Options';
|
||||
|
||||
SMenuHelp = 'Help';
|
||||
SMenuHelpAbout = 'About';
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Hint strings
|
||||
---------------------------------------------------------------------}
|
||||
SHintFileNew = 'New file';
|
||||
SHintFileOpen = 'Open file';
|
||||
SHintFileSave = 'Save file';
|
||||
SHintFileSaveAs = 'Save file as';
|
||||
|
||||
SHintInsertPackage = 'New package';
|
||||
SHintInsertModule = 'New module';
|
||||
SHintInsertElement = 'New element';
|
||||
SHintInsertLink = 'Insert link';
|
||||
ShintInsertTable = 'Insert table';
|
||||
|
||||
SMarkSelection = 'Mark selection %s';
|
||||
|
||||
SHMenuExtraOptions = 'Show options dialog';
|
||||
SHMenuHelpAbout = 'About this program';
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Error messages.
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
|
||||
SErrNoPackageForModule = 'No package found to insert module "%s"';
|
||||
SErrNoNodeForPackage = 'No node found for package "%s"';
|
||||
SErrNoNodeForModule = 'No node found for module "%s"';
|
||||
SErrNoModuleForElement = 'No module found to insert element "%s"';
|
||||
SErrNoNodeForElement = 'No node found for element "%s"';
|
||||
|
||||
|
||||
SSaveFileTitle = 'Enter filename to save to';
|
||||
SOpenFileTitle = 'Select file to open';
|
||||
|
||||
Function FormatHint(S : String) : String;
|
||||
|
||||
implementation
|
||||
|
||||
uses sysutils;
|
||||
|
||||
Function FormatHint(S : String) : String;
|
||||
|
||||
begin
|
||||
Result:=Format(SMarkSelection,[S]);
|
||||
end;
|
||||
|
||||
end.
|
103
utils/fpdoc/fpde/fpdeopts.pp
Normal file
103
utils/fpdoc/fpde/fpdeopts.pp
Normal file
@ -0,0 +1,103 @@
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
unit fpdeopts;
|
||||
|
||||
Interface
|
||||
|
||||
uses SysUtils,IniFiles;
|
||||
|
||||
Var
|
||||
SkipEmptyNodes : Boolean;
|
||||
ConfirmDelete : Boolean;
|
||||
CreateBackup : Boolean;
|
||||
MaxRecentUsed : Integer;
|
||||
BackupExtension : String;
|
||||
DefaultExtension : String;
|
||||
|
||||
Procedure LoadOptions;
|
||||
Procedure SaveOptions;
|
||||
Function GetOptionFileName : String;
|
||||
|
||||
Implementation
|
||||
|
||||
Const
|
||||
DefFilename = 'fpde.ini';
|
||||
SecPrefs = 'Preferences';
|
||||
KeySkipEmptyNodes = 'SkipEmptyNodes';
|
||||
KeyConfirmDelete = 'ConfirmDelete';
|
||||
KeyCreateBackup = 'CreateBackup';
|
||||
KeyBackupExtension = 'BackupExtension';
|
||||
KeyDefaultExtension = 'DefaultExtension';
|
||||
KeyMaxRecentUsed = 'MaxMRUitems';
|
||||
|
||||
{$ifndef win32}
|
||||
Function GetOptionFileName : String;
|
||||
|
||||
Const
|
||||
fpdedir = '.fpde';
|
||||
|
||||
Var
|
||||
HomeDir : String;
|
||||
|
||||
begin
|
||||
HomeDir:=GetEnvironmentVariable('HOME');
|
||||
If (HomeDir<>'') then
|
||||
begin
|
||||
HomeDir:=IncludeTrailingPathDelimiter(HomeDir)+fpdedir;
|
||||
If not DirectoryExists(HomeDir) then
|
||||
If Not CreateDir(HomeDir) then
|
||||
HomeDir:=''
|
||||
else
|
||||
HomeDir:=HomeDir;
|
||||
end;
|
||||
Result:=IncludeTrailingPathDelimiter(HomeDir)+DefFileName;
|
||||
end;
|
||||
|
||||
{$else}
|
||||
|
||||
Function GetOptionFileName : String;
|
||||
|
||||
begin
|
||||
Result:=ExtractFilePath(Paramstr(0))+DefFileName;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
Procedure LoadOptions;
|
||||
|
||||
begin
|
||||
With TInifile.Create(GetOptionFileName) do
|
||||
Try
|
||||
SkipEmptyNodes:=ReadBool(SecPrefs,KeySkipEmptyNodes,SkipEmptyNodes);
|
||||
ConfirmDelete:=ReadBool(SecPrefs,KeyConfirmDelete,ConfirmDelete);
|
||||
CreateBackup:=ReadBool(SecPrefs,KeyCreateBackup,CreateBackup);
|
||||
BackupExtension:=ReadString(SecPrefs,KeyBackupExtension,BackupExtension);
|
||||
DefaultExtension:=ReadString(SecPrefs,KeyDefaultExtension,DefaultExtension);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure SaveOptions;
|
||||
|
||||
begin
|
||||
With TInifile.Create(GetOptionFileName) do
|
||||
Try
|
||||
WriteBool(SecPrefs,KeySkipEmptyNodes,SkipEmptyNodes);
|
||||
WriteBool(SecPrefs,KeyConfirmDelete,ConfirmDelete);
|
||||
WriteBool(SecPrefs,KeyCreateBackup,CreateBackup);
|
||||
WriteString(SecPrefs,KeyBackupExtension,BackupExtension);
|
||||
WriteString(SecPrefs,KeyDefaultExtension,DefaultExtension);
|
||||
UpdateFile;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Initialization
|
||||
SkipEmptyNodes := True;
|
||||
ConfirmDelete := True;
|
||||
CreateBackup := True;
|
||||
BackupExtension := '.~xml';
|
||||
DefaultExtension := '.xml';
|
||||
MaxRecentUSed := 10;
|
||||
end.
|
60
utils/fpdoc/fpde/frmabout.pp
Normal file
60
utils/fpdoc/fpde/frmabout.pp
Normal file
@ -0,0 +1,60 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmabout;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TAboutForm = Class (TFPGtkWindow)
|
||||
FAboutText : TFPGtkLabel;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
uses fpdemsg;
|
||||
|
||||
Constructor TAboutForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Procedure TAboutForm.CreateWindow;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// About text
|
||||
FAboutText:=TFPgtkLabel.Create(SAboutText);
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FAboutText,True,True,0);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end.
|
86
utils/fpdoc/fpde/frmlink.pp
Normal file
86
utils/fpdoc/fpde/frmlink.pp
Normal file
@ -0,0 +1,86 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmlink;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TLinkForm = Class (TFPGtkWindow)
|
||||
FTable : TFPGtkTable;
|
||||
FLLinkTarget,
|
||||
FLLinkText : TFPGtkLabel;
|
||||
FLinkText : TFPGtkEntry;
|
||||
FLinkTarget : TFPGtkCombo;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
uses fpdemsg;
|
||||
|
||||
Constructor TLinkForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Procedure TLinkForm.CreateWindow;
|
||||
|
||||
Var
|
||||
OH,OV : TgtkAttachOPtions;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// Table area
|
||||
FTable:=TFPGtkTable.Create(2,2);
|
||||
FLLinktarget:=TFPGtkLabel.Create(SLinkTarget);
|
||||
FLLinktarget.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FLLinkText:=TFPGtkLabel.Create(SLinkText);
|
||||
FLLinktext.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FLinkText:=TFPgtkEntry.Create;
|
||||
FlinkTarget:=TFPGtkCombo.Create;
|
||||
OH:=GTK_EXPAND or GTK_FILL;
|
||||
FTable.Attach(FLLinkTarget,0,1,0,1,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FLLinkText,0,1,1,2,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FLinkTarget,1,2,0,1,OH,0,4,4);
|
||||
FTable.Attach(FLinkText,1,2,1,2,OH,0,4,4);
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FTable,False,False,0);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
// Some events;
|
||||
ConnectShow(@OnShow,Nil);
|
||||
end;
|
||||
|
||||
Procedure TLinkForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
FocusedWidget(FLinkTarget.entry);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
888
utils/fpdoc/fpde/frmmain.pp
Normal file
888
utils/fpdoc/fpde/frmmain.pp
Normal file
@ -0,0 +1,888 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
unit frmmain;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
gtk,gdk,fpgtk,fpgtkext,pgEditor,frmlink,sysutils,classes,fpdeopts;
|
||||
|
||||
Const
|
||||
DefaultTooltips = True;
|
||||
DefaultToolBarStyle = GTK_TOOLBAR_ICONS;
|
||||
DefaultToolbarRelief = GTK_RELIEF_NONE;
|
||||
SFileTemplate = 'template.xml';
|
||||
|
||||
Type
|
||||
TNodeType = (ntfile,ntPackage,ntModule,ntElement);
|
||||
|
||||
TMainForm = Class(TFPGtkWindow)
|
||||
Private
|
||||
FRecent : TStrings;
|
||||
FPages : TFPGtkNoteBook;
|
||||
FVBox : TFPGTKVBox;
|
||||
FMenu : TFpGTKMenuBar;
|
||||
FNewImage,
|
||||
FOpenImage,
|
||||
FSaveImage,
|
||||
FSaveAsImage,
|
||||
FNewPackageImage,
|
||||
FNewModuleImage,
|
||||
FNewElementImage,
|
||||
FBoldImage,
|
||||
FUnderlineImage,
|
||||
FItalicsImage,
|
||||
FParagraphImage,
|
||||
FVarImage,
|
||||
FLinkImage,
|
||||
FRemarkImage,
|
||||
FTableImage : TFPGtkPixmap;
|
||||
FHelpMenu,
|
||||
FExtraMenu,
|
||||
FInsertMenu,
|
||||
FFormatMenu,
|
||||
FFileMenu : TFPGtkMenuItem;
|
||||
FToolbarFrame : TFPGtkFrame;
|
||||
FFormatToolBar,
|
||||
FToolsToolBar,
|
||||
FMainToolBar : TFPGtkToolbar;
|
||||
FFileOpen,
|
||||
FFileNew,
|
||||
FFileNewFromFile,
|
||||
FFileSave,
|
||||
FFileSaveAs,
|
||||
FFileRecent,
|
||||
FFileClose,
|
||||
FFileExit,
|
||||
FInsertPackage,
|
||||
FInsertModule,
|
||||
FInsertElement,
|
||||
FInsertLink,
|
||||
FInsertTable,
|
||||
FFormatParagraph,
|
||||
FFormatBold,
|
||||
FFormatItalic,
|
||||
FFormatUnderline,
|
||||
FFormatRemark,
|
||||
FFormatVariable,
|
||||
FFormatCode,
|
||||
FFormatFile,
|
||||
FExtraoptions,
|
||||
FHelpAbout : TFPGtkMenuItem;
|
||||
// Utility functions
|
||||
Function FormatMenuItem(ACaption : String; tt : TTagType) : TFPgtkMenuItem;
|
||||
Function FormatMenuItem(ACaption : String; tt : TTagType; Accel : PAccelKeyDef) : TFPgtkMenuItem;
|
||||
// Editor functions.
|
||||
procedure BuildReopenList;
|
||||
Procedure AddTorecent(FN : String);
|
||||
Procedure OpenFile(FN : String);
|
||||
Procedure SaveEditorAs(E : TEditorPage);
|
||||
Procedure SaveEditor(E : TEditorPage);
|
||||
Function CloseEditor(E : TEditorPage) : Boolean;
|
||||
Procedure LoadRecent;
|
||||
Procedure SaveRecent;
|
||||
Procedure CreateForm;
|
||||
Function CreatePage : TEditorPage;
|
||||
Function Currenteditor : TEditorPage;
|
||||
Function AllowClose : Boolean;
|
||||
// Callbacks
|
||||
Procedure TagClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileReopen(Sender: TFPGTKObject;data : Pointer);
|
||||
Procedure FileOpenClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileNewClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileNewFromFileClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileSaveAsClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileSaveClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileExitClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure FileCloseClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure OptionsClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure HelpAboutClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure InsertNodeClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure LinkClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure TableClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
Procedure GetLinkData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
Procedure GetTableData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
Procedure GetNodeData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
Procedure GetSkeletonData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
Procedure DialogSetFilename(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
Function OnDeleteEvent(Sender:TFPgtkWidget; Event:PGdkEvent; data:pointer): boolean;
|
||||
Public
|
||||
Constructor create;
|
||||
Destructor Destroy; override;
|
||||
end;
|
||||
|
||||
Const
|
||||
NodeNames : Array[TNodeType] of String
|
||||
= ('file','package','module','element');
|
||||
|
||||
implementation
|
||||
|
||||
uses fpdemsg,frmnewnode,frmtable,frmmakeskel,process,frmOptions,frmAbout,inifiles,xpms;
|
||||
|
||||
|
||||
Function TMainForm.CreatePage : TEditorPage;
|
||||
|
||||
begin
|
||||
Result:=TEditorPage.Create;
|
||||
Result.FileNameLabel:=TFPgtkLabel.Create(SNewDocument);
|
||||
FPages.AppendPage(Result, REsult.FileNameLabel);
|
||||
FPages.Page:=Result;
|
||||
end;
|
||||
|
||||
Function PixmapFromFile (FN : String; Const ImgArray : Array of string) :TFPGtkPixmap;
|
||||
|
||||
begin
|
||||
Result:=TFPGtkPixmap.CReate;
|
||||
{$ifdef debug}
|
||||
writeln('loading ','bitmaps'+directoryseparator+FN);
|
||||
{$endif}
|
||||
If FileExists('bitmaps'+directoryseparator+FN) then
|
||||
Result.LoadFromFile('bitmaps'+directoryseparator+FN)
|
||||
else
|
||||
Result.loadFromArray(ImgArray);
|
||||
|
||||
end;
|
||||
|
||||
Function TMainForm.FormatMenuItem(ACaption : String; tt : TTagType) : TFPgtkMenuItem;
|
||||
|
||||
begin
|
||||
Result:=NewMenuItem(ACaption,FormatHint(ACaption),'',@TagClick,Pointer(tt));
|
||||
end;
|
||||
|
||||
Function TMainForm.FormatMenuItem(ACaption : String; tt : TTagType; Accel : PAccelKeyDef) : TFPgtkMenuItem;
|
||||
|
||||
begin
|
||||
Result:=NewMenuItem(ACaption,FormatHint(ACaption),'',Accel,@TagClick,Pointer(tt));
|
||||
end;
|
||||
|
||||
Procedure TMainForm.CreateForm;
|
||||
|
||||
Var
|
||||
V : TFPGtkHBox;
|
||||
FAccelGroup: Integer;
|
||||
|
||||
begin
|
||||
Title:=SFPDE;
|
||||
FAccelGroup:=AccelGroupNew;
|
||||
{ File menu }
|
||||
{$ifdef debug}
|
||||
Writeln('Menu');
|
||||
{$endif}
|
||||
//anAG : integer; aKey : guint; aMods
|
||||
FFileOpen:=NewMenuItem(SMenuOpen,'','',MakeAccelKeyDef(Self,FaccelGroup,GDK_O,[amcontrol]),@FileOpenClick,Nil);
|
||||
FFileNew:=NewMenuItem(SMenuNew,'','',MakeAccelKeyDef(Self,FaccelGroup,GDK_N,[amcontrol]),@FileNewClick,Nil);
|
||||
FFileNewFromFile:=NewMenuItem(SMenuNewFromSource,'','',@FileNewFromFileClick,Nil);
|
||||
FFileSave:=NewMenuItem(SMenuSave,'','',MakeAccelKeyDef(Self,FaccelGroup,GDK_S,[amcontrol]),@FileSaveClick,Nil);
|
||||
FFileSaveAs:=NewMenuItem(SMenuSaveAs,'','',@FileSaveAsClick,Nil);
|
||||
FFileRecent:=NewSubMenu(SMenuRecent,'','',[]);
|
||||
FFileClose:=NewMenuItem(SMenuClose,'','',MakeAccelKeyDef(Self,FaccelGroup,GDK_W,[amcontrol]),@FileCLoseClick,Nil);
|
||||
FFileExit:=NewMenuItem(SMenuExit,'','',MakeAccelKeyDef(Self,FaccelGroup,GDK_Q,[amcontrol]),@FileExitClick,Nil);
|
||||
FFileMenu:=NewSubMenu(SMenuFile,'','',[FFileNew,FFileNewFromFile,FFileOpen,FFileRecent,FFileSave,FFileSaveAs,FFileClose,NewLine,FFileExit]);
|
||||
|
||||
{ Insert menu }
|
||||
FInsertPackage:=NewMenuItem(SMenuInsertPackage,SHintInsertPackage,'',MakeAccelKeyDef(Self,FaccelGroup,GDK_P,[amcontrol]),@InsertNodeClick,Pointer(ntpackage));
|
||||
FInsertModule:=NewMenuItem(SMenuInsertModule,SHintInsertModule,'',MakeAccelKeyDef(Self,FaccelGroup,GDK_M,[amcontrol]),@InsertNodeClick,Pointer(ntmodule));
|
||||
FInsertElement:=NewMenuItem(SMenuInsertElement,SHintInsertElement,'',MakeAccelKeyDef(Self,FaccelGroup,GDK_E,[amcontrol]),@InsertNodeClick,Pointer(ntElement));
|
||||
FinsertLink:=NewMenuItem(SMenuInsertLink,SHintInsertLink,'',MakeAccelKeyDef(Self,FaccelGroup,GDK_L,[amcontrol]),@LinkClick,Nil);
|
||||
FinsertTable:=NewMenuItem(SMenuInsertTable,SHintInsertTable,'',MakeAccelKeyDef(Self,FaccelGroup,GDK_T,[amcontrol]),@TableClick,Nil);
|
||||
FInsertMenu:=NewSubMenu(SMenuInsert,'','',[FInsertPackage,FInsertModule,FInsertElement,NewLine,FInsertLink,FinsertTable]);
|
||||
|
||||
{ Format menu }
|
||||
|
||||
FFormatBold:=FormatMenuItem(SMenuFormatBold,ttBold,MakeAccelKeyDef(Self,FaccelGroup,GDK_B,[amcontrol]));
|
||||
FFormatItalic:=FormatMenuItem(SMenuFormatItalics,ttItalic,MakeAccelKeyDef(Self,FaccelGroup,GDK_I,[amcontrol]));
|
||||
FFormatUnderline:=FormatMenuItem(SMenuFormatUnderline,ttUnderline,MakeAccelKeyDef(Self,FaccelGroup,GDK_U,[amcontrol]));
|
||||
FFormatVariable:=FormatMenuItem(SMenuFormatVariable,ttVariable);
|
||||
FFormatFile:=FormatMenuItem(SMenuFormatFile,ttFile);
|
||||
FFormatParagraph:=FormatMenuItem(SMenuFormatParagraph,ttParagraph);
|
||||
FFormatRemark:=FormatMenuItem(SMenuFormatRemark,ttRemark);
|
||||
FFormatCode:=FormatMenuItem(SMenuFormatCode,ttCode);
|
||||
FFormatMenu:=NewSubMenu(SMenuFormat,'','',[FFormatBold,FFormatItalic,FFormatUnderline,FFormatVariable,FFormatFile,
|
||||
NewLine,FFormatParagraph,FFormatRemark,FFormatCode]);
|
||||
|
||||
{ Extra menu }
|
||||
FExtraOptions:=NewMenuItem(SMenuExtraOptions,SHMenuExtraOptions,'',@OptionsClick,Nil);
|
||||
FExtraMenu:=NewSubMenu(SMenuExtra,'','',[FExtraOptions]);
|
||||
|
||||
{ Help menu }
|
||||
FHelpAbout:=NewMenuItem(SMenuHelpAbout,SHMenuHelpAbout,'',@HelpAboutClick,Nil);
|
||||
FHelpMenu:=NewSubMenu(SMenuHelp,'','',[FHelpAbout]);
|
||||
|
||||
FMenu:=NewMenuBar([FFileMenu,FInsertMenu,FFormatMenu,FExtraMenu,FHelpMenu]);
|
||||
{$ifdef debug}
|
||||
Writeln('Toolbar pixmaps');
|
||||
{$endif}
|
||||
|
||||
{ Tool bar bitmaps }
|
||||
FNewImage:=PixMapFromFile('new.xpm',ImgNew);
|
||||
FOpenImage:=PixmapFromFile('open.xpm',ImgOpen);
|
||||
FSaveImage:=PixmapFromFile('save.xpm',ImgSave);
|
||||
FSaveAsImage:=PixMapFromFile('saveas.xpm',ImgSaveAs);
|
||||
FNewPackageImage:=PixMapFromFile('newpackage.xpm',ImgNewPackage);
|
||||
FNewModuleImage:=PixMapFromFile('newmodule.xpm',ImgNewModule);
|
||||
FNewElementImage:=PixMapFromFile('newelement.xpm',ImgNewElement);
|
||||
FBoldImage:=PixMapFromFile('bold.xpm',ImgBold);
|
||||
FUnderlineImage:=PixMapFromFile('underline.xpm',ImgUnderline);
|
||||
FItalicsImage:=PixMapFromFile('italic.xpm',ImgItalic);
|
||||
FParagraphImage:=PixMapFromFile('para.xpm',ImgPara);
|
||||
FVarImage:=PixMapFromFile('var.xpm',ImgVar);
|
||||
FRemarkImage:=PixMapFromFile('remark.xpm',ImgRemark);
|
||||
FLinkImage:=PixMapFromFile('link.xpm',ImgLink);
|
||||
FTableImage:=PixMapFromFile('table.xpm',ImgTable);
|
||||
|
||||
{ Tool bars }
|
||||
{$ifdef debug}
|
||||
Writeln('Main toolbar');
|
||||
{$endif}
|
||||
|
||||
FMainToolBar:=TFPGtkToolbar.Create;
|
||||
With FMainToolbar do
|
||||
begin
|
||||
Style:=DefaultToolbarStyle;
|
||||
ButtonRelief:=DefaultToolbarRelief;
|
||||
EnableTooltips:=DefaultTooltips;
|
||||
// AppendElement (ButtonType:TGtkToolbarChildType; PrevRadioBut:TFPgtkWidget; Text:string; TooltipText:string; TooltipPrivate:string; Icon:TFPgtkWidget; CallBack:TFPgtkSignalProcedure; data:pointer) : TFPgtkWidget;
|
||||
AppendItem(SMenuNew,SHintFileNew,'',FNewImage,@FileNewClick,Nil);
|
||||
AppendItem(SMenuOpen,SHintFileOpen,'',FOpenImage,@FileOpenClick,Nil);
|
||||
AppendItem(SmenuSave,SHintFileSave,'',FSaveImage,@FileSaveClick,Nil);
|
||||
AppendItem(SMenuSaveAs,SHintFileSaveAs,'',FSaveAsImage,@FileSaveAsClick,Nil);
|
||||
AppendSpace;
|
||||
AppendItem(SMenuInsertPackage,SHintInsertPackage,'',FNewPackageImage,@InsertNodeClick,Pointer(ntPackage));
|
||||
AppendItem(SMenuInsertModule,SHintInsertModule,'',FNewModuleImage,@InsertNodeClick,Pointer(ntModule));
|
||||
AppendItem(SMenuInsertEleMent,SHintInsertElement,'',FNewElementImage,@InsertNodeClick,Pointer(ntElement));
|
||||
AppendSpace;
|
||||
end;
|
||||
{$ifdef debug}
|
||||
Writeln('Format Toolbars');
|
||||
{$endif}
|
||||
|
||||
FFormatToolBar:=TFPGtkToolbar.Create;
|
||||
With FFormatToolbar do
|
||||
begin
|
||||
Style:=DefaultToolBarStyle;
|
||||
ButtonRelief:=DefaultToolbarRelief;
|
||||
EnableTooltips:=DefaultTooltips;
|
||||
AppendItem(SMenuFormatParaGraph,Format(SMarkSelection,[SMenuFormatParaGraph]),'',FParagraphImage,@TagClick,Pointer(ttParagraph));
|
||||
AppendItem(SMenuFormatBold,Format(SMarkSelection,[SMenuFormatBold]),'',FBoldImage,@TagClick,Pointer(ttBold));
|
||||
AppendItem(SMenuFormatItalics,Format(SMarkSelection,[SMenuFormatItalics]),'',FItalicsImage,@TagClick,Pointer(ttItalic));
|
||||
AppendItem(SMenuFormatUnderline,Format(SMarkSelection,[SMenuFormatUnderline]),'',FUnderlineImage,@TagClick,Pointer(ttUnderline));
|
||||
AppendItem(SMenuFormatVariable,Format(SMarkSelection,[SMenuFormatVariable]),'',FVarImage,@TagClick,Pointer(ttVariable));
|
||||
AppendItem(SmenuFormatRemark,Format(SMarkSelection,[SmenuFormatRemark]),'',FRemarkImage,@TagClick,Pointer(ttRemark));
|
||||
FFormatToolbar.AppendSpace;
|
||||
end;
|
||||
{$ifdef debug}
|
||||
Writeln('Tools toolbar');
|
||||
{$endif}
|
||||
|
||||
FToolsToolBar:=TFPGtkToolbar.Create;
|
||||
With FToolsToolbar do
|
||||
begin
|
||||
Style:=DefaultToolBarStyle;
|
||||
ButtonRelief:=DefaultToolBarRelief;
|
||||
EnableTooltips:=DefaultToolTips;
|
||||
AppendItem(SMenuInsertLink,SHintInsertLink,'',FlinkImage,@LinkCLick,Nil);
|
||||
AppendItem(SMenuInsertTable,SHintInsertTable,'',FTableImage,@TableClick,Nil);
|
||||
AppendSpace;
|
||||
end;
|
||||
|
||||
{$ifdef debug}
|
||||
Writeln('end Toolbars');
|
||||
{$endif}
|
||||
|
||||
V:=TFPGtkHBox.Create;
|
||||
V.PackStart(FMainToolbar,False,False,2);
|
||||
V.PackStart(FFormatToolBar,False,False,2);
|
||||
V.Packstart(FToolsToolbar,True,True,2);
|
||||
|
||||
FToolbarFrame:=TFPGtkFrame.Create;
|
||||
FtoolbarFrame.Add(V);
|
||||
|
||||
{ Pages }
|
||||
|
||||
FPages:=TFPGtkNotebook.Create;
|
||||
|
||||
{ Place everything on form }
|
||||
FVBox:=TFPGTKVBox.create;
|
||||
FVBox.PackStart(FMenu,false, true, 0);
|
||||
FVBox.PackStart(FToolBarFrame,false, true, 0);
|
||||
FVBox.PackStart(FPages,true, true, 0);
|
||||
Self.add(FVBox);
|
||||
setusize(640,480);
|
||||
ConnectDeleteEvent(@OnDeleteEvent,Nil);
|
||||
end;
|
||||
|
||||
Constructor TMainForm.create;
|
||||
|
||||
begin
|
||||
FRecent:=TStringList.Create;
|
||||
Inherited Create(gtk_window_dialog);
|
||||
CreateForm;
|
||||
LoadOptions;
|
||||
LoadRecent;
|
||||
end;
|
||||
|
||||
Destructor TMainForm.Destroy;
|
||||
|
||||
begin
|
||||
SaveRecent;
|
||||
FRecent.Free;
|
||||
Inherited;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TMainForm.LoadRecent;
|
||||
|
||||
Var
|
||||
I,Count : Integer;
|
||||
S : String;
|
||||
|
||||
begin
|
||||
FRecent.Clear;
|
||||
With TInifile.Create(GetoptionFileName) do
|
||||
begin
|
||||
Count:=ReadInteger('Recent','Count',0);
|
||||
For I:=1 to Count do
|
||||
begin
|
||||
S:=ReadString('Recent','File'+IntToStr(i),'');
|
||||
If S<>'' then
|
||||
FRecent.Add(S);
|
||||
end;
|
||||
end;
|
||||
BuildReopenList;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.SaveRecent;
|
||||
|
||||
Var
|
||||
I,Count : Integer;
|
||||
S : String;
|
||||
|
||||
begin
|
||||
With TInifile.Create(GetoptionFileName) do
|
||||
try
|
||||
EraseSection('Recent');
|
||||
WriteInteger('Recent','Count',FRecent.Count);
|
||||
For I:=1 to FRecent.Count do
|
||||
WriteString('Recent','File'+IntToStr(i),FRecent[i-1]);
|
||||
UpdateFile;
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Menu handlers
|
||||
}
|
||||
|
||||
|
||||
Procedure TMainForm.DialogSetFilename(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
|
||||
type
|
||||
PString = ^AnsiString;
|
||||
|
||||
begin
|
||||
PString(Data)^:=(Sender as TFPgtkFileSelection).Filename;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.AddTorecent(FN : String);
|
||||
|
||||
Var
|
||||
Index : Integer;
|
||||
|
||||
begin
|
||||
FN:=ExpandFileName(FN);
|
||||
With FRecent do
|
||||
begin
|
||||
Index:=IndexOf(FN);
|
||||
If Index<>-1 then
|
||||
Delete(Index);
|
||||
Insert(0,FN);
|
||||
While Count>MaxRecentUsed do
|
||||
Delete(Count-1);
|
||||
end;
|
||||
BuildReopenList;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.OpenFile(FN : String);
|
||||
|
||||
Var
|
||||
EFN : String;
|
||||
|
||||
begin
|
||||
IF (FN<>'') then
|
||||
begin
|
||||
If FileExists(FN) then
|
||||
With CreatePage do
|
||||
begin
|
||||
LoadFromFile(FN);
|
||||
AddToRecent(Fn);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.FileOpenClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
var
|
||||
fs : TFPgtkFileSelection;
|
||||
FN : String;
|
||||
begin
|
||||
fs := TFPgtkFileSelection.Create (gtk_window_dialog);
|
||||
FN:='';
|
||||
with fs do
|
||||
begin
|
||||
Title:=SOpenFileTitle;
|
||||
OKButton.ConnectClicked (@(CloseWithResult), inttopointer(drOk));
|
||||
CancelButton.ConnectClicked (@(CloseWindow), nil);
|
||||
if execute (nil, @FN, @DialogSetFilename) = drOk then
|
||||
OpenFile(FN);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.FileNewClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
Const
|
||||
template = '<?xml version="1.0" encoding="ISO8859-1"?>'+LineEnding+
|
||||
'<fpdoc-descriptions>'+LineEnding+
|
||||
'</fpdoc-descriptions>'+LineEnding;
|
||||
|
||||
Var
|
||||
S : TStringStream;
|
||||
|
||||
begin
|
||||
With CreatePage do
|
||||
begin
|
||||
If FileExists(SFileTemplate) then
|
||||
LoadFromFile(SFileTemplate)
|
||||
else
|
||||
begin
|
||||
S:=TStringStream.Create(Template);
|
||||
Try
|
||||
LoadFromStream(S)
|
||||
finally
|
||||
S.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Type
|
||||
TSkeletonData = Record
|
||||
InputFile,
|
||||
OutputFile,
|
||||
PackageName,
|
||||
AdditionalOptions : String;
|
||||
DisableArguments,
|
||||
DisableResults,
|
||||
DisablePrivate,
|
||||
DisableProtected,
|
||||
DisableSeeAlso,
|
||||
DisableErrors : Boolean;
|
||||
end;
|
||||
PSkeletonData = ^TSkeletonData;
|
||||
|
||||
Procedure TMainForm.GetSkeletonData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
|
||||
begin
|
||||
With (Sender as TMakeSkelForm), PSkeletonData(Data)^ do
|
||||
begin
|
||||
InputFile:=FInputFile.FileName;
|
||||
OutputFile:=FOutputFile.FileName;
|
||||
PackageName:=FPackageName.Text;
|
||||
AdditionalOptions:=FadditionalOptions.Text;
|
||||
DisableArguments:=FDisableArguments.Active;
|
||||
DisableResults:=FDisableResults.Active;
|
||||
DisablePrivate:=FDisablePrivate.Active;
|
||||
DisableProtected:=FDisableProtected.Active;
|
||||
DisableSeeAlso:=FDisableSeeAlso.Active;
|
||||
DisableErrors:=FDisableErrors.Active;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function CreateSkeletonFile(Const S : TSkeletonData) : Boolean;
|
||||
|
||||
Var
|
||||
Cmd : String;
|
||||
|
||||
begin
|
||||
With S do
|
||||
begin
|
||||
cmd:='makeskel ';
|
||||
cmd:=cmd+format('--input=''%s %s''',[Inputfile,Additionaloptions]);
|
||||
cmd:=cmd+' --output='+OutputFile;
|
||||
cmd:=cmd+' --package='+PackageName;
|
||||
If DisableErrors then
|
||||
cmd:=cmd+' --disable-errors';
|
||||
If DisableSeeAlso then
|
||||
cmd:=cmd+' --disable-seealso';
|
||||
If DisableProtected then
|
||||
cmd:=cmd+' --disable-protected'
|
||||
else if DisablePrivate then
|
||||
cmd:=cmd+' --disable-private';
|
||||
If DisableResults then
|
||||
cmd:=cmd+' --disable-function-results';
|
||||
If DisableArguments then
|
||||
cmd:=cmd+' --disable-arguments';
|
||||
Writeln(cmd);
|
||||
With TProcess.Create(Nil) do
|
||||
try
|
||||
CommandLine:=cmd;
|
||||
options:=[poWaitOnExit];
|
||||
Execute;
|
||||
If (ExitStatus<>0) then
|
||||
begin
|
||||
If FileExists(OutputFile) then
|
||||
Result:=MessageDlg(SSkelErrorWithFile,[ExitStatus],mtWarning,mbYesNo,0)=mrYes
|
||||
else
|
||||
begin
|
||||
MessageDlg(SSkelErrorWithoutFile,[ExitStatus],mtError,[mbOk],0);
|
||||
Result:=False;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Result:=FileExists(OutputFile);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure TMainForm.FileNewFromFileClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
Var
|
||||
SkeletonData : TSkeletonData;
|
||||
CmdLine : String;
|
||||
|
||||
begin
|
||||
With TMakeSkelform.Create do
|
||||
begin
|
||||
Title:=SMakeSkelFromSource;
|
||||
If Execute(Nil,@SkeletonData,@GetSkeletonData)=drOK Then
|
||||
If CreateSkeletonFile(SkeletonData) then
|
||||
OpenFile(SkeletonData.OutPutFile)
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.SaveEditor(E : TEditorPage);
|
||||
|
||||
begin
|
||||
With E do
|
||||
begin
|
||||
if (FileName=SNewDocument) then
|
||||
SaveEditorAs(E)
|
||||
else
|
||||
SaveToFile(FileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.SaveEditorAs(E : TEditorPage);
|
||||
|
||||
var
|
||||
fs : TFPgtkFileSelection;
|
||||
FN : String;
|
||||
|
||||
begin
|
||||
fs := TFPgtkFileSelection.Create (gtk_window_dialog);
|
||||
FN:='';
|
||||
with fs do
|
||||
begin
|
||||
Title:=SSaveFileTitle;
|
||||
OKButton.ConnectClicked (@(CloseWithResult), inttopointer(drOk));
|
||||
CancelButton.ConnectClicked (@(CloseWindow), nil);
|
||||
FileName:=E.FileName;
|
||||
if execute (nil, @FN, @DialogSetFilename) = drOk then
|
||||
begin
|
||||
IF (FN<>'') then
|
||||
begin
|
||||
If ExtractFileExt(FN)='' then
|
||||
FN:=FN+DefaultExtension;
|
||||
E.SaveToFile(FN);
|
||||
AddToRecent(FN);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TMainForm.CloseEditor(E : TEditorPage) : Boolean;
|
||||
|
||||
begin
|
||||
Result:=Not E.Modified;
|
||||
If Not Result then
|
||||
Case MessageDlg(SFileModified,[E.FileName],mtConfirmation,mbYesNoCancel,0) of
|
||||
mrYes : begin
|
||||
SaveEditor(E);
|
||||
E.Free;
|
||||
Result:=True;
|
||||
end;
|
||||
mrNo : begin
|
||||
E.Free;
|
||||
Result:=True;
|
||||
end;
|
||||
end
|
||||
else
|
||||
E.Free;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.FileSaveClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
If Assigned(CurrentEditor) then
|
||||
SaveEditor(CurrentEditor);
|
||||
end;
|
||||
|
||||
Procedure TMainForm.FileSaveAsClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
If Assigned(CurrentEditor) then
|
||||
SaveEditorAs(CurrentEditor);
|
||||
end;
|
||||
|
||||
|
||||
Procedure TMainForm.FileExitClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
If AllowClose then
|
||||
Close;//(Sender,Data);
|
||||
end;
|
||||
|
||||
|
||||
Procedure TMainForm.FileCloseClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
If Assigned(CurrentEditor) then
|
||||
CloseEditor(CurrentEditor)
|
||||
else
|
||||
Writeln('No current editor to close') ;
|
||||
end;
|
||||
|
||||
Function TMainForm.Currenteditor : TEditorPage;
|
||||
|
||||
begin
|
||||
With FPages do
|
||||
Result:=(Page as TEditorPage);
|
||||
end;
|
||||
|
||||
Procedure TMainForm.GetNodeData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
|
||||
type
|
||||
PString = ^AnsiString;
|
||||
|
||||
begin
|
||||
With (Sender as TNewNodeForm) do
|
||||
PString(Data)^:=FENodeName.Text;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TMainForm.InsertNodeClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
Var
|
||||
S : AnsiString;
|
||||
Nt : TNodeType;
|
||||
|
||||
begin
|
||||
If (CurrentEditor<>Nil) then
|
||||
begin
|
||||
With TNewNodeForm.Create do
|
||||
begin
|
||||
nt:=TNodeType(Data);
|
||||
S:=SNew+' '+NodeNames[nt];
|
||||
Case nt of
|
||||
ntPackage : S:=S+SForFile+ExtractFileName(CurrentEditor.FileName);
|
||||
ntModule: If (CurrentEditor.CurrentPackage<>Nil) then
|
||||
S:=S+SForPackage+CurrentEditor.CurrentPackage['name'];
|
||||
ntElement: begin
|
||||
If (CurrentEditor.CurrentModule<>Nil) then
|
||||
S:=S+SForModule+CurrentEditor.CurrentModule['name'];
|
||||
If Assigned(CurrentEditor.CurrentElement) then
|
||||
FENodeName.Selection:=CurrentEditor.CurrentElement['name'];
|
||||
end;
|
||||
end;
|
||||
Title:=S;
|
||||
S:='';
|
||||
If Execute(Nil,@S,@GetNodeData)=drOK Then
|
||||
Case nt of
|
||||
ntPackage : CurrentEditor.NewPackage(S);
|
||||
ntModule : CurrentEditor.NewModule(S);
|
||||
ntElement : CurrentEditor.NewElement(S);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.TagClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
CurrentEditor.InsertTag(TTagType(Data));
|
||||
end;
|
||||
|
||||
Type
|
||||
TLinkData = Record
|
||||
LText,LTarget : String;
|
||||
end;
|
||||
PLinkData = ^TLinkData;
|
||||
|
||||
TTableData = Record
|
||||
Cols,Rows : Integer;
|
||||
UseHeader : Boolean;
|
||||
end;
|
||||
PTableData = ^TTableData;
|
||||
|
||||
Procedure TMainForm.GetLinkData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
|
||||
begin
|
||||
With (Sender as TLinkForm),PlinkData(Data)^ do
|
||||
begin
|
||||
LText:=FlinkText.Text;
|
||||
LTarget:=FLinkTarget.Entry.Text;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.GetTableData(Sender : TFPGtkWindow;Data : Pointer; Action : Integer;Initiator : TFPGtkObject);
|
||||
|
||||
begin
|
||||
With (Sender as TTableForm),PTableData(Data)^ do
|
||||
begin
|
||||
Rows:=FTableRows.AsInteger;
|
||||
Cols:=FTableCols.AsInteger;
|
||||
UseHeader:=FUSeHeader.Active;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.LinkClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
Var
|
||||
LinkData : TLinkData;
|
||||
S : TstringList;
|
||||
L : TFPgtkListItemGroup;
|
||||
|
||||
begin
|
||||
If Assigned(CurrentEditor) then
|
||||
begin
|
||||
L:=TFpGtkListItemGroup.Create;
|
||||
Try
|
||||
S:=TStringList.Create;
|
||||
Try
|
||||
S.Sorted:=True;
|
||||
CurrentEditor.GetElementList(S);
|
||||
L.FillFromList(S);
|
||||
finally
|
||||
S.Free;
|
||||
end;
|
||||
With TLinkForm.Create do
|
||||
begin
|
||||
Title:=SInsertLink;
|
||||
FLinkText.Text:=CurrentEditor.CurrentSelection;
|
||||
FLinkTarget.List.AppendItems(L);
|
||||
If Execute(Nil,@LinkData,@GetLinkData)=drOK Then
|
||||
With LinkData do
|
||||
CurrentEditor.InsertLink(LTarget,LText);
|
||||
end;
|
||||
finally
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.TableClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
Var
|
||||
TableData : TTableData;
|
||||
|
||||
begin
|
||||
With TTableForm.Create do
|
||||
begin
|
||||
Title:=SInsertTable;
|
||||
FTableRows.AsInteger:=3;
|
||||
FTableCols.AsInteger:=3;
|
||||
If Execute(Nil,@TableData,@GetTableData)=drOK Then
|
||||
With TableData do
|
||||
CurrentEditor.InsertTable(Cols,Rows,UseHeader);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Function TMainForm.AllowClose : Boolean;
|
||||
|
||||
Var
|
||||
P : TFPgtkWidget;
|
||||
|
||||
begin
|
||||
P:=FPages.Page;
|
||||
Result:=True;
|
||||
While (P<>Nil) and Result do
|
||||
begin
|
||||
Result:=CloseEditor(P as TEditorPage);
|
||||
P:=FPages.Page;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TMainForm.OnDeleteEvent(Sender:TFPgtkWidget; Event:PGdkEvent; data:pointer): boolean;
|
||||
|
||||
begin
|
||||
Result:=Not AllowClose;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.OptionsClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
With TOptionsForm.Create do
|
||||
Execute(Nil,Nil,Nil);
|
||||
end;
|
||||
|
||||
Procedure TMainForm.HelpAboutClick(Sender : TFPGtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
With TAboutForm.Create do
|
||||
Execute(Nil,Nil,Nil);
|
||||
end;
|
||||
|
||||
Type
|
||||
TRecentMenuItem = Class (TFPGtkMenuItem)
|
||||
FileName : String;
|
||||
end;
|
||||
|
||||
Procedure TMainForm.FileReopen(Sender: TFPGTKObject;data : Pointer);
|
||||
|
||||
begin
|
||||
OpenFile((Sender as TRecentMenuItem).FileName);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TMainForm.BuildReopenList;
|
||||
|
||||
Function NewRecentMenuItem (Nr : Integer;AFileName : string) : TRecentMenuItem;
|
||||
|
||||
begin
|
||||
If Nr<10 then
|
||||
result := TRecentMenuItem.CreateWithLabel('_'+IntToStr(Nr)+' '+AFileName)
|
||||
else
|
||||
result := TRecentMenuItem.CreateWithLabel(AFileName);
|
||||
result.FileName:=AFileName;
|
||||
Result.ConnectActivate(@FileReopen,Nil);
|
||||
end;
|
||||
|
||||
var I : integer;
|
||||
mi : TFPgtkMenuItem;
|
||||
|
||||
begin
|
||||
with FRecent do
|
||||
begin
|
||||
with FFileRecent do
|
||||
begin
|
||||
if assigned(SubMenu) then
|
||||
SubMenu.Free;
|
||||
SubMenu := TFPgtkMenu.Create;
|
||||
with (submenu as TFPgtkMenu) do
|
||||
for I := FRecent.count-1 downto 0 do
|
||||
begin
|
||||
mi := NewRecentMenuItem (I,FRecent[I]);
|
||||
Append (mi);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
198
utils/fpdoc/fpde/frmmakeskel.pp
Normal file
198
utils/fpdoc/fpde/frmmakeskel.pp
Normal file
@ -0,0 +1,198 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmmakeskel;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,fpgtkext,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TMakeSkelForm = Class (TFPGtkWindow)
|
||||
FTable : TFPGtkTable;
|
||||
FInputFile,
|
||||
FOutputFile : TFPgtkFileEntry;
|
||||
FPackageName,
|
||||
FAdditionalOptions : TFPgtkEntry;
|
||||
FDisableArguments,
|
||||
FDisableResults,
|
||||
FDisableSeeAlso,
|
||||
FDisableProtected,
|
||||
FDisablePrivate,
|
||||
FDisableErrors : TFPGtkToggleButton;
|
||||
FLInputFile,
|
||||
FLOutPutfile,
|
||||
FLPackageName,
|
||||
FLAdditionalOptions,
|
||||
FLDisableArguments,
|
||||
FLDisableResults,
|
||||
FLDisableSeeAlso,
|
||||
FLDisableProtected,
|
||||
FLDisablePrivate,
|
||||
FLDisableErrors : TFPGtkLabel;
|
||||
FDisableFrame : TFPgtkFrame;
|
||||
FDisableTable : TFPgtkTable;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
|
||||
Procedure OnOKClick(Sender : TFpGtkObject;Data : Pointer);
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
resourcestring
|
||||
SDisableCode = 'Do not generate nodes for';
|
||||
SArguments = 'Function arguments';
|
||||
SResults = 'Function results';
|
||||
SProtected = 'Protected class members';
|
||||
SPrivate = 'Private class members';
|
||||
SSeeAlso = 'See also section';
|
||||
SErrors = 'Errors section';
|
||||
SInputfile = 'Input file';
|
||||
SOutputFile = 'Output file';
|
||||
SPackageName = 'Package name';
|
||||
SAdditionalOptions = 'Additional options';
|
||||
SOK = 'OK';
|
||||
SCancel = 'Cancel';
|
||||
SNeedInputFileName = 'An input filename is required.';
|
||||
SNeedOutputFileName = 'An output filename is required.';
|
||||
SNeedPackageName = 'A package name is required.';
|
||||
|
||||
Constructor TMakeSkelForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Procedure TMakeSkelForm.CreateWindow;
|
||||
|
||||
Var
|
||||
OH,OV : TgtkAttachOPtions;
|
||||
|
||||
Function CreateToggle : TFPgtkToggleButton;
|
||||
|
||||
begin
|
||||
Result:=TFPgtkToggleButton.Create;
|
||||
Result.SetUsize(14,14);
|
||||
end;
|
||||
|
||||
Function CreateLLabel(S : String) : TFPgtkLabel;
|
||||
|
||||
begin
|
||||
Result:=TFPgtkLabel.Create(S);
|
||||
Result.Justify:=GTK_JUSTIFY_LEFT;
|
||||
end;
|
||||
|
||||
Function CreateRLabel(S : String) : TFPgtkLabel;
|
||||
|
||||
begin
|
||||
Result:=TFPgtkLabel.Create(S);
|
||||
Result.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
end;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// input options table area
|
||||
FTable:=TFPGtkTable.Create(2,4);
|
||||
FLInputFile:=CreateRLabel(SInputFile);
|
||||
FInputFile:=TFPgtkFileEntry.Create;
|
||||
FLOutputFile:=CreateRLabel(SOutputFile);
|
||||
FOutputFile:=TFPgtkFileEntry.Create;
|
||||
FLAdditionalOptions:=CreateRLabel(SAdditionalOptions);
|
||||
FAdditionalOptions:=TFPgtkEntry.Create;
|
||||
FLPackageName:=CreateRLabel(SPackageName);
|
||||
FPackageName:=TFPgtkEntry.Create;
|
||||
// Pack in table.
|
||||
OH:=GTK_EXPAND or GTK_FILL;
|
||||
With FTable do
|
||||
begin
|
||||
Attach(FLInputFile,0,1,0,1,GTK_FILL,0,4,4);
|
||||
Attach(FLOutputFile,0,1,1,2,GTK_FILL,0,4,4);
|
||||
Attach(FLPackageName,0,1,2,3,GTK_FILL,0,4,4);
|
||||
Attach(FLAdditionalOptions,0,1,3,4,GTK_FILL,0,4,4);
|
||||
Attach(FInputFile,1,2,0,1,OH,0,4,4);
|
||||
Attach(FOutputFile,1,2,1,2,OH,0,4,4);
|
||||
Attach(FPackageName,1,2,2,3,OH,0,4,4);
|
||||
Attach(FAdditionalOptions,1,2,3,4,OH,0,4,4);
|
||||
end;
|
||||
FDisableArguments:=CreateToggle;
|
||||
FDisableResults:=CreateToggle;
|
||||
FDisableSeeAlso:=CreateToggle;
|
||||
FDisableProtected:=CreateToggle;
|
||||
FDisablePrivate:=CreateToggle;
|
||||
FDisableErrors:=CreateToggle;
|
||||
FLDisableArguments:=CreateLLabel(SArguments);
|
||||
FLDisableResults:=CreateLLabel(SResults);
|
||||
FLDisableSeeAlso:=CreateLLabel(SSeeAlso);
|
||||
FLDisableProtected:=CreateLLabel(SProtected);
|
||||
FLDisablePrivate:=CreateLLabel(SPrivate);
|
||||
FLDisableErrors:=CreateLLabel(SErrors);
|
||||
FDisableTable:=TFPgtkTable.Create(2,6);
|
||||
With FDisableTable do
|
||||
begin
|
||||
// Checks
|
||||
Attach(FDisableArguments ,0,1,0,1,0,GTK_FILL,4,4);
|
||||
Attach(FDisableResults ,0,1,1,2,0,GTK_FILL,4,4);
|
||||
Attach(FDisableProtected ,0,1,2,3,0,GTK_FILL,4,4);
|
||||
Attach(FDisablePrivate ,0,1,3,4,0,GTK_FILL,4,4);
|
||||
Attach(FDisableErrors ,0,1,4,5,0,GTK_FILL,4,4);
|
||||
Attach(FDisableSeeAlso ,0,1,5,6,0,GTK_FILL,4,4);
|
||||
// Labels
|
||||
Attach(FLDisableArguments ,1,2,0,1,GTK_FILL,0,4,4);
|
||||
Attach(FLDisableResults ,1,2,1,2,GTK_FILL,0,4,4);
|
||||
Attach(FLDisableProtected ,1,2,2,3,GTK_FILL,0,4,4);
|
||||
Attach(FLDisablePrivate ,1,2,3,4,GTK_FILL,0,4,4);
|
||||
Attach(FLDisableErrors ,1,2,4,5,GTK_FILL,0,4,4);
|
||||
Attach(FLDisableSeeAlso ,1,2,5,6,GTK_FILL,0,4,4);
|
||||
end;
|
||||
FDisableFrame:=TFpgtkFrame.Create;
|
||||
FDisableFrame.Text:=SDisableCode;
|
||||
FDisableFrame.Add(FDisableTable);
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@OnOkCLick,Nil);
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FTable,False,False,0);
|
||||
FVBox.PackStart(FDisableFrame,False,False,4);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
// Some events;
|
||||
ConnectShow(@OnShow,Nil);
|
||||
end;
|
||||
|
||||
Procedure TMakeSkelForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
FocusedWidget(FInputFile.Edit);
|
||||
end;
|
||||
|
||||
Procedure TMakeSkelForm.OnOkClick(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
If (FInputFile.FileName='') then
|
||||
MessageDlg(SNeedInputFileName,mtError,[mbOk],0)
|
||||
else If (FOutPutFile.FileName='') then
|
||||
MessageDlg(SNeedOutPutFileName,mtError,[mbOk],0)
|
||||
Else if (FPackageName.Text='') then
|
||||
MessageDlg(SNeedPackageName,mtError,[mbOk],0)
|
||||
else
|
||||
CloseWithResult(Sender,IntToPointer(drOK));
|
||||
end;
|
||||
|
||||
end.
|
81
utils/fpdoc/fpde/frmnewnode.pp
Normal file
81
utils/fpdoc/fpde/frmnewnode.pp
Normal file
@ -0,0 +1,81 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmnewnode;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TNewNodeForm = Class (TFPGtkWindow)
|
||||
FTable : TFPGtkTable;
|
||||
FLENodeName : TFPGtkLabel;
|
||||
FENodeName : TFPGtkEntry;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
uses
|
||||
fpdemsg;
|
||||
|
||||
Constructor TNewNodeForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Procedure TNewNodeForm.CreateWindow;
|
||||
|
||||
Var
|
||||
OH,OV : TgtkAttachOPtions;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// Table area
|
||||
FTable:=TFPGtkTable.Create(1,1);
|
||||
FLENodeName:=TFPGtkLabel.Create(SName);
|
||||
FLENodeName.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FENodeName:=TFPgtkEntry.Create;
|
||||
FENodeName.GrabFocus;
|
||||
OH:=GTK_EXPAND or GTK_FILL;
|
||||
FTable.Attach(FLENodeName,0,1,0,1,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FENodeName,1,2,0,1,OH,0,4,4);
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FTable,False,False,0);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
// Some events;
|
||||
ConnectShow(@OnShow,Nil);
|
||||
end;
|
||||
|
||||
Procedure TNewNodeForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
FocusedWidget(FENodeName);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
169
utils/fpdoc/fpde/frmoptions.pp
Normal file
169
utils/fpdoc/fpde/frmoptions.pp
Normal file
@ -0,0 +1,169 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmoptions;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TOptionsForm = Class (TFPGtkWindow)
|
||||
FTable : TFPGtkTable;
|
||||
FLCreateBackup,
|
||||
FLSkipEmptyNodes,
|
||||
FLConfirmDelete,
|
||||
FLMaxRecentUsed,
|
||||
FLbackupExtension,
|
||||
FLDefaultExtension : TFPGtkLabel;
|
||||
FCreateBackup,
|
||||
FSkipEmptyNodes,
|
||||
FConfirmDelete : TFPGtkToggleButton;
|
||||
FBackupExtension,
|
||||
FDefaultExtension : TFPGtkEntry;
|
||||
FMaxRecentUsed : TFPGtkSpinButton;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FHBox : TFPgtkHBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
|
||||
Procedure SaveResult(Sender : TFpGtkObject;Data : Pointer);
|
||||
Procedure OptionsToForm;
|
||||
Procedure FormToOptions;
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
uses fpdemsg,fpdeopts;
|
||||
|
||||
Function MakeLabel(Caption : String) : TFPgtkLabel;
|
||||
|
||||
begin
|
||||
Result:=TFPGtkLabel.Create(Caption);
|
||||
Result.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
end;
|
||||
|
||||
Function MakeCheck : TFPgtkToggleButton;
|
||||
|
||||
begin
|
||||
Result:=TFPgtkToggleButton.create;
|
||||
Result.SetUsize(14,14);
|
||||
end;
|
||||
|
||||
|
||||
Constructor TOptionsForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Function PackBox(W : TFpGtkWidget) : TFpGtkHbox;
|
||||
|
||||
begin
|
||||
Result:=TFPGtkHBox.Create;
|
||||
Result.PackStart(W,True,False,0);
|
||||
end;
|
||||
|
||||
|
||||
Procedure ToptionsForm.CreateWindow;
|
||||
|
||||
Var
|
||||
OH,OV : TgtkAttachOPtions;
|
||||
B : TfpgtkHbox;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// Table area
|
||||
FTable:=TFPGtkTable.Create(2,6);
|
||||
FLCreateBackup:=MakeLabel(SOptCreateBackup);
|
||||
FLSkipEmptyNodes:=MakeLabel(SOptSkipEmptyNodes);
|
||||
FLConfirmDelete:=MakeLabel(SOptConfirmDelete);
|
||||
FLbackupExtension:=MakeLabel(SOptBackupExtension);
|
||||
FLDefaultExtension:=MakeLabel(SOptDefaultExtension);
|
||||
FLMaxRecentUsed:=MakeLabel(SOptMaxRecentUsed);
|
||||
FCreateBackup:=MakeCheck;
|
||||
FSkipEmptyNodes:=MakeCheck;
|
||||
FConfirmDelete:=MakeCheck;
|
||||
FBackupExtension:=TFpGtkEntry.Create;
|
||||
FDefaultExtension:=TFpGtkEntry.Create;
|
||||
FMaxRecentUsed:=TFPGtkSpinButton.Create;
|
||||
FMaxRecentUsed.Adjustment.Upper:=32;
|
||||
OH:=GTK_EXPAND or GTK_FILL;
|
||||
FTable.Attach(FLConfirmDelete ,0,1,0,1,GTK_FILL,0,4,4);
|
||||
FTable.Attach(FLSkipEmptyNodes ,0,1,1,2,GTK_FILL,0,4,4);
|
||||
FTable.Attach(FLCreatebackup ,0,1,2,3,GTK_FILL,0,4,4);
|
||||
FTable.Attach(FLBackupExtension ,0,1,3,4,GTK_FILL,0,4,4);
|
||||
FTable.Attach(FLDefaultExtension ,0,1,4,5,GTK_FILL,0,4,4);
|
||||
FTable.Attach(FLMaxrecentUSed ,0,1,5,6,GTK_FILL,0,4,4);
|
||||
|
||||
FTable.Attach(PackBox(FConfirmDelete) ,1,2,0,1,0,GTK_FILL,4,4);
|
||||
FTable.Attach(PackBox(FSkipEmptyNodes) ,1,2,1,2,0,GTK_FILL,4,4);
|
||||
FTable.Attach(PackBox(FCreatebackup) ,1,2,2,3,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FBackupExtension ,1,2,3,4,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FDefaultExtension ,1,2,4,5,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FMaxRecentUsed ,1,2,5,6,0,GTK_FILL,4,4);
|
||||
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@SaveResult,Nil);
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FTable,False,False,0);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
// Some events;
|
||||
ConnectShow(@OnShow,Nil);
|
||||
end;
|
||||
|
||||
Procedure TOptionsForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
OptionsToForm;
|
||||
FocusedWidget(FConfirmDelete);
|
||||
end;
|
||||
|
||||
Procedure TOptionsForm.SaveResult(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
FormToOptions;
|
||||
CloseWithResult(Sender,IntToPointer(drOK));
|
||||
end;
|
||||
|
||||
Procedure TOptionsForm.OptionsToForm;
|
||||
|
||||
begin
|
||||
FCreateBackup.Active:=CreateBackup;
|
||||
FSkipEmptyNodes.Active:=SkipEmptyNodes;
|
||||
FConfirmDelete.Active:=ConfirmDelete;
|
||||
FBackupExtension.Text:=BackupExtension;
|
||||
FDefaultExtension.Text:=DefaultExtension;
|
||||
FMaxRecentUsed.AsInteger:=MaxRecentUsed;
|
||||
end;
|
||||
|
||||
Procedure TOptionsForm.FormToOptions;
|
||||
|
||||
begin
|
||||
CreateBackup:=FCreateBackup.Active;
|
||||
SkipEmptyNodes:=FSkipEmptyNodes.Active;
|
||||
ConfirmDelete:=FConfirmDelete.Active;
|
||||
BackupExtension:=FBackupExtension.Text;
|
||||
DefaultExtension:=FDefaultExtension.Text;
|
||||
MaxRecentUsed:=FMaxRecentUsed.AsInteger;
|
||||
SaveOptions;
|
||||
end;
|
||||
|
||||
end.
|
97
utils/fpdoc/fpde/frmtable.pp
Normal file
97
utils/fpdoc/fpde/frmtable.pp
Normal file
@ -0,0 +1,97 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
unit frmtable;
|
||||
|
||||
interface
|
||||
|
||||
uses fpgtk,gtk,classes,sysutils;
|
||||
|
||||
Type
|
||||
TTableForm = Class (TFPGtkWindow)
|
||||
FTable : TFPGtkTable;
|
||||
FLTableRows,
|
||||
FLTableCols,
|
||||
FLUseHeader : TFPGtkLabel;
|
||||
FTableRows,
|
||||
FTableCols : TFPGtkSpinButton;
|
||||
FUseHeader : TFPGtkToggleButton;
|
||||
FSeparator : TFPGtkHSeparator;
|
||||
FVBox : TFPgtkVBox;
|
||||
FHBox : TFPgtkHBox;
|
||||
FOK,
|
||||
FCancel : TFPGtkButton;
|
||||
FButtonBox: TFPgtkHBox;
|
||||
Constructor Create;
|
||||
Procedure CreateWindow;
|
||||
Procedure OnShow(Sender : TFpGtkObject;Data : Pointer);
|
||||
end;
|
||||
|
||||
Implementation
|
||||
|
||||
uses fpdemsg;
|
||||
|
||||
Constructor TTableForm.Create;
|
||||
|
||||
begin
|
||||
Inherited Create(GTK_WINDOW_DIALOG);
|
||||
CreateWindow;
|
||||
end;
|
||||
|
||||
Procedure TTableForm.CreateWindow;
|
||||
|
||||
Var
|
||||
OH,OV : TgtkAttachOPtions;
|
||||
|
||||
begin
|
||||
FVBox:=TFPGtkVBox.Create;
|
||||
FVBox.Spacing:=4;
|
||||
FVBox.Border:=8;
|
||||
Add(FVBox);
|
||||
// Table area
|
||||
FTable:=TFPGtkTable.Create(2,3);
|
||||
FLTableRows:=TFPGtkLabel.Create(STableRows);
|
||||
FLTableRows.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FLTableCols:=TFPGtkLabel.Create(STableCols);
|
||||
FLTableCols.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FLUseHeader:=TFPGtkLabel.Create(STableHeader);
|
||||
FLUseHeader.Justify:=GTK_JUSTIFY_RIGHT;
|
||||
FTableRows:=TFPGtkSpinButton.Create;
|
||||
FTableCols:=TFPGtkSpinButton.Create;
|
||||
FUSeHeader:=TFPgtkToggleButton.Create;
|
||||
FUseHeader.SetUSize(14,14);
|
||||
FHBox:=TFPgtkHBox.Create;
|
||||
FHBox.PackStart(FuseHeader,True,False,0);
|
||||
OH:=GTK_EXPAND or GTK_FILL;
|
||||
FTable.Attach(FLTableRows,0,1,0,1,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FLTableCols,0,1,1,2,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FLUseHeader,0,1,2,3,0,GTK_FILL,4,4);
|
||||
FTable.Attach(FTableRows,1,2,0,1,OH,0,4,4);
|
||||
FTable.Attach(FTableCols,1,2,1,2,OH,0,4,4);
|
||||
FTable.Attach(FHBox,1,2,2,3,0,GTK_FILL,4,4);
|
||||
// button area
|
||||
FOK:=TFpGtkButton.CreateWithLabel(SOK);
|
||||
FOK.ConnectClicked(@CloseWithResult,IntToPointer(drOK));
|
||||
FCancel:=TFPgtkButton.CreateWithLabel(SCancel);
|
||||
FCancel.ConnectCLicked(@CloseWithResult,IntToPointer(drCancel));
|
||||
FSeparator:=TFPgtkHSeparator.Create;
|
||||
FButtonBox:=TfpGtkHBox.Create;
|
||||
FButtonBox.Spacing:=4;
|
||||
FButtonBox.PackEnd(FOK,false,false,4);
|
||||
FButtonBox.PackEnd(FCancel,false,false,4);
|
||||
// Add to window
|
||||
FVBox.PackStart(FTable,False,False,0);
|
||||
FVBox.PackStart(FSeparator,False,False,4);
|
||||
FVBox.PackStart(FButtonBox,false,false,0);
|
||||
// Some events;
|
||||
ConnectShow(@OnShow,Nil);
|
||||
end;
|
||||
|
||||
Procedure TTableForm.OnShow(Sender : TFpgtkObject; Data : Pointer);
|
||||
|
||||
begin
|
||||
FocusedWidget(FTableRows);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
1541
utils/fpdoc/fpde/pgeditor.pp
Normal file
1541
utils/fpdoc/fpde/pgeditor.pp
Normal file
File diff suppressed because it is too large
Load Diff
2192
utils/fpdoc/fpde/xpms.pp
Normal file
2192
utils/fpdoc/fpde/xpms.pp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user