richmemo: links example

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4076 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-04-06 00:59:39 +00:00
parent 1a43d1dc90
commit 04b7618b48
4 changed files with 217 additions and 0 deletions

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/>
<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>

View File

@ -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.

View File

@ -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

View File

@ -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.