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