• MacTech Network:
  • Tech Support
  • |
  • MacForge.net
  • |
  • Apple News
  • |
  • Register Domains
  • |
  • SSL Certificates
  • |
  • iPod Deals
  • |
  • Mac Deals
  • |
  • Mac Book Shelf

MAC TECH

  • Home
  • Magazine
    • About MacTech in Print
    • Issue Table of Contents
    • Subscribe
    • Risk Free Sample
    • Back Issues
    • MacTech DVD
  • Archives
    • MacTech Print Archives
    • MacMod
    • MacTutor
    • FrameWorks
    • develop
  • Forums
  • News
    • MacTech News
    • MacTech Blog
    • MacTech Reviews and KoolTools
    • Whitepapers, Screencasts, Videos and Books
    • News Scanner
    • Rumors Scanner
    • Documentation Scanner
    • Submit News or PR
    • MacTech News List
  • Store
  • Apple Expo
    • by Category
    • by Company
    • by Product
  • Job Board
  • Editorial
    • Submit News or PR
    • Writer's Kit
    • Editorial Staff
    • Editorial Calendar
  • Advertising
    • Benefits of MacTech
    • Mechanicals and Submission
    • Dates and Deadlines
    • Submit Apple Expo Entry
  • User
    • Register for Ongoing Raffles
    • Register new user
    • Edit User Settings
    • Logout
  • Contact
    • Customer Service
    • Webmaster Feedback
    • Submit News or PR
    • Suggest an article
  • Connect Tools
    • MacTech Live Podcast
    • RSS Feeds
    • Twitter

ADVERTISEMENT
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

 
MacTech Only Search:
Community Search:

 
 
 

 
 
 
 
 
  • SPREAD THE WORD:
  • Slashdot
  • Digg
  • Del.icio.us
  • Reddit
  • Newsvine
  • Generate a short URL for this page:



MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797
MacTech is a registered trademark of Xplain Corporation. Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, Apple Expo, MacTech Central, MacTech Domains, MacNews, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.
All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
 
Nov. 20: Take Control of Syncing Data in Sow Leopard' released
Nov. 19: Cocktail 4.5 (Leopard Edition) released
Nov. 19: macProVideo offers new Cubase tutorials
Nov. 18: S Stardom anounces Safe Capsule, a companion piece for Apple's
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live