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

📄 udiagramform.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    procedure BottomLeftChanged;


    //Fills the tree view with all available files and record-like types.
    procedure FillTreeView;
    //Returns a root node by the data value.
    function GetRootByData(Data: Integer): TTreeNode;
    //Returns a node under another node by its data.
    function FindNodeUnderByData(Root: TTreeNode; Data: Pointer): TTreeNode;


    //Calls the procedure for the class and all its descendants.
    procedure AddRemoveClassAndDescendants(AddRemove: THandleAddRemoveDataProc;
                                           TheClass: TRecordType;
                                           TheFile: TPascalFile = nil);
    //Calls the procedure for each implementing class and their descendants of
    //the interface or one of its descendants.
    procedure AddRemoveClassesImplementingOrDescendants(
                     AddRemove: THandleAddRemoveDataProc; Interf: TRecordType);

    //If the identifier is a class then the procedure is called with it.
    procedure AddRemoveAssociatedClasses(Ident: TIdentType;
                                         Parent: TIdentifier;
                                         DoRemove: TIdentifier);


    //Deletes all boxes.
    function DeleteSelected(TheClass: TRecordType; TheFile: TPascalFile;
                            Selected: Boolean): TBoxEnumerationActions;
    //Toggles the selection-state of all boxes.
    function ToggleSelection(TheClass: TRecordType; TheFile: TPascalFile;
                             Selected: Boolean): TBoxEnumerationActions;
    //Deletes the box of the class, if it is not declared in the interface of a
    //unit.
    function DeletePrivateClasses(TheClass: TRecordType; TheFile: TPascalFile;
                                  Selected: Boolean): TBoxEnumerationActions;
    //Executes the action ~[link FDirectoryAction].
    function HandleAction(TheClass: TRecordType; TheFile: TPascalFile;
                          Selected: Boolean): TBoxEnumerationActions;





    //Updates the states of the buttons in the tool-bar.
    procedure UpdateButtons;



    //Saves each box.
    procedure SaveEachBox(TheClass: TRecordType; TheFile: TPascalFile;
                          Position, Size: TPoint);
    //Saves the current diagram.
    function SaveCurrentLayout: Boolean;
    //Loads a diagram.
    procedure LoadLayout(Index: Integer);



    //Called when a diagram is selected to show.
    procedure MenuItemSelectLayoutClick(Sender: TObject);





    //Called when the diagram or the control to show the diagram changed its
    //size.
    procedure DoResize(Sender: TObject);
    //Called when the diagram or the control to show the diagram needs to be
    //(re)painted.
    procedure DiagramNeedsRepaint(Sender: TObject);

    //Called when the user clicks on the control that shows the diagram.
    procedure ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    //Called when the user moves the mouse over or drags in the control that
    //shows the diagram.
    procedure ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    //Called when the user clicked on the control that shows the diagram.
    procedure ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);


    //Called when the mouse wheel is moved when the tree view is focused.
    function HandleTreeViewMouseWheel(MousePos: TPoint; Down: Boolean): Boolean;
    //Called when the mouse wheel is moved up when the tree view is focused.
    procedure TreeViewMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
    //Called when the mouse wheel is moved down when the tree view is focused.
    procedure TreeViewMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);



    //Called when the window to show a zoomed map of the diagram is hidden.
    procedure ZoomWindowHide(Sender: TObject);
    //Called when the window to show a zoomed map of the diagram is resized.
    procedure ZoomWindowResize(Sender: TObject);
    //Called when the window to show a zoomed map of the diagram needs
    //(re)painting.
    procedure ZoomWindowPaint(Sender: TObject);
    //Called when the window to show a zoomed map of the diagram is clicked.
    procedure ZoomMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    //Called when the mouse is moved over window to show a zoomed map of the
    //diagram.
    procedure ZoomMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  public
    //Creates the form to create and edit diagrams with all objects.
    constructor Create(Files: TFileList); reintroduce;
    //Frees the form, the diagram, the zoom window and the set of diagrams.
    destructor Destroy; override;

    property ZoomWindow: TForm read FZoomWindow;
    property SVGImageLinkKind: TSVGImageLinkKind read FSVGImageLinkKind;
  end;




//Creates and shows a window to create and edit diagrams based on the parsed
//data.
procedure ShowDiagramEditor(Files: TFileList);

implementation

{$R *.dfm}

uses Math,
{$IFNDEF LINUX}
     ClipBrd,
{$ELSE}
     QClipbrd,
{$ENDIF}
{$IFNDEF NOPNGSUPPORT}
 {$IFNDEF LINUX}
     pngimage,
 {$ENDIF}
{$ENDIF}
     General,
{$IFDEF LINUX}
     GeneralVCL,
{$ENDIF}
     UCommandParameters,
     UPascalConsts, UExtIdents,
     USettingsKeeper;





{Creates and shows a window to create and edit diagrams based on the parsed
 data.
~param Files the data to use to create diagrams }
procedure ShowDiagramEditor(Files: TFileList);
var       Form      :TFormDiagram;      //the windows to create diagrams
begin
 Form := TFormDiagram.Create(Files);    //create the window
 try
{$IFNDEF LINUX}
   Form.ShowModal;                      //show it
{$ELSE}
   ShowFormModal(Form);                 //show it
{$ENDIF}
 finally
  Form.Free;                            //free it
 end;
end;









  { * * *  ***  * * *  ***   TDrawControl   ***  * * *  ***  * * *  }



{Creates the control and initializes some options.
~param AOwner the owner of the conmponent }
constructor TDrawControl.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);         //create the component

{$IFNDEF LINUX}
 DoubleBuffered := False;          //enabled by default in Delphi 4
{$ENDIF}
 //don't fill background (could flicker else)
 ControlStyle := ControlStyle + [csCaptureMouse, csReplicatable, csOpaque];
 Align := alClient;                //use all available space
end;


{Calls FOnPaint if painting is needed. }
procedure TDrawControl.Paint;
begin
 if Assigned(FOnPaint) then        //can be painted?
  FOnPaint(Self);                    //paint it
end;















       //a simple redeclaration to access the protected event handlers
       //OnMouseWheelUp and OnMouseWheelDown.
type   TAccessTreeView = class(TTreeView);




  { * * *  ***  * * *  ***   TFormDiagram   ***  * * *  ***  * * *  }







type
  //the three tool bars on the diagram form
  TDiagramToolBar = (
                     dtbGeneral,   //the general tool bar
                     dtbClasses,   //the tool bar for diagrams of classes
                     dtbFiles);    //the tool bar for diagrams of files

      //base names for ini section for each tool bar in the diagram form
const ToolBarIniBaseNames: array[TDiagramToolBar] of String =
                      ('ToolBarGeneral', 'ToolBarClasses', 'ToolBarFiles');


type
  //settings of the tool bars to be written to and read form an ini file
  TToolBarSetting = record
    Undocked: Boolean;  //whether it is undocked
    Position: TPoint;   //position of tool bar (or tool window if undocked)
  end;


  {Loads and saves the settings of the form to create diagrams about the files
   or classes in the parsed source code. }
  TDiagramFormSettings = class(TFormSettings)
  private
    //whether the tool bars are shown
    FShowToolBars: Boolean;
    //whether the status bar is shown
    FShowStatusBar: Boolean;
    //whether the zoom window is shown
    FShowZoomWindow: Boolean;

    //the positions of all tool bars
    FToolBars: array[TDiagramToolBar] of TToolBarSetting;


    //the width of the tree view with all files and classes
    FTreeViewWidth: Integer;

    //horizontal position of the zoom window
    FZoomWindowLeft: Integer;
    //vertical position of the zoom window
    FZoomWindowTop: Integer;
    //width of the zoom window
    FZoomWindowWidth: Integer;
    //height of the zoom window
    FZoomWindowHeight: Integer;

    //what kind of links should be generated in exported SVG image files
    FSVGImageLinkKind: TSVGImageLinkKind;


  protected
  public
    //Loads the settings from the ini file.
    procedure LoadFromIni(Ini: TCustomIniFile); override;
    //Saves the settings to the ini file.
    procedure SaveToIni(Ini: TCustomIniFile); override;

    //Gets the settings from the form.
    procedure ReadValues(Form: TFormDiagram);

    //Assigns the read properties of the tool bar to it.
    procedure GetToolBar(ToolBar: TToolbar; WhichOne: TDiagramToolBar;
                         PreShow: Boolean);


    property ShowToolBars: Boolean read FShowToolBars;
    property ShowStatusBar: Boolean read FShowStatusBar;
    property ShowZoomWindow: Boolean read FShowZoomWindow;
    property SVGImageLinkKind: TSVGImageLinkKind read FSVGImageLinkKind;
    property TreeViewWidth: Integer read FTreeViewWidth;
    property ZoomWindowLeft: Integer read FZoomWindowLeft;
    property ZoomWindowTop: Integer read FZoomWindowTop;
    property ZoomWindowWidth: Integer read FZoomWindowWidth;
    property ZoomWindowHeight: Integer read FZoomWindowHeight;
  end;






{Loads the settings from the ini file.
~param Ini the ini file to load the settings from }
procedure TDiagramFormSettings.LoadFromIni(Ini: TCustomIniFile);

 {Loads the properties of the tool bar from the ini file.
 ~param WhichOne which tool bar's properties should be read }
 procedure LoadToolBar(WhichOne: TDiagramToolBar);
 begin
  //read whether the tool bar is undocked
  FToolBars[WhichOne].Undocked := Ini.ReadBool(Name,
                                    ToolBarIniBaseNames[WhichOne] + 'Undocked',
                                    FToolBars[WhichOne].Undocked);
  //read position of the tool bar
  FToolBars[WhichOne].Position.x := Ini.ReadInteger(Name,
                                       ToolBarIniBaseNames[WhichOne] + 'Left',
                                       FToolBars[WhichOne].Position.x);
  FToolBars[WhichOne].Position.y := Ini.ReadInteger(Name,
                                       ToolBarIniBaseNames[WhichOne] + 'Top',
                                       FToolBars[WhichOne].Position.y);
 end;

var       i                   :Integer;  //temporal integer value

⌨️ 快捷键说明

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