From 00fcff257a68cc094f644f203338c531d0b5033f Mon Sep 17 00:00:00 2001 From: blikblum Date: Sat, 12 Dec 2009 20:21:04 +0000 Subject: [PATCH] * Add ContentToText and ContentToUnicode for backward compatibility * Advanced demo: fix compilation and add ability to save as UTF-8 git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1044 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../virtualtreeview-new/trunk/VirtualTrees.pas | 14 ++++++++++++++ .../trunk/demos/advanced/GeneralAbilitiesDemo.lfm | 12 +++++++----- .../trunk/demos/advanced/GeneralAbilitiesDemo.pas | 10 +++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/components/virtualtreeview-new/trunk/VirtualTrees.pas b/components/virtualtreeview-new/trunk/VirtualTrees.pas index 2e9124155..aed0c12a3 100644 --- a/components/virtualtreeview-new/trunk/VirtualTrees.pas +++ b/components/virtualtreeview-new/trunk/VirtualTrees.pas @@ -3392,6 +3392,8 @@ type function ContentToHTML(Source: TVSTTextSourceType; const Caption: String = ''): String; function ContentToRTF(Source: TVSTTextSourceType): AnsiString; function ContentToAnsi(Source: TVSTTextSourceType; const Separator: String): AnsiString; + function ContentToText(Source: TVSTTextSourceType; const Separator: String): AnsiString; inline; + function ContentToUnicode(Source: TVSTTextSourceType; const Separator: String): WideString; inline; function ContentToUTF16(Source: TVSTTextSourceType; const Separator: String): WideString; function ContentToUTF8(Source: TVSTTextSourceType; const Separator: String): String; procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; @@ -33248,6 +33250,18 @@ begin end; end; +function TCustomVirtualStringTree.ContentToText(Source: TVSTTextSourceType; + const Separator: String): AnsiString; +begin + Result := ContentToAnsi(Source, Separator); +end; + +function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; + const Separator: String): WideString; +begin + Result := ContentToUTF16(Source, Separator); +end; + //---------------------------------------------------------------------------------------------------------------------- procedure TCustomVirtualStringTree.AddContentToBuffer(Buffer: TBufferedUTF8String; Source: TVSTTextSourceType; const Separator: String); diff --git a/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.lfm b/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.lfm index 272ba7464..b3f124792 100644 --- a/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.lfm +++ b/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.lfm @@ -12,7 +12,7 @@ object GeneralForm: TGeneralForm KeyPreview = True OnCreate = FormCreate ShowHint = True - LCLVersion = '0.9.27' + LCLVersion = '0.9.29' object Label18: TLabel Left = 502 Height = 14 @@ -85,6 +85,7 @@ object GeneralForm: TGeneralForm Hint = 'Image only column.' MaxWidth = 22 Options = [coEnabled, coParentBidiMode, coVisible] + Position = 0 Spacing = 0 Width = 22 end @@ -97,8 +98,7 @@ object GeneralForm: TGeneralForm Text = 'Language column' Width = 300 end> - Header.Font.Height = -11 - Header.Font.Name = 'Lucida Sans Unicode' + Header.DefaultHeight = 17 Header.Height = 20 Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoHotTrack, hoShowHint, hoVisible] Header.ParentFont = True @@ -158,6 +158,7 @@ object GeneralForm: TGeneralForm Top = 455 Width = 37 Anchors = [akRight, akBottom] + Min = 0 Max = 2 Increment = 2 Orientation = udHorizontal @@ -867,6 +868,8 @@ object GeneralForm: TGeneralForm object FontDialog1: TFontDialog Font.Height = -11 Font.Name = 'MS Sans Serif' + MinFontSize = 0 + MaxFontSize = 0 left = 84 top = 148 end @@ -884,8 +887,7 @@ object GeneralForm: TGeneralForm end end object SaveDialog: TSaveDialog - Filter = 'HTML file in UTF-8 (*.htm; *.html)|*.htm;*.html|Unicode UTF-16 text file (*.uni)|*.uni|Rich text UTF-16 file (*.rtf)|*.rtf|Comma separated values ANSI text file (*.csv)|*.csv|Plain ANSI text file (*.txt)|*.txt' - FilterIndex = 0 + Filter = 'HTML file in UTF-8 (*.htm; *.html)|*.htm;*.html|Unicode UTF-16 text file (*.uni)|*.uni|Rich text UTF-16 file (*.rtf)|*.rtf|Comma separated values ANSI text file (*.csv)|*.csv|Unicode UTF-8 text file (*.txt)|*.txt|Plain ANSI text file (*.txt)|*.txt' Options = [ofOverwritePrompt, ofHideReadOnly, ofExtensionDifferent, ofEnableSizing] left = 148 top = 148 diff --git a/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.pas b/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.pas index 92390cea3..8fa940863 100644 --- a/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.pas +++ b/components/virtualtreeview-new/trunk/demos/advanced/GeneralAbilitiesDemo.pas @@ -489,7 +489,7 @@ const var S: string; - WS: UTF8String; + WS: WideString; Data: Pointer; DataSize: Cardinal; TargetName: string; @@ -500,6 +500,7 @@ begin if Execute then begin TargetName := FileName; + writeln('Filter Index: ', FilterIndex); case FilterIndex of 1: // HTML begin @@ -530,6 +531,13 @@ begin Data := PChar(S); DataSize := Length(S); end; + 5: // Unicode UTF-8 text file + begin + TargetName := ChangeFileExt(TargetName, '.txt'); + S := VST2.ContentToUTF8(tstVisible, #9); + Data := PChar(S); + DataSize := Length(S); + end; else // Plain text file TargetName := ChangeFileExt(TargetName, '.txt');