BigEasy/BigEasyUtils.c

/*
    File:       BigEasyUtils.c
 
    Contains:   xxx put contents here xxx
 
    Written by: xxx put writers here xxx
 
    Copyright:  
 
    Change History (most recent first):
 
         <2>    11-10-94    dvb     GetModKeys
 
*/
 
/* file: BigEasyUtils.c
  *
  * Started 25 January 1992, more or less.
  *
  * Little Extras that go
  * well with BigEasy.
  *
  */
 
 
/*----------------
    Inclusions
----------------*/
 
 
#include "BigEasy2.h"
#include "BigEasyUtils.h"
 
 
/*----------------
    Dofu
----------------*/
 
 
void SetMenuItemRange(short loRef,short hiRef,short active,short bulletRef)
/*
 * Set the range of menu-refs passed to either
 * active or inactive (±1) and bullet the
 * one that matches 'bulletref'
 */
    {
    short i;
 
    for(i = loRef; i<= hiRef; i++)
        SetMenuItem(i,active,SignIt(bulletRef == i),'¥',nil);
    }
 
 
 
#ifdef THINK_C
    long RememberThis(long what,short which)
    /*
     * To store something, pass what, and a negative "which".
     * To retrieve it, pass the positive which.
     */
        {
        asm {
            LEA     @them,A0
            MOVE    which,D0
            ADD     D0,D0
            ADD     D0,D0
            BMI.S   @stash
            ADDA    D0,A0
            MOVE.L  (A0),D0
            BRA.S   @done
    @stash:
            SUBA    D0,A0
            MOVE.L  what,(A0)
            MOVE.L  what,D0
            BRA.S   @done
    
    @them   DC.L    0,0,0,0,0,0,0,0,0,0,0
    
    @done:
            }
        }
#endif
 
 
void CenterRect(Rect *centerThis,Rect *insideThis)
    {
    OffsetRect(centerThis,
            (insideThis->left + insideThis->right - centerThis->left - centerThis->right)>>1,
            (insideThis->top + insideThis->bottom - centerThis->top - centerThis->bottom)>>1);
    }
 
 
 
short GetModKeys(void)
/*
 * return the modifier keys just like in an eventrecord
 */
    {
    short result;
    KeyMap keys;
 
    GetKeys(keys);
 
    result = 0;
    if(keys[1] & 1)
        result |= shiftKey;
    if(keys[1] & 4)
        result |= optionKey;
    if(keys[1] & 8)
        result |= controlKey;
    if(keys[1] & 0x8000)
        result |= cmdKey;
 
    return result;
    }