TweetFollow Us on Twitter

Dec 94 Tips
Volume Number:10
Issue Number:12
Column Tag:Tips &Tidbits

Related Info: Color Quickdraw

Tips &Tidbits

By Scott T Boyd, Editor

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Send us your tips! We’ll send you money, and developers all over the world (even in Sweden) will marvel at your insight, your wisdom, or the simple fact that you’ve got enough extra time to write and send a little bit of e-mail to make their lives a little bit better.

We pay $25 for every tip we use, and $50 for Tip of the Month. You can take your award in orders or subscriptions if you prefer. Make sure code compiles, and send tips by e-mail; editorial@xplain.com is a great address. See page two for our other addresses.

Tip Of The Month

White-Bordered Black Text Mode

A recent thread on comp.sys.mac.programmer prompted this little code snippet to work around a glaring omission on QuickDraw text modes. This is actual, tested, working code to draw a white outline around black characters. The trick is in the use of CharExtra, a Color QuickDraw routine that’s worth reading about in Inside Macintosh.


/* 1 */
void
Outline (
        short x ,
        short y ,
        Ptr text ,
        short length )
{
        long w1 , w2 , ce ;

        TextMode ( srcBic ) ;
        TextFace ( outline ) ;
        w1 = TextWidth ( text , 0 , length ) ;
        MoveTo ( x , y ) ;
        DrawText ( text , 0 , length ) ;

        TextMode ( srcOr ) ;
        TextFace ( normal ) ;
        w2 = TextWidth ( text , 0 , length ) ;
        ce = ( w1 - w2 ) * 0x10000L / length ;
        CharExtra ( ce ) ;
        SpaceExtra ( ce ) ;
        MoveTo ( x , y ) ;
        DrawText ( text , 0 , length ) ;

        CharExtra ( 0 ) ;
        SpaceExtra ( 0 ) ;
}

It only works in color GrafPorts, but that’s to be expected since CharExtra requires Color Quickdraw.

- Jon Wätte (h+@nada.kth.se)

Hagagatan 1, 113 48 Stockholm, Sweden

Auntie Flicker

Many operations, especially moving and sizing of controls, cause a lot of flicker on the screen. Some of this can be avoided by hiding the control, moving and sizing it, and bringing it back, but even then there is more drawing to the screen than is really necessary.

The trick to avoiding all this unnecessary drawing is to temporarily turn off drawing during the operations which cause flicker, and then turn it on again. To do this, simply replace the visRgn with a null region temporarily, i.e.:


/* 2 */
RgnHandle vis;

...

vis = window->visRgn;
window->visRgn = NewRgn();

... operations which would normally cause flicker ...

DisposeRgn(window->visRgn);
window->visRgn = vis;

... don’t forget to redraw or invalidate appropriately here!

- Jorg ‘jbx’ Brown

San Francisco, CA

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Combo Quest (Games)
Combo Quest 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Combo Quest is an epic, time tap role-playing adventure. In this unique masterpiece, you are a knight on a heroic quest to retrieve... | Read more »
Hero Emblems (Games)
Hero Emblems 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: ** 25% OFF for a limited time to celebrate the release ** ** Note for iPhone 6 user: If it doesn't run fullscreen on your device... | Read more »
Puzzle Blitz (Games)
Puzzle Blitz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Puzzle Blitz is a frantic puzzle solving race against the clock! Solve as many puzzles as you can, before time runs out! You have... | Read more »
Sky Patrol (Games)
Sky Patrol 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: 'Strategic Twist On The Classic Shooter Genre' - Indie Game Mag... | Read more »
The Princess Bride - The Official Game...
The Princess Bride - The Official Game 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: An epic game based on the beloved classic movie? Inconceivable! Play the world of The Princess Bride... | Read more »
Frozen Synapse (Games)
Frozen Synapse 1.0 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: Frozen Synapse is a multi-award-winning tactical game. (Full cross-play with desktop and tablet versions) 9/10 Edge 9/10 Eurogamer... | Read more »
Space Marshals (Games)
Space Marshals 1.0.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: ### IMPORTANT ### Please note that iPhone 4 is not supported. Space Marshals is a Sci-fi Wild West adventure taking place... | Read more »
Battle Slimes (Games)
Battle Slimes 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: BATTLE SLIMES is a fun local multiplayer game. Control speedy & bouncy slime blobs as you compete with friends and family.... | Read more »
Spectrum - 3D Avenue (Games)
Spectrum - 3D Avenue 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: "Spectrum is a pretty cool take on twitchy/reaction-based gameplay with enough complexity and style to stand out from the... | Read more »
Drop Wizard (Games)
Drop Wizard 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Bring back the joy of arcade games! Drop Wizard is an action arcade game where you play as Teo, a wizard on a quest to save his... | Read more »

Price Scanner via MacPrices.net

Apple’s M4 Mac minis on sale for record-low p...
B&H Photo has M4 and M4 Pro Mac minis in stock and on sale right now for up to $150 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses. Prices start at only $469: – M4... Read more
Deal Alert! Mac Studio with M4 Max CPU on sal...
B&H Photo has the standard-configuration Mac Studio model with Apple’s M4 Max CPU in stock today and on sale for $300 off MSRP, now $1699 (10-Core CPU and 32GB RAM/512GB SSD). B&H also... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.