days ago, i studied @Bob Keeneys TextInputCanvas Sample-Project. It’s good to start with this control. I thought about how to extend these Control to use it as a minimal Word-Processor. I know Bob’s Formated Text Control, but i think it’s cool to have a look, how i’m able to do simple RichText-things with that control.
[h]Multiline Text[/h]
It’s simple along you use a single TextFont and TextSize.
split your Text into an Paragraph-Array by EndOfLine-Seperator
check, if StringWidth of each line > TextInputCanvas.Width. If yes, split again, if no, everythigs fine
draw each Paragraph/line
[h]Formatted Text[/h]
each Paragraph (line) has multiple words, characters.
each character could have his own TextFont, TextSize, TextColor (enough at the moment)
to calculate the current LineWidth we need to add the Width of each Character and check if total width of TextInputCanvas < or > LineWidth, again yes or no…
how to calculate LineHeight? Need to check every Characters TextSize. Biggest TextSize = LineHeight
[h]Structure[/h]
Character
TextFont
TextSize
TextColor
Word
Array of Characters
GetWordWidth As Integer
GetWordHeight As Integer // highest character
Line
Array of Words
GetLineWidth As Integer
Get LineHeight As Integer // highest word
You see, just some thoughts about so a task.
How would you go on with a concept? How to do the calculations? Any input, additions? Someone interested to work on such a control together?
I tried to use the cmdPaste in DoCommand to insert Text from Clipboard, but it doesn’t work. Why?
[code]…
case CmdPaste
MsgBox(“Paste”)
Dim c As New Clipboard
If c.TextAvailable Then
InsertText(c.Text, mSelection)
End If
c.Close
…[/code]
How to go on? My goal is to make it work with multiline Text. But how?
you have to recalculate the Baseline für each Line
a Line is defined as an string with &uA as his last character
how to do auto linebreak, if line.width >= TextInputCanvas.Width
how to set/use blinking caret in multilined Text?
how to realize formatted Textoutput? Each character has a own fontsize and font? Line.Width = Width of each character (graphics.StringWidth(currentCharacter)). Baseline of currentLine = which character within line has the biggest fontsize?
I will need a multi-line version as well in the near future as I’ll have a project that will require it. I will definitely be working on this, or even subcontracting someone to do it (maybe some dollars for you Bob?). I’m not ready right now, however. But I’ll be sure to post my progress and results in this thread.
Formatted Text Control is a very large project and it’s really showing its age. It was written many years ago before Cocoa, and 64 bit, Linux, and HiDPI were a concern. What I really need to do it rewrite it to modern standards. However, that’s a HUGE undertaking and right now Shorts is our #1 priority. Having a consulting project or two would definitely speed things up though.
i can understand you. Can you tell me, why cmdPaste (as shown in my last Post) doesn’t work?
And are my steps the right ones? Or am i wrong with my thoughs about how to perform multiline and multi styled text?
[quote=310835:@Norman Palardy]You do realize you dont need ANY plugin to subclass TextInputCanvas on any platform
TextInputCanvas is built into the IDE
Simply create a class and set its super to “TextInputCanvas”[/quote]
[quote=310826:@Martin Trippensee]I tried to use the cmdPaste in DoCommand to insert Text from Clipboard, but it doesn’t work. Why?
…
case CmdPaste
MsgBox(“Paste”)
Dim c As New Clipboard
If c.TextAvailable Then
InsertText(c.Text, mSelection)
End If
c.Close
…
[/quote]
I made it work by implementing : enablemenuitem ( enable editpaste when there is text in the clipboard)
and the editpaste menuhandler using inserttext method to do the paste.
but yes it seems that the docommand paste command doesnt fire.