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

📄 udiagramform.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
begin
 inherited LoadFromIni(Ini);             //read general form settings

 //read visibility of components
 FShowToolBars := Ini.ReadBool(Name, 'ShowToolBar', FShowToolBars);
 FShowStatusBar := Ini.ReadBool(Name, 'ShowStatusBar', FShowStatusBar);
 FShowZoomWindow := Ini.ReadBool(Name, 'ShowZoomWindow', FShowZoomWindow);

 //read what kind of links should be generated in exported SVG image files
 i := Ini.ReadInteger(Name, 'SVGImageLinkKind', Ord(FSVGImageLinkKind));
 if (i >= Ord(Low(FSVGImageLinkKind))) and
    (i <= Ord(High(FSVGImageLinkKind))) then
  FSVGImageLinkKind := TSVGImageLinkKind(i);

 LoadToolBar(dtbGeneral);                //read the data of all tool bars
 LoadToolBar(dtbClasses);
 LoadToolBar(dtbFiles);

 //read width of tree view
 FTreeViewWidth := Ini.ReadInteger(Name, 'TreeViewWidth', FTreeViewWidth);
 //read position of zoom window
 FZoomWindowLeft := Ini.ReadInteger(Name, 'ZoomWindowLeft', FZoomWindowLeft);
 FZoomWindowTop := Ini.ReadInteger(Name, 'ZoomWindowTop', FZoomWindowTop);
 FZoomWindowWidth := Ini.ReadInteger(Name, 'ZoomWindowWidth', FZoomWindowWidth);
 FZoomWindowHeight := Ini.ReadInteger(Name, 'ZoomWindowHeight',
                                      FZoomWindowHeight);
end;

{Saves the settings to the ini file.
~param Ini the ini file to save the settings to }
procedure TDiagramFormSettings.SaveToIni(Ini: TCustomIniFile);

 {Saves the properties of the tool bar in the ini file.
 ~param WhichOne which tool bar's properties should be writte }
 procedure SaveToolBar(WhichOne: TDiagramToolBar);
 begin
  //write whether the tool bar is undocked
  Ini.WriteBool(Name, ToolBarIniBaseNames[WhichOne] + 'Undocked',
                FToolBars[WhichOne].Undocked);
  //write position of the tool bar
  Ini.WriteInteger(Name, ToolBarIniBaseNames[WhichOne] + 'Left',
                   FToolBars[WhichOne].Position.x);
  Ini.WriteInteger(Name, ToolBarIniBaseNames[WhichOne] + 'Top',
                   FToolBars[WhichOne].Position.y);
 end;

begin
 inherited SaveToIni(Ini);           //write general form settings

 //write visibility of components
 Ini.WriteBool(Name, 'ShowToolBar', FShowToolBars);
 Ini.WriteBool(Name, 'ShowStatusBar', FShowStatusBar);
 Ini.WriteBool(Name, 'ShowZoomWindow', FShowZoomWindow);

 //write what kind of links should be generated in exported SVG image files
 Ini.WriteInteger(Name, 'SVGImageLinkKind', Ord(FSVGImageLinkKind));

 SaveToolBar(dtbGeneral);                //write the data of all tool bars
 SaveToolBar(dtbClasses);
 SaveToolBar(dtbFiles);

 //write width of tree view
 Ini.WriteInteger(Name, 'TreeViewWidth', FTreeViewWidth);
 //write position of zoom window
 Ini.WriteInteger(Name, 'ZoomWindowLeft', FZoomWindowLeft);
 Ini.WriteInteger(Name, 'ZoomWindowTop', FZoomWindowTop);
 Ini.WriteInteger(Name, 'ZoomWindowWidth', FZoomWindowWidth);
 Ini.WriteInteger(Name, 'ZoomWindowHeight', FZoomWindowHeight);
end;


{Gets the settings from the form.
~param Form the form to read the values from }
procedure TDiagramFormSettings.ReadValues(Form: TFormDiagram);

 {Reads the properties of the tool bar from itself.
 ~param ToolBar  the tool bar to read the properties from
 ~param WhichOne which tool bar's properties should be read }
 procedure ReadToolBar(ToolBar: TToolBar; WhichOne: TDiagramToolBar);
 var       PosControl :TWinControl;       //the control to read the position of
 begin
  //read whether the tool bar is undocked
  FToolBars[WhichOne].Undocked :=
{$IFNDEF LINUX}
                                  ToolBar.Floating;
{$ELSE}
                                  False;
{$ENDIF}


  if FToolBars[WhichOne].Undocked then    //if it is undocked
   PosControl := ToolBar.Parent             //use its tool window
  else
   PosControl := ToolBar;                   //or read its own position

  //read position of the tool bar
  FToolBars[WhichOne].Position.x := PosControl.Left;
  FToolBars[WhichOne].Position.y := PosControl.Top;
 end;

begin
 GetValuesFromForm(Form);               //get general values of the form

 //get visibility of components
 FShowToolBars := Form.ControlBar.Visible;
 FShowStatusBar := Form.StatusBar.Visible;
 FShowZoomWindow := Form.ZoomWindow.Visible;

 //get what kind of links should be generated in exported SVG image files
 FSVGImageLinkKind := Form.SVGImageLinkKind;

 ReadToolBar(Form.ToolBarGeneral, dtbGeneral); //read the data of all tool bars
 ReadToolBar(Form.ToolBarClasses, dtbClasses);
 ReadToolBar(Form.ToolBarFiles, dtbFiles);

 //get width of tree view
 FTreeViewWidth := Form.TreeView.Width;
 //get position of zoom window
 FZoomWindowLeft := Form.ZoomWindow.Left;
 FZoomWindowTop := Form.ZoomWindow.Top;
 FZoomWindowWidth := Form.ZoomWindow.Width;
 FZoomWindowHeight := Form.ZoomWindow.Height;
end;

{Assigns the read properties of the tool bar to it.
~param ToolBar  the tool bar to assign the read properties to
~param WhichOne which tool bar's properties should be assigned
~param PreShow  whether the window has already been shown }
procedure TDiagramFormSettings.GetToolBar(ToolBar: TToolbar;
                                          WhichOne: TDiagramToolBar;
                                          PreShow: Boolean);
begin
 if FToolBars[WhichOne].Undocked then      //is undocked?
  begin
   //window alread shown? (if not, showing it modal will disable the
   if not PreShow then                       //tool window)
{$IFNDEF LINUX}
    ToolBar.ManualFloat(Rect(FToolBars[WhichOne].Position.x,  //undock it at
                             FToolBars[WhichOne].Position.y,  //the position
     //the size is is way too big, but the tool window has auto-size
     //and using the "correct" will create scroll bars
                             FToolBars[WhichOne].Position.x +
                             ToolBar.UndockWidth * 2,
                             FToolBars[WhichOne].Position.y +
                             ToolBar.UndockHeight * 2));
{$ENDIF}
  end
 else
  if PreShow then                          //these can be set before showing
   begin
    //set position of the tool bar
    ToolBar.Left := FToolBars[WhichOne].Position.x;
    ToolBar.Top := FToolBars[WhichOne].Position.y;
   end;
end;

















       //enumeration type for the indices of the images for the outline/tree,
       //just a list of constants
type   TImageIndex = (
                      iiClass,        //a single class
                      iiClasses,      //a tree of classes
                      iiFile,         //a single file
                      iiFiles);       //all files


const

       //data of the nodes in the tree view hold the content of the nodes;
       //the root-nodes have no content, so the kind of the root is saved in
       //it; if this bit is set, than it is the root of a list or tree of
       //record-like types, if not then it is the list of all files
       RootIdentIsClass = $200;
       //a bit in the data of a root node in the tree view;
       //if ~[link RootIdentIsClass] is set, this bit defines if it is the root
       //of the tree of record-like types as inheritance trees instead of a
       //simple list; not all kinds of record-like types can have inheritance
       //trees
       RootIdentIsClassByInheritance = $100;


       //format of internal names/ids of diagrams in a set of diagrams, that
       //could be saved and loaded together; the diagrams are saved in ini file
       //format, each diagram has its own section, the names of the sections
       //are constituted with this format string and a random number
       SectionNameFormat = 'Diagram_%d';









{Creates the form to show an Xfig file.
~param Files the parsed data to show diagrams from }
constructor TFormDiagram.Create(Files: TFileList);
var         Settings    :TDiagramFormSettings; //to read ini settings
begin
 inherited Create(nil);                        //create the window

 FFiles := Files;                              //save the data

{$IFDEF LINUX}
 //first popup will be sloooow otherwise
 PopUpMenu.AutoHotkeys := maManual;
// MainMenu.AutoHotkeys := maManual;             //don't know if this helps
{$ENDIF}


 FDrawControl := TDrawControl.Create(Self);    //create control to show diagram
 FDrawControl.Parent := Panel;                 //put it on the panel
// FDrawControl.Align := alClient;             //fill panel with it
 FDrawControl.OnPaint := DiagramNeedsRepaint;  //assign event-methods
 FDrawControl.OnResize := DoResize;
 FDrawControl.OnMouseDown := ImageMouseDown;
 FDrawControl.OnMouseMove := ImageMouseMove;
 FDrawControl.OnMouseUp := ImageMouseUp;

 //scroll also with the mouse wheel
 TAccessTreeView(TreeView).OnMouseWheelUp := TreeViewMouseWheelUp;
 TAccessTreeView(TreeView).OnMouseWheelDown := TreeViewMouseWheelDown;



 FDrawControl.PopupMenu := PopupMenu;          //set pop-up menu

 FDrawControl.HelpContext := Panel.HelpContext;




 FZoomWindow := TForm.Create(Self);            //create zoom window
 //don't fill background (client area) of the window (avoid flickering)
 FZoomWindow.ControlStyle := FZoomWindow.ControlStyle + [csOpaque];
{$IFNDEF LINUX}
 FZoomWindow.DoubleBuffered := False;          //enabled by default in Delphi 4
{$ENDIF}

 FZoomWindow.Caption := 'Zoom';
{$IFNDEF LINUX}                            //really small borders and tile only
 FZoomWindow.BorderStyle := bsSizeToolWin;
{$ELSE}
 FZoomWindow.BorderStyle := fbsSizeToolWin;
{$ENDIF}
// FZoomWindow.FormStyle := fsStayOnTop;
 FZoomWindow.ClientWidth := 100;               //small default size
 FZoomWindow.ClientHeight := 100;
 FZoomWindow.Left := Left + Width - FZoomWindow.Width; //move to lower left
 FZoomWindow.Top := Top + Height - FZoomWindow.Height; //corner of this window
 FZoomWindow.Canvas.Brush.Color := FZoomWindow.Color;

 FZoomWindow.HelpContext := 24500;

 FZoomWindow.Hide;                             //hide zoom window

 FZoomWindow.Hint := 'Zoomed view of the diagram, click to change position.';

 FZoomWindow.OnHide := ZoomWindowHide;         //assign event methods
 FZoomWindow.OnResize := ZoomWindowResize;
 FZoomWindow.OnPaint := ZoomWindowPaint;
 FZoomWindow.OnMouseDown := ZoomMouseDown;
 FZoomWindow.OnMouseMove := ZoomMouseMove;




 FDiagram := TDiagram.Create;                  //create an object for a diagram
 FDiagram.OnNeedRepaint := DiagramNeedsRepaint; //assign event methods
 FDiagram.OnSizeChanged := DoResize;
 FDiagram.ApplyOptions;                   //initialize with its default options


 //fill tree view with all parsed files and record-like types
 FillTreeView;


{$IFNDEF LINUX}
 UpDownFontSize.OnClick := UpDownFontSizeClick;
{$ENDIF}
 ComboBoxFont.Items := Screen.Fonts;           //add all fonts to the combo box
 ComboBoxFont.Text := FDiagram.Font.Name;      //show current font in it
 ComboBoxFontSize.Text := IntToStr(FDiagram.Font.Size); //and its current size
{$IFNDEF LINUX}
 UpDownFontSize.Position := FDiagram.Font.Size;
{$ENDIF}
 ComboBoxFontChange(nil);                     //get available sizes of the font

 //save current position of the lower left corner (for zoom window)
 FOldBottomRight := Point(Left + Width, Top + Height);

 FDiagramSet := TMemIniFile.Create('');       //create list for all diagrams
 FCurrentDiagramIndex := -1;                  //current diagram not saved

 FActionFiles := TList.Create;                //create list for action


 //get object to load the settings from
 Settings := TDiagramFormSettings(TDiagramFormSettings.GetSettings(ClassName));
 if not Assigned(Settings) then        //no object initialized?
  begin                                  //create a new object
   Settings := TDiagramFormSettings.Create(ClassName);
   Settings.ReadValues(Self);            //initialize with the default values
   Settings.Initialize;                  //and read from the ini file
  end;
 Settings.SetValuesToForm(Self);       //initialize form with read values
 Settings.GetToolBar(ToolBarGeneral, dtbGeneral, True);
 Settings.GetToolBar(ToolBarClasses, dtbClasses, True);
 Settings.GetToolBar(ToolBarFiles, dtbFiles, True);
 StatusBar.Visible := Settings.ShowStatusBar;
 ZoomWindow.Visible := Settings.ShowZoomWindow;
 //get what kind of links should be generated in exported SVG image files
 FSVGImageLinkKind := Settings.SVGImageLinkKind;
 TreeView.Width := Settings.TreeViewWidth;
 ZoomWindow.Left := Settings.ZoomWindowLeft;
 ZoomWindow.Top := Settings.ZoomWindowTop;

⌨️ 快捷键说明

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