Class TRbwCheckTreeView

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TRbwCheckTreeView = class(TTreeView)

Description

TRbwCheckTreeView is a TTreeView that has checkboxes at each node.

If a node has children, its checkbox is checked if all its children's checkboxes are checked. Its checkbox is unchecked if all its children's checkboxes are unchecked. Its checkbox is grayed if only some of its children's checkboxes are checked.

Hierarchy

Overview

Fields

Private FImageList: TImageList;
Private FOnCheckChange: TTVCheckItemNotifyEvent;
Private FReadOnly: boolean;
Private FUpdateCount: integer;
Private FUpdating: boolean;

Methods

Private function GetImages: TCustomImageList;
Private procedure UpdateChildren(ParentNode: TTreeNode);
Private procedure UpdateParent(ChildNode: TTreeNode);
Protected procedure DoAutoExpand(ExpandedNode: TTreeNode);
Protected procedure DoDeletion(ANode: TTreeNode); override;
Protected procedure DoItemClick(p1: Integer; p2: QListViewItemH; p3: PPoint; p4: Integer); cdecl;
Protected procedure HookEvents; override;
Protected procedure SetCheck(Sender: TObject; Button: TMouseButton; Node: TTreeNode; const Pt: TPoint);
Public procedure BeginUpdate;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure EndUpdate;

Properties

Published property Images: TCustomImageList read GetImages;
Published property ReadOnly: boolean read FReadOnly write FReadOnly;
Published property OnCheckChange: TTVCheckItemNotifyEvent read FOnCheckChange write FOnCheckChange;

Description

Fields

Private FImageList: TImageList;

FImageList: TImageList; inherited Images is set to FImageList.

Private FOnCheckChange: TTVCheckItemNotifyEvent;

FOnCheckChange: TTVCheckItemNotifyEvent; See OnCheckChange.

Private FReadOnly: boolean;

FReadOnly: boolean; See ReadOnly.

Private FUpdateCount: integer;

FUpdateCount is incremented in BeginUpdate and decremented in EndUpdate. When FUpdateCount reaches zero, the check state of all the TCheckNodes with children is reevaluated.

Private FUpdating: boolean;

FUpdating is set to True within EndUpdate to prevent UpdateChildren and UpdateParent from doing anything.

Methods

Private function GetImages: TCustomImageList;

GetImages always returns nil.

Private procedure UpdateChildren(ParentNode: TTreeNode);

When the checked state of a node is changed, UpdateChildren is used to ensure that the checked states of all of its children are consistent with the checked state of the parent node.

Private procedure UpdateParent(ChildNode: TTreeNode);

When the checked state of a node is changed, UpdateParent is used to ensure that the checked state of its parent is consistent with the checked state of the child nodes.

Protected procedure DoAutoExpand(ExpandedNode: TTreeNode);

Reimplemented from TTreeView. DoAutoExpand of the inherited tree view is private but needs to be used so it is reimplemented here.

Protected procedure DoDeletion(ANode: TTreeNode); override;

DoDeletion calls inherited DoDeletion and then resets the checked state of the nodes.

Protected procedure DoItemClick(p1: Integer; p2: QListViewItemH; p3: PPoint; p4: Integer); cdecl;

Reimplemented from TTreeView. In this method, the mouse position is used to test whether or not the mouse was clicked on the image for the node. If so, the image is changed appropriately.

Protected procedure HookEvents; override;

HookEvents causes the control to respond to mouse clicks using the DoItemClick method.

Protected procedure SetCheck(Sender: TObject; Button: TMouseButton; Node: TTreeNode; const Pt: TPoint);

SetCheck causes the Checked property of the node to be toggled if Pt is over the checkbox for the node.

Public procedure BeginUpdate;

See EndUpdate.

Public constructor Create(AOwner: TComponent); override;

see inherited Create

Public destructor Destroy; override;

Destroy destroys the current instance of TRbwCheckTreeView. Do not call Destroy directly. Call Free instead.

Public procedure EndUpdate;

If TCheckNode.Checked will be changed programatically for more than one TCheckNode at a time, use BeginUpdate before the code that changes them followed by EndUpdate after the code that changes them. This makes the process of updating the TRbwCheckTreeView more efficient.

Properties

Published property Images: TCustomImageList read GetImages;

The inherited Images contains the checkbox images. The first image is for the unchecked state. The second is for the checked state. The third is for the grayed state. The images are 13 pixels square. If a different size checkbox is needed, you will have to adjust the constants in SetCheck.

At present, the user is not given the option of changing any of the images so Images is reimplemented and is always nil.

Published property ReadOnly: boolean read FReadOnly write FReadOnly;

If ReadOnly is true, the user can not change the checked state of the nodes.

Published property OnCheckChange: TTVCheckItemNotifyEvent read FOnCheckChange write FOnCheckChange;

OnCheckChange occurs when the checked state of a node changes.


Generated by PasDoc 0.10.0 on 2006-10-31 09:56:43