a few newbie questions

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
newbee
In need of some credit
In need of some credit
Posts: 8
Joined: Sat Nov 19, 2011 8:54 pm

a few newbie questions

Post by newbee »

Hi,I have a few questions.Hope its not a problem to write all of them mixed in one topic.


1)for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{dc.DrawPoint(j,i); wxSleep(1);}
Is this wrong?If yes why? (here newbie thinks that he can see the points being drawn one-by-one)

2)I draw on a panel,and if I set the stretch parameter for that panel in the boxsizer,when I resize the main window(increase the size),the drawing changes (stretches).In other words,Is it normal the drawing(e.g rectangles) I made using absolute coordinates changes shape at last row&column when the drawing panel changes size?(please see the attachments)

3)I have a boxsizer based layout.And there is a panel at the middle of it.According to user selections,I change the size of the panel to have room for larger content.How can I change the size of the panel,and let the whole window to resize itself according to new dimensions?(thisis the same panel in question2,on which I draw using wxPaintDC)I tried but coulnt re-set the layout and wxALIGN_CENTER didnt work in this new case.

Thanks in advance
User avatar
doublemax
Moderator
Moderator
Posts: 19161
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: a few newbie questions

Post by doublemax »

Code: Select all

for(int i=0;i<n;i++)
  for(int j=0;j<n;j++)
  {
    dc.DrawPoint(j,i);
    wxSleep(1);
  }
Is this wrong?If yes why? (here newbie thinks that he can see the points being drawn one-by-one)
Not technically wrong, but still bad :)

Whether you see the single dots appearing depends on the platform and on the type of wxDC you're painting on. With a normal wxPaintDC or wxClientDC on a platform that doesn't automatically use double buffering you should see the dots one-by-one.

This is still bad though, because you're blocking the gui and depending on what the user does, several new paint events may get triggered and you end up with a totally unresponsive application.

2)I draw on a panel,and if I set the stretch parameter for that panel in the boxsizer,when I resize the main window(increase the size),the drawing changes (stretches).In other words,Is it normal the drawing(e.g rectangles) I made using absolute coordinates changes shape at last row&column when the drawing panel changes size?(please see the attachments)
What attachment?
The graphic should not stretch, without further information i'd say there must be an error in your drawing code.
3)I have a boxsizer based layout.And there is a panel at the middle of it.According to user selections,I change the size of the panel to have room for larger content.How can I change the size of the panel,and let the whole window to resize itself according to new dimensions?
Usually when you put a control into a sizer, you gave up control over its size. You can use wxWindow::SetMinSize() / SetMaxSize() to set contraints though. Afterwards call Layout() on the topmost sizer.
Use the source, Luke!
Post Reply