home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Graphics / picFX / e-source / picFX.e < prev    next >
Text File  |  1999-12-30  |  123KB  |  2,928 lines

  1. OPT LARGE
  2. OPT PREPROCESS,OSVERSION=39
  3.  
  4. #define PlaneFuncObject NewObjectA(cl_planefunc.mcc_class,NIL,[TAG_IGNORE,0
  5. #define ProjectListObject NewObjectA(cl_projectlist.mcc_class,NIL,[TAG_IGNORE,0
  6. #define uSliderObject NewObjectA(cl_uslider.mcc_class,NIL,[TAG_IGNORE,0
  7. #define SizeTextObject NewObjectA(cl_sizetxt.mcc_class,NIL,[TAG_IGNORE,0
  8. #define MyApplicationObject NewObjectA(cl_myapp.mcc_class,NIL,[TAG_IGNORE,0
  9. /*****/
  10. #define VarListObject NewObjectA(varlist_mcc,NIL,[MUIA_List_Format,'MIW=50 BAR,',\
  11.                                                   MUIA_List_ConstructHook,vl_constructhook,\
  12.                                                   MUIA_List_DestructHook,vl_destructhook,\
  13.                                                   MUIA_List_DisplayHook,vl_displayhook
  14.  
  15. #define label(t) TextObject,MUIA_Text_Contents,t,MUIA_Text_SetMax,MUI_TRUE,End
  16.  
  17. #define modt(val) val AND $FF
  18. #define pixel(raw,w,x,y) raw[x+(y*w)]
  19.  
  20. #define PICVERSION 'PicFX 1.1'
  21. #define FULLVERSION '$VER: PicFX 1.1 (27/12/99)'
  22.  
  23. MODULE 'afc/super_picture','afc/trueBitmap'
  24. MODULE       'amigalib/boopsi','amigalib/lists',
  25.        'asl',
  26.        'datatypes','datatypes/datatypes','datatypes/pictureclass','datatypes/pictureclassext','datatypes/datatypesclass',
  27.        'devices/timer',
  28.        'dos/dos','dos/dosextens','dos/dostags',
  29.        'exec/io','exec/lists','exec/memory','exec/nodes','exec/ports','exec/semaphores','exec/tasks',
  30.        'fork',
  31.        'graphics/gfx','graphics/rastport','graphics/view','guigfx','guigfx/guigfx',
  32.        'iffparse','libraries/iffparse',
  33.        'intuition/classes','intuition/classusr','intuition/intuition','intuition/screens',
  34.        'libraries/asl','libraries/cybergraphics','libraries/gadtools','libraries/iffparse','libraries/mui',
  35.            'libraries/muip',
  36.        'mui/lamp_mcc','mui/muicustomclass',
  37.        'muimaster',
  38.        '*varlist',
  39.        'utility','utility/tagitem','utility/hooks','tools/installhook',
  40.        '*parser','tools/longreal',
  41.        'tools/ilbmdefs',
  42.        '*picFXlocale',
  43.        'render/render'
  44.  
  45. MODULE 'tools/debug' ->kputfmt(formatstring,[values])
  46.  
  47. CONST TICKS_PER_MINUTE = TICKS_PER_SECOND*60
  48.  
  49. DEF app,
  50.     messages_win,messages_lst,
  51.     prefs_win, /*Preference button*/
  52.         mainpri_sld,renderpri_sld,renderupdate_sld,mui_btn,currpri_sld,
  53.         recompile_chk,
  54.         close_cyc,showmess_chk,dither_cyc,dither_sld,savep_btn,
  55.     settings_win,colour_txt,
  56.     opened_lsv,opened_lst,
  57.     new_btn,prefs_btn,var_btn,
  58.     varlist_win,varlist_lsv,varlist_lst,varname_str,varval_str,varadd_btn,vardel_btn,
  59.     sgroup, /*settings gadgets*/
  60.     name_str,type_reg,
  61.         path_str,size_rad,size_txt, -> for the DTPic type
  62.         r_lbl,g_lbl,b_lbl,
  63.         red_str,green_str,blue_str,outr_cyc,outg_cyc,outb_cyc, -> for the Function type
  64.         red_fail,green_fail,blue_fail,->comr_cyc,comg_cyc,comb_cyc,
  65.     width_str,height_str,
  66.             /*action buttons*/
  67.     draw_btn,savepic_btn,savefunc_btn,abort_btn,showme_cyc,close_btn,
  68.     loadfunc_btn,clear_btn,
  69.             /*state area*/
  70.     lamp_lmp,state_txt,state_gau,
  71.  
  72.     ftype_registertitles,size_radiolabels,showme_cyclelabels,
  73.     sigs=0,
  74.     lastid=0,/* lastid is a global variable incremented everytime a project is opened.
  75.                 absolutely no risk to have several projects with same ID*/
  76.     screentitle,
  77.     title[15]:STRING,counter=1, -> number of messages
  78.     messages[15]:ARRAY OF LONG,
  79.     picdir:PTR TO CHAR,funcdir:PTR TO CHAR,
  80.  
  81.     cat:PTR TO catalog_picFX,
  82.  
  83.     rp=-2,cp=-1,        -> Priorities
  84.     rupd=10,wclose,dithm,ditha,     -> Some preference variables..
  85. ->    psema:ss,           -> Semaphore for preferences  (!!)
  86.  
  87.     currid=-1,quiet=FALSE     -> currid contains the id of the currently selected project. Quiet controls attributes refreshing.
  88.  
  89. DEF nodraw,friend=NIL
  90.  
  91. ENUM SETID_MainP=1,
  92.      SETID_RenderP,
  93.      SETID_CurrP,
  94.      SETID_RUpd,
  95.      SETID_Close,
  96.      SETID_ShowMess,
  97.      SETID_DithM,
  98.      SETID_DithA
  99.  
  100. DEF cl_planefunc:PTR TO mui_customclass
  101. DEF cl_projectlist:PTR TO mui_customclass
  102. DEF cl_uslider:PTR TO mui_customclass
  103. DEF cl_sizetxt:PTR TO mui_customclass
  104. DEF cl_myapp:PTR TO mui_customclass
  105.  
  106. /*Registation Number:FCB96172; I take FCB9 as base... :(*/
  107. ENUM MUIA_PlaneFunc_Bstr=$FCB90000, -> String of the B function
  108.      MUIA_PlaneFunc_Fail,           -> $RGB:How decoding went..
  109.      MUIA_PlaneFunc_Gstr,           -> String of the G function
  110.      MUIA_PlaneFunc_Height,         -> Height of the object
  111.      MUIA_PlaneFunc_ImageFile,      -> FileName of the image to load
  112.      MUIA_PlaneFunc_Left,
  113.      MUIA_PlaneFunc_Loading,        -> TRUE/FALSE
  114.      MUIA_PlaneFunc_LoadM,          -> Way of loading an image, concerning the size
  115.      MUIA_PlaneFunc_Lock,           -> Allows to read/write lock the instance of the class
  116.      MUIA_PlaneFunc_Name,           -> Name of the graph
  117.      MUIA_PlaneFunc_Percent,        -> Percentage of current work done.
  118.      MUIA_PlaneFunc_OutputR,        -> values: OUT_Integer,OUT_Float32 or OUT_Float64,...
  119.      MUIA_PlaneFunc_OutputG,        -> ... or OUT_OldR,OUT_OldG,OUT_OldB,...
  120.      MUIA_PlaneFunc_OutputB,        -> ... or Out_CopyR,OUT_CopyG (!)
  121.      MUIA_PlaneFunc_ProjectID,      -> Used by ProjectList class, it is the ID of the object
  122.      MUIA_PlaneFunc_ProjectNode,    -> Address of the node in the exec_list of opened_lst
  123.      MUIA_PlaneFunc_Quiet,          -> Width/Height changes won't resize the window if non-zero
  124.      MUIA_PlaneFunc_Rstr,           -> R function string
  125.      MUIA_PlaneFunc_State,
  126.      MUIA_PlaneFunc_Top,
  127.      MUIA_PlaneFunc_Type,           -> Type of graph
  128.      MUIA_PlaneFunc_Width           -> Width of the object
  129.  
  130. ENUM MUIM_PlaneFunc_Abort=$FCB90800,-> Aborts Rendering SubTask
  131.      MUIM_PlaneFunc_Clear,          -> Clears bitmap
  132.      MUIM_PlaneFunc_Close,          -> React after a click on the close button.
  133.      MUIM_PlaneFunc_DrawHandle,     -> Releases (if necessary) then obtains a new drawhandle
  134.      MUIM_PlaneFunc_Lamps,          -> This updates the failure lamps of the functions.
  135.      MUIM_PlaneFunc_LoadFunc,       -> Loads a function from disk
  136.      MUIM_PlaneFunc_Render,         -> Launches/pauses the rendering subtask
  137.      MUIM_PlaneFunc_SaveFunc,       -> Saves the function to disk
  138.      MUIM_PlaneFunc_SavePic,        -> Saves the picture to disk, as an ILBM image
  139.      MUIM_PlaneFunc_SetSize,        -> Scales the picture to fit into the window, keeping aspect.
  140.      MUIM_PlaneFunc_SetTaskPri,     -> Sets the priority of the subtask
  141.      MUIM_PlaneFunc_Update          -> sent by the subtask, to update the picture display
  142.  
  143. CONST MUIV_PlaneFunc_Type_DTPic=1,
  144.       MUIV_PlaneFunc_Type_Graph=2,
  145.  
  146.       MUIV_PlaneFunc_LoadM_Scale=1,
  147.       MUIV_PlaneFunc_LoadM_CutTile=2,
  148.       MUIV_PlaneFunc_LoadM_ChangeSize=3,
  149.  
  150.       MUIV_PlaneFunc_State_Idle=0,   ->free
  151.       MUIV_PlaneFunc_State_Drawing=1,->busy
  152.       MUIV_PlaneFunc_State_Paused=2, ->busy but paused
  153.       MUIV_PlaneFunc_State_Frozen=3, ->free but being read
  154.       MUIV_PlaneFunc_State_Loading=4,->loading picture
  155.  
  156.       MUIV_PlaneFunc_Lock_Write=-1, -> Want to lock it in write mode, so nobody else may touch the object
  157.       MUIV_PlaneFunc_Lock_NoWrite=0,-> remove writelock
  158.       MUIV_PlaneFunc_Lock_Read=1,   -> Want to lock it in read mode, only reading is now allowed. Nesting counter!
  159.       MUIV_PlaneFunc_Lock_NoRead=0, -> remove one readlock
  160.  
  161.       MUIV_PlaneFunc_Abort_Finish=1,-> Aborted because rendering finished
  162.       MUIV_PlaneFunc_Abort_Abort=2, -> Aborted because user asked
  163.       MUIV_PlaneFunc_Abort_NoLoad=3 -> Aborted because picture could not be loaded
  164.  
  165. ENUM MUIM_ProjectList_DelItem=$FCB91800,-> Closes the current project if possible (i.e. if it isn't read-locked)
  166.      MUIM_ProjectList_Exit,             -> This aborts all currently running projects and quits the application
  167.      MUIM_ProjectList_Forward,          -> Forwards the method (no args!) to the current project
  168.      MUIM_ProjectList_Memory,           -> Shows available memory in title bar.
  169.      MUIM_ProjectList_NewItem,          -> Adds an item in the list
  170.      MUIM_ProjectList_Notify,           -> Sends a notification information to the current project
  171.      MUIM_ProjectList_Prefs,            -> writes a new value in a preference variable
  172.      MUIM_ProjectList_Refresh,          -> Refreshes the user interface according to the select item
  173.      MUIM_ProjectList_SavePrefs,        -> Writes to env:picFX.prefs AND copies to envarc:
  174.      MUIM_ProjectList_SetPri,           -> Set the priority of a task (see MUIV_~)
  175.      MUIM_ProjectList_ShowMe            -> Sets the MUIA_Window_Open of the current project
  176.  
  177. ENUM MUIV_ProjectList_Notify_Name=1,    /*gadget that has been changed*/
  178.      MUIV_ProjectList_Notify_Type,
  179.      MUIV_ProjectList_Notify_ImageFile,
  180.      MUIV_ProjectList_Notify_LoadM,
  181.      MUIV_ProjectList_Notify_Red,
  182.      MUIV_ProjectList_Notify_Green,
  183.      MUIV_ProjectList_Notify_Blue,
  184.      MUIV_ProjectList_Notify_OutputR,
  185.      MUIV_ProjectList_Notify_OutputG,
  186.      MUIV_ProjectList_Notify_OutputB,
  187.      MUIV_ProjectList_Notify_Width,
  188.      MUIV_ProjectList_Notify_Height
  189.  
  190. ENUM MUIV_ProjectList_SetPri_Main=0,
  191.      MUIV_ProjectList_SetPri_Render,
  192.      MUIV_ProjectList_SetPri_Curr
  193.  
  194. CONST MUIA_uSlider_Stringify=$FCB92000
  195.  
  196. ENUM MUIM_uSlider_Bigger=$ECB92800, -> how do I know if this tag is already used????
  197.      MUIM_uSlider_Smaller
  198.  
  199. ENUM STC_STARTUP=-2,
  200.     STC_SHUTDOWN,      /*messages to the subtask*/
  201.     STC_START,
  202.     STC_PAUSE,
  203.     STC_RESTART,
  204.     STC_CHANGEDONE
  205.  
  206. /***************************************************************
  207. **            Custom PlaneFunc private Class                  **
  208. ****************************************************************
  209. This class is responsible for rendering the functions. It uses a
  210. subtask to avoid the main program to be freezed during rendering
  211. ***************************************************************/
  212.  
  213. OBJECT empty_data -> class(es) that doesn't use any data
  214.     nothing
  215. ENDOBJECT
  216.  
  217. OBJECT projectList_data
  218.     exec_list:PTR TO lh -> list of the opened projects
  219. /* Stuff for timer (title bar) */
  220. /* Everything is copied from mui demo "inputhandler" Thanks for its authors ;-) */
  221.     port:PTR TO mp
  222.     req:PTR TO timerequest
  223.     ihnode:mui_inputhandlernode_timer
  224. ENDOBJECT
  225.  
  226. OBJECT uslider_data
  227.     buffer:PTR TO CHAR
  228.     stringify
  229. ENDOBJECT
  230.  
  231. OBJECT args_compare -> MUIM_uSlider_Bigger/Smaller
  232.     id
  233.     than
  234. ENDOBJECT
  235.  
  236. OBJECT args_abort -> Used by MUIM_PlaneFunc_Abort
  237.     id
  238.     reason
  239. ENDOBJECT
  240.  
  241. OBJECT args_ctp -> MUIM_PlaneFunc_SetTaskPri
  242.     id
  243.     value
  244. ENDOBJECT
  245.  
  246. OBJECT args_notify -> Used by MUIM_ProjectList_Notify
  247.     id
  248.     gadget -> MUIV_ProjectList_Notify_<something>
  249.     value
  250. ENDOBJECT
  251.  
  252. OBJECT args_showme -> Used by MUIM_ProjectList_ShowMe
  253.     id
  254.     value
  255. ENDOBJECT
  256.  
  257. OBJECT args_forward -> Used by MUIM_ProjectList_Forward
  258.     id
  259.     method
  260. ENDOBJECT
  261.  
  262. OBJECT args_prefs -> MUIM_ProjectList_Prefs
  263.     id
  264.     var:PTR TO LONG
  265.     value
  266. ENDOBJECT
  267.  
  268. OBJECT args_refresh -> Used by MUIM_ProjectList_Refresh
  269.     id
  270.     ostate -> TRUE if only the 'state' field must be refreshed.
  271. ENDOBJECT
  272.  
  273. OBJECT args_setpri -> MUIM_ProjectList_SetPri
  274.     id
  275.     task -> MUIV_ProjectList_SetPri_*
  276.     value
  277. ENDOBJECT
  278.  
  279. /*--------------*/
  280. /* A little tool to help reading IFF chunks from any version */
  281. OBJECT chunkSeeker
  282.     data:PTR TO LONG
  283.     size
  284.     shift -> this how far we are in data...
  285. ENDOBJECT
  286.  
  287. PROC create(sp:PTR TO storedproperty) OF chunkSeeker
  288.     self.data:=sp.data
  289.     self.size:=sp.size
  290. ENDPROC
  291.  
  292. PROC read(object,attribute) OF chunkSeeker
  293. DEF dt:PTR TO LONG
  294.     IF self.shift > self.size THEN RETURN
  295.  
  296.     dt:=self.data+self.shift
  297.     set(object,attribute,dt[])
  298.     self.shift:=self.shift+4
  299. ENDPROC
  300.  
  301. PROC write(object,attribute) OF chunkSeeker
  302. DEF dt:PTR TO LONG
  303.     IF self.shift > self.size THEN RETURN
  304.     dt:=self.data
  305.     get(object,attribute,dt+self.shift)
  306.     self.shift:=self.shift+4
  307. ENDPROC
  308. /*--------------*/
  309. PROC planeFunc_dispatcher(cl:PTR TO iclass,obj,msg:PTR TO msg)
  310. DEF methodid
  311.     methodid:=msg.methodid
  312.     SELECT methodid
  313.     CASE OM_NEW;        RETURN planeFunc_new(cl,obj,msg)
  314.     CASE OM_DISPOSE;    RETURN planeFunc_dispose(cl,obj,msg)
  315.     CASE OM_GET;        RETURN planeFunc_get(cl,obj,msg)   /*gets an attribute*/
  316.     CASE OM_SET;        RETURN planeFunc_set(cl,obj,msg)   /*sets an attribute*/
  317.     CASE MUIM_AskMinMax;RETURN planeFunc_askminmax(cl,obj,msg)
  318.     CASE MUIM_Cleanup;  RETURN planeFunc_cleanup(cl,obj,msg)
  319.     CASE MUIM_Draw;     RETURN planeFunc_draw(cl,obj,msg)  /*mui (or the subtask) asked to redraw*/
  320.     CASE MUIM_HandleInput;RETURN planeFunc_handleinput(cl,obj,msg)
  321.     CASE MUIM_Setup;    RETURN planeFunc_setup(cl,obj,msg)
  322.  
  323.     CASE MUIM_PlaneFunc_Abort;      RETURN planeFunc_abort(cl,obj,msg)      /*public methods...*/
  324.     CASE MUIM_PlaneFunc_Clear;      RETURN planeFunc_clear(cl,obj/*,msg*/)
  325.     CASE MUIM_PlaneFunc_Close;      RETURN planeFunc_close(cl,obj/*,msg*/)
  326.     CASE MUIM_PlaneFunc_DrawHandle; RETURN planeFunc_drawhandle(cl,obj,msg)
  327.     CASE MUIM_PlaneFunc_Lamps;      RETURN planeFunc_lamps(cl,obj/*,msg*/)
  328.     CASE MUIM_PlaneFunc_LoadFunc;   RETURN planeFunc_loadfunc(cl,obj/*,msg*/)
  329.     CASE MUIM_PlaneFunc_Render;     RETURN planeFunc_render(cl,obj/*,msg*/)
  330.     CASE MUIM_PlaneFunc_SaveFunc;   RETURN planeFunc_savefunc(cl,obj/*,msg*/)
  331.     CASE MUIM_PlaneFunc_SavePic;    RETURN planeFunc_savepic(cl,obj/*,msg*/)
  332.     CASE MUIM_PlaneFunc_SetSize;    RETURN planeFunc_setsize(cl,obj/*,msg*/)
  333.     CASE MUIM_PlaneFunc_SetTaskPri; RETURN planeFunc_settaskpri(cl,obj,msg)
  334.     CASE MUIM_PlaneFunc_Update;     RETURN planeFunc_update(cl,obj/*,msg*/)
  335.     ENDSELECT
  336. ENDPROC doSuperMethodA(cl,obj,msg)
  337.  
  338. PROC planeFunc_new(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  339. DEF data:PTR TO planeFunc_data
  340.     IF (obj:=doSuperMethodA(cl,obj,msg))=NIL THEN RETURN 0
  341.     data:=INST_DATA(cl,obj)
  342.  
  343.     data.self:=obj
  344.     data.app:=TRUE
  345.     InitSemaphore(data.sema)
  346.  
  347.     data.projectid:=lastid++
  348.     data.failure:=$000
  349.     data.rstr:=String(256)
  350.     data.gstr:=String(256)
  351.     data.bstr:=String(256)
  352.     StrCopy(data.rstr,'x')
  353.     StrCopy(data.gstr,'y')
  354.     StrCopy(data.bstr,'(x+y)/2')
  355.     data.outputr:=OUT_Integer
  356.     data.outputg:=OUT_Integer
  357.     data.outputb:=OUT_Integer
  358.     NEW data.rfunc.create(data.outputr,data.rstr)
  359.     NEW data.gfunc.create(data.outputg,data.gstr)
  360.     NEW data.bfunc.create(data.outputb,data.bstr)
  361.     data.imagefile:=String(256)
  362.  
  363.     data.height:=256
  364.     StrCopy(data.imagefile,cat.msg_Unnamed.getstr())
  365.     data.newleft:=-1
  366.     data.loadm:=MUIV_PlaneFunc_LoadM_CutTile
  367.     data.lock:=0
  368.     data.name:=String(32)
  369.     StrCopy(data.name,cat.msg_Unnamed.getstr())
  370.     data.paused:=FALSE
  371.     data.ratio:=100000
  372.     data.newtop:=-1
  373.     data.type:=MUIV_PlaneFunc_Type_Graph
  374.     data.width:=256
  375.  
  376.     data.xmin:=10
  377.     data.xmax:=240
  378.     data.ymin:=30
  379.     data.ymax:=80
  380.  
  381.     IF data.imagedata <> 0 -> Just a test to see if it might be nonzero when allocated with E..
  382.         WriteF('data.imagedata was $\h\n',data.imagedata)
  383.         data.imagedata:=NIL
  384.     ENDIF
  385.  
  386.     data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  387.     data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  388.  
  389. ENDPROC obj
  390. PROC planeFunc_askminmax(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_askminmax)
  391. DEF minmax:PTR TO mui_minmax,data:PTR TO planeFunc_data
  392.     data:=INST_DATA(cl,obj)
  393.     doSuperMethodA(cl,obj,msg)
  394.     minmax:=msg.minmaxinfo
  395.     minmax.maxwidth:=minmax.maxwidth+MUI_MAXMAX
  396.     minmax.maxheight:=minmax.maxheight+MUI_MAXMAX
  397.     minmax.defwidth:=minmax.defwidth+(data.width)
  398.     minmax.defheight:=minmax.defheight+(data.height)
  399. ENDPROC 0
  400.  
  401. PROC planeFunc_setup(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  402.     IF doSuperMethodA(cl,obj,msg)=NIL THEN RETURN FALSE
  403.     Mui_RequestIDCMP(obj,IDCMP_MOUSEBUTTONS)
  404.     ->Mui_RequestIDCMP(obj,IDCMP_RAWKEY)
  405. ENDPROC MUI_TRUE
  406.  
  407. PROC planeFunc_cleanup(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  408. DEF data:PTR TO planeFunc_data
  409.     Mui_RejectIDCMP(obj,IDCMP_MOUSEBUTTONS)
  410.     ->Mui_RejectIDCMP(obj,IDCMP_RAWKEY)
  411.  
  412.     data:=INST_DATA(cl,obj)
  413.     IF data.drawhandle
  414.         ReleaseDrawHandle(data.drawhandle);data.drawhandle:=NIL
  415.     ENDIF
  416.  
  417. ENDPROC doSuperMethodA(cl,obj,msg)
  418.  
  419. PROC planeFunc_handleinput(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_handleinput)
  420. #define _between(a,x,b) (((x)>=(a)) AND ((x)<=(b)))
  421. DEF data:PTR TO planeFunc_data,col,colourstr[30]:STRING,x,y
  422.  
  423.     data:=INST_DATA(cl,obj)
  424.     IF msg.imsg
  425.         IF (msg.imsg.class=IDCMP_MOUSEBUTTONS) AND (msg.imsg.code=SELECTDOWN)
  426.             _mwidth(obj)*(data.width-data.left)/Div(Mul(_mwidth(obj),100000),data.ratio)
  427.             IF (_between(_mleft(obj),msg.imsg.mousex,_mright(obj)) AND _between(_mtop(obj),msg.imsg.mousey,_bottom(obj)))
  428.                 x:=Div(Mul(msg.imsg.mousex-_mleft(obj),100000),data.ratio)+data.left
  429.                 y:=Div(Mul(msg.imsg.mousey-_mtop(obj),100000),data.ratio)+data.top
  430.                 IF (x>=data.width) OR (y>=data.height) THEN RETURN doSuperMethodA(cl,obj,msg)
  431.                 /*get colour*/
  432.                 ObtainSemaphore(data.sema)
  433.                 /*IF cybergfxbase
  434.                     col:=ReadRGBPixel(data.rp,x,y)
  435.                 ELSE
  436.                     col:=Pi96ReadPixel(data.rp,x,y)
  437.                 ENDIF*/
  438.                 IF data.imagedata THEN
  439.                     col:=pixel(data.imagedata,data.width,x,y)
  440.                 ReleaseSemaphore(data.sema)
  441.                 StringF(colourstr,'c(\d,\d,\d)=[\d,\d,\d]',data.projectid,x,y,Shr(col,16),Shr(col AND $FF00,8),col AND $FF)
  442.                 set(colour_txt,MUIA_Text_Contents,colourstr)
  443.             ENDIF
  444. /*        ELSEIF (msg.imsg.class=IDCMP_RAWKEY)
  445.             IF (msg.imsg.code=96) OR (msg.imsg.code=97)
  446.                 data.shift:=TRUE
  447.             ELSEIF (msg.imsg.code=224) OR (msg.imsg.code=225)
  448.                 data.shift:=FALSE
  449.             ENDIF*/
  450.         ENDIF
  451.     ENDIF
  452. ENDPROC doSuperMethodA(cl,obj,msg)
  453.  
  454. PROC planeFunc_clear(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  455. DEF data:PTR TO planeFunc_data
  456.     data:=INST_DATA(cl,obj)
  457.     ObtainSemaphore(data.sema)
  458.     IF data.lock=0
  459.         DeletePicture(data.picture)
  460.         data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  461.         data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  462.  
  463.         ReleaseSemaphore(data.sema)
  464.         Mui_Redraw(obj,MADF_DRAWUPDATE)
  465.     ELSE
  466.         ReleaseSemaphore(data.sema)
  467.         message(data.projectid,cat.msgm_WriteVsLock.getstr())
  468.     ENDIF
  469. ENDPROC
  470.  
  471. PROC planeFunc_drawhandle(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  472. DEF data:PTR TO planeFunc_data,window
  473.     data:=INST_DATA(cl,obj)
  474.  
  475.     IF data.drawhandle
  476.         ReleaseDrawHandle(data.drawhandle);data.drawhandle:=NIL
  477.     ENDIF
  478.     get(obj,MUIA_Window,{window})
  479.     IF window
  480.         data.drawhandle:=odhandle(obj)
  481.         Mui_Redraw(obj,MADF_DRAWUPDATE)
  482.     ENDIF
  483. ENDPROC
  484.  
  485. PROC odhandle(obj:PTR TO object)
  486. DEF dm,id
  487.     SELECT dithm
  488.         CASE 0; dm:=DITHERMODE_NONE
  489.         CASE 1; dm:=DITHERMODE_EDD
  490.         CASE 2; dm:=DITHERMODE_FS
  491.         CASE 3; dm:=DITHERMODE_RANDOM
  492.         ENDSELECT
  493.  
  494.         id:=GetVPModeID(_screen(obj).viewport)
  495.  
  496.         RETURN ObtainDrawHandleA(NIL,_window(obj).rport,_window(obj).wscreen.viewport.colormap,[
  497.         GGFX_DitherMode,dm,
  498.         GGFX_DitherAmount,ditha,
  499.         GGFX_ModeID,id,
  500.  
  501.         TAG_DONE])
  502. ENDPROC
  503.  
  504. PROC planeFunc_close(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  505. DEF data:PTR TO planeFunc_data,kdata:PTR TO projectList_data
  506. DEF state,node:PTR TO project_Node,count=0,exec_list:PTR TO lh
  507.     data:=INST_DATA(cl,obj)
  508.     IF wclose=0
  509.         IF data.projectid=currid
  510.             nnset(showme_cyc,MUIA_Cycle_Active,0) -> update cycle display.
  511.         ENDIF
  512.         set(data.projectnode.window,MUIA_Window_Open,FALSE)
  513.     ELSEIF wclose=1
  514. quiet:=TRUE
  515.         kdata:=INST_DATA(cl_projectlist.mcc_class,opened_lst)
  516.         doMethodA(obj,[MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Abort])
  517.         get(obj,MUIA_PlaneFunc_State,{state})
  518.         IF state = MUIV_PlaneFunc_State_Frozen
  519.             message(data.projectid,cat.msgm_RemVsFreeze.getstr())
  520.             quiet:=FALSE
  521.             RETURN
  522.         ENDIF
  523.         IF currid=data.projectid THEN currid:=-1
  524.  
  525.         exec_list:=kdata.exec_list
  526.         node:=exec_list.head
  527.         WHILE node.pid <> data.projectid
  528.             count++
  529.             node:=node.ln.succ
  530.         ENDWHILE
  531.         get(obj,MUIA_PlaneFunc_ProjectNode,{state})
  532.         doMethodA(opened_lst,[MUIM_List_Remove,count])
  533.         DisposeLink(node.item)
  534.         set(node.window,MUIA_Window_Open,FALSE)
  535.         doMethodA(app,[OM_REMMEMBER,node.window])
  536.         Mui_DisposeObject(node.window)
  537.         Remove(node)
  538.         END node
  539. quiet:=FALSE
  540.         doMethodA(opened_lst,[MUIM_ProjectList_Refresh,0])
  541.     ENDIF
  542. ENDPROC
  543.  
  544. PROC planeFunc_dispose(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  545. DEF data:PTR TO planeFunc_data
  546.     data:=INST_DATA(cl,obj)
  547.     ObtainSemaphore(data.sema)
  548.     data.app:=FALSE
  549.     ReleaseSemaphore(data.sema)
  550.     IF data.subtask
  551.         killsubtask(data)
  552.         set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoWrite)
  553.     ENDIF
  554. /*    IF cybergfxbase
  555.         IF (data.rp.bitmap) THEN FreeBitMap(data.rp.bitmap)
  556.     ELSE
  557.         IF (data.rp.bitmap) THEN Pi96FreeBitMap(data.rp.bitmap)
  558.     ENDIF*/
  559.     DisposeLink(data.name)
  560.     DisposeLink(data.rstr)
  561.     DisposeLink(data.gstr)
  562.     DisposeLink(data.bstr)
  563.     END data.rfunc
  564.     END data.gfunc
  565.     END data.bfunc
  566.     DisposeLink(data.imagefile)
  567.  
  568. ->    IF data.imagedata AND data.vec THEN FreeMem(data.imagedata,data.width*data.height*4)
  569.     IF data.picture THEN DeletePicture(data.picture) -> does picture free its data or not, when I did allocate it?
  570. ENDPROC doSuperMethodA(cl,obj,msg)
  571. PROC planeFunc_lamps(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  572. DEF data:PTR TO planeFunc_data
  573.     data:=INST_DATA(cl,obj)
  574.     IF data.failure AND $1
  575.         set(blue_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Error)
  576.     ELSE
  577.         set(blue_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Ok)
  578.     ENDIF
  579.     data:=INST_DATA(cl,obj)
  580.     IF data.failure AND $10
  581.         set(green_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Error)
  582.     ELSE
  583.         set(green_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Ok)
  584.     ENDIF
  585.     IF data.failure AND $100
  586.         set(red_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Error)
  587.     ELSE
  588.         set(red_fail,MUIA_Lamp_Color,MUIV_Lamp_Color_Ok)
  589.     ENDIF
  590. ENDPROC
  591.  
  592. PROC planeFunc_draw(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_draw)
  593. DEF data:PTR TO planeFunc_data,delta,d=FALSE,window:PTR TO window,mw,mh,w,h
  594.     doSuperMethodA(cl,obj,msg)
  595.     data:=INST_DATA(cl,obj)
  596.  
  597.     mw:=_mwidth(obj);mh:=_mheight(obj)
  598.  
  599.     IF data.drawhandle = NIL
  600.         get(obj,MUIA_Window,{window})
  601.         IF window
  602.             data.drawhandle:=odhandle(obj)
  603.             IF data.drawhandle = 0
  604.                 WriteF('I can''t obtain the draw handle..\n\n');RETURN
  605.             ENDIF
  606.         ELSE ; WriteF('MUIA_Window returned NIL\n');RETURN
  607.         ENDIF
  608.     ENDIF
  609.  
  610.     ObtainSemaphore(data.sema)
  611.     IF (msg.flags AND MADF_DRAWUPDATE)
  612.         IF data.newtop <> -1/*scroll vertically*/
  613.             data.top:=data.newtop;data.newtop:=-1
  614.             d:=TRUE
  615.         ENDIF
  616.         IF data.newleft <> -1/*scroll horizontally*/
  617.             data.left:=data.newleft;data.newleft:=-1
  618.             d:=TRUE
  619.         ENDIF
  620.  
  621.     ELSEIF (msg.flags AND MADF_DRAWOBJECT)
  622.         /*the window may have been resized..*/
  623.         set(data.hscroll,MUIA_Prop_Visible,Div(Mul(mw,100000),data.ratio))
  624.         set(data.vscroll,MUIA_Prop_Visible,Div(Mul(mh,100000),data.ratio))
  625.         get(data.vscroll,MUIA_Prop_First,{delta})
  626.         data.top:=delta
  627.         get(data.hscroll,MUIA_Prop_First,{delta})
  628.         data.left:=delta
  629.         d:=TRUE
  630.     ENDIF
  631.  
  632.     IF mw*mh=0 THEN
  633.         RETURN ReleaseSemaphore(data.sema) -> Would be silly to draw when size is zero :)
  634.  
  635.     w:=Div(Mul(mw,100000),data.ratio) -> dimensions of source to display.
  636.     h:=Div(Mul(mh,100000),data.ratio)
  637.     DrawPictureA(data.drawhandle,data.picture,_mleft(obj),_mtop(obj),[
  638.                                             GGFX_SourceX,data.left,
  639.                                             GGFX_SourceY,data.top,
  640.                                             GGFX_SourceWidth,Min(w,data.width-data.left),
  641.                                             GGFX_DestWidth,Min(mw,mw*(data.width-data.left)/w),
  642.                                             GGFX_SourceHeight,Min(h,data.height-data.top),
  643.                                             GGFX_DestHeight,Min(mh,mh*(data.height-data.top)/h),
  644.                                             TAG_DONE])
  645.     ReleaseSemaphore(data.sema)
  646. ENDPROC
  647.  
  648. /*not yet finished: ability to select a destination area*/
  649.  
  650. /*PROC drawhoriz(x,y,xx,obj:PTR TO object,data:PTR TO planeFunc_data)
  651.     IF data.ymin > data.top              /*top border*/
  652.         Move(_rp(obj),_mleft(obj)+Max(0,data.xmin-data.left),         _mtop(obj)+data.ymin-data.top)
  653.         Draw(_rp(obj),_mleft(obj)+Min(_mwidth(obj),data.xmax-data.left),_mtop(obj)+data.ymin-data.top)
  654.     ENDIF
  655.  
  656.     Move(_rp(obj),x,y)
  657.     Draw(_rp(obj),xx,y)
  658. ENDPROC*/
  659.  
  660. PROC planeFunc_get(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO opget)
  661. DEF data:PTR TO planeFunc_data,storage,attrid
  662.  
  663.     data:=INST_DATA(cl,obj)
  664.     attrid:=msg.attrid
  665.     storage:=msg.storage
  666.     ObtainSemaphore(data.sema)
  667.     SELECT attrid
  668.     CASE MUIA_PlaneFunc_Bstr
  669.         ^storage:=data.bstr
  670. /*    CASE MUIA_CompileR
  671.         ^storage:=data.compiler
  672.     CASE MUIA_CompileG
  673.         ^storage:=data.compileg
  674.     CASE MUIA_CompileB
  675.         ^storage:=data.compileb
  676. */    CASE MUIA_PlaneFunc_Gstr
  677.         ^storage:=data.gstr
  678.     CASE MUIA_PlaneFunc_Height
  679.         ^storage:=data.height
  680.     CASE MUIA_PlaneFunc_ImageFile
  681.         ^storage:=data.imagefile
  682.     CASE MUIA_PlaneFunc_Loading
  683.         ^storage:=data.loading
  684.     CASE MUIA_PlaneFunc_LoadM
  685.         ^storage:=data.loadm
  686.     CASE MUIA_PlaneFunc_Lock
  687.         ^storage:=data.lock
  688.     CASE MUIA_PlaneFunc_Name
  689.         ^storage:=data.name
  690.     CASE MUIA_PlaneFunc_Percent
  691.         IF data.lock=MUIV_PlaneFunc_Lock_Write
  692.             ^storage:=data.calculated*100/data.height
  693.         ELSE
  694.             ^storage:=0
  695.         ENDIF
  696.     CASE MUIA_PlaneFunc_OutputR
  697.         ^storage:=data.outputr
  698.     CASE MUIA_PlaneFunc_OutputG
  699.         ^storage:=data.outputg
  700.     CASE MUIA_PlaneFunc_OutputB
  701.         ^storage:=data.outputb
  702.     CASE MUIA_PlaneFunc_ProjectID
  703.         ^storage:=data.projectid
  704.     CASE MUIA_PlaneFunc_ProjectNode
  705.         ^storage:=data.projectnode
  706.     CASE MUIA_PlaneFunc_Quiet
  707.         ^storage:=data.quiet
  708.     CASE MUIA_PlaneFunc_Rstr
  709.         ^storage:=data.rstr
  710.     CASE MUIA_PlaneFunc_State
  711.         IF data.lock = MUIV_PlaneFunc_Lock_Write
  712.             IF data.paused
  713.                 ^storage:=MUIV_PlaneFunc_State_Paused
  714.             ELSEIF data.loading
  715.                 ^storage:=MUIV_PlaneFunc_State_Loading
  716.             ELSE
  717.                 ^storage:=MUIV_PlaneFunc_State_Drawing
  718.             ENDIF
  719.         ELSE
  720.             IF data.lock = 0
  721.                 ^storage:=MUIV_PlaneFunc_State_Idle
  722.             ELSE
  723.                 ^storage:=MUIV_PlaneFunc_State_Frozen
  724.             ENDIF
  725.         ENDIF
  726.     CASE MUIA_PlaneFunc_Type
  727.         ^storage:=data.type
  728.     CASE MUIA_PlaneFunc_Width
  729.         ^storage:=data.width
  730.     DEFAULT
  731.         ReleaseSemaphore(data.sema)
  732.         RETURN doSuperMethodA(cl,obj,msg)
  733.     ENDSELECT
  734.     ReleaseSemaphore(data.sema)
  735. ENDPROC MUI_TRUE
  736.  
  737. PROC planeFunc_set(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO opset)
  738. DEF data:PTR TO planeFunc_data,
  739.     tags:PTR TO tagitem,
  740.     tag:PTR TO tagitem,
  741.     attrid
  742. DEF window,group
  743.     data:=INST_DATA(cl,obj)
  744.     tags:=msg.attrlist
  745.     ObtainSemaphore(data.sema)
  746.     WHILE tag:=NextTagItem({tags})
  747.         attrid:=tag.tag
  748.         SELECT attrid
  749.         CASE MUIA_PlaneFunc_ImageFile
  750.             StrCopy(data.imagefile,tag.data)
  751.         CASE MUIA_PlaneFunc_Loading
  752.             data.loading:=tag.data
  753.             IF data.projectid=currid THEN
  754.                 setlamp(obj)
  755.         CASE MUIA_PlaneFunc_Left
  756.             data.newleft:=tag.data
  757.             Mui_Redraw(obj,MADF_DRAWUPDATE)
  758.         CASE MUIA_PlaneFunc_ProjectNode
  759.             data.projectnode:=tag.data
  760.         CASE MUIA_PlaneFunc_Top
  761.             data.newtop:=tag.data
  762.             Mui_Redraw(obj,MADF_DRAWUPDATE)
  763.         CASE MUIA_PlaneFunc_Lock
  764.             IF data.lock=MUIV_PlaneFunc_Lock_Write-> If the object is being written, the only tag allowed is NoWrite
  765.                 IF tag.data=MUIV_PlaneFunc_Lock_NoWrite
  766.                     data.lock:=0
  767.                 ENDIF
  768.             ELSEIF data.lock=0            -> If the object is free, it can either be read or write - locked
  769.                 data.lock:=tag.data
  770.             ELSE                         -> If the object is read locked, it can be read unlocked or read locked again.
  771.                 IF tag.data=MUIV_PlaneFunc_Lock_NoRead
  772.                     data.lock:=data.lock-1
  773.                 ELSEIF tag.data=MUIV_PlaneFunc_Lock_Read
  774.                     data.lock:=data.lock+1
  775.                 ENDIF
  776.             ENDIF
  777.             doMethodA(opened_lst,[MUIM_ProjectList_Refresh,data.projectid+2]) -> Refresh the "state" lamp.
  778.         CASE MUIA_PlaneFunc_Name
  779.             StrCopy(data.name,tag.data)
  780.             get(obj,MUIA_WindowObject,{window})
  781.             set(window,MUIA_Window_Title,data.name)
  782.         CASE MUIA_PlaneFunc_Quiet
  783.             data.quiet:=tag.data
  784.             IF data.quiet=FALSE
  785.                 get(obj,MUIA_Parent,{group})
  786.                 doMethodA(group,[MUIM_Group_InitChange])
  787.                 doMethodA(group,[MUIM_Group_ExitChange])
  788.                 /*IF cybergfxbase
  789.                     IF (data.rp.bitmap) THEN FreeBitMap(data.rp.bitmap)
  790.                     data.rp.bitmap:= AllocBitMap(data.width,data.height,24,BMF_MINPLANES OR BMF_CLEAR,friend)
  791.                 ELSE
  792.                     IF (data.rp.bitmap) THEN Pi96FreeBitMap(data.rp.bitmap)
  793.                     data.rp.bitmap:= Pi96AllocBitMap(data.width,data.height,24,BMF_MINPLANES OR BMF_CLEAR,NIL,RGBFB_A8R8G8B8)
  794.                 ENDIF*/
  795. ->                IF data.imagedata AND data.vec THEN FreeMem(data.imagedata,data.width*data.height*4);data.imagedata:=NIL
  796.                -> IF data.picture THEN DeletePicture(data.picture) -> NO!!
  797.  
  798.               /*  data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  799.                 data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  800.               */
  801.                 IF data.projectid=currid
  802.                     nnset(width_str,MUIA_String_Integer,data.width)
  803.                     nnset(height_str,MUIA_String_Integer,data.height)
  804.                 ENDIF
  805.                 /*IF data.subtask THEN
  806.                     sendsubtaskmsg(data.subtask,STC_CHANGEDONE,NIL) */
  807.             ENDIF
  808.         DEFAULT
  809.             IF (data.lock <> MUIV_PlaneFunc_Lock_Write) OR (data.quiet=-2)
  810.                 SELECT attrid
  811.                 CASE MUIA_PlaneFunc_Bstr
  812.                     StrCopy(data.bstr,tag.data)
  813.                     LowerStr(data.bstr)
  814.                     idecode(data.bfunc,tag.data,$1,data)
  815.                 CASE MUIA_PlaneFunc_Gstr
  816.                     StrCopy(data.gstr,tag.data)
  817.                     idecode(data.gfunc,tag.data,$10,data)
  818.                 CASE MUIA_PlaneFunc_LoadM
  819.                     data.loadm:=tag.data
  820.                 CASE MUIA_PlaneFunc_OutputR
  821.                     data.outputr:=tag.data
  822.                     idecode(data.rfunc,data.rstr,$100,data,data.outputr)
  823.                 CASE MUIA_PlaneFunc_OutputG
  824.                     data.outputg:=tag.data
  825.                     idecode(data.gfunc,data.gstr,$10,data,data.outputg)
  826.                 CASE MUIA_PlaneFunc_OutputB
  827.                     data.outputb:=tag.data
  828.                     idecode(data.bfunc,data.bstr,$1,data,data.outputb)
  829.                 CASE MUIA_PlaneFunc_Rstr
  830.                     StrCopy(data.rstr,tag.data)
  831.                     LowerStr(data.rstr)
  832.                     idecode(data.rfunc,tag.data,$100,data)
  833.                 CASE MUIA_PlaneFunc_Type
  834.                     data.type:=tag.data
  835.                 DEFAULT
  836.                     IF (data.lock <> MUIV_PlaneFunc_Lock_NoRead) AND (data.quiet<>-2)
  837.                         message(data.projectid,cat.msgm_AttrVsLock.getstr())
  838.                     ELSEIF attrid = MUIA_PlaneFunc_Width
  839.                         data.width:=tag.data
  840.                         set(data.hscroll,MUIA_Prop_Entries,tag.data)
  841.                         IF data.quiet=FALSE
  842.                             get(obj,MUIA_Parent,{group})
  843.                             doMethodA(group,[MUIM_Group_InitChange])
  844.                             doMethodA(group,[MUIM_Group_ExitChange])
  845.                             /*IF cybergfxbase
  846.                                 IF (data.rp.bitmap) THEN FreeBitMap(data.rp.bitmap)
  847.                                 data.rp.bitmap:= AllocBitMap(data.width,data.height,24,BMF_MINPLANES OR BMF_CLEAR,friend)
  848.                             ELSE
  849.                                 IF (data.rp.bitmap) THEN Pi96FreeBitMap(data.rp.bitmap)
  850.                                 data.rp.bitmap:= Pi96AllocBitMap(data.width,data.height,24,BMF_MINPLANES OR BMF_CLEAR,NIL,RGBFB_A8R8G8B8)
  851.                             ENDIF*/
  852. ->                            IF data.imagedata AND data.vec THEN FreeMem(data.imagedata,data.width*data.height*4);data.imagedata:=NIL
  853.                             IF data.picture THEN DeletePicture(data.picture);data.picture:=NIL
  854.                             data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  855.                             data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  856.                         ENDIF
  857.                     ELSEIF attrid = MUIA_PlaneFunc_Height
  858.                         data.height:=tag.data
  859.                         set(data.vscroll,MUIA_Prop_Entries,tag.data)
  860.                         IF data.quiet=FALSE
  861.                             get(obj,MUIA_Parent,{group})
  862.                             doMethodA(group,[MUIM_Group_InitChange])
  863.                             doMethodA(group,[MUIM_Group_ExitChange])
  864. ->                            IF data.imagedata AND data.vec THEN FreeMem(data.imagedata,data.width*data.height*4);data.imagedata:=NIL
  865.                             IF data.picture THEN DeletePicture(data.picture);data.picture:=NIL
  866.                             data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  867.                             data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  868.                         ENDIF
  869.                     ENDIF
  870.                 ENDSELECT
  871.             ELSE
  872.                 message(data.projectid,cat.msgm_AttrVsLock.getstr())
  873.             ENDIF
  874.         ENDSELECT
  875.     ENDWHILE
  876.     ReleaseSemaphore(data.sema)
  877. ENDPROC doSuperMethodA(cl,obj,msg)
  878.  
  879. /*idecode, extends f.create(). Ok, I know I should maybe have written a method, but it's easier like this :-¦*/
  880. PROC idecode(f:PTR TO expression,s:PTR TO CHAR,l,data:PTR TO planeFunc_data,in=-1)
  881. DEF out/*:PTR TO outinfo,err*/,i:PTR TO CHAR
  882.  
  883.     i:=String(StrLen(s)) -> New string so that lowerstr doesn't change text in field.
  884.     StrCopy(i,s)
  885.     LowerStr(i)
  886.  
  887.     IF in = -1 THEN
  888.         in:=f.precision
  889.  
  890.     IF in = OUT_Float64
  891.         message(data.projectid,cat.msgm_Nof64.getstr())
  892.         DisposeLink(i)
  893.         RETURN
  894.     ENDIF
  895.  
  896.     END f
  897.  
  898.     NEW f.create(in,i)
  899.     out:=f.message
  900.     IF out AND FAILURE
  901.         data.failure:=data.failure OR l
  902.         /*err:=out.error
  903.         SELECT err
  904.         CASE ERR_NoParse
  905.             messagefmt(data.projectid,cat.msgm_NoParse.getstr(),out.quote)
  906.         CASE ERR_NoFunc
  907.             messagefmt(data.projectid,cat.msgm_NoFunc.getstr(),out.quote)
  908.         CASE ERR_NoChar
  909.             messagefmt(data.projectid,cat.msgm_NoChar.getstr(),out.quote)
  910.         DEFAULT
  911.             message(data.projectid,cat.msgm_Failure.getstr())
  912.         ENDSELECT
  913.         END out*/
  914.     ELSE -> Can't currently have both failure and warning. It will come :-)
  915.         data.failure:=data.failure AND Not(l)
  916.         IF out AND WARN_NoSupport THEN
  917.             message(data.projectid,cat.msgm_WarnNoSupport.getstr())
  918.         IF out AND WARN_EPi THEN
  919.             message(data.projectid,cat.msgm_WarnEPi.getstr())
  920.     ENDIF
  921.     doMethodA(data.self,[MUIM_PlaneFunc_Lamps])
  922.     DisposeLink(i)
  923. ENDPROC
  924.  
  925. PROC planeFunc_abort(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_abort)
  926. DEF data:PTR TO planeFunc_data,ds1:PTR TO datestamp,ds2:datestamp,qe[30]:STRING,u
  927.     data:=INST_DATA(cl,obj)
  928.     IF data.subtask
  929.         killsubtask(data)
  930.         set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoWrite)
  931.  
  932.         u:=msg.reason
  933.         SELECT u
  934.         CASE MUIV_PlaneFunc_Abort_Finish
  935.             ds1:=data.ds
  936.             DateStamp(ds2)
  937.             u:=(ds2.minute-ds1.minute)*TICKS_PER_MINUTE+ds2.tick-ds1.tick -> number of ticks
  938.             StringF(qe,'\s  \z\d[2]:\z\d[2].\z\d[2].',cat.msgm_Done.getstr(),u/TICKS_PER_MINUTE,Mod(u,TICKS_PER_MINUTE)/TICKS_PER_SECOND,Mod(u,TICKS_PER_SECOND)*100/TICKS_PER_SECOND)
  939.             message(data.projectid,qe)
  940.         CASE MUIV_PlaneFunc_Abort_Abort
  941.             message(data.projectid,cat.msgm_Abort.getstr())
  942.             IF data.type = MUIV_PlaneFunc_Type_Graph AND data.imagedata -> the rendering was aborted. we'll have to tidy up
  943.                 IF data.picture THEN DeletePicture(data.picture)
  944.                 data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  945.                 data.calculated:=0
  946.             ENDIF
  947.         CASE MUIV_PlaneFunc_Abort_NoLoad
  948.             message(data.projectid,cat.msgm_NoLoad.getstr())
  949.         ENDSELECT
  950.  
  951.         data.drawn:=0
  952.         data.calculated:=0
  953.         data.paused:=FALSE
  954.         data.loading:=FALSE
  955.  
  956.         Mui_Redraw(obj,MADF_DRAWUPDATE)
  957.     ENDIF
  958. ENDPROC
  959.  
  960. PROC planeFunc_loadfunc(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  961. DEF u,filereq:PTR TO filerequester,s[200]:STRING,handler,data:PTR TO planeFunc_data,
  962.     eq,var[10]:STRING,value:PTR TO CHAR
  963.  
  964.     data:=INST_DATA(cl,obj)
  965.     get(settings_win,MUIA_Window_Window,{u})
  966.     filereq:=AllocAslRequest(ASL_FILEREQUEST,
  967.                             [ASL_HAIL,      cat.msgr_Loadf_T.getstr(),
  968.                              ASL_OKTEXT,    cat.msgr_Loadf_Ok.getstr(),
  969.                              ASL_DIR,       funcdir,
  970.                              ASL_WINDOW,    u,
  971.                              NIL])
  972.     IF filereq=NIL
  973.         Mui_RequestA(app,settings_win,0,cat.msgr_Loadf_T.getstr(),NIL,cat.msgr_NoAslReq.getstr(),NIL)
  974.     ELSE
  975.         IF AslRequest(filereq,NIL)
  976.             StrCopy(s,filereq.drawer)
  977.             DisposeLink(funcdir);funcdir:=String(StrLen(s));StrCopy(funcdir,s)
  978.             AddPart(s,filereq.file,StrMax(s))
  979.             SetStr(s,StrLen(s))
  980.         ENDIF
  981.         FreeAslRequest(filereq)
  982.     ENDIF
  983.     IF s[] = NIL THEN RETURN
  984.     handler:=Open(s,OLDFILE)
  985.     Fgets(handler,s,StrMax(s)-1)
  986.     IF s[]=NIL
  987.         Close(handler)
  988.         message(data.projectid,cat.msgm_EmptyFile.getstr())
  989.         RETURN
  990.     ENDIF
  991.     SetStr(s,StrLen(s)-1)
  992.     IF Not(StrCmp(s,'picFX function-file; type1'))
  993.         Close(handler)
  994.         message(data.projectid,cat.msgm_BadFile.getstr())
  995.         RETURN
  996.     ENDIF
  997.     set(obj,MUIA_PlaneFunc_Quiet,MUI_TRUE)
  998.     WHILE Fgets(handler,s,StrMax(s)-1)/* semaphore will be obtained in the SET method */
  999.         SetStr(s,StrLen(s)-1)
  1000.         eq:=InStr(s,'=')
  1001.         StrCopy(var,s,eq)
  1002.         value:=s+eq+1
  1003.         IF StrCmp(var,'bstr')
  1004.             set(obj,MUIA_PlaneFunc_Bstr,value)
  1005.         ELSEIF StrCmp(var,'gstr')
  1006.             set(obj,MUIA_PlaneFunc_Gstr,value)
  1007.         ELSEIF StrCmp(var,'height')
  1008.             set(obj,MUIA_PlaneFunc_Height,Val(value))
  1009.         ELSEIF StrCmp(var,'rstr')
  1010.             set(obj,MUIA_PlaneFunc_Rstr,value)
  1011.         ELSEIF StrCmp(var,'width')
  1012.             set(obj,MUIA_PlaneFunc_Width,Val(value))
  1013.         ELSEIF StrCmp(var,'precision') -> Obsolete tag!
  1014.             set(obj,MUIA_PlaneFunc_OutputR,Val(value))
  1015.             set(obj,MUIA_PlaneFunc_OutputG,Val(value))
  1016.             set(obj,MUIA_PlaneFunc_OutputB,Val(value))
  1017.             message(data.projectid,cat.msgm_Obsolete.getstr())
  1018.         ELSEIF StrCmp(var,'outputr')
  1019.             set(obj,MUIA_PlaneFunc_OutputR,Val(value))
  1020.         ELSEIF StrCmp(var,'outputg')
  1021.             set(obj,MUIA_PlaneFunc_OutputG,Val(value))
  1022.         ELSEIF StrCmp(var,'outputb')
  1023.             set(obj,MUIA_PlaneFunc_OutputB,Val(value))
  1024.         ELSE
  1025.             StringF(s,cat.msgm_UnknownVar.getstr(),var)
  1026.             message(data.projectid,s)
  1027.         ENDIF
  1028.     ENDWHILE
  1029.     Close(handler)
  1030.     set(obj,MUIA_PlaneFunc_Quiet,FALSE)
  1031.     doMethodA(opened_lst,[MUIM_ProjectList_Refresh,0])
  1032. ENDPROC
  1033.  
  1034. PROC planeFunc_render(cl:PTR TO iclass,obj:PTR TO object/*,msg*/)
  1035. DEF data:PTR TO planeFunc_data,state,r,msg
  1036.     data:=INST_DATA(cl,obj)
  1037.     get(obj,MUIA_PlaneFunc_State,{state})
  1038.     IF state = MUIV_PlaneFunc_State_Idle
  1039.         get(recompile_chk,MUIA_Pressed,{r}) ; IF r -> do recompile
  1040.             get(red_str,MUIA_String_Contents,{r})
  1041.             doMethodA(opened_lst,[MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Red,r])
  1042.             get(green_str,MUIA_String_Contents,{r})
  1043.             doMethodA(opened_lst,[MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Green,r])
  1044.             get(blue_str,MUIA_String_Contents,{r})
  1045.             doMethodA(opened_lst,[MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Blue,r])
  1046.         ENDIF
  1047.  
  1048.         set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_Write)
  1049.  
  1050.         data.subtask:=AllocVec(SIZEOF subtask,MEMF_PUBLIC OR MEMF_CLEAR)
  1051.  
  1052.         IF data.type = MUIV_PlaneFunc_Type_DTPic
  1053.             set(obj,MUIA_PlaneFunc_Loading,TRUE)
  1054.         ELSE
  1055.             IF freeze(data.rfunc) = 0 -> This will freeze used projects; if zero, it failed.
  1056.                 message(data.projectid,cat.msgm_NoAlloc.getstr())
  1057.                 FreeVec(data.subtask);data.subtask:=NIL
  1058.                 set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoWrite)
  1059.                 RETURN
  1060.             ENDIF
  1061.             IF freeze(data.gfunc) = 0
  1062.                 message(data.projectid,cat.msgm_NoAlloc.getstr())
  1063.                 FreeVec(data.subtask);data.subtask:=NIL
  1064.                 set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoWrite)
  1065.                 RETURN
  1066.             ENDIF
  1067.             IF freeze(data.bfunc) = 0
  1068.                 message(data.projectid,cat.msgm_NoAlloc.getstr())
  1069.                 FreeVec(data.subtask);data.subtask:=NIL
  1070.                 set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoWrite)
  1071.                 RETURN
  1072.             ENDIF
  1073.             /*will we have to save previous pixel information?*/
  1074.             data.savepixel:=(data.outputr>=OUT_OldR) AND (data.outputr<=OUT_OldB)
  1075.             data.savepixel:=data.savepixel OR ((data.outputg>=OUT_OldR) AND (data.outputg<=OUT_OldB))
  1076.             data.savepixel:=data.savepixel OR ((data.outputb>=OUT_OldR) AND (data.outputb<=OUT_OldB))
  1077.  
  1078.             data.rupd:=rupd
  1079.             data.subtask.st_Reply:=CreateMsgPort()
  1080.         ENDIF
  1081.  
  1082.  
  1083.         r,msg:=fork()
  1084.         SELECT r
  1085.         CASE 0 -> if we are here then we are the subtask
  1086.             IF data.type = MUIV_PlaneFunc_Type_DTPic
  1087.                 loadpicture(data)
  1088.             ELSE
  1089.                 data.subtask.st_Port:=CreateMsgPort()
  1090.                 renderfunc(data)                
  1091.             ENDIF
  1092.         CASE -1
  1093.             SELECT msg -> if we're here then forking the process failed
  1094.             CASE FORKERROR_SIGNAL
  1095.                 message(data.projectid,cat.msgm_FEsignal.getstr())
  1096.             CASE FORKERROR_MEMORY
  1097.                 message(data.projectid,cat.msgm_FEmemory.getstr())
  1098.             CASE FORKERROR_CHILD
  1099.                 message(data.projectid,cat.msgm_FEchild.getstr())
  1100.             DEFAULT
  1101.                 messagefmt(data.projectid,'Unexpected error $\h',msg) -> ditto
  1102.             ENDSELECT
  1103.         DEFAULT -> if we're here then we're still the main task
  1104.             data.subtask.st_Task:=r
  1105.             SetTaskPri(data.subtask.st_Task,cp)
  1106.         ENDSELECT
  1107.     ELSEIF data.type = MUIV_PlaneFunc_Type_Graph
  1108.         SELECT state
  1109.         CASE MUIV_PlaneFunc_State_Drawing
  1110.             sendsubtaskmsg(data.subtask,STC_PAUSE,NIL)
  1111.             data.paused:=TRUE
  1112.             doMethodA(opened_lst,[MUIM_ProjectList_Refresh,data.projectid+2])
  1113.         CASE MUIV_PlaneFunc_State_Paused
  1114.             data.paused:=FALSE
  1115.             sendsubtaskmsg(data.subtask,STC_RESTART,NIL)
  1116.             doMethodA(opened_lst,[MUIM_ProjectList_Refresh,data.projectid+2])
  1117.         CASE MUIV_PlaneFunc_State_Frozen
  1118.             message(data.projectid,cat.msgm_WriteVsFreeze.getstr())
  1119.         ENDSELECT
  1120.     ENDIF
  1121. ENDPROC
  1122.  
  1123. PROC planeFunc_savefunc(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1124. DEF u,filereq:PTR TO filerequester,s[200]:STRING,newhandler,oldhandler,data:PTR TO planeFunc_data
  1125.     data:=INST_DATA(cl,obj)
  1126.     get(settings_win,MUIA_Window_Window,{u})
  1127.     filereq:=AllocAslRequest(ASL_FILEREQUEST,
  1128.                             [ASL_HAIL,      cat.msgr_Savef_T.getstr(),
  1129.                              ASL_OKTEXT,    cat.msgr_Savef_Ok.getstr(),
  1130.                              ASL_DIR,       funcdir,
  1131.                              ASL_WINDOW,    u,
  1132.                              ASL_FUNCFLAGS, FILF_SAVE,
  1133.                              NIL])
  1134.     IF filereq=NIL
  1135.         Mui_RequestA(app,settings_win,0,cat.msgr_Savef_T.getstr(),NIL,cat.msgr_NoAslReq.getstr(),NIL)
  1136.     ELSE
  1137.         IF AslRequest(filereq,NIL)
  1138.             StrCopy(s,filereq.drawer)
  1139.             DisposeLink(funcdir);funcdir:=String(StrLen(s));StrCopy(funcdir,s)
  1140.             AddPart(s,filereq.file,StrMax(s))
  1141.             SetStr(s,StrLen(s))
  1142.         ENDIF
  1143.         FreeAslRequest(filereq)
  1144.     ENDIF
  1145.     IF s[] = NIL THEN RETURN
  1146.     newhandler:=Open(s,NEWFILE)
  1147.     oldhandler:=SetStdOut(newhandler)
  1148.     WriteF('picFX function-file; type1\n')
  1149.     ObtainSemaphore(data.sema)
  1150.     WriteF('bstr=\s\n',data.bstr)
  1151.     WriteF('gstr=\s\n',data.gstr)
  1152.     WriteF('height=\d\n',data.height)
  1153.     WriteF('rstr=\s\n',data.rstr)
  1154.     WriteF('outputr=\d\n',data.outputr)
  1155.     WriteF('outputg=\d\n',data.outputg)
  1156.     WriteF('outputb=\d\n',data.outputb)
  1157.     WriteF('width=\d\n',data.width)
  1158.     ReleaseSemaphore(data.sema)
  1159.     Close(newhandler)
  1160.     SetStdOut(oldhandler)
  1161. ENDPROC
  1162.  
  1163. -> Care if I put this in a separate task with setlamp(obj)...
  1164. PROC planeFunc_savepic(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO args_file*/)
  1165. DEF iff:PTR TO iffhandle,bmhd:PTR TO bmhd,x,y,w,bp,bit=0,b:PTR TO CHAR,c,k
  1166. DEF filereq:PTR TO filerequester,s[200]:STRING,data:PTR TO planeFunc_data
  1167.     data:=INST_DATA(cl,obj)
  1168.     get(settings_win,MUIA_Window_Window,{w})
  1169.     filereq:=AllocAslRequest(ASL_FILEREQUEST,
  1170.                             [ASL_HAIL,      cat.msgr_SavePicture.getstr(),
  1171.                              ASL_OKTEXT,    cat.msgr_Savef_Ok.getstr(),
  1172.                              ASL_DIR,       picdir,
  1173.                              ASL_WINDOW,    w,
  1174.                              ASL_FUNCFLAGS, FILF_SAVE,
  1175.                              NIL])
  1176.     IF filereq=NIL
  1177.         Mui_RequestA(app,settings_win,0,cat.msgr_SavePicture.getstr(),NIL,cat.msgr_NoAslReq.getstr(),NIL)
  1178.     ELSE
  1179.         IF AslRequest(filereq,NIL)
  1180.             StrCopy(s,filereq.drawer)
  1181.             DisposeLink(picdir);picdir:=String(StrLen(s));StrCopy(picdir,s)
  1182.             AddPart(s,filereq.file,StrMax(s))
  1183.             SetStr(s,StrLen(s))
  1184.         ENDIF
  1185.         FreeAslRequest(filereq)
  1186.     ENDIF
  1187.     IF s[] = NIL THEN RETURN
  1188.  
  1189.     set(state_txt,MUIA_Text_Contents,cat.msgs_Saving.getstr())
  1190.     set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_SavingData)
  1191.     set(state_gau,MUIA_Gauge_Current,0)
  1192.  
  1193.     iff:=AllocIFF()
  1194.     iff.stream:=Open(s,NEWFILE)
  1195.     IF iff.stream = NIL THEN RETURN
  1196.     InitIFFasDOS(iff)
  1197.     OpenIFF(iff,IFFF_WRITE)
  1198.  
  1199.     PushChunk(iff,ID_ILBM,ID_FORM,IFFSIZE_UNKNOWN)
  1200.  
  1201.     NEW bmhd
  1202.     bmhd.w:=data.width;bmhd.h:=data.height
  1203.     bmhd.planes:=24
  1204.     bmhd.compression:=0 -> currently (?) saving uncompressed iffs.
  1205.     bmhd.xaspect:=1;bmhd.yaspect:=bmhd.xaspect -> what should be correct values?
  1206.     bmhd.pagew:=bmhd.w;bmhd.pageh:=bmhd.h
  1207.  
  1208.     PushChunk(iff,ID_ILBM,ID_BMHD,SIZEOF bmhd)
  1209.     WriteChunkBytes(iff,bmhd,SIZEOF bmhd)
  1210.     PopChunk(iff)
  1211.     END bmhd
  1212.  
  1213.     PushChunk(iff,ID_ILBM,ID_BODY,IFFSIZE_UNKNOWN)
  1214.     w:=data.width
  1215.     w:=(w-1) AND Not(%1111)+15 -> Rounded to the nearest multiple of 16, and substract 1 because we start from zero...
  1216.     NEW b[(w+1)*3+1]
  1217.     c:=b
  1218.     bit:=0
  1219.     FOR y:=0 TO data.height
  1220.         set(state_gau,MUIA_Gauge_Current,y*100/data.height)
  1221.         FOR k:=0 TO 2
  1222.             FOR bp:=16-(k*8) TO 23-(k*8)
  1223.                 FOR x:=0 TO w
  1224.                     b[]:=Shl(b[],1)+(Shr(pixel(data.imagedata,data.width,x,y),bp) AND $1) -> Yurk, that's awfully sloow!!!
  1225.                     bit++
  1226.                     IF bit=8
  1227.                         b++;bit:=0
  1228.                         b[]:=0
  1229.                     ENDIF
  1230.                 ENDFOR
  1231.             ENDFOR
  1232.         ENDFOR
  1233.         b:=c
  1234.         WriteChunkBytes(iff,b,(w+1)*3)
  1235.     ENDFOR
  1236.     PopChunk(iff)
  1237.     END b[(w+1)*3+1]
  1238.     PopChunk(iff)
  1239.  
  1240.     CloseIFF(iff)
  1241.     Close(iff.stream)
  1242.     FreeIFF(iff)
  1243.     setlamp(obj)
  1244. ENDPROC
  1245.  
  1246. PROC planeFunc_setsize(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1247. DEF data:PTR TO planeFunc_data,k,nr
  1248.     data:=INST_DATA(cl,obj)
  1249. /*We want the sum of the apparent dimensions of the picture to be the same as the one for the drawing area.*/
  1250.  
  1251.     nr:=Div(Mul(100000,_mwidth(obj)+_mheight(obj)+1),data.width+data.height+1)
  1252.     IF data.ratio=nr
  1253.         data.ratio:=100000 -> Press twice space bar to set ratio to 1:1
  1254.     ELSE
  1255.         data.ratio:=nr
  1256.     ENDIF
  1257.  
  1258.     set(data.hscroll,MUIA_Prop_Visible,Div(Mul(_mwidth(obj),100000),data.ratio))
  1259.     set(data.vscroll,MUIA_Prop_Visible,Div(Mul(_mheight(obj),100000),data.ratio))
  1260.     get(data.vscroll,MUIA_Prop_First,{k})
  1261.     data.newtop:=k
  1262.     get(data.hscroll,MUIA_Prop_First,{k})
  1263.     data.newleft:=k
  1264.  
  1265.     Mui_Redraw(obj,MADF_DRAWOBJECT)
  1266. ENDPROC
  1267.  
  1268. PROC planeFunc_settaskpri(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_ctp)
  1269. DEF data:PTR TO planeFunc_data
  1270.     data:=INST_DATA(cl,obj)
  1271.     ObtainSemaphore(data.sema)
  1272.     IF data.subtask THEN
  1273.         SetTaskPri(data.subtask.st_Task,msg.value)
  1274.     ReleaseSemaphore(data.sema)
  1275. ENDPROC
  1276. PROC planeFunc_update(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1277. DEF data:PTR TO planeFunc_data
  1278.     data:=INST_DATA(cl,obj)
  1279.     ObtainSemaphore(data.sema)
  1280.     data.app:=FALSE
  1281.     ReleaseSemaphore(data.sema)
  1282.     IF data.calculated=0 THEN Mui_Redraw(obj,MADF_DRAWUPDATE)
  1283.     IF data.projectid = currid
  1284. ->        ObtainSemaphore(data.sema)
  1285.         set(state_gau,MUIA_Gauge_Current,data.calculated*100/data.height)
  1286. ->        ReleaseSemaphore(data.sema)
  1287.     ENDIF
  1288.     ObtainSemaphore(data.sema)
  1289.     data.app:=TRUE
  1290.     ReleaseSemaphore(data.sema)
  1291. ENDPROC
  1292.  
  1293. /***************************************************************
  1294. ** custom ProjectList private subclass of List class          **
  1295. ****************************************************************
  1296. **                                                            **
  1297. ** Interaction between the application and the opened projects**
  1298. ***************************************************************/
  1299.  
  1300. CONST PROJECTNODE_ID=100
  1301.  
  1302. PROC projectList_dispatcher(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  1303. DEF methodid
  1304.     methodid:=msg.methodid
  1305.     SELECT methodid
  1306.     CASE OM_NEW                   ; RETURN projectList_new(cl,obj,msg)
  1307.     CASE OM_DISPOSE               ; RETURN projectList_dispose(cl,obj,msg)
  1308.     CASE MUIM_Setup               ; RETURN projectList_setup(cl,obj,msg)
  1309.     CASE MUIM_Cleanup             ; RETURN projectList_cleanup(cl,obj,msg)
  1310.     CASE MUIM_ProjectList_DelItem ; RETURN projectList_delitem(cl,obj/*,msg*/)
  1311.     CASE MUIM_ProjectList_Exit    ; RETURN projectList_exit(cl,obj/*,msg*/)
  1312.     CASE MUIM_ProjectList_Forward ; RETURN projectList_forward(cl,obj,msg)
  1313.     CASE MUIM_ProjectList_Memory  ; RETURN projectList_memory(cl,obj/*,msg*/)
  1314.     CASE MUIM_ProjectList_NewItem ; RETURN projectList_newitem(cl,obj/*,msg*/)
  1315.     CASE MUIM_ProjectList_Notify  ; RETURN projectList_notify(cl,obj,msg)
  1316.     CASE MUIM_ProjectList_Prefs   ; RETURN projectList_prefs(cl,obj,msg)
  1317.     CASE MUIM_ProjectList_Refresh ; RETURN projectList_refresh(cl,obj,msg)
  1318.     CASE MUIM_ProjectList_SavePrefs;RETURN projectList_saveprefs(/*cl,obj,msg*/)
  1319.     CASE MUIM_ProjectList_SetPri  ; RETURN projectList_setpri(cl,obj,msg)
  1320.     CASE MUIM_ProjectList_ShowMe  ; RETURN projectList_showme(cl,obj,msg)
  1321.     ENDSELECT
  1322. ENDPROC doSuperMethodA(cl,obj,msg)
  1323.  
  1324. PROC getcurrent(data:PTR TO projectList_data,obj:PTR TO object)
  1325. DEF active
  1326. DEF exec_list:PTR TO lh,worknode:PTR TO project_Node,z,list:PTR TO mlh,cs:PTR TO object
  1327.     get(obj,MUIA_List_Active,{active})
  1328.     IF active=MUIV_List_Active_Off THEN RETURN 0
  1329.     exec_list:=data.exec_list
  1330.     worknode:=exec_list.head
  1331.               /* I should add here a check that the bound of the list is never reached!*/
  1332.     IF active > 0
  1333.         FOR z:=1 TO active
  1334.             worknode:=worknode.ln.succ
  1335.         ENDFOR
  1336.     ENDIF
  1337.     get(worknode.window,MUIA_Window_RootObject,{z})
  1338.  
  1339.     get(z,MUIA_Group_ChildList,{list})
  1340.     cs:=list.head
  1341. ENDPROC NextObject({cs}),worknode.window
  1342.  
  1343. /*Care! getp() asks the ProjectID and not line number!!!*/
  1344.  
  1345. PROC getp(data:PTR TO projectList_data,pid)
  1346. DEF exec_list:PTR TO lh,worknode:PTR TO project_Node,z,list:PTR TO mlh,cs:PTR TO object
  1347.  
  1348.     exec_list:=data.exec_list
  1349.     worknode:=exec_list.head
  1350.               /* I should add here a check that the bound of the list is never reached!*/
  1351.     WHILE mcomp(worknode,pid)
  1352.         worknode:=worknode.ln.succ
  1353.     ENDWHILE
  1354.     IF worknode.ln.succ = 0
  1355.         z:=String(80)
  1356.         StringF(z,cat.msgm_NoID.getstr(),pid)
  1357.         message(-1,z)
  1358.         DisposeLink(z)
  1359.         RETURN 0,0
  1360.     ENDIF
  1361.     get(worknode.window,MUIA_Window_RootObject,{z})
  1362.  
  1363.     get(z,MUIA_Group_ChildList,{list})
  1364.     cs:=list.head
  1365. ENDPROC NextObject({cs}),worknode.window
  1366.  
  1367. PROC mcomp(node:PTR TO project_Node,id)
  1368.     IF node.ln.succ=0 THEN RETURN FALSE -> This silly proc to avoid a atupid enforcer hit :-s
  1369. ENDPROC (node.pid <> id)
  1370.  
  1371. PROC getdata(data:PTR TO projectList_data,pid)
  1372. DEF gad
  1373.     gad:=getp(data,pid)
  1374.     IF gad = 0 THEN RETURN 0
  1375. ENDPROC INST_DATA(cl_planefunc.mcc_class,gad)
  1376.  
  1377. PROC projectList_new(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  1378. DEF exec_list:PTR TO lh,data:PTR TO projectList_data
  1379. DEF port,req
  1380.     IF (obj:=doSuperMethodA(cl,obj,msg)) = FALSE THEN RETURN FALSE
  1381.     data:=INST_DATA(cl,obj)
  1382.     NEW exec_list
  1383.     newList(exec_list) -> Create an Exec list for the opened projects
  1384.     data.exec_list:=exec_list -> save the list in the instance data
  1385.  
  1386.     screentitle:=String(150)
  1387.  
  1388.     port := CreateMsgPort() -> Check here that port exists
  1389.     data.port:=port
  1390.     req := CreateIORequest(data.port,SIZEOF timerequest) -> Check here that req exists
  1391.     data.req:=req
  1392.     OpenDevice(TIMERNAME,UNIT_VBLANK,data.req,0) -> NIL if it went all right, check it
  1393.     data.ihnode.ihn_millis  := 5000 -> Update memory display every five seconds
  1394.     data.ihnode.ihn_object  := obj
  1395.     data.ihnode.ihn_method  := MUIM_ProjectList_Memory
  1396.     data.ihnode.ihn_flags   := MUIIHNF_TIMER
  1397. ENDPROC obj
  1398.  
  1399. PROC projectList_setup(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_setup)
  1400. DEF id,data:PTR TO projectList_data
  1401.     IF doSuperMethodA(cl,obj,msg) = FALSE THEN RETURN FALSE
  1402.     data:=INST_DATA(cl,obj)
  1403.     -> All screenmode stuff is now handled by guigfx :-)
  1404.  
  1405.     data.req.io.command := TR_ADDREQUEST
  1406.     data.req.time.secs    := 5 -> Update every five seconds
  1407.     data.req.time.micro   := 0
  1408.     SendIO(data.req)
  1409.     doMethodA(_app(obj),[MUIM_Application_AddInputHandler,data.ihnode])
  1410.  
  1411.     initfuncs({getdata},data,varlist_lst) -> initialization of parser.m
  1412.  
  1413. ENDPROC MUI_TRUE
  1414.  
  1415. PROC projectList_cleanup(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  1416. DEF data:PTR TO projectList_data
  1417.     data := INST_DATA(cl,obj)
  1418.     doMethodA(_app(obj),[MUIM_Application_RemInputHandler,data.ihnode])
  1419.     IF (CheckIO(data.req)=NIL) THEN AbortIO(data.req)
  1420.     WaitIO(data.req)
  1421.     cleanfuncs()
  1422. ENDPROC (doSuperMethodA(cl,obj,msg))
  1423.  
  1424. PROC projectList_dispose(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  1425. DEF worknode:PTR TO project_Node, nextnode,exec_list:PTR TO lh,data:PTR TO projectList_data
  1426.     data:=INST_DATA(cl,obj)
  1427.     exec_list:=data.exec_list
  1428.     worknode:=exec_list.head  -> First node
  1429.     IF worknode
  1430.         WHILE nextnode:=worknode.ln.succ
  1431.             END worknode;worknode:=nextnode
  1432.         ENDWHILE
  1433.     ENDIF
  1434.  
  1435.     DisposeLink(screentitle)
  1436.  
  1437.     IF (data.req)
  1438.         IF (data.req.io.device) THEN CloseDevice(data.req)
  1439.         DeleteIORequest(data.req)
  1440.     ENDIF
  1441.     IF (data.port) THEN DeleteMsgPort(data.port)
  1442. ENDPROC doSuperMethodA(cl,obj,msg)
  1443.  
  1444. PROC projectList_delitem(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1445. DEF data:PTR TO projectList_data,gad,window,state,
  1446.   node:PTR TO project_Node
  1447.  
  1448. quiet:=TRUE /*prevents the opened projects list from refreshing the display*/
  1449.     data:=INST_DATA(cl,obj)
  1450.     gad,window:=getcurrent(data,obj)
  1451.     doMethodA(gad,[MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Abort])/*aborts the task, if necessary*/
  1452.     get(gad,MUIA_PlaneFunc_ProjectNode,{node})
  1453.     get(gad,MUIA_PlaneFunc_State,{state})
  1454.     IF state = MUIV_PlaneFunc_State_Frozen
  1455.         message(node.pid,cat.msgm_RemVsFreeze.getstr())
  1456.         quiet:=FALSE
  1457.         RETURN
  1458.     ENDIF
  1459.     doMethodA(obj,[MUIM_List_Remove,MUIV_List_Remove_Active])/*removes the name from the list*/
  1460.     DisposeLink(node.item)
  1461.     set(window,MUIA_Window_Open,FALSE)/*Closes the window*/
  1462.     doMethodA(app,[OM_REMMEMBER,window])
  1463.     Mui_DisposeObject(window) /*Removes the window and the PlaneFuncObject*/
  1464.     Remove(node)
  1465.     END node
  1466.     currid:=-1 -> This is to prevent projectList to change that unexistant project's priority
  1467. quiet:=FALSE
  1468.     doMethodA(obj,[MUIM_ProjectList_Refresh,0])
  1469. ENDPROC
  1470.  
  1471. PROC projectList_exit(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1472. DEF gad,data:PTR TO projectList_data,str[40]:STRING,pid
  1473. DEF exec_list:PTR TO lh,worknode:PTR TO project_Node,z,list:PTR TO mlh,cs:PTR TO object
  1474.     data:=INST_DATA(cl,obj)
  1475.     exec_list:=data.exec_list
  1476.     worknode:=exec_list.head
  1477.     WHILE worknode.ln.succ
  1478.         get(worknode.window,MUIA_Window_RootObject,{z})
  1479.         get(z,MUIA_Group_ChildList,{list})
  1480.         cs:=list.head
  1481.         gad:=NextObject({cs})
  1482.         get(gad,MUIA_PlaneFunc_ProjectID,{pid})
  1483.         StringF(str,cat.msgm_Removing.getstr(),pid)
  1484.         message(-1,str)
  1485.         doMethodA(gad,[MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Abort])
  1486.         worknode:=worknode.ln.succ
  1487.     ENDWHILE
  1488. ENDPROC
  1489.  
  1490. PROC projectList_forward(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_forward)
  1491. DEF gad,data:PTR TO projectList_data
  1492.     data:=INST_DATA(cl,obj)
  1493.     gad:=getcurrent(data,obj)
  1494.     IF msg.method=MUIM_PlaneFunc_Abort
  1495.         doMethodA(gad,[MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Abort])
  1496.     ELSE
  1497.         doMethodA(gad,[msg.method])
  1498.     ENDIF
  1499. ENDPROC
  1500.  
  1501. PROC projectList_memory(cl:PTR TO iclass,obj:PTR TO object)
  1502. DEF win:PTR TO object,data:PTR TO projectList_data
  1503.     data:=INST_DATA(cl,obj)
  1504.  
  1505.     StringF(screentitle,'\s - \d Chip - \d Fast - \d Total',PICVERSION,AvailMem(MEMF_CHIP),AvailMem(MEMF_FAST),AvailMem(MEMF_ANY))
  1506.     get(obj,MUIA_WindowObject,{win})
  1507.     set(win,MUIA_Window_ScreenTitle,screentitle)
  1508.     set(messages_win,MUIA_Window_ScreenTitle,screentitle)
  1509. ENDPROC
  1510.  
  1511. PROC projectList_newitem(cl:PTR TO iclass,obj:PTR TO object/*,msg:PTR TO msg*/)
  1512. DEF window, pfunc,vscroll,hscroll,pid,
  1513. name:PTR TO CHAR,node:PTR TO project_Node,inlist:PTR TO CHAR,
  1514. exec_list:PTR TO lh,data:PTR TO projectList_data,
  1515. pdata:PTR TO planeFunc_data
  1516.  
  1517.     data:=INST_DATA(cl,obj);exec_list:=data.exec_list
  1518.     NEW node
  1519.     window:=WindowObject,
  1520.         MUIA_Window_ScreenTitle, PICVERSION,
  1521.         ->MUIA_Window_UseRightBorderScroller,MUI_TRUE,
  1522.         MUIA_Window_UseBottomBorderScroller,MUI_TRUE,
  1523.         WindowContents,
  1524.             HGroup,
  1525.                 MUIA_Group_Spacing,0,
  1526.                 Child, pfunc:=PlaneFuncObject,End,
  1527.                 Child, vscroll:=ScrollbarObject,
  1528.                     MUIA_FixWidth,20,
  1529.                     ->MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Right, /*This is an MUI bug, the refreshing is not done correctely when having a scroller in the right border..*/
  1530.                     MUIA_Prop_Entries,255,MUIA_Prop_Visible,255,
  1531.                 End,
  1532.                 Child, hscroll:=PropObject,
  1533.                     MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Bottom,
  1534.                     MUIA_Prop_Entries,255,MUIA_Prop_Visible,255,
  1535.                 End,
  1536.             End,
  1537.         End
  1538.  
  1539.     set(vscroll,MUIA_Prop_Entries,255) -> entries not set correctely..
  1540.  
  1541.     doMethodA(app,[OM_ADDMEMBER,window])  /* now the project window is ready;*/
  1542.     get(pfunc,MUIA_PlaneFunc_Name,{name}) /* the PlaneFunc class has also initialised.*/
  1543.     set(window,MUIA_Window_Title,name) -> Read the default PlaneFunc name
  1544.     pdata:=INST_DATA(cl_planefunc.mcc_class,pfunc)
  1545.     pdata.hscroll:=hscroll
  1546.     pdata.vscroll:=vscroll
  1547.     doMethodA(hscroll,[MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,pfunc,3,MUIM_Set,MUIA_PlaneFunc_Left,MUIV_TriggerValue])
  1548.     doMethodA(vscroll,[MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,pfunc,3,MUIM_Set,MUIA_PlaneFunc_Top,MUIV_TriggerValue])
  1549.     doMethodA(window,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,pfunc,1,MUIM_PlaneFunc_Close])
  1550.     doMethodA(window,[MUIM_Notify,MUIA_Window_InputEvent,'space',pfunc,1,MUIM_PlaneFunc_SetSize])
  1551.     node.window:=window
  1552.     node.ln.name:=name
  1553.     node.ln.type:=PROJECTNODE_ID
  1554.     node.ln.pri:=0
  1555.     inlist:=String(40)
  1556.     node.item:=inlist
  1557.     get(pfunc,MUIA_PlaneFunc_ProjectID,{pid})
  1558.     node.pid:=pid
  1559.     AddTail(exec_list,node)
  1560.  
  1561.     set(window,MUIA_Window_ID,$12345678+pid) -> stupid but unique id for a project :-)
  1562.  
  1563.     set(pfunc,MUIA_PlaneFunc_ProjectNode,node)
  1564.  
  1565.     StringF(inlist,'\d :\s',lastid-1,name)
  1566.     doMethodA(obj,[MUIM_List_InsertSingle,inlist,MUIV_List_Insert_Bottom])
  1567.     set(window,MUIA_Window_Open,MUI_TRUE) -> Open the window when everything is finished
  1568.     set(obj,MUIA_List_Active,MUIV_List_Active_Bottom)
  1569.     doMethodA(obj,[MUIM_ProjectList_Memory]) -> Update memory display when opening a project
  1570. ENDPROC
  1571.  
  1572. PROC projectList_notify(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_notify)
  1573. DEF data:PTR TO projectList_data,gadid,z,gad,value,pid,node:PTR TO project_Node
  1574.     data:=INST_DATA(cl,obj)
  1575.     gad:=getcurrent(data,obj)
  1576.     value:=msg.value
  1577.     gadid:=msg.gadget
  1578.     SELECT gadid
  1579.     CASE MUIV_ProjectList_Notify_Name
  1580.         set(gad,MUIA_PlaneFunc_Name,value)
  1581.         get(gad,MUIA_PlaneFunc_State,{z})
  1582.         IF (z=MUIV_PlaneFunc_State_Drawing) OR (value=MUIV_PlaneFunc_State_Loading)
  1583.             z:=33
  1584.         ELSE
  1585.             z:=32
  1586.         ENDIF
  1587.         get(gad,MUIA_PlaneFunc_ProjectID,{pid})
  1588.         get(gad,MUIA_PlaneFunc_ProjectNode,{node})
  1589.         StringF(node.item,'\d\c:\s',pid,z,value)
  1590.         doMethodA(obj,[MUIM_List_Redraw,MUIV_List_Redraw_Active])
  1591.     CASE MUIV_ProjectList_Notify_Type
  1592.         SELECT value
  1593.         CASE 0
  1594.             set(gad,MUIA_PlaneFunc_Type,MUIV_PlaneFunc_Type_DTPic)
  1595.         CASE 1
  1596.             set(gad,MUIA_PlaneFunc_Type,MUIV_PlaneFunc_Type_Graph)
  1597.         ENDSELECT
  1598.     CASE MUIV_ProjectList_Notify_ImageFile
  1599.         set(gad,MUIA_PlaneFunc_ImageFile,value)
  1600.     CASE MUIV_ProjectList_Notify_LoadM
  1601.         SELECT value
  1602.         CASE 0
  1603.             set(gad,MUIA_PlaneFunc_LoadM,MUIV_PlaneFunc_LoadM_Scale)
  1604.         CASE 1
  1605.             set(gad,MUIA_PlaneFunc_LoadM,MUIV_PlaneFunc_LoadM_CutTile)
  1606.         CASE 2
  1607.             set(gad,MUIA_PlaneFunc_LoadM,MUIV_PlaneFunc_LoadM_ChangeSize)
  1608.         ENDSELECT
  1609.     CASE MUIV_ProjectList_Notify_Red
  1610.         set(gad,MUIA_PlaneFunc_Rstr,value)
  1611.     CASE MUIV_ProjectList_Notify_Green
  1612.         set(gad,MUIA_PlaneFunc_Gstr,value)
  1613.     CASE MUIV_ProjectList_Notify_Blue
  1614.         set(gad,MUIA_PlaneFunc_Bstr,value)
  1615. /*    CASE MUIV_ProjectList_Notify_CompileR
  1616.         set(gad,MUIA_PlaneFunc_CompileR,value)
  1617.     CASE MUIV_ProjectList_Notify_CompileG
  1618.         set(gad,MUIA_PlaneFunc_CompileG,value)
  1619.     CASE MUIV_ProjectList_Notify_CompileB
  1620.         set(gad,MUIA_PlaneFunc_CompileB,value)
  1621. */    CASE MUIV_ProjectList_Notify_OutputR
  1622.         set(gad,MUIA_PlaneFunc_OutputR,value)
  1623.     CASE MUIV_ProjectList_Notify_OutputG
  1624.         set(gad,MUIA_PlaneFunc_OutputG,value)
  1625.     CASE MUIV_ProjectList_Notify_OutputB
  1626.         set(gad,MUIA_PlaneFunc_OutputB,value)
  1627.     CASE MUIV_ProjectList_Notify_Width
  1628.         set(gad,MUIA_PlaneFunc_Width,Val(value))
  1629.     CASE MUIV_ProjectList_Notify_Height
  1630.         set(gad,MUIA_PlaneFunc_Height,Val(value))
  1631.     ENDSELECT
  1632. ENDPROC
  1633.  
  1634. PROC projectList_prefs(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_prefs) -> a future version may require semaphore, but not for now.
  1635. DEF worknode:PTR TO project_Node, nextnode,exec_list:PTR TO lh,data:PTR TO projectList_data,gad
  1636.     msg.var[]:=msg.value
  1637.  
  1638.     IF (msg.var={dithm}) -> In these cases we've got to update the drawhandle for all windows
  1639.  
  1640.         data:=INST_DATA(cl,obj)
  1641.         exec_list:=data.exec_list
  1642.         worknode:=exec_list.head  -> First node
  1643.         IF currid > -1
  1644.             set(state_txt,MUIA_Text_Contents,cat.msgs_DrawHandle.getstr())
  1645.             set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_Processing)
  1646.             set(state_gau,MUIA_Gauge_Current,0)
  1647.         ENDIF
  1648.         IF worknode
  1649.             WHILE nextnode:=worknode.ln.succ
  1650.                 gad:=getp(data,worknode.pid)
  1651.                 doMethodA(gad,[MUIM_PlaneFunc_DrawHandle])
  1652.                 worknode:=nextnode
  1653.             ENDWHILE
  1654.             obj:=getcurrent(data,obj);setlamp(obj)
  1655.         ENDIF
  1656.     ENDIF
  1657. ENDPROC
  1658.  
  1659. /*This method reads all attributes of the current class and writes the state of the gadgets
  1660. in the settings window*/
  1661. PROC projectList_refresh(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_refresh)
  1662. DEF data:PTR TO projectList_data,nm:PTR TO CHAR,gad,value,q[11]:STRING,pid,win
  1663. DEF exec_list:PTR TO lh,worknode:PTR TO project_Node, count=0,ogad
  1664.  
  1665.     IF quiet=TRUE THEN RETURN
  1666.     data:=INST_DATA(cl,obj)
  1667.     gad,win:=getcurrent(data,obj)
  1668.     IF gad=NIL
  1669.         set(sgroup,MUIA_Disabled,MUI_TRUE)
  1670.         currid:=-1
  1671.         RETURN
  1672.     ENDIF
  1673.     set(sgroup,MUIA_Disabled,FALSE)
  1674. /*Unimplemented features:*/
  1675.     set(size_rad,MUIA_Disabled,MUI_TRUE)
  1676. ->    set(savepic_btn,MUIA_Disabled,MUI_TRUE)
  1677.     get(gad,MUIA_PlaneFunc_ProjectID,{pid})
  1678.     IF pid <> currid /*was currid and will be pid*/
  1679.         IF currid > -1
  1680.             ogad:=getp(data,currid)
  1681.             doMethodA(ogad,[MUIM_PlaneFunc_SetTaskPri,rp])
  1682.         ENDIF
  1683.         doMethodA(gad,[MUIM_PlaneFunc_SetTaskPri,cp])
  1684.     ENDIF
  1685.  
  1686.     currid:=pid
  1687.     IF msg.ostate=FALSE
  1688.         doMethodA(gad,[MUIM_PlaneFunc_Lamps])
  1689.         StringF(q,'r(\d,x,y)=',pid)
  1690.         set(r_lbl,MUIA_Text_Contents,q)
  1691.         StringF(q,'g(\d,x,y)=',pid)
  1692.         set(g_lbl,MUIA_Text_Contents,q)
  1693.         StringF(q,'b(\d,x,y)=',pid)
  1694.         set(b_lbl,MUIA_Text_Contents,q)
  1695.         get(gad,MUIA_PlaneFunc_Name,{value})
  1696.         nnset(name_str,MUIA_String_Contents,value)   /*nnset to avoid triggering useless notification*/
  1697.         get(gad,MUIA_PlaneFunc_Type,{value})
  1698.         SELECT value
  1699.         CASE MUIV_PlaneFunc_Type_DTPic
  1700.             nnset(type_reg,MUIA_Group_ActivePage,0)
  1701.         CASE MUIV_PlaneFunc_Type_Graph
  1702.             nnset(type_reg,MUIA_Group_ActivePage,1)
  1703.         ENDSELECT
  1704.  
  1705.         get(gad,MUIA_PlaneFunc_LoadM,{value})  /* these are for image-projects*/
  1706.         SELECT value                           
  1707.         CASE MUIV_PlaneFunc_LoadM_Scale        /* but all settings are updated, so that */   
  1708.             nnset(size_rad,MUIA_Radio_Active,0)/* the user may change the selected page and*/
  1709.         CASE MUIV_PlaneFunc_LoadM_CutTile      /*see the current settings..*/                
  1710.             nnset(size_rad,MUIA_Radio_Active,1)
  1711.         CASE MUIV_PlaneFunc_LoadM_ChangeSize
  1712.             nnset(size_rad,MUIA_Radio_Active,2)
  1713.         ENDSELECT
  1714.         get(gad,MUIA_PlaneFunc_ImageFile,{value})
  1715.         nnset(path_str,MUIA_String_Contents,value)
  1716.  
  1717.         get(gad,MUIA_PlaneFunc_Rstr,{value})   /*these are for function-projects*/
  1718.         nnset(red_str,MUIA_String_Contents,value)
  1719.         get(gad,MUIA_PlaneFunc_Gstr,{value})
  1720.         nnset(green_str,MUIA_String_Contents,value)
  1721.         get(gad,MUIA_PlaneFunc_Bstr,{value})
  1722.         nnset(blue_str,MUIA_String_Contents,value)
  1723.         get(gad,MUIA_PlaneFunc_OutputR,{value})
  1724.         nnset(outr_cyc,MUIA_Cycle_Active,value)
  1725.         get(gad,MUIA_PlaneFunc_OutputG,{value})
  1726.         nnset(outg_cyc,MUIA_Cycle_Active,value)
  1727.         get(gad,MUIA_PlaneFunc_OutputB,{value})
  1728.         nnset(outb_cyc,MUIA_Cycle_Active,value)
  1729.         get(gad,MUIA_PlaneFunc_Width,{value})
  1730.         nnset(width_str,MUIA_String_Integer,value)
  1731.         get(gad,MUIA_PlaneFunc_Height,{value})
  1732.         nnset(height_str,MUIA_String_Integer,value)
  1733.         get(win,MUIA_Window_Open,{value})
  1734.         nnset(showme_cyc,MUIA_Cycle_Active,value)
  1735.     ENDIF
  1736.     IF (msg.ostate = FALSE) OR (msg.ostate-2=pid)
  1737.         setlamp(gad)
  1738.     ENDIF
  1739.     IF msg.ostate > 0
  1740.         pid:=msg.ostate-2
  1741.         gad:=getp(data,pid)
  1742.         get(gad,MUIA_PlaneFunc_Name,{nm})
  1743.         get(gad,MUIA_PlaneFunc_State,{value})
  1744.         IF (value=MUIV_PlaneFunc_State_Drawing) OR (value=MUIV_PlaneFunc_State_Loading)
  1745.             value:=33
  1746.         ELSE
  1747.             value:=32
  1748.         ENDIF
  1749.  
  1750.         exec_list:=data.exec_list
  1751.         worknode:=exec_list.head
  1752.         WHILE worknode.pid <> pid
  1753.             count++
  1754.             worknode:=worknode.ln.succ
  1755.         ENDWHILE
  1756.  
  1757.         StringF(worknode.item,'\d\c:\s',pid,value,nm)
  1758.         doMethodA(obj,[MUIM_List_Redraw,count])
  1759.     ENDIF
  1760. ENDPROC
  1761.  
  1762. PROC setlamp(gad:PTR TO object)
  1763. DEF value
  1764.     get(gad,MUIA_PlaneFunc_State,{value})
  1765.     SELECT value
  1766.     CASE MUIV_PlaneFunc_State_Idle
  1767.         set(state_txt,MUIA_Text_Contents,cat.msgs_Idle.getstr())
  1768.         set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_Off)
  1769.         set(state_gau,MUIA_Gauge_Current,0)
  1770.         set(draw_btn,MUIA_Text_Contents,cat.msgl_Render.getstr())
  1771.     CASE MUIV_PlaneFunc_State_Drawing
  1772.         set(state_txt,MUIA_Text_Contents,cat.msgs_Drawing.getstr())
  1773.         set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_Processing)
  1774.         get(gad,MUIA_PlaneFunc_Percent,{value})
  1775.         set(state_gau,MUIA_Gauge_Current,value)
  1776.         set(draw_btn,MUIA_Text_Contents,cat.msgl_Pause.getstr())
  1777.     CASE MUIV_PlaneFunc_State_Loading
  1778.         set(state_txt,MUIA_Text_Contents,cat.msgs_Loading.getstr())
  1779.         set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_LoadingData)
  1780.         get(gad,MUIA_PlaneFunc_Percent,{value})
  1781.         set(state_gau,MUIA_Gauge_Current,value)
  1782.         set(draw_btn,MUIA_Text_Contents,cat.msgl_Pause.getstr())
  1783.     CASE MUIV_PlaneFunc_State_Paused
  1784.         set(state_txt,MUIA_Text_Contents,cat.msgs_Paused.getstr())
  1785.         set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_Ok)
  1786.         get(gad,MUIA_PlaneFunc_Percent,{value})
  1787.         set(state_gau,MUIA_Gauge_Current,value)
  1788.         set(draw_btn,MUIA_Text_Contents,cat.msgl_Restart.getstr())
  1789.     CASE MUIV_PlaneFunc_State_Frozen
  1790.         set(state_txt,MUIA_Text_Contents,cat.msgs_Frozen.getstr())
  1791.         set(lamp_lmp,MUIA_Lamp_Color,MUIV_Lamp_Color_SendingData) -> That project is sending some data to  others ;-)
  1792.         set(state_gau,MUIA_Gauge_Current,0)
  1793.         set(draw_btn,MUIA_Text_Contents,cat.msgl_Render.getstr())
  1794.     ENDSELECT
  1795. ENDPROC
  1796.  
  1797. PROC useprefs()
  1798. /*Don't forget to update this once adding prefs :-)*/
  1799. #define prCount 8
  1800.  
  1801. DEF iff:PTR TO iffhandle,sp:storedproperty,prefs:PTR TO chunkSeeker,dt:PTR TO CHAR
  1802.  
  1803.     iff:=AllocIFF()
  1804.     iff.stream:=Open('ENV:picFX.prefs',NEWFILE)
  1805.     IF iff.stream = NIL THEN RETURN
  1806.     InitIFFasDOS(iff)
  1807.     OpenIFF(iff,IFFF_WRITE)
  1808.  
  1809.     PushChunk(iff,"PPRF",ID_FORM,prCount*4+12)
  1810.  
  1811.     PushChunk(iff,"PPRF","BODY",prCount*4)
  1812.  
  1813.     NEW dt[prCount*4]
  1814.     sp.data:=dt
  1815.     sp.size:=prCount*4
  1816.     NEW prefs.create(sp)
  1817.  
  1818.     prefs.write(mainpri_sld,MUIA_Slider_Level)
  1819.     prefs.write(renderpri_sld,MUIA_Slider_Level)
  1820.     prefs.write(currpri_sld,MUIA_Slider_Level)
  1821.     prefs.write(renderupdate_sld,MUIA_Slider_Level)
  1822.     prefs.write(close_cyc,MUIA_Cycle_Active)
  1823.     prefs.write(showmess_chk,MUIA_Selected)
  1824.     prefs.write(dither_cyc,MUIA_Cycle_Active)
  1825.     prefs.write(recompile_chk,MUIA_Selected)
  1826.  
  1827.     WriteChunkBytes(iff,prefs.data,prCount*4)
  1828.     PopChunk(iff)
  1829.     PopChunk(iff)
  1830.  
  1831.     CloseIFF(iff)
  1832.     Close(iff.stream)
  1833.     FreeIFF(iff)
  1834.  
  1835.     END dt
  1836. ENDPROC
  1837.  
  1838. PROC loadprefs() HANDLE
  1839. DEF iff:PTR TO iffhandle,sp:storedproperty,b:PTR TO LONG,prefs:PTR TO chunkSeeker,out
  1840. DEF context:PTR TO contextnode,k[5]:STRING
  1841. DEF p:PTR TO LONG
  1842.  
  1843.     iff:=AllocIFF()
  1844.     iff.stream:=Open('env:picFX.prefs',OLDFILE)
  1845.     IF iff.stream = NIL THEN Raise("OPEN")
  1846.     InitIFFasDOS(iff)
  1847.     OpenIFF(iff,IFFF_READ)
  1848.  
  1849.     LOOP
  1850.         out:=ParseIFF(iff,IFFPARSE_RAWSTEP)
  1851.         IF out * (out - IFFERR_EOC) THEN Raise("PARS") -> An eof is an error, too
  1852.         context:=CurrentChunk(iff)
  1853.         IF context
  1854.             IF (context.id="BODY") AND (context.type="PPRF") THEN
  1855.                 JUMP offloop
  1856.         ENDIF
  1857.     ENDLOOP
  1858. offloop:
  1859.     sp.size:=context.size
  1860.     sp.data:=NewR(context.size)
  1861.     p:=sp.data
  1862.     IF (out:=ReadChunkBytes(iff,sp.data,sp.size)) <> sp.size THEN Raise("PARS")
  1863.  
  1864.     /*IF sp = NIL THEN Raise("PARS")*/
  1865.  
  1866.     NEW prefs.create(sp)
  1867.  
  1868.     prefs.read(mainpri_sld,MUIA_Slider_Level)
  1869.     prefs.read(renderpri_sld,MUIA_Slider_Level)
  1870.     prefs.read(currpri_sld,MUIA_Slider_Level)
  1871.     prefs.read(renderupdate_sld,MUIA_Slider_Level)
  1872.     prefs.read(close_cyc,MUIA_Cycle_Active)
  1873.     prefs.read(showmess_chk,MUIA_Selected)
  1874.     prefs.read(dither_cyc,MUIA_Cycle_Active)
  1875.     prefs.read(recompile_chk,MUIA_Selected)
  1876. EXCEPT DO
  1877.     IF exception THEN WriteF('exception \s\n',IdtoStr(exception,k))
  1878.     IF iff
  1879.         IF iff.stream
  1880.             CloseIFF(iff)
  1881.             Close(iff.stream)
  1882.         ENDIF
  1883.         FreeIFF(iff)
  1884.     ENDIF
  1885.     Dispose(sp.data) -> I know it is not required, but it is maybe cleaner so? :-)
  1886. ENDPROC
  1887.  
  1888. PROC projectList_saveprefs(/*cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg*/)
  1889.     useprefs()
  1890.     Execute('Copy env:picFX.prefs TO envarc:',NIL,NIL)
  1891. ENDPROC
  1892.  
  1893. PROC projectList_setpri(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_setpri)
  1894. DEF data:PTR TO projectList_data,task,
  1895. gad
  1896. DEF worknode:PTR TO project_Node, nextnode,exec_list:PTR TO lh,list:PTR TO mlh,cs:PTR TO object,z
  1897.     data:=INST_DATA(cl,obj)
  1898.     task:=msg.task
  1899.     SELECT task
  1900.     CASE MUIV_ProjectList_SetPri_Main
  1901.         SetTaskPri(FindTask(0),msg.value)
  1902.     CASE MUIV_ProjectList_SetPri_Render
  1903.         rp:=msg.value
  1904.  
  1905.         exec_list:=data.exec_list
  1906.         worknode:=exec_list.head  -> First node
  1907.         IF worknode
  1908.             WHILE nextnode:=worknode.ln.succ
  1909.                 IF worknode.pid <> currid
  1910.                     get(worknode.window,MUIA_Window_RootObject,{z})
  1911.                     get(z,MUIA_Group_ChildList,{list})
  1912.                     cs:=list.head
  1913.                     gad:=NextObject({cs})
  1914.                     doMethodA(gad,[MUIM_PlaneFunc_SetTaskPri,rp])
  1915.                 ENDIF
  1916.                 worknode:=nextnode
  1917.             ENDWHILE
  1918.         ENDIF
  1919.  
  1920.     CASE MUIV_ProjectList_SetPri_Curr
  1921.         cp:=msg.value
  1922.         gad:=getcurrent(data,obj)
  1923.         IF gad
  1924.             doMethodA(gad,[MUIM_PlaneFunc_SetTaskPri,cp])
  1925.         ENDIF
  1926.     ENDSELECT
  1927. ENDPROC
  1928.  
  1929. PROC projectList_showme(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO args_showme)
  1930. DEF win,data:PTR TO projectList_data
  1931. DEF exec_list:PTR TO lh,active,worknode:PTR TO project_Node,z->,qe[30]:STRING
  1932.  
  1933.     data:=INST_DATA(cl,obj)
  1934.  
  1935.     exec_list:=data.exec_list
  1936.     get(obj,MUIA_List_Active,{active})
  1937.     /*get item number "active" of the exec_list (isn't any faster way to do it?)*/
  1938.     worknode:=exec_list.head
  1939.               /* I should add here a check that the bound of the list is never reached!*/
  1940.     IF active > 0
  1941.         FOR z:=1 TO active DO worknode:=worknode.ln.succ
  1942.     ENDIF -> now worknode is the node of the wanted project
  1943.     win:=worknode.window
  1944.     set(win,MUIA_Window_Open,msg.value)
  1945.     /*StringF(qe,'set(\d,MUIA_Window_Open,\d)',win,msg.value)
  1946.     message(active,qe)*/
  1947. ENDPROC
  1948.  
  1949. /***************************************************************
  1950. ** custom uSlider private subclass of Slider class            **
  1951. ****************************************************************
  1952. *                                                              *
  1953. *Simple sub-class of Slider, overriding MUIM_Numeric_Stringify *
  1954. *                                                              *
  1955. ***************************************************************/
  1956. PROC uslider_dispatcher(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_numeric_stringify)
  1957. DEF data:PTR TO uslider_data,methodid
  1958.     methodid:=msg.methodid
  1959.     SELECT methodid
  1960.     CASE OM_NEW;RETURN uslider_new(cl,obj,msg)
  1961.     CASE MUIM_Numeric_Stringify
  1962.         data:=INST_DATA(cl,obj)
  1963.         IF data.stringify=MUI_TRUE
  1964.             data.buffer:=String(10) -> Mysterious bug fixed like that :-( => leaving unused allocated memory on *each* call to this method (freed at program quit)
  1965.             IF msg.value = 0
  1966.                 StrCopy(data.buffer,cat.msgp_guNone.getstr())
  1967.             ELSEIF msg.value=1
  1968.                 StringF(data.buffer,'\d \s',msg.value,cat.msgp_Pixel.getstr())
  1969.             ELSE
  1970.                 StringF(data.buffer,'\d \s',msg.value,cat.msgp_Pixels.getstr())
  1971.             ENDIF
  1972.             RETURN data.buffer
  1973.         ENDIF
  1974.     CASE MUIM_uSlider_Bigger;RETURN uslider_bigger(obj,msg)
  1975.     CASE MUIM_uSlider_Smaller;RETURN uslider_smaller(obj,msg)
  1976.     CASE MUIM_Cleanup
  1977.         data:=INST_DATA(cl,obj)
  1978.         IF data.stringify THEN
  1979.             DisposeLink(data.buffer)
  1980.     ENDSELECT
  1981. ENDPROC doSuperMethodA(cl,obj,msg)
  1982.  
  1983. PROC uslider_new(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO opset)
  1984. DEF data:PTR TO uslider_data,
  1985.     tags:PTR TO tagitem,
  1986.     tag:PTR TO tagitem
  1987.  
  1988.     IF (obj:=doSuperMethodA(cl,obj,msg))=NIL THEN RETURN 0
  1989.  
  1990.     data:=INST_DATA(cl,obj)
  1991.     tags:=msg.attrlist
  1992.     WHILE tag:=NextTagItem({tags})
  1993.         IF (tag.tag=MUIA_uSlider_Stringify) AND (tag.data=MUI_TRUE)
  1994.             data.stringify:=tag.data
  1995.             data.buffer:=String(10)
  1996.         ENDIF
  1997.     ENDWHILE
  1998. ENDPROC obj
  1999.  
  2000. PROC uslider_bigger(obj:PTR TO object,msg:PTR TO args_compare)
  2001. DEF level
  2002.     get(obj,MUIA_Slider_Level,{level})
  2003.     IF level < msg.than THEN
  2004.         nnset(obj,MUIA_Slider_Level,msg.than)
  2005. ENDPROC
  2006.  
  2007. PROC uslider_smaller(obj:PTR TO object,msg:PTR TO args_compare)
  2008. DEF level
  2009.     get(obj,MUIA_Slider_Level,{level})
  2010.     IF level > msg.than THEN
  2011.         nnset(obj,MUIA_Slider_Level,msg.than)
  2012. ENDPROC
  2013.  
  2014. /***************************************************************
  2015. ** sizetxt class                                              **
  2016. ****************************************************************
  2017. *  textobject containing the size of the last loaded picture.  *
  2018. ***************************************************************/
  2019.  
  2020. OBJECT sizetxt_data
  2021.     buffer:PTR TO CHAR
  2022. ENDOBJECT
  2023.  
  2024. CONST MUIM_SizeTxt_Update=$FCB93800
  2025.  
  2026. OBJECT muip_stupd
  2027.     methodid
  2028.     width,height,depth
  2029.     projectid
  2030. ENDOBJECT
  2031.  
  2032. PROC sizetxt_dispatcher(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  2033. DEF methodid
  2034.     methodid:=msg.methodid
  2035.     SELECT methodid
  2036.     CASE OM_NEW;RETURN sizetxt_new(cl,obj,msg)
  2037.     CASE OM_DISPOSE;RETURN sizetxt_dispose(cl,obj,msg)
  2038.     CASE MUIM_SizeTxt_Update;RETURN sizetxt_update(cl,obj,msg)
  2039.     ENDSELECT
  2040. ENDPROC doSuperMethodA(cl,obj,msg)
  2041.  
  2042. PROC sizetxt_new(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  2043. DEF data:PTR TO sizetxt_data
  2044.     obj:=doSuperMethodA(cl,obj,msg)
  2045.     data:=INST_DATA(cl,obj)
  2046.     data.buffer:=String(50)
  2047. ENDPROC obj
  2048.  
  2049. PROC sizetxt_dispose(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO msg)
  2050. DEF data:PTR TO sizetxt_data
  2051.     data:=INST_DATA(cl,obj)
  2052.     DisposeLink(data.buffer)
  2053. ENDPROC doSuperMethodA(cl,obj,msg)
  2054.  
  2055. PROC sizetxt_update(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_stupd)
  2056. DEF data:PTR TO sizetxt_data
  2057.     data:=INST_DATA(cl,obj)
  2058.     IF msg.projectid = currid
  2059.         StringF(data.buffer,'\s\d×\d×\d',cat.msgl_PicSize.getstr(),msg.width,msg.height,msg.depth)
  2060.         set(obj,MUIA_Text_Contents,data.buffer)
  2061.     ENDIF
  2062. ENDPROC
  2063.  
  2064. PROC myapp_dispatcher(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_application_returnid)
  2065.     IF msg.methodid=MUIM_Application_ReturnID
  2066.         IF msg.retid=MUIV_Application_ReturnID_Quit THEN /*separate IFs to avoid illegal memory access, if the message hasn't any argument*/
  2067.             doMethodA(opened_lst,[MUIM_ProjectList_Exit]) -> This will cause the Exit method to be executed right before
  2068.     ENDIF                                           -> ReturnId (when called with Exit returnid)
  2069. ENDPROC doSuperMethodA(cl,obj,msg)
  2070.  
  2071. PROC sendsubtaskmsg(st:PTR TO subtask,command,params)
  2072.     IF st.st_Port=NIL THEN RETURN
  2073.     st.st_Message.stm_Message.replyport:= st.st_Reply
  2074.     st.st_Message.stm_Message.length   := SIZEOF subtaskmsg
  2075.     st.st_Message.stm_Command          := command
  2076.     st.st_Message.stm_Parameter        := params
  2077.     st.st_Message.stm_Result           := 0
  2078.     PutMsg(IF command=STC_STARTUP THEN st.st_Task::process.msgport ELSE st.st_Port,st.st_Message)
  2079.     WaitPort(st.st_Reply)          /*gets the reply*/
  2080.     GetMsg(st.st_Reply)
  2081. ENDPROC (st.st_Message.stm_Result)
  2082.  
  2083. PROC killsubtask(data:PTR TO planeFunc_data)
  2084.     IF data.type = MUIV_PlaneFunc_Type_Graph THEN
  2085.         sendsubtaskmsg(data.subtask,STC_SHUTDOWN,data.subtask)
  2086.     wait_one_fork()
  2087.     IF data.type = MUIV_PlaneFunc_Type_Graph
  2088.         free(data.rfunc)
  2089.         free(data.gfunc)
  2090.         free(data.bfunc)                    
  2091.         IF data.subtask.st_Reply THEN
  2092.             DeleteMsgPort(data.subtask.st_Reply)
  2093.     ENDIF
  2094.     FreeVec(data.subtask);data.subtask:=NIL
  2095. ENDPROC
  2096.  
  2097. /***************************************************************
  2098. **    Subtask which does all the time-consuming rendering     **
  2099. ***************************************************************/
  2100.  
  2101. PROC renderfunc(data:PTR TO planeFunc_data)
  2102. DEF st=NIL:PTR TO subtask,
  2103.     worktodo=TRUE,x,y,
  2104.     stm=NIL:PTR TO subtaskmsg,
  2105.     command,i,
  2106.     red,green,blue,lr:PTR TO longreal,cnt,oldpixel,oldid:PTR TO LONG,
  2107.     rf,gf,bf,rc,gc,bc
  2108.  
  2109.     st:=data.subtask
  2110.  
  2111.     ObtainSemaphore(data.sema)
  2112. /*                    data.drawn:=-1
  2113.                     data.calculated:=-1
  2114. */
  2115.     DateStamp(data.ds)
  2116.     oldid:=data.imagedata
  2117.     data.imagedata:=AllocMem(data.width*data.height*4,MEMF_PUBLIC OR MEMF_CLEAR);data.vec:=TRUE
  2118.  
  2119.     ReleaseSemaphore(data.sema)
  2120.  
  2121.     y:=0->;cnt:=data.rupd
  2122.     i:=0
  2123.     NEW lr
  2124.     rf:=data.rfunc.calculate
  2125.     gf:=data.gfunc.calculate
  2126.     bf:=data.bfunc.calculate
  2127.     rc:=data.rfunc.precalc
  2128.     gc:=data.gfunc.precalc
  2129.     bc:=data.bfunc.precalc
  2130.  
  2131.  
  2132.     ->IF (st:= initsubtask())
  2133.         LOOP
  2134.             WHILE (stm:= GetMsg(st.st_Port))
  2135.                 command:=stm.stm_Command
  2136.                 SELECT command
  2137.                 CASE STC_SHUTDOWN
  2138.                     JUMP exit
  2139.                 CASE STC_PAUSE
  2140.                     worktodo:= FALSE
  2141.                 CASE STC_RESTART -> Deactivate pause
  2142.                     worktodo:=TRUE
  2143.                 ENDSELECT
  2144.                 ReplyMsg(stm.stm_Message)
  2145.             ENDWHILE
  2146.  
  2147.             IF (worktodo)
  2148.                 /* if there is work to do, i.e. if the rendering is not
  2149.                    finished yet, we calculate the next line and draw
  2150.                    it to the offscreen rastport.*/
  2151.  
  2152.                 IF data.outputr=OUT_Integer      /*red*/
  2153.                     rc(x,y)
  2154.                 ELSEIF data.outputr=OUT_Float32
  2155.                     rc(x!,y!)
  2156.                 ENDIF
  2157.                 IF data.outputg=OUT_Integer      /*green*/
  2158.                     gc(x,y)
  2159.                 ELSEIF data.outputg=OUT_Float32
  2160.                     gc(x!,y!)
  2161.                 ENDIF
  2162.                 IF data.outputb=OUT_Integer      /*blue*/
  2163.                     bc(x,y)
  2164.                 ELSEIF data.outputb=OUT_Float32
  2165.                     bc(x!,y!)
  2166.                 ENDIF
  2167.  
  2168.                 ObtainSemaphore(data.sema)
  2169.  
  2170.                 IF data.savepixel THEN
  2171.                     oldpixel:=oldid[i] ->pixel(oldid,data.width,0,y)
  2172.  
  2173.                 FOR x:=0 TO data.width-1
  2174.                     IF data.outputr=OUT_Integer      /*red*/
  2175.  
  2176.                         red:=rf(x,y)
  2177.                         red:=modt(red)
  2178.                         red:=Shl(red,16)
  2179.                     ELSEIF data.outputr=OUT_Float32
  2180.                         red:=!rf(x!,y!)!
  2181.                         red:=modt(red)
  2182.                         red:=Shl(red,16)
  2183.                     /*ELSEIF data.outputr=OUT_Float64
  2184.                         rproc(x,y,lr,data.rfunc)
  2185.                         red:=dFix(lr)
  2186.                         red:=modt(red)
  2187.                         red:=Shl(red,16)*/
  2188.                     ELSEIF data.outputr=OUT_OldR
  2189.                         red:=oldpixel AND $FF0000
  2190.                     ELSEIF data.outputr=OUT_OldG
  2191.                         red:=Shl(oldpixel AND $FF00,8)
  2192.                     ELSE /*IF data.outputr=OUT_OldB*/
  2193.                         red:=Shl(oldpixel AND $FF,16)
  2194.                     ENDIF
  2195.                     IF data.outputg=OUT_Integer      /*green*/
  2196.                         green:=gf(x,y)
  2197.                         green:=modt(green)
  2198.                         green:=Shl(green,8)
  2199.                     ELSEIF data.outputg=OUT_Float32
  2200.                         green:=!gf(x!,y!)!
  2201.                         green:=modt(green)
  2202.                         green:=Shl(green,8)
  2203.                     /*ELSEIF data.outputg=OUT_Float64
  2204.                         gproc(x,y,lr,data.gfunc)
  2205.                         green:=dFix(lr)
  2206.                         green:=modt(green)
  2207.                         green:=Shl(green,8)*/
  2208.                     ELSEIF data.outputg=OUT_OldR
  2209.                         green:=oldpixel AND $FF0000
  2210.                         green:=Shr(green,8)
  2211.                     ELSEIF data.outputg=OUT_OldG
  2212.                         green:=oldpixel AND $FF00
  2213.                     ELSEIF data.outputg=OUT_OldB
  2214.                         green:=oldpixel AND $FF
  2215.                         green:=Shl(green,8)
  2216.                     ELSE /*IF data.outputr=OUT_CopyR*/
  2217.                         green:=Shr(red,8)
  2218.                     ENDIF
  2219.                     IF data.outputb=OUT_Integer      /*blue*/
  2220.                         blue:=bf(x,y)
  2221.                         blue:=modt(blue)
  2222.                     ELSEIF data.outputb=OUT_Float32
  2223.                         blue:=!bf(x!,y!)!
  2224.                         blue:=modt(blue)
  2225.                     /*ELSEIF data.outputb=OUT_Float64
  2226.                         bproc(x,y,lr,data.bfunc)
  2227.                         blue:=dFix(lr)
  2228.                         blue:=modt(blue)*/
  2229.                     ELSEIF data.outputb=OUT_OldR
  2230.                         blue:=Shr(oldpixel,16)
  2231.                     ELSEIF data.outputb=OUT_OldG
  2232.                         blue:=Shr(oldpixel,8) AND $FF
  2233.                         blue:=blue AND $FF
  2234.                     ELSEIF data.outputb=OUT_OldB
  2235.                         blue:=oldpixel AND $FF
  2236.                     ELSEIF data.outputb=OUT_CopyR
  2237.                         blue:=Shr(red,16)
  2238.                     ELSE /*IF data.outputb=OUT_CopyG*/
  2239.                         blue:=Shr(green,8)
  2240.                     ENDIF
  2241.                     data.imagedata[i]:=red+green+blue
  2242.                     i++
  2243.                     IF data.savepixel THEN
  2244.                         oldpixel:=oldid[i] ->pixel(data.imagedata,data.width,x+1,y)
  2245.                 ENDFOR
  2246.                 ReleaseSemaphore(data.sema)
  2247.                 y++
  2248.  
  2249.                 IF (y AND $F=0)
  2250.                     IF data.app
  2251.                         data.calculated:=y
  2252.                         doMethodA(app,[MUIM_Application_PushMethod,data.self,1,MUIM_PlaneFunc_Update])
  2253.                     ENDIF
  2254.                 ENDIF
  2255.  
  2256.                 IF (y=data.height)
  2257.                     /* check if we are finished to draw our picture */
  2258.                      worktodo:= FALSE
  2259.                     /*if we're finished, we ask the main task to exit ourselves..*/
  2260.                     IF data.picture THEN DeletePicture(data.picture)
  2261.                     data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  2262.                     doMethodA(app,[MUIM_Application_PushMethod,data.self,2,MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Finish])
  2263.                 ENDIF
  2264.                 /* Since we are very busy working, we do not Wait() for signals. */
  2265.             ELSE
  2266.                 /* We have nothing to do, just sit quietly and wait for something to happen */
  2267.                 WaitPort(st.st_Port)
  2268.             ENDIF
  2269.         ENDLOOP
  2270. exit:
  2271.     END lr
  2272.     IF data.subtask.st_Port
  2273.         DeleteMsgPort(data.subtask.st_Port);data.subtask.st_Port:=NIL
  2274.         data.subtask.st_Port:=NIL
  2275.     ENDIF
  2276.    -> ENDIF
  2277. ReplyMsg(stm.stm_Message)
  2278.  
  2279. ENDPROC
  2280.  
  2281. PROC loadpicture(data:PTR TO planeFunc_data)
  2282. DEF w,h
  2283. DEF st=NIL:PTR TO subtask,
  2284.     x,y,
  2285.     stm=NIL:PTR TO subtaskmsg,
  2286.     command,i,
  2287.     cnt=0,init=2
  2288.  
  2289.     /*IF AttemptSemaphore(data.sema)
  2290.         WriteF('Went all right..\n')
  2291.     ELSE
  2292.         WriteF('The semaphore is locked!!!\n')
  2293.     ENDIF
  2294.     */
  2295.     ObtainSemaphore(data.sema)
  2296.     DateStamp(data.ds)
  2297.     IF data.picture
  2298.         DeletePicture(data.picture)
  2299.     ENDIF
  2300.     data.picture:=LoadPictureA(data.imagefile,[TAG_DONE])
  2301.     IF data.picture = NIL  ->And if data.app=NIL ? :-)
  2302.         data.imagedata:=AllocMem(data.width*data.height*4,MEMF_CLEAR OR MEMF_PUBLIC);data.vec:=TRUE
  2303.         data.picture:=MakePictureA(data.imagedata,data.width,data.height,[GGFX_PixelFormat,PIXFMT_0RGB_32,TAG_DONE])
  2304.         ReleaseSemaphore(data.sema)
  2305.         doMethodA(app,[MUIM_Application_PushMethod,data.self,2,MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_NoLoad])
  2306.     ELSE
  2307.         GetPictureAttrsA(data.picture,[PICATTR_PixelFormat,{x},TAG_DONE])
  2308.         IF x <> PIXFMT_0RGB_32 THEN
  2309.             DoPictureMethodA(data.picture,PICMTHD_RENDER,[PIXFMT_0RGB_32,TAG_DONE])
  2310.  
  2311.         IF TRUE ->data.loadm=MUIV_PlaneFunc_LoadM_ChangeSize
  2312.             GetPictureAttrsA(data.picture,[PICATTR_Width,{w},PICATTR_Height,{h},PICATTR_RawData,{x},TAG_DONE])
  2313.             data.imagedata:=x;data.vec:=FALSE
  2314.             doMethodA(app,[MUIM_Application_PushMethod,data.self,3,
  2315.                 MUIM_Set,MUIA_PlaneFunc_Quiet,-2])
  2316.             doMethodA(app,[MUIM_Application_PushMethod,data.self,3,
  2317.                 MUIM_Set,MUIA_PlaneFunc_Width,w])
  2318.             doMethodA(app,[MUIM_Application_PushMethod,data.self,3,
  2319.                 MUIM_Set,MUIA_PlaneFunc_Height,h])
  2320.             doMethodA(app,[MUIM_Application_PushMethod,data.self,3,
  2321.                 MUIM_Set,MUIA_PlaneFunc_Quiet,FALSE])
  2322.         ELSE -> MUIV_PlaneFunc_LoadM_Scale
  2323.             DoPictureMethodA(data.picture,PICMTHD_SCALE,[data.width,data.height,TAG_DONE])
  2324.         ENDIF
  2325.         ReleaseSemaphore(data.sema)
  2326.     -> No need to send an update message, as the quiet attribute-change did it for us.
  2327.         doMethodA(app,[MUIM_Application_PushMethod,data.self,2,MUIM_PlaneFunc_Abort,MUIV_PlaneFunc_Abort_Finish])
  2328.     ENDIF
  2329.     Delay(10)
  2330. ENDPROC
  2331. /********************************
  2332. *   Inter-referencing...        *
  2333. ********************************/
  2334.  
  2335. /*freeze(expression): this will read-lock all used functions.
  2336. returns true if success, or false if failure*/
  2337.  
  2338. PROC freeze(f:PTR TO expression)
  2339. DEF a:PTR TO planeFunc_data,b,c,data:PTR TO projectList_data,obj,lock
  2340. DEF exec_list:PTR TO lh,worknode:PTR TO project_Node
  2341.     IF f.precision > OUT_Float64 THEN RETURN TRUE
  2342.     data:=INST_DATA(cl_projectlist.mcc_class,opened_lst)
  2343.  
  2344.     a,b,c:=f.reference()
  2345.     IF a > 3 -> direct reference to project "a" (a is the data of the object)
  2346.             /* + sub-functions "b" and "c"*/
  2347.         /*checks that a exists, searching it in the projects list*/
  2348.         data:=INST_DATA(cl_projectlist.mcc_class,opened_lst)
  2349.         exec_list:=data.exec_list
  2350.         worknode:=exec_list.head
  2351.         WHILE wcomp(worknode,a)
  2352.             worknode:=worknode.ln.succ
  2353.         ENDWHILE
  2354.         IF worknode.ln.succ = 0 -> a doesn't exist
  2355.             RETURN FALSE
  2356.         ENDIF
  2357.         obj:=a.self
  2358.         get(obj,MUIA_PlaneFunc_Lock,{lock})
  2359.         IF lock = MUIV_PlaneFunc_Lock_Write THEN RETURN FALSE
  2360.         set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_Read)
  2361.         IF freeze(b) = 0
  2362.             set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoRead)
  2363.             RETURN FALSE
  2364.         ENDIF
  2365.         IF freeze(c) = 0
  2366.             free(b) -> IF "c" can't be frozen, let's free "b" before returning
  2367.             set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoRead)
  2368.             RETURN FALSE
  2369.         ENDIF
  2370.         RETURN TRUE
  2371.     ENDIF
  2372.  
  2373.     SELECT a
  2374.     CASE 2 -> One sub-function : "b"
  2375.         IF freeze(b) = 0 THEN RETURN FALSE
  2376.     CASE 3 -> Two sub functions : "b" and "c"
  2377.         IF freeze(b) = 0 THEN RETURN FALSE
  2378.         IF freeze(c) = 0
  2379.             free(b) -> IF "c" can't be frozen, let's free "b" before returning
  2380.             RETURN FALSE
  2381.         ENDIF
  2382.     ENDSELECT
  2383. ENDPROC TRUE
  2384.  
  2385. PROC wcomp(node:PTR TO project_Node,data)
  2386.     IF node.ln.succ = 0 THEN RETURN FALSE
  2387. ENDPROC (wdata(node.window) <> data)
  2388.  
  2389. PROC wdata(window)
  2390. DEF gad,list:PTR TO mlh,cs:PTR TO object
  2391.     get(window,MUIA_Window_RootObject,{gad})
  2392.     get(gad,MUIA_Group_ChildList,{list})
  2393.     cs:=list.head
  2394. ENDPROC INST_DATA(cl_planefunc.mcc_class,NextObject({cs}))
  2395.  
  2396. /*free(expression): This un read-locks all used functions.
  2397. It assumes that freeze(function) has been executed before and that
  2398. function did not change since*/
  2399.  
  2400. PROC free(f:PTR TO expression)
  2401. DEF a:PTR TO planeFunc_data,b,c,data:PTR TO projectList_data,obj
  2402.  
  2403.     data:=INST_DATA(cl_projectlist.mcc_class,opened_lst)
  2404.  
  2405.     IF f.precision > OUT_Float64 THEN RETURN TRUE
  2406.  
  2407.     a,b,c:=f.reference()
  2408.     IF a > 3
  2409.         obj:=a.self
  2410.         set(obj,MUIA_PlaneFunc_Lock,MUIV_PlaneFunc_Lock_NoRead)
  2411.         a:=3 -> This will cause a problem if a function f(c,x), where c is a project, ever comes.
  2412.     ENDIF
  2413.     SELECT a
  2414.     CASE 2 -> One sub-expression : "b"
  2415.         free(b)
  2416.     CASE 3 -> Two sub-expressions : "b" and "c"
  2417.         free(b)
  2418.         free(c)
  2419.     ENDSELECT
  2420. ENDPROC
  2421.  
  2422. /***************************************************************
  2423. **                       main program                         **
  2424. ****************************************************************
  2425.  Opens the libraries, creates the user interface structure and
  2426. notifications. The input loop just waits for MUI to say to quit.
  2427. ***************************************************************/
  2428.  
  2429. PROC main() HANDLE
  2430. DEF l
  2431.     IF (localebase:=OpenLibrary('locale.library',0)) = NIL THEN
  2432.         Raise('locale.library')
  2433.     NEW cat.create()
  2434.     cat.open()
  2435.  
  2436.     IF (aslbase:=OpenLibrary('asl.library',37))=NIL THEN
  2437.         Raise('asl.library')
  2438.     IF (datatypesbase:=OpenLibrary('datatypes.library',0))=NIL THEN
  2439.         Raise('datatypes.library')
  2440.     IF (guigfxbase:=OpenLibrary('guigfx.library',10))=NIL THEN
  2441.         Raise('guiGFX.library')
  2442.     IF (iffparsebase:=OpenLibrary('iffparse.library',0))=NIL THEN
  2443.         Raise('iffparse.library')
  2444.     IF (muimasterbase:=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)) = NIL THEN
  2445.         Raise('muimaster.library')
  2446.     IF (utilitybase:=OpenLibrary('utility.library',36))=NIL THEN
  2447.         Raise('utility.library') /*for tag-list parsing*/
  2448.  
  2449.     funcdir:=String(19)
  2450.     StrCopy(funcdir,'progdir:functions/')
  2451.     picdir:=String(18)
  2452.     StrCopy(picdir,'progdir:pictures/')
  2453.  
  2454.     init_fork([FORK_NAME,'picFX-Render Task',TAG_DONE])
  2455.  
  2456.     dInit(TRUE)
  2457.     cl_planefunc:=eMui_CreateCustomClass(NIL,MUIC_Area ,NIL,SIZEOF planeFunc_data,{planeFunc_dispatcher})
  2458.     cl_projectlist:=eMui_CreateCustomClass(NIL,MUIC_List,NIL,SIZEOF projectList_data,{projectList_dispatcher})
  2459.     cl_uslider:=eMui_CreateCustomClass(NIL,MUIC_Slider,NIL,SIZEOF uslider_data,{uslider_dispatcher})
  2460.     cl_sizetxt:=eMui_CreateCustomClass(NIL,MUIC_Text,NIL,SIZEOF sizetxt_data,{sizetxt_dispatcher})
  2461.     cl_myapp:=eMui_CreateCustomClass(NIL,MUIC_Application,NIL,SIZEOF empty_data,{myapp_dispatcher})
  2462.     ftype_registertitles:=[cat.msgl_type_Image.getstr(),cat.msgl_type_Function.getstr(),NIL]
  2463.     size_radiolabels:=[cat.msgl_lm_Scale.getstr(),cat.msgl_lm_CutTile.getstr(),cat.msgl_lm_Change.getstr(),NIL]
  2464.     showme_cyclelabels:=[cat.msgl_Hidden.getstr(),cat.msgl_Shown.getstr(),NIL]
  2465.     ccc() -> VarList
  2466.  
  2467.     FOR app:=0 TO 14 -> app: I did not want to create a var just for that loop :-)
  2468.         messages[app]:=String(100)
  2469.     ENDFOR
  2470.     app:=MyApplicationObject,
  2471.         MUIA_Application_Title, 'picFX',
  2472.         MUIA_Application_Version,FULLVERSION,
  2473.         MUIA_Application_Author, 'Maxime Gamboni',
  2474.         MUIA_Application_Description, cat.msg_Description.getstr(),
  2475.         MUIA_Application_Base,'picFX',
  2476.  
  2477.         SubWindow,varlist_win:=WindowObject, -> This window must come before the project_list creation for initfuncs()
  2478.             MUIA_Window_Title,cat.msgl_VarListWin.getstr(),
  2479.             MUIA_Window_ID,"VARS",
  2480.             WindowContents,VGroup,
  2481.                 Child, varlist_lsv:=ListviewObject,
  2482.                     InputListFrame,
  2483.                     MUIA_Listview_List,varlist_lst:=VarListObject,End,
  2484.                 End,
  2485.                 Child, HGroup,
  2486.                     Child, varname_str:=StringObject,
  2487.                         StringFrame,
  2488.                         MUIA_Disabled,MUI_TRUE,
  2489.                         MUIA_String_AttachedList,varlist_lsv,
  2490.                         MUIA_CycleChain,MUI_TRUE,
  2491.                     End,
  2492.                     Child, TextObject,
  2493.                         MUIA_Text_Contents,'\ec=',
  2494.                     End,
  2495.                     Child, varval_str:=StringObject,
  2496.                         StringFrame,
  2497.                         MUIA_Disabled,MUI_TRUE,
  2498.                         MUIA_String_AttachedList,varlist_lsv,
  2499.                         MUIA_CycleChain,MUI_TRUE,
  2500.                     End,
  2501.                 End,
  2502.                 Child, HGroup,
  2503.                     Child, varadd_btn:=SimpleButton(cat.msgl_Add.getstr()),
  2504.                     Child, vardel_btn:=SimpleButton(cat.msgl_Del.getstr()),
  2505.                 End,
  2506.             End,
  2507.         End,
  2508.  
  2509.         SubWindow, settings_win:=WindowObject,
  2510.             MUIA_Window_Title, cat.msgl_Title.getstr(),
  2511.             MUIA_Window_ScreenTitle, PICVERSION,
  2512.             MUIA_Window_ID,"SETT",
  2513.             WindowContents,HGroup,
  2514.                 Child, VGroup,
  2515.                     MUIA_Weight,30,
  2516.                     Child, TextObject,
  2517.                         NoFrame,
  2518.                         MUIA_Text_PreParse,'\ec',
  2519.                         MUIA_Text_Contents,cat.msgl_OpenedProjects.getstr(),
  2520.                     End,
  2521.                     Child, opened_lsv:=ListviewObject,
  2522.                         InputListFrame,
  2523.                         MUIA_Listview_List,opened_lst:=ProjectListObject,End,
  2524.                     End,
  2525.                     Child, new_btn:=SimpleButton(cat.msgl_New.getstr()),
  2526.                     Child, var_btn:=TextObject,
  2527.                         ButtonFrame,
  2528.                         MUIA_Background,MUII_ButtonBack,
  2529.                         MUIA_Text_PreParse,'\ec',
  2530.                         MUIA_Text_Contents,cat.msgl_VarList.getstr(),
  2531.                         MUIA_InputMode,MUIV_InputMode_Toggle,
  2532.                     End,
  2533.                     Child, RectangleObject,MUIA_Rectangle_HBar,MUI_TRUE,MUIA_Weight,0,End,
  2534.                     Child, prefs_btn:=TextObject,
  2535.                         ButtonFrame,
  2536.                         MUIA_Background,MUII_ButtonBack,
  2537.                         MUIA_Text_PreParse,'\ec',
  2538.                         MUIA_Text_Contents,cat.msgl_Prefs.getstr(),
  2539.                         MUIA_InputMode,MUIV_InputMode_RelVerify,
  2540.                     End,
  2541.                 End,
  2542.                 Child, RectangleObject,MUIA_Rectangle_VBar,MUI_TRUE,MUIA_Weight,0,End,
  2543.                 Child, sgroup:=VGroup,
  2544.                     MUIA_Disabled,MUI_TRUE, -> No projects are opened at beginning
  2545.                     Child,name_str:= StringObject,MUIA_String_Contents,cat.msg_Unnamed.getstr(),StringFrame,End,
  2546.                     Child, type_reg:=RegisterGroup(ftype_registertitles),
  2547.                         Child, VGroup,
  2548.                             Child, HGroup,
  2549.                                 Child, FreeLabel(cat.msgl_Path.getstr()),
  2550.                                 Child, PopaslObject,
  2551.                                     MUIA_Popstring_Button,PopButton(MUII_PopFile),
  2552.                                     MUIA_Popasl_Type,ASL_FILEREQUEST,
  2553.                                     MUIA_Popstring_String,path_str:=StringObject,
  2554.                                         StringFrame,
  2555.                                         MUIA_String_Contents,cat.msg_Unnamed.getstr(),
  2556.                                     End,
  2557.                                 End,
  2558.                             End,
  2559.                             Child, HGroup,
  2560.                                 Child, size_rad:=RadioObject,
  2561.                                     GroupFrameT(cat.msgl_Size.getstr()),
  2562.                                     MUIA_Radio_Entries,size_radiolabels,
  2563.                                     MUIA_Radio_Active,1,
  2564.                                 End,
  2565.                                 Child, VGroup,
  2566.                                     Child, RectangleObject,End,
  2567.                                     Child, size_txt:=SizeTextObject,
  2568.                                         TextFrame,
  2569.                                         MUIA_Text_PreParse,'\ec',
  2570.                                         MUIA_Text_Contents,cat.msgl_PicSize.getstr(),
  2571.                                     End,
  2572.                                     Child, RectangleObject,End,
  2573.                                 End,
  2574.                             End,
  2575.                         End,
  2576.                         Child, VGroup,
  2577.                             Child, HGroup,
  2578.                                 Child,red_fail:=LampObject,
  2579.                                     MUIA_Lamp_Type,MUIV_Lamp_Type_Big,
  2580.                                     MUIA_Lamp_ColorType,MUIV_Lamp_ColorType_UserDefined,
  2581.                                     MUIA_Lamp_Color,MUIV_Lamp_Color_Ok,
  2582.                                 End,
  2583.                                 Child, r_lbl:=label('r(#,x,y)='),
  2584.                                 Child, red_str:=StringObject,
  2585.                                     StringFrame,
  2586.                                 End,
  2587.                             End,
  2588.                             Child, HGroup,
  2589.                                 Child, Label(cat.msgl_Output.getstr()),
  2590.                                 Child, outr_cyc:=CycleObject,
  2591.                                     MUIA_Cycle_Entries,[cat.msgl_Int32.getstr(),cat.msgl_Float32.getstr(),cat.msgl_Float64.getstr(),
  2592.                                                         cat.msgl_OldR.getstr(),cat.msgl_OldG.getstr(),cat.msgl_OldB.getstr(),NIL],
  2593.                                     MUIA_Cycle_Active,3,
  2594.                                 End,
  2595.                                 Child, RectangleObject,End,
  2596.                             End,
  2597.  
  2598.                             Child, HGroup,
  2599.                                 Child,green_fail:=LampObject,
  2600.                                     MUIA_Lamp_Type,MUIV_Lamp_Type_Big,
  2601.                                     MUIA_Lamp_ColorType,MUIV_Lamp_ColorType_UserDefined,
  2602.                                     MUIA_Lamp_Color,MUIV_Lamp_Color_Ok,
  2603.                                 End,
  2604.                                 Child, g_lbl:=label('g(#,x,y)='),
  2605.                                 Child, green_str:=StringObject,
  2606.                                     StringFrame,
  2607.                                 End,
  2608.                             End,
  2609.                             Child, HGroup,
  2610.                                 Child, Label(cat.msgl_Output.getstr()),
  2611.                                 Child, outg_cyc:=CycleObject,
  2612.                                     MUIA_Cycle_Entries,[cat.msgl_Int32.getstr(),cat.msgl_Float32.getstr(),cat.msgl_Float64.getstr(),
  2613.                                                         cat.msgl_OldR.getstr(),cat.msgl_OldG.getstr(),cat.msgl_OldB.getstr(),
  2614.                                                         cat.msgl_CopyR.getstr(),NIL],
  2615.                                     MUIA_Cycle_Active,3,
  2616.                                 End,
  2617.                                 Child, RectangleObject,End,
  2618.                             End,
  2619.  
  2620.                             Child, HGroup,
  2621.                                 Child,blue_fail:=LampObject,
  2622.                                     MUIA_Lamp_Type,MUIV_Lamp_Type_Big,
  2623.                                     MUIA_Lamp_ColorType,MUIV_Lamp_ColorType_UserDefined,
  2624.                                     MUIA_Lamp_Color,MUIV_Lamp_Color_Ok,
  2625.                                 End,
  2626.                                 Child, b_lbl:=label('b(#,x,y)='),
  2627.                                 Child, blue_str:=StringObject,
  2628.                                     StringFrame,
  2629.                                 End,
  2630.                             End,
  2631.                             Child, HGroup,
  2632.                                 Child, Label(cat.msgl_Output.getstr()),
  2633.                                 Child, outb_cyc:=CycleObject,
  2634.                                     MUIA_Cycle_Entries,[cat.msgl_Int32.getstr(),cat.msgl_Float32.getstr(),cat.msgl_Float64.getstr(),
  2635.                                                         cat.msgl_OldR.getstr(),cat.msgl_OldG.getstr(),cat.msgl_OldB.getstr(),
  2636.                                                         cat.msgl_CopyR.getstr(),cat.msgl_CopyG.getstr(),NIL],
  2637.                                     MUIA_Cycle_Active,3,
  2638.                                 End,
  2639.                                 Child, RectangleObject,End,
  2640.                             End,
  2641.                         End,
  2642.                     End,
  2643.                     Child, HGroup,
  2644.                         Child, TextObject,
  2645.                             MUIA_Text_PreParse,'\ec',
  2646.                             MUIA_Text_Contents,cat.msgl_Width.getstr(),
  2647.                         End,
  2648.                         Child, TextObject,
  2649.                             MUIA_Text_PreParse,'\ec',
  2650.                             MUIA_Text_Contents,cat.msgl_Height.getstr(),
  2651.                         End,
  2652.                     End,
  2653.                     Child, HGroup,
  2654.                         Child, width_str:=StringObject,
  2655.                             StringFrame,
  2656.                             MUIA_String_Accept,'0123456789',
  2657.                         End,
  2658.                         Child, height_str:=StringObject,
  2659.                             StringFrame,
  2660.                             MUIA_String_Accept,'0123456789',
  2661.                         End,
  2662.                     End,
  2663.                     Child, GroupObject,MUIA_Group_Rows,2,
  2664.                         Child, draw_btn:=TextObject,
  2665.                             ButtonFrame,
  2666.                             MUIA_Background,MUII_ButtonBack,
  2667.                             MUIA_Text_PreParse,'\ec',
  2668.                             MUIA_Text_Contents,cat.msgl_Render.getstr(),
  2669.                             MUIA_InputMode,MUIV_InputMode_RelVerify,
  2670.                         End,
  2671.                         Child, savepic_btn:=SimpleButton(cat.msgl_SavePic.getstr()),
  2672.                         Child, savefunc_btn:=SimpleButton(cat.msgl_SaveFunc.getstr()),
  2673.                         Child, abort_btn:=SimpleButton(cat.msgl_Abort.getstr()),
  2674.                         Child, showme_cyc:=CycleObject,
  2675.                             ButtonFrame,
  2676.                             MUIA_Cycle_Entries,showme_cyclelabels,
  2677.                             MUIA_Cycle_Active,1,
  2678.                         End,
  2679.                         Child, close_btn:=SimpleButton(cat.msgl_Close.getstr()),
  2680.                         Child, loadfunc_btn:=SimpleButton(cat.msgl_LoadFunc.getstr()),
  2681.                         Child, clear_btn:=SimpleButton(cat.msgl_Clear.getstr()),
  2682.                     End,
  2683.                     Child, HGroup,
  2684.                         Child,lamp_lmp:=LampObject,
  2685.                             MUIA_Lamp_Type,MUIV_Lamp_Type_Big,
  2686.                             MUIA_Lamp_ColorType,MUIV_Lamp_ColorType_UserDefined,
  2687.                             MUIA_Lamp_Color,MUIV_Lamp_Color_Off,
  2688.                         End,
  2689.                         Child,state_txt:=TextObject,
  2690.                             MUIA_Text_Contents,cat.msgs_Idle.getstr(),
  2691.                             MUIA_Weight,50,
  2692.                         End,
  2693.                         Child,state_gau:=GaugeObject,
  2694.                             TextFrame,
  2695.                             MUIA_Gauge_Horiz , MUI_TRUE,
  2696.                         End,
  2697.                     End,
  2698.                 End,
  2699.             End,
  2700.         End,
  2701.         SubWindow,prefs_win:=WindowObject,
  2702.             MUIA_Window_Title,cat.msgl_Prefs.getstr(),
  2703.             MUIA_Window_ID,"PREF",
  2704.             WindowContents,VGroup,
  2705.                 Child, HGroup,
  2706.                     Child, VGroup,
  2707.                         GroupFrameT(cat.msgp_Priority.getstr()),
  2708.                         Child, mainpri_sld:=uSliderObject,
  2709.                             GroupFrameT(cat.msgp_MainTask.getstr()),
  2710.                             MUIA_Slider_Min,-10,
  2711.                             MUIA_Slider_Max,10,
  2712.                             MUIA_Slider_Level,0,
  2713.                         End,
  2714.                         Child, currpri_sld:=uSliderObject,
  2715.                             GroupFrameT(cat.msgp_CurrentTask.getstr()),
  2716.                             MUIA_Slider_Min,-10,
  2717.                             MUIA_Slider_Max,10,
  2718.                             MUIA_Slider_Level,-1,
  2719.                         End,
  2720.                         Child, renderpri_sld:=uSliderObject,
  2721.                             GroupFrameT(cat.msgp_RenderTask.getstr()),
  2722.                             MUIA_Slider_Min,-10,
  2723.                             MUIA_Slider_Max,10,
  2724.                             MUIA_Slider_Level,-2,
  2725.                         End,
  2726.                     End,
  2727.                     Child, VGroup,
  2728.                         Child, HGroup,
  2729.                             Child,recompile_chk:=CheckMark(MUI_TRUE),
  2730.                             Child,FreeLabel(cat.msgp_Recompile.getstr()),
  2731.                         End,
  2732.                         Child, renderupdate_sld:=uSliderObject,
  2733.                             MUIA_Disabled,MUI_TRUE,
  2734.                             GroupFrameT(cat.msgp_RenderUpd.getstr()),
  2735.                             MUIA_uSlider_Stringify,MUI_TRUE,
  2736.                             MUIA_Slider_Min,0,
  2737.                             MUIA_Slider_Max,40,
  2738.                             MUIA_Slider_Level,10,
  2739.                         End,
  2740.                         Child, HGroup,
  2741.                             Child, FreeLabel(cat.msgp_Close.getstr()),
  2742.                             Child, close_cyc:=CycleObject,
  2743.                                 MUIA_Cycle_Entries,[cat.msgl_Iconify.getstr(),cat.msgl_Close.getstr(),NIL],
  2744.                                 MUIA_Cycle_Active,0,
  2745.                             End,
  2746.                         End,
  2747.                         Child, HGroup,
  2748.                             Child, showmess_chk:=CheckMark(MUI_TRUE),
  2749.                             Child, FreeLabel(cat.msgp_ShowMw.getstr()),
  2750.                         End,
  2751.                     End,
  2752.                     Child, VGroup,
  2753.                         Child, HGroup,
  2754.                             Child, FreeLabel(cat.msgp_DithM.getstr()),
  2755.                             Child, dither_cyc:=CycleObject,
  2756.                                 MUIA_Cycle_Entries,[cat.msgp_diNone.getstr(),'EDD','Floyd Steinberg',cat.msgp_diRand.getstr(),NIL],
  2757.                                 MUIA_Cycle_Active,2,
  2758.                             End,
  2759.                         End,
  2760.                         Child, dither_sld:=SliderObject,
  2761.                             GroupFrameT(cat.msgp_DithA.getstr()),
  2762.                             MUIA_Slider_Min,0,
  2763.                             MUIA_Slider_Max,255,
  2764.                             MUIA_Slider_Level,40,
  2765.                         End,
  2766.                         Child, mui_btn:=SimpleButton(cat.msgp_MuiPrefs.getstr()),
  2767.                     End,
  2768.                 End,
  2769.                 Child, HGroup,
  2770.                     Child, RectangleObject,End,
  2771.                     Child, savep_btn:=SimpleButton(cat.msgp_SavePrefs.getstr()),
  2772.                     Child, RectangleObject,End,
  2773.                 End,
  2774.             End,
  2775.         End,
  2776.         SubWindow,messages_win:=WindowObject,
  2777.             MUIA_Window_Title,cat.msgm_NoMsg.getstr(),
  2778.             MUIA_Window_ID,"MESS",
  2779.             MUIA_Window_CloseGadget,FALSE,
  2780.             WindowContents,VGroup,
  2781.                 Child,ListviewObject,
  2782.                     MUIA_VertDisappear,50,
  2783.                     MUIA_Listview_Input,FALSE,
  2784.                     ReadListFrame,
  2785.                     MUIA_Listview_List,messages_lst:=ListObject,
  2786.                         MUIA_List_SourceArray,messages,
  2787.                     End,
  2788.                 End,
  2789.                 Child, colour_txt:=TextObject,
  2790.                     TextFrame,
  2791.                     MUIA_Background,MUII_TextBack,
  2792.                     MUIA_Text_Contents,'c(p,x,y)=[r,g,b]',
  2793.                 End,
  2794.             End,
  2795.         End,
  2796.     End
  2797.     IF app <> NIL
  2798.         set(settings_win,MUIA_Window_DefaultObject,opened_lsv) -> This doesn't really work.
  2799.  
  2800.         doMethodA(settings_win,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit])
  2801.         doMethodA(messages_win,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,showmess_chk,3,MUIM_NoNotifySet,MUIA_Selected,FALSE])
  2802.  
  2803.         doMethodA(new_btn,     [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,1,MUIM_ProjectList_NewItem])
  2804. /*Variable List handling*/
  2805.         doMethodA(varlist_lst,[MUIM_VariableList_Fields,varname_str,varval_str])
  2806.         doMethodA(var_btn,     [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,varlist_win,3,MUIM_Set,MUIA_Window_Open,MUIV_TriggerValue])
  2807.         doMethodA(varlist_win, [MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,var_btn,3,MUIM_Set,MUIA_Selected,FALSE])
  2808.         doMethodA(varlist_lst, [MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,varlist_lst,3,MUIM_VariableList_UpdateStr,varname_str,varval_str])
  2809.         doMethodA(varname_str, [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,varlist_lst,3,MUIM_VariableList_SetVar,MUIV_VariableList_SetVar_Name,MUIV_TriggerValue])
  2810.         doMethodA(varval_str,  [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,varlist_lst,3,MUIM_VariableList_SetVar,MUIV_VariableList_SetVar_Value,MUIV_TriggerValue])
  2811.         doMethodA(varname_str, [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,varlist_win,3,MUIM_Set,MUIA_Window_ActiveObject,varname_str])
  2812.         doMethodA(varval_str,  [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,varlist_win,3,MUIM_Set,MUIA_Window_ActiveObject,varval_str])
  2813.  
  2814.         doMethodA(varadd_btn,  [MUIM_Notify,MUIA_Pressed,FALSE,varlist_lst,1,MUIM_VariableList_AddVar])
  2815.         doMethodA(vardel_btn,  [MUIM_Notify,MUIA_Pressed,FALSE,varlist_lst,2,MUIM_List_Remove,MUIV_List_Remove_Active])
  2816. /*preferences*/
  2817.         doMethodA(prefs_win,       [MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,prefs_win,3,MUIM_Set,MUIA_Window_Open,FALSE])
  2818.         doMethodA(prefs_btn,       [MUIM_Notify,MUIA_Pressed,     FALSE,         prefs_win,3,MUIM_Set,MUIA_Window_Open,MUI_TRUE])
  2819.  
  2820.         doMethodA(mui_btn,         [MUIM_Notify,MUIA_Pressed,     FALSE,         app,1,MUIM_Application_OpenConfigWindow])
  2821.         doMethodA(savep_btn,       [MUIM_Notify,MUIA_Pressed,     FALSE,         opened_lst,1,MUIM_ProjectList_SavePrefs])
  2822.         doMethodA(mainpri_sld,     [MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_SetPri,MUIV_ProjectList_SetPri_Main,MUIV_TriggerValue])
  2823.         doMethodA(currpri_sld,     [MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_SetPri,MUIV_ProjectList_SetPri_Curr,MUIV_TriggerValue])
  2824.         doMethodA(renderpri_sld,   [MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_SetPri,MUIV_ProjectList_SetPri_Render,MUIV_TriggerValue])
  2825.         doMethodA(renderupdate_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Prefs,{rupd},MUIV_TriggerValue])
  2826.         doMethodA(close_cyc,       [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,app,3,MUIM_WriteLong,MUIV_TriggerValue,{wclose}])
  2827.         doMethodA(showmess_chk,    [MUIM_Notify,MUIA_Selected    ,MUIV_EveryTime,messages_win,3,MUIM_Set,MUIA_Window_Open,MUIV_TriggerValue])
  2828.         doMethodA(dither_cyc,      [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Prefs,{dithm},MUIV_TriggerValue])
  2829.         doMethodA(dither_sld,      [MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Prefs,{ditha},MUIV_TriggerValue])
  2830. /*mainpri >= currpri >= renderpri*/
  2831.         doMethodA(mainpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,currpri_sld,2,MUIM_uSlider_Smaller,MUIV_TriggerValue])
  2832.         doMethodA(mainpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,renderpri_sld,2,MUIM_uSlider_Smaller,MUIV_TriggerValue])
  2833.         doMethodA(currpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,renderpri_sld,2,MUIM_uSlider_Smaller,MUIV_TriggerValue])
  2834.         doMethodA(currpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,mainpri_sld,2,MUIM_uSlider_Bigger,MUIV_TriggerValue])
  2835.         doMethodA(renderpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,mainpri_sld,2,MUIM_uSlider_Bigger,MUIV_TriggerValue])
  2836.         doMethodA(renderpri_sld,[MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,currpri_sld,2,MUIM_uSlider_Bigger,MUIV_TriggerValue])
  2837. /*Every change to a gadget is sent to the ProjectList class*/
  2838.         doMethodA(name_str,    [MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Name,MUIV_TriggerValue])
  2839.         doMethodA(type_reg,    [MUIM_Notify,MUIA_Group_ActivePage,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Type,MUIV_TriggerValue])
  2840.         doMethodA(path_str,    [MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_ImageFile,MUIV_TriggerValue])
  2841.         doMethodA(size_rad,    [MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_LoadM,MUIV_TriggerValue])
  2842.         doMethodA(red_str,     [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Red,MUIV_TriggerValue])
  2843.         doMethodA(green_str,   [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Green,MUIV_TriggerValue])
  2844.         doMethodA(blue_str,    [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Blue,MUIV_TriggerValue])
  2845.         doMethodA(outr_cyc,    [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_OutputR,MUIV_TriggerValue])
  2846.         doMethodA(outg_cyc,    [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_OutputG,MUIV_TriggerValue])
  2847.         doMethodA(outb_cyc,    [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_OutputB,MUIV_TriggerValue])
  2848.         doMethodA(width_str,   [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Width,MUIV_TriggerValue])
  2849.         doMethodA(height_str,  [MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,opened_lst,3,MUIM_ProjectList_Notify,MUIV_ProjectList_Notify_Height,MUIV_TriggerValue])
  2850. /*If the active element of the Opened Projects List has changed, the gadgets must be refreshed*/
  2851.         doMethodA(opened_lst,  [MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,opened_lst,1,MUIM_ProjectList_Refresh,0])
  2852. /*Action buttons:ProjectList class will forward those messages to the selected project*/
  2853.         doMethodA(draw_btn,    [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_Render])
  2854.         doMethodA(savepic_btn, [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_SavePic])
  2855.         doMethodA(savefunc_btn,[MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_SaveFunc])
  2856.         doMethodA(loadfunc_btn,[MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_LoadFunc])
  2857.         doMethodA(abort_btn,   [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_Abort])
  2858.         doMethodA(clear_btn,   [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,2,MUIM_ProjectList_Forward,MUIM_PlaneFunc_Clear])
  2859. /*since the address of the current project is variable I can't do direct notification. Instead, there are two methods for ProjectList.*/
  2860.         doMethodA(opened_lsv,  [MUIM_Notify,MUIA_Listview_DoubleClick,MUI_TRUE,showme_cyc,3,MUIM_Set,MUIA_Cycle_Active,1])
  2861.         doMethodA(showme_cyc,  [MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,opened_lst,2,MUIM_ProjectList_ShowMe,MUIV_TriggerValue])
  2862.         doMethodA(close_btn,   [MUIM_Notify,MUIA_Pressed,FALSE,opened_lst,1,MUIM_ProjectList_DelItem])
  2863.  
  2864.         loadprefs()
  2865.  
  2866.         set(settings_win,MUIA_Window_Open,MUI_TRUE)
  2867.         get(showmess_chk,MUIA_Selected,{l}) ; IF l THEN
  2868.            set(messages_win,MUIA_Window_Open,MUI_TRUE)
  2869.  
  2870.         doMethodA(opened_lst,[MUIM_ProjectList_Memory])
  2871.  
  2872.         message(-1,cat.msgm_Welcome.getstr())
  2873.  
  2874.     WHILE Not(doMethodA(app,[MUIM_Application_NewInput,{sigs}]) = MUIV_Application_ReturnID_Quit)
  2875.             IF sigs THEN sigs := Wait(sigs)
  2876.         ENDWHILE
  2877.  
  2878.     ELSE
  2879.         WriteF(cat.msg_NoApp.getstr())
  2880.     ENDIF
  2881. EXCEPT DO
  2882.     useprefs()
  2883.     IF app THEN Mui_DisposeObject(app)
  2884.     IF cl_planefunc THEN Mui_DeleteCustomClass(cl_planefunc)
  2885.     IF cl_projectlist THEN Mui_DeleteCustomClass(cl_projectlist)
  2886.     IF cl_uslider THEN Mui_DeleteCustomClass(cl_uslider)
  2887.     IF cl_sizetxt THEN Mui_DeleteCustomClass(cl_sizetxt)
  2888.     IF cl_myapp THEN Mui_DeleteCustomClass(cl_myapp)
  2889.     dcc() -> VarList
  2890.     dCleanup()
  2891.     IF exception
  2892.         IF localebase
  2893.             WriteF(cat.msg_Nolib.getstr(),exception)
  2894.         ELSE
  2895.             WriteF('Failed to open \s.\n',exception)
  2896.         ENDIF
  2897.     ENDIF
  2898.     IF aslbase       THEN CloseLibrary(aslbase)
  2899.     IF datatypesbase THEN CloseLibrary(datatypesbase)
  2900.     IF guigfxbase    THEN CloseLibrary(guigfxbase)
  2901.     IF iffparsebase  THEN CloseLibrary(iffparsebase)
  2902.     IF muimasterbase THEN CloseLibrary(muimasterbase)
  2903.     IF utilitybase   THEN CloseLibrary(utilitybase)
  2904.     cat.close()
  2905.     IF localebase THEN CloseLibrary(localebase)
  2906. ENDPROC                     
  2907.  
  2908. PROC message(id,info:PTR TO CHAR) -> Writes a message in the message-list
  2909. DEF t
  2910.     FOR t:=0 TO 13
  2911.         StrCopy(messages[t],messages[t+1]) -> Warning, the addresses mustn't change!
  2912.     ENDFOR
  2913.     StringF(messages[14],'[\d] \s',id,info)
  2914.     doMethodA(messages_lst,[MUIM_List_Redraw,MUIV_List_Redraw_All])
  2915.     IF counter <> 1
  2916.         StringF(title,'\d \s',counter++,cat.msgm_Messages.getstr())     /*I will have to localize this, too!*/
  2917.     ELSE
  2918.         StringF(title,'\d \s',counter++,cat.msgm_Message.getstr())
  2919.     ENDIF
  2920.     set(messages_win,MUIA_Window_Title,title)
  2921. ENDPROC
  2922.  
  2923. PROC messagefmt(id,info:PTR TO CHAR,arg1=0,arg2=0,arg3=0)
  2924. DEF s[100]:STRING
  2925.     StringF(s,info,arg1,arg2,arg3)
  2926.     message(id,s)
  2927. ENDPROC
  2928.