* Change WideString to UnicodeString (an alias to Widestring) to help in the migration for UTF8

* Complete the sync  with the main repository started earlier

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@629 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2008-12-14 00:09:21 +00:00
parent 7fa5265c86
commit 73a72ee52c

View File

@ -159,13 +159,13 @@ unit VirtualTrees;
// For full document history see help file.
//
// Credits for their valuable assistance and code donations go to:
// Freddy Ertl, Marian Aldenhvel, Thomas Bogenrieder, Jim Kuenemann, Werner Lehmann, Jens Treichler,
// Paul Gallagher (IBO tree), Ondrej Kelle, Ronaldo Melo Ferraz, Heri Bender, Roland Bedrftig (BCB)
// Freddy Ertl, Marian Aldenhövel, Thomas Bogenrieder, Jim Kuenemann, Werner Lehmann, Jens Treichler,
// Paul Gallagher (IBO tree), Ondrej Kelle, Ronaldo Melo Ferraz, Heri Bender, Roland Bedürftig (BCB)
// Anthony Mills, Alexander Egorushkin (BCB), Mathias Torell (BCB), Frank van den Bergh, Vadim Sedulin, Peter Evans,
// Milan Vandrovec (BCB), Steve Moss, Joe White, David Clark, Anders Thomsen, Igor Afanasyev, Eugene Programmer,
// Corbin Dunn, Richard Pringle, Uli Gerhardt, Azza, Igor Savkic, Daniel Bauten, Timo Tegtmeier
// Beta testers:
// Freddy Ertl, Hans-Jrgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein,
// Freddy Ertl, Hans-Jürgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein,
// Wim van der Vegt, Franc v/d Westelaken
// Indirect contribution (via publicly accessible work of those persons):
// Alex Denissov, Hiroyuki Hori (MMXAsm expert)
@ -178,8 +178,8 @@ unit VirtualTrees;
// Subversion (server), TortoiseSVN (client tools), Fisheye (Web interface)
// Accessability implementation:
// Marco Zehe (with help from Sebastian Modersohn)
// LCL Port (version 4.5.1):
// Luiz Amrico Pereira Cmara
// LCL Port:
// Luiz Américo Pereira Câmara
//----------------------------------------------------------------------------------------------------------------------
interface
@ -360,6 +360,8 @@ var // Clipboard format IDs used in OLE drag'n drop and clipboard transfers.
{$MinEnumSize 1, make enumerations as small as possible}
type
UnicodeString = WideString;
// The exception used by the trees.
EVirtualTreeError = class(Exception);
@ -778,12 +780,10 @@ type
sdDown
);
// OLE drag'n drop support
TFormatEtcArray = array of TFormatEtc;
TFormatArray = array of Word;
// IDataObject.SetData support
TInternalStgMedium = packed record
Format: TClipFormat;
@ -832,7 +832,6 @@ type
function InitializeFromWindow(Window: HWND; var ppt: TPoint; pDataObject: IDataObject): HRESULT; stdcall;
end;
IVTDragManager = interface(IUnknown)
['{C4B25559-14DA-446B-8901-0C879000EB16}']
procedure ForceDragLeave; stdcall;
@ -915,16 +914,15 @@ type
function QueryContinueDrag(EscapePressed: BOOL; KeyState: Integer): HResult; stdcall;
end;
PVTHintData = ^TVTHintData;
TVTHintData = record
Tree: TBaseVirtualTree;
Node: PVirtualNode;
Column: TColumnIndex;
HintRect: TRect; // used for draw trees only, string trees get the size from the hint string
DefaultHint: WideString; // used only if there is no node specific hint string available
DefaultHint: UnicodeString; // used only if there is no node specific hint string available
// or a header hint is about to appear
HintText: WideString; // set when size of the hint window is calculated
HintText: UnicodeString; // set when size of the hint window is calculated
BidiMode: TBidiMode;
Alignment: TAlignment;
LineBreakStyle: TVTToolTipLineBreakStyle;
@ -954,6 +952,7 @@ type
procedure WMShowWindow(var Message: TLMShowWindow); message LM_SHOWWINDOW;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
@ -1045,7 +1044,7 @@ type
TVirtualTreeColumn = class(TCollectionItem)
private
FText,
FHint: WideString;
FHint: UnicodeString;
FLeft,
FWidth: Integer;
FPosition: TColumnPosition;
@ -1078,7 +1077,7 @@ type
procedure SetPosition(Value: TColumnPosition);
procedure SetSpacing(Value: Integer);
procedure SetStyle(Value: TVirtualTreeColumnStyle);
procedure SetText(const Value: WideString);
procedure SetText(const Value: UnicodeString);
procedure SetWidth(Value: Integer);
protected
procedure ComputeHeaderLayout(DC: HDC; const Client: TRect; UseHeaderGlyph, UseSortGlyph: Boolean;
@ -1111,7 +1110,7 @@ type
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode stored IsBiDiModeStored default bdLeftToRight;
property Color: TColor read FColor write SetColor stored IsColorStored default clWindow;
property Hint: WideString read FHint write FHint stored False;
property Hint: UnicodeString read FHint write FHint stored False;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
property Layout: TVTHeaderColumnLayout read FLayout write SetLayout default blGlyphLeft;
property Margin: Integer read FMargin write SetMargin default 4;
@ -1122,7 +1121,7 @@ type
property Spacing: Integer read FSpacing write SetSpacing default 4;
property Style: TVirtualTreeColumnStyle read FStyle write SetStyle default vsText;
property Tag: Integer read FTag write FTag default 0;
property Text: WideString read FText write SetText stored False; // Never let the VCL store the wide string,
property Text: UnicodeString read FText write SetText stored False; // Never let the VCL store the wide string,
// it is simply unable to write it correctly.
// We use DefineProperties here.
property Width: Integer read FWidth write SetWidth default 50;
@ -1162,7 +1161,7 @@ type
procedure AdjustPosition(Column: TVirtualTreeColumn; Position: Cardinal);
function CanSplitterResize(P: TPoint; Column: TColumnIndex): Boolean;
procedure DoCanSplitterResize(P: TPoint; Column: TColumnIndex; var Allow: Boolean);
procedure DrawButtonText(DC: HDC; Caption: WideString; Bounds: TRect; Enabled, Hot: Boolean; DrawFormat: Cardinal);
procedure DrawButtonText(DC: HDC; Caption: UnicodeString; Bounds: TRect; Enabled, Hot: Boolean; DrawFormat: Cardinal);
procedure DrawXPButton(DC: HDC; const ButtonR: TRect; DrawSplitter, Down, Hover: Boolean);
procedure FixPositions;
function GetColumnAndBounds(const P: TPoint; var ColumnLeft, ColumnRight: Integer; Relative: Boolean = True): Integer;
@ -1742,7 +1741,7 @@ type
TVTGetImageExEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer; var ImageList: TCustomImageList) of object;
TVTGetImageTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var ImageText: WideString) of object;
var ImageText: UnicodeString) of object;
TVTHotNodeChangeEvent = procedure(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode) of object;
TVTInitChildrenEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal) of object;
TVTInitNodeEvent = procedure(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
@ -1823,7 +1822,7 @@ type
// search, sort
TVTCompareEvent = procedure(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
var Result: Integer) of object;
TVTIncrementalSearchEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: WideString;
TVTIncrementalSearchEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: UnicodeString;
var Result: Integer) of object;
// miscellaneous
@ -1972,7 +1971,7 @@ type
// search
FIncrementalSearch: TVTIncrementalSearch; // Used to determine whether and how incremental search is to be used.
FSearchTimeout: Cardinal; // Number of milliseconds after which to stop incremental searching.
FSearchBuffer: WideString; // Collects a sequence of keypresses used to do incremental searching.
FSearchBuffer: UnicodeString; // Collects a sequence of keypresses used to do incremental searching.
FLastSearchNode: PVirtualNode; // Reference to node which was last found as search fit.
FSearchDirection: TVTSearchDirection; // Direction to incrementally search the tree.
FSearchStart: TVTSearchStart; // Where to start iteration on each key press.
@ -2363,10 +2362,10 @@ type
function DoGetImageIndex(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var Index: Integer): TCustomImageList; virtual;
procedure DoGetImageText(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var ImageText: WideString); virtual;
var ImageText: UnicodeString); virtual;
procedure DoGetLineStyle(var Bits: Pointer); virtual;
function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): WideString; virtual;
function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): WideString; virtual;
function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; virtual;
function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; virtual;
function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; virtual;
function DoGetPopupMenu(Node: PVirtualNode; Column: TColumnIndex; const Position: TPoint): TPopupMenu; virtual;
procedure DoGetUserClipboardFormats(var Formats: TFormatEtcArray); virtual;
@ -2382,7 +2381,7 @@ type
procedure DoHeaderMouseMove(Shift: TShiftState; X, Y: Integer); virtual;
procedure DoHeaderMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
procedure DoHotChange(Old, New: PVirtualNode); virtual;
function DoIncrementalSearch(Node: PVirtualNode; const Text: WideString): Integer; virtual;
function DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; virtual;
procedure DoInitChildren(Node: PVirtualNode; var ChildCount: Cardinal); virtual;
procedure DoInitNode(Parent, Node: PVirtualNode; var InitStates: TVirtualNodeInitStates); virtual;
function DoKeyAction(var CharCode: Word; var Shift: TShiftState): Boolean; virtual;
@ -2602,6 +2601,7 @@ type
property OnGetHelpContext: TVTHelpContextEvent read FOnGetHelpContext write FOnGetHelpContext;
property OnGetImageIndex: TVTGetImageEvent read FOnGetImage write FOnGetImage;
property OnGetImageIndexEx: TVTGetImageExEvent read FOnGetImageEx write FOnGetImageEx;
property OnGetImageText: TVTGetImageTextEvent read FOnGetImageText write FOnGetImageText;
property OnGetLineStyle: TVTGetLineStyleEvent read FOnGetLineStyle write FOnGetLineStyle;
property OnGetNodeDataSize: TVTGetNodeDataSizeEvent read FOnGetNodeDataSize write FOnGetNodeDataSize;
property OnGetPopupMenu: TVTPopupEvent read FOnGetPopupMenu write FOnGetPopupMenu;
@ -2742,7 +2742,7 @@ type
function GetSortedCutCopySet(Resolve: Boolean): TNodeArray;
function GetSortedSelection(Resolve: Boolean): TNodeArray;
procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect;
var Text: WideString); virtual;
var Text: UnicodeString); virtual;
function GetTreeRect: TRect;
function GetVisibleParent(Node: PVirtualNode): PVirtualNode;
function HasAsParent(Node, PotentialParent: PVirtualNode): Boolean;
@ -2826,7 +2826,7 @@ type
property OffsetXY: TPoint read GetOffsetXY write SetOffsetXY;
property OffsetY: Integer read FOffsetY write SetOffsetY;
property RootNode: PVirtualNode read FRoot;
property SearchBuffer: WideString read FSearchBuffer;
property SearchBuffer: UnicodeString read FSearchBuffer;
property Selected[Node: PVirtualNode]: Boolean read GetSelected write SetSelected;
property TotalCount: Cardinal read GetTotalCount;
property TreeStates: TVirtualTreeStates read FStates write FStates;
@ -2955,19 +2955,19 @@ type
TVTPaintText = procedure(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType) of object;
TVSTGetTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType; var CellText: WideString) of object;
TextType: TVSTTextType; var CellText: UnicodeString) of object;
TVSTGetHintEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString) of object;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: UnicodeString) of object;
// New text can only be set for variable caption.
TVSTNewTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
const NewText: WideString) of object;
const NewText: UnicodeString) of object;
TVSTShortenStringEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; const S: WideString; TextSpace: Integer; var Result: WideString;
Column: TColumnIndex; const S: UnicodeString; TextSpace: Integer; var Result: UnicodeString;
var Done: Boolean) of object;
TCustomVirtualStringTree = class(TBaseVirtualTree)
private
FDefaultText: WideString; // text to show if there's no OnGetText event handler (e.g. at design time)
FDefaultText: UnicodeString; // text to show if there's no OnGetText event handler (e.g. at design time)
FTextHeight: Integer; // true size of the font
FEllipsisWidth: Integer; // width of '...' for the current font
FInternalDataOffset: Cardinal; // offset to the internal data of the string tree
@ -2979,40 +2979,42 @@ type
FOnNewText: TVSTNewTextEvent; // used to notify the application about an edited node caption
FOnShortenString: TVSTShortenStringEvent; // used to allow the application a customized string shortage
function GetImageText(Node: PVirtualNode; Kind: TVTImageKind;
Column: TColumnIndex): UnicodeString;
procedure GetRenderStartValues(Source: TVSTTextSourceType; var Node: PVirtualNode;
var NextNodeProc: TGetNextNodeProc);
function GetOptions: TCustomStringTreeOptions;
function GetText(Node: PVirtualNode; Column: TColumnIndex): WideString;
function GetText(Node: PVirtualNode; Column: TColumnIndex): UnicodeString;
procedure InitializeTextProperties(var PaintInfo: TVTPaintInfo);
procedure PaintNormalText(var PaintInfo: TVTPaintInfo; TextOutFlags: Integer; Text: WideString);
procedure PaintStaticText(const PaintInfo: TVTPaintInfo; TextOutFlags: Integer; const Text: WideString);
procedure PaintNormalText(var PaintInfo: TVTPaintInfo; TextOutFlags: Integer; Text: UnicodeString);
procedure PaintStaticText(const PaintInfo: TVTPaintInfo; TextOutFlags: Integer; const Text: UnicodeString);
procedure ReadText(Reader: TReader);
procedure SetDefaultText(const Value: WideString);
procedure SetDefaultText(const Value: UnicodeString);
procedure SetOptions(const Value: TCustomStringTreeOptions);
procedure SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: WideString);
procedure SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: UnicodeString);
procedure WriteText(Writer: TWriter);
procedure WMSetFont(var Msg: TLMNoParams{TWMSetFont}); message LM_SETFONT;
protected
procedure AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); override;
function CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const Text: WideString): Integer; virtual;
function CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const Text: UnicodeString): Integer; virtual;
function ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; override;
procedure DefineProperties(Filer: TFiler); override;
function DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; override;
function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): WideString; override;
function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): WideString; override;
function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; override;
function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; override;
function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; override;
procedure DoGetText(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var Text: WideString); virtual;
function DoIncrementalSearch(Node: PVirtualNode; const Text: WideString): Integer; override;
procedure DoNewText(Node: PVirtualNode; Column: TColumnIndex; const Text: WideString); virtual;
var Text: UnicodeString); virtual;
function DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; override;
procedure DoNewText(Node: PVirtualNode; Column: TColumnIndex; const Text: UnicodeString); virtual;
procedure DoPaintNode(var PaintInfo: TVTPaintInfo); override;
procedure DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex;
TextType: TVSTTextType); virtual;
function DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const S: WideString; Width: Integer;
EllipsisWidth: Integer = 0): WideString; virtual;
procedure DoTextDrawing(var PaintInfo: TVTPaintInfo; const Text: WideString; CellRect: TRect; DrawFormat: Cardinal); virtual;
function DoTextMeasuring(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const Text: WideString): Integer; virtual;
function DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const S: UnicodeString; Width: Integer;
EllipsisWidth: Integer = 0): UnicodeString; virtual;
procedure DoTextDrawing(var PaintInfo: TVTPaintInfo; const Text: UnicodeString; CellRect: TRect; DrawFormat: Cardinal); virtual;
function DoTextMeasuring(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const Text: UnicodeString): Integer; virtual;
function GetOptionsClass: TTreeOptionsClass; override;
function InternalData(Node: PVirtualNode): Pointer;
procedure MainColumnChanged; override;
@ -3022,7 +3024,7 @@ type
function RenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; ForClipboard: Boolean): HResult; override;
procedure WriteChunks(Stream: TStream; Node: PVirtualNode); override;
property DefaultText: WideString read FDefaultText write SetDefaultText stored False;
property DefaultText: UnicodeString read FDefaultText write SetDefaultText stored False;
property EllipsisWidth: Integer read FEllipsisWidth;
property TreeOptions: TCustomStringTreeOptions read GetOptions write SetOptions;
@ -3034,19 +3036,20 @@ type
public
constructor Create(AOwner: TComponent); override;
function ComputeNodeHeight(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; S: WideString = ''): Integer; virtual;
function ComputeNodeHeight(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; S: UnicodeString = ''): Integer; virtual;
function ContentToClipboard(Format: Word; Source: TVSTTextSourceType): HGLOBAL;
function ContentToHTML(Source: TVSTTextSourceType; const Caption: WideString = ''): string;
function ContentToRTF(Source: TVSTTextSourceType): string;
function ContentToText(Source: TVSTTextSourceType; Separator: Char): string;
function ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): WideString;
function ContentToHTML(Source: TVSTTextSourceType; const Caption: UnicodeString = ''): AnsiString;
function ContentToRTF(Source: TVSTTextSourceType): AnsiString;
function ContentToText(Source: TVSTTextSourceType; Separator: AnsiChar): AnsiString; // AnsiText
function ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): UnicodeString;
procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect;
var Text: WideString); override;
var Text: UnicodeString); override;
function InvalidateNode(Node: PVirtualNode): TRect; override;
function Path(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; Delimiter: WideChar): WideString;
function Path(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; Delimiter: WideChar): UnicodeString;
procedure ReinitNode(Node: PVirtualNode; Recursive: Boolean); override;
property Text[Node: PVirtualNode; Column: TColumnIndex]: WideString read GetText write SetText;
property ImageText[Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex]: UnicodeString read GetImageText;
property Text[Node: PVirtualNode; Column: TColumnIndex]: UnicodeString read GetText write SetText;
end;
TVirtualStringTree = class(TCustomVirtualStringTree)
@ -3194,6 +3197,7 @@ type
property OnGetHelpContext;
property OnGetImageIndex;
property OnGetImageIndexEx;
property OnGetImageText;
property OnGetHint;
property OnGetLineStyle;
property OnGetNodeDataSize;
@ -3486,7 +3490,7 @@ procedure AlphaBlend(Source, Destination: HDC; const R: TRect; const Target: TPo
{$ifdef EnablePrint}
procedure PrtStretchDrawDIB(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
{$endif}
function ShortenString(DC: HDC; const S: WideString; Width: Integer; EllipsisWidth: Integer = 0): WideString;
function ShortenString(DC: HDC; const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString;
function TreeFromNode(Node: PVirtualNode): TBaseVirtualTree;
//----------------------------------------------------------------------------------------------------------------------
@ -3682,14 +3686,14 @@ type
FStart,
FPosition,
FEnd: PWideChar;
function GetAsString: WideString;
function GetAsString: UnicodeString;
public
destructor Destroy; override;
procedure Add(const S: WideString);
procedure Add(const S: UnicodeString);
procedure AddNewLine;
property AsString: WideString read GetAsString;
property AsString: UnicodeString read GetAsString;
end;
var
@ -4073,7 +4077,7 @@ end;
//----------------- utility functions ----------------------------------------------------------------------------------
procedure ShowError(Msg: WideString; HelpContext: Integer);
procedure ShowError(Msg: UnicodeString; HelpContext: Integer);
begin
raise EVirtualTreeError.CreateHelp(Msg, HelpContext);
@ -4161,7 +4165,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function ShortenString(DC: HDC; const S: WideString; Width: Integer; EllipsisWidth: Integer = 0): WideString;
function ShortenString(DC: HDC; const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString;
// Adjusts the given string S so that it fits into the given width. EllipsisWidth gives the width of
// the three points to be added to the shorted string. If this value is 0 then it will be determined implicitely.
@ -5293,7 +5297,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TWideBufferedString.GetAsString: WideString;
function TWideBufferedString.GetAsString: UnicodeString;
begin
SetString(Result, FStart, FPosition - FStart);
@ -5301,7 +5305,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TWideBufferedString.Add(const S: WideString);
procedure TWideBufferedString.Add(const S: UnicodeString);
var
LastLen,
@ -5401,7 +5405,6 @@ var
begin
if FMiscOptions <> Value then
begin
ToBeSet := Value - FMiscOptions;
ToBeCleared := FMiscOptions - Value;
FMiscOptions := Value;
@ -5739,7 +5742,7 @@ procedure TVirtualTreeHintWindow.InternalPaint(Step, StepSize: Integer);
var
R: TRect;
Y: Integer;
S: WideString;
S: UnicodeString;
DrawFormat: Cardinal;
Shadow: Integer;
@ -5996,6 +5999,7 @@ begin
hatFade:
begin
// Make sure the window is not drawn unanimated.
//lcl_todo: see the meaning of ValidateRect
//ValidateRect(Self.Handle, nil);
// Empirically determined animation duration shows that fading needs about twice as much time as
// sliding to show a comparable visual effect.
@ -6004,6 +6008,7 @@ begin
hatSlide:
begin
// Make sure the window is not drawn unanimated.
//lcl_todo: see the meaning of ValidateRect
//ValidateRect(Self.Handle, nil);
Animate(Self.Height, FAnimationDuration, AnimationCallback, nil);
end;
@ -7086,7 +7091,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TVirtualTreeColumn.SetText(const Value: WideString);
procedure TVirtualTreeColumn.SetText(const Value: UnicodeString);
begin
if FText <> Value then
@ -7620,7 +7625,7 @@ procedure TVirtualTreeColumn.LoadFromStream(const Stream: TStream; Version: Inte
var
Dummy: Integer;
S: WideString;
S: UnicodeString;
begin
with Stream do
@ -7978,7 +7983,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TVirtualTreeColumns.DrawButtonText(DC: HDC; Caption: WideString; Bounds: TRect; Enabled, Hot: Boolean;
procedure TVirtualTreeColumns.DrawButtonText(DC: HDC; Caption: UnicodeString; Bounds: TRect; Enabled, Hot: Boolean;
DrawFormat: Cardinal);
var
@ -9222,7 +9227,6 @@ begin
if not (hpeDropMark in ActualElements) and (DropMark <> dmmNone) then
begin
Y := (PaintRectangle.Top + PaintRectangle.Bottom - UtilityImages.Height) div 2;
if DropMark = dmmLeft then
DirectMaskBlt(FHeaderBitmap.Canvas.Handle, PaintRectangle.Left, Y, UtilityImageSize, UtilityImageSize, UtilityImages.Canvas.Handle,
0 * UtilityImageSize, 0, UtilityImages.MaskHandle)
@ -12238,6 +12242,7 @@ begin
end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.GetDisabled(Node: PVirtualNode): Boolean;
begin
@ -13125,6 +13130,7 @@ begin
fmWindowColor:
Brush.Color := clWindow;
end;
Pen.Color := FColors.TreeLineColor;
Rectangle(0, 0, TreeButtonSize, TreeButtonSize);
Pen.Color := Self.Font.Color;
@ -13154,7 +13160,6 @@ begin
if NeedLines then
begin
//WARNING: It requires a patched LCL
if FDottedBrush <> 0 then
DeleteObject(FDottedBrush);
@ -15115,8 +15120,10 @@ var
Ghosted: Boolean;
ImageIndex: Integer;
R: TRect;
Text: WideString;
Text: UnicodeString;
{$ifndef UNICODE}
ANSIText: ANSIString;
{$endif}
begin
// We can only return valid data if a nodes reference is given.
@ -15170,10 +15177,16 @@ begin
if (Item.mask and TVIF_TEXT) <> 0 then
begin
GetTextInfo(Node, -1, Font, R, Text);
{$ifdef UNICODE}
StrLCopy(Item.pszText, PWideChar(Text), Item.cchTextMax - 1);
Item.pszText[Length(Text)] := #0;
{$else}
// Convert the Unicode implicitely to ANSI using the current locale.
ANSIText := Text;
StrLCopy(Item.pszText, PChar(ANSIText), Item.cchTextMax - 1);
Item.pszText[Length(ANSIText)] := #0;
{$endif}
end;
end;
end;
@ -15329,6 +15342,7 @@ procedure TBaseVirtualTree.WMContextMenu(var Message: TLMContextMenu);
begin
Logger.EnterMethod([lcMessages],'WMContextMenu');
DoStateChange([], [tsClearPending, tsEditPending, tsOLEDragPending, tsVCLDragPending]);
if not (tsPopupMenuShown in FStates) then
inherited WMContextMenu(Message);
Logger.ExitMethod([lcMessages],'WMContextMenu');
@ -16010,7 +16024,6 @@ begin
end
else
DoStateChange([tsIncrementalSearchPending]);
VK_ESCAPE: // cancel actions currently in progress
begin
if IsMouseSelecting then
@ -16178,11 +16191,9 @@ begin
{
Cardinal(Pos) := GetMessagePos;
Control := FindVCLWindow(SmallPointToPoint(Pos));
// Every control derived from TOleControl has potentially the focus problem. In order to avoid including
// the OleCtrls unit (which will, among others, include Variants), which would allow to test for the TOleControl
// class, the IOleClientSite interface is used for the test, which is supported by TOleControl and a good indicator.
if Assigned(Control) and Control.GetInterface(IOleClientSite, Unknown) then
Form.ActiveControl := nil;
}
@ -18730,7 +18741,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.DoGetImageText(Node: PVirtualNode; Kind: TVTImageKind;
Column: TColumnIndex; var ImageText: WideString);
Column: TColumnIndex; var ImageText: UnicodeString);
// Queries the application/descendant about alternative image text for a node.
@ -18751,7 +18762,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle): WideString;
var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString;
begin
Result := Hint;
@ -18761,7 +18772,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle): WideString;
var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString;
begin
Result := Hint;
@ -18917,7 +18928,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.DoIncrementalSearch(Node: PVirtualNode; const Text: WideString): Integer;
function TBaseVirtualTree.DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer;
begin
Result := 0;
@ -20427,7 +20438,7 @@ procedure TBaseVirtualTree.HandleIncrementalSearch(CharCode: Word);
var
Run, Stop: PVirtualNode;
GetNextNode: TGetNextNodeProc;
NewSearchText: WideString;
NewSearchText: UnicodeString;
SingleLetter,
PreviousSearch: Boolean; // True if VK_BACK was sent.
SearchDirection: TVTSearchDirection;
@ -23280,7 +23291,6 @@ begin
// SetFocus;
inherited;
end;
end;
end;
@ -23475,7 +23485,7 @@ begin
Sort(Parent, FHeader.FSortColumn, FHeader.FSortDirection, True);
InvalidateToBottom(Parent);
//lcl
//Calling UpdateHorizontalScrollBar without a header leads to a
//wrong NodeWidth because the node is not initialized at this time.
//As result the horizontal scrollbar is not correctly
@ -26858,7 +26868,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect;
var Text: WideString);
var Text: UnicodeString);
// Generic base method for editors, hint windows etc. to get some info about a node.
@ -28134,7 +28144,6 @@ begin
end;
end;
// Erase rest of window not covered by a node.
if TargetRect.Top < MaximumBottom then
begin
@ -29472,7 +29481,7 @@ begin
end
else
begin
//lcl adjust header
//lclheader
if Integer(Node.TotalHeight) <= (ClientHeight - FHeaderRect.Bottom) then
ScrollIntoView(GetLastChild(Node), toCenterScrollIntoView in FOptions.SelectionOptions)
else
@ -30153,7 +30162,7 @@ function TStringEditLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode;
// Retrieves the true text bounds from the owner tree.
var
Text: WideString;
Text: UnicodeString;
begin
Result := Tree is TCustomVirtualStringTree;
@ -30179,6 +30188,7 @@ begin
FEdit.BidiMode := FTree.Header.Columns[Column].BidiMode;
FAlignment := FTree.Header.Columns[Column].Alignment;
end;
if FEdit.BidiMode <> bdLeftToRight then
ChangeBidiModeAlignment(FAlignment);
end;
@ -30283,6 +30293,20 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.GetImageText(Node: PVirtualNode;
Kind: TVTImageKind; Column: TColumnIndex): UnicodeString;
begin
Assert(Assigned(Node), 'Node must not be nil.');
if not (vsInitialized in Node.States) then
InitNode(Node);
Result := '';
DoGetImageText(Node, Kind, Column, Result);
end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.GetOptions: TCustomStringTreeOptions;
begin
@ -30291,7 +30315,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.GetText(Node: PVirtualNode; Column: TColumnIndex): WideString;
function TCustomVirtualStringTree.GetText(Node: PVirtualNode; Column: TColumnIndex): UnicodeString;
begin
Assert(Assigned(Node), 'Node must not be nil.');
@ -30345,7 +30369,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.PaintNormalText(var PaintInfo: TVTPaintInfo; TextOutFlags: Integer;
Text: WideString);
Text: UnicodeString);
// This method is responsible for painting the given test to target canvas (under consideration of the given rectangles).
// The text drawn here is considered as the normal text in a node.
@ -30434,7 +30458,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.PaintStaticText(const PaintInfo: TVTPaintInfo; TextOutFlags: Integer;
const Text: WideString);
const Text: UnicodeString);
// This method retrives and draws the static text bound to a particular node.
@ -30505,7 +30529,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.SetDefaultText(const Value: WideString);
procedure TCustomVirtualStringTree.SetDefaultText(const Value: UnicodeString);
begin
if FDefaultText <> Value then
@ -30526,7 +30550,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: WideString);
procedure TCustomVirtualStringTree.SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: UnicodeString);
begin
DoNewText(Node, Column, Value);
@ -30614,8 +30638,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
const Text: WideString): Integer;
function TCustomVirtualStringTree.CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const Text: UnicodeString): Integer;
// Determines the width of the given text.
@ -30671,7 +30694,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle): WideString;
var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString;
begin
Result := inherited DoGetNodeHint(Node, Column, LineBreakStyle);
@ -30682,7 +30705,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle): WideString;
var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString;
begin
Result := inherited DoGetNodeToolTip(Node, Column, LineBreakStyle);
@ -30735,7 +30758,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.DoGetText(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var Text: WideString);
var Text: UnicodeString);
begin
if Assigned(FOnGetText) then
@ -30744,7 +30767,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.DoIncrementalSearch(Node: PVirtualNode; const Text: WideString): Integer;
function TCustomVirtualStringTree.DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer;
// Since the string tree has access to node text it can do incremental search on its own. Use the event to
// override the default behavior.
@ -30761,7 +30784,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.DoNewText(Node: PVirtualNode; Column: TColumnIndex; const Text: WideString);
procedure TCustomVirtualStringTree.DoNewText(Node: PVirtualNode; Column: TColumnIndex; const Text: UnicodeString);
begin
if Assigned(FOnNewText) then
@ -30779,7 +30802,7 @@ procedure TCustomVirtualStringTree.DoPaintNode(var PaintInfo: TVTPaintInfo);
// Main output routine to print the text of the given node using the space provided in PaintInfo.ContentRect.
var
S: WideString;
S: UnicodeString;
TextOutFlags: Integer;
begin
@ -30823,7 +30846,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
const S: WideString; Width: Integer; EllipsisWidth: Integer = 0): WideString;
const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString;
var
Done: Boolean;
@ -30838,7 +30861,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.DoTextDrawing(var PaintInfo: TVTPaintInfo; const Text: WideString; CellRect: TRect;
procedure TCustomVirtualStringTree.DoTextDrawing(var PaintInfo: TVTPaintInfo; const Text: UnicodeString; CellRect: TRect;
DrawFormat: Cardinal);
begin
@ -30848,7 +30871,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.DoTextMeasuring(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
const Text: WideString): Integer;
const Text: UnicodeString): Integer;
var
Size: TSize;
@ -30907,7 +30930,7 @@ function TCustomVirtualStringTree.ReadChunk(Stream: TStream; Version: Integer; N
// read in the caption chunk if there is one
var
NewText: WideString;
NewText: UnicodeString;
begin
case ChunkType of
@ -31011,7 +31034,7 @@ procedure TCustomVirtualStringTree.WriteChunks(Stream: TStream; Node: PVirtualNo
var
Header: TChunkHeader;
S: WideString;
S: UnicodeString;
Len: Integer;
begin
@ -31037,7 +31060,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.ComputeNodeHeight(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
S: WideString): Integer;
S: UnicodeString): Integer;
// Default node height calculation for multi line nodes. This method can be used by the application to delegate the
// computation to the string tree.
@ -31091,11 +31114,11 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.ContentToHTML(Source: TVSTTextSourceType; const Caption: WideString = ''): string;
function TCustomVirtualStringTree.ContentToHTML(Source: TVSTTextSourceType; const Caption: UnicodeString = ''): string;
// Renders the current tree content (depending on Source) as HTML text encoded in UTF-8.
// If Caption is not empty then it is used to create and fill the header for the table built here.
// Based on ideas and code from Frank van den Bergh and Andreas Hrstemeier.
// Based on ideas and code from Frank van den Bergh and Andreas Hörstemeier.
type
UCS2 = Word;
@ -31123,7 +31146,7 @@ var
//---------------------------------------------------------------------------
function UTF16ToUTF8(const S: WideString): string;
function UTF16ToUTF8(const S: UnicodeString): AnsiString;
// Converts the given Unicode text (which may contain surrogates) into
// the UTF-8 encoding used for the HTML clipboard format.
@ -31269,7 +31292,7 @@ var
AddHeader: AnsiString;
Save, Run: PVirtualNode;
GetNextNode: TGetNextNodeProc;
Text: WideString;
Text: UnicodeString;
RenderColumns: Boolean;
Columns: TColumnsArray;
@ -31572,7 +31595,7 @@ end;
function TCustomVirtualStringTree.ContentToRTF(Source: TVSTTextSourceType): AnsiString;
// Renders the current tree content (depending on Source) as RTF (rich text).
// Based on ideas and code from Frank van den Bergh and Andreas Hrstemeier.
// Based on ideas and code from Frank van den Bergh and Andreas Hörstemeier.
var
Fonts: TStringList;
@ -31640,7 +31663,7 @@ var
//---------------------------------------------------------------------------
procedure TextPlusFont(Text: WideString; Font: TFont);
procedure TextPlusFont(Text: UnicodeString; Font: TFont);
var
UseUnderline,
@ -31691,8 +31714,8 @@ var
I, J: Integer;
Save, Run: PVirtualNode;
GetNextNode: TGetNextNodeProc;
S, Tabs : string;
Text: WideString;
S, Tabs : AnsiString;
Text: UnicodeString;
Twips: Integer;
RenderColumns: Boolean;
@ -32006,7 +32029,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): WideString;
function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): UnicodeString;
// Renders the current tree content (depending on Source) as Unicode text.
// If an entry contains the separator char then it is wrapped with double quotation marks.
@ -32014,11 +32037,11 @@ function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; S
// that an entry must not contain double quotation marks, otherwise import into other programs might fail!
const
WideCRLF: WideString = #13#10;
WideCRLF: UnicodeString = #13#10;
var
RenderColumns: Boolean;
Tabs: WideString;
Tabs: UnicodeString;
GetNextNode: TGetNextNodeProc;
Run, Save: PVirtualNode;
@ -32027,7 +32050,7 @@ var
Level, MaxLevel: Cardinal;
Index,
I: Integer;
Text: WideString;
Text: UnicodeString;
Buffer: TWideBufferedString;
begin
@ -32147,7 +32170,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualStringTree.GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect;
var Text: WideString);
var Text: UnicodeString);
// Returns the font, the text and its bounding rectangle to the caller. R is returned as the closest
// bounding rectangle around Text.
@ -32206,13 +32229,13 @@ end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualStringTree.Path(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
Delimiter: WideChar): WideString;
Delimiter: WideChar): UnicodeString;
// Constructs a string containing the node and all its parents. The last character in the returned path is always the
// given delimiter.
var
S: WideString;
S: UnicodeString;
begin
if (Node = nil) or (Node = FRoot) then