Calculate the space needed

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Calculate the space needed

Post by ONEEYEMAN » Mon Jan 13, 2020 3:26 pm

Hi, ALL,
Let's say I have a wxTextCtrl.
I also have a text in a form of:
SELECT "a"."x", "b"."y" FROM "a", "b" WHERE "a".id" = "b"."id";
What I'd like to do is to display that string in that text control as:

Code: Select all

SELECT "a"."x",
             "b"."y"
FROM "a",
          "b"
WHERE "a"."id" = "b"."id;
I need a string "b"."y" to be exactly under "a"."x" (unfortunately the formatting is not preserved).

For that I need to calculate the number of spaces I need to add in order to format the string nicely.

What is the best way of doing it?

Or maybe there is a better way?

Thank you.

Kvaz1r
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 216
Joined: Tue Jun 07, 2016 1:07 pm

Re: Calculate the space needed

Post by Kvaz1r » Mon Jan 13, 2020 4:46 pm

First of all you should use monospace font and after that just find length of "SELECT " for second line and "FROM " for forth line. Am I understood you correct?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Calculate the space needed

Post by ONEEYEMAN » Mon Jan 13, 2020 5:45 pm

Hi,
Which fonts are monospace?
How to identify that the font is monospace?
And what do you mean - "identify the length"?

Thank you.

alys666
Super wx Problem Solver
Super wx Problem Solver
Posts: 317
Joined: Tue Oct 18, 2016 2:31 pm

Re: Calculate the space needed

Post by alys666 » Mon Jan 13, 2020 9:27 pm

read about wxFont and search around <wxFONTFAMILY_TELETYPE>
ubuntu 16.04, wxWidgets 3.0.4

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4235
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Calculate the space needed

Post by ONEEYEMAN » Tue Jan 14, 2020 4:33 pm

Thank you guys.
Works as expected.

Post Reply