diff --git a/components/richmemo/samples/customrtfload/mainform.lfm b/components/richmemo/samples/customrtfload/mainform.lfm new file mode 100644 index 000000000..35b879156 --- /dev/null +++ b/components/richmemo/samples/customrtfload/mainform.lfm @@ -0,0 +1,128 @@ +object Form1: TForm1 + Left = 353 + Height = 435 + Top = 267 + Width = 615 + Caption = 'Custom RTF Loader' + ClientHeight = 435 + ClientWidth = 615 + OnCreate = FormCreate + LCLVersion = '1.3' + object Panel1: TPanel + Left = 0 + Height = 40 + Top = 0 + Width = 615 + Align = alTop + BevelOuter = bvNone + ClientHeight = 40 + ClientWidth = 615 + TabOrder = 0 + object Button1: TButton + Left = 8 + Height = 25 + Top = 8 + Width = 75 + Anchors = [akTop, akRight] + Caption = 'Load from File' + OnClick = Button1Click + TabOrder = 0 + end + object btnRTFtoMemo: TButton + Left = 88 + Height = 25 + Top = 8 + Width = 128 + Caption = 'RTF to Rich Memo' + OnClick = btnRTFtoMemoClick + TabOrder = 1 + end + end + object Splitter1: TSplitter + Cursor = crVSplit + Left = 0 + Height = 5 + Top = 40 + Width = 615 + Align = alTop + ResizeAnchor = akTop + end + object Memo1: TMemo + Left = 0 + Height = 90 + Top = 45 + Width = 615 + Align = alTop + Lines.Strings = ( + 'Raw RTF' + ) + TabOrder = 2 + end + object Splitter2: TSplitter + Cursor = crVSplit + Left = 0 + Height = 5 + Top = 135 + Width = 615 + Align = alTop + ResizeAnchor = akTop + end + object RichMemo1: TRichMemo + Left = 0 + Height = 165 + Top = 140 + Width = 615 + Align = alClient + HideSelection = False + Lines.Strings = ( + 'RichMemo1' + ) + TabOrder = 4 + end + object Panel2: TPanel + Left = 0 + Height = 40 + Top = 305 + Width = 615 + Align = alBottom + BevelOuter = bvNone + ClientHeight = 40 + ClientWidth = 615 + TabOrder = 5 + object Button2: TButton + Left = 8 + Height = 25 + Top = 8 + Width = 136 + Caption = 'Rich Memo to RTF' + OnClick = Button2Click + TabOrder = 0 + end + object Button3: TButton + Left = 152 + Height = 25 + Top = 8 + Width = 75 + Caption = 'Save to File' + OnClick = Button3Click + TabOrder = 1 + end + end + object Memo2: TMemo + Left = 0 + Height = 90 + Top = 345 + Width = 615 + Align = alBottom + Lines.Strings = ( + 'Memo2' + ) + TabOrder = 6 + end + object OpenDialog1: TOpenDialog + left = 240 + end + object SaveDialog1: TSaveDialog + left = 288 + end +end diff --git a/components/richmemo/samples/customrtfload/mainform.pas b/components/richmemo/samples/customrtfload/mainform.pas new file mode 100644 index 000000000..fac651547 --- /dev/null +++ b/components/richmemo/samples/customrtfload/mainform.pas @@ -0,0 +1,79 @@ +unit mainform; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, + Buttons, ComCtrls, Spin, ExtCtrls, RichMemo, RichMemoUtils, RichMemoRTF; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + Button2: TButton; + Button3: TButton; + btnRTFtoMemo: TButton; + Memo1: TMemo; + Memo2: TMemo; + OpenDialog1: TOpenDialog; + Panel1: TPanel; + Panel2: TPanel; + RichMemo1: TRichMemo; + SaveDialog1: TSaveDialog; + Splitter1: TSplitter; + Splitter2: TSplitter; + procedure btnRTFtoMemoClick(Sender: TObject); + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { private declarations } + public + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.Button1Click(Sender: TObject); +begin + if OpenDialog1.Execute then begin + Memo1.Lines.LoadFromFile( OpenDialog1.FileName ); + btnRTFtoMemoClick(nil); + end; +end; + +procedure TForm1.btnRTFtoMemoClick(Sender: TObject); +begin + RichMemo1.Rtf:=Memo1.Text; +end; + +procedure TForm1.Button2Click(Sender: TObject); +begin + Memo2.Text:=RichMemo1.Rtf; +end; + +procedure TForm1.Button3Click(Sender: TObject); +begin + if SaveDialog1.Execute then + Memo2.Lines.SaveToFile(SaveDialog1.FileName); +end; + +procedure TForm1.FormCreate(Sender: TObject); +begin + RegisterRTFLoader; + RegisterRTFSaver; +end; + +end. + diff --git a/components/richmemo/samples/customrtfload/testload.lpi b/components/richmemo/samples/customrtfload/testload.lpi new file mode 100644 index 000000000..6e8448c98 --- /dev/null +++ b/components/richmemo/samples/customrtfload/testload.lpi @@ -0,0 +1,78 @@ + + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + </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"/> + <LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="richmemopackage"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="testload.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="mainform.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="mainform"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="testload"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + </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/customrtfload/testload.lpr b/components/richmemo/samples/customrtfload/testload.lpr new file mode 100644 index 000000000..36eaaff90 --- /dev/null +++ b/components/richmemo/samples/customrtfload/testload.lpr @@ -0,0 +1,20 @@ +program testload; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, mainform, richmemopackage; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. +