Solved

RectInRgn()

Posted on 2000-03-07
6
200 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
  • 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 50 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 98
difference between String.subString() and String.subSequence() 6 192
centeredAverage challenge 8 159
unix example issues 18 89
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

816 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now