home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / GRAPHICS / jpegshow_2.0.lzh / JPEGSHOW / openwin.c < prev    next >
C/C++ Source or Header  |  1995-03-22  |  2KB  |  79 lines

  1. #include <stdio.h>
  2. #include <signal.h>
  3. #include <wind.h>
  4. #include <mouse.h>
  5. #include <signal.h>
  6. #define MAIN
  7. #include <stdmenu.h>
  8. #include <buffs.h>
  9. #include <math.h>
  10.  
  11. #define MS_SIG 200
  12. #define MN_NEXT 30
  13.  
  14. MNDSCR wnmen[] =
  15. {
  16.  {{"Next"}, MN_NEXT, 6, 0, 1}
  17. };
  18.  
  19. WNDSCR windat = {
  20.       "Jpegshow", sizeof(wnmen) / sizeof(wnmen[0]), 40, 10, WINSYNC, wnmen};
  21.  
  22. int wtype = WT_FSWIN | WC_MOVE | WC_GROW;
  23. int gotsig;
  24. int h_pos, v_pos;
  25. MSRET ms;
  26.  
  27. int repaint(int x, int y);
  28.  
  29. openwin(int actwin)
  30. {
  31.    register int mx, my;
  32.    windat._wnmen = wnmen;
  33.  
  34.    Palette(actwin, 251, 100, 100, 100);         /* highlighting */           
  35.    Palette(actwin, 252, 150, 150, 150);         /* shadow       */
  36.    Palette(actwin, 253, 0, 0, 0);               /* background   */
  37.    Palette(actwin, 254, 180, 180, 180);         /* foreground   */
  38.    Palette(actwin, 255, 180, 180, 180);         /* border       */
  39.    Mn_Colors(actwin, 254, 253, 255, 251, 252);
  40.    _ss_wset(actwin, wtype, &windat);
  41.    Select(actwin);
  42.    Font(actwin, GRP_FONT, FNT_G8X8);
  43.    _ss_sbar(actwin, h_pos, v_pos);
  44. }
  45.  
  46. mmenu(int actwin)
  47. {
  48.    int sel, item;
  49.  
  50.    for (;;) {
  51.       _ss_msig(actwin, MS_SIG);
  52.       sleep(0);
  53.       if (gotsig != MS_SIG)
  54.          continue;
  55.       _gs_mouse(actwin, &ms);
  56.       if (ms.pt_area != WR_CNTRL)  /* not control region - ignore */
  57.          continue;
  58.  
  59.       sel = _gs_msel(actwin, &item);
  60.       switch ( sel ) {
  61.       case MN_CLOS: kill(getpid(), SIGINT);
  62.       case MN_NEXT: return;
  63.       case MN_HSCRL: 
  64.                      if ( repaint(item, v_pos) ) {
  65.                         h_pos = item;
  66.                         _ss_sbar(actwin, h_pos, v_pos);
  67.                      }
  68.                      break;
  69.       case MN_VSCRL: 
  70.                      if ( repaint(h_pos, item) ) {
  71.                         v_pos = item;
  72.                         _ss_sbar(actwin, h_pos, v_pos);
  73.                      }
  74.                      break;
  75.       default:
  76.       }
  77.    }
  78. }
  79.