diff options
Diffstat (limited to 'examples/apps')
29 files changed, 734 insertions, 107 deletions
diff --git a/examples/apps/debugserver/fpgDebugServer.lpi b/examples/apps/debugserver/fpgDebugServer.lpi index da1b22f2..f26f35ee 100644 --- a/examples/apps/debugserver/fpgDebugServer.lpi +++ b/examples/apps/debugserver/fpgDebugServer.lpi @@ -54,7 +54,7 @@ <CompilerOptions> <Version Value="11"/> <Target> - <Filename Value="fpgDebugServer"/> + <Filename Value="dbugsrv"/> </Target> <SearchPaths> <UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/> diff --git a/examples/apps/docedit/docedit.lpi b/examples/apps/docedit/docedit.lpi index 640d3114..3e06fdd7 100644 --- a/examples/apps/docedit/docedit.lpi +++ b/examples/apps/docedit/docedit.lpi @@ -1,7 +1,7 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <Version Value="7"/> + <Version Value="9"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> @@ -9,11 +9,13 @@ </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <TargetFileExt Value=""/> </General> <VersionInfo> - <ProjectVersion Value=""/> + <StringTable ProductVersion=""/> </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="default" Default="True"/> + </BuildModes> <PublishOptions> <Version Value="2"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> @@ -69,9 +71,19 @@ </Units> </ProjectOptions> <CompilerOptions> - <Version Value="8"/> + <Version Value="11"/> + <Target> + <Filename Value="docedit"/> + </Target> + <SearchPaths> + <UnitOutputDirectory Value="units"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <UseAnsiStrings Value="False"/> + </SyntaxOptions> + </Parsing> <Other> - <CustomOptions Value="-FUunits"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/apps/docedit/frm_main.pas b/examples/apps/docedit/frm_main.pas index f6404b79..884a2d5b 100644 --- a/examples/apps/docedit/frm_main.pas +++ b/examples/apps/docedit/frm_main.pas @@ -63,7 +63,9 @@ type implementation uses - fpg_dialogs, frm_options; + fpg_dialogs, + fpg_constants, + frm_options; const diff --git a/examples/apps/ide/src/builderthread.pas b/examples/apps/ide/src/builderthread.pas index bfdc48b1..b5a1ad6f 100644 --- a/examples/apps/ide/src/builderthread.pas +++ b/examples/apps/ide/src/builderthread.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit BuilderThread; {$mode objfpc}{$H+} @@ -115,7 +131,7 @@ begin finally FreeAndNil(p); end; - + end; procedure TBuilderThread.DoOutputLine; diff --git a/examples/apps/ide/src/filemonitor.pas b/examples/apps/ide/src/filemonitor.pas index 1c97185a..6d28642c 100644 --- a/examples/apps/ide/src/filemonitor.pas +++ b/examples/apps/ide/src/filemonitor.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit filemonitor; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/fpg_textedit.pas b/examples/apps/ide/src/fpg_textedit.pas index b68c78b3..013ad86b 100644 --- a/examples/apps/ide/src/fpg_textedit.pas +++ b/examples/apps/ide/src/fpg_textedit.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -124,17 +124,20 @@ type function GetGutterVisible: Boolean; function GetHScrollPos: Integer; function GetVScrollPos: Integer; + function GetCaretPosH: Integer; + function GetCaretPosV: Integer; procedure SetFontDesc(const AValue: string); procedure SetGutterShowLineNumbers(const AValue: Boolean); procedure SetGutterVisible(const AValue: Boolean); procedure SetHScrollPos(const AValue: Integer); + procedure SetCaretPosH(const AValue: Integer); + procedure SetCaretPosV(const AValue: Integer); procedure SetLines(const AValue: TStrings); procedure SetScrollBarStyle(const AValue: TfpgScrollStyle); procedure SetTabWidth(const AValue: Integer); procedure SetVScrollPos(const AValue: Integer); procedure UpdateCharBounds; procedure GetSelBounds(var AStartNo, AEndNo, AStartOffs, AEndOffs: Integer); - procedure UpdateScrollBars; procedure VScrollBarMove(Sender: TObject; position: integer); procedure HScrollBarMove(Sender: TObject; position: integer); procedure SetVPos(p: Integer); @@ -181,6 +184,7 @@ type public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + procedure UpdateScrollBars; function GetClientRect: TfpgRect; override; function GetWordAtPos(const X, Y: Integer; out XBegin: Integer): TfpgString; procedure GetRowColAtPos(const X, Y: Integer; out Row, Col: Integer); @@ -196,6 +200,8 @@ type procedure SaveToFile(const AFileName: TfpgString); procedure LoadFromFile(const AFileName: TfpgString); procedure FindText(TextToFind: TfpgString; FindOptions: TfpgFindOptions; Backward: Boolean = False); + property CaretPos_H: Integer read GetCaretPosH write SetCaretPosH; + property CaretPos_V: Integer read GetCaretPosV write SetCaretPosV; property FontHeight: Integer read FChrH; property FontWidth: Integer read FChrW; property ScrollPos_H: Integer read GetHScrollPos write SetHScrollPos; @@ -418,6 +424,16 @@ begin Result := VPos; end; +function TfpgBaseTextEdit.GetCaretPosH: Integer; +begin + Result := CaretPos.Y; +end; + +function TfpgBaseTextEdit.GetCaretPosV: Integer; +begin + Result := CaretPos.X; +end; + procedure TfpgBaseTextEdit.SetFontDesc(const AValue: string); begin FFont.Free; @@ -455,6 +471,16 @@ begin FTabWidth := AValue; end; +procedure TfpgBaseTextEdit.SetCaretPosH(const AValue: integer); +begin + CaretPos.Y := AValue; +end; + +procedure TfpgBaseTextEdit.SetCaretPosV(const AValue: integer); +begin + CaretPos.X := AValue; +end; + procedure TfpgBaseTextEdit.SetVScrollPos(const AValue: Integer); begin SetVPos(AValue); @@ -666,7 +692,7 @@ end; to set selection if Shift key is pressed. } procedure TfpgBaseTextEdit.KeyboardCaretNav(const ShiftState: TShiftState; const AKeyCode: Word); var - SaveXCaret: Integer; + SaveYCaretOffset: Integer; procedure CtrlKeyLeftKey; var @@ -971,6 +997,8 @@ begin CaretPos.Y := 0; CaretPos.X := 0; end; + ScrollPos_V := 0; + UpdateScrollBars; Exit; end; if ssShift in ShiftState then @@ -1017,6 +1045,8 @@ begin CaretPos.Y := pred(FLines.Count); CaretPos.X := Length(FLines[CaretPos.Y]); end; + ScrollPos_V := CaretPos.Y - FVisLines; + UpdateScrollBars; Exit; end; if ssShift in ShiftState then @@ -1048,7 +1078,7 @@ begin FSelStartNo := CaretPos.Y; FSelStartOffs := CaretPos.X; end; - SaveXCaret := CaretPos.Y - FTopLine; + SaveYCaretOffset := CaretPos.Y - FTopLine; if AKeyCode = keyPageUp then begin if VPos = 0 then @@ -1062,15 +1092,15 @@ begin if FVScrollBar.Visible then FVScrollBar.PageUp; // restore caret at same line offset as before - CaretPos.Y := FTopLine + SaveXCaret; + CaretPos.Y := FTopLine + SaveYCaretOffset; end; end else - begin + begin { PageDown handling } if VPos > (FLines.Count - FVisLines) then begin CaretPos.Y := FLines.Count-1; - CaretPos.X := Length(FLines[CaretPos.Y]); + CaretPos.X := UTF8Length(FLines[CaretPos.Y]); end else begin @@ -1078,7 +1108,7 @@ begin if FVScrollBar.Visible then FVScrollBar.PageDown; // restore caret at same line offset as before - CaretPos.Y := FTopLine + SaveXCaret; + CaretPos.Y := FTopLine + SaveYCaretOffset; end; end; if ssShift in ShiftState then @@ -1677,6 +1707,7 @@ begin if SLine = '' then // short circut the code block begin FLines.Delete(CaretPos.Y); + FVScrollBar.Max := FVScrollBar.Max - 1; end else begin diff --git a/examples/apps/ide/src/frm_configureide.pas b/examples/apps/ide/src/frm_configureide.pas index 2b2e42c1..fad0418f 100644 --- a/examples/apps/ide/src/frm_configureide.pas +++ b/examples/apps/ide/src/frm_configureide.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit frm_configureide; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/frm_debug.pas b/examples/apps/ide/src/frm_debug.pas index 267871c2..6991b916 100644 --- a/examples/apps/ide/src/frm_debug.pas +++ b/examples/apps/ide/src/frm_debug.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit frm_debug; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/frm_find.pas b/examples/apps/ide/src/frm_find.pas index 03e27dd2..3ec856f7 100644 --- a/examples/apps/ide/src/frm_find.pas +++ b/examples/apps/ide/src/frm_find.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit frm_find; {$mode objfpc}{$H+} @@ -88,6 +104,11 @@ begin begin Consumed := True; btnFind.Click; + end + else if KeyCode = keyEscape then + begin + Consumed := True; + Close; end; end; diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas index 92d5243e..6ef73f50 100644 --- a/examples/apps/ide/src/frm_main.pas +++ b/examples/apps/ide/src/frm_main.pas @@ -1,3 +1,21 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + Maximus IDE is an example application, to showcase a bit more of + what fpGUI can do in a larger project. It also ties in a lot of + various fpGUI widgets and framework functionality. +} + unit frm_main; {$mode objfpc}{$H+} @@ -22,7 +40,6 @@ type btnOpen: TfpgButton; btnSave: TfpgButton; btnSaveAll: TfpgButton; - btnTest: TfpgButton; pnlStatusBar: TfpgBevel; lblStatus: TfpgLabel; pnlClientArea: TfpgBevel; @@ -39,8 +56,6 @@ type tsFiles: TfpgTabSheet; grdFiles: TfpgFileGrid; Splitter2: TfpgSplitter; - grdOpenFiles: TfpgStringGrid; - Splitter3: TfpgSplitter; pcEditor: TfpgPageControl; tseditor: TfpgTabSheet; TextEditor: TfpgTextEdit; @@ -54,7 +69,11 @@ type mnuSettings: TfpgPopupMenu; mnuHelp: TfpgPopupMenu; {@VFD_HEAD_END: MainForm} + {$ifdef DEBUGSVR} + btnTest: TfpgButton; + {$endif} pmOpenRecentMenu: TfpgPopupMenu; + miFile: TfpgMenuItem; miRecentProjects: TfpgMenuItem; FRecentFiles: TfpgMRU; FRegex: TRegExpr; @@ -68,6 +87,7 @@ type procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure btnQuitClicked(Sender: TObject); procedure btnOpenFileClicked(Sender: TObject); + procedure miFileNewUnit(Sender: TObject); procedure miFileSave(Sender: TObject); procedure miFileSaveAs(Sender: TObject); procedure miEditCutClicked(Sender: TObject); @@ -95,8 +115,10 @@ type procedure miRecentProjectsClick(Sender: TObject; const FileName: String); procedure miProjectSave(Sender: TObject); procedure miProjectSaveAs(Sender: TObject); + procedure AddUnitToProject(const AUnitName: TfpgString); procedure miProjectAddUnitToProject(Sender: TObject); procedure tvProjectDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint); + procedure grdMessageKeyPressed(Sender: TObject; var KeyCode: Word; var ShiftState: TShiftState; var Consumed: Boolean); procedure TabSheetClosing(Sender: TObject; ATabSheet: TfpgTabSheet); procedure BuildTerminated(Sender: TObject); procedure BuildOutput(Sender: TObject; const ALine: string); @@ -108,6 +130,7 @@ type procedure ClearMessagesWindow; procedure CloseAllTabs; procedure LoadProject(const AFilename: TfpgString); + function CreateNewEditorTab(const ATitle: TfpgString): TfpgTabSheet; function OpenEditorPage(const AFilename: TfpgString): TfpgTabSheet; procedure miTest(Sender: TObject); function GetUnitsNode: TfpgTreeNode; @@ -176,6 +199,34 @@ begin end; end; +procedure TMainForm.miFileNewUnit(Sender: TObject); +var + newunit: TfpgString; + sl: TStringList; + FInternalMacroList: TIDEMacroList; + i: integer; +begin + if fpgInputQuery('New Unit', 'Please give the new unit a file name', newunit) then + begin + if GProject.UnitList.FileExists(newunit) then + begin + ShowMessage(Format('The unit <%s> already exists in the project', [newunit])); + Exit; + end; + sl := TStringList.Create; + try + sl.LoadFromFile(GMacroList.ExpandMacro('${TEMPLATEDIR}default/unit.pas')); + sl.Text := StringReplace(sl.Text, '${UNITNAME}', fpgChangeFileExt(fpgExtractFileName(newunit), ''), [rfReplaceAll, rfIgnoreCase]); + sl.SaveToFile(GProject.ProjectDir + newunit); + finally + sl.Free; + end; +// AddUnitToProject(newunit); + + OpenEditorPage(newunit); + end; +end; + procedure TMainForm.miFileSave(Sender: TObject); var s: TfpgString; @@ -471,6 +522,7 @@ begin s := s + cProjectExt; try GProject.Save(s); + FRecentFiles.AddItem(s); except on E: Exception do begin @@ -482,26 +534,20 @@ begin end; end; -procedure TMainForm.miProjectAddUnitToProject(Sender: TObject); +procedure TMainForm.AddUnitToProject(const AUnitName: TfpgString); var u: TUnit; s: TfpgString; r: TfpgTreeNode; n: TfpgTreeNode; begin - s := pcEditor.ActivePage.Hint; -// writeln('adding unit: ', s); - if s = '' then - Exit; - if GProject.UnitList.FileExists(s) then - Exit; u := TUnit.Create; - u.FileName := s; + u.FileName := AUnitName; u.Opened := True; GProject.UnitList.Add(u); // add reference to tabsheet pcEditor.ActivePage.TagPointer := u; - s := ExtractRelativepath(GProject.ProjectDir, u.FileName); + s := fpgExtractRelativepath(GProject.ProjectDir, u.FileName); r := GetUnitsNode; n := r.AppendText(s); // add reference to treenode @@ -509,6 +555,19 @@ begin tvProject.Invalidate; end; +procedure TMainForm.miProjectAddUnitToProject(Sender: TObject); +var + s: TfpgString; +begin + s := pcEditor.ActivePage.Hint; +// writeln('adding unit: ', s); + if s = '' then + Exit; + if GProject.UnitList.FileExists(s) then + Exit; + AddUnitToProject(s); +end; + procedure TMainForm.tvProjectDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint); var r: TfpgTreeNode; @@ -528,6 +587,22 @@ begin end; end; +procedure TMainForm.grdMessageKeyPressed(Sender: TObject; var KeyCode: Word; var ShiftState: TShiftState; var Consumed: Boolean); +var + cr: TClipboardKeyType; + i: integer; + s: TfpgString; +begin + cr := CheckClipboardKey(KeyCode, ShiftState); + if cr = ckCopy then + begin + s := ''; + for i := 0 to grdMessages.RowCount-1 do + s := s + grdMessages.Cells[0, i] + LineEnding; + fpgClipboard.Text := s; + end; +end; + procedure TMainForm.TabSheetClosing(Sender: TObject; ATabSheet: TfpgTabSheet); var u: TUnit; @@ -578,8 +653,7 @@ begin begin for i := 0 to GProject.UnitList.Count-1 do begin - {$Note ExtractRelativePath still needs a fpGUI wrapper } - s := ExtractRelativepath(GProject.ProjectDir, GProject.UnitList[i].FileName); + s := fpgExtractRelativepath(GProject.ProjectDir, GProject.UnitList[i].FileName); n := r.AppendText(s); n.Data := GProject.UnitList[i]; end; @@ -655,6 +729,20 @@ begin AddMessage('Project loaded'); end; +function TMainForm.CreateNewEditorTab(const ATitle: TfpgString): TfpgTabSheet; +var + m: TfpgTextEdit; +begin + Result := pcEditor.AppendTabSheet(ATitle); + m := TfpgTextEdit.Create(Result); + m.SetPosition(1, 1, 200, 20); + m.Align := alClient; + m.FontDesc := gINI.ReadString(cEditor, 'Font', '#Edit2'); + m.GutterVisible := True; + m.GutterShowLineNumbers := True; + m.RightEdge := True; +end; + function TMainForm.OpenEditorPage(const AFilename: TfpgString): TfpgTabSheet; var s: TfpgString; @@ -662,10 +750,11 @@ var i: integer; found: Boolean; ts: TfpgTabSheet; - m: TfpgTextEdit; ext: TfpgString; pos_h: integer; pos_v: integer; + cur_pos_h: integer; + cur_pos_v: integer; editor: TfpgTextEdit; begin s := AFilename; @@ -684,10 +773,15 @@ begin editor := TfpgTextEdit(pcEditor.Pages[i].Components[0]); pos_h := editor.ScrollPos_H; pos_v := editor.ScrollPos_V; + cur_pos_h := editor.CaretPos_H; + cur_pos_v := editor.CaretPos_V; editor.Lines.BeginUpdate; editor.LoadFromFile(s); editor.ScrollPos_H := pos_h; editor.ScrollPos_V := pos_v; + editor.CaretPos_H := cur_pos_h; + editor.CaretPos_V := cur_pos_v; + editor.UpdateScrollBars; editor.Lines.EndUpdate; pcEditor.ActivePageIndex := i; ts := pcEditor.ActivePage; @@ -696,17 +790,12 @@ begin else begin // we need a new tabsheet - ts := pcEditor.AppendTabSheet(f); - m := TfpgTextEdit.Create(ts); - m.SetPosition(1, 1, 200, 20); - m.Align := alClient; - m.FontDesc := gINI.ReadString(cEditor, 'Font', '#Edit2'); - m.GutterVisible := True; - m.GutterShowLineNumbers := True; - m.RightEdge := True; - TfpgTextEdit(ts.Components[0]).Lines.BeginUpdate; - TfpgTextEdit(ts.Components[0]).Lines.LoadFromFile(s); - TfpgTextEdit(ts.Components[0]).Lines.EndUpdate; + ts := CreateNewEditorTab(f); + editor := ts.Components[0] as TfpgTextEdit; + editor.Lines.BeginUpdate; + if fpgFileExists(s) then + editor.Lines.LoadFromFile(s); + editor.Lines.EndUpdate; if gINI.ReadBool(cEditor, 'SyntaxHighlighting', True) then begin ext := fpgExtractFileExt(AFilename); @@ -733,12 +822,14 @@ var s: TfpgString; r: TfpgString; begin + {$ifdef DEBUGSVR} TempHourGlassCursor(TfpgWidget(self)); s := cMacro_Compiler + ' -FU' +cMacro_Target+' -Fu' + cMacro_FPGuiLibDir; -// writeln('source string = ', s); + SendDebug('source string = ' + s); r := GMacroList.ExpandMacro(s); -// writeln('expanded string = ', r); + SendDebug('expanded string = ' + r); sleep(5000); + {$endif} end; function TMainForm.GetUnitsNode: TfpgTreeNode; @@ -1243,20 +1334,6 @@ begin TabOrder := 6; end; - btnTest := TfpgButton.Create(Toolbar); - with btnTest do - begin - Name := 'btnTest'; - SetPosition(168, 2, 80, 24); - Text := 'test'; - Down := False; - FontDesc := '#Label1'; - Hint := ''; - ImageName := ''; - TabOrder := 7; - OnClick := @miTest; - end; - pnlStatusBar := TfpgBevel.Create(self); with pnlStatusBar do begin @@ -1325,6 +1402,7 @@ begin RowSelect := True; ShowHeader := False; TabOrder := 13; + OnKeyPress := @grdMessageKeyPressed; end; tsScribble := TfpgTabSheet.Create(pnlWindow); @@ -1420,31 +1498,6 @@ begin Align := alLeft; end; - grdOpenFiles := TfpgStringGrid.Create(pnlClientArea); - with grdOpenFiles do - begin - Name := 'grdOpenFiles'; - SetPosition(516, 2, 120, 279); - Align := alRight; - BackgroundColor := TfpgColor($80000002); - AddColumn('File', 100, taLeftJustify); - FontDesc := '#Grid'; - HeaderFontDesc := '#GridHeader'; - Hint := ''; - RowCount := 0; - RowSelect := True; - ShowHeader := False; - TabOrder := 24; - end; - - Splitter3 := TfpgSplitter.Create(pnlClientArea); - with Splitter3 do - begin - Name := 'Splitter3'; - SetPosition(508, 2, 8, 279); - Align := alRight; - end; - pcEditor := TfpgPageControl.Create(pnlClientArea); with pcEditor do begin @@ -1483,7 +1536,7 @@ begin begin Name := 'mnuFile'; SetPosition(476, 61, 172, 20); - AddMenuItem('New...', rsKeyCtrl+'N', nil).Enabled := False; + miFile := AddMenuItem('New...', rsKeyCtrl+'N', @miFileNewUnit); AddMenuItem('-', '', nil); AddMenuItem('Open...', rsKeyCtrl+'O', @btnOpenFileClicked); AddMenuItem('Open Recent', '', nil).Enabled := False; @@ -1643,6 +1696,20 @@ begin FRecentFiles.LoadMRU; {$IFDEF DEBUGSVR} + btnTest := TfpgButton.Create(Toolbar); + with btnTest do + begin + Name := 'btnTest'; + SetPosition(168, 2, 80, 24); + Text := 'test'; + Down := False; + FontDesc := '#Label1'; + Hint := ''; + ImageName := ''; + TabOrder := 7; + OnClick := @miTest; + end; + SendMethodExit('TMainForm.AfterCreate'); {$ENDIF} end; diff --git a/examples/apps/ide/src/frm_procedurelist.pas b/examples/apps/ide/src/frm_procedurelist.pas index 4b5b7548..14eb77dd 100644 --- a/examples/apps/ide/src/frm_procedurelist.pas +++ b/examples/apps/ide/src/frm_procedurelist.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit frm_procedurelist; {$mode objfpc}{$H+} @@ -194,7 +210,7 @@ begin { E := TSimpleEngine.Create; try - writeln(Format('Parsing file <%s> for OS <%s> and CPU <%s>', [FFilename, OSTarget, CPUTarget])); +// writeln(Format('Parsing file <%s> for OS <%s> and CPU <%s>', [FFilename, OSTarget, CPUTarget])); M := ParseSource(E, FFilename, OSTarget, CPUTarget); { Cool, we successfully parsed the unit. @@ -203,8 +219,7 @@ begin for I := 0 to Decls.Count - 1 do begin p := TObject(Decls[I]) as TPasElement; - Writeln('Interface item ', I, ': ' + p.Name + ' [line ' + IntToStr(p.SourceLinenumber) + ']'); - +// Writeln('Interface item ', I, ': ' + p.Name + ' [line ' + IntToStr(p.SourceLinenumber) + ']'); end; FreeAndNil(M); finally @@ -357,7 +372,7 @@ begin else if StrContains('destructor', ProcName, False) then // Do not localize. Result := ImageIndexTrash else if StrBeginsWith('class proc', ProcName, False) // Do not localize. - or StrContains('class func', ProcName, False) + or StrContains('class func', ProcName, False) or (ProcClass <> '') then Result := ImageIndexGear else @@ -991,7 +1006,7 @@ begin finally SFile.Free; end; - SendDebug('Procedure List: Starting Parse'); +// SendDebug('Procedure List: Starting Parse'); case Language of ltPas: Parser.Origin := MemStream.Memory; // ltCpp: CParser.SetOrigin(MemStream.Memory, MemStream.Size); @@ -1004,7 +1019,7 @@ begin finally LoadObjectCombobox; end; - SendDebug('Procedure List: QuickSorting procedures'); +// SendDebug('Procedure List: QuickSorting procedures'); QuickSort(0, FProcList.Count - 1); // StatusBar.Panels[1].Text := Trim(IntToStr(lvProcs.Items.Count)); finally @@ -1155,7 +1170,7 @@ begin FLanguage := ltPas; FSearchAll := True; // search anywhere in a method name // FImageList := TfpgImageList.Create; - + // CreateImage_BMP(@grdimg_destructor_16, SizeOf(grdimg_destructor_16)); fpgImages.AddMaskedBMP( // 16x16 image diff --git a/examples/apps/ide/src/frm_projectoptions.pas b/examples/apps/ide/src/frm_projectoptions.pas index 74178090..1e1c318a 100644 --- a/examples/apps/ide/src/frm_projectoptions.pas +++ b/examples/apps/ide/src/frm_projectoptions.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit frm_projectoptions; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/ideconst.pas b/examples/apps/ide/src/ideconst.pas index 03c43ec4..38973457 100644 --- a/examples/apps/ide/src/ideconst.pas +++ b/examples/apps/ide/src/ideconst.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit ideconst; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/ideimages.pas b/examples/apps/ide/src/ideimages.pas index 6963e6e9..929267af 100644 --- a/examples/apps/ide/src/ideimages.pas +++ b/examples/apps/ide/src/ideimages.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit ideimages; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/idemacros.pas b/examples/apps/ide/src/idemacros.pas index deee6507..e7632a07 100644 --- a/examples/apps/ide/src/idemacros.pas +++ b/examples/apps/ide/src/idemacros.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit idemacros; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/ideutils.pas b/examples/apps/ide/src/ideutils.pas index 672103f3..3a75dc0b 100644 --- a/examples/apps/ide/src/ideutils.pas +++ b/examples/apps/ide/src/ideutils.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit ideutils; {$mode objfpc}{$H+} @@ -101,7 +117,7 @@ type constructor Create(var AWidget: TfpgWidget); destructor Destroy; override; end; - + constructor TTempHourClassCursor.Create(var AWidget: TfpgWidget); begin inherited Create; @@ -115,7 +131,7 @@ begin FWidget.MouseCursor := FOldCursor; inherited Destroy; end; - + function TempHourGlassCursor(var AWidget: TfpgWidget): IInterface; diff --git a/examples/apps/ide/src/maximus.lpr b/examples/apps/ide/src/maximus.lpr index d481ba4a..1f758a43 100644 --- a/examples/apps/ide/src/maximus.lpr +++ b/examples/apps/ide/src/maximus.lpr @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + program maximus; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/maximus.project b/examples/apps/ide/src/maximus.project index 8c2f4261..31af43e3 100644 --- a/examples/apps/ide/src/maximus.project +++ b/examples/apps/ide/src/maximus.project @@ -3,19 +3,19 @@ ProjectName=maximus.project MainUnit=maximus.lpr TargetFile=maximus${EXEEXT} DefaultMake=0 -MakeOptionsCount=5 +MakeOptionsCount=7 MakeOptionEnabled1=1,1,1,1,1,1 MakeOptionEnabled2=1,1,1,1,1,0 -MakeOptionEnabled3=0,1,0,0,0,1 +MakeOptionEnabled3=1,1,0,0,0,1 MakeOptionEnabled4=0,0,0,0,1,1 -MacroCount=6 -Macro1=TargetCPU=x86_64 -Macro2=TargetOS=linux -Macro3=TargetCPU=i386 -Macro4=TargetOS=win32 +MacroCount=4 +Macro1=TargetCPU=i386 +Macro2=TargetOS=win32 +Macro3=FPGUI_DIR=/home/graemeg/programming/fpgui/ +Macro4=tiOPF_fpGUI_Dir=/home/graemeg/programming/3rdParty/tiOPF2/src/ Macro5=FPGUI_DIR=/home/graemeg/programming/fpgui/ Macro6=tiOPF_fpGUI_Dir=/home/graemeg/programming/3rdParty/tiOPF2/src/ -UnitDirsCount=7 +UnitDirsCount=8 UnitDirEnabled1=1,1,1,1,0,0,0,1,0,0 UnitDirEnabled2=1,1,1,1,0,0,1,1,0,0 UnitDirEnabled3=1,1,1,0,0,0,1,1,0,0 @@ -23,14 +23,18 @@ UnitDirEnabled4=0,0,0,1,0,0,1,1,0,0 UnitDirEnabled5=1,1,1,1,0,0,1,1,0,0 UnitDirEnabled6=1,1,1,1,0,0,1,0,0,0 UnitDirEnabled7=0,0,0,0,1,1,1,0,0,0 -UnitDirEnabled8=0,0,0,0,0,1,1,0,0,0 +UnitDirEnabled8=1,0,0,0,0,0,1,1,0,0 UnitOutputDir=units/${TARGET}/ MakeOptionEnabled5=1,0,0,0,0,0 +MakeOptionEnabled6=1,0,0,0,0,0 +MakeOptionEnabled7=0,0,0,0,0,0 MakeOption1=-l -Mobjfpc -Sch MakeOption2=-g -gl -O- -gw2 -godwarfsets MakeOption3=-B MakeOption4=-O2 -XX -Xs -CX MakeOption5=-veiw +MakeOption6=-dDEBUGSVR +MakeOption7=-dAGGCanvas UnitDir1=${FPGUIDIR}src/ UnitDir2=${FPGUIDIR}src/corelib/ UnitDir3=${FPGUIDIR}src/corelib/x11/ @@ -38,26 +42,27 @@ UnitDir4=${FPGUIDIR}src/corelib/gdi/ UnitDir5=${FPGUIDIR}src/gui/ UnitDir6=${FPGUIDIR}src/gui/db/ UnitDir7=${FPGUILIBDIR} +UnitDir8=${FPGUIDIR}src/corelib/render/software/ [Units] UnitCount=20 Unit1=builderthread.pas,0 Unit2=filemonitor.pas,0 -Unit3=fpg_textedit.pas,0 +Unit3=fpg_textedit.pas,-1 Unit4=frm_configureide.pas,0 Unit5=frm_debug.pas,0 Unit6=frm_find.pas,-1 Unit7=frm_main.pas,-1 -Unit8=frm_procedurelist.pas,0 -Unit9=frm_projectoptions.pas,0 +Unit8=frm_procedurelist.pas,-1 +Unit9=frm_projectoptions.pas,-1 Unit10=ideconst.pas,0 Unit11=ideimages.pas,0 -Unit12=idemacros.pas,0 +Unit12=idemacros.pas,-1 Unit13=ideutils.pas,0 Unit14=maximus.lpr,0 Unit15=mPasLex.pas,0 Unit16=project.pas,-1 Unit17=sha1.pas,0 Unit18=stringhelpers.pas,0 -Unit19=synregexpr.pas,-1 +Unit19=synregexpr.pas,0 Unit20=unitlist.pas,0 diff --git a/examples/apps/ide/src/project.pas b/examples/apps/ide/src/project.pas index cde77fdf..a82a23c5 100644 --- a/examples/apps/ide/src/project.pas +++ b/examples/apps/ide/src/project.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit Project; {$mode objfpc}{$H+} @@ -254,6 +270,7 @@ begin FIniFile := TfpgINIFile.CreateExt(AProjectFile); ProjectDir := fpgExtractFilePath(AProjectFile); + fpgSetCurrentDir(ProjectDir); ProjectName := FIniFile.ReadString(cProjectOptions, 'ProjectName', fpgChangeFileExt(fpgExtractFileName(AProjectFile), '')); MainUnit := FIniFile.ReadString(cProjectOptions, 'MainUnit', ''); TargetFile := FIniFile.ReadString(cProjectOptions, 'TargetFile', ''); diff --git a/examples/apps/ide/src/stringhelpers.pas b/examples/apps/ide/src/stringhelpers.pas index 35fb9060..6e563da5 100644 --- a/examples/apps/ide/src/stringhelpers.pas +++ b/examples/apps/ide/src/stringhelpers.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit stringhelpers; {$mode objfpc}{$H+} diff --git a/examples/apps/ide/src/templates/default/program.pas b/examples/apps/ide/src/templates/default/program.pas new file mode 100644 index 00000000..d901e3ac --- /dev/null +++ b/examples/apps/ide/src/templates/default/program.pas @@ -0,0 +1,11 @@ +program ${PROGRAMNAME}; + +{$mode objfpc}{$H+} + +uses + Classes, + SysUtils; + +begin + WriteLn('Hello'); +end. diff --git a/examples/apps/ide/src/templates/default/unit.pas b/examples/apps/ide/src/templates/default/unit.pas new file mode 100644 index 00000000..b3837ea3 --- /dev/null +++ b/examples/apps/ide/src/templates/default/unit.pas @@ -0,0 +1,9 @@ +unit ${UNITNAME}; + +{$mode objfpc}{$H+} + +interface + +implementation + +end. diff --git a/examples/apps/ide/src/templates/fpgui/mainform.pas b/examples/apps/ide/src/templates/fpgui/mainform.pas new file mode 100644 index 00000000..6b9500ac --- /dev/null +++ b/examples/apps/ide/src/templates/fpgui/mainform.pas @@ -0,0 +1,45 @@ +unit frm_main; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, + Classes, + fpg_base, + fpg_main, + fpg_form; + +type + + TMainForm = class(TfpgForm) + private + {@VFD_HEAD_BEGIN: MainForm} + {@VFD_HEAD_END: MainForm} + public + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +implementation + +{@VFD_NEWFORM_IMPL} + +procedure TMainForm.AfterCreate; +begin + {%region 'Auto-generated GUI code' -fold} + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(374, 228, 490, 258); + WindowTitle := 'MainForm'; + Hint := ''; + WindowPosition := wpOneThirdDown; + + {@VFD_BODY_END: MainForm} + {%endregion} +end; + + +end. diff --git a/examples/apps/ide/src/templates/fpgui/program.pas b/examples/apps/ide/src/templates/fpgui/program.pas new file mode 100644 index 00000000..7f3f9732 --- /dev/null +++ b/examples/apps/ide/src/templates/fpgui/program.pas @@ -0,0 +1,31 @@ +program ${PROGRAMNAME}; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpg_main, + frm_main; + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + try + frm.Show; + fpgApplication.Run; + finally + frm.Free; + end; +end; + +begin + MainProc; +end. + diff --git a/examples/apps/ide/src/templates/fpgui/program_all_in_one.pas b/examples/apps/ide/src/templates/fpgui/program_all_in_one.pas new file mode 100644 index 00000000..0b17ee85 --- /dev/null +++ b/examples/apps/ide/src/templates/fpgui/program_all_in_one.pas @@ -0,0 +1,55 @@ +program ${PROJECTNAME}; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, fpg_main, fpg_form; + +type + + TMainForm = class(TfpgForm) + public + {@VFD_HEAD_BEGIN: MainForm} + {@VFD_HEAD_END: MainForm} + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + + + +{@VFD_NEWFORM_IMPL} + +procedure TMainForm.AfterCreate; +begin + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(316, 186, 300, 250); + WindowTitle := 'MainForm'; + + {@VFD_BODY_END: MainForm} +end; + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + try + frm.Show; + fpgApplication.Run; + finally + frm.Free; + end; +end; + +begin + MainProc; +end. + + diff --git a/examples/apps/ide/src/templates/fpgui/simpleform.pas b/examples/apps/ide/src/templates/fpgui/simpleform.pas new file mode 100644 index 00000000..d804f4a3 --- /dev/null +++ b/examples/apps/ide/src/templates/fpgui/simpleform.pas @@ -0,0 +1,45 @@ +unit ${UNITNAME}; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, + Classes, + fpg_base, + fpg_main, + fpg_form; + +type + + T${FORMNAME} = class(TfpgForm) + private + {@VFD_HEAD_BEGIN: ${FORMNAME}} + {@VFD_HEAD_END: ${FORMNAME}} + public + procedure AfterCreate; override; + end; + +{@VFD_NEWFORM_DECL} + +implementation + +{@VFD_NEWFORM_IMPL} + +procedure T${FORMNAME}.AfterCreate; +begin + {%region 'Auto-generated GUI code' -fold} + {@VFD_BODY_BEGIN: ${FORMNAME}} + Name := '${FORMNAME}'; + SetPosition(374, 228, 490, 258); + WindowTitle := 'New Form'; + Hint := ''; + WindowPosition := wpOneThirdDown; + + {@VFD_BODY_END: ${FORMNAME}} + {%endregion} +end; + + +end. diff --git a/examples/apps/ide/src/templates/fptest/program.pas b/examples/apps/ide/src/templates/fptest/program.pas new file mode 100644 index 00000000..8c4729bc --- /dev/null +++ b/examples/apps/ide/src/templates/fptest/program.pas @@ -0,0 +1,30 @@ +program ${%PROGRAMNAME%}; + +{$Mode objfpc}{$H+} + + +{$Define TextRunner} +{.$Define GUIRunner} + + +{$ifdef GuiRunner} + {$apptype gui} +{$endif} + + +uses + {$IFDEF TextRunner} + TextTestRunner, + {$ENDIF} + {$IFDEF GUIRunner} + GUITestRunner, + {$ENDIF} + Classes, + SampleTests; + +begin + // Register all tests + SampleTests.RegisterTests; + + RunRegisteredTests; +end. diff --git a/examples/apps/ide/src/templates/fptest/testunit.pas b/examples/apps/ide/src/templates/fptest/testunit.pas new file mode 100644 index 00000000..83d2a624 --- /dev/null +++ b/examples/apps/ide/src/templates/fptest/testunit.pas @@ -0,0 +1,39 @@ +unit ${UNITNAME}; + +{$mode objfpc}{$H+} + +interface + +uses + TestFramework; + +type + TMyTestCase = class(TTestCase) + published + procedure FirstTest; + end; + + +procedure RegisterTests; + + +implementation + +//uses +// SomeUnitToTest; + + +procedure RegisterTests; +begin + TestFramework.RegisterTest(TMyTestCase.Suite); +end; + +{ TMyTestCase } + +procedure TMyTestCase.FirstTest; +begin + Check(2, 1+1, 'Failed on 1'); +end; + + +end. diff --git a/examples/apps/ide/src/unitlist.pas b/examples/apps/ide/src/unitlist.pas index b8ca59ad..827326e7 100644 --- a/examples/apps/ide/src/unitlist.pas +++ b/examples/apps/ide/src/unitlist.pas @@ -1,3 +1,19 @@ +{ + fpGUI IDE - Maximus + + Copyright (C) 2012 - 2013 Graeme Geldenhuys + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. + + This program 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. + + Description: + --- +} + unit UnitList; {$mode objfpc}{$H+} |