├── .gitignore ├── Docs ├── Globals.md ├── README.md ├── TCanvasRecall.md ├── TGraphConstraints.md ├── TGraphLink.md ├── TGraphNode.md ├── TGraphObject.HitTesting.md ├── TGraphObject.md ├── TGraphObjectList.md ├── TGraphScrollBar.md ├── TMemoryHandleStream.md ├── TPolygonalNode.md ├── TSimpleGraph.Events.md ├── TSimpleGraph.Keyboard.md ├── TSimpleGraph.Methods.md ├── TSimpleGraph.Mouse.md ├── TSimpleGraph.Properties.md └── TSimpleGraph.md ├── Examples ├── Editor │ ├── AboutDelphiArea.dfm │ ├── AboutDelphiArea.pas │ ├── AlignDlg.dfm │ ├── AlignDlg.pas │ ├── DesignProp.dfm │ ├── DesignProp.pas │ ├── Keyboard.rtf │ ├── LinkProp.dfm │ ├── LinkProp.pas │ ├── Main.dfm │ ├── Main.pas │ ├── MarginsProp.dfm │ ├── MarginsProp.pas │ ├── Mouse.rtf │ ├── NodeProp.dfm │ ├── NodeProp.pas │ ├── ObjectProp.dfm │ ├── ObjectProp.pas │ ├── SGDemo.dpr │ ├── SGDemo.dproj │ ├── SGDemo.res │ ├── Samples │ │ ├── Sample1.sgp │ │ ├── Sample2.sgp │ │ └── Sample3.sgp │ ├── SizeDlg.dfm │ ├── SizeDlg.pas │ ├── UsageHelp.dfm │ └── UsageHelp.pas └── ElasticNodes │ ├── ElasticNodes.dpr │ ├── ElasticNodes.dproj │ ├── ElasticNodes.res │ ├── Main.dfm │ └── Main.pas ├── HISTORY.md ├── Images ├── sg1.gif └── sg2.gif ├── LICENSE ├── README.md └── Source ├── DELPHIAREA.INC ├── SimpleGraph.dcr ├── SimpleGraph.pas └── SimpleGraph.res /.gitignore: -------------------------------------------------------------------------------- 1 | # Delphi compiler-generated binaries 2 | *.exe 3 | *.dll 4 | *.bpl 5 | *.bpi 6 | *.dcp 7 | *.so 8 | *.apk 9 | *.drc 10 | *.map 11 | *.dres 12 | *.rsm 13 | *.tds 14 | *.dcu 15 | *.lib 16 | *.a 17 | *.o 18 | *.ocx 19 | 20 | # Delphi autogenerated files 21 | *.cfg 22 | *.hpp 23 | *Resource.rc 24 | 25 | # Delphi local files 26 | *.local 27 | *.identcache 28 | *.projdata 29 | *.tvsconfig 30 | *.dsk 31 | 32 | # Delphi history and backups 33 | __history/ 34 | __recovery/ 35 | *.~* 36 | 37 | # Castalia statistics file 38 | *.stat 39 | -------------------------------------------------------------------------------- /Docs/Globals.md: -------------------------------------------------------------------------------- 1 | Global Procedures 2 | ================= 3 | 4 | ```pascal 5 | WrapText(Canvas: TCanvas; const Text: String; MaxWidth: Integer): String; 6 | ``` 7 | Breaks a text between words if the lines of the text exceed a given width. 8 | 9 | | Parameter | Description | 10 | |-----------|-------------------------------------------------------------------| 11 | | Canvas | The canvas that provides the font metrics for the measurements | 12 | | Text | The text to be wrapped | 13 | | MaxWidth | The maximum width of the text lines | 14 | 15 | Returns the wrapped text. 16 | 17 | 18 | ```pascal 19 | function MinimizeText(Canvas: TCanvas; const Text: String; const Rect: TRect): String; 20 | ``` 21 | Breaks a text between words and chopping it off if its dimensions exceed a given bounds. 22 | 23 | | Parameter | Description | 24 | |-----------|-------------------------------------------------------------------| 25 | | Canvas | The canvas that provides the font metrics for the measurements | 26 | | Text | The text to be minimized | 27 | | Rect | The bounding rectangle of the text on the canvas | 28 | 29 | Returns the minimized text. 30 | 31 | 32 | ```pascal 33 | function IsBetween(Value: Integer; Bound1, Bound2: Integer): Boolean; 34 | ``` 35 | Determines whether a value is in a given range. 36 | 37 | | Parameter | Description | 38 | |-----------|-------------------------------------------------------------------| 39 | | Value | The value to be examined | 40 | | Bound1 | The lower or upper bound of the range | 41 | | Rect | The upper or lower bound of the range | 42 | 43 | Returns `true` if the value is in the range; otherwise, returns `false`. 44 | 45 | 46 | ```pascal 47 | function EqualPoint(const Pt1, Pt2: TPoint): Boolean; 48 | ``` 49 | Determines whether two points are equal. 50 | 51 | | Parameter | Description | 52 | |-----------|-------------------------------------------------------------------| 53 | | Pt1 | The first point | 54 | | Pt2 | The second point | 55 | 56 | Returns `true` if points are equal; otherwise, returns `false`. 57 | 58 | 59 | ```pascal 60 | function NormalizeAngle(const Angle: Double): Double; 61 | ``` 62 | Converts an angle value, so that it falls between `-Pi` and `Pi`. 63 | 64 | | Parameter | Description | 65 | |-----------|-------------------------------------------------------------------| 66 | | Angle | The angle to be normalized in radians | 67 | 68 | Returns the normalized angle in radians. 69 | 70 | 71 | ```pascal 72 | function TransformRgn(Rgn: HRGN; const XForm: TXForm): HRGN; 73 | ``` 74 | Transforms a region using a given transformation matrix. 75 | 76 | | Parameter | Description | 77 | |-----------|-------------------------------------------------------------------| 78 | | Rgn | The windows handle of region to be transformed | 79 | | XForm | The transformation matrix | 80 | 81 | Returns the windows handle of the new transformed region. 82 | 83 | 84 | ```pascal 85 | procedure TransformPoints(var Points: array of TPoint; const XForm: TXForm); 86 | ``` 87 | Transforms a set of coordinates using a given transformation matrix. 88 | 89 | | Parameter | Description | 90 | |-----------|-------------------------------------------------------------------| 91 | | Points | The coordinates to be transformed | 92 | | XForm | The transformation matrix | 93 | 94 | 95 | ```pascal 96 | procedure RotatePoints(var Points: array of TPoint; const Angle: Double; const OrgPt: TPoint); 97 | ``` 98 | Rotates a set of coordinates around a given point. 99 | 100 | | Parameter | Description | 101 | |-----------|-------------------------------------------------------------------| 102 | | Points | The coordinates to be transformed | 103 | | Angle | The angle of rotation in radians | 104 | | OrgPt | The point where the coordinates should be rotated around | 105 | 106 | 107 | ```pascal 108 | procedure ScalePoints(var Points: array of TPoint; const Factor: Double; const RefPt: TPoint); 109 | ``` 110 | Moves a set of coordinates toward or away from a given point by a scaling factor. 111 | 112 | | Parameter | Description | 113 | |-----------|-------------------------------------------------------------------| 114 | | Points | The coordinates to be transformed | 115 | | Factor | The scaling factor | 116 | | RefPt | The point where the coordinates should be moved related to | 117 | 118 | 119 | ```pascal 120 | procedure ShiftPoints(var Points: array of TPoint; dX, dY: Integer; const RefPt: TPoint); 121 | ``` 122 | Moves a set of coordinates toward or away from a given point by the specified amount of horizontal and vertical displacement. 123 | 124 | | Parameter | Description | 125 | |-----------|-------------------------------------------------------------------| 126 | | Points | The coordinates to be transformed | 127 | | dX | The amount of horizontal displacement | 128 | | dY | The amount of vertical displacement | 129 | | RefPt | The point where the coordinates should be moved related to | 130 | 131 | 132 | ```pascal 133 | procedure OffsetPoints(var Points: array of TPoint; dX, dY: Integer); 134 | ``` 135 | Moves a set of coordinates by the specified amount of horizontal and vertical displacement. 136 | 137 | | Parameter | Description | 138 | |-----------|-------------------------------------------------------------------| 139 | | Points | The coordinates to be transformed | 140 | | dX | The amount of horizontal displacement | 141 | | dY | The amount of vertical displacement | 142 | 143 | 144 | ```pascal 145 | function CenterOfPoints(var Points: array of TPoint): TPoint; 146 | ``` 147 | Determines the point at the center of a set of coordinates. 148 | 149 | | Parameter | Description | 150 | |-----------|-------------------------------------------------------------------| 151 | | Points | The source coordinates | 152 | 153 | Returns the center of mass. 154 | 155 | 156 | ```pascal 157 | function BoundsRectOfPoints(var Points: array of TPoint): TRect; 158 | ``` 159 | Determines the minimum bounding box of a set of coordinates. 160 | 161 | | Parameter | Description | 162 | |-----------|-------------------------------------------------------------------| 163 | | Points | The source coordinates | 164 | 165 | Returns the minimum bounding rectangle. 166 | 167 | 168 | ```pascal 169 | function NearestPoint(const Points: array of TPoint; const RefPt: TPoint; out NearestPt: TPoint): Integer; 170 | ``` 171 | Determines the nearest point in a set of coordinates to a given point. 172 | 173 | | Parameter | Description | 174 | |-----------|-------------------------------------------------------------------| 175 | | Points | The source coordinates | 176 | | RefPt | The target coordinate | 177 | | NearestPt | When the function returns, contains the nearest coordinate | 178 | 179 | Returns the zero-based index of the nearest coordinate. 180 | 181 | 182 | ```pascal 183 | function MakeSquare(const Center: TPoint; Radius: Integer): TRect; 184 | ``` 185 | Creates a square specified by its center and radius. 186 | 187 | | Parameter | Description | 188 | |-----------|-------------------------------------------------------------------| 189 | | Center | The coordinate of the square's center | 190 | | Radius | The radius of the square (half of the sides' length) | 191 | 192 | Returns a `TRect` value. 193 | 194 | 195 | ```pascal 196 | function MakeRect(const Corner1, Corner2: TPoint): TRect; 197 | ``` 198 | Creates a rectangle specified by its two opposite corners. 199 | 200 | | Parameter | Description | 201 | |-----------|-------------------------------------------------------------------| 202 | | Corner1 | The coordinate of one of the rectangle's corners | 203 | | Corner2 | The coordinate of the opposite corner | 204 | 205 | Returns a `TRect` value. 206 | 207 | 208 | ```pascal 209 | function CenterOfRect(const Rect: TRect): TPoint; 210 | ``` 211 | Determines the point at the center of a rectangle. 212 | 213 | | Parameter | Description | 214 | |-----------|-------------------------------------------------------------------| 215 | | Rect | The rectangle that its center should be calculated | 216 | 217 | Returns the center of mass. 218 | 219 | 220 | ```pascal 221 | procedure UnionRect(var DstRect: TRect; const SrcRect: TRect); 222 | ``` 223 | Enlarges a rectangle, so that it also covers the area of another rectangle. None of the rectangles should be empty. 224 | 225 | | Parameter | Description | 226 | |-----------|-------------------------------------------------------------------| 227 | | DstRect | The rectangle that gets updated | 228 | | SrcRect | The other rectangle | 229 | 230 | 231 | ```pascal 232 | procedure IntersectRect(var DstRect: TRect; const SrcRect: TRect); 233 | ``` 234 | Shrinks a rectangle, so that it covers only the shared area with another rectangle. None of the rectangles should be empty. 235 | 236 | | Parameter | Description | 237 | |-----------|-------------------------------------------------------------------| 238 | | DstRect | The rectangle that gets updated | 239 | | SrcRect | The other rectangle | 240 | 241 | 242 | ```pascal 243 | function OverlappedRect(const Rect1, Rect2: TRect); 244 | ``` 245 | Determines if two rectangles have intersections. 246 | 247 | | Parameter | Description | 248 | |-----------|-------------------------------------------------------------------| 249 | | Rect1 | The first rectangle | 250 | | Rect2 | The second rectangle | 251 | 252 | Returns `true` if two rectangles are intersecting; otherwise, returns `false`. 253 | 254 | 255 | ```pascal 256 | function LineLength(const LinePt1, LinePt2: TPoint): Double; 257 | ``` 258 | Determines the length of a line segment. 259 | 260 | | Parameter | Description | 261 | |-----------|-------------------------------------------------------------------| 262 | | LinePt1 | The first endpoint of the line segment | 263 | | LinePt2 | The second endpoint of the line segment | 264 | 265 | Returns the length of the line segment. 266 | 267 | 268 | ```pascal 269 | function LineSlopeAngle(const LinePt1, LinePt2: TPoint): Double; 270 | ``` 271 | Determines the slope angle of a line. 272 | 273 | |-----------|-------------------------------------------------------------------| 274 | | Parameter | Description | 275 | |-----------|-------------------------------------------------------------------| 276 | | LinePt1 | The first point on the line segment | 277 | | LinePt2 | The second point on the line segment | 278 | 279 | Returns the slope angle of the line in radians 280 | 281 | 282 | ```pascal 283 | function DistanceToLine(const LinePt1, LinePt2: TPoint; const QueryPt: TPoint): Double; 284 | ``` 285 | Determines the shortest distance between a line segment and a point. 286 | 287 | | Parameter | Description | 288 | |-----------|-------------------------------------------------------------------| 289 | | LinePt1 | The first endpoint of the line segment | 290 | | LinePt2 | The second endpoint of the line segment | 291 | | QueryPt | The point to calculate its distance from the line distance | 292 | 293 | Returns the shortest distance between the line segment and the point. 294 | 295 | 296 | ```pascal 297 | function NearestPointOnLine(const LinePt1, LinePt2: TPoint; const RefPt: TPoint): TPoint; 298 | ``` 299 | Finds the coordinate of a point on a line segment, which is the closest point to a given point. 300 | 301 | | Parameter | Description | 302 | |-----------|-------------------------------------------------------------------| 303 | | LinePt1 | The first endpoint of the line segment | 304 | | LinePt2 | The second endpoint of the line segment | 305 | | QueryPt | The point to calculate its distance from the line segment | 306 | 307 | Returns the coordinate of the nearest point on the line segment. 308 | 309 | 310 | ```pascal 311 | function NextPointOfLine(const LineAngle: Double; const LinePt: TPoint; const LineLength: Double): TPoint; 312 | ``` 313 | Determines the next endpoint of a line segment. 314 | 315 | | Parameter | Description | 316 | |------------|-------------------------------------------------------------------| 317 | | LineAngle | The slope angle of the line segment in radians | 318 | | LinePt | The coordinate of the known endpoint of the line segment | 319 | | LineLength | The length of the line segment | 320 | 321 | Returns the next endpoint of the line segment. 322 | 323 | 324 | ```pascal 325 | function IntersectLines(const Line1Pt: TPoint; const Line1Angle: Double; const Line2Pt: TPoint; const Line2Angle: Double; out Intersect: TPoint): Boolean; 326 | ``` 327 | Determines the intersection coordinate of two lines if any. 328 | 329 | | Parameter | Description | 330 | |------------|-------------------------------------------------------------------| 331 | | Line1Pt | A point on the first line | 332 | | Line1Angle | The slope angle of the first line (between `-Pi` and `Pi`) | 333 | | Line1Pt | A point on the second line | 334 | | Line1Angle | The slope angle of the second line (between `-Pi` and `Pi`) | 335 | | Intersect | When the function returns, contains the intersection coordinate | 336 | 337 | Returns `true` if the lines intersect; otherwise, returns `false`. 338 | 339 | 340 | ```pascal 341 | function IntersectLineRect(const LinePt: TPoint; const LineAngle: Double; const Rect: TRect): TPoints; 342 | ``` 343 | Determines the coordinates, where a line intersects with a rectangle. 344 | 345 | | Parameter | Description | 346 | |-----------|--------------------------------------------------------------------| 347 | | LinePt | A point on the line | 348 | | LineAngle | The slope angle of the line (between `-Pi` and `Pi`) | 349 | | Rect | The rectangle | 350 | 351 | Returns the intersection points as a dynamic array. 352 | 353 | 354 | ```pascal 355 | function IntersectLineRoundRect(const LinePt: TPoint; const LineAngle: Double; const Bounds: TRect; CW, CH: Integer): TPoints; 356 | ``` 357 | Determines the coordinates, where a line intersects with a rounded rectangle. 358 | 359 | | Parameter | Description | 360 | |-----------|--------------------------------------------------------------------| 361 | | LinePt | A point on the line | 362 | | LineAngle | The slope angle of the line (between `-Pi` and `Pi`) | 363 | | Bounds | The bounding box of the rounded rectangle | 364 | | CW | The horizontal curvature of the rounded rectangle | 365 | | CH | The vertical curvature of the rounded rectangle | 366 | 367 | Returns the intersection points as a dynamic array. 368 | 369 | 370 | ```pascal 371 | function IntersectLineEllipse(const LinePt: TPoint; const LineAngle: Double; const Bounds: TRect): TPoints; 372 | ``` 373 | Determines the coordinates, where a line intersects with an ellipse. 374 | 375 | | Parameter | Description | 376 | |-----------|--------------------------------------------------------------------| 377 | | LinePt | A point on the line | 378 | | LineAngle | The slope angle of the line (between `-Pi` and `Pi`) | 379 | | Bounds | The bounding box of the ellipse | 380 | 381 | Returns the intersection points as a dynamic array. 382 | 383 | 384 | ```pascal 385 | function IntersectLinePolygon(const LinePt: TPoint; const LineAngle: Double; const Vertices: array of TPoint): TPoints; 386 | ``` 387 | Determines the coordinates, where a line intersects with a polygon. 388 | 389 | | Parameter | Description | 390 | |-----------|--------------------------------------------------------------------| 391 | | LinePt | A point on the line | 392 | | LineAngle | The slope angle of the line (between `-Pi` and `Pi`) | 393 | | Vertices | The coordinates of the polygon's vertices | 394 | 395 | Returns the intersection points as a dynamic array. 396 | 397 | 398 | ```pascal 399 | function IntersectLinePolyline(const LinePt: TPoint; const LineAngle: Double; const Points: array of TPoint): TPoints; 400 | ``` 401 | Determines the coordinates, where a line intersects with a polyline. 402 | 403 | | Parameter | Description | 404 | |-----------|--------------------------------------------------------------------| 405 | | LinePt | A point on the line | 406 | | LineAngle | The slope angle of the line (between `-Pi` and `Pi`) | 407 | | Points | The coordinates of the polyline's points | 408 | 409 | Returns the intersection points as a dynamic array. 410 | -------------------------------------------------------------------------------- /Docs/README.md: -------------------------------------------------------------------------------- 1 | Content 2 | ======= 3 | The `SimpleGraph` unit defines the following classes: 4 | 5 | - **[TSimpleGraph](TSimpleGraph.md) = class (TCustomControl)** \ 6 | Provides a canvas for drawing simple directional graphs. 7 | 8 | - **[TGraphConstraints](TGraphConstraints.md) = class(TPersistent)** \ 9 | Defines the bounding constraints of the graphs on the [TSimpleGraph](TSimpleGraph.md) control. 10 | 11 | - **[TGraphObjectList](TGraphObjectList.md) = class(TPersistent)** \ 12 | Maintains the collection of objects on a graph. 13 | 14 | - **[TGraphObject](TGraphObject.md) = class(TPersistent)** \ 15 | Represents an object on a graph. 16 | 17 | - **[TGraphLink](TGraphLink.md) = class([TGraphObject](TGraphObject.md))** \ 18 | Represents a link/edge on a graph. 19 | 20 | - **[TGraphNode](TGraphNode.md) = class([TGraphObject](TGraphObject.md))** \ 21 | Represents a node on a graph. 22 | 23 | - **[TPolygonalNode](TPolygonalNode.md) = class([TGraphNode](TGraphNode.md))** \ 24 | Represents a polygonal node on a graph. 25 | 26 | - **TRoundRectangularNode = class([TGraphNode](TGraphNode.md))** \ 27 | Represents a rounded rectangular node on a graph. 28 | 29 | - **TEllipticNode = class([TGraphNode](TGraphNode.md))** \ 30 | Represents an elliptical node on a graph. 31 | 32 | - **TTriangularNode = class([TPolygonalNode](TPolygonalNode.md))** \ 33 | Represents a triangular node on a graph. 34 | 35 | - **TRectangularNode = class([TPolygonalNode](TPolygonalNode.md))** \ 36 | Represents a rectangular node on a graph. 37 | 38 | - **TRhomboidalNode = class([TPolygonalNode](TPolygonalNode.md))** \ 39 | Represents a rhomboidal node on a graph. 40 | 41 | - **THexagonalNode = class([TPolygonalNode](TPolygonalNode.md))** \ 42 | Represents a hexagonal node on a graph. 43 | 44 | - **[TGraphScrollBar](TGraphScrollBar.md) = class(TPersistent)** \ 45 | Manages a horizontal or vertical scroll bar on the [TSimpleGraph](TSimpleGraph.md) control. 46 | 47 | - **[TMemoryHandleStream](TMemoryHandleStream.md) = class(TMemoryStream)** \ 48 | Creates a stream whose backing store is memory allocated in the Windows global heap. 49 | 50 | - **[TCanvasRecall](TCanvasRecall.md) = class(TObject)** \ 51 | Stores the current state of a `Canvas` object, so that it can be restored at a later time. 52 | 53 | - **TCompatibleCanvas = class(TCanvas)** \ 54 | Provides a `Canvas` object compatible with the screen's device context. 55 | 56 | In addition, the code offers various [global procedures and functions](Globals.md). 57 | -------------------------------------------------------------------------------- /Docs/TCanvasRecall.md: -------------------------------------------------------------------------------- 1 | TCanvasRecall = class(TObject) 2 | ============================== 3 | This class holds a reference to a `Canvas` object and saves its current state. Later, the saved state of the `Canvas` object can be retrieved by calling the `Retrieve` method or automatically when the `TCanvasRecall` instance is destroyed. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the `TObject` class, the `TCanvasRecall` class has the following property: 8 | 9 | - **`public Reference: TCanvas`** \ 10 | The reference to a `Canvas` object that is managed by this instance. This property can be `nil`. 11 | 12 | By changing this property, the `TCanvasRecall` instance restores the state of the previous `Canvas` object and saves the state of the new one. 13 | 14 | Methods 15 | ------- 16 | In addition to the methods of the `TObject` class, the `TCanvasRecall` class defines or overrides the following public methods: 17 | 18 | - **`constructor Create(AReference: TCanvas);`** \ 19 | Creates an instance of the class and saves the state of the `Canvas` object specified by the parameter. 20 | 21 | | Parameter | Description | 22 | |------------|----------------------------------------------------------------------------| 23 | | AReference | The `Canvas` object that should be managed by this instance (can be `nil`) | 24 | 25 | - **`destructor Destroy; override;`** \ 26 | Restores the saved state of the `Canvas` object and destroys the instance. 27 | 28 | - **`procedure Store;`** \ 29 | Saves the current state of the `Canvas` object. 30 | 31 | - **`procedure Retrieve;`** \ 32 | Restores the saved state of the `Canvas` object. 33 | 34 | -------------------------------------------------------------------------------- /Docs/TGraphConstraints.md: -------------------------------------------------------------------------------- 1 | TGraphConstraints = class(TPersistent) 2 | ====================================== 3 | This class has the bounding box of the graph objects on a [TSimpleGraph](TSimpleGraph.md) control. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the `TPersistent` class, the `TGraphConstraints` class provides the following properties: 8 | 9 | - **`public BoundsRect: TRect`** \ 10 | Specifies the bounding box of the graph objects on canvas as a `TRect` value. 11 | 12 | - **`published MinLeft: Integer default 0`** \ 13 | Specifies the minimum horizontal placement of a graph object on canvas. 14 | 15 | - **`published MinTop: Integer default 0`** \ 16 | Specifies the minimum vertical placement of a graph object on canvas. 17 | 18 | - **`published MaxRight: Integer default 65535`** \ 19 | Specifies the maximum horizontal placement of a graph object on canvas. 20 | 21 | - **`published MaxBottom: Integer default 65535`** \ 22 | Specifies the maximum vertical placement of a graph object on canvas. 23 | 24 | - **`public Owner: TSimpleGraph`** (read-only) \ 25 | Gets the [TSimpleGraph](TSimpleGraph.md) control that owns this instance. 26 | 27 | Methods 28 | ------- 29 | In addition to the methods of the `TPersistent` class, the `TGraphConstraints` class has the following public methods: 30 | 31 | - **`procedure SetBounds(aLeft, aTop, aWidth, aHeight: Integer);`** \ 32 | Sets the bounding box of the graph objects on canvas. 33 | 34 | | Parameter | Description | 35 | |-----------|---------------------------------------------------| 36 | | aLeft | The minimum horizontal position | 37 | | aTop | The minimum vertical position | 38 | | aWidth | The maximum horizontal size | 39 | | aHeight | The minimum vertical size | 40 | 41 | - **`function WithinBounds(const Pts: array of TPoint): Boolean;`** \ 42 | Determines whether all the given coordinates satisfy the constraints. 43 | 44 | | Parameter | Description | 45 | |-----------|---------------------------------------------------| 46 | | Pts | The array of coordinates to be examined | 47 | 48 | Returns `true` if all the coordinates satisfy the constraints; otherwise, return `false`. 49 | 50 | - **`function ConfinePt(var Pt: TPoint): Boolean;`** \ 51 | Moves a given coordinate inside the bounding box if it is outside of the box. 52 | 53 | | Parameter | Description | 54 | |-----------|---------------------------------------------------| 55 | | Pt | The coordinates to be confined | 56 | 57 | Returns `true` if the coordinate already satisfies the constraints; otherwise, return `false`. 58 | 59 | - **`function ConfineRect(var Rect: TRect): Boolean;`** \ 60 | Shrinks a given rectangle to fit inside the bounding box if any side of it is outside of the box. 61 | 62 | | Parameter | Description | 63 | |-----------|---------------------------------------------------| 64 | | Rect | The rectangle to be confined | 65 | 66 | Returns `true` if the rectangle already satisfies the constraints; otherwise, return `false`. 67 | 68 | - **`function ConfineMoveResize(const Rect: TRect; Mobility: TObjectSides; var dX, dY: Integer): Boolean;`** \ 69 | Adjusts changes in position and/or size of a rectangle, so that the rectangle stays inside the bounding box. 70 | 71 | | Parameter | Description | 72 | |-----------|---------------------------------------------------| 73 | | Rect | The rectangle | 74 | | Mobility | The sides of the rectangle that can be displaced | 75 | | dX | The amount of horizontal changes | 76 | | dY | The amount of vertical changes | 77 | 78 | Returns `true` if after applying the changes, the rectangle already satisfies the constraints; otherwise, return `false`. 79 | 80 | Events 81 | ------ 82 | The `TGraphConstraints` class has the following event: 83 | 84 | - **`OnChange: TNotifyEvent`** \ 85 | Occurs when the value of a property has been changed. 86 | -------------------------------------------------------------------------------- /Docs/TGraphLink.md: -------------------------------------------------------------------------------- 1 | TGraphLink = class([TGraphObject](TGraphObject.md)) 2 | =================================================== 3 | This class represents links (edges) of a graph. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the [TGraphObject](Docs/TGraphObject.md) class, the `TGraphLink` class has the following extra properties: 8 | 9 | - **`public Polyline: TPoints`** \ 10 | Gets or sets the endpoint coordinates of the link's line segments. 11 | 12 | - **`public Points[Index: Integer]: TPoint`** \ 13 | Determines the coordinate of a start, break, or end point of the link, by specifying its zero-based index. 14 | 15 | - **`public PointCount: Integer read fPointCount`** (read-only) \ 16 | Gets the number of points in the `Polyline` and `Points` properties of the link. 17 | 18 | - **`published TextPosition: Integer default -1`** \ 19 | Determines the index of the line segment, where the caption of the link appears parallel to it. A value of -1 for this property, indicates the longest line segment. 20 | 21 | - **`published TextSpacing: Integer default 0`** \ 22 | Determines the distance between the caption of the link and the line segment parallel to it. 23 | 24 | - **`published BeginStyle: TLinkBeginEndStyle default lsNone`** \ 25 | `TLinkBeginEndStyle = (lsNone, lsArrow, lsArrowSimple, lsCircle, lsDiamond)` \ 26 | Specifies the begin style of the link. 27 | 28 | | Value | Shape at the starting point of the link | 29 | |---------------|-----------------------------------------| 30 | | lsNone | Nothing | 31 | | lsArrow | An open-headed arrow | 32 | | lsArrowSimple | A simple arrow | 33 | | lsCircle | A circle | 34 | | lsDiamond | A diamond | 35 | 36 | - **`published BeginSize: Byte default 6`** \ 37 | Determines the size of the `BeginStyle` shape of the link. 38 | 39 | - **`published EndStyle: TLinkBeginEndStyle default lsArrow`** \ 40 | `TLinkBeginEndStyle = (lsNone, lsArrow, lsArrowSimple, lsCircle, lsDiamond)` \ 41 | Specifies the end style of the link. 42 | 43 | | Value | Shape at the ending point of the link | 44 | |---------------|-----------------------------------------| 45 | | lsNone | Nothing | 46 | | lsArrow | An open-headed arrow | 47 | | lsArrowSimple | A simple arrow | 48 | | lsCircle | A circle | 49 | | lsDiamond | A diamond | 50 | 51 | - **`published EndSize: Byte default 6`** \ 52 | Determines the size of the `EndStyle` shape of the link. 53 | 54 | - **`published LinkOptions: TGraphLinkOptions default []`** \ 55 | `TGraphLinkOptions = (gloFixedStartPoint, gloFixedEndPoint, gloFixedBreakPoints, gloFixedAnchorStartPoint, gloFixedAnchorEndPoint)` \ 56 | Specifies the behavioral attributes of the node. 57 | 58 | | Value | Description | 59 | |--------------------------|-----------------------------------------------------------------------| 60 | | gloFixedStartPoint | The starting point of the link cannot be changed. | 61 | | gloFixedEndPoint | The ending point of the link cannot be changed. | 62 | | gloFixedBreakPoints | The breakpoints of the link cannot be changed. | 63 | | gloFixedAnchorStartPoint | If the starting point of the link is attached to a node, the point is fixed to the center of the node. If the starting point of the link is attached to a link, the point is fixed to the innermost breakpoint or line segment of the other link. | 64 | | gloFixedAnchorEndPoint | If the ending point of the link is attached to a node, the point is fixed to the center of the node. If the ending point of the link is attached to a link, the point is fixed to the innermost breakpoint or line segment of the other link. | 65 | 66 | See also the `Options` property of [TGraphObject](TGraphObject.md) class. 67 | 68 | - **`public Source: TGraphObject`** \ 69 | Determines the graph object to which the starting point of the link is attached. 70 | 71 | - **`public Target: TGraphObject`** \ 72 | Determines the graph object to which the ending point of the link is attached. 73 | 74 | Methods 75 | ------- 76 | In addition to the methods of the [TGraphObject](Docs/TGraphObject.md) class, the `TGraphLink` class has the following extra methods: 77 | 78 | - **`constructor CreateNew(AOwner: TSimpleGraph; ASource: TGraphObject; const Pts: array of TPoint; ATarget: TGraphObject);`** \ 79 | Initiates a new instance of the link class. 80 | 81 | | Parameter | Description | 82 | |----------------|------------------------------------------------------------------------------------------------------| 83 | | AOwner | The [TSimpleGraph](TSimpleGraph.md) instance that owns this link | 84 | | ASource | The [GraphObject](TGraphObject.md.md) instance that is the source of a connection, or `nil` for none | 85 | | Pts | The control points of the link | 86 | | ATarget | The [GraphObject](TGraphObject.md.md) instance that is the target of a connection, or `nil` for none | 87 | 88 | A `EGraphInvalidOperation` exception will be raised if instance cannot be created. 89 | 90 | - **`function AddPoint(const Pt: TPoint): Integer;`** \ 91 | Adds a point to the end of the `Points` list. 92 | 93 | | Parameter | Description | 94 | |----------------|------------------------------------------------------------------------| 95 | | Pt | The coordinate of the new point | 96 | 97 | Returns the index of the newly added point in the `Points` list. 98 | 99 | - **`procedure InsertPoint(Index: Integer; const Pt: TPoint);`** \ 100 | Adds a point at a specified index of the `Points` list . 101 | 102 | | Parameter | Description | 103 | |----------------|------------------------------------------------------------------------| 104 | | Index | The index of the new point in the `Points` list | 105 | | Pt | The coordinate of the new point | 106 | 107 | - **`procedure RemovePoint(Index: Integer);`** \ 108 | Removes the point at the specified index of the `Points` list. 109 | 110 | | Parameter | Description | 111 | |----------------|------------------------------------------------------------------------| 112 | | Index | The index of the point in the `Points` list | 113 | 114 | - **`function IndexOfPoint(const Pt: TPoint; Neighborhood: Integer = 0): Integer;`** \ 115 | Finds index of a point in the `Points` list. 116 | 117 | | Parameter | Description | 118 | |----------------|------------------------------------------------------------------------| 119 | | Pt | The coordinate of the point | 120 | | Neighborhood | The proximity tolerance as radius in pixels | 121 | 122 | Returns the index of the point if the point is found; otherwise, returns -1. 123 | 124 | - **`function AddBreakPoint(const Pt: TPoint): Integer;`** \ 125 | Inserts a breakpoint at the specified point on (or close to) a line segment of the link. 126 | 127 | | Parameter | Description | 128 | |----------------|------------------------------------------------------------------------| 129 | | Pt | The coordinate of the point | 130 | 131 | Returns the index of the inserted point in the `Points` list, or -1 if the point was not close to any line segment. 132 | 133 | - **`function NormalizeBreakPoints(Options: TLinkNormalizeOptions): Boolean;`** \ 134 | Passes through the `Points` list and deletes the ineffectual ones. 135 | 136 | | Parameter | Description | 137 | |----------------|------------------------------------------------------------------------| 138 | | Options | Determines how to select the candidate points for removal | 139 | 140 | The `Options` parameter can have a combination of the following values: 141 | 142 | | Value | Meaning | 143 | |--------------------|--------------------------------------------------------------------| 144 | | lnoDeleteSamePoint | Remove the break points that produce tiny line segments | 145 | | lnoDeleteSameAngle | Remove the break points that produce parallel line segments | 146 | 147 | Returns `true` if any point is removed; otherwise, returns `false`. 148 | 149 | - **`function IsFixedPoint(Index: Integer; HookedPointsAsFixed: Boolean): Boolean;`** \ 150 | Determines whether the point at the specified index of the `Points` list, is fixed. 151 | 152 | | Parameter | Description | 153 | |---------------------|-----------------------------------------------------------------------------------------| 154 | | Index | The index of the point in the `Points` list | 155 | | HookedPointsAsFixed | Specifies whether the points attached to other graph objects should be considered fixed | 156 | 157 | Returns `true` if the point is a fixed point; otherwise, returns `false`. 158 | 159 | - **`function IsHookedPoint(Index: Integer): Boolean;`** \ 160 | Determines whether the point at the specified index of the `Points` list is attached to a graph object. 161 | 162 | | Parameter | Description | 163 | |---------------------|---------------------------------------------------------------------| 164 | | Index | The index of the point in the `Points` list | 165 | 166 | Returns `true` if the point is attached to a graph object; otherwise, returns `false`. 167 | 168 | - **`function HookedObjectOf(Index: Integer): TGraphObject;`** \ 169 | Gets the graph object to which the point at the specified index of the `Points` list is attached. 170 | 171 | | Parameter | Description | 172 | |---------------------|---------------------------------------------------------------------| 173 | | Index | The index of the point in the `Points` list | 174 | 175 | Returns the graph object to which the point is attached, or `nil` if the point is attached to none. 176 | 177 | - **`function HookedIndexOf(GraphObject: TGraphObject): Integer;`** \ 178 | Gets the index of a point in the `Points` list, to which a specified graph object is attached. 179 | 180 | | Parameter | Description | 181 | |---------------------|---------------------------------------------------------------------| 182 | | GraphObject | A [TGraphObject](TGraphObject.md) instance | 183 | 184 | Returns the index of the point, or -1 if the graph object is not attached to the link. 185 | 186 | - **`function HookedPointCount: Integer;`** \ 187 | Returns the number of points in the `Points` list, which are attached to a graph object. 188 | 189 | - **`function CanHook(Index: Integer; GraphObject: TGraphObject): Boolean;`** \ 190 | Examines whether the point at the specified index of the `Points` list can be attached to a given graph object. 191 | 192 | | Parameter | Description | 193 | |---------------------|---------------------------------------------------------------------| 194 | | Index | The index of the point in the `Points` list | 195 | | GraphObject | A [TGraphObject](TGraphObject.md) instance | 196 | 197 | Returns `true` if the link can be attached to the graph object at the specified point; otherwise, returns `false`. 198 | 199 | - **`function Hook(Index: Integer; GraphObject: TGraphObject): Boolean;`** \ 200 | Attaches the point at the specified index of the `Points` list to a given graph object. 201 | 202 | | Parameter | Description | 203 | |---------------------|---------------------------------------------------------------------| 204 | | Index | The index of the point in the `Points` list | 205 | | GraphObject | A [TGraphObject](TGraphObject.md) instance | 206 | 207 | Returns `true` if the link could attach to the graph object at the specified point; otherwise, returns `false`. 208 | 209 | - **`function Unhook(Index: Integer): Boolean; overload;`** \ 210 | Detaches the point at the specified index of the `Points` list from any graph object. 211 | 212 | | Parameter | Description | 213 | |---------------------|---------------------------------------------------------------------| 214 | | Index | The index of the point in the `Points` list | 215 | 216 | Returns `true` if the link was attached to a graph object at the specified point; otherwise, returns `false`. 217 | 218 | - **`function Unhook(GraphObject: TGraphObject): Integer; overload;`** \ 219 | Detaches the link from a given graph object. 220 | 221 | | Parameter | Description | 222 | |---------------------|---------------------------------------------------------------------| 223 | | GraphObject | A [TGraphObject](TGraphObject.md) instance | 224 | 225 | Returns the index of the attached point if the link was attached to the graph object; otherwise, returns -1. 226 | 227 | - **`function CanLink(ASource, ATarget: TGraphObject): Boolean;`** \ 228 | Examines whether the link can connect two graph objects. 229 | 230 | | Parameter | Description | 231 | |-------------|-----------------------------------------------------------------------------| 232 | | ASource | A [TGraphObject](TGraphObject.md) instance as the source of the connection | 233 | | ASource | A [TGraphObject](TGraphObject.md) instance as the target of the connection | 234 | 235 | Returns `true` if the link can connect the graph objects; otherwise, returns `false`. 236 | 237 | - **`function Link(ASource, ATarget: TGraphObject): Boolean;`** \ 238 | Connects two graph objects. 239 | 240 | | Parameter | Description | 241 | |-------------|-----------------------------------------------------------------------------| 242 | | ASource | A [TGraphObject](TGraphObject.md) instance as the source of the connection | 243 | | ASource | A [TGraphObject](TGraphObject.md) instance as the target of the connection | 244 | 245 | Returns `true` if the link could connect the graph objects; otherwise, returns `false`. 246 | 247 | - **`function CanMove: Boolean;`** \ 248 | Returns `true` if all the points in the `Points` list of the link can move freely. 249 | 250 | - **`function Rotate(const Angle: Double; const Origin: TPoint): Boolean;`** \ 251 | Rotates the link by an angle around a specified point. 252 | 253 | | Parameter | Description | 254 | |-------------|-----------------------------------------------------------------------------| 255 | | Angle | The angle of rotation in radians | 256 | | Origin | The coordinate of the center of rotation | 257 | 258 | Returns `true` if the link is rotated; otherwise, returns `false`. 259 | 260 | - **`function Scale(const Factor: Double): Boolean;`** \ 261 | Scales the link by a scaling factor. 262 | 263 | | Parameter | Description | 264 | |-------------|-----------------------------------------------------------------------------| 265 | | Factor | The scaling factor | 266 | 267 | Returns `true` if the link is scaled; otherwise, returns `false`. 268 | 269 | - **`procedure Reverse;`** \ 270 | Reverses the direction of the link. 271 | -------------------------------------------------------------------------------- /Docs/TGraphNode.md: -------------------------------------------------------------------------------- 1 | TGraphNode = class([TGraphObject](TGraphObject.md)) 2 | =================================================== 3 | This abstract class the base class of all graph nodes. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the [TGraphObject](Docs/TGraphObject.md) class, the `TGraphNode` class has the following extra properties: 8 | 9 | - **`published Alignment: TAlignment default taCenter`** \ 10 | `TAlignment = (taLeftJustify, taRightJustify, taCenter)` \ 11 | Controls the horizontal placement of the text within the node. 12 | 13 | | Value | Description | 14 | |----------------|--------------------------------------------------------------------------| 15 | | taLeftJustify | The text is left-justified: lines all begin at the left edge of the node | 16 | | taCenter | The text is centered horizontally in the node | 17 | | taRightJustify | The text is right-justified: lines all end at the right edge of the node | 18 | 19 | - **`published Layout: TTextLayout default tlCenter`** \ 20 | `TTextLayout = (tlTop, tlCenter, tlBottom)` \ 21 | Specifies the vertical placement of the text within the node. 22 | 23 | | Value | Description | 24 | |----------------|--------------------------------------------------------------------------| 25 | | tlTop | The text appears at the top of the node | 26 | | tlCenter | The text is vertically centered in the node | 27 | | tlBottom | The text appears along the bottom of the node | 28 | 29 | - **`published Margin: Integer default 8`** \ 30 | Determines the margin of the text from edges of the node. 31 | 32 | - **`published Background: TPicture`** \ 33 | Specifies the background image of the node. 34 | 35 | - **`public BackgroundMargins: TRect`** \ 36 | Determines the margins of the background image relative to the node's dimensions in percent. 37 | 38 | - **`published Left: Integer`** \ 39 | Specifies the x-coordinate of the node's top-left corner. 40 | 41 | - **`published Top: Integer`** \ 42 | Specifies the y-coordinate of the node's top-left corner. 43 | 44 | - **`published Width: Integer`** \ 45 | Specifies the horizontal size of the node. 46 | 47 | - **`published Height: Integer`** \ 48 | Specifies the vertical size of the node 49 | 50 | - **`public Center: TPoint`** (read-only) \ 51 | Gets the coordinate of the node's center of mass. 52 | 53 | - **`published NodeOptions: TGraphNodeOptions default [gnoMovable, gnoResizable, gnoShowBackground]`** \ 54 | `TGraphNodeOptions = set of (gnoMovable, gnoResizable, gnoShowBackground)` \ 55 | Specifies the visual and behavioral attributes of the node. 56 | 57 | | Value | Description | 58 | |-------------------|-----------------------------------------------------------------------| 59 | | gnoMovable | The location of node is changeable | 60 | | gnoResizable | The size of node is changeable | 61 | | gnoShowBackground | The background image of the node is visible | 62 | 63 | See also the `Options` property of [TGraphObject](TGraphObject.md) class. 64 | 65 | 66 | Methods 67 | ---------- 68 | In addition to the properties of the [TGraphObject](Docs/TGraphObject.md) class, the `TGraphNode` class has the following extra methods: 69 | 70 | - **`constructor CreateNew(AOwner: TSimpleGraph; const Bounds: TRect);`** \ 71 | Creates an instance of the node class and sets its bounding rectangle. 72 | 73 | | Parameter | Description | 74 | |----------------|--------------------------------------------------------------------------| 75 | | AOwner | The [TSimpleGraph](TSimpleGraph.md) instance that owns this node | 76 | | Bounds | The bounding rectangle of the node | 77 | 78 | - **`procedure CanMoveResize(var NewLeft, NewTop, NewWidth, NewHeight: Integer; out CanMove, CanResize: Boolean);`** \ 79 | Examines whether the node can be moved or resized. 80 | 81 | | Parameter | Description | 82 | |----------------|--------------------------------------------------------------------------| 83 | | NewLeft | The new x-coordinate of the node's top-left corner | 84 | | NewTop | The new y-coordinate of the node's top-left corner | 85 | | NewWidth | The new width of the node | 86 | | NewHeight | The new height of the node | 87 | | CanMove | Specifies whether the node is relocatable | 88 | | CanResize | Specifies whether the node is resizable | 89 | 90 | - **`procedure SetBounds(aLeft, aTop, aWidth, aHeight: Integer);`** \ 91 | Sets the `Left`, `Top`, `Width`, and `Height` properties of the node, all at once. 92 | 93 | | Parameter | Description | 94 | |----------------|--------------------------------------------------------------------------| 95 | | aLeft | The new x-coordinate of the node's top-left corner | 96 | | aTop | The new y-coordinate of the node's top-left corner | 97 | | aWidth | The new width of the node | 98 | | aHeight | The new height of the node | 99 | -------------------------------------------------------------------------------- /Docs/TGraphObject.HitTesting.md: -------------------------------------------------------------------------------- 1 | Graph Object Hit-Testing 2 | ======================== 3 | The hit-test result of a graph object is a mask of 32-bit values. Presence of each value in the result, determines which part of the graph object is at the point of hit-testing. 4 | 5 | | Value | Meaning | Scope | 6 | |-----------------|-------------------------------------------------------------------------------------------------------|---------------------------------| 7 | | GHT_NOWHERE | The point is not on the object. | [TGraphObject](TGraphObject.md) | 8 | | GHT_TRANSPARENT | The point is on the object, but the object is not selectable. | [TGraphObject](TGraphObject.md) | 9 | | GHT_LEFT | The point is on the left side of the object. | [TGraphNode](TGraphNode.md) | 10 | | GHT_TOP | The point is on the top side of the object. | [TGraphNode](TGraphNode.md) | 11 | | GHT_RIGHT | The point is on the right side of the object. | [TGraphNode](TGraphNode.md) | 12 | | GHT_BOTTOM | The point is on the bottom side of the object. | [TGraphNode](TGraphNode.md) | 13 | | GHT_TOPLEFT | The point is on the top-left corner of the object. | [TGraphNode](TGraphNode.md) | 14 | | GHT_TOPRIGHT | The point is on the top-right corner of the object. | [TGraphNode](TGraphNode.md) | 15 | | GHT_BOTTOMLEFT | The point is on the bottom-left corner of the object. | [TGraphNode](TGraphNode.md) | 16 | | GHT_BOTTOMRIGHT | The point is on the bottom-right corner of the object. | [TGraphNode](TGraphNode.md) | 17 | | GHT_CLIENT | The point is on the body of the object. | [TGraphObject](TGraphObject.md) | 18 | | GHT_CAPTION | The point is on the caption of the object. | [TGraphObject](TGraphObject.md) | 19 | | GHT_POINT | The point is on one of the control points of the object. The high-order word holds the point's index. | [TGraphLink](TGraphLink.md) | 20 | | GHT_LINE | The point is on one of the line segments of the object. The high-order word holds the line's index. | [TGraphLink](TGraphLink.md) | 21 | 22 | For example, the following function returns the index of a breakpoint/endpoint of a given link, if the mouse pointer is over such point. 23 | 24 | ```pascal 25 | function IndexOfPointUnderMouseCursor(Link: TGraphLink): Integer; 26 | var 27 | HT: DWord; 28 | begin 29 | HT := Link.HitTest(Link.Owner.CursorPos); 30 | if (HT and GHT_POINT) <> 0 then 31 | Result := HiWord(HT) 32 | else 33 | Result := -1; 34 | end; 35 | -------------------------------------------------------------------------------- /Docs/TGraphObject.md: -------------------------------------------------------------------------------- 1 | TGraphObject = class(TPersistent) 2 | ================================= 3 | This abstract class is the ancestor of all the objects that appear on a graph. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the `TPersistent` class, the `TGraphObject` class provides the following properties: 8 | 9 | - **`public BoundsRect: TRect`** \ 10 | Determines the bounding rectangle of the graph object in graph coordinates. 11 | 12 | - **`published Brush: TBrush`** \ 13 | Determines the color and pattern for filling the background of the graph object. 14 | 15 | - **`public Data: Pointer`** \ 16 | Stores a pointer value as part of the graph object. 17 | 18 | - **`public DependentCount: Integer`** (read-only) \ 19 | Determines the number of graph objects whose placement on the graph is dependent on this graph object. 20 | 21 | - **`public Dependents[Index: Integer]: TGraphObject`** (read-only) \ 22 | Contains the list of graph objects whose placement on the graph is dependent on this graph object. 23 | 24 | - **`public Dragging: Boolean`** (read-only) \ 25 | Indicates whether the graph object is being dragged. 26 | 27 | - **`published Font: TFont`** \ 28 | Specifies the font to use when rendering a text on the graph object. 29 | 30 | - **`published HasCustomData: Boolean default false`** \ 31 | Indicates whether the graph object holds some application defined data that should be saved. 32 | 33 | If `HasCustomData` is set to `true`, the owner [TSimpleGraph](TSimpleGraph.md) control raises an `OnObjectWrite` event for saving the custom data of the graph object into a stream. 34 | 35 | - **`published Hint: String`** \ 36 | Specifies the text string that appears as the tooltip of the graph object. 37 | 38 | - **`public ID: DWord`** (read-only) \ 39 | Determines the unique identifier of the graph object in the graph. 40 | 41 | - **`public LinkInputCount: Integer`** \ 42 | Determines the number of graph links/edges whose ending point is attached to this graph object. 43 | 44 | - **`public LinkInputs[Index: Integer]: TGraphLink`** \ 45 | Contains the list of graph links/edges whose ending point is attached to this graph object. 46 | 47 | The `Target` property of all the [TGraphLink](TGraphLink.md) objects in this list refers to this graph object. 48 | 49 | - **`public LinkOutputCount: Integer`** \ 50 | Determines the number of graph links/edges whose starting point is attached to this graph object. 51 | 52 | - **`public LinkOutputs[Index: Integer]: TGraphLink`** \ 53 | Contains the list of graph links/edges whose starting point is attached to this graph object. 54 | 55 | The `Source` property of all the [TGraphLink](TGraphLink.md) objects in this list refers to this graph object. 56 | 57 | - **`published Options: TGraphObjectOptions default [goLinkable, goSelectable, goShowCaption]`** \ 58 | `TGraphObjectOptions = set of (goLinkable, goSelectable, goShowCaption)` \ 59 | Specifies the visual and behavioral attributes of the node. 60 | 61 | | Value | Description | 62 | |----------------|-----------------------------------------------------------------------| 63 | | goLinkable | A link/edge of the graph can attach to this graph object | 64 | | goSelectable | The graph object is selectable | 65 | | goShowCaption | The caption of the graph object is visible | 66 | 67 | - **`public Owner: TSimpleGraph`** (read-only) \ 68 | Determines the [TSimpleGraph](TSimpleGraph.md) control that owns this graph object. 69 | 70 | - **`published ParentFont: Boolean default true`** \ 71 | Determines where the graph object looks for its font information. 72 | 73 | If `ParentFont` is set to `true`, the graph object uses the font of its owner [TSimpleGraph](TSimpleGraph.md) control. 74 | 75 | - **`published Pen: TPen`** \ 76 | Specifies the kind of pen the graph object uses for drawing lines and outlining shapes. 77 | 78 | - **`public Selected: Boolean`** \ 79 | Indicates whether the graph object is selected. 80 | 81 | - **`public SelectedVisualRect: TRect`** (read-only) \ 82 | Specifies the rectangle area that the graph object occupies on the graph when it is selected. 83 | 84 | - **`public Showing: Boolean`** (read-only) \ 85 | Indicates whether the graph object is showing on the owner [TSimpleGraph](TSimpleGraph.md) control. 86 | 87 | - **`public States: TGraphObjectStates`** \ 88 | `TGraphObjectStates = set of (osCreating, osDestroying, osLoading, osReading, osWriting, osUpdating, osDragging, osDragDisabled, osConverting)` \ 89 | Describes the current state of the graph object, indicating when a component needs to avoid certain actions. 90 | 91 | | Value | Description | 92 | |----------------|--------------------------------------------------------------------------------------------------| 93 | | osCreating | The graph object is being created. | 94 | | osDestroying | The graph object is about to be destroyed. | 95 | | osLoading | The graph object is currently being loaded. | 96 | | osReading | The graph object is reading its properties from a stream. | 97 | | osWriting | The graph object is writing its properties into a stream. | 98 | | osUpdating | The graph object is being updated. This flag is set between `BeginUpdate` and `EndUpdate` block. | 99 | | osDragging | The graph object is being dragged. | 100 | | osDragDisabled | The graph object doesn't accept a drag operation at this moment. | 101 | | osConverting | The graph object is currently either source or target of a type conversion operation. | 102 | 103 | - **`published Tag: Integer default 0`** \ 104 | Stores an integer value as part of the graph object. 105 | 106 | - **`published Text: String`** \ 107 | Specifies the text string that appears as the caption of the graph object. 108 | 109 | - **`published Visible: Boolean default true`** \ 110 | Determines whether the graph object appears on the owner [TSimpleGraph](TSimpleGraph.md) control. 111 | 112 | - **`public VisualRect: TRect`** \ 113 | Specifies the rectangle area that the graph object occupies on the graph when it is not selected. 114 | 115 | - **`public ZOrder: Integer`** \ 116 | Specifies the back-to-front order in which the graph object is displayed relative to other graph objects. 117 | 118 | 119 | Methods 120 | ------- 121 | In addition to the methods of the `TPersistent` class, the `TGraphObject` class provides the following methods: 122 | 123 | - **`function ConvertTo(AnotherClass: TGraphObjectClass): TGraphObject;`** \ 124 | Converts the graph object to another graph object type. 125 | 126 | | Parameter | Description | 127 | |----------------|--------------------------------------------------------------------------| 128 | | AnotherClass | The new graph object type | 129 | 130 | If the graph object is a link, the new class type must be a link, and if the graph object is a node, the new class type must be a node. 131 | 132 | - **`procedure LoadFromStream(Stream: TStream);`** \ 133 | Loads the properties of the graph object from a stream. 134 | 135 | | Parameter | Description | 136 | |-------------|---------------------------------------------------------------| 137 | | Stream | The input stream | 138 | 139 | - **`procedure SaveToStream(Stream: TStream);`** \ 140 | Saves the properties of the graph object into a stream. 141 | 142 | | Parameter | Description | 143 | |-------------|---------------------------------------------------------------| 144 | | Stream | The output stream | 145 | 146 | - **`procedure BeginUpdate;`** \ 147 | Suspends screen repainting of the graph object. 148 | 149 | - **`procedure EndUpdate;`** \ 150 | Resumes screen repainting of the graph object. 151 | 152 | - **`procedure Invalidate;`** \ 153 | Repaints the graph object. 154 | 155 | - **`procedure BringToFront;`** \ 156 | Puts the graph object in front of all other graph objects. 157 | 158 | - **`procedure SendToBack;`** \ 159 | Puts the graph object behind all other graph objects. 160 | 161 | - **`function Delete: Boolean;`** \ 162 | Removes the graph object from the graph 163 | 164 | Returns `true` if the graph object could be deleted; otherwise, returns `false`. 165 | 166 | **Note:**: Any reference to the deleted graph object is invalid and raises an AV exception. 167 | 168 | - **`function CanDelete: Boolean;`** \ 169 | Returns `true` if the graph object can be deleted; otherwise, returns `false`. 170 | 171 | 172 | - **`function IsLocked: Boolean;`** \ 173 | Returns `true` if the graph object is being locked by the owner [TSimpleGraph](TSimpleGraph.md) control. 174 | 175 | Users cannot interact with a locked graph object using a mouse or keyboard. 176 | 177 | - **`function HitTest(const Pt: TPoint): DWord;`** \ 178 | Determines which part of the graph object is at the specified point specified. 179 | 180 | | Parameter | Description | 181 | |-------------|---------------------------------------------------------------| 182 | | Pt | The query point in graph coordinates | 183 | 184 | Returns the [Hit-Test](TGraphObject.HitTesting.md) result. 185 | 186 | - **`function ContainsPoint(X, Y: Integer): Boolean;`** \ 187 | Examines whether a given point is inside the graph object. 188 | 189 | | Parameter | Description | 190 | |-------------|---------------------------------------------------------------| 191 | | X | The x-coordinate of the point | 192 | | Y | The x-coordinate of the point | 193 | 194 | Returns `true` if the graph object is visible and the point is inside it; otherwise, returns `false`. 195 | 196 | - **`function IntersectsWith(const Rect: TRect): Boolean;`** \ 197 | Examines whether a given rectangle has any intersection with the graph object. 198 | 199 | | Parameter | Description | 200 | |-------------|---------------------------------------------------------------| 201 | | Rect | The rectangle in graph coordinates | 202 | 203 | Returns `true` if the graph object is visible and has intersection with the rectangle; otherwise, returns `false`. 204 | 205 | - **`function BeginDrag(const Pt: TPoint; HT: DWord = $FFFFFFFF): Boolean;`** \ 206 | Initiates manual dragging of the graph object. 207 | 208 | | Parameter | Description | 209 | |-------------|---------------------------------------------------------------------------------------------------------------| 210 | | Rect | The coordinate of the drag origin | 211 | | HT | Specifies the part of the graph object that should be dragged (see [hit-testing](TGraphObject.HitTesting.md)) | 212 | 213 | If `HT` parameter is `$FFFFFFFF`, the function detects the dragging part of the graph object. 214 | 215 | Returns `true` if the drag operation is initiated; otherwise, returns `false`. 216 | 217 | **Note:** The other selected objects in the graph may follow the drag operation. 218 | 219 | - **`function EndDrag(Accept: Boolean): Boolean;`** \ 220 | Terminates the current drag operation of the graph object. 221 | 222 | | Parameter | Description | 223 | |-------------|---------------------------------------------------------------| 224 | | Accept | Indicates whether to commit the outcome of the drag operation | 225 | 226 | Returns `true` if the graph object was being dragged; otherwise, returns `false`. 227 | 228 | - **`function DragTo(const Pt: TPoint; SnapToGrid: Boolean): Boolean;`** \ 229 | Moves the drag origin of the graph object to a given point. 230 | 231 | | Parameter | Description | 232 | |-------------|---------------------------------------------------------------| 233 | | Pt | The coordinate of the target point | 234 | | SnapToGrid | Indicates whether snap the drag origin to the grid | 235 | 236 | Returns `true` if the graph object is being dragged; otherwise, returns `false`. 237 | 238 | - **`function DragBy(dX, dY: Integer; SnapToGrid: Boolean): Boolean;`** \ 239 | Moves the drag origin of the graph object by a given amount along the x- and y-axis. 240 | 241 | | Parameter | Description | 242 | |-------------|---------------------------------------------------------------| 243 | | dX | The changes along the x-axis in pixels | 244 | | dY | The changes along the y-axis in pixels | 245 | | SnapToGrid | Indicates whether snap the drag origin to the grid | 246 | 247 | Returns `true` if the graph object is being dragged; otherwise, returns `false`. 248 | 249 | - **`class function IsLink: Boolean;`** \ 250 | Returns `true` if this graph object type representing a link/edge; otherwise, returns `false`. 251 | 252 | - **`class function IsNode: Boolean;`** \ 253 | Returns `true` if this graph object type representing a node; otherwise, returns `false`. 254 | -------------------------------------------------------------------------------- /Docs/TGraphObjectList.md: -------------------------------------------------------------------------------- 1 | TGraphObjectList = class(TPersistent) 2 | ===================================== 3 | This class holds a list of [TGraphObject](TGraphObject.md) objects. 4 | 5 | The instances of `TGraphObjectList` class do not own their holding objects. 6 | 7 | Properties 8 | ---------- 9 | In addition to the properties of the `TPersistent` class, the `TGraphObjectList` class provides the following properties: 10 | 11 | - **`public Capacity: Integer`** \ 12 | Specifies the allocated size of the array of items maintained by the list. 13 | 14 | - **`public Count: Integer`** (read-only) \ 15 | Gets the number of entries in the list that are in use. 16 | 17 | - **`public Items[Index: Integer]: TGraphObject`** (read-only) \ 18 | Gets an item in the list by its zero-based index. 19 | 20 | Methods 21 | ------- 22 | In addition to the methods of the `TPersistent` class, the `TGraphObjectList` class has the following public methods: 23 | 24 | - **`procedure Clear;`** \ 25 | Deletes all the items from the list. 26 | 27 | - **`function Add(Item: TGraphObject): Integer;`** \ 28 | Adds a new item at the end of the list. 29 | 30 | | Parameter | Description | 31 | |-----------|---------------------------------------------------| 32 | | Item | The item to be added | 33 | 34 | Returns the index of the added item. 35 | 36 | - **`procedure Insert(Index: Integer; Item: TGraphObject);`** \ 37 | Inserts a new item at a specified index of the list. 38 | 39 | | Parameter | Description | 40 | |-----------|---------------------------------------------------| 41 | | Index | The zero-based index of the new item in the list | 42 | | Item | The item to be added | 43 | 44 | - **`procedure Delete(Index: Integer);`** \ 45 | Removes an item at a specified index from the list. 46 | 47 | | Parameter | Description | 48 | |-----------|---------------------------------------------------| 49 | | Index | The zero-based index of the item to be removed | 50 | 51 | - **`function Remove(Item: TGraphObject): Integer;`** \ 52 | Removes a specified item from the list. 53 | 54 | | Parameter | Description | 55 | |-----------|---------------------------------------------------| 56 | | Item | The item to be removed | 57 | 58 | Returns the index of the removed item if the item is found; otherwise, returns -1. 59 | 60 | - **`procedure Move(CurIndex, NewIndex: Integer);`** \ 61 | Changes the position of an item in the list. 62 | 63 | | Parameter | Description | 64 | |-----------|---------------------------------------------------| 65 | | CurIndex | The zero-based index of the item to be moved | 66 | | NewIndex | The new zero-based index of the item in the list | 67 | 68 | - **`function IndexOf(Item: TGraphObject): Integer;`** \ 69 | Locates the index of an item in the list. 70 | 71 | Returns the index of the item if the item is found; otherwise, returns -1. 72 | 73 | - **`function First: TGraphObject;`** \ 74 | Initializes the forward enumeration of the list and returns the first item. 75 | 76 | Return the first item in the list if the list is not empty; otherwise, returns `nil`. 77 | 78 | - **`function Last: TGraphObject;`** \ 79 | Initializes the backward enumeration of the list and returns the last item. 80 | 81 | Return the last item of the list if the list is not empty; otherwise, returns `nil`. 82 | 83 | - **`function Next: TGraphObject;`** \ 84 | During enumeration, returns the next item of a forward enumeration. 85 | Before calling this method for the first time, the `First` method should be called. 86 | 87 | Returns next item in the list or `nil` if end of the list is reached. 88 | 89 | - **`function Prior: TGraphObject;`** \ 90 | During enumeration, returns the next item of a backward enumeration. 91 | Before calling this method for the first time, the `Last` method should be called. 92 | 93 | Returns previous item in the list or `nil` if begin of the list is reached. 94 | 95 | - **`function Push: Boolean;`** \ 96 | Saves the current enumeration state. 97 | 98 | Returns `true` if an enumeration state is saved; otherwise, `false`. 99 | 100 | - **`function Pop: Boolean;`** \ 101 | Restores the last saved enumeration state. 102 | 103 | Returns `true` if an enumeration state is restored; otherwise, `false`. 104 | 105 | Events 106 | ------ 107 | The `TGraphObjectList` class has the following event: 108 | 109 | - **`OnChange: TGraphObjectListEvent`** \ 110 | `TGraphObjectListEvent = procedure(Sender: TObject; GraphObject: TGraphObject; Action: TGraphObjectListAction) of object` \ 111 | Occurs when the list has been changed. 112 | 113 | | Parameter | Description | 114 | |-------------|----------------------------------------------------------------------------| 115 | | Sender | The `TGraphObjectList` instance that generated the event | 116 | | GraphObject | The [TGraphObject](TGraphObject.md) instance that was target of the change | 117 | | Action | The action that caused the event | 118 | 119 | The action parameter can have one of the following values: 120 | 121 | | Value | Description | 122 | |-------------|----------------------------------------------------------------------------| 123 | | glAdded | The item has been added to the list | 124 | | glRemoved | The item has been removed from the list | 125 | | glReordered | The position of the item in the list has been changed | 126 | -------------------------------------------------------------------------------- /Docs/TGraphScrollBar.md: -------------------------------------------------------------------------------- 1 | TGraphScrollBar = class(TPersistent) 2 | ==================================== 3 | This class manages a horizontal or vertical scroll bar on a [TSimpleGraph](TSimpleGraph.md) control. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the `TPersistent` class, the `TGraphScrollBar` class provides the following properties: 8 | 9 | - **`published ButtonSize: Integer default 0`** \ 10 | Specifies the sizes of the buttons in the scroll bar. 11 | 12 | If the scroll bar is horizontal, `ButtonSize` is the width of the arrow buttons in pixels. 13 | 14 | If the scroll bar is vertical, `ButtonSize` is the height of the arrow buttons in pixels. 15 | 16 | Set this property to zero to use the system's default button size. 17 | 18 | - **`published Color: TColor default clBtnHighlight`** \ 19 | Specifies the scroll bar's color. 20 | 21 | - **`published Increment: TScrollBarInc default 8`** \ 22 | Determines how far the display moves when the user clicks one of the small end arrows on the scroll bar. 23 | 24 | - **`public Kind: TScrollBarKind`** (read-only) \ 25 | Indicates whether the scroll bar is horizontal or vertical. 26 | 27 | - **`published Margin: Word default 0`** \ 28 | Determines the minimum number of pixels that must separate a graph object from the edge of the [TSimpleGraph](TSimpleGraph.md) control. At runtime, whenever a graph object is less than `Margin` pixels from the edge and the `Visible` property is set to `true`, the scroll bar appears. 29 | 30 | - **`public Owner: TSimpleGraph`** (read-only) \ 31 | Determines the [TSimpleGraph](TSimpleGraph.md) control that owns this scroll bar. 32 | 33 | - **`published ParentColor: Boolean default true`** \ 34 | Specifies whether the scroll bar should use the color of its parent [TSimpleGraph](TSimpleGraph.md) control. 35 | 36 | When the value of the `Color` property is changed, the `ParentColor` property is automatically set to `false`. 37 | 38 | - **`published Position: Integer default 0`** \ 39 | Specifies the position of the thumb tab on the scroll bar. 40 | 41 | Use `Position` to programmatically scroll the client area of the [TSimpleGraph](TSimpleGraph.md) control. 42 | 43 | The value of `Position` changes (from 0 to `Range`) at runtime as the user scrolls the scroll bar. 44 | 45 | - **`public Range: Integer`** (read-only) \ 46 | Determines how far the scrolling region of the [TSimpleGraph](TSimpleGraph.md) control can move. 47 | 48 | - **`public ScrollPos: Integer`** (read-only) \ 49 | Indicates the position of the thumb tab. 50 | 51 | The read-only `ScrollPos` property gets the current value of the `Position` property when the scroll bar is visible. If the scroll bar is not visible, the value of this property is 0. 52 | 53 | - **`published Size: Integer default 0`** \ 54 | Specifies the scroll bar's size. 55 | 56 | If the scroll bar is horizontal, `Size` is the width of the scroll bar in pixels. 57 | 58 | If the scroll bar is vertical, `ButtonSize` is the height of the scroll bar in pixels. 59 | 60 | Set this property to zero to use the system's default size. 61 | 62 | - **`published Smooth: Boolean default false`** \ 63 | Specifies whether the amount the [TSimpleGraph](TSimpleGraph.md) control scrolls is dynamically computed. 64 | 65 | - **`published Style: TScrollBarStyle default ssRegular`** \ 66 | Determines whether the scroll bar appears three-dimensional, flat, or uses hot tracking. 67 | 68 | - **`published ThumbSize: Integer default 0`** \ 69 | Specifies the length of the scroll bar's thumb tab. 70 | 71 | - **`published Tracking: Boolean default false`** \ 72 | Determines whether the graph on the [TSimpleGraph](TSimpleGraph.md) control moves before the thumb tab is released. 73 | 74 | - **`published Visible: Boolean default true`** \ 75 | Determines whether the scroll bar appears. 76 | 77 | If `Visible` is set to `true`, the scroll bar appears whenever a graph object is less than `Margin` pixels from the edge of the [TSimpleGraph](TSimpleGraph.md) control. 78 | 79 | If `Visible` is set to `false`, the scroll bar is never visible. 80 | 81 | Methods 82 | ------- 83 | In addition to the methods of the `TPersistent` class, the `TGraphScrollBar` class has the following public method: 84 | 85 | - **`function IsScrollBarVisible: Boolean;`** \ 86 | Determines whether the scroll bar is currently visible on the [TSimpleGraph](TSimpleGraph.md) control. 87 | 88 | Returns `true` if the scroll bar is visible; otherwise, returns `false`. -------------------------------------------------------------------------------- /Docs/TMemoryHandleStream.md: -------------------------------------------------------------------------------- 1 | TMemoryHandleStream = class(TMemoryStream) 2 | ========================================== 3 | This class is similar to the Delphi's standard `TMemoryStream` class, except that it uses the Windows global heap. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the `TMemoryStream` class, the `TMemoryHandleStream` class has the following properties: 8 | 9 | - **`public Handle: THandle`** \ 10 | The handle to the memory allocated in the Windows global heap. 11 | 12 | - **`public ReleaseHandle: Boolean default false`** \ 13 | Specifies whether the instance should release the managed memory during destruction. 14 | 15 | Methods 16 | ------- 17 | In addition to the methods of the `TMemoryStream` class, the `TMemoryHandleStream` has the following method: 18 | 19 | - **`constructor Create(MemHandle: THandle);`** \ 20 | Creates an instance of the class. 21 | 22 | | Parameter | Description | 23 | |------------|---------------------------------------------------------------------------| 24 | | MemHandle | The handle to a memory allocated on the Windows global heap (can be zero) | 25 | -------------------------------------------------------------------------------- /Docs/TPolygonalNode.md: -------------------------------------------------------------------------------- 1 | TPolygonalNode = class([TGraphNode](Docs/TGraphNode.md)) 2 | ======================================================== 3 | This abstract class is the base class of the graph nodes that their shape can be represented by a polygon. 4 | 5 | Properties 6 | ---------- 7 | In addition to the properties of the [TGraphNode](Docs/TGraphNode.md) class, the `TPolygonalNode` class has the following property: 8 | 9 | - **`public Vertices: TPoints`** (read-only) \ 10 | `TPoints = array of TPoint` \ 11 | Gets the coordinates of the polygon's vertices as an array. 12 | 13 | Methods 14 | ------- 15 | In addition to the methods of the [TGraphNode](Docs/TGraphNode.md) class, the `TPolygonalNode` class has the following abstract method: 16 | 17 | - **`procedure DefineVertices(const ARect: TRect; var Points: TPoints); abstract;`** \ 18 | Calculates the coordinates of the polygon's vertices relative to its bounding box. 19 | 20 | | Parameter | Description | 21 | |-----------|--------------------------------------------------------------------------------------------------------------------------------| 22 | | ARect | The bounding box of the polygon | 23 | | Points | When the procedure returns, this dynamic array contains the coordinates of the polygon's vertices relative to the bounding box | 24 | 25 | For example, the `TRectangularNode` class overrides the `DefineVertices` method in the following way: 26 | 27 | ```pascal 28 | procedure TRectangularNode.DefineVertices(const ARect: TRect; var Points: TPoints); 29 | begin 30 | SetLength(Points, 4); 31 | Points[0].X := ARect.Left; 32 | Points[0].Y := ARect.Top; 33 | Points[1].X := ARect.Right; 34 | Points[1].Y := ARect.Top; 35 | Points[2].X := ARect.Right; 36 | Points[2].Y := ARect.Bottom; 37 | Points[3].X := ARect.Left; 38 | Points[3].Y := ARect.Bottom; 39 | end; 40 | ``` 41 | -------------------------------------------------------------------------------- /Docs/TSimpleGraph.Events.md: -------------------------------------------------------------------------------- 1 | TSimpleGraph Events 2 | =================== 3 | In addition to the events of the `TCustomControl` class, the [TSimpleGraph](TSimpleGraph.md) control defines the following events: 4 | 5 | - **`OnAfterDraw: TGraphDrawEvent`** \ 6 | `TGraphDrawEvent = procedure(Graph: TSimpleGraph; Canvas: TCanvas) of object` \ 7 | Occurs after the graph is drawn on a canvas. 8 | 9 | | Parameter | Description | 10 | |-------------|---------------------------------------------------------------| 11 | | Graph | The `TSimpleGraph` control, which owns the graph | 12 | | Canvas | The canvas where the graph is drawn on | 13 | 14 | - **`OnBeforeDraw: TGraphDrawEvent`** \ 15 | `TGraphDrawEvent = procedure(Graph: TSimpleGraph; Canvas: TCanvas) of object` \ 16 | Occurs when the graph is about to be drawn on a canvas. 17 | 18 | | Parameter | Description | 19 | |-------------|---------------------------------------------------------------| 20 | | Graph | The `TSimpleGraph` control, which owns the graph | 21 | | Canvas | The canvas` where the graph is about to be drawn on | 22 | 23 | - **`OnCanHookLink: TGraphCanHookEvent`** \ 24 | `TGraphCanHookEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Link: TGraphLink; Index: Integer; var CanHook: Boolean) of object` \ 25 | Occurs when an attempt is made to attach a point of a link to a graph object. 26 | 27 | | Parameter | Description | 28 | |-------------|-------------------------------------------------------------------| 29 | | Graph | The `TSimpleGraph` control, which owns the graph | 30 | | GraphObject | The graph object that the link is about to be attached to | 31 | | Link | The link that is being attached | 32 | | Index | The index of attaching point in the `Points` property of the link | 33 | | CanHook | Specifies whether the attachment is allowed to be made | 34 | 35 | - **`OnCanLinkObjects: TGraphCanLinkEvent`** \ 36 | `TGraphCanLinkEvent = procedure(Graph: TSimpleGraph; Link: TGraphLink; Source, Target: TGraphObject; var CanLink: Boolean) of object` \ 37 | Occurs when an attempt is made to connect two graph objects together via a link. 38 | 39 | | Parameter | Description | 40 | |-------------|-------------------------------------------------------------------| 41 | | Graph | The `TSimpleGraph` control, which owns the graph | 42 | | Link | The link that is about to connect the graph objects | 43 | | Source | The graph object that is the links's source object | 44 | | Target | The graph object that is the link's target object | 45 | | CanLink | Specifies whether the connection is allowed to be made | 46 | 47 | - **`OnCanMoveResizeNode: TCanMoveResizeNodeEvent`** \ 48 | `TCanMoveResizeNodeEvent = procedure(Graph: TSimpleGraph; Node: TGraphNode; var NewLeft, NewTop, NewWidth, NewHeight: Integer; var CanMove, CanResize: Boolean) of object` \ 49 | Occurs when an attempt is made to resize or relocate a node. 50 | 51 | | Parameter | Description | 52 | |-------------|-------------------------------------------------------------------| 53 | | Graph | The `TSimpleGraph` control, which owns the graph | 54 | | Node | The node that is about to be relocated and/or resized | 55 | | NewLeft | The new x-coordinate of the node's top-left corner | 56 | | NewTop | The new y-coordinate of the node's top-left corner | 57 | | NewWidth | The new width of the node | 58 | | NewHeight | The new height of the node | 59 | | CanMove | Specifies whether the node is relocatable | 60 | | CanResize | Specifies whether the node is resizable | 61 | 62 | - **`OnCanRemoveObject: TGraphCanRemoveEvent`** \ 63 | `TGraphCanRemoveEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; var CanRemove: Boolean) of object` \ 64 | Occurs when an attempt is made to delete a graph object. 65 | 66 | | Parameter | Description | 67 | |-------------|-------------------------------------------------------------------| 68 | | Graph | The `TSimpleGraph` control, which owns the graph | 69 | | GraphObject | The graph object that is about to be removed | 70 | | CanRemove | Specifies whether the graph object is removable | 71 | 72 | - **`OnCommandModeChange: TNotifyEvent`** \ 73 | Occurs just after the `CommandMode` property is changed. 74 | 75 | - **`OnGraphChange: TNotifyEvent`** \ 76 | Occurs just after the graph is changed. 77 | 78 | - **`OnInfoTip: TGraphInfoTipEvent`** \ 79 | `TGraphInfoTipEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; var InfoTip: String) of object`\ 80 | Occurs when the mouse pointer is paused over a graph object. 81 | 82 | | Parameter | Description | 83 | |-------------|--------------------------------------------------------------------| 84 | | Graph | The `TSimpleGraph` control, which owns the graph | 85 | | GraphObject | The graph object that the mouse pointer is over it | 86 | | InfoTip | The text that will be displayed as the tooltip of the graph object | 87 | 88 | - **`OnNodeMoveResize: TGraphNodeNotifyEvent`** \ 89 | Occurs when a node is moved and/or resized. 90 | 91 | | Parameter | Description | 92 | |-------------|--------------------------------------------------------------------| 93 | | Graph | The `TSimpleGraph` control, which owns the graph | 94 | | Node | The node that has been moved and/or resized | 95 | 96 | - **`OnObjectAfterDraw: TGraphObjectDrawEvent`** \ 97 | `TGraphObjectDrawEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Canvas: TCanvas) of object` \ 98 | Occurs after a graph is drawn on a canvas. 99 | 100 | | Parameter | Description | 101 | |-------------|---------------------------------------------------------------| 102 | | Graph | The `TSimpleGraph` control, which owns the graph | 103 | | GraphObject | The graph object that is drawn | 104 | | Canvas | The canvas where the graph object is drawn on | 105 | 106 | - **`OnObjectBeforeDraw: TGraphObjectDrawEvent`** \ 107 | `TGraphObjectDrawEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Canvas: TCanvas) of object` \ 108 | Occurs when a graph object is about to be drawn on a canvas. 109 | 110 | | Parameter | Description | 111 | |-------------|---------------------------------------------------------------| 112 | | Graph | The `TSimpleGraph` control, which owns the graph | 113 | | GraphObject | The graph object that is about to be drawn | 114 | | Canvas | The canvas where the graph object is about to be drawn on | 115 | 116 | - **`OnObjectBeginDrag: TGraphBeginDragEvent`** \ 117 | `TGraphBeginDragEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; HT: DWord) of object` \ 118 | Occurs just after a graph object is started being dragged. 119 | 120 | | Parameter | Description | 121 | |-------------|-----------------------------------------------------------------------------------------------------------| 122 | | Graph | The `TSimpleGraph` control, which owns the graph | 123 | | GraphObject | The graph object that is being dragged | 124 | | HT | Determines which part of the graph object is under the mouse pointer (see [hit-testing](TGraphObject.HitTesting.md)) | 125 | 126 | **Note:** The other selected objects may follow the drag operation but this event occurs only for the drag source. 127 | 128 | - **`OnObjectEndDrag: TGraphEndDragEvent`** \ 129 | `TGraphEndDragEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; HT: DWord; Canceled: Boolean) of object` \ 130 | Occurs just after a graph object is finished being dragged. 131 | 132 | | Parameter | Description | 133 | |-------------|-----------------------------------------------------------------------------------------------------------| 134 | | Graph | The `TSimpleGraph` control, which owns the graph | 135 | | GraphObject | The graph object that was being dragged | 136 | | HT | Determines which part of the graph object is under the mouse pointer (see [hit-testing](TGraphObject.HitTesting.md)) | 137 | | Canceled | Indicates whether the operation was canceled | 138 | 139 | **Note:** The other selected objects may follow the drag operation but this event occurs only for the drag source. 140 | 141 | - **`OnObjectChange: TGraphNotifyEvent`** \ 142 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 143 | Occurs when a graph object is changed. 144 | 145 | | Parameter | Description | 146 | |-------------|---------------------------------------------------------------| 147 | | Graph | The `TSimpleGraph` control, which owns the graph | 148 | | GraphObject | The graph object that is changed | 149 | 150 | - **`OnObjectClick: TGraphNotifyEvent`** \ 151 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 152 | Occurs when user clicks on a graph object. 153 | 154 | | Parameter | Description | 155 | |-------------|---------------------------------------------------------------| 156 | | Graph | The `TSimpleGraph` control, which owns the graph | 157 | | GraphObject | The graph object that is being clicked | 158 | 159 | - **`OnObjectDblClick: TGraphNotifyEvent`** \ 160 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 161 | Occurs when user double-clicks on a graph object. 162 | 163 | | Parameter | Description | 164 | |-------------|---------------------------------------------------------------| 165 | | Graph | The `TSimpleGraph` control, which owns the graph | 166 | | GraphObject | The graph object that is being double-clicked | 167 | 168 | - **`OnObjectContextPopup: TGraphContextPopupEvent`** \ 169 | `TGraphContextPopupEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; const MousePos: TPoint; var Handled: Boolean) of object` \ 170 | Occurs when user right-clicks on a graph object. 171 | 172 | | Parameter | Description | 173 | |-------------|---------------------------------------------------------------| 174 | | Graph | The `TSimpleGraph` control, which owns the graph | 175 | | GraphObject | The graph object that is being right-clicked | 176 | | MousePos | The position of the mouse pointer in client-area coordinates | 177 | | Handled | Specifies whether the default behavior should be bypassed | 178 | 179 | - **`OnObjectMouseEnter: TGraphNotifyEvent`** \ 180 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 181 | Occurs when the mouse pointer moves over a graph object. 182 | 183 | | Parameter | Description | 184 | |-------------|---------------------------------------------------------------| 185 | | Graph | The `TSimpleGraph` control, which owns the graph | 186 | | GraphObject | The graph object that the mouse pointer moved over it | 187 | 188 | - **`OnObjectMouseLeave: TGraphNotifyEvent`** \ 189 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 190 | Occurs when the mouse pointer moves off from over a graph object. 191 | 192 | | Parameter | Description | 193 | |-------------|----------------------------------------------------------------| 194 | | Graph | The `TSimpleGraph` control, which owns the graph | 195 | | GraphObject | The graph object that the mouse pointer moved off from over it | 196 | 197 | - **`OnObjectInitInstance: TGraphNotifyEvent`** \ 198 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 199 | Occurs when a new graph object is instantiated. 200 | 201 | | Parameter | Description | 202 | |-------------|---------------------------------------------------------------| 203 | | Graph | The `TSimpleGraph` control, which owns the graph | 204 | | GraphObject | The graph object that is instantiated | 205 | 206 | **Note:** When this event is triggered, the graph object is not placed on the graph yet. 207 | 208 | - **`OnObjectInsert: TGraphNotifyEvent`** \ 209 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 210 | Occurs when a new graph object is added to the graph. 211 | 212 | | Parameter | Description | 213 | |-------------|---------------------------------------------------------------| 214 | | Graph | The `TSimpleGraph` control, which owns the graph | 215 | | GraphObject | The newly added graph object | 216 | 217 | - **`OnObjectRemove: TGraphNotifyEvent`** \ 218 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 219 | Occurs when a new graph object is removed from the graph. 220 | 221 | | Parameter | Description | 222 | |-------------|---------------------------------------------------------------| 223 | | Graph | The `TSimpleGraph` control, which owns the graph | 224 | | GraphObject | The removed graph object | 225 | 226 | - **`OnObjectSelect: TGraphNotifyEvent`** \ 227 | `TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object` \ 228 | Occurs when the selection state of a graph object is changed. 229 | 230 | | Parameter | Description | 231 | |-------------|---------------------------------------------------------------| 232 | | Graph | The `TSimpleGraph` control, which owns the graph | 233 | | GraphObject | The graph object that its selection state is toggled | 234 | 235 | - **`OnObjectHook: TGraphHookEvent`** \ 236 | `TGraphHookEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Link: TGraphLink; Index: Integer) of object` \ 237 | Occurs when a point of a link is attached to a graph object. 238 | 239 | | Parameter | Description | 240 | |-------------|---------------------------------------------------------------| 241 | | Graph | The `TSimpleGraph` control, which owns the graph | 242 | | GraphObject | The graph object that the link is attached to | 243 | | Link | The link that is attached to the graph object | 244 | | Index | The index of the point in the `Points` property of the link | 245 | 246 | - **`OnObjectUnhook: TGraphHookEvent`** \ 247 | Occurs when a point of a link is detached from a graph object. 248 | 249 | | Parameter | Description | 250 | |-------------|---------------------------------------------------------------| 251 | | Graph | The `TSimpleGraph` control, which owns the graph | 252 | | GraphObject | The graph object that the link is detached from | 253 | | Link | The link that is detached from the graph object | 254 | | Index | The index of the point in the `Points` property of the link | 255 | 256 | - **`OnObjectRead: TGraphStreamEvent`** \ 257 | `TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object` \ 258 | Occurs when a graph object with custom data is being read from a stream. 259 | 260 | | Parameter | Description | 261 | |-------------|---------------------------------------------------------------| 262 | | Graph | The `TSimpleGraph` control, which owns the graph | 263 | | GraphObject | The graph object that is being read | 264 | | Stream | The stream where the custom data can be read from | 265 | 266 | - **`OnObjectWrite: TGraphStreamEvent`** \ 267 | `TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object` \ 268 | Occurs when a graph object with custom data is being written into a stream. 269 | 270 | | Parameter | Description | 271 | |-------------|---------------------------------------------------------------| 272 | | Graph | The `TSimpleGraph` control, which owns the graph | 273 | | GraphObject | The graph object that is being written | 274 | | Stream | The stream where the custom data can be written into | 275 | 276 | - **`OnZoomChange: TNotifyEvent`** \ 277 | Occurs just after the `Zoom` property is changed. -------------------------------------------------------------------------------- /Docs/TSimpleGraph.Keyboard.md: -------------------------------------------------------------------------------- 1 | KEYBOARD SHORTCUTS 2 | ================== 3 | The [TSimpleGraph](TSimpleGraph.md) control handles the following keyboard shortcuts by default. 4 | 5 | ## All Objects 6 | The following shortcut keys are available for all the graph objects. 7 | 8 | | Key | Behavior | 9 | |-----------------------|-----------------------------------------------------------------| 10 | | `Ctrl` | For some keyboard/mouse actions, toggles the snap to gird mode | 11 | | `Tab` | Selects the next selectable object | 12 | | `Shift`+`Tab` | Selects the previous selectable object | 13 | | `Left Arrow` | Moves left the movable objects in the selection | 14 | | `Right Arrow` | Moves right the movable objects in the selection | 15 | | `Up Arrow` | Moves up the movable objects in the selection | 16 | | `Down Arrow` | Moves down the movable objects in the selection to down | 17 | 18 | ## Nodes 19 | The following shortcut keys are available only for the graph nodes. 20 | 21 | | Key | Behavior | 22 | |-----------------------|-----------------------------------------------------------------| 23 | | `Shift`+`Left Arrow` | Decreases the width of resizable objects in the selection | 24 | | `Shift`+`Right Arrow` | Increases the width of resizable objects in the selection | 25 | | `Shift`+`Up Arrow` | Decreases the height of resizable objects in the selection | 26 | | `Shift`+`Down Arrow` | Increases the height of resizable objects in the selection | 27 | -------------------------------------------------------------------------------- /Docs/TSimpleGraph.Mouse.md: -------------------------------------------------------------------------------- 1 | MOUSE ACTIONS 2 | ============= 3 | The [TSimpleGraph](TSimpleGraph.md) control handles the following mouse actions by default. 4 | 5 | ## Design Area 6 | The following mouse actions are available when the action is performed on the client area of the control, but not on a graph object. 7 | 8 | | Action | Behavior | 9 | |---------------------|-----------------------------------------------------------------------------------------------------| 10 | | Drag | Selects the selectable objects in the selected area and clears the previous selection | 11 | | `Ctrl`+Drag | Selects the selectable nodes in the selected area and clears the previous selection | 12 | | `Shift`+Drag | Toggles selection of the selectable objects in the selected area while preserving the old selection | 13 | | `Ctrl`+`Shift`+Drag | Toggles selection of the selectable nodes in the selected area while preserving the old selection | 14 | | `Alt`+Drag | Zooms the selected area in | 15 | 16 | ## All Objects 17 | The following mouse actions are available for all the graph objects. 18 | 19 | | Action | Behavior | 20 | |---------------------|-----------------------------------------------------------------------------------------------------| 21 | | Click | Selects the clicked object if it is selectable and clears the previous selection | 22 | | `Shift`+Click | Toggles selection of the clicked object if it is selectable, preserving the old selection | 23 | 24 | ## Nodes 25 | The following mouse actions are available only for the graph nodes. 26 | 27 | | Action | Behavior | 28 | |---------------------|-----------------------------------------------------------------------------------------------------| 29 | | Drag Node | Moves the node if it is movable | 30 | | Drag Marker | Resizes the node if it is resizable | 31 | 32 | ## Links/Edges 33 | The following mouse actions are available only for the graph links/edges. 34 | 35 | | Action | Behavior | 36 | |---------------------|-----------------------------------------------------------------------------------------------------| 37 | | Drag Line/Caption | Moves the link if it does not have any fixed point | 38 | | Drag Point | Moves the point if it is not fixed | 39 | | `Alt`+Drag Point | Establishes a connection if the point is not fixed and is dropped on another object | 40 | | `Alt`+Click Point | Deletes the point if the point is not fixed | 41 | | `Alt`+Click Line | Inserts a new breakpoint at the clicked position if the line segment is not fixed | 42 | | `Right`+Click | Inserts a new breakpoint while a point is dragging | 43 | -------------------------------------------------------------------------------- /Docs/TSimpleGraph.Properties.md: -------------------------------------------------------------------------------- 1 | TSimpleGraph Properties 2 | ======================= 3 | In addition to the properties of the `TCustomControl` class, the [TSimpleGraph](TSimpleGraph.md) control has the following properties: 4 | 5 | - **`published ClipboardFormats: TGraphClipboardFormats default [cfNative]`** \ 6 | `TGraphClipboardFormats = set of (cfNative, cfMetafile, cfBitmap)` \ 7 | Specifies the formats that should be used for copying the graph contents into the Windows clipboard. 8 | 9 | | Value | Windows Value | Clipboard Content | 10 | |------------|----------------|-----------------------------------------------------------------------------------| 11 | | cfNative | CF_SIMPLEGRAPH | Native binary data (the only format supported by the `PasteFromClipboard` method) | 12 | | cfMetafile | CF_ENHMETAFILE | Enhanced metafile image | 13 | | cfBitmap | CF_BITMAP | Device dependent bitmap image | 14 | 15 | - **`public CommandMode: TGraphCommandMode`** \ 16 | `TGraphCommandMode = (cmViewOnly, cmEdit, cmInsertNode, cmLinkNodes)` \ 17 | Determines which set of commands are available to the user. 18 | 19 | | Value | Description | 20 | |--------------|-----------------------------------------------------------------------------| 21 | | cmViewOnly | User cannot interact with the graph | 22 | | cmPan | User can only pan the graph | 23 | | cmEdit | User can modify the existing graph nodes and links | 24 | | cmInsertNode | User can add a node; this mode changes to `cmEdit` after inserting the node | 25 | | cmLinkNodes | User can add a link; this mode changes to `cmEdit` after inserting the link | 26 | 27 | - **`public CursorPos: TPoint`** \ 28 | Gets or sets the position of mouse pointer in graph coordinates. 29 | 30 | - **`published DefaultKeyMap: Boolean default true`** \ 31 | Specifies whether the control should handle the keyboard shortcuts entered by the user. 32 | See [Keyboard Shortcuts](TSimpleGraph.Keyboard.md) for the default keyboard mapping. 33 | 34 | - **`public DefaultLinkClass: TGraphLinkClass`** \ 35 | `TGraphLinkClass = class of TGraphLink` \ 36 | Gets or sets the [TGraphLink](TGraphLink.md) class that should be used when adding a new link to a graph. 37 | 38 | - **`public DefaultNodeClass: TGraphNodeClass`** \ 39 | `TGraphNodeClass = class of TGraphNode` \ 40 | Gets or sets the [TGraphNode](TGraphNode.md) class that should be used when adding a new node to a graph. 41 | 42 | - **`public DragSource: TGraphObject`** (read-only) \ 43 | Gets the [TGraphObject](TGraphObject.md) instance that is the source of a drag operation, or `nil` if there is none. 44 | 45 | - **`public DraggingBounds: TRect`** (read-only) \ 46 | Gets the smallest visual bounding rectangle of the graph objects, which are being dragged. The values are in graph coordinates. 47 | 48 | - **`public DraggingObjects: TGraphObjectList`** (read-only) \ 49 | Gets the [TGraphObjectList](TGraphObjectList.md) instance, which contains the graph objects being dragged. 50 | 51 | - **`published DrawOrder: TGraphDrawOrder default doDefault`** \ 52 | Specifies the z-order of the graph objects. 53 | 54 | | Value | Description | 55 | |--------------|----------------------------------------------| 56 | | doDefault | The objects are drawn in their natural order | 57 | | doNodesOnTop | The nodes appear above the links | 58 | | doLinksOnTop | The links appear above the nodes | 59 | 60 | - **`published FixedScrollBars: Boolean false`** \ 61 | Determines how range of the scroll bars should be calculated. 62 | 63 | If `FixedScrollBars` is set to `true`, the range of the scroll bars is set to the maximum permitted dimensions of the graph. 64 | 65 | If `FixedScrollBars` is set to `false`, the range of the scroll bars is measured using the current dimensions of the graph. 66 | 67 | - **`public GraphBounds: TRect`** (read-only) \ 68 | Gets the smallest visual bounding rectangle of the visible graph objects. 69 | 70 | - **`published GraphConstraints: TGraphConstraints`** (read-only) \ 71 | Gets the [TGraphConstraints](TGraphObjectList.md) instance that specifies the bounding constraints of the graphs. 72 | 73 | - **`published GridColor: TColor default clGray`** \ 74 | Determines the color of the grid. 75 | 76 | - **`published GridSize: TGridSize default 8`** \ 77 | `TGridSize = 4..128` \ 78 | Determines the grid's spacing along the x- and y-axis. 79 | 80 | - **`published HideSelection: Boolean default false`** \ 81 | Specifies whether the visual indication of the selected graph objects should remain when focus shifts to another control. 82 | 83 | - **`published HorzScrollBar: TGraphScrollBar`** (read-only) \ 84 | Gets the [TGraphScrollBar](TGraphScrollBar.md) instance that represents the horizontal scroll bar. 85 | 86 | - **`published LockLinks: Boolean default false`** \ 87 | Specifies whether the users are disallowed to move the links/edges of the graph. 88 | 89 | - **`published LockNodes: Boolean default false`** \ 90 | Specifies whether the users are disallowed to move and resize the nodes of the graph. 91 | 92 | - **`published MarkerColor: TColor default clBlack`** \ 93 | Determines the color of the markers on the selected graph objects. 94 | 95 | - **`published MarkerSize: TMarkerSize default 3`** \ 96 | `TMarkerSize = 3..9` \ 97 | Determines the size of the markers on the selected graph objects. 98 | 99 | - **`published MinNodeSize: default 16`** \ 100 | Specifies the minimum width and height of the nodes of the graph. 101 | 102 | - **`public Modified: Boolean`** (read-only) \ 103 | Indicates wether the graph has been changed. 104 | 105 | - **`public ObjectAtCursor: TGraphObject`** (read-only) \ 106 | Gets the [TGraphObject](TGraphObject.md) instance that is currently under the mouse pointer, or `nil` if there is none. 107 | 108 | - **`published ObjectPopupMenu: TPopupMenu`** \ 109 | Determines the popup menu of the graph objects. 110 | 111 | - **`public Objects: TGraphObjectList`** (read-only) \ 112 | Gets the [TGraphObjectList](TGraphObjectList.md) instance, which contains all the graph objects. 113 | 114 | - **`public SelectedObjects: TGraphObjectList`** (read-only) \ 115 | Gets the [TGraphObjectList](TGraphObjectList.md) instance, which contains the selected graph objects. 116 | 117 | - **`public SelectionBounds: TRect`** (read-only) \ 118 | Gets the smallest visual bounding rectangle of the selected graph objects. The values are in graph coordinates. 119 | 120 | - **`published ShowGrid: Boolean default true`** \ 121 | Specifies whether the grid should appear on the control. 122 | 123 | - **`published ShowHiddenObjects: Boolean default false`** \ 124 | Indicates whether the control should show the hidden graph objects. 125 | 126 | - **`published SnapToGrid: Boolean default true`** \ 127 | Indicates whether the graph objects are automatically aligned with the grid when they are placed, moved, or resized. 128 | 129 | - **`published Transparent: Boolean default false`** \ 130 | Specifies whether the background of the control is transparent. 131 | 132 | - **`published VertScrollBar: TGraphScrollBar`** \ 133 | Gets the [TGraphScrollBar](TGraphScrollBar.md) instance that represents the vertical scroll bar. 134 | 135 | - **`public VisibleBounds: TRect`** (read-only) \ 136 | Gets the bounding rectangle of the visible part of the graph. The values are in graph coordinates. 137 | 138 | - **`published Zoom: TZoom default 100`** \ 139 | `TZoom = 5..36863` \ 140 | Specifies the display scaling factor of the graph on the control in percent. 141 | -------------------------------------------------------------------------------- /Docs/TSimpleGraph.md: -------------------------------------------------------------------------------- 1 | TSimpleGraph = class (TCustomControl) 2 | ===================================== 3 | This control provides a canvas for displaying and drawing of [simple directed graphs](https://mathworld.wolfram.com/SimpleDirectedGraph.html). 4 | 5 | The control can export and import graphs as DFM format. The graphs can also be exported as image files or printed directly on a printer. 6 | 7 | The control keeps the graph nodes and edges as a collection of [TGraphObject](TGraphObject.md) instances. 8 | 9 | See also: 10 | - [Control's Properties](TSimpleGraph.Properties.md) 11 | - [Control's Events](TSimpleGraph.Events.md) 12 | - [Control's Methods](TSimpleGraph.Methods.md) 13 | - [Keyboard Shortcuts](TSimpleGraph.Keyboard.md) 14 | - [Mouse Actions](TSimpleGraph.Mouse.md) 15 | -------------------------------------------------------------------------------- /Examples/Editor/AboutDelphiArea.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/AboutDelphiArea.dfm -------------------------------------------------------------------------------- /Examples/Editor/AboutDelphiArea.pas: -------------------------------------------------------------------------------- 1 | unit AboutDelphiArea; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, ExtCtrls, StdCtrls; 8 | 9 | type 10 | TAbout = class(TForm) 11 | Bevel1: TBevel; 12 | btnOk: TButton; 13 | Label1: TLabel; 14 | Label2: TLabel; 15 | Label3: TLabel; 16 | Image1: TImage; 17 | Shape1: TShape; 18 | Label4: TLabel; 19 | procedure FormCreate(Sender: TObject); 20 | end; 21 | 22 | 23 | implementation 24 | 25 | {$R *.dfm} 26 | 27 | procedure TAbout.FormCreate(Sender: TObject); 28 | begin 29 | SetBounds(Screen.Width - Width - 30, 50, Width, Height); 30 | end; 31 | 32 | end. 33 | -------------------------------------------------------------------------------- /Examples/Editor/AlignDlg.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/AlignDlg.dfm -------------------------------------------------------------------------------- /Examples/Editor/AlignDlg.pas: -------------------------------------------------------------------------------- 1 | unit AlignDlg; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, StdCtrls, ExtCtrls; 8 | 9 | type 10 | TAlignDialog = class(TForm) 11 | Horz: TRadioGroup; 12 | Vert: TRadioGroup; 13 | btnOK: TButton; 14 | btnCancel: TButton; 15 | public 16 | class function Execute(out HorzAlign: THAlignOption; 17 | out VertAlign: TVAlignOption): Boolean; 18 | end; 19 | 20 | implementation 21 | 22 | {$R *.dfm} 23 | 24 | class function TAlignDialog.Execute(out HorzAlign: THAlignOption; 25 | out VertAlign: TVAlignOption): Boolean; 26 | begin 27 | Result := False; 28 | with Create(Application) do 29 | try 30 | if ShowModal = mrOK then 31 | begin 32 | HorzAlign := THAlignOption(Horz.ItemIndex); 33 | VertAlign := TVAlignOption(Vert.ItemIndex); 34 | Result := True; 35 | end; 36 | finally 37 | Free; 38 | end; 39 | end; 40 | 41 | end. 42 | -------------------------------------------------------------------------------- /Examples/Editor/DesignProp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/DesignProp.dfm -------------------------------------------------------------------------------- /Examples/Editor/DesignProp.pas: -------------------------------------------------------------------------------- 1 | unit DesignProp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, ExtCtrls, StdCtrls, ComCtrls; 8 | 9 | type 10 | TDesignerProperties = class(TForm) 11 | Grid: TGroupBox; 12 | ShowGrid: TCheckBox; 13 | Label1: TLabel; 14 | SnapToGrid: TCheckBox; 15 | Colors: TGroupBox; 16 | Label2: TLabel; 17 | DesignerBackgroundColor: TPanel; 18 | Label3: TLabel; 19 | DesignerMarkerColor: TPanel; 20 | Label4: TLabel; 21 | DesignerGridColor: TPanel; 22 | btnOK: TButton; 23 | btnCancel: TButton; 24 | Bevel1: TBevel; 25 | ColorDialog: TColorDialog; 26 | btnApply: TButton; 27 | Edit1: TEdit; 28 | GridSize: TUpDown; 29 | BackgroundColor: TShape; 30 | MarkerColor: TShape; 31 | GridColor: TShape; 32 | procedure DesignerBackgroundColorClick(Sender: TObject); 33 | procedure DesignerMarkerColorClick(Sender: TObject); 34 | procedure DesignerGridColorClick(Sender: TObject); 35 | procedure btnApplyClick(Sender: TObject); 36 | procedure FormCreate(Sender: TObject); 37 | private 38 | S: TSimpleGraph; 39 | procedure ApplyChanges; 40 | public 41 | class function Execute(SimpleGraph: TSimpleGraph): Boolean; 42 | end; 43 | 44 | implementation 45 | 46 | {$R *.dfm} 47 | 48 | { TDesignerProperties } 49 | 50 | class function TDesignerProperties.Execute(SimpleGraph: TSimpleGraph): Boolean; 51 | begin 52 | Result := False; 53 | with Create(Application) do 54 | try 55 | S := SimpleGraph; 56 | GridSize.Min := Low(TGridSize); 57 | GridSize.Max := High(TGridSize); 58 | SnapToGrid.Checked := SimpleGraph.SnapToGrid; 59 | ShowGrid.Checked := SimpleGraph.ShowGrid; 60 | GridSize.Position := SimpleGraph.GridSize; 61 | BackgroundColor.Brush.Color := SimpleGraph.Color; 62 | MarkerColor.Brush.Color := SimpleGraph.MarkerColor; 63 | GridColor.Brush.Color := SimpleGraph.GridColor; 64 | if ShowModal = mrOK then 65 | begin 66 | ApplyChanges; 67 | Result := True; 68 | end; 69 | finally 70 | Free; 71 | end; 72 | end; 73 | 74 | procedure TDesignerProperties.ApplyChanges; 75 | begin 76 | S.BeginUpdate; 77 | try 78 | S.SnapToGrid := SnapToGrid.Checked; 79 | S.ShowGrid := ShowGrid.Checked; 80 | S.GridSize := GridSize.Position; 81 | S.Color := BackgroundColor.Brush.Color; 82 | S.MarkerColor := MarkerColor.Brush.Color; 83 | S.GridColor := GridColor.Brush.Color; 84 | finally 85 | S.EndUpdate; 86 | end; 87 | end; 88 | 89 | procedure TDesignerProperties.DesignerBackgroundColorClick(Sender: TObject); 90 | begin 91 | ColorDialog.Color := BackgroundColor.Brush.Color; 92 | if ColorDialog.Execute then 93 | BackgroundColor.Brush.Color := ColorDialog.Color; 94 | end; 95 | 96 | procedure TDesignerProperties.DesignerMarkerColorClick(Sender: TObject); 97 | begin 98 | ColorDialog.Color := MarkerColor.Brush.Color; 99 | if ColorDialog.Execute then 100 | MarkerColor.Brush.Color := ColorDialog.Color; 101 | end; 102 | 103 | procedure TDesignerProperties.DesignerGridColorClick(Sender: TObject); 104 | begin 105 | ColorDialog.Color := GridColor.Brush.Color; 106 | if ColorDialog.Execute then 107 | GridColor.Brush.Color := ColorDialog.Color; 108 | end; 109 | 110 | procedure TDesignerProperties.btnApplyClick(Sender: TObject); 111 | begin 112 | ApplyChanges; 113 | end; 114 | 115 | procedure TDesignerProperties.FormCreate(Sender: TObject); 116 | begin 117 | SetBounds(Screen.Width - Width - 30, 50, Width, Height); 118 | end; 119 | 120 | end. 121 | -------------------------------------------------------------------------------- /Examples/Editor/Keyboard.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}} 2 | {\*\generator Riched20 10.0.22000}\viewkind4\uc1 3 | \pard\ul\b\f0\fs28 GENERAL\fs20\par 4 | \par 5 | 6 | \pard\li360\ulnone CTRL\b0\tab\tab\lang8192 T\lang1033 oggles\lang2057 the \lang1033 snap\lang8192 \lang1033 to\lang2057 \lang1033 gird\lang2057 \lang1033 mode\lang8192 for some\par 7 | keyboard/mouse actions\lang1033 .\par 8 | \par 9 | \b TAB\b0\tab\tab Selects\lang2057 \lang1033 the\lang2057 \lang1033 next\lang2057 \lang1033 selectable\lang2057 \lang1033 object.\par 10 | \par 11 | \b SHIFT+TAB\b0\tab Selectes\lang2057 \lang1033 the\lang2057 \lang1033 previous\lang2057 \lang1033 selectable\lang2057 \lang1033 object.\par 12 | \par 13 | \b LEFT\b0\tab\tab Moves\lang2057 \lang1033 left\lang2057 the \lang1033 selected\lang2057 \lang1033 movable\lang2057 \lang1033 objects.\par 14 | \par 15 | \b RIGHT\b0\tab\tab Moves\lang2057 \lang1033 right\lang2057 the \lang1033 selected\lang2057 \lang1033 movable\lang2057 \lang1033 objects.\par 16 | \par 17 | \b UP\b0\tab\tab\tab Moves\lang2057 \lang1033 up\lang2057 the \lang1033 selected\lang2057 \lang1033 movable\lang2057 \lang1033 objects.\par 18 | \par 19 | \b DOWN\b0\tab\tab Moves\lang2057 \lang1033 down\lang2057 the \lang1033 selected\lang2057 \lang1033 movable\lang2057 \lang1033 objects.\par 20 | 21 | \pard\par 22 | \par 23 | \par 24 | \ul\b\fs28 NODES\fs20\par 25 | \par 26 | 27 | \pard\li360\ulnone SHIFT+LEFT\b0\tab Decreases\lang2057 the \lang1033 width\lang2057 \lang1033 of\lang2057 the \lang1033 selected\lang2057 \lang1033 resizable\lang8192\par 28 | \lang1033 nodes.\par 29 | \par 30 | \b SHIFT+RIGHT\b0\tab Increases\lang2057 the \lang1033 width\lang2057 \lang1033 of\lang2057 the \lang1033 selected\lang2057 \lang1033 resizable\lang2057\par 31 | \lang8192 \lang1033 nodes.\par 32 | \par 33 | \b SHIFT+UP\b0\tab\tab Decreases\lang2057 the \lang1033 height\lang2057 \lang1033 of\lang2057 the \lang1033 selected\lang2057 \lang1033 resizable\lang2057\par 34 | \lang8192 \lang1033 nodes.\par 35 | \par 36 | \b SHIFT+DOWN\b0\tab Increases\lang2057 the \lang1033 height\lang2057 \lang1033 of\lang2057 the \lang1033 selected\lang2057 \lang1033 resizable\lang2057\par 37 | \lang8192 \lang1033 nodes.\par 38 | 39 | \pard\par 40 | } 41 | -------------------------------------------------------------------------------- /Examples/Editor/LinkProp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/LinkProp.dfm -------------------------------------------------------------------------------- /Examples/Editor/LinkProp.pas: -------------------------------------------------------------------------------- 1 | unit LinkProp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, ExtCtrls, StdCtrls, CheckLst, ComCtrls; 8 | 9 | type 10 | TLinkProperties = class(TForm) 11 | Label1: TLabel; 12 | LinkLabel: TEdit; 13 | Style: TGroupBox; 14 | StyleSolid: TRadioButton; 15 | Shape1: TShape; 16 | Shape2: TShape; 17 | Shape3: TShape; 18 | StyleDash: TRadioButton; 19 | StyleDot: TRadioButton; 20 | Colors: TGroupBox; 21 | Label2: TLabel; 22 | Label3: TLabel; 23 | LinkLineColor: TPanel; 24 | LinkStyleColor: TPanel; 25 | btnChangeFont: TButton; 26 | btnOK: TButton; 27 | btnCancel: TButton; 28 | Bevel1: TBevel; 29 | FontDialog: TFontDialog; 30 | ColorDialog: TColorDialog; 31 | btnApply: TButton; 32 | Label4: TLabel; 33 | AllOptions: TCheckListBox; 34 | LabelPlacement: TGroupBox; 35 | Edit4: TEdit; 36 | LabelPosition: TUpDown; 37 | Size: TGroupBox; 38 | Edit1: TEdit; 39 | PenWidth: TUpDown; 40 | LineBegin: TGroupBox; 41 | Label5: TLabel; 42 | LineBeginStyle: TComboBox; 43 | Label6: TLabel; 44 | Edit2: TEdit; 45 | LineBeginSize: TUpDown; 46 | LineEnd: TGroupBox; 47 | Label7: TLabel; 48 | Label8: TLabel; 49 | LineEndStyle: TComboBox; 50 | Edit3: TEdit; 51 | LineEndSize: TUpDown; 52 | LineColor: TShape; 53 | StyleColor: TShape; 54 | Label9: TLabel; 55 | Label10: TLabel; 56 | Edit5: TEdit; 57 | LabelSpacing: TUpDown; 58 | procedure LinkLineColorClick(Sender: TObject); 59 | procedure LinkStyleColorClick(Sender: TObject); 60 | procedure btnChangeFontClick(Sender: TObject); 61 | procedure btnApplyClick(Sender: TObject); 62 | procedure FormCreate(Sender: TObject); 63 | private 64 | S: TSimpleGraph; 65 | L: TGraphObjectList; 66 | procedure SetObjectOptions(Value: TGraphObjectOptions); 67 | function GetObjectOptions: TGraphObjectOptions; 68 | procedure SetLinkOptions(Value: TGraphLinkOptions); 69 | function GetLinkOptions: TGraphLinkOptions; 70 | procedure ApplyChanges; 71 | public 72 | class function Execute(Links: TGraphObjectList): Boolean; 73 | end; 74 | 75 | implementation 76 | 77 | {$R *.dfm} 78 | 79 | { TLinkProperties } 80 | 81 | class function TLinkProperties.Execute(Links: TGraphObjectList): Boolean; 82 | begin 83 | Result := False; 84 | with Create(Application) do 85 | try 86 | L := Links; 87 | with TGraphLink(Links[0]) do 88 | begin 89 | S := Owner; 90 | LinkLabel.Text := Text; 91 | LabelPosition.Position := TextPosition; 92 | LabelSpacing.Position := TextSpacing; 93 | PenWidth.Position := Pen.Width; 94 | case Pen.Style of 95 | psSolid: StyleSolid.Checked := True; 96 | psDash: StyleDash.Checked := True; 97 | psDot: StyleDot.Checked := True; 98 | end; 99 | LineColor.Brush.Color := Pen.Color; 100 | StyleColor.Brush.Color := Brush.Color; 101 | LineBeginStyle.ItemIndex := Ord(BeginStyle); 102 | LineBeginSize.Position := BeginSize; 103 | LineEndStyle.ItemIndex := Ord(EndStyle); 104 | LineEndSize.Position := EndSize; 105 | FontDialog.Font := Font; 106 | SetObjectOptions(Options); 107 | SetLinkOptions(LinkOptions); 108 | end; 109 | if ShowModal = mrOK then 110 | begin 111 | ApplyChanges; 112 | Result := True; 113 | end; 114 | finally 115 | Free; 116 | end; 117 | end; 118 | 119 | procedure TLinkProperties.ApplyChanges; 120 | var 121 | I: Integer; 122 | begin 123 | S.BeginUpdate; 124 | try 125 | for I := 0 to L.Count - 1 do 126 | with TGraphLink(L[I]) do 127 | begin 128 | BeginUpdate; 129 | try 130 | Text := LinkLabel.Text; 131 | TextPosition := LabelPosition.Position; 132 | TextSpacing := LabelSpacing.Position; 133 | Pen.Width := PenWidth.Position; 134 | if StyleSolid.Checked then 135 | Pen.Style := psSolid 136 | else if StyleDash.Checked then 137 | Pen.Style := psDash 138 | else if StyleDot.Checked then 139 | Pen.Style := psDot; 140 | Pen.Color := LineColor.Brush.Color; 141 | Brush.Color := StyleColor.Brush.Color; 142 | BeginStyle := TLinkBeginEndStyle(LineBeginStyle.ItemIndex); 143 | BeginSize := LineBeginSize.Position; 144 | EndStyle := TLinkBeginEndStyle(LineEndStyle.ItemIndex); 145 | EndSize := LineEndSize.Position; 146 | Font := FontDialog.Font; 147 | Options := GetObjectOptions; 148 | LinkOptions := GetLinkOptions; 149 | finally 150 | EndUpdate; 151 | end; 152 | end; 153 | finally 154 | S.EndUpdate; 155 | end; 156 | end; 157 | 158 | procedure TLinkProperties.LinkLineColorClick(Sender: TObject); 159 | begin 160 | ColorDialog.Color := LineColor.Brush.Color; 161 | if ColorDialog.Execute then 162 | LineColor.Brush.Color := ColorDialog.Color; 163 | end; 164 | 165 | procedure TLinkProperties.LinkStyleColorClick(Sender: TObject); 166 | begin 167 | ColorDialog.Color := StyleColor.Brush.Color; 168 | if ColorDialog.Execute then 169 | StyleColor.Brush.Color := ColorDialog.Color; 170 | end; 171 | 172 | procedure TLinkProperties.btnChangeFontClick(Sender: TObject); 173 | begin 174 | FontDialog.Execute; 175 | end; 176 | 177 | procedure TLinkProperties.btnApplyClick(Sender: TObject); 178 | begin 179 | ApplyChanges; 180 | end; 181 | 182 | procedure TLinkProperties.FormCreate(Sender: TObject); 183 | begin 184 | SetBounds(Screen.Width - Width - 30, 50, Width, Height); 185 | end; 186 | 187 | function TLinkProperties.GetObjectOptions: TGraphObjectOptions; 188 | var 189 | Option: TGraphObjectOption; 190 | begin 191 | Result := []; 192 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 193 | if AllOptions.Checked[Ord(Option)] then 194 | Include(Result, Option); 195 | end; 196 | 197 | procedure TLinkProperties.SetObjectOptions(Value: TGraphObjectOptions); 198 | var 199 | Option: TGraphObjectOption; 200 | begin 201 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 202 | AllOptions.Checked[Ord(Option)] := Option in Value; 203 | end; 204 | 205 | function TLinkProperties.GetLinkOptions: TGraphLinkOptions; 206 | var 207 | Option: TGraphLinkOption; 208 | begin 209 | Result := []; 210 | for Option := Low(TGraphLinkOption) to High(TGraphLinkOption) do 211 | if AllOptions.Checked[Ord(Option) + Ord(High(TGraphObjectOption)) + 1] then 212 | Include(Result, Option); 213 | end; 214 | 215 | procedure TLinkProperties.SetLinkOptions(Value: TGraphLinkOptions); 216 | var 217 | Option: TGraphLinkOption; 218 | begin 219 | for Option := Low(TGraphLinkOption) to High(TGraphLinkOption) do 220 | AllOptions.Checked[Ord(Option) + Ord(High(TGraphObjectOption)) + 1] := Option in Value; 221 | end; 222 | 223 | end. 224 | -------------------------------------------------------------------------------- /Examples/Editor/Main.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/Main.dfm -------------------------------------------------------------------------------- /Examples/Editor/MarginsProp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/MarginsProp.dfm -------------------------------------------------------------------------------- /Examples/Editor/MarginsProp.pas: -------------------------------------------------------------------------------- 1 | unit MarginsProp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, ComCtrls, StdCtrls; 8 | 9 | type 10 | TMarginDialog = class(TForm) 11 | btnOK: TButton; 12 | btnCancel: TButton; 13 | GroupBox1: TGroupBox; 14 | Edit1: TEdit; 15 | mLeft: TUpDown; 16 | Edit2: TEdit; 17 | mTop: TUpDown; 18 | Edit3: TEdit; 19 | mRight: TUpDown; 20 | Edit4: TEdit; 21 | mBottom: TUpDown; 22 | public 23 | class function Execute(var Margins: TRect): Boolean; 24 | end; 25 | 26 | implementation 27 | 28 | {$R *.dfm} 29 | 30 | { TMarginDialog } 31 | 32 | class function TMarginDialog.Execute(var Margins: TRect): Boolean; 33 | begin 34 | Result := True; 35 | with Create(Application) do 36 | try 37 | mLeft.Position := Margins.Left; 38 | mTop.Position := Margins.Top; 39 | mRight.Position := Margins.Right; 40 | mBottom.Position := Margins.Bottom; 41 | if ShowModal = mrOK then 42 | begin 43 | Margins.Left := mLeft.Position; 44 | Margins.Top := mTop.Position; 45 | Margins.Right := mRight.Position; 46 | Margins.Bottom := mBottom.Position; 47 | Result := True; 48 | end; 49 | finally 50 | Free; 51 | end; 52 | end; 53 | 54 | end. 55 | -------------------------------------------------------------------------------- /Examples/Editor/Mouse.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}} 2 | {\*\generator Riched20 10.0.22000}\viewkind4\uc1 3 | \pard\ul\b\f0\fs28 GENERAL\fs20\par 4 | \par 5 | 6 | \pard\li360\ulnone CLICK\b0\tab\tab\lang2057 \lang1033 Selects\lang2057 \lang1033 the\lang2057 \lang1033 clicked\lang2057 \lang1033 object\lang2057 \lang1033 if\lang2057 \lang1033 it\lang2057 \lang1033 is\lang2057 \lang1033 selectable\par 7 | \tab\tab\tab\lang2057 \lang1033 and\lang2057 \lang1033 clears\lang2057 the \lang1033 previous\lang2057 \lang1033 selection.\par 8 | \par 9 | \b SHIFT+CLICK\b0\tab\lang2057 \lang1033 Toggles\lang2057 \lang1033 selection\lang2057 \lang1033 of\lang2057 \lang1033 the\lang2057 \lang1033 clicked\lang2057 \lang1033 object\lang2057 while \lang1033\par 10 | \tab\tab\tab\lang2057 \lang1033 keep\lang2057 ing \lang1033 the\lang2057 \lang1033 old\lang2057 \lang1033 selection.\lang2057 The non-selectable \lang1033\tab\tab\tab\lang2057 objects are ignored\lang1033 .\par 11 | \par 12 | \par 13 | 14 | \pard\ul\b\fs28 DESIGNER\fs20\par 15 | \par 16 | 17 | \pard\li360\ulnone DRAG\b0\tab\tab\lang2057 \lang1033 Selects\lang2057 the \lang1033 selectable\lang2057 \lang1033 objects\lang2057 \lang1033 in\lang2057 \lang1033 the\lang2057 \lang1033 selected\par 18 | \tab\tab\tab\lang2057 \lang1033 area\lang2057 \lang1033 and\lang2057 \lang1033 clears\lang2057 the \lang1033 previous\lang2057 \lang1033 selection.\lang8192 \lang2057 The \par 19 | \lang1033\tab\tab\tab\lang2057 non-selectable objects are ignored\lang1033 .\lang2057 Holding the\par 20 | \lang1033\tab\tab\tab\lang2057 \b CTRL\b0 key down\lang8192 \lang2057 causes only the node objects get\par 21 | \lang1033\tab\tab\tab\lang2057 selected. \lang1033\par 22 | \par 23 | \b SHIFT+DRAG\b0\tab\lang2057 \lang1033 Toggles\lang2057 \lang1033 selection\lang2057 \lang1033 of\lang2057 \lang1033 the\lang2057 \lang1033 objects\lang2057 \lang1033 in\lang2057 \lang1033 the\lang2057\par 24 | \lang1033\tab\tab\tab\lang2057 \lang8192 \lang1033 selected\lang2057 \lang1033 area\lang2057 while \lang1033 keep\lang2057 ing \lang1033 the\lang2057 \lang1033 old\lang2057 \lang1033 selection.\lang2057 \lang1033\tab\tab\tab\lang2057 The non-selectable\lang8192 \lang2057 objects are ignored\lang1033 .\lang2057 Holding \lang1033\tab\tab\tab\lang2057 the\lang8192 \b\lang2057 CTRL\b0 key down causes the selection of only \lang1033\tab\tab\tab\lang2057 the\lang8192 \lang2057 node objects get toggled.\lang1033\par 25 | \par 26 | \b ALT+DRAG\b0\tab\tab\lang2057 \lang1033 Zooms\lang2057 \lang1033 the\lang2057 \lang8192 marked\lang2057 \lang1033 area\lang8192 in\lang1033 .\par 27 | \par 28 | \par 29 | 30 | \pard\ul\b\fs28 NODES\fs20\par 31 | \par 32 | 33 | \pard\li360\ulnone DRAG\lang2057 \lang8192 NODE\lang1033\tab\lang2057 \b0 \lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 node\lang2057 \lang1033 is\lang2057 \lang1033 movable,\lang2057 \lang1033 moves\lang2057 \lang1033 the\lang2057 \lang1033 node.\par 34 | \par 35 | \b DRAG\lang2057 \lang1033 MARKER\b0\tab\lang2057 \lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 node\lang2057 \lang1033 is\lang2057 \lang1033 resizable,\lang2057 \lang1033 resize\lang2057 \lang1033 the\lang2057 \lang1033 node.\par 36 | \par 37 | \par 38 | 39 | \pard\ul\b\fs28 LINKS\fs20\par 40 | \par 41 | 42 | \pard\li360\ulnone DRAG\lang2057 \lang8192 LINE/CAPTION\lang2057 \b0\lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 link\lang2057 \lang1033 does\lang2057 \lang1033 not\lang2057 \lang1033 have\lang2057 \lang1033 any\lang2057 \lang1033 fixed\lang2057 \lang1033 point,\lang2057\par 43 | \lang1033\tab\tab\tab\lang2057 \lang1033 moves\lang2057 \lang1033 the\lang2057 \lang1033 link.\par 44 | \par 45 | \b DRAG\lang2057 \lang1033 POINT\b0\tab\lang2057 \lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 point\lang2057 \lang1033 is\lang2057 \lang1033 not\lang2057 \lang1033 fixed,\lang2057 \lang1033 moves\lang2057 \lang1033 the\lang2057 \lang1033 point.\lang2057 \lang1033 If\lang2057 \lang1033\par 46 | \tab\tab\tab\lang2057 \lang1033 the\lang2057 \lang1033 point\lang2057 \lang1033 is\lang2057 \lang1033 an\lang2057 \lang1033 endpoint\lang2057 \lang1033 and\lang2057 the \b\lang1033 ALT\b0\lang2057 \lang1033 key\lang2057 \lang1033 is\lang2057 \lang1033 not\lang2057 \lang1033\par 47 | \tab\tab\tab\lang2057 \lang1033 down,\lang2057 \lang1033 dropping\lang2057 \lang1033 the\lang2057 \lang1033 point\lang2057 \lang1033 on\lang2057 \lang1033 an\lang2057 \lang1033 object\lang2057 \lang1033\par 48 | \tab\tab\tab\lang2057 e\lang1033 stablishes\lang2057 \lang1033 a\lang2057 \lang1033 link.\lang2057 \lang1033\par 49 | \par 50 | \b ALT+CLICK\lang2057 \lang1033 POINT\lang2057 \b0 \lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 point\lang2057 \lang1033 is\lang2057 \lang1033 not\lang2057 \lang1033 fixed,\lang2057 \lang1033 removes\lang2057 \lang1033 the\lang2057 \lang1033 point.\par 51 | \par 52 | \b ALT+CLICK\lang2057 \lang1033 LINE\tab\lang2057 \b0 \lang1033 If\lang2057 \lang1033 the\lang2057 \lang1033 link\lang2057 \lang1033 is\lang2057 \lang1033 not\lang2057 \lang1033 marked\lang2057 \lang1033 as\lang2057 \lang1033 fixed,\lang2057 \lang1033 inserts\lang2057 \lang1033 a\lang2057 \lang1033\par 53 | \tab\tab\tab\lang2057 \lang1033 new\lang2057 \lang1033 breakpoint\lang2057 \lang1033 at\lang2057 \lang1033 the\lang2057 \lang1033 clicked\lang2057 position\lang1033 .\par 54 | \par 55 | \b RIGHT+CLICK\tab\lang2057 \b0 \lang1033 If\lang2057 \lang1033 a\lang2057 \lang1033 point\lang2057 \lang1033 is\lang2057 \lang1033 dragging,\lang2057 \lang1033 inserts\lang2057 \lang1033 a\lang2057 \lang1033 new\lang2057 \lang1033\par 56 | \tab\tab\tab\lang2057 \lang1033 breakpoint.\lang2057 \lang1033 The\lang2057 \lang1033 source\lang2057 \lang1033 point\lang2057 \lang1033 of\lang2057 \lang1033 the\lang2057 \lang1033 drag\lang2057 \lang1033 action\lang2057 \lang1033\par 57 | \tab\tab\tab\lang2057 \lang1033 keeps\lang2057 \lang1033 its\lang2057 \lang1033 dragging\lang2057 \lang1033 state.\par 58 | \par 59 | } 60 | -------------------------------------------------------------------------------- /Examples/Editor/NodeProp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/NodeProp.dfm -------------------------------------------------------------------------------- /Examples/Editor/NodeProp.pas: -------------------------------------------------------------------------------- 1 | unit NodeProp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, ExtCtrls, StdCtrls, ComCtrls, ExtDlgs, CheckLst; 8 | 9 | type 10 | TNodeProperties = class(TForm) 11 | Label1: TLabel; 12 | NodeShape: TRadioGroup; 13 | Colors: TGroupBox; 14 | Label2: TLabel; 15 | Label3: TLabel; 16 | NodeBodyColor: TPanel; 17 | NodeBorderColor: TPanel; 18 | btnChangeFont: TButton; 19 | btnOK: TButton; 20 | btnCancel: TButton; 21 | Bevel1: TBevel; 22 | FontDialog: TFontDialog; 23 | ColorDialog: TColorDialog; 24 | NodeText: TMemo; 25 | btnApply: TButton; 26 | GroupBox1: TGroupBox; 27 | OpenPictureDialog: TOpenPictureDialog; 28 | cbAlignment: TComboBox; 29 | AllOptions: TCheckListBox; 30 | Label4: TLabel; 31 | BodyColor: TShape; 32 | BorderColor: TShape; 33 | cbLayout: TComboBox; 34 | edtMargin: TEdit; 35 | UpDownMargin: TUpDown; 36 | Label5: TLabel; 37 | Label6: TLabel; 38 | Label7: TLabel; 39 | Styles: TGroupBox; 40 | FillStyle: TComboBox; 41 | Label8: TLabel; 42 | BorderStyle: TComboBox; 43 | Label9: TLabel; 44 | GroupBox3: TGroupBox; 45 | btnChangBkgnd: TButton; 46 | btnClearBackground: TButton; 47 | btnBackgroundMargins: TButton; 48 | procedure NodeBodyColorClick(Sender: TObject); 49 | procedure NodeBorderColorClick(Sender: TObject); 50 | procedure btnChangeFontClick(Sender: TObject); 51 | procedure btnChangBkgndClick(Sender: TObject); 52 | procedure btnClearBackgroundClick(Sender: TObject); 53 | procedure btnApplyClick(Sender: TObject); 54 | procedure FormCreate(Sender: TObject); 55 | procedure btnBackgroundMarginsClick(Sender: TObject); 56 | private 57 | Backgnd: Integer; 58 | S: TSimpleGraph; 59 | N: TGraphObjectList; // w2m - for apply button 60 | MarginRect: TRect; 61 | procedure ListRegistredNodeClasses; 62 | procedure ApplyChanges; 63 | procedure SetObjectOptions(Value: TGraphObjectOptions); 64 | function GetObjectOptions: TGraphObjectOptions; 65 | procedure SetNodeOptions(Value: TGraphNodeOptions); 66 | function GetNodeOptions: TGraphNodeOptions; 67 | public 68 | class function Execute(Nodes: TGraphObjectList): Boolean; 69 | end; 70 | 71 | function PrettyNodeClassName(const AClassName: string): string; 72 | 73 | implementation 74 | 75 | uses MarginsProp; 76 | 77 | {$R *.dfm} 78 | 79 | function PrettyNodeClassName(const AClassName: string): string; 80 | var 81 | I: Integer; 82 | begin 83 | Result := ''; 84 | for I := 2 to Length(AClassName) do 85 | begin 86 | if(UpCase(AClassName[I]) = AClassName[I]) and (Result <> '') then 87 | Result := Result + ' ' + AClassName[I] 88 | else 89 | Result := Result + AClassName[I] 90 | end; 91 | Result := StringReplace(Result, ' Node', '', []); 92 | end; 93 | 94 | { TNodeProperties } 95 | 96 | class function TNodeProperties.Execute(Nodes: TGraphObjectList): Boolean; 97 | begin 98 | Result := False; 99 | with Create(Application) do 100 | try 101 | N := Nodes; 102 | ListRegistredNodeClasses; 103 | with TGraphNode(Nodes[0]) do 104 | begin 105 | S := Owner; 106 | case Alignment of 107 | taLeftJustify: cbAlignment.ItemIndex := 0; 108 | taCenter: cbAlignment.ItemIndex := 1; 109 | taRightJustify: cbAlignment.ItemIndex := 2; 110 | end; 111 | case Layout of 112 | tlTop: cbLayout.ItemIndex := 0; 113 | tlCenter: cbLayout.ItemIndex := 1; 114 | tlBottom: cbLayout.ItemIndex := 2; 115 | end; 116 | UpDownMargin.Position := Margin; 117 | NodeText.Lines.Text := Text; 118 | if Nodes.Count = 1 then 119 | NodeShape.ItemIndex := NodeShape.Items.IndexOfObject(TObject(ClassType)) 120 | else 121 | NodeShape.ItemIndex := -1; 122 | BodyColor.Brush.Color := Brush.Color; 123 | BorderColor.Brush.Color := Pen.Color; 124 | FillStyle.ItemIndex := Ord(Brush.Style); 125 | BorderStyle.ItemIndex := Ord(Pen.Style); 126 | FontDialog.Font := Font; 127 | MarginRect := BackgroundMargins; 128 | SetObjectOptions(Options); 129 | SetNodeOptions(NodeOptions); 130 | end; 131 | if ShowModal = mrOK then 132 | begin 133 | ApplyChanges; 134 | Result := True; 135 | end; 136 | finally 137 | Free; 138 | end; 139 | end; 140 | 141 | procedure TNodeProperties.ListRegistredNodeClasses; 142 | var 143 | I: Integer; 144 | NodeClass: TGraphNodeClass; 145 | begin 146 | for I := 0 to TSimpleGraph.NodeClassCount - 1 do 147 | begin 148 | NodeClass := TSimpleGraph.NodeClasses(I); 149 | NodeShape.Items.AddObject(PrettyNodeClassName(NodeClass.ClassName), 150 | TObject(NodeClass)); 151 | end; 152 | end; 153 | 154 | procedure TNodeProperties.ApplyChanges; 155 | var 156 | I: Integer; 157 | begin 158 | S.BeginUpdate; 159 | try 160 | for I := 0 to N.Count - 1 do 161 | with TGraphNode(N[I]) do 162 | begin 163 | BeginUpdate; 164 | try 165 | case cbAlignment.ItemIndex of 166 | 0: Alignment := taLeftJustify; 167 | 1: Alignment := taCenter; 168 | 2: Alignment := taRightJustify; 169 | end; 170 | case cbLayout.ItemIndex of 171 | 0: Layout := tlTop; 172 | 1: Layout := tlCenter; 173 | 2: Layout := tlBottom; 174 | end; 175 | Margin := UpDownMargin.Position; 176 | Text := NodeText.Lines.Text; 177 | Brush.Color := BodyColor.Brush.Color; 178 | Pen.Color := BorderColor.Brush.Color; 179 | Brush.Style := TBrushStyle(FillStyle.ItemIndex); 180 | Pen.Style := TPenStyle(BorderStyle.ItemIndex); 181 | Font := FontDialog.Font; 182 | if Backgnd = 1 then 183 | Background.LoadFromFile(OpenPictureDialog.FileName) 184 | else if Backgnd = 2 then 185 | Background.Graphic := nil; 186 | BackgroundMargins := MarginRect; 187 | Options := GetObjectOptions; 188 | NodeOptions := GetNodeOptions; 189 | finally 190 | EndUpdate; 191 | end; 192 | if NodeShape.ItemIndex >= 0 then 193 | ConvertTo(TSimpleGraph.NodeClasses(NodeShape.ItemIndex)); 194 | end; 195 | finally 196 | S.EndUpdate; 197 | Backgnd := 0; 198 | end; 199 | end; 200 | 201 | procedure TNodeProperties.NodeBodyColorClick(Sender: TObject); 202 | begin 203 | ColorDialog.Color := BodyColor.Brush.Color; 204 | if ColorDialog.Execute then 205 | BodyColor.Brush.Color := ColorDialog.Color; 206 | end; 207 | 208 | procedure TNodeProperties.NodeBorderColorClick(Sender: TObject); 209 | begin 210 | ColorDialog.Color := BorderColor.Brush.Color; 211 | if ColorDialog.Execute then 212 | BorderColor.Brush.Color := ColorDialog.Color; 213 | end; 214 | 215 | procedure TNodeProperties.btnChangeFontClick(Sender: TObject); 216 | begin 217 | FontDialog.Execute; 218 | end; 219 | 220 | procedure TNodeProperties.btnChangBkgndClick(Sender: TObject); 221 | begin 222 | if OpenPictureDialog.Execute then 223 | Backgnd := 1; 224 | end; 225 | 226 | procedure TNodeProperties.btnClearBackgroundClick(Sender: TObject); 227 | begin 228 | Backgnd := 2; 229 | end; 230 | 231 | procedure TNodeProperties.btnApplyClick(Sender: TObject); 232 | begin 233 | ApplyChanges; 234 | end; 235 | 236 | procedure TNodeProperties.FormCreate(Sender: TObject); 237 | begin 238 | SetBounds(Screen.Width - Width - 30, 50, Width, Height); 239 | end; 240 | 241 | function TNodeProperties.GetObjectOptions: TGraphObjectOptions; 242 | var 243 | Option: TGraphObjectOption; 244 | begin 245 | Result := []; 246 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 247 | if AllOptions.Checked[Ord(Option)] then 248 | Include(Result, Option); 249 | end; 250 | 251 | procedure TNodeProperties.SetObjectOptions(Value: TGraphObjectOptions); 252 | var 253 | Option: TGraphObjectOption; 254 | begin 255 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 256 | AllOptions.Checked[Ord(Option)] := Option in Value; 257 | end; 258 | 259 | function TNodeProperties.GetNodeOptions: TGraphNodeOptions; 260 | var 261 | Option: TGraphNodeOption; 262 | begin 263 | Result := []; 264 | for Option := Low(TGraphNodeOption) to High(TGraphNodeOption) do 265 | if AllOptions.Checked[Ord(Option) + Ord(High(TGraphObjectOption)) + 1] then 266 | Include(Result, Option); 267 | end; 268 | 269 | procedure TNodeProperties.SetNodeOptions(Value: TGraphNodeOptions); 270 | var 271 | Option: TGraphNodeOption; 272 | begin 273 | for Option := Low(TGraphNodeOption) to High(TGraphNodeOption) do 274 | AllOptions.Checked[Ord(Option) + Ord(High(TGraphObjectOption)) + 1] := Option in Value; 275 | end; 276 | 277 | procedure TNodeProperties.btnBackgroundMarginsClick(Sender: TObject); 278 | begin 279 | TMarginDialog.Execute(MarginRect); 280 | end; 281 | 282 | end. 283 | 284 | -------------------------------------------------------------------------------- /Examples/Editor/ObjectProp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/ObjectProp.dfm -------------------------------------------------------------------------------- /Examples/Editor/ObjectProp.pas: -------------------------------------------------------------------------------- 1 | unit ObjectProp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, ExtCtrls, StdCtrls, ComCtrls, CheckLst; 8 | 9 | type 10 | TObjectProperties = class(TForm) 11 | Label1: TLabel; 12 | Colors: TGroupBox; 13 | Label2: TLabel; 14 | Label3: TLabel; 15 | ObjectFillColor: TPanel; 16 | ObjectLineColor: TPanel; 17 | btnChangeFont: TButton; 18 | btnOK: TButton; 19 | btnCancel: TButton; 20 | Bevel1: TBevel; 21 | FontDialog: TFontDialog; 22 | ColorDialog: TColorDialog; 23 | ObjectText: TMemo; 24 | btnApply: TButton; 25 | PublicOptions: TCheckListBox; 26 | Label4: TLabel; 27 | FillColor: TShape; 28 | LineColor: TShape; 29 | procedure ObjectFillColorClick(Sender: TObject); 30 | procedure ObjectLineColorClick(Sender: TObject); 31 | procedure btnChangeFontClick(Sender: TObject); 32 | procedure btnApplyClick(Sender: TObject); 33 | procedure FormCreate(Sender: TObject); 34 | private 35 | S: TSimpleGraph; 36 | O: TGraphObjectList; 37 | procedure SetObjectOptions(Value: TGraphObjectOptions); 38 | function GetObjectOptions: TGraphObjectOptions; 39 | procedure ApplyChanges; 40 | public 41 | class function Execute(Objects: TGraphObjectList): Boolean; 42 | end; 43 | 44 | implementation 45 | 46 | {$R *.dfm} 47 | 48 | { TObjectProperties } 49 | 50 | class function TObjectProperties.Execute(Objects: TGraphObjectList): Boolean; 51 | begin 52 | Result := False; 53 | with Create(Application) do 54 | try 55 | O := Objects; 56 | with Objects[0] do 57 | begin 58 | S := Owner; 59 | ObjectText.Lines.Text := Text; 60 | FillColor.Brush.Color := Brush.Color; 61 | LineColor.Brush.Color := Pen.Color; 62 | FontDialog.Font := Font; 63 | SetObjectOptions(Options); 64 | end; 65 | if ShowModal = mrOK then 66 | begin 67 | ApplyChanges; 68 | Result := True; 69 | end; 70 | finally 71 | Free; 72 | end; 73 | end; 74 | 75 | procedure TObjectProperties.ApplyChanges; 76 | var 77 | I: Integer; 78 | begin 79 | S.BeginUpdate; 80 | try 81 | for I := 0 to O.Count - 1 do 82 | with O[I] do 83 | begin 84 | BeginUpdate; 85 | try 86 | Text := ObjectText.Lines.Text; 87 | Brush.Color := FillColor.Brush.Color; 88 | Pen.Color := LineColor.Brush.Color; 89 | Font := FontDialog.Font; 90 | Options := GetObjectOptions; 91 | finally 92 | EndUpdate; 93 | end; 94 | end; 95 | finally 96 | S.EndUpdate; 97 | end; 98 | end; 99 | 100 | procedure TObjectProperties.ObjectFillColorClick(Sender: TObject); 101 | begin 102 | ColorDialog.Color := FillColor.Brush.Color; 103 | if ColorDialog.Execute then 104 | FillColor.Brush.Color := ColorDialog.Color; 105 | end; 106 | 107 | procedure TObjectProperties.ObjectLineColorClick(Sender: TObject); 108 | begin 109 | ColorDialog.Color := LineColor.Brush.Color; 110 | if ColorDialog.Execute then 111 | LineColor.Brush.Color := ColorDialog.Color; 112 | end; 113 | 114 | procedure TObjectProperties.btnChangeFontClick(Sender: TObject); 115 | begin 116 | FontDialog.Execute; 117 | end; 118 | 119 | procedure TObjectProperties.btnApplyClick(Sender: TObject); 120 | begin 121 | ApplyChanges; 122 | end; 123 | 124 | procedure TObjectProperties.FormCreate(Sender: TObject); 125 | begin 126 | SetBounds(Screen.Width - Width - 30, 50, Width, Height); 127 | end; 128 | 129 | function TObjectProperties.GetObjectOptions: TGraphObjectOptions; 130 | var 131 | Option: TGraphObjectOption; 132 | begin 133 | Result := []; 134 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 135 | if PublicOptions.Checked[Ord(Option)] then 136 | Include(Result, Option); 137 | end; 138 | 139 | procedure TObjectProperties.SetObjectOptions(Value: TGraphObjectOptions); 140 | var 141 | Option: TGraphObjectOption; 142 | begin 143 | for Option := Low(TGraphObjectOption) to High(TGraphObjectOption) do 144 | PublicOptions.Checked[Ord(Option)] := Option in Value; 145 | end; 146 | 147 | end. 148 | -------------------------------------------------------------------------------- /Examples/Editor/SGDemo.dpr: -------------------------------------------------------------------------------- 1 | program SGDemo; 2 | 3 | uses 4 | Forms, 5 | Main in 'Main.pas' {MainForm}, 6 | DesignProp in 'DesignProp.pas' {DesignerProperties}, 7 | ObjectProp in 'ObjectProp.pas' {ObjectProperties}, 8 | LinkProp in 'LinkProp.pas' {LinkProperties}, 9 | NodeProp in 'NodeProp.pas' {NodeProperties}, 10 | AboutDelphiArea in 'AboutDelphiArea.pas' {About}, 11 | UsageHelp in 'UsageHelp.pas' {HelpOnActions}, 12 | MarginsProp in 'MarginsProp.pas' {MarginDialog}, 13 | AlignDlg in 'AlignDlg.pas' {AlignDialog}, 14 | SizeDlg in 'SizeDlg.pas' {SizeDialog}; 15 | 16 | {$R *.res} 17 | 18 | begin 19 | Application.Initialize; 20 | Application.Title := 'Simple Graph Demo'; 21 | Application.CreateForm(TMainForm, MainForm); 22 | Application.Run; 23 | end. 24 | -------------------------------------------------------------------------------- /Examples/Editor/SGDemo.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {F2EE3125-3128-40D4-A529-CF2501156C40} 4 | SGDemo.dpr 5 | Debug 6 | DCC32 7 | 12.0 8 | 9 | 10 | true 11 | 12 | 13 | true 14 | Base 15 | true 16 | 17 | 18 | true 19 | Base 20 | true 21 | 22 | 23 | 00400000 24 | false 25 | x86 26 | SGDemo.exe 27 | false 28 | false 29 | false 30 | false 31 | 32 | 33 | false 34 | RELEASE;$(DCC_Define) 35 | 0 36 | false 37 | 38 | 39 | DEBUG;$(DCC_Define) 40 | 41 | 42 | 43 | MainSource 44 | 45 | 46 |
MainForm
47 |
48 | 49 |
DesignerProperties
50 |
51 | 52 |
ObjectProperties
53 |
54 | 55 |
LinkProperties
56 |
57 | 58 |
NodeProperties
59 |
60 | 61 |
About
62 |
63 | 64 |
HelpOnActions
65 |
66 | 67 |
MarginDialog
68 |
69 | 70 |
AlignDialog
71 |
72 | 73 |
SizeDialog
74 |
75 | 76 | Base 77 | 78 | 79 | Cfg_2 80 | Base 81 | 82 | 83 | Cfg_1 84 | Base 85 | 86 |
87 | 88 | 89 | Delphi.Personality.12 90 | VCLApplication 91 | 92 | 93 | 94 | SGDemo.dpr 95 | 96 | 97 | False 98 | True 99 | False 100 | 101 | 102 | False 103 | False 104 | 1 105 | 0 106 | 0 107 | 0 108 | False 109 | False 110 | False 111 | False 112 | False 113 | 1065 114 | 1256 115 | 116 | 117 | 118 | 119 | 1.0.0.0 120 | 121 | 122 | 123 | 124 | 125 | 1.0.0.0 126 | 127 | 128 | 129 | 130 | 12 131 | 132 |
133 | -------------------------------------------------------------------------------- /Examples/Editor/SGDemo.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/SGDemo.res -------------------------------------------------------------------------------- /Examples/Editor/Samples/Sample1.sgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/Samples/Sample1.sgp -------------------------------------------------------------------------------- /Examples/Editor/Samples/Sample2.sgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/Samples/Sample2.sgp -------------------------------------------------------------------------------- /Examples/Editor/Samples/Sample3.sgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/Samples/Sample3.sgp -------------------------------------------------------------------------------- /Examples/Editor/SizeDlg.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/SizeDlg.dfm -------------------------------------------------------------------------------- /Examples/Editor/SizeDlg.pas: -------------------------------------------------------------------------------- 1 | unit SizeDlg; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, StdCtrls, ExtCtrls; 8 | 9 | type 10 | TSizeDialog = class(TForm) 11 | Horz: TRadioGroup; 12 | Vert: TRadioGroup; 13 | btnOK: TButton; 14 | btnCancel: TButton; 15 | public 16 | class function Execute(out HorzSize: TResizeOption; 17 | out VertSize: TResizeOption): Boolean; 18 | end; 19 | 20 | implementation 21 | 22 | {$R *.dfm} 23 | 24 | class function TSizeDialog.Execute(out HorzSize: TResizeOption; 25 | out VertSize: TResizeOption): Boolean; 26 | begin 27 | Result := False; 28 | with Create(Application) do 29 | try 30 | if ShowModal = mrOK then 31 | begin 32 | HorzSize := TResizeOption(Horz.ItemIndex); 33 | VertSize := TResizeOption(Vert.ItemIndex); 34 | Result := True; 35 | end; 36 | finally 37 | Free; 38 | end; 39 | end; 40 | 41 | end. 42 | -------------------------------------------------------------------------------- /Examples/Editor/UsageHelp.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/Editor/UsageHelp.dfm -------------------------------------------------------------------------------- /Examples/Editor/UsageHelp.pas: -------------------------------------------------------------------------------- 1 | unit UsageHelp; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 7 | Dialogs, StdCtrls, ComCtrls; 8 | 9 | type 10 | THelpOnActions = class(TForm) 11 | PageControl: TPageControl; 12 | TabSheet1: TTabSheet; 13 | TabSheet2: TTabSheet; 14 | RichEdit1: TRichEdit; 15 | RichEdit2: TRichEdit; 16 | btnClose: TButton; 17 | public 18 | class procedure Execute; 19 | end; 20 | 21 | implementation 22 | 23 | {$R *.dfm} 24 | 25 | { THelpOnActions } 26 | 27 | class procedure THelpOnActions.Execute; 28 | begin 29 | with Create(Application) do 30 | try 31 | RichEdit1.Lines.LoadFromFile(ExtractFilePath(Application.ExeName) + 'Keyboard.rtf'); 32 | RichEdit2.Lines.LoadFromFile(ExtractFilePath(Application.ExeName) + 'Mouse.rtf'); 33 | ShowModal; 34 | finally 35 | Free; 36 | end; 37 | end; 38 | 39 | end. 40 | -------------------------------------------------------------------------------- /Examples/ElasticNodes/ElasticNodes.dpr: -------------------------------------------------------------------------------- 1 | program ElasticNodes; 2 | 3 | uses 4 | Forms, 5 | Main in 'Main.pas' {MainForm}; 6 | 7 | {$R *.res} 8 | 9 | begin 10 | Application.Initialize; 11 | Application.CreateForm(TMainForm, MainForm); 12 | Application.Run; 13 | end. 14 | -------------------------------------------------------------------------------- /Examples/ElasticNodes/ElasticNodes.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {F2095BA1-62F4-4726-8065-219531FC93AA} 4 | ElasticNodes.dpr 5 | True 6 | Debug 7 | 1 8 | Application 9 | VCL 10 | 19.2 11 | Win32 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Base 40 | true 41 | 42 | 43 | true 44 | Cfg_2 45 | true 46 | true 47 | 48 | 49 | false 50 | false 51 | false 52 | false 53 | false 54 | 00400000 55 | ElasticNodes 56 | Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) 57 | 8192 58 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= 59 | 60 | 61 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 62 | Debug 63 | true 64 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) 65 | 1033 66 | $(BDS)\bin\default_app.manifest 67 | ElasticNodes_Icon.ico 68 | true 69 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 70 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 71 | 72 | 73 | ElasticNodes_Icon.ico 74 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 75 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 76 | 77 | 78 | RELEASE;$(DCC_Define) 79 | 0 80 | false 81 | 0 82 | 83 | 84 | true 85 | PerMonitorV2 86 | 87 | 88 | DEBUG;$(DCC_Define) 89 | false 90 | true 91 | 92 | 93 | true 94 | PerMonitorV2 95 | 96 | 97 | 98 | MainSource 99 | 100 | 101 |
MainForm
102 |
103 | 104 | Cfg_2 105 | Base 106 | 107 | 108 | Base 109 | 110 | 111 | Cfg_1 112 | Base 113 | 114 |
115 | 116 | Delphi.Personality.12 117 | 118 | 119 | 120 | 121 | ElasticNodes.dpr 122 | 123 | 124 | 125 | True 126 | False 127 | 128 | 129 | 12 130 | 131 | 132 | 133 |
134 | -------------------------------------------------------------------------------- /Examples/ElasticNodes/ElasticNodes.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Examples/ElasticNodes/ElasticNodes.res -------------------------------------------------------------------------------- /Examples/ElasticNodes/Main.dfm: -------------------------------------------------------------------------------- 1 | object MainForm: TMainForm 2 | Left = 192 3 | Top = 151 4 | Width = 559 5 | Height = 527 6 | Caption = 'Elastic Nodes' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | Position = poScreenCenter 15 | OnCreate = FormCreate 16 | PixelsPerInch = 96 17 | TextHeight = 13 18 | object SimpleGraph: TSimpleGraph 19 | Left = 0 20 | Top = 0 21 | Width = 543 22 | Height = 489 23 | Align = alClient 24 | HideSelection = True 25 | HorzScrollBar.Visible = False 26 | ShowGrid = False 27 | SnapToGrid = False 28 | TabOrder = 0 29 | VertScrollBar.Visible = False 30 | OnObjectEndDrag = SimpleGraphObjectEndDrag 31 | OnNodeMoveResize = SimpleGraphNodeMoveResize 32 | object Panel: TPanel 33 | Left = 0 34 | Top = 0 35 | Width = 543 36 | Height = 41 37 | Align = alTop 38 | Caption = 'Drag a node!' 39 | Font.Charset = DEFAULT_CHARSET 40 | Font.Color = clWindowText 41 | Font.Height = -19 42 | Font.Name = 'Tahoma' 43 | Font.Style = [] 44 | ParentFont = False 45 | TabOrder = 0 46 | end 47 | end 48 | object Timer: TTimer 49 | Enabled = False 50 | Interval = 30 51 | OnTimer = TimerTimer 52 | Left = 8 53 | Top = 48 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /Examples/ElasticNodes/Main.pas: -------------------------------------------------------------------------------- 1 | unit Main; 2 | 3 | interface 4 | 5 | uses 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 | Dialogs, SimpleGraph, ExtCtrls; 8 | 9 | type 10 | 11 | TElasticNode = class(TEllipticNode) 12 | private 13 | procedure SetCenter(const Value: TPoint); 14 | public 15 | constructor Create(AOwner: TSimpleGraph; cX, cY: Integer); reintroduce; 16 | function UpdatePosition: Boolean; 17 | end; 18 | 19 | TElasticEdge = class(TGraphLink) 20 | public 21 | constructor Create(AOwner: TSimpleGraph; SourceNode, TargetNode: TElasticNode); reintroduce; 22 | end; 23 | 24 | TMainForm = class(TForm) 25 | SimpleGraph: TSimpleGraph; 26 | Timer: TTimer; 27 | Panel: TPanel; 28 | procedure FormCreate(Sender: TObject); 29 | procedure TimerTimer(Sender: TObject); 30 | procedure SimpleGraphNodeMoveResize(Graph: TSimpleGraph; Node: TGraphNode); 31 | procedure SimpleGraphObjectEndDrag(Graph: TSimpleGraph; 32 | GraphObject: TGraphObject; HT: DWord; Canceled: Boolean); 33 | private 34 | function UpdateNodes: Boolean; 35 | end; 36 | 37 | var 38 | MainForm: TMainForm; 39 | 40 | implementation 41 | 42 | uses Math; 43 | 44 | {$R *.dfm} 45 | 46 | { TElasticNode } 47 | 48 | constructor TElasticNode.Create(AOwner: TSimpleGraph; cX, cY: Integer); 49 | begin 50 | inherited Create(AOwner); 51 | SetBounds(cX + Owner.Width div 2 - 10, cY + Owner.Height div 2 - 10, 20, 20); 52 | NodeOptions := NodeOptions - [gnoResizable]; 53 | Brush.Color := clRed; 54 | end; 55 | 56 | procedure TElasticNode.SetCenter(const Value: TPoint); 57 | begin 58 | SetBounds(Value.X - Width div 2, Value.Y - Height div 2, Width, Height); 59 | end; 60 | 61 | function TElasticNode.UpdatePosition; 62 | var 63 | ThisCenter, OtherCenter, NewCenter: TPoint; 64 | xVel, yVel: Double; 65 | dx, dy: Integer; 66 | Weight, l, i: Integer; 67 | begin 68 | Result := False; 69 | if Dragging then 70 | Exit; 71 | 72 | ThisCenter := Center; 73 | xVel := 0.0; 74 | yVel := 0.0; 75 | 76 | for i := 0 to Owner.Objects.Count - 1 do 77 | begin 78 | if not (Owner.Objects[i] is TElasticNode) then 79 | Continue; 80 | OtherCenter := TElasticNode(Owner.Objects[i]).Center; 81 | dx := ThisCenter.X - OtherCenter.X; 82 | dy := ThisCenter.Y - OtherCenter.Y; 83 | l := 2 * (dx * dx + dy * dy); 84 | if l > 0 then 85 | begin 86 | xVel := xVel + (dx * 150) / l; 87 | yVel := yVel + (dy * 150) / l; 88 | end; 89 | end; 90 | 91 | Weight := (LinkInputCount + LinkOutputCount + 1) * 10; 92 | for i := 0 to LinkInputCount + LinkOutputCount - 1 do 93 | begin 94 | if i < LinkInputCount then 95 | OtherCenter := TElasticNode(LinkInputs[i].Source).Center 96 | else 97 | OtherCenter := TElasticNode(LinkOutputs[i - LinkInputCount].Target).Center; 98 | dx := ThisCenter.X - OtherCenter.X; 99 | dy := ThisCenter.Y - OtherCenter.Y; 100 | xVel := xVel - dx / Weight; 101 | yVel := yVel - dy / Weight; 102 | end; 103 | NewCenter.X := ThisCenter.X + Round(xVel); 104 | NewCenter.Y := ThisCenter.Y + Round(yVel); 105 | 106 | NewCenter.X := Min(Max(NewCenter.X, 10), Owner.ClientWidth - 10); 107 | NewCenter.Y := Min(Max(NewCenter.Y, 10), Owner.ClientHeight - 10); 108 | 109 | if (NewCenter.X <> ThisCenter.X) or (NewCenter.Y <> ThisCenter.Y) then 110 | begin 111 | SetCenter(NewCenter); 112 | Result := True; 113 | end; 114 | end; 115 | 116 | { TElasticEdge } 117 | 118 | constructor TElasticEdge.Create(AOwner: TSimpleGraph; 119 | SourceNode, TargetNode: TElasticNode); 120 | begin 121 | inherited CreateNew(AOwner, SourceNode, [], TargetNode); 122 | Options := Options - [goSelectable]; 123 | Brush.Color := Pen.Color; 124 | BeginStyle := lsArrow; 125 | EndStyle := lsArrow; 126 | BeginSize := 4; 127 | EndSize := 4; 128 | end; 129 | 130 | { TMainForm } 131 | 132 | procedure TMainForm.FormCreate(Sender: TObject); 133 | var 134 | Node1, Node2, Node3, Node4, 135 | Node6, Node7, Node8, Node9, 136 | CenterNode: TElasticNode; 137 | begin 138 | Node1 := TElasticNode.Create(SimpleGraph, -50, -50); 139 | Node2 := TElasticNode.Create(SimpleGraph, 0, -50); 140 | Node3 := TElasticNode.Create(SimpleGraph, 50, -50); 141 | Node4 := TElasticNode.Create(SimpleGraph, -50, 0); 142 | CenterNode := TElasticNode.Create(SimpleGraph, 0, 0); 143 | Node6 := TElasticNode.Create(SimpleGraph, 50, 0); 144 | Node7 := TElasticNode.Create(SimpleGraph, -50, 50); 145 | Node8 := TElasticNode.Create(SimpleGraph, 0, 50); 146 | Node9 := TElasticNode.Create(SimpleGraph, 50, 50); 147 | TElasticEdge.Create(SimpleGraph, Node1, Node2); 148 | TElasticEdge.Create(SimpleGraph, Node2, Node3); 149 | TElasticEdge.Create(SimpleGraph, Node2, CenterNode); 150 | TElasticEdge.Create(SimpleGraph, Node3, Node6); 151 | TElasticEdge.Create(SimpleGraph, Node4, Node1); 152 | TElasticEdge.Create(SimpleGraph, Node4, CenterNode); 153 | TElasticEdge.Create(SimpleGraph, CenterNode, Node6); 154 | TElasticEdge.Create(SimpleGraph, CenterNode, Node8); 155 | TElasticEdge.Create(SimpleGraph, Node6, Node9); 156 | TElasticEdge.Create(SimpleGraph, Node7, Node4); 157 | TElasticEdge.Create(SimpleGraph, Node8, Node7); 158 | TElasticEdge.Create(SimpleGraph, Node9, Node8); 159 | end; 160 | 161 | function TMainForm.UpdateNodes: Boolean; 162 | var 163 | i: Integer; 164 | begin 165 | Result := False; 166 | for i := 0 to SimpleGraph.Objects.Count - 1 do 167 | if (SimpleGraph.Objects[i] is TEllipticNode) and 168 | TElasticNode(SimpleGraph.Objects[i]).UpdatePosition 169 | then 170 | Result := True; 171 | end; 172 | 173 | procedure TMainForm.TimerTimer(Sender: TObject); 174 | begin 175 | Timer.Enabled := UpdateNodes; 176 | end; 177 | 178 | procedure TMainForm.SimpleGraphNodeMoveResize(Graph: TSimpleGraph; 179 | Node: TGraphNode); 180 | begin 181 | Timer.Enabled := True; 182 | end; 183 | 184 | procedure TMainForm.SimpleGraphObjectEndDrag(Graph: TSimpleGraph; 185 | GraphObject: TGraphObject; HT: DWord; Canceled: Boolean); 186 | begin 187 | SimpleGraph.ClearSelection; 188 | end; 189 | 190 | end. 191 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## Version 2.92 (July 25, 2022) 2 | - Fixed bug in the `ForEachObject` method of the [TSimpleGraph](Docs/TSimpleGraph.md) control. The method was always returning zero. 3 | - Renamed the `ContainsRect` method of the [TGraphObject](Docs/TGraphObject.md) class to `IntersectsWith` for sake of clarity. 4 | - Renamed the `TGraphNodeResizeEvent` event type to `TGraphNodeNotifyEvent`. 5 | - Refactored the code. 6 | - Improved the documentation. 7 | 8 | ## Version 2.91 (January 25, 2013) 9 | - Fixed a bug in wrapping text (Thanks to _Oleg_). 10 | 11 | ## Version 2.90 (April 27, 2013) 12 | - Fixed the bug causing some random characters appear on the caption of links. 13 | - Improved positioning of the links' caption. 14 | 15 | ## Version 2.81 (January 6, 2013) 16 | - Fixed the compatibility issues with Delphi XE2 and XE3. 17 | 18 | ## Version 2.80 (June 2, 2011) 19 | - Added the `gloFixedAnchorStartPoint` and `gloFixedAnchorEndPoint` options to the `LinkOptions` property of the [TGraphLink](Docs/TGraphLink.md) class. These options determine whether the hooked links should be anchored to a fixed point on the target object or not. 20 | 21 | ## Version 2.72 (February 2, 2009) 22 | - Fixed code malfunction in changing the `Left`, `Top`, `Width`, and `Height` properties of the [TGraphNode](Docs/TGraphNode.md) class inside a `BeginUpdate`/`EndUpdate` block. 23 | 24 | ## Version 2.71 (January 16, 2009) 25 | - Re-entrance problem in repositioning of hooked objects is fixed (Thanks to _cml0816_). 26 | - Problem in selecting horizontal and vertical links with one pixel width is fixed (Thanks to _cml0816_). 27 | - Added the `Push` and `Pop` methods to the [TGraphObjectList](Docs/TGraphObjectList.md) class. 28 | 29 | ## Version 2.70 (November 14, 2008) 30 | - Fixed compatibility issue with Delphi 2009. 31 | - Fixed bug in the `NormalizeBreakPoints` method of the [TGraphLink](Docs/TGraphLink.md) class (Thanks to _liu8670_). 32 | - Fixed bug in the `ZoomRect` method of the [TSimpleGraph](Docs/TSimpleGraph.md) control (Thanks to _Choe, Cheng-Dae_). 33 | 34 | ## Version 2.62 (May 15, 2007) 35 | - Fixed the compatibility issue with Delphi 5. 36 | 37 | ## Version 2.61 (March 30, 2006) 38 | - Fixed a bug in managing mouse, which was occurred when the `CommandMode` property was set to `cmViewOnly`. 39 | 40 | ## Version 2.60 (March 29, 2006) 41 | - Added the `OnObjectMouseEnter` and `OnObjectMouseLeave` events to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 42 | - Added the `DragSource` and `ObjectAtCursor` properties to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 43 | - Added the `ResizeSelection` method to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 44 | 45 | ## Version 2.50 (March 26, 2006) 46 | - Introduced the `OverlappedRect` global procedure. 47 | - Added the `Transparent` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 48 | - Added the `ChangeZoom`, `ChangeZoomBy`, and `AlignSelection` methods to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 49 | - Fixed a bug in drawing child controls. 50 | - Fixed a bug in calculating range of scroll bars when the control had some aligned child controls. 51 | 52 | ## Version 2.40 (March 22, 2006) 53 | - Fixed a bug in scrolling the graph by keyboard. 54 | - Fixed a bug in the `Assign` method of the [TGraphObjectList](Docs/TGraphObjectList.md) class. 55 | 56 | ## Version 2.30 (March 21, 2006) 57 | - Introduced the [TCompatibleCanvas](Docs/TCompatibleCanvas.md) class. 58 | - Introduced `cmPan` as a new option for the `CommandMode` property of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 59 | - Added the `OnMoveResizeNode` event to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 60 | - Fixed a bug in the `FindObjectAt` method of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 61 | - Fixed a bug in triggering some events while loading or clearing a graph. 62 | 63 | ## Version 2.20 (March 19, 2006) 64 | - Added the `SourceRect` property to the [TGraphConstraints](Docs/TGraphConstraints.md) class. 65 | - Fixed a bug in merging graphs. 66 | 67 | ## Version 2.10 (March 18, 2006) 68 | - Introduced the [TCanvasRecall](Docs/TCanvasRecall.md) class. 69 | - Added the `UnionRect` and `IntersectRect` global procedures. 70 | - Added the `ClipboardFormats`, `DraggingObjects`, and `DraggingBounds` properties to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 71 | - Added the `ScrollCenter`, `ScreenToGraph`, `GraphToScreen`, `SnapPoint`, `SnapOffset`, `FindObjectByID`, `ForEachObject`, `SaveAsBitmap`, `CopyToGraphic`, `MergeFromStream`, `MergeFromFile`, and `InvalidateRect` methods to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 72 | - Added `OnObjectInitInstance`, `OnObjectChange`, `OnCanRemoveObject`, `OnObjectRead` and `OnObjectWrite` events to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 73 | - Added the `ID`, `Data`, `States`, `HasCustomData`, `VisualRect`, `SelectedVisualRect`, `Dependents`, `DependentCount`, `LinkInputs`, `LinkInputCount`, `LinkOutputs`, and `LinkOutputCount` properties to the [TGraphObject](Docs/TGraphObject.md) class. 74 | - Added the `CanDelete`, `DragBy`, and `Invalidate` methods to the [TGraphObject](Docs/TGraphObject.md) class. 75 | - Added the missing `AssignTo` method to the [TGraphObject](Docs/TGraphObject.md) class. 76 | - Added the `IsNode` class method to the [TGraphObject](Docs/TGraphObject.md) class. 77 | - Added the `Create` constructor to the [TGraphObject](Docs/TGraphObject.md) class. 78 | - Added the `CreateNew` constructor to the [TGraphLink](Docs/TGraphLink.md) class. 79 | - Added the `CreateNew` constructor to the [TGraphNode](Docs/TGraphNode.md) class. 80 | - Changed signature of the `BeginDrag` and `DragTo` methods of the [TGraphObject](Docs/TGraphObject.md) class. 81 | - Changed the return value of the `ConvertTo` method of the [TGraphObject](Docs/TGraphObject.md) class. 82 | - Changed the [TGraphObjectList](Docs/TGraphObjectList.md) class. The new implementation provides safe enumeration of the graph objects even when the list is changed during the enumeration. 83 | - Changed the `OnObjectBeginDrag` and `OnObjectEndDrag` events of the [TSimpleGraph](Docs/TSimpleGraph.md) control, so that more information about the dragging object be available. 84 | - Changed zooming properties of the [TSimpleGraph](Docs/TSimpleGraph.md) control. The current zoom range is between 5% and 36863%. Because of the new `OnMouseWheelDown` and `OnMouseWheelUp` events of the control, the control does not change the zoom factor internally. Due to these changes, `ZoomMin`, `ZoomMax`, and `ZoomStep` properties of the control are removed. 85 | - Changed signature of the `FindObjectAt` method of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 86 | - Improved painting algorithm to increase speed and reduce CPU usage. 87 | - Fixed a bug in moving a group of selected link objects. 88 | - Fixed a bug in inserting links, which were occurring in Delphi 4 and 5. 89 | - Fixed the bug about not triggering the `OnObjectUnhook` event of the [TSimpleGraph](Docs/TSimpleGraph.md) control when unhooking was the result of an object deletion. 90 | - Fixed a bug in saving the `BackgroundMargins` property of the [TGraphObject](Docs/TGraphObject.md) class. 91 | - Fixed a bug in the `MinimizeText` global procedure. In addition, three periods as ellipsis (...) is changed to a single character ellipses (…) if the font supports it. 92 | - Fixed a bug regarding positioning of the links. 93 | - Fixed some minor other bugs. 94 | - And, many other improvements in the stability and performance of the code. 95 | 96 | ## Version 2.00 (February 23, 2006) 97 | To improve performance and functionality of the control, most part of the code is rewritten. This may lead to some breaking changes in your code. 98 | 99 | Changes in the [TSimpleGraph](Docs/TSimpleGraph.md) class: 100 | - Added the `LockLinks` property. 101 | - Added the `OnObjectBeginDrag` and `OnObjectEndDrag` events. 102 | - Added the `OnObjectHook` and `OnObjectUnhook` events. 103 | - Added the `OnCanHookLink` event. 104 | - Replaced the `OnCanLinkNodes` event with the `OnCanLinkObjects` event. 105 | - Replaced the `ToggleNodesAt` method with the `ToggleSelection` method. The new method is more flexible and detects objects that are either inside or intersecting with the selection rectangle. 106 | - Added an overload for the `FindObjectAt` method. 107 | - Changed `Bounds` parameter of the `InsertNode` method from `PRect` to `TRect`. 108 | - Replaced the `LinkNodes` method with the `InsertLink` method. The new method has four overloads. 109 | - Added the `ClearSelection` method. 110 | - Renamed the `cmLinkNodes` value of the `CommandMode` property to `cmInsertLink`. 111 | - Removed the `IsValidLink` method. Use the `CanLink` method of the [TGraphLink](Docs/TGraphLink.md) class as substitute. 112 | - Changed some keyboard and mouse actions. As of now, each object has its own keyboard and mouse events. 113 | - Added the missing constraints check while moving/resizing objects by keyboard. 114 | 115 | Changes in the [TGraphObject] class: 116 | - Added the `Options` property. 117 | - Added the `Dragging` property as read-only. 118 | - Added the `BeginDrag`, `DragTo`, and `EndDrag` methods. 119 | - Added the `HitTest` method. 120 | - Added the `ContainsRect` method. 121 | - Added the `Delete` method. 122 | - Added the `IsLocked` method. 123 | - Changed the `IsLink` property to class method. 124 | 125 | Changes in the [TGraphLink](Docs/TGraphLink.md) class: 126 | - Improved functionality. Each endpoint of a link can be hooked to a graph object (node or link), and style of each endpoint is customizable. The new links can have breakpoints. 127 | - Added the `Points`, `PointCount`, and `Polyline` properties. 128 | - Added the `TextPosition` and `TextSpacing` properties. 129 | - Added the `LinkOptions` property. 130 | - Replaced the `Kind` property with the `BeginStyle` and `EndStyle` properties. 131 | - Replaced the `ArrowSize` property with the `BeginSize` and `EndSize` properties. 132 | - Replace the `FromNode` and `ToNode` properties with the `Source` and `Target` properties. 133 | - Added the `CanMove` method. 134 | - Added the `AddPoint`, `InsertPoint`, `RemovePoint`, `IndexOfPoint`, `AddBreakPoint`, and `NormalizeBreakpoints` methods for manipulating the `Polyline` property. 135 | - Added the `IsFixedPoint`, `IsHookedPoint`, `HookedObjectOf`, `HookedIndexOf`, and `HookedPointCount` methods. 136 | - Added the `CanHook`, `Hook`, `Unhook`, `CanLink`, and `Link` methods for managing the hooking and linking actions. 137 | - Added the `Rotate` and `Scale` methods. 138 | 139 | Changes in the [TGraphNode](Docs/TGraphNode.md) class: 140 | - Added the `NodeOptions` property. 141 | - Added the `BackgroundMargins` property. 142 | - Added the `CanMoveResize` method. 143 | - Removed the `QueryLinkTo` method. 144 | - Fixed clipped text problem that was occurring when graph was zoomed in. 145 | - Introduced the Hexagonal node shape. 146 | 147 | Changes in the [TPolygonalNode](Docs/TPolygonalNode.md) class: 148 | - Added the `Vertices` property as read-only. 149 | 150 | Changes in the `TRectangularNode` class: 151 | - Changed the base class from the [TGraphNode](Docs/TGraphNode.md) class to the [TPolygonalNode](Docs/TPolygonalNode.md) class. 152 | 153 | Changes in the [TGraphConstraints](Docs/TGraphConstraints.md) class: 154 | - Added the `WithinBounds` method. 155 | - Added the `ConfineOffset` method. 156 | - Changed signature of `ConfinePt` and `ConfineRect` methods. 157 | - Fixed malfunction of the `ConfineRect` method. 158 | 159 | Changes in global procedures: 160 | - Added the `NormalizeAngle`, `EqualPoint`, `ScalePoints`, `ShiftPoints`, `MakeSquare`, `LineLength`, `NearestPointOnLine`, and `IntersectLinePolyline` functions. 161 | - Changed signature of the `IntersectLineRect`, `IntersectLineEllipse`, `IntersectLineRoundRect`, and `IntersectLinePolygon` functions. 162 | - Changed the return type of the `DistanceToLine` function from integer to double. 163 | - Changed type of `DistanceFromThisPt` parameter of the `NextPointOfLine` function from integer to double. 164 | 165 | ## Version 1.67 (November 14, 2005) 166 | - Added the `OnZoomChange` event the [TSimpleGraph](Docs/TSimpleGraph.md) control. 167 | - Fixed bug on calling the `OnResize` and `OnCanResize` events of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 168 | 169 | ## Version 1.66 (November 11, 2005) 170 | - Added the `FixedScrollBars` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 171 | - Applied constrains check on the new nodes inserted by mouse actions. 172 | - Added the `ConfinePt` and `ConfineRect` methods to the [TGraphConstraints](Docs/TGraphConstraints.md) class. 173 | 174 | ## Version 1.65 (November 10, 2005) 175 | - Introduced the [TGraphConstraints](Docs/TGraphConstraints.md) class. 176 | - Replaced the `FreezeTopLeft` property of the [TSimpleGraph](Docs/TSimpleGraph.md) control with the `GraphConstraints` property. 177 | - Added missing `OnClick` and `OnObjectClick` to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 178 | - Improved paint handler to remove memory limit on graph's bounds and speed up drawing. 179 | - The [TSimpleGraph](Docs/TSimpleGraph.md) control accepts child controls now. 180 | 181 | ## Version 1.61 (November 1, 2005) 182 | - Added the `OnInfoTip` event to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 183 | - Introduced the `NearestPoint` global procedure. 184 | - Changed all `Extended` data types to `Double` to prevent "Invalid Floating Point Operation" exception. 185 | - Fixed the bug in calculating the end points of the links. 186 | - Dropped the limit on the number of allowed polygon's vertices in the [TPolygonalNode](Docs/TPolygonalNode.md) class. 187 | 188 | ## Version 1.60 (October 29, 2005) 189 | - Added the `Layout` property to the [TGraphNode](Docs/TGraphNode.md) class. 190 | - Added the `DrawOrder` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 191 | - Added `OnBeforeDraw`, `OnAfterDraw`, `OnObjectBeforeDraw`, and `OnObjectAfterDraw` to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 192 | - Introduced the `WrapText` and `MinimizeText` global procedures. 193 | - Displayed caption of objects as hint if the caption does not fit on the screen. 194 | - Fixed issue with drawing caption of nodes for zoom factors other than 100%. 195 | - Some minor tweaks. 196 | 197 | ## Version 1.58 (September 29, 2005) 198 | - Added the `Hint` property to the [TGraphObject](Docs/TGraphObject.md) class. 199 | 200 | ## Version 1.57 (May 13, 2005) 201 | - Workaround a Windows API bug. If the view size of a metafile image is larger than the screen size, Windows API cannot clip it. 202 | 203 | ## Version 1.56 (May 9, 2005) 204 | - Fixed bug in copy/paste functions. 205 | 206 | ## Version 1.55 (April 21, 2005) 207 | - Fixed memory leak issue. 208 | 209 | ## Version 1.54.2 (August 24, 2004) 210 | - Fixed the black border artifact, which was appearing during scroll. 211 | 212 | ## Version 1.54.1 (August 20, 2004) 213 | - Fixed bug in calculating range of the scroll bars. 214 | 215 | ## Version 1.54 (August 6, 2004) 216 | - Added the `MinNodeSize` property the [TSimpleGraph](Docs/TSimpleGraph.md) control. 217 | - Added the `ArrowSize` to the [TGraphLink](Docs/TGraphLink.md) class. 218 | - Some minor tweaks. 219 | 220 | ## Version 1.53.1 (August 4, 2004) 221 | - Fixed bug related to the `FreezeTopLeft` property of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 222 | 223 | ## Version 1.53 (August 4, 2004) 224 | - Fixed bug in moving/resizing overlapped objects. 225 | - Added the `FreezeTopLeft` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 226 | 227 | ## Version 1.52 (July 18, 2004) 228 | - Fixed the scrolling malfunction when the zoom was greater than 100%. 229 | 230 | ## Version 1.51 (June 28, 2004) 231 | - Fixed a minor bug. 232 | 233 | ## Version 1.50 (June 22, 2004) 234 | - Added the `VisibleBounds` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 235 | - Introduced the abstract [TPolygonalNode](Docs/TPolygonalNode.md) class. 236 | - Introduced the Triangular, Rhomboidal, and Pentagonal node shapes. 237 | - Added some new global functions. 238 | - Improved performance. 239 | 240 | ## Version 1.21.1 (June 18, 2004) 241 | - Fixed the compiler error on Delphi 4. 242 | 243 | ## Version 1.21 (June 13, 2004) 244 | - Added the `SelectionBounds` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 245 | - Added the `ZoomRect`, `ZoomObject`, `ZoomSelection`, and `ZoomGraph` to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 246 | - Added the missing `GraphToClient` method to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 247 | - Some minor tweaks. 248 | 249 | ## Version 1.20 (June 12, 2004) 250 | - Introduced the zooming capabilities. As the result, the `Zoom`, `ZoomMin`, `ZoomMax` and `ZoomStep` properties are added to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 251 | - Added the `ClientToGraph` method to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 252 | 253 | ## Version 1.10 (May 16, 2004) 254 | - Added the `Kind` property to the [TGraphLink](Docs/TGraphLink.md) class. 255 | - Renamed the `LinkTypeTo` method of [TGraphNode](Docs/TGraphNode.md) class to `QueryLinkTo`. Also, improved its functionality. 256 | 257 | ## Version 1.09 (May 9, 2004) 258 | - Smashed some bugs. 259 | 260 | ## Version 1.08 (May 10, 2003) 261 | - Fixed the division by zero exception in calculating the distance of a point from a line. 262 | 263 | ## Version 1.07 (April 27, 2003) 264 | - Added the `Background`property to the [TGraphNode](Docs/TGraphNode.md) class. 265 | 266 | ## Version 1.06 (April 23, 2003) 267 | - Added the `Print` and `SaveAsMetafile` methods to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 268 | - Removed the `PaintTo` method of the [TSimpleGraph](Docs/TSimpleGraph.md) control. 269 | - Add the `HideSelection` property to the [TSimpleGraph](Docs/TSimpleGraph.md) control. 270 | 271 | ## Version 1.05 (April 21, 2003) 272 | - Added the `Alignment` and `Margin` properties to the [TGraphNode](Docs/TGraphNode.md) class. 273 | 274 | ## Version 1.04 (April 21, 2003) 275 | - Polished the code for the initial public domain release. 276 | 277 | ## Version 1.03 (August 27, 2000) 278 | - Fixed issue in finding the intersection of a line and a round rectangle. 279 | 280 | ## Version 1.02 (August 22, 2000) 281 | - Fixed bug in movement of links. 282 | 283 | ## Version 1.01 (July 01, 2000) 284 | - Fixed the wrong behavior of the control when nodes were locked. 285 | 286 | ## Version 1.00 (June 11, 2000) 287 | - Initial release. -------------------------------------------------------------------------------- /Images/sg1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Images/sg1.gif -------------------------------------------------------------------------------- /Images/sg2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Images/sg2.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2000-2022 Kambiz Khojasteh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | [TSimpleGraph](Docs/TSimpleGraph.md) is a visual Delphi component, which provides a canvas for drawing [simple directed graphs](https://mathworld.wolfram.com/SimpleDirectedGraph.html). 4 | 5 | ![SimpleGraph](Images/sg1.gif) 6 | 7 | The control has the following predefined node types for basic geometric shapes: 8 | 9 | - Triangle 10 | - Rhomboid 11 | - Rectangle 12 | - Rounded Rectangle 13 | - Pentagon 14 | - Hexagon 15 | - Ellipse 16 | 17 | By overriding one or two methods, a new node type can be derived easily from one of the existing node classes. 18 | 19 | The control has one predefined link (edge) type. Each endpoint of a link can be anchored to a node or another link. 20 | 21 | ![SimpleGraph](Images/sg2.gif) 22 | 23 | The repository contains the source code of a Delphi application, which demonstrates the features of the [TSimpleGraph](Docs/TSimpleGraph.md) control in action. 24 | 25 | See the [documentation](Docs/README.md) for details. 26 | 27 | Installation 28 | ============ 29 | Add the following file into a new or existing package: 30 | 31 | - `SimpleGraph.pas` 32 | 33 | The following packages must be added to the requires clause of your package: 34 | 35 | - `VCL` 36 | - `RTL` (for Delphi 6 or higher only) 37 | - `DesignIDE` (for design-time package of Delphi 6 or higher only) 38 | 39 | Ensure `SimpleGraph.pas` and `DELPHIAREA.INC` files are in the search path of your Delphi installation. -------------------------------------------------------------------------------- /Source/DELPHIAREA.INC: -------------------------------------------------------------------------------- 1 | { Compiler Settings } 2 | { Last modified: 2013-01-05 } 3 | 4 | {$B-} // Complete Boolean Evaluation Off 5 | {$R-} // Range Checking Off 6 | {$Q-} // Overflow Checking Off 7 | {$V-} // Var String Checking Off 8 | {$T-} // Typed @ operator Off 9 | {$X+} // Extended Syntax On 10 | {$P+} // Open String Params On 11 | {$O+} // Optimization On 12 | {$IFDEF WIN32} 13 | {$H+} // Use long strings by default 14 | {$ENDIF} 15 | 16 | { Assume the latest version of compiler is available } 17 | 18 | {$DEFINE COMPILER_XE3_UP} 19 | {$DEFINE COMPILER_XE2_UP} 20 | {$DEFINE COMPILER_XE_UP} 21 | {$DEFINE COMPILER2010_UP} 22 | {$DEFINE COMPILER2009_UP} 23 | {$DEFINE COMPILER2007_UP} 24 | {$DEFINE COMPILER2006_UP} 25 | {$DEFINE COMPILER2005_UP} 26 | {$DEFINE COMPILER7_UP} 27 | {$DEFINE COMPILER6_UP} 28 | {$DEFINE COMPILER5_UP} 29 | {$DEFINE COMPILER4_UP} 30 | {$DEFINE COMPILER3_UP} 31 | {$DEFINE COMPILER2_UP} 32 | 33 | { Then find the wrong assumptions (.NET versions are ignored) } 34 | 35 | {$IFDEF VER240} // Delphi XE3 36 | // nothing to do 37 | {$ENDIF} 38 | 39 | {$IFDEF VER230} // Delphi XE2 40 | {$UNDEF COMPILER_XE3_UP} 41 | {$ENDIF} 42 | 43 | {$IFDEF VER220} // Delphi XE 44 | {$UNDEF COMPILER_XE3_UP} 45 | {$UNDEF COMPILER_XE2_UP} 46 | {$ENDIF} 47 | 48 | {$IFDEF VER210} // Delphi 2010 49 | {$UNDEF COMPILER_XE3_UP} 50 | {$UNDEF COMPILER_XE2_UP} 51 | {$UNDEF COMPILER_XE_UP} 52 | {$ENDIF} 53 | 54 | {$IFDEF VER200} // Delphi 2009 55 | {$UNDEF COMPILER_XE3_UP} 56 | {$UNDEF COMPILER_XE2_UP} 57 | {$UNDEF COMPILER_XE_UP} 58 | {$UNDEF COMPILER2010_UP} 59 | {$ENDIF} 60 | 61 | {$IFDEF VER185} // Delphi 2007 62 | {$UNDEF COMPILER_XE3_UP} 63 | {$UNDEF COMPILER_XE2_UP} 64 | {$UNDEF COMPILER_XE_UP} 65 | {$UNDEF COMPILER2010_UP} 66 | {$UNDEF COMPILER2009_UP} 67 | {$ENDIF} 68 | 69 | {$IFDEF VER180} // Delphi 2006 70 | {$UNDEF COMPILER_XE3_UP} 71 | {$UNDEF COMPILER_XE2_UP} 72 | {$UNDEF COMPILER_XE_UP} 73 | {$UNDEF COMPILER2010_UP} 74 | {$UNDEF COMPILER2009_UP} 75 | {$UNDEF COMPILER2007_UP} 76 | {$ENDIF} 77 | 78 | {$IFDEF VER170} // Delphi 2005 79 | {$UNDEF COMPILER_XE3_UP} 80 | {$UNDEF COMPILER_XE2_UP} 81 | {$UNDEF COMPILER_XE_UP} 82 | {$UNDEF COMPILER2010_UP} 83 | {$UNDEF COMPILER2009_UP} 84 | {$UNDEF COMPILER2007_UP} 85 | {$UNDEF COMPILER2006_UP} 86 | {$ENDIF} 87 | 88 | {$IFDEF VER150} // Delphi 7 89 | {$UNDEF COMPILER_XE3_UP} 90 | {$UNDEF COMPILER_XE2_UP} 91 | {$UNDEF COMPILER_XE_UP} 92 | {$UNDEF COMPILER2010_UP} 93 | {$UNDEF COMPILER2009_UP} 94 | {$UNDEF COMPILER2007_UP} 95 | {$UNDEF COMPILER2006_UP} 96 | {$UNDEF COMPILER2005_UP} 97 | {$ENDIF} 98 | 99 | {$IFDEF VER140} // Delphi 6 & C++Builder 6 100 | {$UNDEF COMPILER_XE3_UP} 101 | {$UNDEF COMPILER_XE2_UP} 102 | {$UNDEF COMPILER_XE_UP} 103 | {$UNDEF COMPILER2010_UP} 104 | {$UNDEF COMPILER2009_UP} 105 | {$UNDEF COMPILER2007_UP} 106 | {$UNDEF COMPILER2006_UP} 107 | {$UNDEF COMPILER2005_UP} 108 | {$UNDEF COMPILER7_UP} 109 | {$ENDIF} 110 | 111 | {$IFDEF VER130} // Delphi 5 & C++Builder 5 112 | {$UNDEF COMPILER_XE3_UP} 113 | {$UNDEF COMPILER_XE2_UP} 114 | {$UNDEF COMPILER_XE_UP} 115 | {$UNDEF COMPILER2010_UP} 116 | {$UNDEF COMPILER2009_UP} 117 | {$UNDEF COMPILER2007_UP} 118 | {$UNDEF COMPILER2006_UP} 119 | {$UNDEF COMPILER2005_UP} 120 | {$UNDEF COMPILER7_UP} 121 | {$UNDEF COMPILER6_UP} 122 | {$ENDIF} 123 | 124 | {$IFDEF VER130} // Delphi 5 & C++Builder 5 125 | {$UNDEF COMPILER_XE3_UP} 126 | {$UNDEF COMPILER_XE2_UP} 127 | {$UNDEF COMPILER_XE_UP} 128 | {$UNDEF COMPILER2010_UP} 129 | {$UNDEF COMPILER2009_UP} 130 | {$UNDEF COMPILER2007_UP} 131 | {$UNDEF COMPILER2006_UP} 132 | {$UNDEF COMPILER2005_UP} 133 | {$UNDEF COMPILER7_UP} 134 | {$UNDEF COMPILER6_UP} 135 | {$ENDIF} 136 | 137 | {$IFDEF VER125} // C++Builder 4 138 | {$UNDEF COMPILER_XE3_UP} 139 | {$UNDEF COMPILER_XE2_UP} 140 | {$UNDEF COMPILER_XE_UP} 141 | {$UNDEF COMPILER2010_UP} 142 | {$UNDEF COMPILER2009_UP} 143 | {$UNDEF COMPILER2007_UP} 144 | {$UNDEF COMPILER2006_UP} 145 | {$UNDEF COMPILER2005_UP} 146 | {$UNDEF COMPILER7_UP} 147 | {$UNDEF COMPILER6_UP} 148 | {$UNDEF COMPILER5_UP} 149 | {$ENDIF} 150 | 151 | {$IFDEF VER120} // Delphi 4 152 | {$UNDEF COMPILER_XE3_UP} 153 | {$UNDEF COMPILER_XE2_UP} 154 | {$UNDEF COMPILER_XE_UP} 155 | {$UNDEF COMPILER2010_UP} 156 | {$UNDEF COMPILER2009_UP} 157 | {$UNDEF COMPILER2007_UP} 158 | {$UNDEF COMPILER2006_UP} 159 | {$UNDEF COMPILER2005_UP} 160 | {$UNDEF COMPILER7_UP} 161 | {$UNDEF COMPILER6_UP} 162 | {$UNDEF COMPILER5_UP} 163 | {$ENDIF} 164 | 165 | {$IFDEF VER110} // C++Builder 3 166 | {$UNDEF COMPILER_XE3_UP} 167 | {$UNDEF COMPILER_XE2_UP} 168 | {$UNDEF COMPILER_XE_UP} 169 | {$UNDEF COMPILER2010_UP} 170 | {$UNDEF COMPILER2009_UP} 171 | {$UNDEF COMPILER2007_UP} 172 | {$UNDEF COMPILER2006_UP} 173 | {$UNDEF COMPILER2005_UP} 174 | {$UNDEF COMPILER7_UP} 175 | {$UNDEF COMPILER6_UP} 176 | {$UNDEF COMPILER5_UP} 177 | {$UNDEF COMPILER4_UP} 178 | {$ENDIF} 179 | 180 | {$IFDEF VER100} // Delphi 3 181 | {$UNDEF COMPILER_XE3_UP} 182 | {$UNDEF COMPILER_XE2_UP} 183 | {$UNDEF COMPILER_XE_UP} 184 | {$UNDEF COMPILER2010_UP} 185 | {$UNDEF COMPILER2009_UP} 186 | {$UNDEF COMPILER2007_UP} 187 | {$UNDEF COMPILER2006_UP} 188 | {$UNDEF COMPILER2005_UP} 189 | {$UNDEF COMPILER7_UP} 190 | {$UNDEF COMPILER6_UP} 191 | {$UNDEF COMPILER5_UP} 192 | {$UNDEF COMPILER4_UP} 193 | {$ENDIF} 194 | 195 | {$IFDEF VER93} // C++Builder 1 196 | {$UNDEF COMPILER_XE3_UP} 197 | {$UNDEF COMPILER_XE2_UP} 198 | {$UNDEF COMPILER_XE_UP} 199 | {$UNDEF COMPILER2010_UP} 200 | {$UNDEF COMPILER2009_UP} 201 | {$UNDEF COMPILER2007_UP} 202 | {$UNDEF COMPILER2006_UP} 203 | {$UNDEF COMPILER2005_UP} 204 | {$UNDEF COMPILER7_UP} 205 | {$UNDEF COMPILER6_UP} 206 | {$UNDEF COMPILER5_UP} 207 | {$UNDEF COMPILER4_UP} 208 | {$ENDIF} 209 | 210 | {$IFDEF VER90} // Delphi 2 211 | {$UNDEF COMPILER_XE3_UP} 212 | {$UNDEF COMPILER_XE2_UP} 213 | {$UNDEF COMPILER_XE_UP} 214 | {$UNDEF COMPILER2010_UP} 215 | {$UNDEF COMPILER2009_UP} 216 | {$UNDEF COMPILER2007_UP} 217 | {$UNDEF COMPILER2006_UP} 218 | {$UNDEF COMPILER2005_UP} 219 | {$UNDEF COMPILER7_UP} 220 | {$UNDEF COMPILER6_UP} 221 | {$UNDEF COMPILER5_UP} 222 | {$UNDEF COMPILER4_UP} 223 | {$UNDEF COMPILER3_UP} 224 | {$ENDIF} 225 | 226 | {$IFDEF VER80} // Delphi 1 227 | {$UNDEF COMPILER_XE3_UP} 228 | {$UNDEF COMPILER_XE2_UP} 229 | {$UNDEF COMPILER_XE_UP} 230 | {$UNDEF COMPILER2010_UP} 231 | {$UNDEF COMPILER2009_UP} 232 | {$UNDEF COMPILER2007_UP} 233 | {$UNDEF COMPILER2006_UP} 234 | {$UNDEF COMPILER2005_UP} 235 | {$UNDEF COMPILER7_UP} 236 | {$UNDEF COMPILER6_UP} 237 | {$UNDEF COMPILER5_UP} 238 | {$UNDEF COMPILER4_UP} 239 | {$UNDEF COMPILER3_UP} 240 | {$UNDEF COMPILER2_UP} 241 | {$ENDIF} 242 | 243 | {$IFDEF COMPILER2010_UP} 244 | {$INLINE AUTO} 245 | {$ELSE} 246 | {$IFDEF COMPILER2009_UP} 247 | {$INLINE ON} 248 | {$ENDIF} 249 | {$ENDIF} 250 | -------------------------------------------------------------------------------- /Source/SimpleGraph.dcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Source/SimpleGraph.dcr -------------------------------------------------------------------------------- /Source/SimpleGraph.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Khojasteh/simple-graph/6657005a5e6691a9b58dc145d311f3e48822c0d5/Source/SimpleGraph.res --------------------------------------------------------------------------------