SetAlignment for wxTextCtrl

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

SetAlignment for wxTextCtrl

Post by dsilvia »

I originally posted a question generally about this in the General forum, but received 0 response after 8 days.

Here's the problem, and it's not specific to dev-c++ wx beta 6.7, but since that's what I'm using (the others I tried weren't any better and some weren't as good or up to date)...

Whenever you change something in the .wxform, all code generating the widgets is regenerated: understandable.

The problem is with wxTextCtrl. There's no provision to set the alignment to anything other than the default: left. I can add wxTE_RIGHT to the constructor call, but once I change something in the .wxform, I have to do that again. This problem is multiplied by the number of wxTextCtrl widgets I have, and if each has some control associated, sifting through the generated code to effect the replacement can get dicey!

I've tried to find a way to access the wxTextAttr associated with wxTextCtrl, but that mechanism evades me. So, I cannot use SetAlignment.

Furthermore, using SetDefaultStyle seems to have no effect.

This seems to me to be a big piece missing out of simple text display parameters.

There must be a better way!

Display of numbers left justified is _not_ pretty. Nor is it conventional. The only widgets I can find to allow me to set right justification (alignment) don't allow user input.

HELP!!!!

tia,
Dave S.
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Post by tbreina »

The current alpha version has the TE_RIGHT, TE_CENTRE, TE_RICH, etc. alignment options for text controls. I believe we've added/corrected all of the style options for the controls. Currently, the form designer doesn't display the text as right aligned, but the correct wxWidgets option is coded.

-Tony
http://reina.homedns.org/wxdevcpp/
Everybody's got something to hide except for me and my monkey.
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

Post by dsilvia »

Does that mean that I can do what I'm trying to do? If yes, how do I get a copy of the code you're referring to?

thx,
Dave S.
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

Post by dsilvia »

I think I answered my own question. I downloaded devcpp_4jun2005.exe from the link in your reply. Taking a guess, I substituted it for the devcpp.exe in my Dev-Cpp directory (saved the original :wink: ) and tried it on my doodling project before using it on the real thing.

It Works! :D

Thank you for your reply!

I'm also assuming the link you included is a good place to keep an eye on if I have future problems?

tia,
Dave S.
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

Post by dsilvia »

OOPS! What about wxTE_MULTILINE? :(

That's needed for '\n' to be processed correctly. Otherwise it's all one line. I thought, perhaps, wxTE_LINEWRAP would work, but it doesn't.

So, though a multitude of my problems have been solved, I still have one, I've got a message window that I have to patch the constructor for manually each time I make a change in .wxform.

Oh, well, I suppose I'd complain if I were hung with a new rope! :wink:

thx,
Dave S.
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

Post by dsilvia »

A cheap cheat!...

beta 6.7 doesn't know what wxTE_BESTWRAP is, so I select it for my multiline window and define it at the top of my .cpp as wxTE_MULTILINE! :wink:

fyi,
Dave S.
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Post by tbreina »

OOPS! What about wxTE_MULTILINE?
Good catch. I forgot to add it. I just corrected it. There's a new devcpp exectuable on the alpha testers site that should work for you.
I think I answered my own question. I downloaded devcpp_4jun2005.exe from the link in your reply. Taking a guess, I substituted it for the devcpp.exe in my Dev-Cpp directory (saved the original :Wink ) and tried it on my doodling project before using it on the real thing.
That's the right procedure to test it. The alpha test shots are intermittent work based on the current CVS. Yes, it's a good place to get the "latest" version, but it's most definitely a work in progress.

-Tony
Everybody's got something to hide except for me and my monkey.
dsilvia
Earned some good credits
Earned some good credits
Posts: 145
Joined: Sun May 29, 2005 3:42 pm
Location: Bettendorf, Iowa, USA (aka, BFE)

Post by dsilvia »

Thanks again! :D

thx,
Dave S.
Post Reply