From a32406dc1d6b63f3447f4dfea186515cc5140d5c Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sun, 19 Apr 2015 03:30:11 +0000 Subject: [PATCH] richmemo: added hittest (CharAtPos) example git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4087 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../richmemo/samples/hittest/hittest.lpi | 91 +++++++++++++++++++ .../richmemo/samples/hittest/hittest.lpr | 21 +++++ .../richmemo/samples/hittest/mainform.lfm | 32 +++++++ .../richmemo/samples/hittest/mainform.pas | 40 ++++++++ 4 files changed, 184 insertions(+) create mode 100644 components/richmemo/samples/hittest/hittest.lpi create mode 100644 components/richmemo/samples/hittest/hittest.lpr create mode 100644 components/richmemo/samples/hittest/mainform.lfm create mode 100644 components/richmemo/samples/hittest/mainform.pas diff --git a/components/richmemo/samples/hittest/hittest.lpi b/components/richmemo/samples/hittest/hittest.lpi new file mode 100644 index 000000000..9d080779b --- /dev/null +++ b/components/richmemo/samples/hittest/hittest.lpi @@ -0,0 +1,91 @@ + + + + + + + + + + <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="hittest.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="hittest"/> + </Unit0> + <Unit1> + <Filename Value="mainform.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="mainform"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="hittest"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + <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/hittest/hittest.lpr b/components/richmemo/samples/hittest/hittest.lpr new file mode 100644 index 000000000..521521843 --- /dev/null +++ b/components/richmemo/samples/hittest/hittest.lpr @@ -0,0 +1,21 @@ +program hittest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, mainform + { 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/hittest/mainform.lfm b/components/richmemo/samples/hittest/mainform.lfm new file mode 100644 index 000000000..7b2a663aa --- /dev/null +++ b/components/richmemo/samples/hittest/mainform.lfm @@ -0,0 +1,32 @@ +object Form1: TForm1 + Left = 457 + Height = 240 + Top = 261 + Width = 320 + Caption = 'Form1' + ClientHeight = 240 + ClientWidth = 320 + LCLVersion = '1.2.4.0' + object RichMemo1: TRichMemo + Left = 8 + Height = 208 + Top = 16 + Width = 304 + Anchors = [akTop, akLeft, akRight, akBottom] + HideSelection = False + Lines.Strings = ( + 'Move mouse cursor over this Rich Memo. ' + 'Form caption should change to the result of ' + 'CharAtPos' + '123457890 123457890 123457890' + '' + '' + '123457890 123457890 123457890' + ) + OnMouseMove = RichMemo1MouseMove + Rtf = '{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Segoe UI;}{\f1\fnil Segoe UI;}}'#13#10'{\*\generator Riched20 6.3.9600}\viewkind4\uc1 '#13#10'\pard\f0\fs18 Move mouse cursor over this Rich Memo. Form caption should change to the result of CharAtPos\par'#13#10'123457890 123457890 123457890\par'#13#10'\par'#13#10'\par'#13#10'123457890 123457890 123457890\f1\par'#13#10'\par'#13#10'}'#13#10#0 + ScrollBars = ssVertical + TabOrder = 0 + ZoomFactor = 1 + end +end diff --git a/components/richmemo/samples/hittest/mainform.pas b/components/richmemo/samples/hittest/mainform.pas new file mode 100644 index 000000000..76ae7eade --- /dev/null +++ b/components/richmemo/samples/hittest/mainform.pas @@ -0,0 +1,40 @@ +unit mainform; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, RichMemo; + +type + + { TForm1 } + + TForm1 = class(TForm) + RichMemo1: TRichMemo; + procedure RichMemo1MouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.RichMemo1MouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + Caption:=IntToStr(RichMemo1.CharAtPos(x,y)); +end; + +end. +