|
| 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. |
0 commit comments