Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

VB6 Rendering of Nodes in a Graph (with Hover over Connections)

$
0
0
This cairo-(vbRichClient5)-dependent Demo will show (as the Title says) - how to efficiently
implement a scenario, where you have to manage "connectable, draggable Boxes"
(as in the Graph in the following screenshot):



There's a green highlighted Connection (with an appropriate ToolTip), which can - (especially
when the Path is complex) - often cause headaches with regards to: "how-to-implement".

With cairo we have two nice calls available, which can help a great deal, when solving
such more challenging "HitTest-problems":

- cCairoContext.InFill(x, y)
- cCairoContext.InStroke(x, y) <-- this one was used in the Demo

So, what one basically has to do to accomplish a complex HitTest is, to simply apply the Path
in question onto a CairoContext with the appropriate coordinates "as when truly rendered".

Even better, such a cairo-context doesn't have to be derived from "something physically"
(as e.g. a larger ImageSurface), a "virtual one" is already sufficient for that task.

For that purpose (when working with the WidgetEngine, as in this Demo) - each cWidgetBase
already offers such a context over W.MeasureContext.

A slight problem I found was, that whilst CC.InFill always worked reliably, CC.InStroke was only
delivering reliable Hits in 80-90% on the length of a complex Path (as e.g. the Beziers I used here,
due to rounding-errors in the cairo-C-Source).

Though I found a patch for that in the cairo-repo and backported that to the version (vb_cairo_sqlite.dll)
which comes with the RichClient - in consequence CC.InStroke will now work equally reliable as CC.InFill.

So the version of the RichClient (including the latest compile of vb_cairo_sqlite.dll) which will work
well with the zipped Demo-Archive below, needs to be at least 5.0.24
- please visit the Download-
page at vbRichClient.com and update your package appropriately before running it.

Here's the Demo-Zip:
WidgetGraphConnections.zip

Have fun...

Olaf
Attached Files

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>