?
Solved

RectInRgn()

Posted on 2000-03-07
6
Medium Priority
?
204 Views
Last Modified: 2013-12-26
I am trying to prevent a Rect in a window from being redrawn if
not necessary. I tried the following code but it does not work
any suggestions. I tried putting the Draw_The_Window() within
Begin & End update and it didn't make a difference.

BTW: The code works fine when I don't check for the
RectInRgn().


case updateEvt:
BeginUpdate((DialogPtr)gMainEventRecord.message);                        
EndUpdate((DialogPtr)gMainEventRecord.message);
Draw_The_Window((DialogPtr)gMainEventRecord.message);
break;


void Draw_The_Window (DialogPtr theDialog)
{
DialogPeek            theDialogPeek;
Rect                  iconRect = {20, 32, 52, 64};

theDialogPeek - (DialogPeek)theDialog;
      
if( RectInRgn( &iconRect, theDialogPeek->window.updateRgn) )
      Display_Icon( theDialog );

}
0
Comment
Question by:gail_p
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2610963
BeginUpdate() immediately clears the update region, so that RectInRgn call will always return false. If you check against clipRgn instead this ought to work.

That's if you don't call EndUpdate() before calling your draw routine, because EndUpdate() sets the clipping region back to whatever it was before BeginUpdate() set it to the pending update region.

So move EndUpdate after the Draw_The_Window call, and check the clipping region instead of the update region, and you ought to be good to go.
0
 

Author Comment

by:gail_p
ID: 2615499
If I move Draw_The_Window() routine between the Begin and End Update the the PlotIconSuite() call in the Draw_The_Window() gets drawn over. That is why I put the Draw_The_Window() after the EndUpdate().
0
 
LVL 4

Accepted Solution

by:
Alex Curylo earned 200 total points
ID: 2616775
Check out the diagram at

http://developer.apple.com/techpubs/mac/Toolbox/Toolbox-207.html#MARKER-9-210

which shows how BeginUpdate() and EndUpdate() affect the clipping region of the window. If it's not working the way you expect, then something must be invalidating your window incorrectly.

A useful technique would be to put a call to FillRgn() on the update region in pink or something like that just before the BeginUpdate call; then you can see exactly what part of the window will be drawn over by calls within Begin/EndUpdate. If it's not what you expect, then something is wrong with your invalidation code and it ought to be fixed where the problem is instead of working around it at update time.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2616792
And if you draw anywhere _other_ than between Begin/End update calls, don't forget to make sure to call ValidRect/ValidRgn as appropriate, otherwise yes of course it'll flicker because the Window Manager has no way to know what part of the window you don't want redrawn now.

But it's better to never draw except at update time to avoid all these kinds of problems.
0
 

Author Comment

by:gail_p
ID: 2617874
Great, thanks for the help. Any suggestions for my Balloon Help question?
0
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2617999
You're welcome. I'll go look at it now.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question