Author Topic: simple question enable scroll under wxsmith?  (Read 6391 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
simple question enable scroll under wxsmith?
« on: January 04, 2012, 09:28:16 am »
I admit I'm a wxWidgets beginner. (Maybe, this is a wxWidgets related problem)

Now, I have a project I create a wxFrame based project wizards, then I just add a wxPanel in the frame. Now, I have add many items in the panel. Then, the wxPanel is quite big, so if the wxFrame's size is smaller than the wxPanel, some items were cropped. Are there any option that I can enable the scroll bar on the wxFrame so I can scroll if wxFrame size is smaller? (the problem is the scroll bar is shown, but drag the scroll bar gives nothing)

I have tried some way (enable scroll option in wxFrame) but does not work. It looks like there is an item wxScrollWindow, but I have drag this item in wxsmith, but still now how to enable scroll.

Any ideas?

Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: simple question enable scroll under wxsmith?
« Reply #1 on: January 04, 2012, 12:11:41 pm »
Do you know the wxWidgets book:
it's free for download from http://www.informit.com/promotions/promotion.aspx?promo=135563 (there are several other interesting and free books on this side).
Direct link: http://www.phptr.com/content/images/0131473816/downloads/0131473816_book.pdf
               

With wxScrolledWindow, you still need to setup the scrollbars-dimensions, but do not need to create event-handlers for scrolling, as it is needed by other windows.

You can put something like
Code
ScrolledWindow1->SetScrollbars(10, 10, 100, 100);
in the "Extra code" section of the wxScrolledWindow (assuming the variable holding the pointer to the scrolled window is called ScrolledWindow1).

You can place all the stuff directly into it, without the need of a wxPanel.

I personally prefer to work with sizers and use the automatically layout capability of wxWidgets.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: simple question enable scroll under wxsmith?
« Reply #2 on: January 04, 2012, 03:02:47 pm »
Do you know the wxWidgets book:
it's free for download from http://www.informit.com/promotions/promotion.aspx?promo=135563 (there are several other interesting and free books on this side).
Direct link: http://www.phptr.com/content/images/0131473816/downloads/0131473816_book.pdf
Yes, I have this book(CHM version) when I begin to use wxWidgets three years ago, but I briefly read it :).
Now I see there is a section "container window" in chapter 4 to introduce the wxScrolledWindow, so I will read it right now, Thank you very much for your directions and links.
               
Quote
With wxScrolledWindow, you still need to setup the scrollbars-dimensions, but do not need to create event-handlers for scrolling, as it is needed by other windows.

You can put something like
Code
ScrolledWindow1->SetScrollbars(10, 10, 100, 100);
in the "Extra code" section of the wxScrolledWindow (assuming the variable holding the pointer to the scrolled window is called ScrolledWindow1).

You can place all the stuff directly into it, without the need of a wxPanel.

I personally prefer to work with sizers and use the automatically layout capability of wxWidgets.
I will test your code after carefully reading the "containing window" section.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: simple question enable scroll under wxsmith?
« Reply #3 on: January 04, 2012, 03:40:41 pm »
I found a trick that I can quickly change the type wxPanel to wxScrolledWindow(Leave every items unchanged), see the screen shot:

Then add the extra code
Code
Panel1->SetScrollbars(10, 10, 100, 100);
Now, my original "wxPanel" becomes to "wxScrolledWindow" which has scrolled bars work OK.
Great thanks to jens!!!

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.