home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / wb_tools / urouhack / source / urouhack.c < prev   
C/C++ Source or Header  |  1996-03-01  |  38KB  |  1,226 lines

  1. /********************************************************************************/
  2. /* Urouhack V1.3beta by Tinic Urou 18.02.96                                     */
  3. /*                                                                              */
  4. /* Please leave me a mail, if you are using this code.                          */
  5. /* And, it would be nice, if you could send me a copy of your modified codes    */
  6. /* uuencoded via mail.                                                          */
  7. /*                                                                              */
  8. /* 5uro@informatik.uni-hamburg.de                                               */
  9. /********************************************************************************/
  10.  
  11. /********************************************************************************/
  12. /* Some macros for class creation handling                                      */
  13. /* Why did no one have this idea?.. Hmmm... this is really missing in MUI...    */
  14. /* I will enhance these macros and release them sometimes...                    */
  15. /********************************************************************************/
  16.  
  17. #define BOOPSI_Class( initName, dispatchName, ClassID, SuperClass, SuperClassPtr, InstantStruct, Flags)\
  18. Class  *initName(void);\
  19. ULONG   dispatchName(Class *, Object *, Msg);\
  20. Class * initName(void)\
  21. {\
  22.     Class *cl;\
  23.     extern ULONG HookEntry();\
  24.     if(cl=MakeClass(ClassID,SuperClass,SuperClassPtr,sizeof(struct InstantStruct), Flags))\
  25.     {\
  26.     cl->cl_Dispatcher.h_Entry   = HookEntry;\
  27.     cl->cl_Dispatcher.h_SubEntry= dispatchName;\
  28.     }\
  29.     return(cl);\
  30. }\
  31. __geta4 ULONG dispatchName(Class *cl, Object *object,Msg msg)\
  32. {\
  33.     struct InstantStruct *data;\
  34.     data=(struct *InstantStruct)0;\
  35.     switch(msg->MethodID)\
  36.     {
  37.  
  38. #define BOOPSI_Method( MethodID)\
  39.     case MethodID:
  40.  
  41. #define BOOPSI_Method_End\
  42.     break;
  43.  
  44. #define BOOPSI_InitData\
  45.     data=INST_DATA(cl,object);
  46.  
  47. #define BOOPSI_Method_SuperDefault\
  48.     default : return(DoSuperMethodA(cl,object,msg));
  49.  
  50. #define BOOPSI_Method_SuperReturn\
  51.     return(DoSuperMethodA(cl,object,msg));
  52.  
  53. #define BOOPSI_End\
  54.     }\
  55. }
  56.  
  57. /********************************************************************************/
  58. /* Includes and libbases                                                        */
  59. /********************************************************************************/
  60.  
  61. #include <exec/types.h>
  62. #include <intuition/intuition.h>
  63. #include <intuition/classes.h>
  64. #include <intuition/classusr.h>
  65. #include <intuition/imageclass.h>
  66. #include <intuition/gadgetclass.h>
  67. #include <intuition/cghooks.h>
  68. #include <intuition/icclass.h>
  69. #include <utility/tagitem.h>
  70. #include <utility/hooks.h>
  71. #include <clib/intuition_protos.h>
  72. #include <clib/utility_protos.h>
  73. #include <clib/alib_protos.h>
  74. #include <clib/alib_stdio_protos.h>
  75. #include <intuition/IntuitionBase.h>
  76. #include <graphics/gfxbase.h>
  77. #include <graphics/text.h>
  78. #include <datatypes/datatypes.h>
  79. #include <datatypes/pictureclass.h>
  80. #include <dos/dos.h>
  81. #include <dos/rdargs.h>
  82. #include <exec/memory.h>
  83. #include <exec/tasks.h>
  84. #include <clib/macros.h>
  85.  
  86. extern struct IntuitionBase *IntuitionBase;
  87. extern struct Library       *UtilityBase;
  88. static char                 *version="$VER: Urouhack V1.3 by Tinic Urou";
  89.  
  90. BOOL    pframes         = TRUE,
  91.     psysi           = TRUE,
  92.     sysihackstyle   = FALSE,
  93.     pwin            = TRUE,
  94.     trymwb          = FALSE,
  95.     XStyle          = FALSE;
  96.  
  97. /********************************************************************************/
  98. /* Append new pens to the DrawInfo and allocate them                            */
  99. /********************************************************************************/
  100.  
  101. #define HALFSHADOWPEN   (0x000C)
  102. #define HALFSHINEPEN    (0x000D)
  103. #define DARKPAINTPEN    (0x000E)    /* Brown  on MagicWB */
  104. #define SHINEPAINTPEN   (0x000F)    /* Orange on MagicWB */
  105.  
  106. #define NEWNUMDRIPENS   (0x0010)
  107. #define NEWDRIVERSION   (0x0003)
  108.  
  109. struct NewPenStruct
  110. {
  111.     UWORD halfdark;
  112.     UWORD halfshine;
  113.     UWORD darkpaint;
  114.     UWORD shinepaint;
  115. };
  116.  
  117. struct ExtNewPenStruct
  118. {
  119.     ULONG   c1r;
  120.     ULONG   c1g;
  121.     ULONG   c1b;
  122.     ULONG   c2r;
  123.     ULONG   c2g;
  124.     ULONG   c2b;
  125.     ULONG   c3r;
  126.     ULONG   c3g;
  127.     ULONG   c3b;
  128.     ULONG   c4r;
  129.     ULONG   c4g;
  130.     ULONG   c4b;
  131. };
  132.  
  133. /***** Default shit *****/
  134.  
  135. struct ExtNewPenStruct defpens=
  136. {
  137.     0x80808080,0x80808080,0x80808080,
  138.     0xafafafaf,0xafafafaf,0xafafafaf,
  139.     0xaaaaaaaa,0x99999999,0x77777777,
  140.     0xffffffff,0xa9a9a9a9,0x97979797
  141. };
  142.  
  143. struct NewPenStruct p1={3,0,1,1};
  144. struct NewPenStruct p2={4,5,6,7};
  145.  
  146. struct NewPenStruct *penlist[256]=
  147. {
  148.     &p1,
  149.     &p2
  150. };
  151.  
  152. BOOL exttrymwb[256];
  153.  
  154. char *namelist[256]=
  155. {
  156.     "Don't look at me!",
  157.     "Workbench"
  158. };
  159.  
  160. int GetPubScreens(struct Screen *src, char *namelist[])
  161. {
  162.     struct List     *PubScreenList;
  163.     struct PubScreenNode *ScreenNode;
  164.  
  165.     PubScreenList = LockPubScreenList();
  166.     for(ScreenNode=(struct PubScreenNode *)PubScreenList->lh_Head;ScreenNode->psn_Node.ln_Succ;ScreenNode=(struct PubScreenNode *)ScreenNode->psn_Node.ln_Succ)
  167.     {
  168.     if(ScreenNode->psn_Screen==src)
  169.     {
  170.         int i=0;
  171.  
  172.         while(namelist[i])
  173.         {
  174.         if(strcmp(ScreenNode->psn_Node.ln_Name,namelist[i])==0)
  175.         {
  176.             UnlockPubScreenList();
  177.             return(i);
  178.         }
  179.         i++;
  180.         }
  181.         UnlockPubScreenList();
  182.         return(0);
  183.     }
  184.     }
  185.     UnlockPubScreenList();
  186.     return(0);
  187. }
  188.  
  189. __geta4 void allocNewPens(__A2 struct Screen *scr)
  190. {
  191.     struct DrawInfo *dr;
  192.     int                     i;
  193.  
  194.     if(dr=GetScreenDrawInfo(scr))
  195.     {
  196.     if(dr->dri_Version==DRI_VERSION)
  197.     {
  198.         UWORD   *newpens;
  199.         if(newpens=(UWORD *)AllocVec((NEWNUMDRIPENS+1)<<1,0L))
  200.         {
  201.         CopyMem(dr->dri_Pens,newpens,NUMDRIPENS<<1);
  202.  
  203.         dr->dri_Pens            = newpens;
  204.         dr->dri_Version         = NEWDRIVERSION;
  205.         newpens[NEWNUMDRIPENS]  = ~0;
  206.  
  207.         if(i=GetPubScreens(scr,namelist))
  208.         {
  209.             if(exttrymwb[i]) /* Try to allocate Mwb colors on selected screen */
  210.             {
  211.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c1r,defpens.c1g, defpens.c1b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  212.             newpens[HALFSHADOWPEN]= i>-1 ? i : penlist[0]->halfdark;
  213.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c2r,defpens.c2g, defpens.c2b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  214.             newpens[HALFSHINEPEN] = i>-1 ? i : penlist[0]->halfshine;
  215.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c3r,defpens.c3g, defpens.c3b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  216.             newpens[DARKPAINTPEN] = i>-1 ? i : penlist[0]->darkpaint;
  217.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c4r,defpens.c4g, defpens.c4b,OBP_Precision,PRECISION_IMAGE,TAG_DONE);
  218.             newpens[SHINEPAINTPEN]= i>-1 ? i : penlist[0]->shinepaint;
  219.             }
  220.             else
  221.             {
  222.             newpens[HALFSHADOWPEN]=penlist[i]->halfdark;
  223.             newpens[HALFSHINEPEN]= penlist[i]->halfshine;
  224.             newpens[DARKPAINTPEN]= penlist[i]->darkpaint;
  225.             newpens[SHINEPAINTPEN]=penlist[i]->shinepaint;
  226.             }
  227.         }
  228.         else
  229.         {
  230.             if(trymwb) /* Try to allocate Mwb colors on any screen */
  231.             {
  232.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c1r,defpens.c1g, defpens.c1b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  233.             newpens[HALFSHADOWPEN]= i>-1 ? i : penlist[0]->halfdark;
  234.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c2r,defpens.c2g, defpens.c2b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  235.             newpens[HALFSHINEPEN] = i>-1 ? i : penlist[0]->halfshine;
  236.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c3r,defpens.c3g, defpens.c3b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  237.             newpens[DARKPAINTPEN] = i>-1 ? i : penlist[0]->darkpaint;
  238.             i=ObtainBestPen(scr->ViewPort.ColorMap,defpens.c4r,defpens.c4g, defpens.c4b,OBP_Precision,PRECISION_IMAGE,OBP_FailIfBad,TRUE,TAG_DONE);
  239.             newpens[SHINEPAINTPEN]= i>-1 ? i : penlist[0]->shinepaint;
  240.             }
  241.             else /* No! */
  242.             {
  243.             newpens[HALFSHADOWPEN]= penlist[0]->halfdark;
  244.             newpens[HALFSHINEPEN] = penlist[0]->halfshine;
  245.             newpens[DARKPAINTPEN] = penlist[0]->darkpaint;
  246.             newpens[SHINEPAINTPEN]= penlist[0]->shinepaint;
  247.             }
  248.         }
  249.         }
  250.     }
  251.     FreeScreenDrawInfo(scr,dr);
  252.     }
  253. }
  254.  
  255. BYTE    b_top   = 3,
  256.     b_bottom= 3,
  257.     b_left  = 3,
  258.     b_right = 3,
  259.  
  260.     b_height=14,
  261.     b_width =18;
  262.  
  263.  
  264. /* This change is needed for some programs like DeliTrackerII etc... */
  265.  
  266. __geta4 changeSize(__A0 struct NewWindow *win,__A1 struct TagItem *tags)
  267. {
  268.     struct TagItem  *ti;
  269.     if(tags)
  270.     {
  271.     ULONG flags=GetTagData(WA_Flags,win->Flags,tags);
  272.     if(flags&WFLG_SIZEGADGET)
  273.     {
  274.         if(flags&WFLG_SIZEBBOTTOM)
  275.         {
  276.         if(ti=FindTagItem(WA_InnerHeight,tags))
  277.         {
  278.             ti->ti_Data+=(b_height-10);
  279.         }
  280.         }
  281.         if(flags&WFLG_SIZEBRIGHT)
  282.         {
  283.         if(ti=FindTagItem(WA_InnerWidth,tags))
  284.         {
  285.             ti->ti_Data+=(b_width-10);
  286.         }
  287.         }
  288.     }
  289.     }
  290. }
  291.  
  292. /********************************************************************************/
  293. /* standard function for drawing frames, I should convert this to assembler.... */
  294. /********************************************************************************/
  295.  
  296. draw_frame(struct RastPort *rp, UWORD x, UWORD y, UWORD width, UWORD height, UWORD col1, UWORD col2, UWORD col3, UWORD col4, UWORD col5, BOOL bg)
  297. {
  298.     if((width>x)&&(height>y))
  299.     {
  300.     UWORD *ptr=rp->AreaPtrn;
  301.     rp->AreaPtrn=0L;            /* Remove any patterns, since we use RectFills */
  302.     SetAPen(rp,col2);
  303.     RectFill(rp,width,y,width,height-1);
  304.     RectFill(rp,x,height,width,height);
  305.     SetAPen(rp,col1);
  306.     RectFill(rp,x+1,y,width,y);
  307.     RectFill(rp,x,y,x,height);
  308.     x++;y++;height--;width--;
  309.     if(bg)
  310.     {
  311.         SetAPen(rp,col5);
  312.         RectFill(rp,x+1,y+1,width-1,height-1);
  313.     }
  314.     SetAPen(rp,col3);
  315.     RectFill(rp,x+1,y,width-1,y);
  316.     RectFill(rp,x,y,x,height-1);
  317.     SetAPen(rp,col4);
  318.     RectFill(rp,x+1,height,width,height);
  319.     RectFill(rp,width,y+1,width,height-1);
  320.     rp->AreaPtrn=ptr;
  321.     }
  322. }
  323.  
  324. draw_simple(struct RastPort *rp,UWORD x, UWORD y, UWORD width, UWORD height, UWORD col1, UWORD col2)
  325. {
  326.     if((width>x)&&(height>y))
  327.     {
  328.     SetAPen(rp,col1);
  329.     RectFill(rp,x,y,width,y);
  330.     RectFill(rp,x,y,x,height);
  331.     SetAPen(rp,col2);
  332.     RectFill(rp,width,y,width,height);
  333.     RectFill(rp,x,height,width,height);
  334.     }
  335. }
  336.  
  337. /******************************************************************/
  338. /* FRAMEICLASS Hack                                               */
  339. /******************************************************************/
  340.  
  341. struct FRAMEData
  342. {
  343.     ULONG type;
  344.     ULONG edgesonly;
  345.     ULONG recessed;
  346.     ULONG data;
  347. };
  348.  
  349. BOOL DrawXEN(struct impDraw *imsg,struct FRAMEData *data, struct RastPort *rp, UWORD minx, UWORD miny, UWORD maxx, UWORD maxy, UWORD *pens)
  350. {
  351.     switch (data->type)
  352.     {
  353.     case    FRAME_DEFAULT:
  354.     case    FRAME_BUTTON:
  355.         if (imsg->imp_State==IDS_NORMAL)
  356.         {
  357.             if(data->edgesonly)
  358.             {
  359.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[HALFSHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  360.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],0,FALSE);
  361.             }
  362.             else
  363.             {
  364.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  365.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  366.             }
  367.         }
  368.         else
  369.         {
  370.             if(data->edgesonly) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],0,FALSE);
  371.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  372.         }
  373.         break;
  374.     case    FRAME_RIDGE:
  375.         if(data->edgesonly)
  376.         {
  377.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],0,FALSE);
  378.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[SHADOWPEN],0,FALSE);
  379.         }
  380.         else
  381.         {
  382.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  383.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[SHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  384.         }
  385.         break;
  386.     }
  387.     return(TRUE);
  388. }
  389.  
  390. BOOL DrawX(struct impDraw *imsg,struct FRAMEData *data, struct RastPort *rp, UWORD minx, UWORD miny, UWORD maxx, UWORD maxy, UWORD *pens)
  391. {
  392.     switch (data->type)
  393.     {
  394.     case    FRAME_DEFAULT:
  395.     case    FRAME_BUTTON:
  396.         if (imsg->imp_State==IDS_NORMAL)
  397.         {
  398.             if(data->edgesonly)
  399.             {
  400.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  401.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  402.             }
  403.             else
  404.             {
  405.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  406.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  407.             }
  408.         }
  409.         else
  410.         {
  411.             if(data->edgesonly) draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  412.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  413.         }
  414.         break;
  415.     case    FRAME_RIDGE:
  416.         if(data->edgesonly)
  417.         {
  418.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],0,FALSE);
  419.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],0,FALSE);
  420.         }
  421.         else
  422.         {
  423.             if(!data->recessed) draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[BACKGROUNDPEN],TRUE);
  424.             else                draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  425.         }
  426.         break;
  427.     }
  428.     return(TRUE);
  429. }
  430.  
  431.  
  432. BOOPSI_Class(initFRAMEClass,dispatchFRAME,"frameiclass","breizhclass",NULL,FRAMEData, 0)
  433.  
  434.     BOOPSI_Method(OM_NEW)
  435.     {
  436.     ULONG   type,edgesonly,recessed;
  437.     type      =GetTagData(IA_FrameType,0L,((struct opSet *)msg)->ops_AttrList);
  438.     edgesonly =GetTagData(IA_EdgesOnly,0L,((struct opSet *)msg)->ops_AttrList);
  439.     recessed  =GetTagData(IA_Recessed ,0L,((struct opSet *)msg)->ops_AttrList);
  440.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  441.     {
  442.         BOOPSI_InitData
  443.         data->type      =type;
  444.         data->edgesonly =edgesonly;
  445.         data->recessed  =recessed;
  446.     }
  447.     return(object);
  448.     }
  449.     BOOPSI_Method_End
  450.  
  451.     BOOPSI_Method(IM_DRAWFRAME)
  452.     BOOPSI_Method(IM_DRAW)
  453.     {
  454.     BOOPSI_InitData
  455.  
  456.     if((data->type==FRAME_BUTTON)||(data->type==FRAME_RIDGE))
  457.     {
  458.         struct  impDraw     *imsg;
  459.         imsg=(struct impDraw *)msg;
  460.         if(imsg->imp_DrInfo)
  461.         {
  462.         UWORD   *pens;
  463.         pens=imsg->imp_DrInfo->dri_Pens;
  464.         if(imsg->imp_DrInfo->dri_Version==NEWDRIVERSION)
  465.         {
  466.             UWORD   minx,miny,maxx,maxy;
  467.             struct  RastPort    *rp;
  468.             rp  =imsg->imp_RPort;
  469.             minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  470.             miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  471.             maxx=minx+((msg->MethodID==IM_DRAWFRAME) ? imsg->imp_Dimensions.Width  : ((struct Image *)object)->Width )-1;
  472.             maxy=miny+((msg->MethodID==IM_DRAWFRAME) ? imsg->imp_Dimensions.Height : ((struct Image *)object)->Height)-1;
  473.             if(XStyle)
  474.             {
  475.             return(DrawX(imsg,data,rp,minx,miny,maxx,maxy,pens));
  476.             }
  477.             else
  478.             {
  479.             return(DrawXEN(imsg,data,rp,minx,miny,maxx,maxy,pens));
  480.             }
  481.         }
  482.         }
  483.     }
  484.     BOOPSI_Method_SuperReturn
  485.     }
  486.     BOOPSI_Method_End
  487.  
  488.     BOOPSI_Method_SuperDefault
  489.  
  490. BOOPSI_End
  491.  
  492. /********************************************************************/
  493. /* GADCLASS Hack                                                    */
  494. /*                                                                  */
  495. /* This patch is needed to adjust the position of the sizing gadget */
  496. /********************************************************************/
  497.  
  498. struct GADData
  499. {
  500.     ULONG what;
  501. };
  502.  
  503. BOOPSI_Class(initGADClass, dispatchGADClass, "buttongclass","tinicclass",NULL,GADData, 0)
  504.  
  505.     BOOPSI_Method(OM_NEW)
  506.     {
  507.     ULONG type=GetTagData(GA_SysGType,0L,((struct opSet *)msg)->ops_AttrList);
  508.  
  509.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  510.     {
  511.         if(type==GTYP_SIZING)
  512.         {
  513.         SetAttrs(object,GA_RelBottom,1-((struct Gadget *)(object))->Height,
  514.                 GA_RelRight, 1-((struct Gadget *)(object))->Width,
  515.                 TAG_DONE);
  516.         }
  517.     }
  518.     return(object);
  519.     }
  520.     BOOPSI_Method_End
  521.  
  522.     BOOPSI_Method_SuperDefault
  523.  
  524. BOOPSI_End
  525.  
  526. /******************************************************************/
  527. /* SYSIClass Hack                                                 */
  528. /******************************************************************/
  529.  
  530. struct SYSIData
  531. {
  532.     UWORD what;
  533.     UWORD dummy;
  534. };
  535.  
  536. ULONG DrawUrou(struct SYSIData *data,struct impDraw *imsg,Object *object, Class *cl, Msg msg)
  537. {
  538.     UWORD   y_size,dummy,minx,miny,maxx,maxy;
  539.     struct  RastPort    *rp;
  540.     UWORD   *pens;
  541.     pens=imsg->imp_DrInfo->dri_Pens;
  542.     rp=imsg->imp_RPort;
  543.     y_size=((struct Image *)object)->Height-1;
  544.     dummy=(y_size+1)>>1;
  545.     minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  546.     miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  547.     maxx=minx+((struct Image *)object)->Width-1;
  548.     maxy=miny+((struct Image *)object)->Height-1;
  549.  
  550.     switch (data->what)
  551.     {
  552.     case    SDEPTHIMAGE:
  553.         SetAPen(rp,pens[BACKGROUNDPEN]);
  554.         RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  555.     case    ZOOMIMAGE:
  556.     case    DEPTHIMAGE:
  557.         minx++;
  558.     case    LEFTIMAGE:
  559.     case    UPIMAGE:
  560.     case    DOWNIMAGE:
  561.     case    RIGHTIMAGE:
  562.     case    SIZEIMAGE:
  563.     case    CLOSEIMAGE:
  564.         if(XStyle)
  565.         {
  566.             if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  567.             else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  568.         }
  569.         else
  570.         {
  571.             if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],pens[BACKGROUNDPEN],TRUE);
  572.             else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN],pens[HALFSHINEPEN],pens[HALFSHADOWPEN],pens[BACKGROUNDPEN],TRUE);
  573.         }
  574.         break;
  575.     };
  576.     switch (data->what)
  577.     {
  578.     case    LEFTIMAGE:
  579.         SetAPen(rp,pens[SHADOWPEN]);
  580.         Move(rp,minx+3,miny+dummy);
  581.         Draw(rp,maxx-3,maxy-3);
  582.         Draw(rp,maxx-3,miny+3);
  583.         SetAPen(rp,pens[SHINEPEN]);
  584.         Draw(rp,minx+3,maxy-dummy);
  585.         return(0L);
  586.     case    RIGHTIMAGE:
  587.         SetAPen(rp,pens[SHINEPEN]);
  588.         Move(rp,maxx-3,maxy-dummy);
  589.         Draw(rp,minx+3,miny+3);
  590.         Draw(rp,minx+3,maxy-3);
  591.         SetAPen(rp,pens[SHADOWPEN]);
  592.         Draw(rp,maxx-3,miny+dummy);
  593.         return(0L);
  594.     case    UPIMAGE:
  595.         SetAPen(rp,pens[SHADOWPEN]);
  596.         Move(rp,maxx-((maxx-minx)>>1),miny+3);
  597.         Draw(rp,maxx-3,maxy-3);
  598.         Draw(rp,minx+3,maxy-3);
  599.         SetAPen(rp,pens[SHINEPEN]);
  600.         Draw(rp,minx+((maxx-minx)>>1),miny+3);
  601.         return(0L);
  602.     case    DOWNIMAGE:
  603.         SetAPen(rp,pens[SHADOWPEN]);
  604.         Move(rp,maxx-((maxx-minx)>>1),maxy-3);
  605.         Draw(rp,maxx-3,miny+3);
  606.         SetAPen(rp,pens[SHINEPEN]);
  607.         Draw(rp,minx+3,miny+3);
  608.         Draw(rp,minx+((maxx-minx)>>1),maxy-3);
  609.         return(0L);
  610.         break;
  611.     case    SIZEIMAGE:
  612.         switch (imsg->imp_State)
  613.         {
  614.             case    IDS_NORMAL:
  615.             case    IDS_SELECTED:
  616.                 SetAPen(rp,pens[FILLPEN]);
  617.                 RectFill(rp,minx+1,miny+1,minx+((maxx-minx)>>1)-1,miny+dummy-1);
  618.                 break;
  619.         }
  620.         SetAPen(rp,pens[SHADOWPEN]);
  621.         RectFill(rp,minx+1,miny+dummy,minx+((maxx-minx)>>1),miny+dummy);
  622.         RectFill(rp,minx+((maxx-minx)>>1),miny+1,minx+((maxx-minx)>>1),miny+dummy);
  623.         SetAPen(rp,pens[SHINEPEN]);
  624.         RectFill(rp,minx+1,miny+dummy+1,minx+((maxx-minx)>>1)+1,miny+dummy+1);
  625.         RectFill(rp,minx+((maxx-minx)>>1)+1,miny+1,minx+((maxx-minx)>>1)+1,miny+dummy+1);
  626.         return(0L);
  627.     case    CLOSEIMAGE:
  628.         SetAPen(rp,pens[SHINEPEN]);
  629.         RectFill(rp,maxx+1,miny+1,maxx+1,maxy);
  630.         switch (imsg->imp_State)
  631.         {
  632.             case    IDS_NORMAL:
  633.                 SetAPen(rp,pens[SHINEPEN]);
  634.                 RectFill(rp,minx+4,miny+dummy-2,maxx-4,miny+dummy-2);
  635.                 RectFill(rp,minx+4,miny+dummy-2,minx+4,miny+dummy+1);
  636.                 SetAPen(rp,pens[SHADOWPEN]);
  637.                 RectFill(rp,minx+4,miny+dummy+1,maxx-4,miny+dummy+1);
  638.                 RectFill(rp,maxx-4,miny+dummy-2,maxx-4,miny+dummy+1);
  639.                 SetAPen(rp,pens[FILLPEN]);
  640.                 RectFill(rp,minx+5,miny+dummy-1,maxx-5,miny+dummy);
  641.                 break;
  642.             case    IDS_SELECTED:
  643.                 RectFill(rp,minx+6,miny+dummy-2,maxx-6,miny+dummy-2);
  644.                 RectFill(rp,minx+6,miny+dummy-2,minx+6,miny+dummy+1);
  645.                 SetAPen(rp,pens[SHADOWPEN]);
  646.                 RectFill(rp,minx+6,miny+dummy+1,maxx-6,miny+dummy+1);
  647.                 RectFill(rp,maxx-6,miny+dummy-2,maxx-6,miny+dummy+1);
  648.                 SetAPen(rp,pens[FILLPEN]);
  649.                 RectFill(rp,minx+7,miny+dummy-1,maxx-7,miny+dummy);
  650.                 break;
  651.             default:
  652.                 SetAPen(rp,pens[SHINEPEN]);
  653.                 RectFill(rp,minx+4,miny+dummy-2,maxx-4,miny+dummy-2);
  654.                 RectFill(rp,minx+4,miny+dummy-2,minx+4,miny+dummy+1);
  655.                 SetAPen(rp,pens[SHADOWPEN]);
  656.                 RectFill(rp,minx+4,miny+dummy+1,maxx-4,miny+dummy+1);
  657.                 RectFill(rp,maxx-4,miny+dummy-2,maxx-4,miny+dummy+1);
  658.                 break;
  659.         }
  660.         return(0L);
  661.     case    DEPTHIMAGE:
  662.     case    SDEPTHIMAGE:
  663.         minx--;
  664.         SetAPen(rp,pens[SHADOWPEN]);
  665.         RectFill(rp,minx,miny+1,minx,maxy);
  666.         switch (imsg->imp_State)
  667.         {
  668.             case    IDS_NORMAL:
  669.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  670.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  671.                 SetAPen(rp,pens[FILLPEN]);
  672.                 RectFill(rp,minx+5,miny+4,minx+((maxx-minx)>>1)+2,maxy-6);
  673.                 break;
  674.             case    IDS_SELECTED:
  675.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  676.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  677.                 SetAPen(rp,pens[FILLPEN]);
  678.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-4);
  679.                 break;
  680.             default:
  681.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  682.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-5,pens[SHINEPEN],pens[SHADOWPEN]);
  683.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  684.                 RectFill(rp,minx+5,miny+4,minx+((maxx-minx)>>1)+2,maxy-6);
  685.                 break;
  686.         }
  687.         return(0L);
  688.     case    ZOOMIMAGE:
  689.         minx--;
  690.         SetAPen(rp,pens[SHADOWPEN]);
  691.         RectFill(rp,minx,miny+1,minx,maxy);
  692.         draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+dummy-1,maxx-((maxx-minx)>>1)+2,miny+dummy,pens[SHADOWPEN],pens[SHINEPEN]);
  693.         return(0L);
  694.     default:
  695.         BOOPSI_Method_SuperReturn
  696.     }
  697. }
  698.  
  699. ULONG DrawSysiHack(struct SYSIData *data,struct impDraw *imsg,Object *object, Class *cl, Msg msg)
  700. {
  701.     UWORD   y_size,dummy,minx,miny,maxx,maxy,h,w;
  702.     struct  RastPort    *rp;
  703.     UWORD   *pens;
  704.     pens=imsg->imp_DrInfo->dri_Pens;
  705.     rp=imsg->imp_RPort;
  706.     y_size=((struct Image *)object)->Height-1;
  707.     dummy=(y_size+1)>>1;
  708.     minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  709.     miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  710.     w=((struct Image *)object)->Width;
  711.     h=((struct Image *)object)->Height;
  712.     maxx=minx+w-1;
  713.     maxy=miny+h-1;
  714.  
  715.     switch (data->what)
  716.     {
  717.     case    ZOOMIMAGE:
  718.     case    DEPTHIMAGE:
  719.         minx++;
  720.     case    LEFTIMAGE:
  721.     case    UPIMAGE:
  722.     case    DOWNIMAGE:
  723.     case    RIGHTIMAGE:
  724.     case    SIZEIMAGE:
  725.     case    CLOSEIMAGE:
  726.         switch(imsg->imp_State)
  727.         {
  728.             case    IDS_SELECTED:
  729.                 SetAPen(rp,pens[FILLPEN]);
  730.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  731.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN]);
  732.                 break;
  733.             case    IDS_NORMAL:
  734.                 SetAPen(rp,pens[FILLPEN]);
  735.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  736.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  737.                 break;
  738.             default:
  739.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  740.                 RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  741.                 draw_simple(rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  742.                 break;
  743.         }
  744.         break;
  745.     case    SDEPTHIMAGE:
  746.         SetAPen(rp,pens[BACKGROUNDPEN]);
  747.         RectFill(rp,minx+1,miny+1,maxx-1,maxy-1);
  748.         if(imsg->imp_State==IDS_SELECTED) draw_simple(rp,minx+1,miny,maxx,maxy,pens[SHADOWPEN],pens[SHINEPEN]);
  749.         else                              draw_simple(rp,minx+1,miny,maxx,maxy,pens[SHINEPEN],pens[SHADOWPEN]);
  750.         break;
  751.     };
  752.     switch (data->what)
  753.     {
  754.     case    LEFTIMAGE:
  755.         SetAPen(rp,pens[SHADOWPEN]);
  756.         Move(rp,minx+3,miny+dummy);
  757.         Draw(rp,maxx-3,maxy-3);
  758.         Draw(rp,maxx-3,miny+3);
  759.         SetAPen(rp,pens[SHINEPEN]);
  760.         Draw(rp,minx+3,maxy-dummy);
  761.         return(0L);
  762.     case    RIGHTIMAGE:
  763.         SetAPen(rp,pens[SHINEPEN]);
  764.         Move(rp,maxx-3,maxy-dummy);
  765.         Draw(rp,minx+3,miny+3);
  766.         Draw(rp,minx+3,maxy-3);
  767.         SetAPen(rp,pens[SHADOWPEN]);
  768.         Draw(rp,maxx-3,miny+dummy);
  769.         return(0L);
  770.     case    UPIMAGE:
  771.         SetAPen(rp,pens[SHADOWPEN]);
  772.         Move(rp,maxx-((maxx-minx)>>1),miny+3);
  773.         Draw(rp,maxx-3,maxy-3);
  774.         Draw(rp,minx+3,maxy-3);
  775.         SetAPen(rp,pens[SHINEPEN]);
  776.         Draw(rp,minx+((maxx-minx)>>1),miny+3);
  777.         return(0L);
  778.     case    DOWNIMAGE:
  779.         SetAPen(rp,pens[SHADOWPEN]);
  780.         Move(rp,maxx-((maxx-minx)>>1),maxy-3);
  781.         Draw(rp,maxx-3,miny+3);
  782.         SetAPen(rp,pens[SHINEPEN]);
  783.         Draw(rp,minx+3,miny+3);
  784.         Draw(rp,minx+((maxx-minx)>>1),maxy-3);
  785.         return(0L);
  786.         break;
  787.     case    ZOOMIMAGE:
  788.         minx--;
  789.         SetAPen(rp,pens[SHADOWPEN]);
  790.         RectFill(rp,minx,miny+1,minx,maxy);
  791.         if(imsg->imp_State==IDS_SELECTED)
  792.         {
  793.             draw_simple(rp,minx+4,miny+3,maxx-4,maxy-3,pens[SHINEPEN],pens[SHADOWPEN]);
  794.             draw_simple(rp,minx+5,miny+4,maxx-((w-4)>>1),maxy-((h-4)>>1)-1,pens[SHADOWPEN],pens[SHINEPEN]);
  795.         }
  796.         else
  797.         {
  798.             draw_simple(rp,minx+4,miny+3,maxx-4,maxy-3,pens[SHADOWPEN],pens[SHINEPEN]);
  799.             draw_simple(rp,minx+5,miny+4,maxx-((w-4)>>1),maxy-((h-4)>>1)-1,pens[SHINEPEN],pens[SHADOWPEN]);
  800.         }
  801.         return(0L);
  802.     case    CLOSEIMAGE:
  803.         {
  804.             UWORD foo,fao;
  805.             SetAPen(rp,pens[SHINEPEN]);
  806.             RectFill(rp,maxx+1,miny+1,maxx+1,maxy);
  807.             foo=(h-1)/3;
  808.             fao=(w-1)/3;
  809.             if(imsg->imp_State==IDS_SELECTED)
  810.             {
  811.  
  812.             draw_simple(rp,minx+fao+1,miny+foo+1,maxx-fao-1,maxy-foo-1,pens[SHADOWPEN],pens[SHINEPEN]);
  813.             }
  814.             else
  815.             {
  816.             draw_simple(rp,minx+fao,miny+foo,maxx-fao,maxy-foo,pens[SHADOWPEN],pens[SHINEPEN]);
  817.             }
  818.         }
  819.         return(0L);
  820.     case    DEPTHIMAGE:
  821.         minx--;
  822.         SetAPen(rp,pens[SHADOWPEN]);
  823.         RectFill(rp,minx,miny+1,minx,maxy);
  824.         switch (imsg->imp_State)
  825.         {
  826.             case    IDS_NORMAL:
  827.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  828.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  829.                 SetAPen(rp,pens[FILLPEN]);
  830.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  831.                 break;
  832.             case    IDS_SELECTED:
  833.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHINEPEN],pens[SHADOWPEN]);
  834.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  835.                 break;
  836.             default:
  837.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  838.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  839.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  840.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  841.                 break;
  842.         }
  843.         return(0L);
  844.     case    SDEPTHIMAGE:
  845.         SetAPen(rp,pens[SHADOWPEN]);
  846.         RectFill(rp,minx,miny+1,minx,maxy);
  847.         switch (imsg->imp_State)
  848.         {
  849.             case    IDS_NORMAL:
  850.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  851.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  852.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  853.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  854.                 break;
  855.             case    IDS_SELECTED:
  856.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHINEPEN],pens[SHADOWPEN]);
  857.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  858.                 break;
  859.             default:
  860.                 draw_simple(rp,minx+((maxx-minx)>>1)-1,miny+5,maxx-3,maxy-2,pens[SHINEPEN],pens[SHADOWPEN]);
  861.                 draw_simple(rp,minx+4,miny+3,minx+((maxx-minx)>>1)+3,maxy-4,pens[SHADOWPEN],pens[SHINEPEN]);
  862.                 SetAPen(rp,pens[BACKGROUNDPEN]);
  863.                 RectFill(rp,minx+((maxx-minx)>>1),miny+6,maxx-4,maxy-3);
  864.                 break;
  865.         }
  866.         return(0L);
  867.     case    SIZEIMAGE:
  868.         minx--;
  869.         SetAPen(rp,pens[SHADOWPEN]);
  870.         Move(rp,maxx-3,miny+3);
  871.         Draw(rp,maxx-3,maxy-3);
  872.         Draw(rp,minx+3,maxy-3);
  873.         SetAPen(rp,pens[SHINEPEN]);
  874.         Draw(rp,maxx-3,miny+3);
  875.         return(0L);
  876.     default:
  877.         BOOPSI_Method_SuperReturn
  878.     }
  879. }
  880.  
  881. BOOPSI_Class(initSYSIClass,dispatchSYSIClass,"sysiclass","urouclass",NULL,SYSIData, 0)
  882.  
  883.     BOOPSI_Method(OM_NEW)
  884.     {
  885.     ULONG               what;
  886.     struct  DrawInfo    *mydr;
  887.  
  888.     what=   GetTagData(SYSIA_Which, 0x0, ((struct opSet *)msg)->ops_AttrList);
  889.     mydr=   (struct DrawInfo *)GetTagData(SYSIA_DrawInfo,0x0,((struct opSet *)msg)->ops_AttrList);
  890.     if(object=(Object *)DoSuperMethodA(cl,object,msg))
  891.     {
  892.         BOOPSI_InitData
  893.  
  894.         switch (what)
  895.         {
  896.         case    SIZEIMAGE:
  897.         case    LEFTIMAGE:
  898.         case    RIGHTIMAGE:
  899.         case    UPIMAGE:
  900.         case    DOWNIMAGE:
  901.             SetAttrs(object,IA_Width,b_width,IA_Height,b_height,TAG_DONE);
  902.             break;
  903.         case    CLOSEIMAGE:
  904.         case    ZOOMIMAGE:
  905.         case    DEPTHIMAGE:
  906.             {
  907.                 LONG    tmp;
  908.                 GetAttr(IA_Height,object,&tmp);
  909.                 if(tmp)  SetAttrs(object,IA_Height,tmp+(b_top-2),TAG_DONE);
  910.             }
  911.             break;
  912.         }
  913.         data->what=what;
  914.     }
  915.     return(object);
  916.     }
  917.     BOOPSI_Method_End
  918.  
  919.     BOOPSI_Method(IM_DRAW)
  920.     {
  921.     struct  impDraw     *imsg;
  922.  
  923.     BOOPSI_InitData;
  924.  
  925.     if((imsg=(struct impDraw *)msg)->imp_DrInfo)
  926.     {
  927.         if(imsg->imp_DrInfo->dri_Version==NEWDRIVERSION)
  928.         {
  929.         switch (data->what)
  930.         {
  931.             case    CHECKIMAGE:
  932.             case    MXIMAGE:
  933.                 {
  934.                 UWORD   minx,miny,maxx,maxy;
  935.                 struct  RastPort    *rp=imsg->imp_RPort;
  936.                 UWORD   *pens=imsg->imp_DrInfo->dri_Pens;
  937.                 minx=imsg->imp_Offset.X+((struct Image *)object)->LeftEdge;
  938.                 miny=imsg->imp_Offset.Y+((struct Image *)object)->TopEdge;
  939.                 maxx=minx+((struct Image *)object)->Width-1;
  940.                 maxy=miny+((struct Image *)object)->Height-1;
  941.                 if(XStyle)
  942.                 {
  943.                     if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  944.                     else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHINEPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  945.                 }
  946.                 else
  947.                 {
  948.                     if(imsg->imp_State==IDS_SELECTED) draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[HALFSHADOWPEN],pens[SHINEPEN],pens[HALFSHINEPEN],TRUE);
  949.                     else                              draw_frame (rp,minx,miny,maxx,maxy,pens[SHADOWPEN],pens[SHADOWPEN],pens[SHINEPEN],pens[HALFSHADOWPEN],pens[HALFSHINEPEN],TRUE);
  950.                 }
  951.                 if(imsg->imp_State==IDS_SELECTED)
  952.                 {
  953.                     SetAPen(rp,pens[FILLPEN]);
  954.                     if(((maxx-minx)<6)&&((maxy-miny)<6)) RectFill(rp,minx+3,miny+3,maxx-3,maxy-3);
  955.                 }
  956.                 }
  957.                 return(TRUE);
  958.                 break;
  959.             default:
  960.                 if(sysihackstyle)
  961.                 {
  962.                 return(DrawSysiHack(data,imsg,object,cl,msg));
  963.                 }
  964.                 else
  965.                 {
  966.                 return(DrawUrou(data,imsg,object,cl,msg));
  967.                 }
  968.                 break;
  969.         }
  970.         }
  971.     }
  972.     BOOPSI_Method_SuperReturn;
  973.     }
  974.     BOOPSI_Method_End
  975.  
  976.     BOOPSI_Method_SuperDefault
  977. BOOPSI_End
  978.  
  979. /************************************************************************/
  980. /* Patched functions                                                    */
  981. /************************************************************************/
  982.  
  983. ULONG  oldOTLRoutine;
  984. extern newOTLRoutine();
  985. ULONG  oldOSRoutine;
  986. extern newOSRoutine();
  987. ULONG  oldOWTLRoutine;
  988. extern newOWTLRoutine();
  989. ULONG  oldOWRoutine;
  990. extern newOWRoutine();
  991.  
  992. fail()
  993. {
  994.     PutStr("uRøURAçK SUCKS! Please run it before any screen was opened or IPrefs was started!");
  995.     exit(0);
  996. }
  997.  
  998. enum{SCRFIL,WIN_TOP,WIN_BOT,WIN_LEF,WIN_RIG,FINBOT,FINRIG,PATFRAME,PATSYSI,ONLYWIN,TRYMWB,SYSISTYLE,XWIN,ARG_COUNT};
  999. #define ARGTEMPLATE "SCREENFILE/M,WINDOW_TOP/K/N,WINDOW_BOTTOM/K/N,WINDOW_LEFT/K/N,WINDOW_RIGHT/K/N,FINE_BOTTOM/K/N,FINE_RIGHT/K/N,NOFRAMEPATCH/S,NOSYSIPATCH/S,ONLYWINDOWIMAGES/S,TRYMAGICWB/S,SYSIHACKSTYLE/S,XWINSTYLE/S"
  1000.  
  1001. enum{SCRNAME,SCRPEN1,SCRPEN2,SCRPEN3,SCRPEN4,ALLMWB,SCRARG_COUNT};
  1002. #define SCRARGTMPL "SCREEN,PEN1/N,PEN2/N,PEN3/N,PEN4/N,ALLOCATEMWB/S"
  1003.  
  1004. getscreenlist(char *filename)
  1005. {
  1006.     BPTR    file;
  1007.     STRPTR  *ArgArray;
  1008.     char    *line,*name;
  1009.  
  1010.     if(line=(char *)AllocVec(256L,MEMF_CLEAR))
  1011.     {
  1012.     if(file=(BPTR)Open(filename,MODE_OLDFILE))
  1013.     {
  1014.         int i=0;
  1015.         while(FGets(file,line,255))
  1016.         {
  1017.         i++;
  1018.         if(penlist[i]=(struct NewPenStruct *)AllocVec(sizeof(struct NewPenStruct),MEMF_CLEAR))
  1019.         {
  1020.             if(ArgArray = (STRPTR *)AllocVec((sizeof(STRPTR) * (SCRARG_COUNT)) + 16L,MEMF_ANY|MEMF_CLEAR))
  1021.             {
  1022.             struct RDArgs *rd;
  1023.             if(rd=(struct RDArgs *)AllocDosObject(DOS_RDARGS,TAG_DONE))
  1024.             {
  1025.                 rd->RDA_Source.CS_Buffer=line;
  1026.                 rd->RDA_Source.CS_Length=strlen(line);
  1027.                 rd->RDA_Source.CS_CurChr=0L;
  1028.  
  1029.                 if(ReadArgs(SCRARGTMPL,(LONG *)ArgArray,rd))
  1030.                 {
  1031.                 if(ArgArray[SCRNAME])
  1032.                 {
  1033.                     if(name = (char *)((LONG *)ArgArray[SCRNAME]))
  1034.                     {
  1035.                     if(namelist[i]=(char *)AllocVec(strlen(name)+4L,0L))
  1036.                     {
  1037.                         strcpy(namelist[i],name);
  1038.                     }
  1039.                     }
  1040.                 }
  1041.                 if(ArgArray[SCRPEN1])
  1042.                 {
  1043.                     penlist[i]->halfdark   = (UWORD)(*(LONG *)ArgArray[SCRPEN1])&0xFFFF;
  1044.                 }
  1045.                 if(ArgArray[SCRPEN2])
  1046.                 {
  1047.                     penlist[i]->halfshine  = (UWORD)(*(LONG *)ArgArray[SCRPEN2])&0xFFFF;
  1048.                 }
  1049.                 if(ArgArray[SCRPEN3])
  1050.                 {
  1051.                     penlist[i]->darkpaint  = (UWORD)(*(LONG *)ArgArray[SCRPEN3])&0xFFFF;
  1052.                 }
  1053.                 if(ArgArray[SCRPEN4])
  1054.                 {
  1055.                     penlist[i]->shinepaint = (UWORD)(*(LONG *)ArgArray[SCRPEN4])&0xFFFF;
  1056.                 }
  1057.                 if(ArgArray[ALLMWB])
  1058.                 {
  1059.                     exttrymwb[i]=TRUE;
  1060.                 }
  1061.                 FreeArgs(rd);
  1062.                 }
  1063.                 FreeDosObject(rd);
  1064.             }
  1065.             FreeVec(ArgArray);
  1066.             }
  1067.         }
  1068.         }
  1069.         Close(file);
  1070.     }
  1071.     else PutStr("Could not open file...");
  1072.     FreeVec(line);
  1073.     }
  1074. }
  1075.  
  1076. getconfig()
  1077. {
  1078.     STRPTR  *ArgArray;
  1079.     if(ArgArray = (STRPTR *)AllocVec((sizeof(STRPTR) * (ARG_COUNT)) + 16L,MEMF_ANY|MEMF_CLEAR))
  1080.     {
  1081.     struct RDArgs *rd;
  1082.     if(rd=(struct RDArgs *)AllocDosObject(DOS_RDARGS,TAG_DONE))
  1083.     {
  1084.         if(ReadArgs(ARGTEMPLATE,(LONG *)ArgArray,rd))
  1085.         {
  1086.         if(ArgArray[SCRFIL])
  1087.         {
  1088.             if((char *)(*(LONG *)ArgArray[SCRFIL]))
  1089.             {
  1090.             getscreenlist((char *)(*(LONG *)ArgArray[SCRFIL]));
  1091.             }
  1092.         }
  1093.         if(ArgArray[WIN_TOP])
  1094.         {
  1095.             b_top = (BYTE)(*(LONG *)ArgArray[WIN_TOP])&0xFF;
  1096.         }
  1097.         if(ArgArray[WIN_BOT])
  1098.         {
  1099.             b_bottom = (BYTE)(*(LONG *)ArgArray[WIN_BOT])&0xFF;
  1100.         }
  1101.         if(ArgArray[WIN_LEF])
  1102.         {
  1103.             b_left = (BYTE)(*(LONG *)ArgArray[WIN_LEF])&0xFF;
  1104.         }
  1105.         if(ArgArray[WIN_RIG])
  1106.         {
  1107.             b_right = (BYTE)(*(LONG *)ArgArray[WIN_RIG])&0xFF;
  1108.         }
  1109.         if(ArgArray[FINBOT])
  1110.         {
  1111.             b_height = (*(LONG *)ArgArray[FINBOT])&0xFF;
  1112.         }
  1113.         if(ArgArray[FINRIG])
  1114.         {
  1115.             b_width = (*(LONG *)ArgArray[FINBOT])&0xFF;
  1116.         }
  1117.         if(ArgArray[PATFRAME])
  1118.         {
  1119.             pframes=FALSE;
  1120.         }
  1121.         if(ArgArray[PATSYSI])
  1122.         {
  1123.             psysi=FALSE;
  1124.         }
  1125.         if(ArgArray[ONLYWIN])
  1126.         {
  1127.             pwin=FALSE;
  1128.         }
  1129.         if(ArgArray[TRYMWB])
  1130.         {
  1131.             trymwb=TRUE;
  1132.         }
  1133.         if(ArgArray[SYSISTYLE])
  1134.         {
  1135.             sysihackstyle=TRUE;
  1136.         }
  1137.         if(ArgArray[XWIN])
  1138.         {
  1139.             XStyle=TRUE;
  1140.         }
  1141.         FreeArgs(rd);
  1142.         }
  1143.         FreeDosObject(rd);
  1144.     }
  1145.     FreeVec(ArgArray);
  1146.     }
  1147. }
  1148.  
  1149. void main(int argc, char *argv[])
  1150. {
  1151.     UWORD   pens[8];
  1152.     struct  TextAttr topaz_font = { "topaz.font", 8, 0, FPF_ROMFONT, };
  1153.     struct  DrawInfo mydrawinfo = { DRI_VERSION, 9, &pens[BACKGROUNDPEN], 0, 2, 1, 1, NULL, NULL, NULL, 0, 0, 0, 0, 0 };
  1154.     Class   *my_cl,*oldcl;
  1155.     Object  *g;
  1156.  
  1157.     getconfig();
  1158.  
  1159.     if(pframes)
  1160.     {
  1161.     Forbid();
  1162.     oldOTLRoutine = SetFunction(IntuitionBase,(WORD)-612,newOTLRoutine);
  1163.     oldOSRoutine  = SetFunction(IntuitionBase,(WORD)-198,newOSRoutine);
  1164.     Permit();
  1165.  
  1166.     if( g=(Object *)NewObject(NULL,"frameiclass",IA_Width,10,IA_Height,10, TAG_END))
  1167.     {
  1168.         oldcl=OCLASS(g); DisposeObject(g);
  1169.         Forbid();
  1170.  
  1171.         oldcl->cl_ID="breizhclass";
  1172.  
  1173.         if(my_cl=initFRAMEClass())
  1174.         {
  1175.         AddClass(my_cl);
  1176.         Permit();
  1177.         }
  1178.         else fail();
  1179.     }
  1180.     else fail();
  1181.     }
  1182.     if(psysi)
  1183.     {
  1184.     mydrawinfo.dri_Font=(struct TextFont *)OpenFont(&topaz_font);
  1185.  
  1186.     Forbid();
  1187.     oldOWTLRoutine= SetFunction(IntuitionBase,(WORD)-606,newOWTLRoutine);
  1188.     oldOWRoutine  = SetFunction(IntuitionBase,(WORD)-204,newOWRoutine);
  1189.     Permit();
  1190.  
  1191.     if( g=(Object *)NewObject(NULL, "sysiclass", SYSIA_Which, RIGHTIMAGE, SYSIA_DrawInfo, &mydrawinfo, TAG_END))
  1192.     {
  1193.         oldcl=OCLASS(g); DisposeObject(g);
  1194.         Forbid();
  1195.  
  1196.         oldcl->cl_ID="urouclass";
  1197.  
  1198.         if(my_cl=initSYSIClass())
  1199.         {
  1200.         AddClass(my_cl);
  1201.         Permit();
  1202.         }
  1203.         else fail();
  1204.     }
  1205.     else fail();
  1206.     if( g=(Object *)NewObject(NULL,"buttongclass",GA_Width,10,GA_Height,10,TAG_END))
  1207.     {
  1208.         oldcl=OCLASS(g); DisposeObject(g);
  1209.         Forbid();
  1210.  
  1211.         oldcl->cl_ID="tinicclass";
  1212.  
  1213.         if(my_cl=initGADClass())
  1214.         {
  1215.         AddClass(my_cl);
  1216.         Permit();
  1217.         }
  1218.         else fail();
  1219.     }
  1220.     else fail();
  1221.     }
  1222.     if(Cli()) ((struct CommandLineInterface *)Cli())->cli_Module=0L; /* That wwas a good tip ;-)) */
  1223.     else      Wait(0L); /* for the security */
  1224. }
  1225.  
  1226.