Recent

Author Topic: The problem of drawing lines under strings  (Read 10315 times)

jianwt

  • Full Member
  • ***
  • Posts: 164
The problem of drawing lines under strings
« on: January 25, 2024, 02:32:12 am »
A problem that has been bothering me for a long time is the problem of drawing lines under a text string during the input process.

How to create a horizontal line under the input string in Linux system (not the underline of the string), and when the string is folded or entered, a line will be automatically added, allowing for free input of the string on the line.

What controls can achieve this effect!  Or make a simple demo, I am extremely grateful.  Looking forward to hearing back!!
(Google Translate, not necessarily correct)

krolikbest

  • Sr. Member
  • ****
  • Posts: 273
Re: The problem of drawing lines under strings
« Reply #1 on: January 25, 2024, 08:53:43 am »
If using e.g. Canvas you could then simply MoveTo, LineTo etc, but your question didn't provide an info where/how the process of  input string is done

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: The problem of drawing lines under strings
« Reply #2 on: January 25, 2024, 11:12:28 am »
iow do you mean simply underline or specific purposely drawn lines?
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: The problem of drawing lines under strings
« Reply #3 on: January 25, 2024, 12:47:03 pm »
I assume he mean some kind of chat/messenger visualization thing, I would try my luck with SynEdit, there you can, more or less, easy color (highlight) each user, maybe even let SynEdit draw a line under a finished text.
I would start with a two component setup, one is the conversation display (SynEdit) and a simple TEdit to enter text.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: The problem of drawing lines under strings
« Reply #4 on: January 26, 2024, 02:39:10 am »
Thank you for the answers from the above experts.

Maybe I didn't express it clearly. It's actually a text input control like TMEMO(TRichMemo), where I input strings and require a horizontal line from left to right below each line of string. When the input string is less than one line, the line lines should also be filled from left to right. When the input string exceeds one line or when using the enter key, a line will be automatically drawn.
(The purpose of drawing horizontal lines is to show the effect.)
See the picture below.

Because I don't understand English, I completely translated it using translation software!!
« Last Edit: January 27, 2024, 03:48:15 am by jianwt »

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: The problem of drawing lines under strings
« Reply #5 on: January 26, 2024, 02:53:53 am »
@KodeZwerg
Thank you. How to implement this function with SynEdit, can you help me? Or write a little DEMO. Thank you very much!

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: The problem of drawing lines under strings
« Reply #6 on: January 27, 2024, 04:08:17 am »
In fact, it's just an input field with parallel lines of water under the string. Water parallel lines are used to enhance the display. The full effect is shown below.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: The problem of drawing lines under strings
« Reply #7 on: January 27, 2024, 06:40:38 am »
@KodeZwerg:
I am not sure on your idea to use SynEdit (as I do not know enough about it) but note that TS explicitly stated not wanting to use the underlined font option in order to achieve the effect, rather to use drawing actual lines between two separate text-lines. I have no idea if synedit is able to accomplish that (in a easy manner)
Today is tomorrow's yesterday.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: The problem of drawing lines under strings
« Reply #8 on: January 27, 2024, 01:12:32 pm »
@TRon, I was thinking about to use the Gutter and its properties but also I am not a SynEdit expert but since IDE draw it on specific input, my thought was that in OP case the input is a VK_RETURN = let it draw a line.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

jamie

  • Hero Member
  • *****
  • Posts: 7490
Re: The problem of drawing lines under strings
« Reply #9 on: January 27, 2024, 09:45:25 pm »
StringGrid

I just fooled around a little here and got what he wanted.

Now to adjust the colors of the line.

1 Column
OnResize to adjust the width of the column.
AutoEditmode = true;
goEdit etc.

use the key functions to add more rows as needed.

I spent like 5 mins just for a concept model, I am sure it can be expanded on.
The only true wisdom is knowing you know nothing

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: The problem of drawing lines under strings
« Reply #10 on: January 27, 2024, 10:20:58 pm »
@KodeZwerg: interesting idea. Will have to look at that later.

One thing is for sure and that is that I got nowhere with a standard tmemo control.

@jamie: yeah a stringgrid will (of course) do but that is perhaps a bit overkill for TS.

@jianwt: Did you have any idea yourself on what type of control you would like to use for inputting your strings ? Or would jamie's solution using a stringgrid (showing only one column) be enough for your use case ? I ask because there are plenty of existing customdrawn controls (which are usually pretty easy to override their drawing mechanism).
Today is tomorrow's yesterday.

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: The problem of drawing lines under strings
« Reply #11 on: January 28, 2024, 02:36:25 am »
@jamie@TRon, thanks for the great advice.
Due to the limitations of stringgrid (for example, one line cannot automatically replace the next line when the input is full, instead of a simple carriage return), the input interface is not only used for input, but also needs to take string data for the next operation (such as setting the font and color of each paragraph). As I am a beginner, I still do not know much about stringgrid operation. It is estimated that it will not achieve the effect you want, but thank you for the advice of 2 masters.
I want to see if there are any other options. I found that the RichViewEdit control can do this, but it is not supported on linux systems.

« Last Edit: January 28, 2024, 02:43:51 am by jianwt »

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: The problem of drawing lines under strings
« Reply #12 on: January 28, 2024, 04:37:54 am »
... the input interface is not only used for input, but also needs to take string data for the next operation (such as setting the font and color of each paragraph).
Oh, but that requires a bit more functionality than just drawing some lines underneath some text  :)

Quote
As I am a beginner, I still do not know much about stringgrid operation.
A stringgrid will indeed not be able to distinguish between different paragraphs (unless a paragraph can be contained within a single stringgrid cell).

Quote
I want to see if there are any other options. I found that the RichViewEdit control can do this, but it is not supported on linux systems.
Looks like me you are looking for a (multi-platform supported) richedit replacement and the closest I can think of is KMemo but I haven't been able to figure out how to customdraw the control so that it is able to display lines as per your (initial) request.
Today is tomorrow's yesterday.

krolikbest

  • Sr. Member
  • ****
  • Posts: 273
Re: The problem of drawing lines under strings
« Reply #13 on: January 28, 2024, 12:57:19 pm »
My idea with Canvas, maybe it helps..

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: The problem of drawing lines under strings
« Reply #14 on: January 29, 2024, 04:11:29 am »
@krolikbest 
Thank you very much.
Horizontal lines should be drawn in RichMemo or SynEdit, because there are other editing operations to be done.

 

TinyPortal © 2005-2018