⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeed.pas

📁 TeeChart 7.0 With Source在Delphi 7.0中的安装
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  Sender.Font.Size:=GetFontSize;
end;

procedure TTreeEditor.ChangeFontAlign(Sender: TTreeNodeShape);
begin
  Sender.HorizTextAlign:=GetFontAlign;
end;

procedure TTreeEditor.ChangeInterChar(Sender: TTreeNodeShape);
begin
  Sender.Font.InterCharSize:=UDFontInter.Position;
end;

Procedure TTreeEditor.DoSetOutLine(Sender:TTreeNodeShape);
begin
  Sender.Font.OutLine.Assign(TheTree.Selected.First.Font.OutLine);
end;

procedure TTreeEditor.TheTreeMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (not TheTree.CancelMouse) and
     (not TheTree.Connecting) and
     (Button=mbRight) and
     (TheTree.Designing) then
        TryPopup(TheTree,x,y);
end;

procedure TTreeEditor.TheTreeClickConnection(Sender: TTreeConnection;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  TheTree.SelectConnection(Sender);
end;

procedure TTreeEditor.TheTreeDblClickShape(Sender: TTreeNodeShape;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  With TheTree do
  if Designing and (Selected.Count>0) then
  begin
    TheTree.Canvas.Calculate2DPosition(X,Y,0);
    if Selected.First.ClickedImage(x,y) then
       EditTreeShapePage(Self,TheTree.Selected.First,stImage,True)
    else
       EditTreeShape(Self,TheTree.Selected.First);
    SetToolBars;
    CancelMouse:=True; { to not expand / collapse the node... }
    TeeModified;
  end;
end;

Function TTreeEditor.GetToolBarShape:PTreeTagShape;
var t : Integer;
begin
  result:=nil;

  With PageShapes.ActivePage do
  for t:=0 to ControlCount-1 do
  if Controls[t] is TSpeedButton then
  With Controls[t] as TSpeedButton do
  if Down and (Tag{$IFDEF CLR}<>nil{$ELSE}>=0{$ENDIF}) then
  begin
    {$IFDEF CLR}
    if not Variant.IsNull(Tag) then
    {$ENDIF}
       result:=PTreeTagShape(Tag);
    break;
  end;
end;

procedure TTreeEditor.AddNewShape(AClass:PTreeTagShape; Const R:TRect);
var tmpShape : TTreeNodeShape;
begin
  if OldDesignState then
     TInternalLoadTree(TheTree).SetDesigning(True);
  try
    tmpShape:=TheTree.AddShapeClass(R.Left,R.Top,'',nil,AClass.AClass);
  finally
    if OldDesignState then
       TInternalLoadTree(TheTree).SetDesigning(False);
  end;

  With tmpShape do
  begin
    if R.Left<>0 then X0:=R.Left;
    if R.Top<>0 then  Y0:=R.Top;
    if AClass.UseStyle then Style:=AClass.Style;
    if ((R.Right-R.Left)>0) and ((R.Bottom-R.Top)>0) then
    begin
      X1:=R.Right;
      Y1:=R.Bottom;
      AutoSize:=False;
    end{
     else begin
       X1:=X0;
       Y1:=Y0;
     end};
    if Text.Count=0 then Text.Add(Name);

    Case Style of
      tssTriangleTop   : VertTextAlign  :=vtaBottom;
      tssTriangleBottom: VertTextAlign  :=vtaTop;
      tssTriangleLeft  : HorizTextAlign :=htaRight;
      tssTriangleRight : HorizTextAlign :=htaLeft;
    end;

    if not (tmpShape is TImageShape) then
       ImageIndex:=tiNone;

    Tree.Selected.Clear;
    Selected:=True;
    Expanded:=True;
  end;
end;

procedure TTreeEditor.TheTreeOnZoomedArea(Const R:TRect);
var tmp : PTreeTagShape;
begin
  tmp:=GetToolBarShape;

  if Assigned(tmp) then
  begin
    AddNewShape(tmp,R);
    TheTree.CancelMouse:=True;
    FillNodeTree;
    TeeModified;
    SpeedNormal.Down:=True;
    TTreeAccess(TheTree).IZoomPriority:=False;
  end;
end;

procedure TTreeEditor.CBImageStyleChange(Sender: TObject);
begin
  TheTree.BackImageMode:=TTeeBackImageMode(CBImageStyle.ItemIndex);
  TeeModified;
end;

Function TTreeEditor.AddNewRoot:TTreeNodeShape;
begin
  result:=TheTree.AddRoot(TreeMsg_Root+' '+TeeStr(TheTree.Roots.Count+1));
end;

procedure TTreeEditor.AddnewRoot2Click(Sender: TObject);
begin
  TheTree.Selected.Clear;
  AddNewRoot.Selected:=True;
  FillNodeTree;
  TeeModified;
end;

{$IFNDEF CLX}
type
  TTreeRegistry=class(TRegistry)
  public
    {$IFDEF CLR}
    Constructor Create;
    {$ENDIF}

    Procedure ReadVisible(Const AKey:String; AControl:TWinControl);
  end;

{$IFDEF CLR}
Constructor TTreeRegistry.Create;
begin
  inherited Create;
end;
{$ENDIF}

Procedure TTreeRegistry.ReadVisible(Const AKey:String; AControl:TWinControl);
begin
  if ValueExists(AKey) then AControl.Visible:=ReadBool(AKey);
end;
{$ENDIF}

Procedure TTreeEditor.LoadEditorParameters;
{$IFNDEF CLX}
var l,t,w,h,s:Integer;
{$ENDIF}
begin
  {$IFNDEF CLX}
  With TTreeRegistry.Create do
  try
    if {$IFDEF D4}OpenKeyReadOnly{$ELSE}OpenKey{$ENDIF}(TeeTreeKey{$IFNDEF D4},False{$ENDIF}) then
    begin
      if ValueExists('Left') then
      begin
        l:=ReadInteger('Left');
        t:=ReadInteger('Top');
        w:=ReadInteger('Width');
        h:=ReadInteger('Height');
        Self.SetBounds(l,t,w,h);
      end;

      Self.WindowState:=wsNormal;
      if ValueExists('State') then
      begin
        s:=ReadInteger('State');
        Self.WindowState:=TWindowState(s);

        // Do not allow minimized:
        if Self.WindowState=wsMinimized then Self.WindowState:=wsNormal;
      end;

      ReadVisible('Tabs',PageTree);
      ReadVisible('ShapeTabs',PageShapes);
      ReadVisible('Status',StatusBar1);
      ReadVisible('FontToolBar',PanelFont);
      ReadVisible('BorderToolBar',PanelShape);
      ReadVisible('ToolBar',PanelToolButtons);

      ReadVisible('Rulers',HorizRuler);
      VertRuler.Visible:=HorizRuler.Visible;

      if ValueExists('RulersUnits') then
      begin
        HorizRuler.ShowUnits:=ReadBool('RulersUnits');
        VertRuler.ShowUnits:=HorizRuler.ShowUnits;
      end;

      if ValueExists('NodeTreeWidth') then
         PanelNodes.Width:=ReadInteger('NodeTreeWidth');

      if ValueExists('NodeTree') then
         if ReadBool('NodeTree')<>NodeTheTree.Checked then
            NodeTheTreeClick(Self);

      if ValueExists('NodeTreeLeft') then
         if not ReadBool('NodeTreeLeft') then
            AlignToLeft1Click(Self);
    end;
  finally
    Free;
  end;
  {$ENDIF}
end;

Procedure TTreeEditor.SaveEditorParameters;
begin
  {$IFNDEF CLX}
  With TRegistry.Create do
  try
    if OpenKey(TeeTreeKey,True) then
    begin
      if Self.WindowState=wsNormal then
      begin
        WriteInteger('Left',Self.Left);
        WriteInteger('Top',Self.Top);
        WriteInteger('Width',Self.Width);
        WriteInteger('Height',Self.Height);
      end;

      WriteInteger('State',Ord(Self.WindowState));
      WriteBool('Tabs',PageTree.Visible);
      WriteBool('ShapeTabs',PageShapes.Visible);
      WriteBool('NodeTree',PanelNodesInt.Visible);
      WriteBool('Status',StatusBar1.Visible);
      WriteBool('FontToolBar',PanelFont.Visible);
      WriteBool('BorderToolBar',PanelShape.Visible);
      WriteBool('ToolBar',PanelToolButtons.Visible);
      WriteBool('Rulers',HorizRuler.Visible);
      WriteBool('RulersUnits',HorizRuler.ShowUnits);

      WriteInteger('NodeTreeWidth',PanelNodes.Width);
      WriteBool('NodeTreeLeft',PanelNodes.Align=alLeft);
    end;
  finally
    Free;
  end;
  {$ENDIF}
end;

procedure TTreeEditor.DoPrune(Sender: TTreeNodeShape);
begin
  Sender.Parent:=nil;
end;

procedure TTreeEditor.Prune1Click(Sender: TObject);
begin
  TheTree.Selected.ForEach(DoPrune);
  FillNodeTree;
  TeeModified;
end;

procedure TTreeEditor.Button6Click(Sender: TObject);
begin
  if EditChartBrush(Self,TheTree.CrossBox.Brush) then
     TeeModified;
end;

procedure TTreeEditor.Edit2Change(Sender: TObject);
begin
  if not Creating then
  begin
    TheTree.CrossBox.Size:=UDCrossSize.Position;
    TeeModified;
  end;
end;

const
  ShortCuts: array[0..108] of TShortCut = (
    scNone,
    Byte('A') or scCtrl,
    Byte('B') or scCtrl,
    Byte('C') or scCtrl,
    Byte('D') or scCtrl,
    Byte('E') or scCtrl,
    Byte('F') or scCtrl,
    Byte('G') or scCtrl,
    Byte('H') or scCtrl,
    Byte('I') or scCtrl,
    Byte('J') or scCtrl,
    Byte('K') or scCtrl,
    Byte('L') or scCtrl,
    Byte('M') or scCtrl,
    Byte('N') or scCtrl,
    Byte('O') or scCtrl,
    Byte('P') or scCtrl,
    Byte('Q') or scCtrl,
    Byte('R') or scCtrl,
    Byte('S') or scCtrl,
    Byte('T') or scCtrl,
    Byte('U') or scCtrl,
    Byte('V') or scCtrl,
    Byte('W') or scCtrl,
    Byte('X') or scCtrl,
    Byte('Y') or scCtrl,
    Byte('Z') or scCtrl,
    Byte('A') or scCtrl or scAlt,
    Byte('B') or scCtrl or scAlt,
    Byte('C') or scCtrl or scAlt,
    Byte('D') or scCtrl or scAlt,
    Byte('E') or scCtrl or scAlt,
    Byte('F') or scCtrl or scAlt,
    Byte('G') or scCtrl or scAlt,
    Byte('H') or scCtrl or scAlt,
    Byte('I') or scCtrl or scAlt,
    Byte('J') or scCtrl or scAlt,
    Byte('K') or scCtrl or scAlt,
    Byte('L') or scCtrl or scAlt,
    Byte('M') or scCtrl or scAlt,
    Byte('N') or scCtrl or scAlt,
    Byte('O') or scCtrl or scAlt,
    Byte('P') or scCtrl or scAlt,
    Byte('Q') or scCtrl or scAlt,
    Byte('R') or scCtrl or scAlt,
    Byte('S') or scCtrl or scAlt,
    Byte('T') or scCtrl or scAlt,
    Byte('U') or scCtrl or scAlt,
    Byte('V') or scCtrl or scAlt,
    Byte('W') or scCtrl or scAlt,
    Byte('X') or scCtrl or scAlt,
    Byte('Y') or scCtrl or scAlt,
    Byte('Z') or scCtrl or scAlt,
    VK_F1,
    VK_F2,
    VK_F3,
    VK_F4,
    VK_F5,
    VK_F6,
    VK_F7,
    VK_F8,
    VK_F9,
    VK_F10,
    VK_F11,
    VK_F12,
    VK_F1 or scCtrl,
    VK_F2 or scCtrl,
    VK_F3 or scCtrl,
    VK_F4 or scCtrl,
    VK_F5 or scCtrl,
    VK_F6 or scCtrl,
    VK_F7 or scCtrl,
    VK_F8 or scCtrl,
    VK_F9 or scCtrl,
    VK_F10 or scCtrl,
    VK_F11 or scCtrl,
    VK_F12 or scCtrl,
    VK_F1 or scShift,
    VK_F2 or scShift,
    VK_F3 or scShift,
    VK_F4 or scShift,
    VK_F5 or scShift,
    VK_F6 or scShift,
    VK_F7 or scShift,
    VK_F8 or scShift,
    VK_F9 or scShift,
    VK_F10 or scShift,
    VK_F11 or scShift,
    VK_F12 or scShift,
    VK_F1 or scShift or scCtrl,
    VK_F2 or scShift or scCtrl,
    VK_F3 or scShift or scCtrl,
    VK_F4 or scShift or scCtrl,
    VK_F5 or scShift or scCtrl,
    VK_F6 or scShift or scCtrl,
    VK_F7 or scShift or scCtrl,
    VK_F8 or scShift or scCtrl,
    VK_F9 or scShift or scCtrl,
    VK_F10 or scShift or scCtrl,
    VK_F11 or scShift or scCtrl,
    VK_F12 or scShift or scCtrl,
    VK_INSERT,
    VK_INSERT or scShift,
    VK_INSERT or scCtrl,
    VK_DELETE,
    VK_DELETE or scShift,
    VK_DELETE or scCtrl,
    VK_BACK or scAlt,
    VK_BACK or scShift or scAlt);

procedure TTreeEditor.FormCreate(Sender: TObject);
var t : Integer;
begin
  // CLX does not support Tabs.Strings
  // This is why tabs are added here:
  with TabControl1.Tabs do
  begin
    Add('Design');
    Add('Preview');
  end;

  with CBTextKey do
  begin
    Clear;
    for t:=1 to High(ShortCuts) do
       Items.Add(ShortCutToText(ShortCuts[t]));
  end;

  // Not supported in CLX (TMenuItem.Default)
  {$IFNDEF CLX}
  Edit1.Default:=True;
  Edit6.Default:=True;
  {$ENDIF}

  TreeUndo:=

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -