📄 jvqpagelisttreeview.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvPageListTreeView.PAS, released on 2003-01-22.
The Initial Developer of the Original Code is Peter Th鰎nqvist [peter3 at sourceforge dot net] .
Portions created by Peter Th鰎nqvist are Copyright (C) 2003 Peter Th鰎nqvist.
All Rights Reserved.
Contributor(s):
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Changes:
2002-10-22:
Changed TJvPageIndexNode.SetPageIndex to only set the parent PageIndex if the Treeview is a
TJvCustomSettingsTreeView since this is the first class implementing this behaviour
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQPageListTreeView.pas,v 1.17 2005/02/06 14:06:16 asnepvangers Exp $
unit JvQPageListTreeView;
{$I jvcl.inc}
interface
uses
SysUtils, Classes,
QWindows, QMessages, QGraphics, QControls, QImgList, QComCtrls,
JvQComponent, JvQThemes, JvQPageList, JvQExComCtrls;
type
TJvCustomPageListTreeView = class;
TJvPageIndexNode = class(TTreeNode)
private
FPageIndex: Integer;
procedure SetPageIndex(const Value: Integer);
published
procedure Assign(Source: TPersistent); override;
property PageIndex: Integer read FPageIndex write SetPageIndex;
end;
TJvPageIndexNodes = class(TTreeNodes)
private
procedure ReadData(Stream: TStream);
procedure WriteData(Stream: TStream);
protected
procedure DefineProperties(Filer: TFiler); override;
end;
// this is a "fake" class so we have something to anchor the design-time editor with
TJvPageLinks = class(TPersistent)
private
FTreeView: TJvCustomPageListTreeView;
public
property TreeView: TJvCustomPageListTreeView read FTreeView;
end;
{ TJvCustomPageListTreeView is a base treeview class that can be hooked up with an IPageList
implementor. When the selected tree node is changed, the associated page in the IPageList is changed too as
determined by the TJvPageIndexNode.PageIndex property
Properties:
* PageDefault is the default PageIndex to assign to new nodes
* PageLinks is the property used att design time to set up a Nodes PageIndex. At run-time, use
TJvPageIndexNode(Node).PageIndex := Value;
* PageList is the IPageList implementor that is attached to this control. NOTE: for D5, PageList is
instead a TComponent: to get at the IPageList interface, use PageListIntf instead
* CanChange calls IPageList.CanChange method and Change calls IPageList.SetActivePageIndex
* IPageList.getPageCaption is only used by the design-time editor for the PageLinks property
}
TJvCustomPageListTreeView = class(TJvExCustomTreeView)
private
FItems: TJvPageIndexNodes;
FPageList: IPageList;
FPageDefault: Integer;
FLinks: TJvPageLinks;
procedure SetPageDefault(const Value: Integer);
procedure SetLinks(const Value: TJvPageLinks);
procedure SetPageList(const Value: IPageList);
function GetItems: TJvPageIndexNodes;
procedure SetItems(const Value: TJvPageIndexNodes);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
function CreateNode: TTreeNode; dynamic;
function CreateNodes: TTreeNodes;
function CanChange(Node: TTreeNode): Boolean; dynamic;
procedure Change(Node: TTreeNode); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property PageDefault: Integer read FPageDefault write SetPageDefault;
property PageLinks: TJvPageLinks read FLinks write SetLinks;
property PageList: IPageList read FPageList write SetPageList;
protected
property AutoExpand default True;
property ShowButtons default False;
property ReadOnly default True;
property Items: TJvPageIndexNodes read GetItems write SetItems;
end;
{ TJvSettingsTreeImages is a property class that describes the images used in a
TJvCustomSettingsTreeView as the usage of images in this control differs from the normal
TreeView
}
TJvSettingsTreeImages = class(TPersistent)
private
FSelectedIndex: TImageIndex;
FCollapsedIndex: TImageIndex;
FImageIndex: TImageIndex;
FExpandedIndex: TImageIndex;
FTreeView: TJvCustomPageListTreeView;
public
constructor Create;
property TreeView: TJvCustomPageListTreeView read FTreeView write FTreeView;
published
property CollapsedIndex: TImageIndex read FCollapsedIndex write FCollapsedIndex default 0;
property ExpandedIndex: TImageIndex read FExpandedIndex write FExpandedIndex default 1;
property SelectedIndex: TImageIndex read FSelectedIndex write FSelectedIndex default 2;
property ImageIndex: TImageIndex read FImageIndex write FImageIndex default -1;
end;
{ TJvCustomSettingsTreeView is a base class for treeviews that behave like the
treeview in the Settings Dialog in Visual Studio: When a node in the treeview
is selected, a new page of settings is shown on a panel to the right.
Specifically, the following is True:
* The normal ImageIndex/SelectedIndex is ignored for nodes - use PageNodeImages instead. You still
need to assign a TImageList to the Images property
* When a node is expanded, it is assigned the expanded image until it is collapsed, regardless
whether it's selected or not
* When a parent folder is selected, the first non-folder child has it's
normal image set as the selected image
* By default, AutoExpand and ReadOnly is True, ShowButtons and ShowLines are False
Other than that, it should work like a normal TreeView. Note that the treeview was designed with AutoExpand = True
in mind but should work with AutoExpand = False
To get the VS look , Images should contain:
Image 0: Closed Folder
Image 1: Open Folder
Image 2: Right-pointing teal-colored arrow
PageNodeImages should then be set to (the defaults):
ClosedFolder = 0;
ImageIndex = -1; (no image)
OpenFolder = 1;
SelectedIndex = 2;
}
TJvCustomSettingsTreeView = class(TJvCustomPageListTreeView)
private
FNodeImages: TJvSettingsTreeImages;
procedure SetImageSelection(const Value: TJvSettingsTreeImages);
protected
FLastSelected: TTreeNode;
procedure Delete(Node: TTreeNode); override;
function CanChange(Node: TTreeNode): Boolean; override;
procedure Change(Node: TTreeNode); override;
procedure ResetPreviousNode(NewNode: TTreeNode); virtual;
procedure SetPreviousNode(NewNode: TTreeNode); virtual;
procedure Loaded; override;
procedure Expand(Node: TTreeNode); override;
procedure Collapse(Node: TTreeNode); override;
property PageNodeImages: TJvSettingsTreeImages read FNodeImages write SetImageSelection;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TJvPageListTreeView = class(TJvCustomPageListTreeView)
published
property AutoExpand;
property ShowButtons;
property ReadOnly;
property PageDefault;
property PageLinks;
property PageList;
property OnMouseEnter;
property OnMouseLeave;
property OnParentColorChange;
property Align;
property Anchors;
property BorderStyle;
property Color;
property Constraints;
property DragMode;
property Enabled;
property Font;
property Images;
property Indent;
property ParentColor default False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RowSelect;
property ShowHint;
property SortType;
property TabOrder;
property TabStop default True;
property Visible;
property OnChange;
property OnChanging;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnContextPopup;
property OnCustomDrawItem;
property OnDblClick;
property OnDeletion;
property OnDragDrop;
property OnDragOver;
property OnEdited;
property OnEditing;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnExpanding;
property OnExpanded;
property OnGetImageIndex;
property OnGetSelectedIndex;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property Items;
end;
TJvSettingsTreeView = class(TJvCustomSettingsTreeView)
published
property AutoExpand default True;
property ShowButtons default False;
property ReadOnly default True;
property PageDefault;
property PageNodeImages;
property PageLinks;
property PageList;
property OnMouseEnter;
property OnMouseLeave;
property OnParentColorChange;
property Align;
property Anchors;
property BorderStyle;
property Color;
property Constraints;
property DragMode;
property Enabled;
property Font;
property Images;
property Indent;
// don't use!
// property MultiSelect;
// property MultiSelectStyle;
property ParentColor default False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RowSelect;
property ShowHint;
property SortType;
property TabOrder;
property TabStop default True;
property Visible;
property OnChange;
property OnChanging;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnContextPopup;
property OnCustomDrawItem;
property OnDblClick;
property OnDeletion;
property OnDragDrop;
property OnDragOver;
property OnEdited;
property OnEditing;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnExpanding;
property OnExpanded;
property OnGetImageIndex;
property OnGetSelectedIndex;
property OnInsert;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property Items;
end;
implementation
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
QForms;
(* (ahuser) make Delphi 5 compiler happy
procedure ResetAllNonParentNodes(Items: TTreeNodes; ImageIndex, SelectedIndex: Integer);
var
N: TTreeNode;
begin
N := Items.GetFirstNode;
while Assigned(N) do
begin
if not N.HasChildren then
begin
N.ImageIndex := ImageIndex;
N.SelectedIndex := SelectedIndex;
end;
N := N.GetNext;
end;
end;
procedure ResetSiblings(Node: TTreeNode; ImageIndex, SelectedIndex: Integer; Recurse: Boolean = False);
var
N: TTreeNode;
begin
N := Node.getPrevSibling;
while Assigned(N) do
begin
if not N.HasChildren then
begin
N.ImageIndex := ImageIndex;
N.SelectedIndex := SelectedIndex;
end
else
if Recurse then
ResetSiblings(N.getFirstChild, ImageIndex, SelectedIndex, Recurse);
N := N.getPrevSibling;
end;
N := Node.getNextSibling;
while Assigned(N) do
begin
if not N.HasChildren then
begin
N.ImageIndex := ImageIndex;
N.SelectedIndex := SelectedIndex;
end
else
if Recurse then
ResetSiblings(N.getFirstChild, ImageIndex, SelectedIndex, Recurse);
N := N.getNextSibling;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -