home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 580a.lha / HDFView_v3.01 / source.LZH / source / src / showPalette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-03  |  2.1 KB  |  122 lines

  1. #include <stdio.h>
  2. #include <exec/types.h>
  3. #include <intuition/intuition.h>
  4. #include <graphics/rastport.h>
  5. #include <graphics/gfxmacros.h>
  6. #include <proto/intuition.h>
  7. #include <proto/graphics.h>
  8. #include <proto/exec.h>
  9.  
  10. #include  "hame.h"
  11. #include "View_Define.h"
  12. #include "ViewProtos.h"
  13.  
  14. extern float min, max;
  15. extern struct HamePort *hamePort;
  16. extern struct Library *HameBase;
  17. extern struct TextAttr textAttr;
  18.  
  19. /* NewWindow structure for palette window */
  20.  
  21. struct NewWindow NW = 
  22. {
  23.    1, 1,
  24.    256, 26,
  25.    0, 0,
  26.    ACTIVEWINDOW,
  27.    WINDOWDRAG|SMART_REFRESH|BORDERLESS,
  28.    NULL,
  29.    NULL,
  30.    NULL,
  31.    NULL,
  32.    NULL,
  33.    0,0,
  34.    0,0,
  35.    CUSTOMSCREEN
  36. };
  37.  
  38. struct IntuiText it2 = {
  39.       15, 0,
  40.       JAM1,
  41.       8, 10,
  42.       &textAttr,
  43.       "Some string",
  44.       NULL
  45. };
  46.  
  47. extern struct MsgPort *messagePort; 
  48. extern int isscale;
  49.    
  50. /* Show the palette window */
  51. struct Window *
  52. showScale(struct Screen *s, int mode)
  53. {
  54.    int   i,j;
  55.    struct Window *sw;
  56.    
  57.    if(max > min) NW.Height = 46;
  58.    else NW.Height = 26; 
  59.    
  60.    
  61.          
  62.    NW.Screen = s;
  63.    NW.LeftEdge = s->Width/2 - 128;
  64.    NW.Width = 256;
  65.    if( (mode==HAME) || (mode==HAME_LACE) )
  66.    {
  67.        NW.LeftEdge=64;
  68.        NW.Width=512;
  69.        NW.TopEdge=11;
  70.    }
  71.       
  72.    sw = OpenWindow(&NW);
  73.    if(sw == NULL) myExit("Can't Open Scale Window");
  74.    isscale=1;
  75.    
  76.    if(sw->UserPort) DeletePort(sw->UserPort);
  77.    sw->UserPort = messagePort;
  78.    ModifyIDCMP(sw,INACTIVEWINDOW|MOUSEBUTTONS);
  79.  
  80. if( (mode==COLORS_32) || (mode==COLORS_LACE_32) )
  81.        for(i=0;i<256;i++)
  82.     {
  83.       SetAPen(sw->RPort,i/8);
  84.       RectFill(sw->RPort,i,SYSGADHEIGHT,i,26);
  85.     }
  86. }
  87.  
  88. if( (mode==COLORS_16) || (mode==COLORS_LACE_16) )
  89. {
  90.       for(i=0;i<256;i++)
  91.     {
  92.       SetAPen(sw->RPort,i/16);
  93.       RectFill(sw->RPort,i,SYSGADHEIGHT,i,26);
  94.     }
  95. }
  96.  
  97. if( (mode==HAME) || (mode==HAME_LACE) )
  98. {
  99.       
  100.       for(i=0;i<256;i++)
  101.       {
  102.          HAME_SetAPen(hamePort,i);
  103.          for(j=11;j<27;j++) HAME_WriteWPixel(hamePort,sw,i,j);
  104.       }
  105.       
  106. }
  107.  
  108. if(max>min)
  109. {
  110.    sprintf(it2.IText,"Min: %3.2e",min);
  111.    PrintIText(sw->RPort,&it2,4,25);
  112.    sprintf(it2.IText,"Max: %3.2e",max);
  113.    PrintIText(sw->RPort,&it2,144,25);
  114. }
  115.     
  116.    
  117.    return(sw);
  118. }
  119.  
  120.  
  121.