Change widgets' size

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.
wxJack
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Jun 20, 2018 8:06 am

Change widgets' size

Postby wxJack » Thu Aug 09, 2018 2:36 pm

Hi everyone:)
I have a question appereantly easy but I can't figure them out..
I'm trying to understand how the sizers work in wxWidgets, so i followed this tutorial http://zetcode.com/gui/wxwidgets/layoutmanagement/ , because I saw this post linked here in this forum, don't remember when..

Trying the example of the wxGridSizer, I want to put high in the center a wxStaticText ; just for exercize, I replace the wxTextCtrl they called "display" , with a static text, as follows:

Code: Select all

display = new wxStaticText(this, -1, wxT("Welcome back to your bank account"), wxPoint(-1, -1),
      wxSize(100, 50), wxALIGN_CENTER);


then, I added it to the main sizer

Code: Select all

sizer->Add(display, 2, wxEXPAND | wxTOP , 4);


1st problem is that that wxSize(x,y) doesn't work, because any value I put into the brackets, the size of the text does not change, but the size where the buttons on the bottom can expand is narrower..like I wanted to expand the sizer where the staticText is placed instead of the staticText itself, but I don't want.

2nd problem is that I don't know how to control how the size of my widget (in this case, the size of the text), will change both when I have the fullscreen and when I have not it, because in my case the size remains unchanged, and I'd prefer it to become bigger when I resize my window to fullscreen

Thanks !!

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

Re: Change widgets' size

Postby doublemax » Thu Aug 09, 2018 3:17 pm

First of all, please make a screenshot that shows what you have right now and explain what you want instead. It makes it much easier to understand.

Then, the Grid* sizers have some unique features that are usually not covered in generic sizer tutorials.

And finally: Use wxFlexGridSizer instead of wxGridSizer and check the AddGrowableCol and AddGrowableRow methods.
Use the source, Luke!

wxJack
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed Jun 20, 2018 8:06 am

Re: Change widgets' size

Postby wxJack » Thu Aug 09, 2018 8:58 pm

You're right..so,

https://ibb.co/fHxjmU

I would like to have something like this image but with a bigger wxStaticText.

I will follow your advice, now I go immediately to see wxGridSizer
Attachments
fourth.PNG
fourth.PNG (14.81 KiB) Viewed 71 times

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

Re: Change widgets' size

Postby doublemax » Fri Aug 10, 2018 1:42 am

If you want the actual text to be bigger, you'll have to manually set a bigger font. Sizers don't do that, they only set the outer size of a control.
Use the source, Luke!


Return to “C++ Development”

Who is online

Users browsing this forum: Google [Bot] and 38 guests