예제 #1
0
파일: demo.cpp 프로젝트: GustavoMOG/efltk
int main(int argc, char **argv)
{
    Fl_Button::default_style->box = FL_PLASTIC_BOX;

    create_the_forms();

    // Add tiled image as window background
    Fl_Image *tile = Fl_Image::read_xpm(0, tile_xpm);
    form->image(tile);
    form->align(FL_ALIGN_TILED);

    char buf[256];
    strcpy(buf, argv[0]);
    fl_file_setext(buf,".menu");
    const char *fname = buf;
    int i = 0;
    if (!Fl::args(argc,argv,i) || i < argc-1)
        Fl::fatal("Usage: %s <switches> <menufile>\n%s",Fl::help);
    if (i < argc) fname = argv[i];
    if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
    strcpy(buf,fname);
    const char *c = fl_file_filename(buf);
    if (c > buf) {buf[c-buf] = 0; chdir(buf);}
    push_menu("@main");
    form->show(argc,argv);
    Fl::run();

    return 0;
}
예제 #2
0
파일: demo.cpp 프로젝트: GustavoMOG/efltk
void pop_menu()
/* Pops a menu */
{
  if (stsize<=1) return;
  stsize -= 2;
  push_menu(stack[stsize]);
}
예제 #3
0
파일: main.c 프로젝트: hharte/vttest
int
menu2(MENU *table, int top)
{
  int i, tablesize, choice;
  char c;
  char storage[BUFSIZ];
  int pagesize = max_lines - 7 - TITLE_LINE;
  int pagetop = 1;
  int redraw = FALSE;

  tablesize = 0;
  for (i = 0; !end_of_menu(table, i); i++) {
    tablesize++;
  }
  tablesize--;

  for (;;) {
    vt_move(top, 1);
    vt_clear(0);

    println("");
    show_entry(table, 0);
    for (i = 0; i < pagesize; i++) {
      int j = pagetop + i;
      if (end_of_menu(table, j))
        break;
      show_entry(table, pagetop + i);
    }

    printf("\n          Enter choice number (0 - %d): ", tablesize);
    for (;;) {
      char *s = storage;
      inputline(s);
      choice = 0;
      redraw = FALSE;
      while ((c = *s++) != '\0') {
        if (c == '*') {
          choice = -1;
          break;
        } else if (c == '?') {
          redraw = TRUE;
          break;
        } else if (tablesize > pagesize && c == 'n') {
          pagetop = next_menu(table, pagetop, pagesize);
          redraw = TRUE;
          break;
        } else if (tablesize > pagesize && c == 'p') {
          pagetop = prev_menu(pagetop, pagesize);
          redraw = TRUE;
          break;
        } else if (c >= '0' && c <= '9') {
          choice = 10 * choice + c - '0';
        } else {
          choice = tablesize + 1;
          break;
        }
      }

      if (redraw)
        break;

      if (choice < 0) {
        for (choice = 0; choice <= tablesize; choice++) {
          vt_clear(2);
          if (table[choice].dispatch != 0) {
            const char *save = push_menu(choice);
            const char *name = table[choice].description;
            if (LOG_ENABLED)
              fprintf(log_fp, "Menu %s: %s\n", current_menu, name);
            if ((*table[choice].dispatch) (name) == MENU_HOLD)
              holdit();
            pop_menu(save);
          }
        }
        return 1;
      } else if (choice <= tablesize) {
        vt_clear(2);
        if (table[choice].dispatch != 0) {
          const char *save = push_menu(choice);
          const char *name = table[choice].description;
          if (LOG_ENABLED)
            fprintf(log_fp, "Menu %s: %s\n", current_menu, name);
          if ((*table[choice].dispatch) (name) != MENU_NOHOLD)
            holdit();
          pop_menu(save);
        }
        return (table[choice].dispatch != 0);
      }
      printf("          Bad choice, try again: ");
    }
  }
}
예제 #4
0
void
MenuManager::push_menu(int id)
{
  push_menu(MenuStorage::instance().create(static_cast<MenuStorage::MenuId>(id)));
}
예제 #5
0
파일: demo.cpp 프로젝트: GustavoMOG/efltk
void dobut(Fl_Widget *, long arg)
/* handles a button push */
{
  int men = find_menu(stack[stsize-1]);
  int n = menus[men].numb;
  int bn = but2numb( (int) arg, n-1);
  if (menus[men].icommand[bn][0] == '@')
    push_menu(menus[men].icommand[bn]);
  else {

#ifdef _WIN32
    STARTUPINFO		suInfo;		// Process startup information
    PROCESS_INFORMATION	prInfo;		// Process information

    memset(&suInfo, 0, sizeof(suInfo));
    suInfo.cb = sizeof(suInfo);

    int icommand_length = strlen(menus[men].icommand[bn]);

    char* copy_of_icommand = new char[icommand_length+1];
    strcpy(copy_of_icommand,menus[men].icommand[bn]);

    // On _WIN32 the .exe suffix needs to be appended to the command
    // whilst leaving any additional parameters unchanged - this
    // is required to handle the correct conversion of cases such as : 
    // `../fluid/fluid valuators.fl' to '../fluid/fluid.exe valuators.fl'.

    // skip leading spaces.
    char* start_command = copy_of_icommand;
    while(*start_command == ' ') ++start_command;

    // find the space between the command and parameters if one exists.
    char* start_parameters = strchr(start_command,' ');

    char* command = new char[icommand_length+6]; // 6 for extra 'd.exe\0'

    if (start_parameters==NULL) { // no parameters required.
#  ifdef _DEBUG
      sprintf(command, "%sd.exe", start_command);
#  else
      sprintf(command, "%s.exe", start_command);
#  endif // _DEBUG
    } else { // parameters required.
      // break the start_command at the intermediate space between
      // start_command and start_parameters.
      *start_parameters = 0;
      // move start_paremeters to skip over the intermediate space.
      ++start_parameters;

#  ifdef _DEBUG
      sprintf(command, "%sd.exe %s", start_command, start_parameters);
#  else
      sprintf(command, "%s.exe %s", start_command, start_parameters);
#  endif // _DEBUG
    }

    CreateProcess(NULL, command, NULL, NULL, FALSE,
                  NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo);
	
    delete command;
    delete copy_of_icommand;
	
#else // NON _WIN32 systems.

    int icommand_length = strlen(menus[men].icommand[bn]);
    char* command = new char[icommand_length+5]; // 5 for extra './' and ' &\0' 

    sprintf(command, "./%s &", menus[men].icommand[bn]);
    system(command);

    delete command;
#endif // _WIN32
  }
}