I'm currently working on a text control that's supposed to clone the behaviour of the mIRC channel textbox. As you'd guess, it's for an IRC client.
However am I in need of a few tips and head ups about how to create such a thing efficiently. It should be restricted to text only, no graphical smily screw arounds, which simplifies the deal.
My current approach is to line, word and format break the line, generate formatting objects to be fed straight into the systems text drawing APIs. It'll regenerate the objects on window resizes.
Currently word and line breaking works by using a lookup table that stores character widths. To find the word break location, I just fly thru the string adding up character widths until I found the best spot to break the word for the remaining render width. Measuring strings works the same way, the API I'm coding against doesn't feature measuring APIs without instancing an object each time I want to measure one. Also my method is currently faster than object instantiation thing.
The next thing to be committed soon will be text selection. I've already ideas about how to do it, by reusing the existing text breaking code.
The reason I'm posting this, is that I'm in awe in the performance of Microsoft Word, compared to mIRC and Klient. Word renders stuff in a jiffy, selecting text like some epileptic up and down barely agitates by CPU graph. mIRC and Klient however make it jump to 80-98% depending on the size of text snippets.
So, anyone already worked on that type of controls and has tips or guides about such a task?
Don't suggest reusing controls, which are licensed under (L)GPL, I'm trying to avoid releasing my source code, especially since the resulting executable should be monolithic (though I've an assembly resolver aside that can load assemblies out of an archive).
Question
Glowstick
I'm currently working on a text control that's supposed to clone the behaviour of the mIRC channel textbox. As you'd guess, it's for an IRC client.
However am I in need of a few tips and head ups about how to create such a thing efficiently. It should be restricted to text only, no graphical smily screw arounds, which simplifies the deal.
My current approach is to line, word and format break the line, generate formatting objects to be fed straight into the systems text drawing APIs. It'll regenerate the objects on window resizes.
Currently word and line breaking works by using a lookup table that stores character widths. To find the word break location, I just fly thru the string adding up character widths until I found the best spot to break the word for the remaining render width. Measuring strings works the same way, the API I'm coding against doesn't feature measuring APIs without instancing an object each time I want to measure one. Also my method is currently faster than object instantiation thing.
The next thing to be committed soon will be text selection. I've already ideas about how to do it, by reusing the existing text breaking code.
The reason I'm posting this, is that I'm in awe in the performance of Microsoft Word, compared to mIRC and Klient. Word renders stuff in a jiffy, selecting text like some epileptic up and down barely agitates by CPU graph. mIRC and Klient however make it jump to 80-98% depending on the size of text snippets.
So, anyone already worked on that type of controls and has tips or guides about such a task?
Don't suggest reusing controls, which are licensed under (L)GPL, I'm trying to avoid releasing my source code, especially since the resulting executable should be monolithic (though I've an assembly resolver aside that can load assemblies out of an archive).
Link to comment
Share on other sites
11 answers to this question
Recommended Posts