Ejemplo n.º 1
0
int select_menu( Menu *menu, int mselect )
{
  int eax;
  if ( mselect < 0 || menu->nitem <= mselect )
  {
    return menu->select;
  }
  else
  {
    if ( mselect < menu->offset )
      up_menu( menu, menu->offset - mselect );
    else
    if ( menu->offset + menu->height <= mselect )
      down_menu( menu, ( mselect - menu->offset - menu->height ) + 1 );
    if ( menu->offset <= menu->select && menu->select < menu->offset + menu->height )
      draw_menu_item( menu, menu->select );
    menu->select = mselect;
    standout( );
    draw_menu_item( menu, menu->select );
    standend( );
    move( ( menu->y + mselect ) - menu->offset, menu->x );
    toggle_stand( );
    refresh( );
    menu->select/*error:'i'*/ = menu->select;
    return menu->select;
  }
}
Ejemplo n.º 2
0
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
  static char buffer[50];

  switch (cell_index->row) {
    case 0:
      draw_menu_item(ctx, cell_layer, cell_index, "Unit type", get_long_unit_name());
      break;

    case 1:
      draw_menu_item(ctx, cell_layer, cell_index, "Date format", get_date_format_str());
      break;

    case 2:
      draw_menu_item(ctx, cell_layer, cell_index, "First day of week", (is_monday_first() ? "Monday" : "Sunday"));
      break;

    case 3:
      snprintf(buffer, sizeof(buffer), "%s", get_reminder_str());
      draw_menu_item(ctx, cell_layer, cell_index, "Reminder", buffer);
      break;

    case 4:
      draw_menu_item(ctx, cell_layer, cell_index, "About page", NULL);
      break;
  }
}
Ejemplo n.º 3
0
void
move_to_menu_pos(int pos, menu_state_t *ms)
{
	menu_data_t *const m = ms->d;
	int redraw;

	pos = MIN(m->len - 1, MAX(0, pos));
	if(pos < 0)
	{
		return;
	}

	normalize_top(ms);

	redraw = 0;
	if(pos > get_last_visible_line(m))
	{
		m->top = pos - (ms->win_rows - 2 - 1);
		redraw = 1;
	}
	else if(pos < m->top)
	{
		m->top = pos;
		redraw = 1;
	}

	if(cfg.scroll_off > 0)
	{
		int s = MIN(DIV_ROUND_UP(ms->win_rows - 2, 2), cfg.scroll_off);
		if(pos - m->top < s && m->top > 0)
		{
			m->top -= s - (pos - m->top);
			normalize_top(ms);
			redraw = 1;
		}
		if(pos > get_last_visible_line(m) - s)
		{
			m->top += s - (get_last_visible_line(m) - pos);
			normalize_top(ms);
			redraw = 1;
		}
	}

	ms->current = 1 + (pos - m->top);
	m->pos = pos;

	if(redraw)
	{
		draw_menu(ms);
	}
	else
	{
		draw_menu_item(ms, m->pos, ms->current, 0);
	}
	checked_wmove(menu_win, ms->current, 2);

	show_position_in_menu(m);
}
Ejemplo n.º 4
0
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked()
{
    draw_background_locked(currentIcon);

    if (DialogShowing()) {
        draw_dialog();
        return;
    }

    SetColor(MENU);

    if (show_text) {

        if (currentIcon != ERASING && currentIcon != INSTALLING_UPDATE)
            draw_header_icon();

        if (currentIcon == ERASING || currentIcon == INSTALLING_UPDATE || currentIcon == VIEWING_LOG) {
            int y = currentIcon == INSTALLING_UPDATE ? gr_fb_height() / 4 : header_height + 4;

            SetColor(LOG);
            int cx, cy;
            gr_set_font("log");
            gr_font_size(&cx, &cy);
            // display from the bottom up, until we hit the top of the
            // screen or we've displayed the entire text buffer.
            int row = (text_first_row+log_text_rows-1) % log_text_rows;
            for (int ty = gr_fb_height() - cy, count = 0;
                 ty > y+2 && count < log_text_rows;
                 ty -= (cy+2), ++count) {
                gr_text(4, ty, text[row], 0);
                --row;
                if (row < 0) row = log_text_rows-1;
            }
            return;
        }

        if (show_menu) {
            gr_set_font("menu");

            int nr_items = menu_items - menu_show_start;
            if (nr_items > max_menu_rows)
                nr_items = max_menu_rows;
            for (int i = 0; i < nr_items; ++i) {
                draw_menu_item(text_first_row + 3*i, menu[menu_show_start+i],
                        ((menu_show_start+i) == menu_sel));
            }
        }
    }
}
Ejemplo n.º 5
0
void
draw_menu(menu_state_t *m)
{
	int i, pos;
	const int y = getmaxy(menu_win);

	normalize_top(m);

	werase(menu_win);
	draw_menu_frame(m);

	for(i = 0, pos = m->d->top; i < y - 2 && pos < m->d->len; ++i, ++pos)
	{
		draw_menu_item(m, pos, i + 1, 0);
	}
}
Ejemplo n.º 6
0
/* displays a menu to its associated window */
int
post_gmenu (GMenu * menu)
{
  int i = 0, j = 0, k = 0, start, end, height, total, checked = 0;
  if (menu == NULL)
    return 1;

  werase (menu->win);

  height = menu->h;
  start = menu->start;
  total = menu->size;
  end = height < total ? start + height : total;
  for (i = start; i < end; i++, j++) {
    k = i == menu->idx ? 1 : 0;
    checked = menu->items[i].checked ? 1 : 0;
    draw_menu_item (menu, menu->items[i].name, 0, j, menu->w, k, checked);
  }
  wrefresh (menu->win);
  return 0;
}
Ejemplo n.º 7
0
void draw_menu( Menu *menu )
{
  int x = menu->x - FRAME_WIDTH, y, w = menu->width + ( FRAME_WIDTH * 2 );
  int i, j;
  y = menu->y - 1;
  if ( menu->offset == 0 )
  {
    if ( graph_mode != 0 )
      graphstart( );
    move( y, x );
    addstr( FRAME[3] );
    i = FRAME_WIDTH;
    for ( ; i < w - FRAME_WIDTH; i += FRAME_WIDTH )
    {
      move( y, x + i );
      addstr( FRAME[10] );
      //i += FRAME_WIDTH;
    }
    move( y, x + i );
    addstr( FRAME[6] );
    if ( graph_mode != 0 )
    {
      graphend( );
      while ( j < menu->height )
      {
        y++;
        if ( graph_mode != 0 )
          graphstart( );
        move( y, x );
        addstr( FRAME[5] );
        if ( graph_mode != 0 )
          graphend( );
        draw_menu_item( menu, menu->offset + j );
        if ( graph_mode != 0 )
          graphstart( );
        move( y, ( x + w ) - FRAME_WIDTH );
        addstr( FRAME[5] );
        if ( graph_mode != 0 )
          graphend( );
        j++;
      }
      y++;
      if ( menu->nitem == menu->offset + menu->height )
      {
        if ( graph_mode != 0 )
          graphstart( );
        move( y, x );
        addstr( FRAME[9] );
        i = FRAME_WIDTH;
        for ( ; i < w - FRAME_WIDTH; i += FRAME_WIDTH )
        {
          move( y, x + i );
          addstr( FRAME[10] );
          //i += FRAME_WIDTH;
        }
        move( y, x + i );
        addstr( FRAME[12] );
        if ( graph_mode != 0 )
        {
          graphend( );
        }
      }
      else
      {
        if ( graph_mode != 0 )
          graphstart( );
        move( y, x );
        addstr( FRAME[5] );
        if ( graph_mode != 0 )
          graphend( );
        i = FRAME_WIDTH;
        for ( ; i < w - FRAME_WIDTH; i++ )
        {
          move( y, x + i );
          addstr( " " );
          //i++;
        }
        if ( graph_mode != 0 )
          graphstart( );
        move( y, x + i );
        addstr( FRAME[5] );
        if ( graph_mode != 0 )
          graphend( );
        i = FRAME_WIDTH * ( ( ( w / 2 ) - 1 ) / FRAME_WIDTH );
        move( y, x + i );
        addstr( ":" );
      }
      return;
    }
  }
  else
  {
    if ( graph_mode != 0 )
      graphstart( );
    move( y, x );
    addstr( FRAME[5] );
    if ( graph_mode != 0 )
      graphend( );
    i = FRAME_WIDTH;
    for ( ; w - FRAME_WIDTH <= i; i++ )
    {
      move( y, x + i );
      addstr( " " );
      //i++;
    }
  }
  j = 0;
}
Ejemplo n.º 8
0
void
menu_current_line_erase(menu_state_t *m)
{
	draw_menu_item(m, m->d->pos, m->current, 1);
}