diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-09-03 15:03:23 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-09-03 15:03:23 +0000 |
commit | 4ef91ca61a1cac4918fbe40c1550a84819744404 (patch) | |
tree | 90396bd0b8af74b6b8723feec237f29c9ae315e2 | |
parent | feabd37193a4e63ff629b6f1e05039eeffcc8aa2 (diff) | |
download | fpGUI-4ef91ca61a1cac4918fbe40c1550a84819744404.tar.xz |
* Treeview finally paints itself. Still not 100% and still no input support.
-rw-r--r-- | examples/gui/treeviewtest/treeviewtest.lpr | 8 | ||||
-rw-r--r-- | src/gui/gui_tree.pas | 63 |
2 files changed, 40 insertions, 31 deletions
diff --git a/examples/gui/treeviewtest/treeviewtest.lpr b/examples/gui/treeviewtest/treeviewtest.lpr index 7db4aafe..45c18079 100644 --- a/examples/gui/treeviewtest/treeviewtest.lpr +++ b/examples/gui/treeviewtest/treeviewtest.lpr @@ -32,12 +32,18 @@ begin TV := TfpgTreeView.Create(self); TV.SetPosition(8, 8, 250, 180); - TV.ShowColumns := False; + TV.Align := alClient; + TV.ShowColumns := True; n := TV.RootNode.AppendText('Node 1'); n.AppendText('Node 1.1'); + n.AppendText('Node 1.2'); n := TV.RootNode.AppendText('Node 2'); n.AppendText('Node 2.1'); + n := n.AppendText('Node 2.2'); + n.AppendText('Node 2.2.1'); + TV.RootNode.FirstSubNode.Next.Collapse; TV.RootNode.AppendText('Node 3'); + TV.Selection := n; end; diff --git a/src/gui/gui_tree.pas b/src/gui/gui_tree.pas index f1b95a4a..586745b8 100644 --- a/src/gui/gui_tree.pas +++ b/src/gui/gui_tree.pas @@ -9,6 +9,8 @@ unit gui_tree; WARNING: This is still under heavy development! Do NOT use. } +{.$Define Debug} + interface uses @@ -60,8 +62,8 @@ type // node related procedure UnregisterSubNode(aNode: TfpgTreeNode); procedure Append(aValue: TfpgTreeNode); - function FindSubNode(AText: string; ARecursive: Boolean): TfpgTreeNode; function AppendText(AText: string): TfpgTreeNode; + function FindSubNode(AText: string; ARecursive: Boolean): TfpgTreeNode; function GetMaxDepth: integer; function GetMaxVisibleDepth: integer; procedure Collapse; @@ -162,8 +164,8 @@ type property RootNode: TfpgTreeNode read GetRootNode; property Selection: TfpgTreeNode read FSelection write SetSelection; published - property ShowImages: boolean read FShowImages write SetShowImages; - property ShowColumns: boolean read FShowColumns write SetShowColumns; + property ShowImages: boolean read FShowImages write SetShowImages default False; + property ShowColumns: boolean read FShowColumns write SetShowColumns default False; property FontDesc: string read GetFontDesc write SetFontDesc; property DefaultColumnWidth: word read FDefaultColumnWidth write SetDefaultColumnWidth; property OnChange: TNotifyEvent read FOnChange write FOnChange; @@ -312,7 +314,7 @@ end; procedure TfpgTreeNode.Append(aValue: TfpgTreeNode); begin aValue.Parent := self; - aValue.next := nil; + aValue.Next := nil; if FFirstSubNode = nil then FFirstSubNode := aValue; @@ -577,7 +579,7 @@ end; function TfpgTreeview.GetFontDesc: string; begin - + Result := FFont.FontDesc; end; function TfpgTreeview.GetRootNode: TfpgTreeNode; @@ -826,22 +828,21 @@ var AColumnLeft: PColumnLeft; begin if FColumnLeft = nil then - begin PreCalcColumnLeft; - if AIndex < 0 then - Result := 0 + + if AIndex < 0 then + Result := 0 + else + begin + if AIndex > FColumnLeft.Count - 1 then + begin + AColumnLeft := FColumnLeft[FColumnLeft.Count - 1]; + result := AColumnLeft^; + end else begin - if AIndex > FColumnLeft.Count - 1 then - begin - AColumnLeft := FColumnLeft[FColumnLeft.Count - 1]; - result := AColumnLeft^; - end - else - begin - AColumnLeft := FColumnLeft[AIndex]; - result := AColumnLeft^; - end; + AColumnLeft := FColumnLeft[AIndex]; + result := AColumnLeft^; end; end; end; @@ -901,7 +902,7 @@ begin AColumnLeft := new(PColumnLeft); AColumnLeft^ := Aleft; FColumnLeft.Add(AColumnLeft); - Aleft := ALeft + GetColumnWidth(ACounter); + Aleft := Aleft + GetColumnWidth(ACounter); end; end; @@ -1076,7 +1077,7 @@ begin // draw the nodes with lines h := RootNode.FirstSubNode; - Canvas.SetTextColor(RootNode.ParentTextColor); +// Canvas.SetTextColor(RootNode.ParentTextColor); YPos := 0; while h <> nil do begin @@ -1357,12 +1358,14 @@ end; constructor TfpgTreeview.Create(AOwner: TComponent); begin inherited Create(AOwner); - FRootNode := nil; - FSelection := nil; + FRootNode := nil; + FSelection := nil; + FShowImages := False; + FShowColumns := False; FDefaultColumnWidth := 15; - FFirstColumn := nil; + FFirstColumn := nil; FFont := fpgGetFont('#Label1'); - + FHScrollbar := TfpgScrollbar.Create(self); FHScrollbar.Orientation := orHorizontal; FHScrollbar.OnScroll := @HScrollbarMove; @@ -1376,12 +1379,12 @@ begin FVScrollbar.Position := 0; FVScrollbar.SliderSize := 0.2; - FBackgroundColor := clListBox; - FFocusable := True; - FMoving := False; - FXOffset := 0; - FYOffset := 0; - FColumnHeight := FFont.Height + 2; + FBackgroundColor := clListBox; + FFocusable := True; + FMoving := False; + FXOffset := 0; + FYOffset := 0; + FColumnHeight := FFont.Height + 2; end; procedure TfpgTreeview.SetColumnWidth(AIndex, AWidth: word); |