Blitz (68/172)

From:Andreas Etzrodt
Date:13 Sep 2000 at 14:14:58
Subject:Re: Palette problem

Hello,

and thanks to David for the code. - But it doesn't work.
When I try to compile it the compiler says:"Type not found" in Line 39
(*sh.shape = Addr Shape(sh)).
What am I doing wrong? Of course I'm using blitzlibs:amigalibs.res in the
compiler-options!

bye,
Andreas

; a default shape to use if the program can't find the
; requested icon...

; Try adding as many icons as you like to the list
; at the bottom (but before "*END*").

; Just run it - the program adjusts for icons it
; can't find...in fact, try commenting out one of
; the Data lines (but not the "*END*" one!).

; OK, hit MainCode in the list at the right...

Function.b IconShape {sh.w,iconname$,selected.b}
; (the function that does the cool stuff (by D McMinn) )

*do.DiskObject = GetDiskObject_(&iconname$)

If *do

If selected
*im.Image = *do\do_Gadget\SelectRender
Else *im.Image = *do\do_Gadget\GadgetRender
EndIf

InitShape sh,*im\Width,*im\Height,*im\Depth
*sh.shape = Addr Shape(sh)

DEFTYPE.RastPort rp
DEFTYPE.BitMap bmp

InitRastPort_ &rp
InitBitMap_ &bmp,*im\Depth,*im\Width,*im\Height

For i.w=0 To *im\Depth-1
bmp\Planes[i] = *sh\_data + i * (*im\Height) * ((((*im\Width) + 15)
LSR 3) & $FFFE)
Next i

rp\_BitMap = &bmp
DrawImage_ &rp,*im,0,0
MakeCookie sh

FreeDiskObject_ *do

Function Return -1
Else Function Return 0
End If

End Function

.MainCode

FindScreen 0,"Workbench Screen"

*scr.Screen = Peek.l(Addr Screen(0))

sg.b=0 ; ShapeGadget number
nextx.w=*scr\WBorLeft ; X position for next gadget
tallest.w=0 ; tallest icon
sh1.b=0 ; normal shape
sh2.b=1 ; selected shape

Restore icons ; read from Data statement after "icons:"

Repeat

Read ic$ ; read icons
If ic$<>"*END*" ; until we get "*END*"

norm.b=IconShape {sh1,ic$,0} ; convert to normal
seld.b=IconShape {sh2,ic$,-1} ; convert to selected

If norm AND seld ; got 'em BOTH
ShapeGadget 0,nextx,0,0,sg,sh1,sh2 ; make ShapeGadget
nextx+ShapeWidth(sh1) ; get next position
; check for tallest shape :
If ShapeHeight(sh1)>tallest Then tallest=ShapeHeight(sh1)
sg+1:sh1+2:sh2+2 ; increase gadget number, Shape numbers

EndIf

EndIf

Until ic$="*END*" ; got "*END*", continue...

; nextx + screen border sizes = right edge of window :
nextx+*scr\WBorLeft+*scr\WBorRight

;--------------------------------------------------------------------------
; OK, some crude error checking :

; NOTE - this assumes the window's left edge is gonna be 0 :
If nextx>*scr\Width Then NPrint "Uh-oh...exceeded screen
width!":MouseWait:End

If sg=0 Then NPrint "Uh-oh...didn't create ANY gadgets!":MouseWait:End
If tallest=0 Then NPrint "Uh-oh...the tallest gadget's 0 pixels
high!":MouseWait:End

;--------------------------------------------------------------------------

AddIDCMP #IDCMP_INTUITICKS

; window, adjusted for screen border sizes and tallest shape :
Window
0,0,*scr\BarHeight+1,nextx,tallest+*scr\BarHeight+1+*scr\WBorBottom,$140e,"TABB
- The Amazing Button Bank",-1,-1,0

Repeat

Select WaitEvent
Case $200
End
Case $40
Enable 0,hit
hit=GadgetHit
Disable 0,hit
Case #IDCMP_INTUITICKS
t.b+1
If t>10 Then Enable 0,hit:t=0
End Select
Forever

icons:

; IMPORTANT!!!!! DON'T ADD ".info" to the filenames!!!!

Data$
"sys:prefs/sound","Sys:utilities/multiview","YAM:YAM","Sys:System/Format"
Data$
"sys:tools/calculator","sys:system/rexxmast","sys:prefs/screenmode","Miami:Miami"

; DO NOT REMOVE THIS :

Data$ "*END*" ; no more icons



Mit freundlichen Gr��en
Andreas Etzrodt

http://www.sharksoft.de (Baustelle)
ICQ: 17563638

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie