home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / tutorials / geometer / pulldown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.4 KB  |  81 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #include <gl.h>
  19. #include <device.h>
  20. #include "generic.h"
  21. #include "cmds.h"
  22. #include "showcaseui.h"
  23.  
  24. /* pulldown.c makes a pull-down menu bar across the top of the
  25.  * application.  It has a File menu and a Help menu.  In addition, 
  26.  * it has an Edit menu with one 'Touch' entry for the benefit of
  27.  * the generic application.  If you don't want a pull-down, get
  28.  * rid of this file, and the external calls to makepulldown(), 
  29.  * remakepulldown(),  and to pulldonwevent();
  30.  */
  31.  
  32. #define MENUCOUNT   3
  33.  
  34. static PullDown    *menu[MENUCOUNT];
  35. static MenuBar  *mb = 0;
  36.  
  37. long uiinited = 0;  /* in case you're using libui.a */
  38.  
  39. void makepulldown()
  40. {
  41.     if (!uiinited) {
  42.         uiinited = 1;
  43.     initui();
  44.     }
  45.     initpd();
  46.     if (mb == 0) mb = newmenubar();
  47.     menu[0] = newpd(mb, "File");
  48.     menu[1] = newpd(mb, "Edit");
  49.     menu[2] = newpd(mb, "Help");
  50.     loadpd(menu[0],"New%x100001%an|Open ...%x100002%ao|Save ...%x100003%as|Save As ...%x100004%aS|Insert ...%x100005|Print%x100006%ap|Print EPS%x100010|Quit%x100007%aq");
  51.     loadpd(menu[1],"Edit Geom %x200038%ae|Delete Seln %x200020%ad|Describe %x200037");
  52.     loadpd(menu[2],"Help%x100008");
  53.     loadmenubar(mb, MENUCOUNT, menu);
  54. }
  55.  
  56. void drawpulldown()
  57. {
  58.     pushviewport();
  59.     viewport(0, (short)(xsize - 1), 0, (short)(ysize - 1));
  60.     savemat();
  61.     ortho2(-0.5, xsize-0.5, -0.5, ysize-0.5);
  62.     if (mb) drawmenubar(mb);
  63.     restoremat();
  64.     popviewport();
  65. }
  66.  
  67. long pulldownevent(long mx, long my)
  68. {
  69.     long selection;
  70.     if (inmenubar(mb, mx, my) != -1) {
  71.         selection = dopulldown(mb);
  72.     return selection;
  73.     }
  74.     return -1;
  75. }
  76.  
  77. void remakepulldown()
  78. {
  79.     if (mb) movemenubar(mb);
  80. }
  81.