Exemple #1
0
void viper_form_destroy(FORM *form,gboolean free_windows)
{
	WINDOW	*parent;
	WINDOW	*window;
	WINDOW	*subwin;
	FIELD		**fields;
	gint		count;

	unpost_form(form);
	
	window=form_win(form);
	subwin=form_sub(form);
	parent=window->_parent;
		
	count=field_count(form);
	fields=form_fields(form);
	free_form(form);
	
	while(count>0)
	{
		free_field(fields[count-1]);
		count--;
	}
	g_free(fields);

   if(free_windows==FALSE) return;
	
	/*	delete subwin if it is completely independent.	*/
	if(subwin!=parent && subwin!=window && subwin!=NULL) delwin(subwin);
		
	/*	delete window if it is not the parent window.	*/
	if(parent!=NULL && window!=parent && window!=NULL) delwin(window);
			
	return;
}
Exemple #2
0
static FIELD *
another_field(FORM * form, FIELD * field)
{
    FIELD **f = form_fields(form);
    FIELD *result = 0;
    int n;

    for (n = 0; f[n] != 0; ++n) {
	if (f[n] != field) {
	    result = f[n];
	    field_opts_on(result, O_SELECTABLE);
	    break;
	}
    }
    return result;
}
Exemple #3
0
void viper_form_colorize(FORM *form,chtype field_active,chtype field_normal,
   chtype text_active,chtype text_normal)
{
   FIELD **fields;

   fields=form_fields(form);
   while(*fields!=NULL)
   {
      if(*fields==current_field(form))
      {
         set_field_fore(*fields,text_active);
         set_field_back(*fields,field_active);
      }
      else
      {
         set_field_fore(*fields,text_normal);
         set_field_back(*fields,field_normal);
      }
      
      fields++;
   }

   return;
}
Exemple #4
0
char AskResizeMOSAIC (int *new_height, int *new_width) {
	// creates it if not already there
	if (!resizePanel) {
		InitResizeMOSAIC ();
	}

	// current height, to start the buffer
	char height[4];
	sprintf (height, "%3d", *new_height);
	set_field_buffer (form_fields (resize_form)[0], 0, height);
	// current width, to start the buffer
	char width[4];
	sprintf (width, "%3d", *new_width);
	set_field_buffer (form_fields (resize_form)[1], 0, width);

	// display the panel
	show_panel (resizePanel);
	update_panels ();
	doupdate ();

	int c;

	do {
		c = getch ();

		switch (c) {
			// previous
			case KEY_UP:
				form_driver (resize_form, REQ_PREV_FIELD);
				break;

			// neeeext
			case KEY_DOWN:
				form_driver (resize_form, REQ_NEXT_FIELD);
				break;

			// get out, don't create the new image
			case KEY_ESC:
				hide_panel (resizePanel);
				doupdate ();
				return ERR;

			// backspace: start over
			case KEY_BACKSPACE: case 127:
				form_driver (resize_form, REQ_PREV_FIELD);
				form_driver (resize_form, REQ_NEXT_FIELD);
				break;

			// write the dimensions in the field
			default:
				if (isdigit (c)) {	// only allow digits (for the dimensions)
					form_driver (resize_form, c);
				}
				break;
		}

		wrefresh (resizeWindow);
	} while (c != '\n');

	// validate the string (current field doesn't validate by itself)
	form_driver (resize_form, REQ_VALIDATION);

	// get the fields' data
	*new_height = atoi (field_buffer (form_fields (resize_form)[0], 0));
	*new_width = atoi (field_buffer (form_fields (resize_form)[1], 0));

	hide_panel (resizePanel);
	update_panels ();
	doupdate ();

	return OK;
}