home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / wb / picticon / source / picticon.e < prev    next >
Text File  |  1994-12-04  |  47KB  |  1,686 lines

  1. MODULE 'exec/nodes','exec/ports','exec/types','exec/memory',
  2.        'intuition/intuition','intuition/screens','intuition/gadgetclass',
  3.        'intuition/screens','dos/dos','dos/dosextens','gadtools',
  4.        'libraries/gadtools','graphics/rastport','graphics/gfx','graphics/text',
  5.        'graphics/view','graphics/gfxbase','workbench/workbench',
  6.        'workbench/startup','wb','icon','graphics/clip','diskfont',
  7.        'libraries/diskfont','libraries/iffparse','iffparse','Asl','libraries/Asl',
  8.        'datatypes/datatypes','datatypes/datatypesclass','datatypes/pictureclass',
  9.        'utility/hooks','intuition/classes','intuition/classusr',
  10.        'libraries/locale',
  11.              'mathffp','dos/dosasl',
  12.        'datatypes','layers','keymap','devices/inputevent','mathtrans','locale'
  13. MODULE 'newicon','libraries/newicon'
  14.  
  15. MODULE    'whatis','libraries/whatisbase'
  16.  
  17. MODULE    '*doloaddt'
  18.  
  19. /* options:
  20.  
  21.   MAXIWIDTH=x       ;buffer size width
  22.   MAXIHEIGHT=x      ;buffer size height
  23.   APPICON=$         ;name of App-icon image
  24.   TEMPLATE_ICON=$   ;name of icon to modify (tooltypes, positions)
  25.   BACKGROUND_ICON=$ ;Name of background icon.
  26.   CHUNKYMODE=B      ;save icon with ReadPixels, not bitmap->image.
  27.   FORCE_EIGHT=B     ;If YES then eight planes are saved.
  28.   PIC_X_POS=x       ;Offset for image.
  29.   PIC_Y_POS=x       ;Offset for image.
  30.   PIC_X_SIZE=x      ;Real size of image (not always, but at least < than)
  31.   PIC_Y_SIZE=x      ;Real size of image.
  32.   CENTER=B          ;Center icon? Only valid with PIC_X_SIZE/PIC_Y_SIZE
  33.   SHOWSIZE_X=x      ;X pos for size coords
  34.   SHOWSIZE_Y=x      ;Y pos for size coords
  35.   LOWPRI=B          ;If= "yes" then run at priority -1
  36.   FREE_ICON_POS=B   ;Set icon to "unsnapshot"
  37.   HIGHPEN=x         ;topmost pen to use
  38.   SHOWSIZE_OUTLINE=B;If yes, then outline the size, otherwise, shadow it
  39.   SHOWSIZE_NORMAL=B ;If yes, then no shadow, no outline.
  40.   SHOWSIZE_TALL=B   ;If yes, then font is 8 high, not 6.
  41.   QUIET=B           ;If yes then surpress ALL output.
  42.   APP_X_POS=x       ;x pos of appicon
  43.   APP_Y_POS=y       ;y pos of appicon
  44.     DITHER=B                    ;if YES then do dithering
  45.  
  46.                          ;      The following are EXPERT tooltypes, only...
  47.     TWOPASS=B                    ;if YES and dithering on, then do left to right, right to left passes.
  48.     D_THRESHOLD=x            ;a pos value for the minimum addition value (dithering)  (EXPERT)
  49.     D_IGNORE=x                ;a pos value.  If error<x then igrnore error in dithering.  (EXPERT)
  50.     D_LIMIT=x                    ;a pos value for the maximum addition value (dithering)  (EXPERT)
  51.     D_TYPE=x                    ;0 is default    3/8 , 0/0 , 3/8 , 1/4            x  1st value  (x=from here)
  52.                                         ;1 is FS?        7/16, 3/16, 5/16, 1/16      2nd 3rd 4th values
  53.                                         ;2 is alternate  1/2 , 0/0,  1/2,  0/0
  54.                                         ;3 is crosshatch 0/0 , 1/2,  0/0,  1/2             (all EXPERT tooltypes!)
  55.                     ;4 is linear     1/1 , 0/0,  0/0,  0/0
  56.                                         ;5 is equal      1/4 , 1/4,  1/4,  1/4
  57. */
  58.  
  59. ENUM E_NONE,L_OK,
  60.   L_E_GENERAL,L_E_FILE,L_E_NOFILE,L_E_BADICON,L_E_NOWRITEICON,L_E_CLIP,
  61.   L_E_DATATYPE,L_E_NOPICTURE,L_E_GADGET,
  62.   L_EF_LIBRARY,L_EF_FATAL,L_EF_PUBSCREEN,L_EF_CHIPBUFFER,L_EF_VISUAL,L_EF_MENUS,
  63.   L_EF_MSGPORT,L_EF_WINDOW,L_EF_MEMORY,L_TEXTTITLE,
  64.   L_PICTURE,L_FILEOF,L_LOADING,L_SCALING,L_REMAPPING,L_SAVING,L_PERCENT,
  65.   L_TITLE,L_BODY,L_BUTTONS,L_RENDERING,L_PERCENT2,L_ENDS
  66.  
  67. ENUM MODE_CLI,MODE_WB,MODE_QUIET,MODE_APP
  68. ENUM TEXT_NORMAL,TEXT_SHADOW,TEXT_OUTLINE
  69.   OBJECT mybitmapstruct
  70.     bytesperrow:INT;rows:INT;flags:CHAR;depth:CHAR;pad:INT
  71.     plane1:LONG;plane2:LONG;plane3:LONG;plane4:LONG
  72.     plane5:LONG;plane6:LONG;plane7:LONG;plane8:LONG
  73.   ENDOBJECT
  74.  
  75. DEF dumstr[500]:STRING
  76. DEF texttype=TEXT_SHADOW,tallfont=FALSE
  77. DEF iff:PTR TO iffhandle,ierror
  78. DEF sp=NIL:PTR TO storedproperty
  79. DEF freeme=FALSE
  80. DEF curfile=1,totfile=1
  81. DEF screenfont=NIL:PTR TO textfont
  82. DEF window=NIL:PTR TO window,rast,drawinfo,fgx,fgy,fgw,fgh
  83. DEF showflag=FALSE,showx=0,showy=0,bitsizex,bitsizey,sizestr[50]:STRING
  84. DEF black,white,writecolors=2
  85. DEF posx=0,posy=0,sizex=0,sizey=0,centerflag=FALSE,posflag=FALSE
  86. DEF noappitem=FALSE
  87. DEF minimumx,minimumy
  88. DEF quietflag=FALSE,goodload
  89. DEF requestsizex,requestsizey,highestcolor
  90. DEF k[15]:LIST
  91. DEF redt[256]:LIST,grnt[256]:LIST,blut[256]:LIST
  92. DEF ditz,dang,dumb,body
  93. DEF osversion,quitter,newicon=FALSE
  94. DEF abort
  95. DEF aspectx=1,aspecty=1,useaspect=TRUE
  96. DEF radian,pointfive
  97. DEF catalog,sl[500]:LIST
  98. DEF iconianheader[80]:STRING
  99. DEF scratch,ret,dummy
  100. DEF appimagedata,diskobj=NIL:PTR TO diskobject,newdiskobj=NIL:PTR TO newdiskobject
  101. DEF progname[500]:STRING,sleepername[500]:STRING,templatename[500]:STRING
  102. DEF backname[500]:STRING
  103. DEF gaugestr[100]:STRING
  104. DEF toolobject=NIL:PTR TO diskobject
  105. DEF usewhatis=TRUE
  106. DEF chunkyflag=FALSE,force8=FALSE,first4=-1
  107. DEF maxiwidth=128,maxiheight=100,maxiw=127,maxih=99
  108. DEF filename[500]:STRING
  109. DEF mode=MODE_CLI
  110. DEF scr=NIL:PTR TO screen,viewport:PTR TO viewport
  111. DEF bitmap:PTR TO bitmap,depth,colormap=0,newcolormap=0,cmbuf=0
  112. DEF currast=NIL:PTR TO rastport,curbitmap=NIL:PTR TO bitmap
  113. DEF appname[500]:STRING
  114. DEF visual=NIL,winx=-1,winy=-1
  115. DEF oldpx=-1
  116. DEF appx=-1,appy=-1
  117. DEF dither=TRUE
  118. DEF twopass=FALSE
  119. DEF rawdata=0
  120. DEF div1=3,div2=0,div3=3,div4=1,rem1=8,rem2=1,rem3=8,rem4=4
  121. DEF thres=2,ignore=16,lim=255,typ=0
  122. DEF iinfo=0:PTR TO imageinfo
  123.  
  124. PROC main()
  125.     NEW iinfo
  126.   openlibs()
  127.   radian:=sp_div_tf_tf_f(10000,572958)
  128.   pointfive:=sp_div_tf_tf_f(10,5)
  129.   StrCopy(iconianheader,'Picticon 0.96',ALL)
  130.   loadwinpos()
  131.   handwb()
  132.   savewinpos()
  133.   leave(0)
  134. ENDPROC
  135.  
  136. versionstring:
  137. CHAR '\0$VER: picticon 0.96 (4.12.94)\0'
  138. CHAR 0,0,0,0
  139.  
  140. PROC setraw(x,y,r,g,b)
  141.   IF rawdata
  142.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+(limit(y,0,1)*12*maxiwidth),r)
  143.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+4+(limit(y,0,1)*12*maxiwidth),g)
  144.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+8+(limit(y,0,1)*12*maxiwidth),b)
  145.   ENDIF
  146. ENDPROC
  147.  
  148. PROC rawred(x,y)
  149.   RETURN Long(rawdata+(x*12)+(y*12*maxiwidth))
  150. ENDPROC
  151.  
  152. PROC rawgrn(x,y)
  153.   RETURN Long(rawdata+4+(x*12)+(y*12*maxiwidth))
  154. ENDPROC
  155.  
  156. PROC rawblu(x,y)
  157.   RETURN Long(rawdata+8+(x*12)+(y*12*maxiwidth))
  158. ENDPROC
  159.  
  160. PROC processicon() HANDLE
  161.   DEF gadget:PTR TO gadget
  162.   DEF backobj=NIL:PTR TO diskobject
  163.   DEF screenattr:PTR TO textattr,sfonth=8
  164.   DEF heystring[500]:STRING,file[500]:STRING
  165.   DEF iiii,tttt,oldshowx,loo,gc1,gc2
  166.     DEF inw,inh,lock
  167.     DEF imsg:PTR TO intuimessage
  168.   oldshowx:=showx
  169.   window:=NIL
  170.   IF StrLen(filename)<1 THEN Raise(E_NONE)
  171.   IF ((scr:=LockPubScreen('Workbench'))=0) THEN Raise(L_EF_PUBSCREEN)
  172.   visual:=GetVisualInfoA(scr,NIL)
  173.   viewport:=scr.viewport
  174.   colormap:=viewport.colormap
  175.   bitmap:=scr.bitmap
  176.   depth:=bitmap.depth
  177.     IF (newicon)
  178.         newcolormap:=GetColorMap(256)
  179.         cmbuf:=New(32)
  180.         FOR loo:=0 TO 255
  181.             gc1:=loo AND (Shl(1,depth)-1)
  182.             GetRGB32(colormap,gc1,1,cmbuf)
  183.             SetRGB32CM(newcolormap,loo,Long(cmbuf),Long(cmbuf+4),Long(cmbuf+8))            
  184.         ENDFOR
  185.         colormap:=newcolormap
  186.         Dispose(cmbuf)
  187.     ENDIF
  188.   IF (curbitmap:=myallocbitmap(maxiwidth,maxiheight,8,BMF_CLEAR OR BMF_STANDARD,NIL))=NIL THEN Raise(L_EF_CHIPBUFFER)
  189.  
  190.   IF (currast:=New(SIZEOF rastport))=NIL THEN Raise(L_EF_FATAL)
  191.   InitRastPort(currast);currast.bitmap:=curbitmap
  192.  
  193.   screenattr:=scr.font
  194.   sfonth:=screenattr.ysize
  195.  
  196.   IF ((mode<>MODE_QUIET) AND (mode<>MODE_CLI))
  197.         inw:=bigger(300,12*StrLen(FilePart(filename)))
  198.         inh:=sfonth*3+20-((totfile>1)*(sfonth+4))
  199.     IF winx=-1 THEN winx:=(((scr.width-300)/2))
  200.     IF winy=-1 THEN winy:=(((scr.height-(sfonth*2+16))/2))
  201.     window:=OpenWindowTagList(0,[WA_LEFT,winx,
  202.       WA_TOP,winy,
  203.       WA_INNERWIDTH,inw,
  204.       WA_INNERHEIGHT,inh,
  205.       WA_FLAGS,WFLG_DRAGBAR OR WFLG_DEPTHGADGET OR WFLG_CLOSEGADGET,
  206.             WA_IDCMP,IDCMP_CLOSEWINDOW,
  207.       WA_TITLE,sl[L_TEXTTITLE],
  208.       WA_CUSTOMSCREEN,scr,
  209.       WA_AUTOADJUST,TRUE,
  210.       NIL,NIL])
  211.     rast:=window.rport
  212.     screenfont:=OpenFont(scr.font)
  213.     IF screenfont THEN SetFont(rast,screenfont)
  214.     fgx:=4+window.borderleft
  215.     fgw:=window.width-(8+window.borderleft+window.borderright)
  216.     fgh:=window.height-(window.bordertop+4+window.borderbottom)-(sfonth*2)-8+((totfile>1)*(sfonth+4))
  217.     fgy:=window.height-(sfonth*2)-18
  218.  
  219.  
  220.         SetAPen(rast,2)
  221.         shadowtext(rast,fgx,fgy+6+fgh+screenfont.baseline,'0%',2)
  222.         shadowtext(rast,fgx+fgw-TextLength(rast,'100%',4),fgy+fgh