wxtextCtrl - Width (adjusting in code)

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
dominover
Knows some wx things
Knows some wx things
Posts: 32
Joined: Sun Sep 23, 2012 3:00 am

wxtextCtrl - Width (adjusting in code)

Post by dominover » Mon Jan 21, 2013 6:06 am

Would anyone know how to adjust the width of a wxtextCtrl in c++ code? I'm referring to the length of the actual widget.

Thanks

kipade
Earned some good credits
Earned some good credits
Posts: 118
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: wxtextCtrl - Width (adjusting in code)

Post by kipade » Mon Jan 21, 2013 8:15 am

You meant, adjust the width with its content?
In fact, you can simply manage it in a sizer, with wxEXPAND flag if it layout in a vertical sizer
Slackware GNU/Linux
wxWidgets-3.0.3

dominover
Knows some wx things
Knows some wx things
Posts: 32
Joined: Sun Sep 23, 2012 3:00 am

Re: wxtextCtrl - Width (adjusting in code)

Post by dominover » Mon Jan 21, 2013 8:50 am

I actually meant the size of the widget.
For example.. Lets say the widget (text control for example) is 100 wide. That is the physical length of the widget in the form is 100 wide as it appears.

How do I make an empty widget (lets say a text control) wider. Not character length or the length it can hold, but the actual appearance of the widget wider, longer etc? It's purely for appearance.

I can do this in the properties of the text control by setting the width to x lets say 100, but I don't know how to do it in my code?

User avatar
doublemax
Moderator
Moderator
Posts: 14898
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxtextCtrl - Width (adjusting in code)

Post by doublemax » Mon Jan 21, 2013 9:16 am

Use the source, Luke!

dominover
Knows some wx things
Knows some wx things
Posts: 32
Joined: Sun Sep 23, 2012 3:00 am

Re: wxtextCtrl - Width (adjusting in code)

Post by dominover » Tue Jan 22, 2013 6:32 am

Thanks for that but I'm still very confused.

I have the wxWidgets book and the website but I can't seem to make sense of wxWindow.

I want to change the width of wxTextCtrl1 but not sure how that relates to wxWindow.

I'm going to guess what this means. Do I use wxWindow::SetSize('and in here use the wxTextCtrl as an argument).. is this right? Or do I need to do something to refer to wxWindow to relate it to wxTextCtrl first?

Very very confused..

Radek
Super wx Problem Solver
Super wx Problem Solver
Posts: 286
Joined: Sun Sep 11, 2011 7:17 am

Re: wxtextCtrl - Width (adjusting in code)

Post by Radek » Tue Jan 22, 2013 7:21 am

wxWindow is a base object of wxTextCtrl. The wxTextCtrl inherits all wxWindow methods and data (and adds wxTextCtrl specific ones). Therefore, all wxWindow methods can be used from wxTextCtrl as if they were wxTextCtrl methods. For example SetSize(). You don't need to qualify by wxWindow::SetSize().

It's a general concept of OOP. Every time you can't find something in a particular object which should be there, search predecessors. Perhaps, some predecessor has already defined it and the descendant has inherited it and needed not to define it again.

dominover
Knows some wx things
Knows some wx things
Posts: 32
Joined: Sun Sep 23, 2012 3:00 am

Re: wxtextCtrl - Width (adjusting in code)

Post by dominover » Tue Jan 22, 2013 10:05 am

Thanks very much, that's a really good explanation.

I'm assuming this means that I can place wxTextCtrl2->SetSize() in my code and it will work like SetSize is wxTexCtrl2's method?

Thanks

dominover
Knows some wx things
Knows some wx things
Posts: 32
Joined: Sun Sep 23, 2012 3:00 am

Re: wxtextCtrl - Width (adjusting in code)

Post by dominover » Tue Jan 22, 2013 10:25 am

Disregard my last post. It works exceptionally well. Thanks for the help.

Post Reply