On 15 May 2019, at 13:22, [email protected] wrote:

> 
> Not my area of expertise, but I would not even use -lockFocus and 
> -unlockFocus (assume -lockFocus and -unlockFocus no longer be called!); let 
> alone trying to add something to it to configure the view. See the AppKit 
> NSView.h header:
> 
> - (void)lockFocus NS_DEPRECATED_MAC(10_0, 10_14, "To draw, subclass NSView 
> and implement -drawRect:; AppKit's automatic deferred display mechanism will 
> call -drawRect: as necessary to display the view.");
> - (void)unlockFocus NS_DEPRECATED_MAC(10_0, 10_14, "To draw, subclass NSView 
> and implement -drawRect:; AppKit's automatic deferred display mechanism will 
> call -drawRect: as necessary to display the view.");
> 
> 
> Markus
> 

It's ten years since I did anything on MacOS :-) but I'd go along with this.

In a window system, the "polite" way to draw stuff is to tell the window system 
something has changed (invalidateRect:) and then wait to be told to draw 
yourself (drawRect:).  The system takes care of setting up whatever contexts 
etc. are required.

In the bad old days, when computers were slow and single-threaded, you 
sometimes wanted to draw something immediately.  LockFocus: or something 
similar would be used to set up all the contexts "by hand" so that you could 
draw safely.

The problem is that every time an OS was updated, the book-keeping that 
lockFocus: would have to do might change unpredictably.

The solution to the problem is that nowadays computers are fast and 
multi-threaded, so you can *always* be polite and use the invalidate/draw route.

The code for lockFocus: quoted as part of this thread looks like it was itself 
a workaround intended to account for just such a change between OS versions, 
and - like lots of workarounds - seems to have become immortal because nobody 
can remember what it's for:-)

So, basically, neither over-ride nor use lockFocus: and whenever you need to 
draw something, just invalidate all or part of that view.

Hope this helps.  History is about all I can contribute these days:-)


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ian Kemmish                         2 Sale Mews, Biggleswade, Beds SG18 0AY
[email protected]        Tel: +44 1767 318605     Mob: +44 7952 854387
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to