How to control text position inside wxTextCtrl

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
keyser
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Apr 05, 2009 2:41 am

How to control text position inside wxTextCtrl

Post by keyser » Sun Apr 05, 2009 2:58 am

I create a single-line wxTextCtrl, but i found that the text inside wxTextCtrl is vertical-top-aligned.

I capture an image from Outlook Express, it's text ctrl have the similar size and font with mine, but it's text position looks like vertical-center-aligned.

How can i do that ?

Why i cannot post my screen shot here ?

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Mon Apr 06, 2009 2:21 am

I'm not sure how to fix the problem, but you can try changing the wxTextCtrl height (decrease the height) to offset the problem.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: How to control text position inside wxTextCtrl

Post by Auria » Mon Apr 06, 2009 12:57 pm

keyser wrote:I create a single-line wxTextCtrl, but i found that the text inside wxTextCtrl is vertical-top-aligned.

I capture an image from Outlook Express, it's text ctrl have the similar size and font with mine, but it's text position looks like vertical-center-aligned.

How can i do that ?

Why i cannot post my screen shot here ?
Probably it's not editable text text? I never saw an editable text editor vertically centered. Maybe try a HTML view component?

keyser
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Apr 05, 2009 2:41 am

Post by keyser » Wed Apr 15, 2009 4:22 pm

Thank you for your answers.

First i try to set the height of wxTextCtrl to the exact height of the text inside. That's actully working fine. But the window very *UGLY* because of the wxTextCtrl.

Second i found lot's of program which has vertical-centered text control. Such as the input box of Windows Caculator. Nearly *EVERY* program's text ctrl *ARE* vertical-centered.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Wed Apr 15, 2009 5:22 pm

keyser wrote: Second i found lot's of program which has vertical-centered text control. Such as the input box of Windows Caculator. Nearly *EVERY* program's text ctrl *ARE* vertical-centered.
Sorry for my ignorance, I suppose those are single-line text controls? In this case, the easiest might be to simply don't set a vertical size, and use the default height. Then it would be just large enough for one line

keyser
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Apr 05, 2009 2:41 am

Post by keyser » Thu Apr 30, 2009 2:40 am

Auria wrote:
keyser wrote: Second i found lot's of program which has vertical-centered text control. Such as the input box of Windows Caculator. Nearly *EVERY* program's text ctrl *ARE* vertical-centered.
Sorry for my ignorance, I suppose those are single-line text controls? In this case, the easiest might be to simply don't set a vertical size, and use the default height. Then it would be just large enough for one line
Thank you for your reply.

Yes i mean single line wxTextCtrl.

The first thing i try is use the default size. (I am working with "wxPython 2.8.9.2 For win32 ANSI" on windows xp, and i am using Chinese characters) But it's not cool, the text is top-aligned.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Fri May 01, 2009 1:35 am

Can you show code and screenshot? Granted, I'm not using wxPython on windows, but I never had issues with default sizes not working

keyser
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Apr 05, 2009 2:41 am

Post by keyser » Sat May 23, 2009 10:59 am

Auria wrote:Can you show code and screenshot? Granted, I'm not using wxPython on windows, but I never had issues with default sizes not working
Here i captured one picture.

The first wxTextCtrl with no border is vertical-centered.
The second one is cool, it have default size and default border. But what i need is a no-border wxTextCtrl
Attachments
BadPlace.PNG
BadPlace.PNG (5.04 KiB) Viewed 3541 times

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Sat May 23, 2009 2:28 pm

Please show us the screen shot and the related source code (wxTextCtrl flags used).
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

Post Reply