Example #1
0
static int
widget_calculate_query_width( const char *title, widget_query_entry *menu,
			      char **lines, int num_lines )
{
  widget_query_entry *ptr;
  int max_width=0;
  int i;

  if (!menu) {
    return 64;
  }

  max_width = widget_stringwidth( title )+5*8;

  for( ptr = menu; ptr->text; ptr++ ) {
    int total_width = widget_stringwidth( ptr->text )+3*8;

    if (total_width > max_width)
      max_width = total_width;
  }

  for( i=0; i<num_lines; i++) {
    int total_width = widget_stringwidth( lines[i] )+2*8;

    if( total_width > max_width )
      max_width = total_width;
  }

  return ( max_width + query_vert_external_margin * 2 ) / 8;
}
Example #2
0
static int
widget_calculate_select_width( const char* title )
{
  int i;
  int max_width = widget_stringwidth( title )+5*8;
  /* Leave room for the option labels we'll be adding */
  int label_width = widget_stringwidth( "A: " );

  for( i = 0; i < count; i++ ) {
    int total_width = label_width + widget_stringwidth( options[i] ) + 3 * 8;
    if( total_width > max_width )
      max_width = total_width;
  }

  return ( max_width + select_vert_external_margin * 2 ) / 8;
}
Example #3
0
static void
print_rom( int which )
{
  const char *setting;

  setting = *( settings_get_rom_setting( widget_settings,
					 which + first_rom, is_peripheral ) );
  while( widget_stringwidth( setting ) >= 232 - 68 )
    ++setting;

  widget_rectangle( 68, which * 8 + 24, 232 - 68, 8,
		    WIDGET_COLOUR_BACKGROUND );
  widget_printstring (68, which * 8 + 24,
				   WIDGET_COLOUR_FOREGROUND, setting );
  widget_display_rasters( which * 8 + 24, 8 );
}
Example #4
0
void
print_items( void )
{
  int i;
  char buffer[128];
  size_t height = 24;
  int width = widget_calculate_menu_width(menu);
  int menu_left_edge_x = (DISPLAY_WIDTH_COLS/2-width/2)*8+1;

  for( i = 0; i < count; i++ ) {
    int colour;
    if( !menu[i+1].text[0] ) { height += 4; continue; }

    snprintf( buffer, sizeof (buffer), menu[i+1].text );
    colour = menu[i+1].inactive ?
	     WIDGET_COLOUR_DISABLED :
	     WIDGET_COLOUR_FOREGROUND;

    if( i == highlight_line ) {
      widget_rectangle( menu_left_edge_x, height, width*8-2, 1*8,
                        WIDGET_COLOUR_HIGHLIGHT );
    } else {
      widget_rectangle( menu_left_edge_x, height, width*8-2, 1*8,
                        WIDGET_COLOUR_BACKGROUND );
    }

    widget_printstring( menu_left_edge_x+8, height, colour, buffer );

    if( menu[i+1].submenu ) {
      widget_draw_submenu_arrow(DISPLAY_BORDER_ASPECT_WIDTH+menu_left_edge_x+
                                width*8-9, i*8+49, colour);
    }

    if( menu[i+1].detail ) {
      size_t detail_width = widget_stringwidth( menu[i+1].detail() );
      int x = menu_left_edge_x + (width-1)*8 - detail_width - 2;
      widget_printstring( x, height, WIDGET_COLOUR_DISABLED, menu[i+1].detail() );
    }

    height += 8;
  }

  widget_display_lines( 2, count + 2 );
}
Example #5
0
static int
widget_text_draw_text( void )
{
  int width;
  const char *tptr;

  widget_rectangle( 12, 28, 232, 8, WIDGET_COLOUR_BACKGROUND );

  tptr = text - 1;
  do {
    width = widget_stringwidth (++tptr);
  } while (width > 28 * 8 - 4);

  if( tptr != text )
    widget_rectangle( 14, 29, 1, 6, 5 );

  widget_printstring( 16, 28, WIDGET_COLOUR_FOREGROUND, tptr );
  widget_rectangle( 17 + width, 35, 4, 1, 5 );

  widget_display_rasters( 28, 8 );
  return 0;
}