1 /*********************************************************** 2 * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby. 3 * 4 * This program is freely distributable without licensing fees 5 * and is provided without guarantee or warrantee expressed or 6 * implied. This program is -not- in the public domain. 7 * 8 * FILE: glutMenu.h 9 * 10 * DESCRIPTION: the GlutMenu class is a simple popup menu 11 ***********************************************************/ 12 13 /*********************************************************** 14 * Headers 15 ***********************************************************/ 16 #include <GL/glut.h> 17 #include <Menu.h> 18 #include <MenuItem.h> 19 #include <PopUpMenu.h> 20 21 /*********************************************************** 22 * Definitions 23 ***********************************************************/ 24 const int32 MENU_ITEM = 'menu'; 25 26 /*********************************************************** 27 * CLASS: GlutMenu 28 ***********************************************************/ 29 class GlutMenuItem; 30 class GlutPopUp; 31 class GlutMenu { 32 public: 33 GlutMenu(int n_id, GLUTselectCB n_select) { 34 id = n_id; 35 select = n_select; 36 list = 0; 37 num = 0; 38 } 39 ~GlutMenu(); 40 BMenu *CreateBMenu(bool toplevel=true); // construct BPopUpMenu 41 42 // public data 43 int id; 44 GLUTselectCB select; // callback function 45 GlutMenuItem *list; // list of menu items 46 int num; // number of items 47 }; 48 49 /*********************************************************** 50 * CLASS: GlutMenuItem 51 ***********************************************************/ 52 class GlutMenuItem { 53 public: 54 GlutMenuItem(GlutMenu *n_menu, bool n_trig, int n_value, const char *n_label); 55 56 // public data 57 GlutMenu *menu; // parent menu 58 bool isTrigger; // are we a submenu? 59 int value; // value to send, or submenu id if isTrigger 60 char *label; // strdup'ed label string 61 GlutMenuItem *next; // next menu entry on list 62 }; 63 64 /*********************************************************** 65 * CLASS: GlutPopUp 66 ***********************************************************/ 67 class GlutPopUp : public BPopUpMenu { 68 public: 69 GlutPopUp(int m) : BPopUpMenu(0, false, false) { menu = m;} 70 71 BPoint point; // point to start menu 72 GlutWindow *win; // pointer to my window 73 int menu; // my menu number 74 }; 75 76 /*********************************************************** 77 * CLASS: GlutBMenuItem 78 ***********************************************************/ 79 class GlutBMenuItem : public BMenuItem { 80 public: 81 GlutBMenuItem(const char *name) : BMenuItem(name, 0) {} 82 GlutBMenuItem(BMenu* menu) : BMenuItem(menu) {} 83 int menu, value; 84 }; 85