Page 2 of 2

Posted: Fri May 07, 2010 1:05 pm
by CMark
Hi Jim,

It doesn't make the problem go away.

The idea of the example is to correctly resize the window.

And if you use

Code: Select all

	this->SetSizerAndFit(topSizer); 
than you simply can't resize the window enough.

It's easy to see.
Just look at these posts again and count A's and B's.
CMark wrote:Hi Jim

Did you try to resize the window ?

Did you get correct result

Code: Select all

AAAAAAA|BBBBBBB
CCCCCCC|DDDDDDD
or incorrect ?

Code: Select all

AAAABBB|BBBBBBB
CCCCCCC|DDDDDDD
JimFairway wrote:
CMark,
Hi Jim

Did you try to resize the window ?

Did you get correct result
Yes, and yes.

Jim

You'll see there are 7 A's and 7 B's
in the correct result.

If you use wx 2.9.1. (as Catalin and Auria confirmed)
you get that correct result.
See Auria ...
Auria wrote:when I resize the frame too small the right side simply gets clipped, it does not go over the left side.
But if you use

Code: Select all

	this->SetSizerAndFit(topSizer); 
you just can't get it
because that will stop you on 10 A's and 10 B's
so that will not resize correctly when too small
but simply won't let you to resize too small.

Posted: Fri May 07, 2010 1:43 pm
by catalin
Aha! Initially I thought you didn't want the frame to resize if the space available reached the controls' size, but used a way that exposed that defect.
I'm afraid that there is nothing you can do in 2.8 about this and your current approach.

But why not let the static texts be resizeable? With the correct sizers setup and flags I'm sure you can have your result.
Don't forget about wxSizer::AddSpacer and wxSizer::AddStretchSpacer.

Posted: Fri May 07, 2010 1:53 pm
by JimFairway
so that will not resize correctly when too small
but simply won't let you to resize too small.
Isn't too small, too small?
I.e. why let it get to the point of unusable? If user doesn't want the frame in the way, they can minimize it.

Jim

Posted: Fri May 07, 2010 2:06 pm
by CMark
JimFairway wrote:
so that will not resize correctly when too small
but simply won't let you to resize too small.
Isn't too small, too small?
I.e. why let it get to the point of unusable? If user doesn't want the frame in the way, they can minimize it.

Jim
"Too small" means only too small to fit to all contents.
So it is not unusable at all.
That's way many applications let that.
That's way it is corrected in wx 2.9.1.

Posted: Fri May 07, 2010 2:37 pm
by CMark
Hi Catalin,
catalin wrote:But why not let the static texts be resizeable? With the correct sizers setup and flags I'm sure you can have your result.
Don't forget about wxSizer::AddSpacer and wxSizer::AddStretchSpacer.
It seems as an interesting idea.
But I'm just trying to start with wx/cpp/...
and not sure how to do it.

If you could change my code in that manner

Code: Select all


    wxFrame* frame1 = this;

    wxBoxSizer* bSizerH = new wxBoxSizer(wxHORIZONTAL);
	frame1->SetSizer(bSizerH);

    wxBoxSizer* bSizerV1 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV1, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST1 = new wxStaticText( frame1, wxID_STATIC, _("AAAAAAAAAA"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizerV1->Add(wxST1, 0, wxALIGN_LEFT|wxALL, 5);

    wxTextCtrl* wxTC1 = new wxTextCtrl( frame1, ID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV1->Add(wxTC1, 1, wxEXPAND|wxALL, 5);

    wxBoxSizer* bSizerV2 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV2, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST2 = new wxStaticText( frame1, wxID_STATIC, _("BBBBBBBBBB"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizerV2->Add(wxST2, 0, wxALIGN_RIGHT|wxALL, 5);

    wxTextCtrl* wxTC2 = new wxTextCtrl( frame1, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV2->Add(wxTC2, 1, wxEXPAND|wxALL, 5);

and try it in wx 2.8
I'd like to see it.

But only if it isn't too much time consuming for you.

Anyway, thanks a lot!

Posted: Fri May 07, 2010 2:55 pm
by catalin
Hehe, I think I got it with minimal changes :)

Add wxEXPAND for the static texts, and wxALIGN_RIGHT flag for wxST2, when created.

Code: Select all

    wxFrame* frame1 = this;

    wxBoxSizer* bSizerH = new wxBoxSizer(wxHORIZONTAL);
        frame1->SetSizer(bSizerH);

    wxBoxSizer* bSizerV1 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV1, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST1 = new wxStaticText( frame1, wxID_STATIC, _("AAAAAAAAAA"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizerV1->Add(wxST1, 0, wxALIGN_LEFT|wxEXPAND|wxALL, 5);

    wxTextCtrl* wxTC1 = new wxTextCtrl( frame1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV1->Add(wxTC1, 1, wxEXPAND|wxALL, 5);

    wxBoxSizer* bSizerV2 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV2, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST2 = new wxStaticText( frame1, wxID_STATIC, _("BBBBBBBBBB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
    bSizerV2->Add(wxST2, 0, wxALIGN_RIGHT|wxEXPAND|wxALL, 5);

    wxTextCtrl* wxTC2 = new wxTextCtrl( frame1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV2->Add(wxTC2, 1, wxEXPAND|wxALL, 5);

Posted: Fri May 07, 2010 4:12 pm
by CMark
Hi Catalin,

What to say ?

You're great !

Thanks again :D :D :D

Posted: Sat May 08, 2010 8:31 am
by CMark
Hi,

It's the first time I need to close a topic
and I'm not so sure about it.

So I won't do it right now.
I'll explain here what I think
and if not some posts/complaints against it
I'll do it so in a few days.

I think I should accept Catalin's post
catalin wrote:Hi,
I believe you are using box sizers and wxW 2.8 for this.
There were some bugs with box sizer algorithms, including overlapping of windows, which were fixed in the trunk (Changesets 56010, 63704, 63705, 63706), so you won't get them if using 2.8.
...
..., switch to using trunk / 2.9.1 :)
With this post Catalin solved this topic
almost immediately (at the beginning).

So, if you want to avoid these resize problems
you should use wx 2.9.1.

Catalin make some other interesting posts here
including an nice idea/trick for the example
to work in spite of wx 2.8. problems
catalin wrote:Hehe, I think I got it with minimal changes :)

Add wxEXPAND for the static texts, and wxALIGN_RIGHT flag for wxST2, when created.

Code: Select all

    wxFrame* frame1 = this;

    wxBoxSizer* bSizerH = new wxBoxSizer(wxHORIZONTAL);
        frame1->SetSizer(bSizerH);

    wxBoxSizer* bSizerV1 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV1, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST1 = new wxStaticText( frame1, wxID_STATIC, _("AAAAAAAAAA"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizerV1->Add(wxST1, 0, wxALIGN_LEFT|wxEXPAND|wxALL, 5);

    wxTextCtrl* wxTC1 = new wxTextCtrl( frame1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV1->Add(wxTC1, 1, wxEXPAND|wxALL, 5);

    wxBoxSizer* bSizerV2 = new wxBoxSizer(wxVERTICAL);
    bSizerH->Add(bSizerV2, 1, wxEXPAND|wxALL, 5);

    wxStaticText* wxST2 = new wxStaticText( frame1, wxID_STATIC, _("BBBBBBBBBB"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
    bSizerV2->Add(wxST2, 0, wxALIGN_RIGHT|wxEXPAND|wxALL, 5);

    wxTextCtrl* wxTC2 = new wxTextCtrl( frame1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
    bSizerV2->Add(wxTC2, 1, wxEXPAND|wxALL, 5);
Of course, it's not a way to go.
A window can have a lot of controls.
And an application can have a lot of windows.
So it wouldn't be so easy to do it that way.
Also, I guess, it wouldn't be so good idea
for vertical resizing problems
(like in Catalin's example).
Although, it shows Catalin can make even broken record play.

Jim Fairway also contributed this topic a lot
with his posts
esspecially ones about Catalin's example.
To me the most helpful was Jim's topic confirming
that wx 2.8.7. also has problems with Catalin's example
and I think I should mark that post as assist.

Auria's post confirming that wx 2.9.1.
works correctly with the example
was usuful too.

Thanks again to all.

Best wishes.