Creating Menus

#include <stdio.h>
#include "graphapp.h"

void undo(MenuItem *m)  { printf("Undo!\n"); }
void cut(MenuItem *m)   { printf("Cut!\n"); }
void copy(MenuItem *m)  { printf("Copy!\n"); }
void paste(MenuItem *m) { printf("Paste!\n"); }
  
void quit(MenuItem *m) {
  printf("Quit!\n");
  exit(0);
}

int main(int argc, char *argv[])
{
  App *app;
  Window *w;
  MenuBar *mb;
  Menu *m[2];
  MenuItem *i[10];

  app = new_app(argc, argv);
  w = new_window(app, rect(100,100,500,400),
                "Menu Test", STANDARD_WINDOW);

  mb = new_menu_bar(w);

  m[0] = new_menu(mb, "File");
  i[0] = new_menu_item(m, "Quit",  'Q', quit);

  m[1] = new_menu(mb, "Edit");
  i[1] = new_menu_item(m, "Undo",  'U', undo);
  i[2] = new_menu_item(m, "-",      0,  NULL);
  i[3] = new_menu_item(m, "Cut",   'X', cut);
  i[4] = new_menu_item(m, "Copy",  'C', copy);
  i[5] = new_menu_item(m, "Paste", 'V', paste);

  disable_menu_item(i[1]);

  show_window(w);
  main_loop(app);
  return 0;
}

Notes: