delphi SimpleGraph控件的部分注释

TSimpleGraph是一个delphi下的可视化图形开源控件,有很强编辑态和运行态编辑功能,是学习开发DELPHI控件的一个很好的例子,控件本身有很强的扩展性,完全可以自定义绘制各种图形.

控件的地址为http://www.delphiarea.com/products/delphi-components/simplegraph/

完全读懂这个控件,还是要读源码,吃透

以下为零几年时首次解读控件的注释,当时还是一个DELPHI新手,所以注释的语意难免不是很准确,后面理解了也懒得改了,见凉.现在公开给需要的朋友

  TSimpleGraph = class;      //控件类
  TGraphObject = class;      //图形基类
  TGraphLink = class;        //链接类
  TGraphNode = class;        //结点类

TSimpleGraph 
事件
    property OnObjectInitInstance  //对象初始化事件
    property OnObjectInsert: //对象插入事件
    property OnObjectRemove:           //对象移除事件
    property OnObjectChange:         //对象改变事件
    property OnObjectSelect:  //对象选择事件
    property OnObjectClick:  //对象点击事件
    property OnObjectDblClick://对象双击事件
    property OnObjectContextPopup:  //右键菜单事件
    property OnObjectBeforeDraw:   //对像绘制之前事件
    property OnObjectAfterDraw: //对像绘制之后事件
    property OnObjectBeginDrag:   //对象拖拉之事件
    property OnObjectEndDrag: //对象拖拉之后事件
    property OnObjectMouseEnter://鼠标在进入对象之前事件
    property OnObjectMouseLeave:  //鼠标在进入对象之后事件
    property OnObjectRead:   //读自定义数据事件
    property OnObjectWrite:  //写自定义数据事件
    property OnObjectHook:  //对象吸附之后事件
    property OnObjectUnhook: //对象断开吸附事件
    property OnCanHookLink: //吸附事件
    property OnCanLinkObjects:   //连接事件
    property OnCanMoveResizeNode: //移动结点件事
    property OnCanRemoveObject:   //移除对象事件
    property OnNodeMoveResize:  //结点重设大小事件
    property OnGraphChange:  //图形改变事件
    property OnCommandModeChange: //命令模式改变事件
    property OnBeforeDraw:  //绘制之前事件
    property OnAfterDraw:  //绘制之后事件
    property OnInfoTip:   //提示事件
    property OnZoomChange:  //缩放事件

TGraphObject
  TGraphObject = class(TPersistent)
  private
    fID: DWORD;                                  //对象ID
    fOwner: TSimpleGraph;                        //所有者
    fBrush: TBrush;                              //画刷
    fPen: TPen;                                  //画笔
    fText: String;                               //文本标题
    fHint: String;                               //提示文本
    fFont: TFont;                                //字体
    fParentFont: Boolean;                        //是否使用父控件字体
    fOptions: TGraphObjectOptions;               //可以操作的集合  --goLinkable, goSelectable, goShowCaption
    fVisible: Boolean;                           //是否可以显示
    fSelected: Boolean;                          //是否可以选择
    fStates: TGraphObjectStates;                 //控件的状态    osCreating, osDestroying, osLoading, osReading, osWriting,osUpdating, osDragging, osDragDisabled, osConverting
    fDependentList: TGraphObjectList;            //相关对象
    fLinkInputList: TGraphObjectList;            //连入对象
    fLinkOutputList: TGraphObjectList;           //连出对象
    fTextToShow: String;                         //显示的文本
    fTag: Integer;                               //标识号
    fData: Pointer;                              //暂时没有用上
    fHasCustomData: Boolean;                     //是否有自定义数据
    fVisualRect: TRect;                          //图形占有实际的矩形区大小
    fVisualRectFlags: TGraphChangeFlags;         //图形可占有区的显示标记,即可以显示那些
    UpdateCount: Integer;                        //更新数
    PendingChanges: TGraphChangeFlags;           //挂起的改变
    DragDisableCount: Integer;                   //禁止拖拉数 --没搞明白
    function IsFontStored: Boolean;                          //是否存储字体
    procedure StyleChanged(Sender: TObject);                 //改变样式
  protected
    constructor CreateFromStream //从流中创建对象
    function GetOwner: TPersistent;                         //取所有者
    procedure DefineProperties(Filer: TFiler); 
    procedure Initialize; virtual;                                                  //初始化
    procedure Loaded; virtual;                                                    //载入,
    procedure ReplaceID                        //替换ID
    procedure ReplaceObject        //替换对象
    {------------------------------难点,控件之间更新------------------------------------------------ }
    procedure NotifyDependents      //观察者模式:通知-该对象的每一个依赖通知改变更新
    procedure LookupDependencies;                                   //查找相关
    procedure UpdateDependencies;                                 //更新相关
    procedure UpdateDependencyTo//更新相关  ->>UpdateDependencies  子类实现
    function UpdateTextPlacement       //更新文本位置
    procedure Changed //对象改变方法
    procedure BoundsChanged(dX, dY, dCX, dCY: Integer); virtual;
    procedure DependentChanged        //空-子类实现
    procedure LinkInputChanged      //加入或减少DependentList列表
    procedure LinkOutputChanged   //加入或减少DependentList列表
    {------------------------------------------------------------------------------ }
    procedure ParentFontChanged; virtual;    //父控件写体更新
    function IsUpdateLocked: Boolean; virtual;
    function NeighborhoodRadius: Integer; virtual;  //半径大小
    function FixHookAnchor: TPoint; virtual; abstract;   //固定关联
    function RelativeHookAnchor//修改点加入索引
    procedure DrawControlPoint //一个控制点
    procedure DrawControlPoints //画控制点
    procedure DrawHighlight     //画高亮
    procedure DrawText//画文本
    procedure DrawBody //画身体
    procedure Draw//画函数
    procedure DrawState     //画状态
    function IsVisibleOn   //查询大小
    procedure QueryVisualRect
    function QueryHitTest//查询点击位
    function QueryCursor
    function QueryMobility//根据点击点返回要移动的移动边
    function OffsetHitTest//根据点击点和偏移参数重设大小并返回是否成功
    procedure SnapHitTestOffse //偏移到网格上
    function BeginFollowDrag(HT: DWORD):    //开始拖拉
    function EndFollowDrag:             //结束拖拉
    procedure DisableDrag;                          //禁用拖拉
    procedure EnableDrag;                       //启用拖拉
    procedure MoveBy;     //移到
    procedure MouseDown  // 鼠标按下
    procedure MouseMove                    //鼠标移动
    procedure MouseUp   //鼠标弹起
    function KeyPress               //按键处理
    procedure SetBoundsRect                         //设置边框大小
    function GetBoundsRect: TRect;                                         //获取边框大小
    function GetSelectedVisualRect:                     //获取选择区大小
  protected
    property TextToShow:      //要显示的文本
    property DependentList:                          //相关的对象列表
    property LinkInputList:                          //连入的对象列表
    property LinkOutputList:  //连出的对象列表
    property VisualRectFlags:  //图形可占有区的显示标记,即可以显示那些
  public
    constructor Create//创建对象
    destructor Destroy; //销毁对象
    procedure AfterConstruction;  //创建对象之后
    procedure BeforeDestruction;    //销毁之前
    procedure Assign  //从另一对象复制
    procedure AssignTo //复制到另一对象
    procedure LoadFromStream  //从流中载入对象
    procedure SaveToStream  //保存到流中
    procedure BeginUpdate;                       //开始更新
    procedure EndUpdate;                       //结束更新
    procedure Invalidate;                         //刷新
    procedure BringToFront;                          //至前
    procedure SendToBack;                        //至后
    class function IsLink: Boolean;                 //是否为线路
    class function IsNode: Boolean;              //是否为结点
    function IsLocked: Boolean;                     //是否锁定
    function Delete: Boolean;                   //删除
    function CanDelete: Boolean;                  //是否可以删除
    function HitTest                         //测试-鼠标点击的位置
    function ContainsPoint         //对象中是否包含了XY坐标是否有对象
    function ContainsRect             //Rectc是否与对象重叠
    function BeginDrag  //开始画
    function DragTo; // DragTo—DragBy
    function DragBy //拖拉到
    function EndDrag                 //是否结束拖拉
    property States: //对象的状态
    property Dragging: //是否在拖拉中
    property Showing: //是否在显示中
    property Owner: //所有都
    property ZOrder: //层  Z
    property Selected:  //是否选中
    property BoundsRect: //对象的边大小
    property VisualRect:  //图形占有实际的矩形区大小
    property SelectedVisualRect: //选择区域
    property Dependents[Index: Integer]: //依赖对象
    property DependentCount://依赖数
    property LinkInputs[Index: Integer]: //连接输入对象
    property LinkInputCount:  //连接对象输入数
    property LinkOutputs[Index: Integer]: //连接输出对象
    property LinkOutputCount: //连接对象输出数
    property Data: //暂时没有用上
    property ID:  //对象ID号
  published
    property Text://文本内容
    property Hint: //提示文本
    property Brush://画刷
    property Pen: //画笔
    property Font: //字体
    property ParentFont: //j是否使用父控件字体
    property Options: //图形对象的操作 默认是可链接,可选择,可显示标题
    property Visible: //是否可以显示
    property Tag: //标识号
    property HasCustomData: //是否可有自定义数据
  end;

TGraphLink
    procedure Assign //复制对象
    function ContainsRect //Rectc是否与对象重叠
    function CanMove//是否能移动
    function AddPoint//添加点
    procedure InsertPoint//加入点索引对应的点
    procedure RemovePoint//移除索引对应的点
    function AddBreakPoint //加入折点,还是调用InsertPoint
    function HookedObjectOf //吸附索引对应的对象
    function HookedIndexOf //吸附索引
    function HookedPointCount: //连接点 0,1,2
    function CanHook//是或能吸附连接
    function Hook//吸附
    function Unhook   //断开
    function CanLink// 是否能连接
    function Link//吸附
    function Rotate//旋转
    function Scale //缩放
    procedure Reverse; //反转
    class function IsLink: //是否是链接
    property Source: //源对象
    property Target: //目标对象
    property Points[Index: Integer]: //线的点数组中的一项
    property PointCount: //点数量
    property Polyline:  //线的点数组
  published
    property BeginStyle: //起始点样式
    property BeginSize: //起始点大小,修改点,修改默认参数
    property EndStyle: //结束点样式,修改点,修改默认参数
    property EndSize: //结束点大小,修改点,修改默认参数
    property LinkOptions: 
    property TextPosition:  //文本的位置
    property TextSpacing: //与线的空白距离

公共函数:

function WrapText//文本分行
function MinimizeText//最小文本
function IsBetween//值大小是否是两者之间
function TransformRgn //区域变换  //TXForm; {坐标转换的矩阵结构} 可参考http://www.cnblogs.com/del/articles/1212534.html
function NormalizeAngle //度格式化在—-2pi与2pi之间
function EqualPoint  //两个点坐标是否相等
procedure TransformPoints//转换两个图形区域
procedure RotatePoints//把坐标Points以OrgPt,旋转Angle    Org起始地址
procedure ScalePoints//按Factor比例,以RefPt中心,重计算缩放Points的坐标
procedure ShiftPoints//以 RefPt为中心,按参数 dX, dY,远离它
procedure OffsetPoints//以dx,dy偏移Points
function CenterOfPoints//计算出中心点
function BoundsRectOfPoints//由多点形成的矩形
function NearestPoint//返回多点Points坐标集合中距离RefPt最近的点

function MakeSquare//将一个点通过缩扩Radius倍形成一个矩形
function MakeRect //由两个坐标建立一个矩形
function CenterOfRect//返回矩形中的中心点坐标
procedure UnionRect//由两个矩形合成大矩形返回给DstRect
procedure IntersectRect//返回相交的矩形
function OverlappedRect //两个矩表是否重叠,

function LineLength //两点之间的距离
function LineSlopeAngle//计算线的角度-以弧度表示
function DistanceToLine//点和线的距离
function NearestPointOnLine//计算LinePt1, LinePt2之间线上离RefPt最近的点 采用二分法,无限逼近最近点
function NextPointOfLine//计算距离RefPt点坐标以LineAngle为角度(弧度表示)距离为DistanceFromThisPt的点坐标{从点Line1Pt以Line1Angle角度与点Line2Pt以Line2Angle角度,算出相交的点}
function IntersectLines
function IntersectLineRect//返回线与矩形的交叉点
function IntersectLineEllipse// 返回线与圆的交叉点
function IntersectLineRoundRect //返回线与圆角矩形的交叉点
function IntersectLinePolygon //返回多边形上的交插点集合
function IntersectLinePolyline// 返回线与多边线的交叉点

 

 

simplegraph QQ群号 17267174

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值