Am I understanding this code about regions correctly?

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
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Sep 05, 2013 12:07 am

Am I understanding this code about regions correctly?

Post by wx_n00b » Sat Sep 14, 2013 4:25 pm

Hi, I found the following code online. Now, I'm trying to figure what it does based on the code itself and online docs. I figured that if I can explain what the code does in layman's terms, I'll be able to understand what's going (at the very least have some sense of what is happening.) Are my explanations correct?

If you're curious, I found the code here:

Code: Select all


  // draw two rectangles.  The inside of the rectangles will be white with
  //  gray borders.
  dc.DrawRectangle(101, 20, 50, 50);
  dc.DrawRectangle(110, 40, 50, 50);

  // create two regions that we'll use.  Since regions do not have borders and
  //  instead are hidden and exist only in concept, make sure that they share
  //  the same coordiates.
  wxRegion region1(100, 20, 50, 50);
  wxRegion region2(110, 40, 50, 50);

  // intersect the two regions.

  // after the intersection, get the resulting box (the outer bounds of the
  //  region.)
  wxRect rect1 = region1.GetBox();

  // create a region where we can draw and only there.
  // set the color of the brush (which is used to fill in a rectangle.)
  // draw the rectangle that we desire.
  // clean up after ourselves.

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

Re: Am I understanding this code about regions correctly?

Post by doublemax » Sat Sep 14, 2013 7:44 pm

Sounds right. But the method descriptions together with the screenshot in the tutorial should be clear.
Use the source, Luke!

Post Reply