예제 #1
0
//Opens a new window
void MenuNew(list *FileBuffer, WINDOW *my_menu_win, MENU *my_menu){
	int j;
	MenuExit(FileBuffer, my_menu_win);
	 
	clrtoeol();
	refresh();	
	main();
	exit(1);
}
예제 #2
0
static pascal OSErr QuitApplicationAE( const AppleEvent * theAppleEvent,
	AppleEvent * reply, SInt32 handlerRefcon) {
    static int first_time = true;

 fprintf( logfile, "QUIT event received.\n" ); fflush( logfile );
    quit_event = reply;
    if ( first_time ) {
	atexit( we_are_dead );
	first_time = false;
    }
    MenuExit(NULL,NULL,NULL);
    /* if we get here, they canceled the quit, so we return a failure */
    quit_event = NULL;
 fprintf( logfile, " event failed %d.\n", errAEEventFailed ); fflush( logfile );
return(errAEEventFailed);
}
예제 #3
0
static int splash_e_h(GWindow gw, GEvent *event) {
    static int splash_cnt;
    GRect old;
    int i, y, x;
    static char *foolishness[] = {
/* GT: These strings are for fun. If they are offensive or incomprehensible */
/* GT: simply translate them as something dull like: "FontForge" */
/* GT: This is a spoof of political slogans, designed to point out how foolish they are */
	    N_("A free press discriminates\nagainst the illiterate."),
	    N_("A free press discriminates\nagainst the illiterate."),
/* GT: This is a pun on the old latin drinking song "Gaudeamus igature!" */
	    N_("Gaudeamus Ligature!"),
	    N_("Gaudeamus Ligature!"),
/* GT: Spoof on the bible */
	    N_("In the beginning was the letter..."),
/* GT: Some wit at MIT came up with this ("ontology recapitulates phylogony" is the original) */
	    N_("fontology recapitulates file-ogeny")
    };

    switch ( event->type ) {
      case et_create:
	GDrawGrabSelection(gw,sn_user1);
      break;
      case et_expose:
	GDrawPushClip(gw,&event->u.expose.rect,&old);
	GDrawDrawImage(gw,&splashimage,NULL,0,0);
	GDrawSetFont(gw,splash_font);
	y = splashimage.u.image->height + as + fh/2;
	for ( i=1; i<linecnt; ++i ) {
	    if ( is>=lines[i-1]+1 && is<lines[i] ) {
		x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,is-lines[i-1]-1,0x000000);
		GDrawSetFont(gw,splash_italic);
		GDrawDrawText(gw,x,y,is,lines[i]-is,0x000000);
	    } else if ( ie>=lines[i-1]+1 && ie<lines[i] ) {
		x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,ie-lines[i-1]-1,0x000000);
		GDrawSetFont(gw,splash_font);
		GDrawDrawText(gw,x,y,ie,lines[i]-ie,0x000000);
	    } else
		GDrawDrawText(gw,8,y,lines[i-1]+1,lines[i]-lines[i-1]-1,0x000000);
	    y += fh;
	}
	GDrawPopClip(gw,&old);
      break;
      case et_map:
	splash_cnt = 0;
      break;
      case et_timer:
	if ( event->u.timer.timer==autosave_timer ) {
	    DoAutoSaves();
	} else if ( event->u.timer.timer==splasht ) {
	    if ( ++splash_cnt==1 )
		GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height-30);
	    else if ( splash_cnt==2 )
		GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height);
	    else if ( splash_cnt>=7 ) {
		GGadgetEndPopup();
		GDrawSetVisible(gw,false);
		GDrawCancelTimer(splasht);
		splasht = NULL;
	    }
	} else {
	    DoDelayedEvents(event);
	}
      break;
      case et_char:
      case et_mousedown:
      case et_close:
	GGadgetEndPopup();
	GDrawSetVisible(gw,false);
      break;
      case et_mousemove:
	GGadgetPreparePopup8(gw,_(foolishness[rand()%(sizeof(foolishness)/sizeof(foolishness[0]))]) );
      break;
      case et_selclear:
	/* If this happens, it means someone wants to send us a message with a*/
	/*  filename to open. So we need to ask for it, process it, and then  */
	/*  take the selection back again */
	if ( event->u.selclear.sel == sn_user1 ) {
	    int len;
	    char *arg;
	    arg = GDrawRequestSelection(splashw,sn_user1,"STRING",&len);
	    if ( arg==NULL )
return( true );
	    if ( strcmp(arg,"-new")==0 || strcmp(arg,"--new")==0 )
		FontNew();
	    else if ( strcmp(arg,"-open")==0 || strcmp(arg,"--open")==0 )
		_FVMenuOpen(NULL);
	    else if ( strcmp(arg,"-quit")==0 || strcmp(arg,"--quit")==0 )
		MenuExit(NULL,NULL,NULL);
	    else
		ViewPostScriptFont(arg,0);
	    free(arg);
	    GDrawGrabSelection(splashw,sn_user1);
	}
      break;
      case et_destroy:
	IError("Who killed the splash screen?");
      break;
    }
return( true );
}
예제 #4
0
int main(){

	WINDOW *my_win, *menu_win, *my_menu_win;
	ITEM **my_items;
	MENU *my_menu;
	list *FileBuffer;
	
	int height, width, startx, starty, exit = 0;
	int highlight = 1;
	int ch, c, choice = 0, i, j;
	char str[81];
	
	FileBuffer = (list *)malloc(sizeof(list));
	
	
	if (FileBuffer == NULL)
		return;
	
	InitialiseBuffer(FileBuffer);
	
	initscr();
	clear();
	noecho();
	cbreak();
	
	start_color();
	
	
	/*Checking whether the terminal supports colors*/
	if (has_colors() == FALSE){
		endwin();
		printf("Your terminal does not support colors\n");
	}
		
	
	keypad(stdscr, TRUE);
	
	height = 3;
	width = 10;
	starty = (LINES - height)/2;
	startx = (COLS - width) / 2;	

	refresh();
	
	my_win = Create_NewWindow(height, width, starty, startx);

	mvwhline(my_win, 5, 1,	ACS_HLINE, width - 1);
	
	init_pair(1, COLOR_RED, COLOR_BLACK);
	init_pair(2, COLOR_CYAN, COLOR_BLACK);
	
	/* Create items */
    my_items = (ITEM **)calloc(nchoices, sizeof(ITEM *));
    for(i = 0; i < nchoices; ++i)
    	my_items[i] = new_item(menu_options[i], menu_options[i]);

	/* Create menu */	
	my_menu = new_menu((ITEM **)my_items);

	/* Set menu option not to show the description */
	menu_opts_off(my_menu, O_SHOWDESC);

	/* Create the window to be associated with the menu */
    my_menu_win = newwin(0, 0, 0, 0);
    keypad(my_menu_win, TRUE);
     
	/* Set main window and sub window */
    set_menu_win(my_menu, my_menu_win);
	set_menu_sub(my_menu, derwin(my_menu_win, 0, 0, 0, 0));
 	set_menu_format(my_menu, 1, 6);
	set_menu_mark(my_menu, " * ");


	/* Post the menu */
	post_menu(my_menu);
	wrefresh(my_menu_win);
	
	i = 0;
		
	mvwhline(my_menu_win, 1, 0, ACS_HLINE, COLS);
	mvwprintw(my_menu_win, LINES - 1, 0, "Press F3 to go to the menu, F6 to exit", c);
	
	
	while(1){
		choice = ToggleMenu(my_menu_win, my_menu, i);
		i = choice;
		switch(choice){
			case 0:
				MenuOpen(FileBuffer, my_menu_win);
				break;
			case 1:
				MenuNew(FileBuffer, my_menu_win, my_menu);
				break;
			case 2:
				MenuSave(FileBuffer, my_menu_win);
				break;
			case 3:
				MenuSaveAs(FileBuffer, my_menu_win);
				break;
			case 4:
				MenuEdit(FileBuffer, my_menu_win);
				break;
			case 5:
				MenuExit(FileBuffer, my_menu_win);
				exit = 1;
				break;
			default:
				break;
		}
		if (exit)
			break;
	}
	/*Assertion: the user wants to exit the program*/
    
		
	/* Unpost and free all the memory taken up */
       unpost_menu(my_menu);
       free_menu(my_menu);
       for(j = 0; j < nchoices; ++j)
               free_item(my_items[j]);
                
	clrtoeol();
	refresh();	
	
	/*Ending curses mode*/
	
	endwin();		
	return 0;
}