started componenttree

git-svn-id: trunk@4509 -
This commit is contained in:
mattias 2003-08-22 07:58:38 +00:00
parent ce91561698
commit 36ca9e7471
8 changed files with 299 additions and 66 deletions

1
.gitattributes vendored
View File

@ -173,6 +173,7 @@ designer/abstractformeditor.pp svneol=native#text/pascal
designer/aligncompsdlg.pp svneol=native#text/pascal
designer/columndlg.pp svneol=native#text/pascal
designer/componenteditors.pas svneol=native#text/pascal
designer/componenttreeview.pas svneol=native#text/pascal
designer/controlselection.pp svneol=native#text/pascal
designer/customeditor.pp svneol=native#text/pascal
designer/designer.pp svneol=native#text/pascal

View File

@ -0,0 +1,92 @@
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
Author: Mattias Gaertner
Abstract:
TComponentTreeView is a component to show the child components of a
TComponent. TControls can be shown in a hierachic view.
It supports
- multi selecting components
- editing the creation order
- editing the TControl.Parent hierachy
For example of the usage, see the object inspector.
ToDo:
}
unit ComponentTreeView;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LCLProc, Controls, ComCtrls, PropEdits;
type
{ TComponentTreeView }
TComponentTreeView = class(TCustomTreeView)
private
FComponentList: TComponentSelectionList;
FPropertyEditorHook: TPropertyEditorHook;
procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook);
procedure SetSelections(const AValue: TComponentSelectionList);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure RebuildComponentNodes; virtual;
public
property Selections: TComponentSelectionList read FComponentList
write SetSelections;
property PropertyEditorHook: TPropertyEditorHook
read FPropertyEditorHook write SetPropertyEditorHook;
end;
implementation
{ TComponentTreeView }
procedure TComponentTreeView.SetSelections(const AValue: TComponentSelectionList
);
begin
if FComponentList=AValue then exit;
FComponentList:=AValue;
RebuildComponentNodes;
end;
procedure TComponentTreeView.SetPropertyEditorHook(
const AValue: TPropertyEditorHook);
begin
if FPropertyEditorHook=AValue then exit;
FPropertyEditorHook:=AValue;
end;
constructor TComponentTreeView.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FComponentList:=TComponentSelectionList.Create;
end;
destructor TComponentTreeView.Destroy;
begin
FreeThenNil(FComponentList);
inherited Destroy;
end;
procedure TComponentTreeView.RebuildComponentNodes;
begin
end;
end.

View File

@ -22,8 +22,6 @@
ToDo:
- backgroundcolor=clNone
- a lot more ... see XXX
}
unit ObjectInspector;
@ -37,7 +35,8 @@ uses
Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType,
LCLLinux, LMessages, Controls, ComCtrls, ExtCtrls, TypInfo, Messages,
LResources, Laz_XMLCfg, Menus, Dialogs, ObjInspStrConsts,
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor;
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
ComponentTreeView;
type
@ -50,10 +49,12 @@ type
TOIOptions = class
private
FComponentTreeHeight: integer;
FCustomXMLCfg: TXMLConfig;
FDefaultItemHeight: integer;
FFilename:string;
FFileAge: longint;
FShowComponentTree: boolean;
FXMLCfg: TXMLConfig;
FFileHasChangedOnDisk: boolean;
@ -78,6 +79,7 @@ type
function Save: boolean;
procedure Assign(AnObjInspector: TObjectInspector);
procedure AssignTo(AnObjInspector: TObjectInspector);
public
property Filename:string read FFilename write SetFilename;
property CustomXMLCfg: TXMLConfig read FCustomXMLCfg write FCustomXMLCfg;
@ -86,17 +88,21 @@ type
property Top:integer read FTop write FTop;
property Width:integer read FWidth write FWidth;
property Height:integer read FHeight write FHeight;
property PropertyGridSplitterX:integer
read FPropertyGridSplitterX write FPropertyGridSplitterX;
property EventGridSplitterX:integer
read FEventGridSplitterX write FEventGridSplitterX;
property DefaultItemHeight: integer
read FDefaultItemHeight write FDefaultItemHeight;
property PropertyGridSplitterX:integer read FPropertyGridSplitterX
write FPropertyGridSplitterX;
property EventGridSplitterX:integer read FEventGridSplitterX
write FEventGridSplitterX;
property DefaultItemHeight: integer read FDefaultItemHeight
write FDefaultItemHeight;
property ShowComponentTree: boolean read FShowComponentTree
write FShowComponentTree;
property ComponentTreeHeight: integer read FComponentTreeHeight
write FComponentTreeHeight;
property GridBackgroundColor: TColor
read FGridBackgroundColor write FGridBackgroundColor;
property ShowHints: boolean
read FShowHints write FShowHints;
property GridBackgroundColor: TColor read FGridBackgroundColor
write FGridBackgroundColor;
property ShowHints: boolean read FShowHints
write FShowHints;
end;
TOIPropertyGrid = class;
@ -239,17 +245,18 @@ type
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:integer); override;
procedure MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:integer); override;
procedure MouseMove(Shift:TShiftState; X,Y:integer); override;
procedure MouseUp(Button:TMouseButton; Shift:TShiftState; X,Y:integer); override;
procedure MouseUp(Button:TMouseButton; Shift:TShiftState; X,Y:integer); override;
public
ValueEdit:TEdit;
ValueComboBox:TComboBox;
ValueButton:TButton;
property Selections:TComponentSelectionList read FComponentList write SetSelections;
property PropertyEditorHook:TPropertyEditorHook
read FPropertyEditorHook write SetPropertyEditorHook;
property Selections: TComponentSelectionList read FComponentList
write SetSelections;
property PropertyEditorHook: TPropertyEditorHook
read FPropertyEditorHook write SetPropertyEditorHook;
procedure BuildPropertyList;
procedure RefreshPropertyValues;
@ -261,9 +268,11 @@ type
property TopY:integer read FTopY write SetTopY;
function GridHeight:integer;
function TopMax:integer;
property DefaultItemHeight:integer read FDefaultItemHeight write FDefaultItemHeight;
property DefaultItemHeight:integer read FDefaultItemHeight
write FDefaultItemHeight;
property SplitterX:integer read FSplitterX write SetSplitterX;
property PrefferedSplitterX:integer read FPreferredSplitterX write FPreferredSplitterX;
property PrefferedSplitterX: integer read FPreferredSplitterX
write FPreferredSplitterX;
property Indent:integer read FIndent write FIndent;
property BackgroundColor:TColor
read FBackgroundColor write SetBackgroundColor default clBtnFace;
@ -311,14 +320,18 @@ type
ColorsPopupMenuItem: TMenuItem;
BackgroundColPopupMenuItem: TMenuItem;
ShowHintsPopupMenuItem: TMenuItem;
ShowComponentTreePopupMenuItem: TMenuItem;
ShowOptionsPopupMenuItem: TMenuItem;
ComponentTree: TComponentTreeView;
procedure AvailComboBoxCloseUp(Sender: TObject);
procedure OnBackgroundColPopupMenuItemClick(Sender :TObject);
procedure OnShowHintPopupMenuItemClick(Sender :TObject);
procedure OnShowOptionsPopupMenuItemClick(Sender :TObject);
procedure OnShowComponentTreePopupMenuItemClick(Sender :TObject);
procedure HookRefreshPropertyValues;
private
FComponentList: TComponentSelectionList;
FComponentTreeHeight: integer;
FDefaultItemHeight: integer;
FFlags: TOIFlags;
FOnShowOptions: TNotifyEvent;
@ -326,9 +339,12 @@ type
FOnAddAvailableComponent:TOnAddAvailableComponent;
FOnSelectComponentInOI:TOnSelectComponentInOI;
FOnModified: TNotifyEvent;
FShowComponentTree: boolean;
FUpdateLock: integer;
FUpdatingAvailComboBox:boolean;
FUsePairSplitter: boolean;
function ComponentToString(c:TComponent):string;
procedure SetComponentTreeHeight(const AValue: integer);
procedure SetDefaultItemHeight(const AValue: integer);
procedure SetOnShowOptions(const AValue: TNotifyEvent);
procedure SetPropertyEditorHook(NewValue:TPropertyEditorHook);
@ -338,6 +354,8 @@ type
procedure OnGridModified(Sender: TObject);
procedure SetAvailComboBoxText;
procedure HookGetSelectedComponents(Selection: TComponentSelectionList);
procedure SetShowComponentTree(const AValue: boolean);
procedure SetUsePairSplitter(const AValue: boolean);
public
constructor Create(AnOwner: TComponent); override;
destructor Destroy; override;
@ -360,6 +378,9 @@ type
read FPropertyEditorHook write SetPropertyEditorHook;
property OnModified: TNotifyEvent read FOnModified write FOnModified;
property OnShowOptions: TNotifyEvent read FOnShowOptions write SetOnShowOptions;
property ShowComponentTree: boolean read FShowComponentTree write SetShowComponentTree;
property ComponentTreeHeight: integer read FComponentTreeHeight write SetComponentTreeHeight;
property UsePairSplitter: boolean read FUsePairSplitter write SetUsePairSplitter;
end;
const
@ -1960,6 +1981,8 @@ begin
FPropertyGridSplitterX:=110;
FEventGridSplitterX:=110;
FDefaultItemHeight:=0;
FShowComponentTree:=true;
FComponentTreeHeight:=100;
FGridBackgroundColor:=clBtnFace;
end;
@ -1995,6 +2018,10 @@ begin
FDefaultItemHeight:=XMLConfig.GetValue(
'ObjectInspectorOptions/Bounds/DefaultItemHeight',0);
if FDefaultItemHeight<0 then FDefaultItemHeight:=0;
FShowComponentTree:=XMLConfig.GetValue(
'ObjectInspectorOptions/ComponentTree/Show/Value',true);
FComponentTreeHeight:=XMLConfig.GetValue(
'ObjectInspectorOptions/ComponentTree/Height/Value',100);
FGridBackgroundColor:=XMLConfig.GetValue(
'ObjectInspectorOptions/GridBackgroundColor',clBtnFace);
@ -2023,17 +2050,21 @@ begin
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Width',FWidth);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Height',FHeight);
end;
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX'
,FPropertyGridSplitterX);
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/EventGridSplitterX'
,FEventGridSplitterX);
XMLConfig.SetDeleteValue(
'ObjectInspectorOptions/Bounds/DefaultItemHeight',FDefaultItemHeight,20);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/PropertyGridSplitterX',
FPropertyGridSplitterX);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/EventGridSplitterX',
FEventGridSplitterX);
XMLConfig.SetDeleteValue('ObjectInspectorOptions/Bounds/DefaultItemHeight',
FDefaultItemHeight,20);
{$IFNDEF CompTree}
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Show/Value',
FShowComponentTree,true);
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Height/Value',
FComponentTreeHeight,100);
{$ENDIF}
XMLConfig.SetDeleteValue('ObjectInspectorOptions/GridBackgroundColor'
,FGridBackgroundColor,clBackground);
XMLConfig.SetDeleteValue('ObjectInspectorOptions/GridBackgroundColor',
FGridBackgroundColor,clBackground);
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ShowHints',FShowHints,true);
if XMLConfig<>CustomXMLCfg then XMLConfig.Flush;
@ -2055,6 +2086,8 @@ begin
FPropertyGridSplitterX:=AnObjInspector.PropertyGrid.PrefferedSplitterX;
FEventGridSplitterX:=AnObjInspector.EventGrid.PrefferedSplitterX;
FDefaultItemHeight:=AnObjInspector.DefaultItemHeight;
FShowComponentTree:=AnObjInspector.ShowComponentTree;
FComponentTreeHeight:=AnObjInspector.ComponentTreeHeight;
FGridBackgroundColor:=AnObjInspector.PropertyGrid.BackgroundColor;
FShowHints:=AnObjInspector.PropertyGrid.ShowHint;
end;
@ -2069,6 +2102,8 @@ begin
AnObjInspector.EventGrid.PrefferedSplitterX:=FEventGridSplitterX;
AnObjInspector.EventGrid.SplitterX:=FEventGridSplitterX;
AnObjInspector.DefaultItemHeight:=FDefaultItemHeight;
AnObjInspector.ShowComponentTree:=FShowComponentTree;
AnObjInspector.ComponentTreeHeight:=FComponentTreeHeight;
AnObjInspector.PropertyGrid.BackgroundColor:=FGridBackgroundColor;
AnObjInspector.PropertyGrid.ShowHint:=FShowHints;
AnObjInspector.EventGrid.BackgroundColor:=FGridBackgroundColor;
@ -2083,22 +2118,22 @@ end;
constructor TObjectInspector.Create(AnOwner: TComponent);
procedure AddPopupMenuItem(var NewMenuItem:TmenuItem;
ParentMenuItem:TMenuItem; AName,ACaption,AHint:string;
AOnClick: TNotifyEvent; CheckedFlag,EnabledFlag,VisibleFlag:boolean);
procedure AddPopupMenuItem(var NewMenuItem: TmenuItem;
ParentMenuItem: TMenuItem; const AName, ACaption, AHint: string;
AnOnClick: TNotifyEvent; CheckedFlag, EnabledFlag, VisibleFlag: boolean);
begin
NewMenuItem:=TMenuItem.Create(Self);
with NewMenuItem do begin
Name:=AName;
Caption:=ACaption;
Hint:=AHint;
OnClick:=AOnClick;
OnClick:=AnOnClick;
Checked:=CheckedFlag;
Enabled:=EnabledFlag;
Visible:=VisibleFlag;
end;
if ParentMenuItem<>nil then
ParentMenuItem.Add(NewmenuItem)
ParentMenuItem.Add(NewMenuItem)
else
MainPopupMenu.Items.Add(NewMenuItem);
end;
@ -2111,6 +2146,10 @@ begin
FUpdatingAvailComboBox:=false;
Name := DefaultObjectInspectorName;
FDefaultItemHeight := 22;
FComponentTreeHeight:=100;
{$IFDEF CompTree}
FShowComponentTree:=true;
{$ENDIF}
// StatusBar
StatusBar:=TStatusBar.Create(Self);
@ -2119,7 +2158,6 @@ begin
Parent:=Self;
SimpleText:='All';
Align:= alBottom;
Visible:=true;
end;
// PopupMenu
@ -2136,6 +2174,14 @@ begin
AddPopupMenuItem(ShowHintsPopupMenuItem,nil
,'ShowHintPopupMenuItem','Show Hints','Grid hints'
,@OnShowHintPopupMenuItemClick,false,true,true);
ShowHintsPopupMenuItem.ShowAlwaysCheckable:=true;
AddPopupMenuItem(ShowComponentTreePopupMenuItem,nil
,'ShowComponentTreePopupMenuItem','Show Component Tree',''
,@OnShowComponentTreePopupMenuItemClick,FShowComponentTree,true,true);
ShowComponentTreePopupMenuItem.ShowAlwaysCheckable:=true;
{$IFNDEF CompTree}
ShowComponentTreePopupMenuItem.Enabled:=false;
{$ENDIF}
AddPopupMenuItem(ShowOptionsPopupMenuItem,nil
,'ShowOptionsPopupMenuItem','Options',''
,@OnShowOptionsPopupMenuItemClick,false,true,FOnShowOptions<>nil);
@ -2152,7 +2198,17 @@ begin
OnCloseUp:=@AvailComboBoxCloseUp;
//Sorted:=true;
Align:= alTop;
Visible:=true;
Visible:=not FShowComponentTree;
end;
// Component Tree
ComponentTree:=TComponentTreeView.Create(Self);
with ComponentTree do begin
Name:='ComponentTree';
Height:=ComponentTreeHeight;
Parent:=Self;
Align:=alTop;
Visible:=FShowComponentTree;
end;
// NoteBook
@ -2203,7 +2259,6 @@ begin
PopupMenu:=MainPopupMenu;
OnModified:=@OnGridModified;
end;
end;
destructor TObjectInspector.Destroy;
@ -2241,6 +2296,12 @@ begin
Result:=c.GetNamePath+': '+c.ClassName;
end;
procedure TObjectInspector.SetComponentTreeHeight(const AValue: integer);
begin
if FComponentTreeHeight=AValue then exit;
FComponentTreeHeight:=AValue;
end;
procedure TObjectInspector.SetDefaultItemHeight(const AValue: integer);
var
NewValue: Integer;
@ -2455,6 +2516,24 @@ begin
Selection.Assign(FComponentList);
end;
procedure TObjectInspector.SetShowComponentTree(const AValue: boolean);
begin
{$IFNDEF CompTree}
exit;
{$ENDIF}
if FShowComponentTree=AValue then exit;
FShowComponentTree:=AValue;
ShowComponentTreePopupMenuItem.Checked:=FShowComponentTree;
ComponentTree.Visible:=FShowComponentTree;
AvailCompsComboBox.Visible:=not FShowComponentTree;
end;
procedure TObjectInspector.SetUsePairSplitter(const AValue: boolean);
begin
if FUsePairSplitter=AValue then exit;
FUsePairSplitter:=AValue;
end;
procedure TObjectInspector.OnShowHintPopupMenuItemClick(Sender : TObject);
begin
PropertyGrid.ShowHint:=not PropertyGrid.ShowHint;
@ -2466,6 +2545,12 @@ begin
if Assigned(FOnShowOptions) then FOnShowOptions(Sender);
end;
procedure TObjectInspector.OnShowComponentTreePopupMenuItemClick(Sender: TObject
);
begin
ShowComponentTree:=not ShowComponentTree;
end;
procedure TObjectInspector.HookRefreshPropertyValues;
begin
RefreshPropertyValues;

View File

@ -19,7 +19,7 @@
For more information see the big comment part below.
ToDo:
-digits for floattypes -> I hope, I have guessed right
-digits for floattypes -> I hope, I guessed right
-TIntegerSet missing -> taking my own
-Save ColorDialog settings
-System.TypeInfo(Type) missing -> exists already in the fpc 1.1 version
@ -57,14 +57,14 @@ type
Object Inspector. The property editor is created based on the type of the
property being edited as determined by the types registered by
RegisterPropertyEditor. The Object Inspector uses a TPropertyEditor
for all modification to a property. GetName and GetValue are called to display
the name and value of the property. SetValue is called whenever the user
requests to change the value. Edit is called when the user double-clicks the
property in the Object Inspector. GetValues is called when the drop-down
list of a property is displayed. GetProperties is called when the property
is expanded to show sub-properties. AllEqual is called to decide whether or
not to display the value of the property when more than one component is
selected.
for all modification to a property. GetName and GetValue are called to
display the name and value of the property. SetValue is called whenever the
user requests to change the value. Edit is called when the user
double-clicks the property in the Object Inspector. GetValues is called when
the drop-down list of a property is displayed. GetProperties is called when
the property is expanded to show sub-properties. AllEqual is called to decide
whether or not to display the value of the property when more than one
component is selected.
The following are methods that can be overridden to change the behavior of
the property editor:

View File

@ -1472,6 +1472,7 @@ type
procedure BeginUpdate;
procedure Clear;
procedure ClearMultiSelection;
function IsMultiSelection: boolean;
procedure Delete(Node: TTreeNode);
procedure EndUpdate;
function GetFirstNode: TTreeNode;
@ -1525,6 +1526,7 @@ type
TTreeViewOption = (
tvoAllowMultiselect,
tvoAutoExpand,
tvoAutoInsertMark,
tvoAutoItemHeight,
tvoHideSelection,
tvoHotTrack,
@ -1601,7 +1603,6 @@ type
FSelectedColor: TColor;
FSelectedNode: TTreeNode;
FSortType: TSortType;
FStartDragNode: TTreeNode;
FStateChangeLink: TChangeLink;
FStateImages: TCustomImageList;
FStates: TTreeViewStates;
@ -1742,6 +1743,7 @@ type
procedure SetOptions(NewOptions: TTreeViewOptions);
procedure UpdateDefaultItemHeight; virtual;
procedure WndProc(var Message: TLMessage); override;
procedure UpdateInsertMark(X,Y: integer); virtual;
protected
property AutoExpand: Boolean read GetAutoExpand write SetAutoExpand default False;
property BorderStyle: TBorderStyle
@ -1799,8 +1801,9 @@ type
function GetNodeAt(X, Y: Integer): TTreeNode;
procedure GetInsertMarkAt(X, Y: Integer; var AnInsertMarkNode: TTreeNode;
var AnInsertMarkType: TTreeViewInsertMarkType);
procedure SetInsertMark(var AnInsertMarkNode: TTreeNode;
var AnInsertMarkType: TTreeViewInsertMarkType);
procedure SetInsertMark(AnInsertMarkNode: TTreeNode;
AnInsertMarkType: TTreeViewInsertMarkType);
procedure SetInsertMarkAt(X,Y: integer); virtual;
function IsEditing: Boolean;
procedure BeginUpdate;
procedure EndUpdate;
@ -2027,6 +2030,9 @@ end.
{ =============================================================================
$Log$
Revision 1.83 2003/08/22 07:58:38 mattias
started componenttree
Revision 1.82 2003/08/21 13:04:10 mattias
implemented insert marks for TTreeView

View File

@ -1147,7 +1147,7 @@ begin
then begin
Assert(False, 'Trace:Begin AutoDrag called');
BeginAutoDrag;
Exit;
exit;
end;
Include(FControlState,csLButtonDown);
end;
@ -2468,6 +2468,9 @@ end;
{ =============================================================================
$Log$
Revision 1.148 2003/08/22 07:58:38 mattias
started componenttree
Revision 1.147 2003/08/21 13:04:10 mattias
implemented insert marks for TTreeView

View File

@ -1750,6 +1750,12 @@ begin
end;
end;
function TTreeNodes.IsMultiSelection: boolean;
begin
Result:=(FFirstMultiSelected<>nil)
and (FFirstMultiSelected.GetNextMultiSelected<>nil);
end;
function TTreeNodes.AddChildFirst(ParentNode: TTreeNode; const S: string): TTreeNode;
begin
Result := AddChildObjectFirst(ParentNode, S, nil);
@ -3272,6 +3278,8 @@ var
NodeRect: TRect;
NodeMidY: integer;
begin
if Y<0 then Y:=0;
if Y>=ClientHeight then Y:=ClientHeight-1;
ANode:=GetNodeAtY(Y);
if ANode<>nil then begin
AnInsertMarkNode:=ANode;
@ -3311,7 +3319,7 @@ begin
end;
end;
// normalize
// normalize (try to replace tvimAsPrevSibling)
if (AnInsertMarkType=tvimAsPrevSibling) and (AnInsertMarkNode<>nil) then begin
if (AnInsertMarkNode.GetPrevSibling<>nil) then begin
if (AnInsertMarkNode.GetPrevSibling.Expanded=false)
@ -3327,13 +3335,22 @@ begin
end;
end;
procedure TCustomTreeView.SetInsertMark(var AnInsertMarkNode: TTreeNode;
var AnInsertMarkType: TTreeViewInsertMarkType);
procedure TCustomTreeView.SetInsertMark(AnInsertMarkNode: TTreeNode;
AnInsertMarkType: TTreeViewInsertMarkType);
begin
InsertMarkNode:=AnInsertMarkNode;
InsertMarkType:=AnInsertMarkType;
end;
procedure TCustomTreeView.SetInsertMarkAt(X, Y: integer);
var
AnInsertMarkNode: TTreeNode;
AnInsertMarkType: TTreeViewInsertMarkType;
begin
GetInsertMarkAt(X,Y,AnInsertMarkNode,AnInsertMarkType);
SetInsertMark(AnInsertMarkNode,AnInsertMarkType);
end;
function TCustomTreeView.GetHitTestInfoAt(X, Y: Integer): THitTests;
//var HitTest: TTVHitTestInfo;
var Node: TTreeNode;
@ -3983,7 +4000,7 @@ end;
procedure TCustomTreeView.WndProc(var Message: TLMessage);
begin
if not (csDesigning in ComponentState)
{if not (csDesigning in ComponentState)
and ((Message.Msg = LM_LBUTTONDOWN)
or (Message.Msg = LM_LBUTTONDBLCLK))
and not Dragging and
@ -3994,13 +4011,21 @@ begin
Dispatch(Message);
end;
end
{else if Message.Msg = CN_BASE+LM_CONTEXTMENU then
else if Message.Msg = CN_BASE+LM_CONTEXTMENU then
Message.Result := Perform(LM_CONTEXTMENU, Message.WParam, Message.LParam)
}
else
else}
inherited WndProc(Message);
end;
procedure TCustomTreeView.UpdateInsertMark(X,Y: integer);
begin
if (tvoAutoInsertMark in Options) and (not (csDesigning in ComponentState))
then
SetInsertMarkAt(X,Y)
else
SetInsertMark(nil,tvimNone);
end;
function TCustomTreeView.IsInsertMarkVisible: boolean;
begin
Result:=(FInsertMarkType<>tvimNone) and (FInsertMarkNode<>nil)
@ -4562,6 +4587,9 @@ var
CursorNode: TTreeNode;
bStartDrag: boolean;
begin
{$IFDEF VerboseDrag}
writeln('TCustomTreeView.MouseDown A ',Name,':',ClassName,' ');
{$ENDIF}
fMouseDownX := X;
fMouseDownY := Y;
if Button=mbMiddle then begin
@ -4599,15 +4627,20 @@ begin
end else if (ssCtrl in Shift) then begin
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
end else begin
Items.ClearMultiSelection;
CursorNode.MultiSelected:=true;
if (Selected<>CursorNode) or Items.IsMultiSelection then begin
Items.ClearMultiSelection;
CursorNode.MultiSelected:=true;
end;
end;
end;
bStartDrag := true;
end;
end;
if (bStartDrag) then begin
FStartDragNode:=CursorNode;
{$IFDEF VerboseDrag}
writeln('TCustomTreeView.MouseDown A bStartDrag ',Name,':',ClassName,' ');
{$ENDIF}
FDragNode:=CursorNode;
Include(fStates, tvsWaitForDragging);
end;
if Button=mbMiddle then begin
@ -4632,6 +4665,8 @@ begin
BeginDrag(false);
end;
end;
if (tvoAutoInsertMark in FOptions) then
UpdateInsertMark(X,Y);
end;
procedure TCustomTreeView.MouseUp(Button: TMouseButton; Shift: TShiftState;
@ -4818,12 +4853,20 @@ begin
end;
procedure TCustomTreeView.WMLButtonDown(var AMessage: TLMLButtonDown);
var
{var
Node: TTreeNode;
MousePos: TPoint;
P: TSmallPoint;
P: TSmallPoint;}
begin
{$IFDEF VerboseDrag}
writeln('TCustomTreeView.WMLButtonDown A ',Name,':',ClassName,' ');
{$ENDIF}
Exclude(FStates,tvsDragged);
inherited;
{$IFDEF VerboseDrag}
writeln('TCustomTreeView.WMLButtonDown END ',Name,':',ClassName,' ');
{$ENDIF}
{
FDragNode := nil;
try
inherited;
@ -4847,7 +4890,7 @@ begin
end;
finally
FDragNode := nil;
end;
end;}
end;
procedure TCustomTreeView.WMNotify(var AMessage: TLMNotify);

View File

@ -656,8 +656,8 @@ activate_time : the time at which the activation event occurred.
{Get the width and height for the form}
If TheWinControl.FCompStyle = csForm Then
begin
// the LCL defines the size of a form without border, win32 with
// adjust size
// the LCL defines the size of a form without border, win32 with.
// -> adjust size
//writeln('win32 LM_SETSIZE before adjusting form: ',
// ' New=',NewRect.Left,',',NewRect.Top,',',NewRect.Right - NewRect.Left,',',NewRect.Bottom - NewRect.Top);
R:=NewRect;
@ -2811,6 +2811,9 @@ End;
{
$Log$
Revision 1.92 2003/08/22 07:58:38 mattias
started componenttree
Revision 1.91 2003/08/21 06:52:47 mattias
size fixes from Karl