Re: VB6 Link-Label-Widget with colored KeyWord-rendering
Originally Posted by xiaoyao
Widget, cario is by gdiplus.dll Packaging out of the drawing components?
No, all (RC6)-Cairo-Widgets work independent from gdiplus.dll.
That's the whole point of the RC6-framework (and why it is "somewhat larger")...
It tries to work "as MS-independent as possible" -
(also with the relatively ADO/DAO-compatible cConnection/cRecordset Classes, which work against SQLite).
The "outline", how the above Demo works, is as follows - starting with the Hierarchy:
- fTest.frm (which only "knows" and "deals with" the Widget-instances, as provided by cwLinkText.cls)
---- cwLinkText.cls (which only "knows" and "deals with" the Class-instance, as provided by cTextSplit.cls)
-------- cTextSplit.cls (which works at the lowest level, and provides the basic "Word-Splitting"-Services)
Explanation "from the bottom up" follows:
Since we want to render a given (longer) Text-String - which might not fit onto a "single line" -
the first thing we need, is a "word-breaking-algorithm", which takes apart the longer string "row-by-fitting-row".
(determining, which parts of the longer text belong (after breaking at a given width), into which line-of-text ... and "how many lines will be needed").
This workd-break-algo is called from within cTextSplit.ParseText -
which in turn calls an already built-in Context-method: CC.CalcTextRowsInfo Text, AvailableWidth, ..., ...
So, the first problem (word-breaking, across multiple text-rows) can be solved in a single line of code -
which is followed by looping over the "SubStrings" for each of the "Lines of just broken Text".
(we are still in cTextSplit.ParseText here, where this loop is defined).
We could already "directly render" these split-up TextRow-Substrings directly onto a Cairo-CC now ...
but since we want "colored, clickable Words" in addition, we first have to "parse for single words" (in each Row of SubText).
And that's why the "Main-Loop over the Rows" in cTextSplit.ParseText -
will delegate the Row-SubText into a Sub-Routine called: ParseWords sRow, i
which further "splits a Line into Words and Non-Word-Parts" (an alternating sequence of those is contained in each TextLine).
And it is this Sub-Word-Parsing (per Line), which will trigger several "Callbacks" and Events,
which are in turn received from the hosting Class one level above: cwLinkText
... which in the end will store some of the "Word-infos" internally, to be able to Render and MouseHover over "colored Words" correctly.
Edit: ...forgot to mention, how the Dictionaries in cwTextLink come into play
(after all that "row-parsing/breaking and word-splitting")...
In short, the via Event incoming "single Words" can be compared very fast (in a case-insensitive manner),
via Dictionary.Exists-checks (where these Words were added priorily as "Keys" along with their associated Color-Value).
Their presence in the Dictionary will make them "Key-Words" in the truest sense - and the rendering-algo (triggered from W_Paint) will react to them properly.
The Form-Code which is then making use of our two cwLinkText-instances does not need much explanation, I guess.
(it's similar enough to, how VB-Controls are handled, in case someone creates them dynamically via Controls.Add)
Olaf
Last edited by Schmidt; May 24th, 2023 at 07:55 AM.
Re: VB6 Link-Label-Widget with colored KeyWord-rendering
Originally Posted by DaveDavis
it is really magic and powerful.
When the form resize to minimum, "Monster" & ChrW(160) & "Girl" lost Red color. Is it normal?
Can those dlls including RC6.dll etc. being used in C++ ATL? If so, can you make few example?
Have just tried that (in an ATL-project with VisualStudio 2022) -
and whilst the integrated COMponent-Viewer (the ObjectCatalog) is able to list all RC6-classes just fine...
an import-statement like: #import "c:\Code\RC6\RC6.dll" no_namespace
...will fail, due to problems, translating the typelib-infos into proper *.tlh and *.tli files.
(partly due to coming in a "legacy typelib-format" - and partly due to missing "sub-typelibs",
which should be "ignored" (like the ObjectCatalog-tree-listing demonstrates nicely).
So, if you really want to use it in C++, you'll have to use "old style defines" (involving ClsID and InterfaceIDs) -
writing dedicated wrappers for the Classes you want to use from it...
Not a task I'd like to tackle... - using it (from within C++) in "LateBound-mode" via IDispatch-Invoke is probably a bit easier -
but then you could always go "the other way" - and use the C++ compiler to "contribute fast companion-dlls" -
which are then used (along with the RC6) directly from VB6/VBA or TwinBasic.
Re: VB6 Link-Label-Widget with colored KeyWord-rendering
Originally Posted by Schmidt
Have just tried that (in an ATL-project with VisualStudio 2022) -
and whilst the integrated COMponent-Viewer (the ObjectCatalog) is able to list all RC6-classes just fine...
an import-statement like: #import "c:\Code\RC6\RC6.dll" no_namespace
...will fail, due to problems, translating the typelib-infos into proper *.tlh and *.tli files.
(partly due to coming in a "legacy typelib-format" - and partly due to missing "sub-typelibs",
which should be "ignored" (like the ObjectCatalog-tree-listing demonstrates nicely).
So, if you really want to use it in C++, you'll have to use "old style defines" (involving ClsID and InterfaceIDs) -
writing dedicated wrappers for the Classes you want to use from it...
Not a task I'd like to tackle... - using it (from within C++) in "LateBound-mode" via IDispatch-Invoke is probably a bit easier -
but then you could always go "the other way" - and use the C++ compiler to "contribute fast companion-dlls" -
which are then used (along with the RC6) directly from VB6/VBA or TwinBasic.
Olaf
Thank you very much for this tips. I used RC6 in few VB6 projects to use one of functionalities of SortedDictionary, now I am on the way to convert my VB6 controls to ATL, after I finish the ATL control, I will try RC6 in my new control.