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

Get the selected Desktop pattern


You have two choices.

1) The standard system ppat is always id 16. Call USERESFILE on the System file, then GETPIXPAT and you're done.

Of course, if the user happens to have a program such as my "Mad ppatter!" installed, which changes the desktop pattern on the fly, the default pattern won't be accurate. In this case, you can load the pattern directly.

2) The current desktop pattern is located at _DeskCPat, also known as the long word at &00000CD8. I forget exactly how to copy a desktop pattern, but it's a bit more complex than just duplicating a handle. :-) There may actually be a COPYPIXPAT trap to do the job.

I have no idea how to find a desktop picture, as in OS 8.0's "Desktop Pictures" control panel. I imagine Desktop Pictures overrides the DeskHook and does its own drawing, but my guess is that it keeps picture handles well hidden in its own global space.

Mars


Just so long as _everything_ turns out to be in IM: Imaging (which leaves me wondering what the other 37 volumes can possibly be filled with, and the depressing realization that this means I am about 1/37 of a programmer...)

The whole thing comes down to a laughably simple

mypixhndl& = FN GETPIXPAT(_deskPatId)
LONG IF mypixhndl&
  CALL PENPIXPAT(mypixhndl&)
  CALL PAINTRGN(firstrgn&) 'the non-menu part of my toy desktop
  CALL DISPOSPIXPAT(mypixhndl&) 'IM misspelled it DISPOSEPIXPAT
  CALL PENNORMAL
XELSE
  FN changeColor(102,102,102) 'use your basic grey instead
  CALL PAINTRGN(firstrgn&)
  CALL FORECOLOR(_blackColor)
END IF

(IM neglects to mention the CALL PENNORMAL bit, necessary because a pixpat supersedes any fore- or backcolor statements in perpetuity.)

The effect is really cute & I recommend it to everyone.

Lucy


There's a relevant-looking toolbox call:-

CALL SETDESKCPAT (pPatHndl&)

but the matching GetDeskCPat(), which is what you would like, doesn't seem to exist. Some other pix pattern calls are:-

pPatHndl&=FN GETPIXPAT(resID)
pPatHndl&=FN NEWPIXPAT
CALL DISPOSPIXPAT(pPatHndl&)
CALL COPYPIXPAT(src&,dst&)
CALL PENPIXPAT(pPatHndl&)
CALL BACKPIXPAT(pPatHndl&)

The following short program shows how a pixPatt may be drawn (FILLCRECT, or FILLCRGN etc). But it fails to accomplish the task given. Neither of the two plausible offsets into the CGrafPort (_pnPixPat and _bkPixPat) gives the desktop pattern -- perhaps someone can spot an error in my code.

If you create a resource file "MyPPat.rsrc" containing a ppat resource with id 128, and uncomment the 3 singly-commented lines of the program, the ppat pecified is drawn correctly. Having got that to work, if you uncomment the triply-commented line, the desktop pattern is set to your ppat (this change is lost when you reboot).

LOCAL FN DrawPixPattern(pPatHndl&,x,y)
  DIM aRect.8
  CALL SETRECT(aRect,x,y,x+120,y+200)
  IF pPatHndl&<>_nil THEN CALL FILLCRECT(aRect,pPatHndl&)
  CALL FRAMERECT(aRect)
END FN

DIM wPort&, pPatHndl&
WINDOW 1
CALL GETCWMGRPORT(wPort&)' points to Window Manager's CGrafPort
FN DrawPixPattern([wPort& + _pnPixPat],10,10) ' solid black
FN DrawPixPattern([wPort& + _bkPixPat],140,10) 'uh, oh, solid white
'RESOURCES "MyPPat.rsrc"
'pPatHndl&=FN GETPIXPAT(128)
'FN DrawPixPattern(pPatHndl&,270,10)
'''IF pPatHndl& THEN CALL SETDESKCPAT (pPatHndl&)
DO: UNTIL FN BUTTON

Robert