FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Plot cicn in a GWorld


' FN plotCicn plots a color OR black and white 'cicn' in the destination

' port or GWorld of your choice.

' INPUTS:      resID%    -    INTEGER: the resource ID number of the
'cicn'
'              dPtr&     -    LONGINT: a pointer to the destination
rect.
'                             (just pass rect name, FB will get the
pointer)
'              dPort&    -    LONGINT: destination port or GWorld
'              inColor%  -    INTEGER: true to use the color icon
' OUTPUT:      none
' GLOBALS:     none

LOCAL MODE
  DIM sRect as rect
  DIM cH&, cicn&, icnMsk&, icnBMap&
  DIM icnData&, mskData&, bmpData&
  DIM pmPtr&, maskPtr&, bMapPtr&, h&, maskOS&, bMapOS&, pmOS&
  DIM hState%, ht%, rowBytes%, osErr%
LOCAL FN plotCicn(resID%,dPtr&,dPort&,inColor%)
  cH& = FN GETRESOURCE(_"cicn",resID%)
  LONG IF cH& <> _nil                             ' ck for nil handle
    hState%    = FN HGETSTATE(cH&)                ' save old handle status
    FN HLOCK(cH&)                    ' lock it
    cicn&      = [cH&]                            ' deref pointer to cicn data
  '---------- These offsets from Inside Mac V, pp. 80-81
    icnMsk&    = cicn&+_pmReserved+4              ' get ptr to mask
    sRect;8    = icnMsk&+_pmBounds                ' extract size
    ht%        = sRect.bottom% - sRect.top%         ' calc ht

    rowBytes%  = {icnMsk& + _rowBytes}            ' find rowbytes
    icnBMap&   = icnMsk&+_bounds+8
    icnData&   = icnBMap&+_bounds+8
    mskData&   = icnData&+4
    bmpData&   = mskData& + rowBytes% * ht%

    POKE LONG icnMsk&,mskData&                    ' setup mask bitmap
    CALL SETPORT(dPort&)
    CALL COPYBITS(#icnMsk&,#dPort&+2,sRect,#dPtr&,_srcBIC,0)' punch mask

    pmPtr&     = cicn& + _iconPMap
    maskPtr&   = cicn& + _iconMask
    bMapPtr&   = cicn& + _iconBMap

    h&         = {pmPtr&+_bounds+_bottom} - {pmPtr&+_bounds+_top}

    maskOS&    = {maskPtr& + _rowBytes} * h&
    LONG IF inColor%
      bMapOS&  = {bMapPtr& + _rowBytes} * h&
      POKE LONG(cicn& + _iconData),(cicn& + 82& + maskOS& + bMapOS&)
      POKE LONG(pmPtr& + _pmTable),(cicn& + _iconData)
      pmOS&    = 8 + ({[pmPtr&.pmTable&] + _ctSize} + 1) * 8
      pmPtr&.baseAddr& = cH&..iconData& + pmOS&
      CALL COPYBITS(#(pmPtr& + _baseAddr),#dPort&+2,#(pmPtr& + _bounds),#dPtr&,_srcXOR,0)
    XELSE
      bMapPtr&.baseAddr& = cicn& + 82 + maskOS&
      CALL COPYBITS(#(bMapPtr& + _baseAddr),#dPort&+2,#(bMapPtr& + _bounds),#dPtr&,_srcXOR,0)
    END IF
    FN HSETSTATE(cH&,hState%)            ' restore handle's state
  END IF
END FN
Ian

You can not draw a color icon (cicn) into an offscreen GWorld. It will never work.

STAZ ~)~