📄 tntcomctrls.pas
字号:
type
{TNT-WARN TStatusPanel}
TTntStatusPanel = class(TStatusPanel{TNT-ALLOW TStatusPanel})
private
FText: WideString;
function GetText: Widestring;
procedure SetText(const Value: Widestring);
procedure SetInheritedText(const Value: AnsiString);
protected
procedure DefineProperties(Filer: TFiler); override;
public
procedure Assign(Source: TPersistent); override;
published
property Text: Widestring read GetText write SetText;
end;
{TNT-WARN TStatusPanels}
TTntStatusPanels = class(TStatusPanels{TNT-ALLOW TStatusPanels})
private
function GetItem(Index: Integer): TTntStatusPanel;
procedure SetItem(Index: Integer; Value: TTntStatusPanel);
public
function Add: TTntStatusPanel;
function AddItem(Item: TTntStatusPanel; Index: Integer): TTntStatusPanel;
function Insert(Index: Integer): TTntStatusPanel;
property Items[Index: Integer]: TTntStatusPanel read GetItem write SetItem; default;
end;
{TNT-WARN TCustomStatusBar}
TTntCustomStatusBar = class(TCustomStatusBar{TNT-ALLOW TCustomStatusBar})
private
FSimpleText: WideString;
function GetSimpleText: WideString;
procedure SetSimpleText(const Value: WideString);
procedure SetInheritedSimpleText(const Value: AnsiString);
function SyncLeadingTabs(const WideVal: WideString; const AnsiVal: AnsiString): WideString;
function GetHint: WideString;
function IsHintStored: Boolean;
procedure SetHint(const Value: WideString);
procedure WMGetTextLength(var Message: TWMGetTextLength); message WM_GETTEXTLENGTH;
function GetPanels: TTntStatusPanels;
procedure SetPanels(const Value: TTntStatusPanels);
protected
procedure DefineProperties(Filer: TFiler); override;
function CreatePanels: TStatusPanels{TNT-ALLOW TStatusPanels}; override;
function GetPanelClass: TStatusPanelClass; override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure WndProc(var Msg: TMessage); override;
function GetActionLinkClass: TControlActionLinkClass; override;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
public
function ExecuteAction(Action: TBasicAction): Boolean; override;
property Panels: TTntStatusPanels read GetPanels write SetPanels;
property SimpleText: WideString read GetSimpleText write SetSimpleText;
published
property Hint: WideString read GetHint write SetHint stored IsHintStored;
end;
{TNT-WARN TStatusBar}
TTntStatusBar = class(TTntCustomStatusBar)
private
function GetOnDrawPanel: TDrawPanelEvent;
procedure SetOnDrawPanel(const Value: TDrawPanelEvent);
published
property Action;
property AutoHint default False;
property Align default alBottom;
property Anchors;
property BiDiMode;
property BorderWidth;
property Color default clBtnFace;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font stored IsFontStored;
property Constraints;
property Panels;
property ParentBiDiMode;
property ParentColor default False;
property ParentFont default False;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property SimplePanel {$IFDEF COMPILER_7_UP} default False {$ENDIF};
property SimpleText;
property SizeGrip default True;
property UseSystemFont default True;
property Visible;
property OnClick;
property OnContextPopup;
property OnCreatePanelClass;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnHint;
{$IFDEF COMPILER_9_UP}
property OnMouseActivate;
{$ENDIF}
property OnMouseDown;
{$IFDEF COMPILER_10_UP}
property OnMouseEnter;
property OnMouseLeave;
{$ENDIF}
property OnMouseMove;
property OnMouseUp;
// Required for backwards compatibility with the old event signature
property OnDrawPanel: TDrawPanelEvent read GetOnDrawPanel write SetOnDrawPanel;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
type
TTntTreeNodes = class;
TTntCustomTreeView = class;
{TNT-WARN TTreeNode}
TTntTreeNode = class(TTreeNode{TNT-ALLOW TTreeNode})
private
FText: WideString;
procedure SetText(const Value: WideString);
procedure SetInheritedText(const Value: AnsiString);
function GetText: WideString;
function GetItem(Index: Integer): TTntTreeNode;
function GetNodeOwner: TTntTreeNodes;
function GetParent: TTntTreeNode;
function GetTreeView: TTntCustomTreeView;
procedure SetItem(Index: Integer; const Value: TTntTreeNode);
function IsEqual(Node: TTntTreeNode): Boolean;
procedure ReadData(Stream: TStream; Info: PNodeInfo);
procedure WriteData(Stream: TStream; Info: PNodeInfo);
public
procedure Assign(Source: TPersistent); override;
function getFirstChild: TTntTreeNode; {GetFirstChild conflicts with C++ macro}
function GetLastChild: TTntTreeNode;
function GetNext: TTntTreeNode;
function GetNextChild(Value: TTntTreeNode): TTntTreeNode;
function getNextSibling: TTntTreeNode; {GetNextSibling conflicts with C++ macro}
function GetNextVisible: TTntTreeNode;
function GetPrev: TTntTreeNode;
function GetPrevChild(Value: TTntTreeNode): TTntTreeNode;
function getPrevSibling: TTntTreeNode; {GetPrevSibling conflicts with a C++ macro}
function GetPrevVisible: TTntTreeNode;
property Item[Index: Integer]: TTntTreeNode read GetItem write SetItem; default;
property Owner: TTntTreeNodes read GetNodeOwner;
property Parent: TTntTreeNode read GetParent;
property Text: WideString read GetText write SetText;
property TreeView: TTntCustomTreeView read GetTreeView;
end;
TTntTreeNodeClass = class of TTntTreeNode;
TTntTreeNodesEnumerator = class
private
FIndex: Integer;
FTreeNodes: TTntTreeNodes;
public
constructor Create(ATreeNodes: TTntTreeNodes);
function GetCurrent: TTntTreeNode;
function MoveNext: Boolean;
property Current: TTntTreeNode read GetCurrent;
end;
{TNT-WARN TTreeNodes}
TTntTreeNodes = class(TTreeNodes{TNT-ALLOW TTreeNodes})
private
function GetNodeFromIndex(Index: Integer): TTntTreeNode;
function GetNodesOwner: TTntCustomTreeView;
procedure ClearCache;
procedure ReadData(Stream: TStream);
procedure WriteData(Stream: TStream);
protected
procedure DefineProperties(Filer: TFiler); override;
public
procedure Assign(Source: TPersistent); override;
function Add(Sibling: TTntTreeNode; const S: WideString): TTntTreeNode;
function AddChild(Parent: TTntTreeNode; const S: WideString): TTntTreeNode;
function AddChildFirst(Parent: TTntTreeNode; const S: WideString): TTntTreeNode;
function AddChildObject(Parent: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function AddChildObjectFirst(Parent: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function AddFirst(Sibling: TTntTreeNode; const S: WideString): TTntTreeNode;
function AddObject(Sibling: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function AddObjectFirst(Sibling: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function Insert(Sibling: TTntTreeNode; const S: WideString): TTntTreeNode;
function InsertObject(Sibling: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function InsertNode(Node, Sibling: TTntTreeNode; const S: WideString;
Ptr: Pointer): TTntTreeNode;
function AddNode(Node, Relative: TTntTreeNode; const S: WideString;
Ptr: Pointer; Method: TNodeAttachMode): TTntTreeNode;
public
function GetFirstNode: TTntTreeNode;
function GetEnumerator: TTntTreeNodesEnumerator;
function GetNode(ItemId: HTreeItem): TTntTreeNode;
property Item[Index: Integer]: TTntTreeNode read GetNodeFromIndex; default;
property Owner: TTntCustomTreeView read GetNodesOwner;
end;
TTntTVEditedEvent = procedure(Sender: TObject; Node: TTntTreeNode; var S: WideString) of object;
{TNT-WARN TCustomTreeView}
_TntInternalCustomTreeView = class(TCustomTreeView{TNT-ALLOW TCustomTreeView})
private
function Wide_FindNextToSelect: TTntTreeNode; virtual; abstract;
function Inherited_FindNextToSelect: TTreeNode{TNT-ALLOW TTreeNode};
public
function FindNextToSelect: TTreeNode{TNT-ALLOW TTreeNode}; override;
end;
TTntCustomTreeView = class(_TntInternalCustomTreeView)
private
FSavedNodeText: TTntStrings;
FSavedSortType: TSortType;
FOnEdited: TTntTVEditedEvent;
FTestingForSortProc: Boolean;
FEditHandle: THandle;
FEditInstance: Pointer;
FDefEditProc: Pointer;
function GetTreeNodes: TTntTreeNodes;
procedure SetTreeNodes(const Value: TTntTreeNodes);
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
procedure WMNotify(var Message: TWMNotify); message WM_NOTIFY;
function GetNodeFromItem(const Item: TTVItem): TTntTreeNode;
procedure EditWndProcW(var Message: TMessage);
function Wide_FindNextToSelect: TTntTreeNode; override;
function GetDropTarget: TTntTreeNode;
function GetSelected: TTntTreeNode;
function GetSelection(Index: Integer): TTntTreeNode;
function GetTopItem: TTntTreeNode;
procedure SetDropTarget(const Value: TTntTreeNode);
procedure SetSelected(const Value: TTntTreeNode);
procedure SetTopItem(const Value: TTntTreeNode);
function GetHint: WideString;
function IsHintStored: Boolean;
procedure SetHint(const Value: WideString);
protected
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
function GetActionLinkClass: TControlActionLinkClass; override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
procedure DefineProperties(Filer: TFiler); override;
procedure WndProc(var Message: TMessage); override;
procedure Edit(const Item: TTVItem); override;
function CreateNode: TTreeNode{TNT-ALLOW TTreeNode}; override;
function CreateNodes: TTreeNodes{TNT-ALLOW TTreeNodes}; override;
property Items: TTntTreeNodes read GetTreeNodes write SetTreeNodes;
property OnEdited: TTntTVEditedEvent read FOnEdited write FOnEdited;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure LoadFromFile(const FileName: WideString);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName: WideString);
procedure SaveToStream(Stream: TStream);
function GetNodeAt(X, Y: Integer): TTntTreeNode;
property DropTarget: TTntTreeNode read GetDropTarget write SetDropTarget;
property Selected: TTntTreeNode read GetSelected write SetSelected;
property TopItem: TTntTreeNode read GetTopItem write SetTopItem;
property Selections[Index: Integer]: TTntTreeNode read GetSelection;
function GetSelections(AList: TList): TTntTreeNode;
function FindNextToSelect: TTntTreeNode; reintroduce; virtual;
published
property Hint: WideString read GetHint write SetHint stored IsHintStored;
end;
{TNT-WARN TTreeView}
TTntTreeView = class(TTntCustomTreeView)
published
property Align;
property Anchors;
property AutoExpand;
property BevelEdges;
property BevelInner;
property BevelOuter;
property BevelKind default bkNone;
property BevelWidth;
property BiDiMode;
property BorderStyle;
property BorderWidth;
property ChangeDelay;
property Color;
property Ctl3D;
property Constraints;
property DragKind;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property HotTrack;
property Images;
property Indent;
property MultiSelect;
property MultiSelectStyle;
property ParentBiDiMode;
property ParentColor default False;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property RightClickSelect;
property RowSelect;
property ShowButtons;
property ShowHint;
property ShowLines;
property ShowRoot;
property SortType;
property StateImages;
property TabOrder;
property TabStop default True;
property ToolTips;
property Visible;
property OnAddition;
property OnAdvancedCustomDraw;
property OnAdvancedCustomDrawItem;
property OnChange;
property OnChanging;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnCompare;
property OnContextPopup;
property OnCreateNodeClass;
property OnCustomDraw;
property OnCustomDrawItem;
property OnDblClick;
property OnDeletion;
property OnDragDrop;
property OnDragOver;
property OnEdited;
property OnEditing;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnExpanding;
property OnExpanded;
property OnGetImageIndex;
property OnGetSelectedIndex;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
{$IFDEF COMPILER_9_UP}
property OnMouseActivate;
{$ENDIF}
property OnMouseDown;
{$IFDEF COMPILER_10_UP}
property OnMouseEnter;
property OnMouseLeave;
{$ENDIF}
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
{ Items must be published after OnGetImageIndex and OnGetSelectedIndex }
property Items;
end;
implementation
uses
Forms, SysUtils, TntGraphics, ImgList, TntSystem, TntStdCtrls, StdCtrls,
RichEdit, ActiveIMM_TLB, TntForms, ComStrs, TntMenus,
TntActnList, TntStdActns, TntWindows,
{$IFNDEF COMPILER_10_UP}
TntWideStrings,
{$ELSE}
WideStrings,
{$ENDIF}
{$IFDEF COMPILER_9_UP} WideStrUtils {$ELSE} TntWideStrUtils {$ENDIF};
procedure CreateUnicodeHandle_ComCtl(Control: TWinControl; const Params: TCreateParams;
const SubClass: WideString);
begin
Assert(SubClass <> '', 'TNT Internal Error: Only call CreateUnicodeHandle_ComCtl for Common Controls.');
CreateUnicodeHandle(Control, Params, SubClass);
if Win32PlatformIsUnicode then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -