From 04b7618b48625dad794ee39caa1cd9cc50e76959 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Mon, 6 Apr 2015 00:59:39 +0000 Subject: [PATCH] richmemo: links example git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4076 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../richmemo/samples/links/project1.lpi | 84 +++++++++++++++++++ .../richmemo/samples/links/project1.lpr | 21 +++++ components/richmemo/samples/links/unit1.lfm | 43 ++++++++++ components/richmemo/samples/links/unit1.pas | 69 +++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 components/richmemo/samples/links/project1.lpi create mode 100644 components/richmemo/samples/links/project1.lpr create mode 100644 components/richmemo/samples/links/unit1.lfm create mode 100644 components/richmemo/samples/links/unit1.pas diff --git a/components/richmemo/samples/links/project1.lpi b/components/richmemo/samples/links/project1.lpi new file mode 100644 index 000000000..aa68a91c3 --- /dev/null +++ b/components/richmemo/samples/links/project1.lpi @@ -0,0 +1,84 @@ + + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="richmemopackage"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="project1"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Other> + <CompilerMessages> + <MsgFileName Value=""/> + </CompilerMessages> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/richmemo/samples/links/project1.lpr b/components/richmemo/samples/links/project1.lpr new file mode 100644 index 000000000..ced6d8255 --- /dev/null +++ b/components/richmemo/samples/links/project1.lpr @@ -0,0 +1,21 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/richmemo/samples/links/unit1.lfm b/components/richmemo/samples/links/unit1.lfm new file mode 100644 index 000000000..54a353cb0 --- /dev/null +++ b/components/richmemo/samples/links/unit1.lfm @@ -0,0 +1,43 @@ +object Form1: TForm1 + Left = 270 + Height = 240 + Top = 168 + Width = 320 + Caption = 'Form1' + ClientHeight = 240 + ClientWidth = 320 + OnCreate = FormCreate + LCLVersion = '1.2.4.0' + object RichMemo1: TRichMemo + Left = 8 + Height = 186 + Top = 40 + Width = 296 + Anchors = [akTop, akLeft, akRight, akBottom] + HideSelection = False + Lines.Strings = ( + 'RichMemo1' + ) + OnMouseUp = RichMemo1MouseUp + TabOrder = 0 + ZoomFactor = 1 + end + object Button1: TButton + Left = 8 + Height = 25 + Top = 8 + Width = 75 + Caption = 'Button1' + OnClick = Button1Click + TabOrder = 1 + end + object Button2: TButton + Left = 88 + Height = 25 + Top = 8 + Width = 75 + Caption = 'Button2' + OnClick = Button2Click + TabOrder = 2 + end +end diff --git a/components/richmemo/samples/links/unit1.pas b/components/richmemo/samples/links/unit1.pas new file mode 100644 index 000000000..791306a9a --- /dev/null +++ b/components/richmemo/samples/links/unit1.pas @@ -0,0 +1,69 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, + RichMemo; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + Button2: TButton; + RichMemo1: TRichMemo; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure RichMemo1MouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + private + { private declarations } + public + { public declarations } + procedure OnLinkAction(Sender: TObject; AAction: TLinkAction; + const AMouseInfo: TLinkMouseInfo; StartChar, LenChars: Integer); + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.Button1Click(Sender: TObject); +begin + RichMemo1.SetLink(RichMemo1.SelStart, RichMemo1.SelLength, true); +end; + +procedure TForm1.Button2Click(Sender: TObject); +begin + RichMemo1.SetLink(RichMemo1.SelStart, RichMemo1.SelLength, false); +end; + +procedure TForm1.FormCreate(Sender: TObject); +begin + RichMemo1.OnLinkAction:=@OnLinkAction; +end; + +procedure TForm1.RichMemo1MouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin +end; + +procedure TForm1.OnLinkAction(Sender: TObject; AAction: TLinkAction; + const AMouseInfo: TLinkMouseInfo; StartChar, LenChars: Integer); +begin + if AMouseInfo.button = mbLeft then + writeln('sel: ', StartChar,' ', LenChars); +end; + +end. +