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 »

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: 126
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: wxtextCtrl - Width (adjusting in code)

Post by kipade »

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 x86_64
wxWidgets-3.3.0
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 »

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: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxtextCtrl - Width (adjusting in code)

Post by doublemax »

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 »

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 »

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 »

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 »

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