void menuitem_rebuild_screen_ip(MenuItem *item, Screen *s)
{
	Widget *w;

	debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__,
			((item != NULL) ? item->id : "(null)"),
			((s != NULL) ? s->id : "(null)"));

	if ((item == NULL) || (s == NULL))
		return;

	if (display_props->height >= 2) {
		/* Only add a title if enough space... */
		w = widget_create("text", WID_STRING, s);
		screen_add_widget(s, w);
		w->text = strdup(item->text);
		w->x = 1;
		w->y = 1;
	}

	w = widget_create("value", WID_STRING, s);
	screen_add_widget(s, w);
	w->text = malloc(item->data.ip.maxlength+1);
	w->x = 2;
	w->y = display_props->height / 2 + 1;

	/* Only display error string if enough space... */
	if (display_props->height > 2) {
		w = widget_create("error", WID_STRING, s);
		screen_add_widget(s, w);
		w->text = strdup("");
		w->x = 1;
		w->y = display_props->height;
	}
}
Beispiel #2
0
g_error widget_derive(struct widget **w, handle *h,
		      int type,struct widget *parent,
		      handle hparent,int rship,int owner) {

  g_error e;

  DBG("type %d, rship %d, parent %p, owner %d\n",type,rship,parent,owner);

  /* Allow using this to detach widgets too. Makes sense, since this is called
   * by the attachwidget request handler.
   */
  if (!parent)
    return widget_attach(*w, NULL, NULL, 0);
  
  switch (rship) {

  case PG_DERIVE_INSIDE:
     if (*w == NULL ) {
        e = widget_create(w,h, type, parent->dt, hparent, owner);
        errorcheck;
     }
     e = widget_attach(*w, parent->dt,parent->sub,hparent);
     break;

  case PG_DERIVE_AFTER:
     if ( *w == NULL ) {
        e = widget_create(w,h, type, parent->dt, parent->container, owner);
        errorcheck;
     }
     e = widget_attach(*w,parent->dt,parent->out,parent->container);
     break;

  case PG_DERIVE_BEFORE:
  case PG_DERIVE_BEFORE_OLD:
     if ( *w == NULL ) {
        e = widget_create(w,h, type, parent->dt, parent->container, owner);
        errorcheck;
     }
     e = widget_attach(*w,parent->dt,parent->where,parent->container);
     break;
     
  default:
    return mkerror(PG_ERRT_BADPARAM,22);

  }
  
  /* Error checking code common to all cases */
  if (iserror(e)) {
    widget_remove(*w);
    errorcheck;
  }

  if ((*w)->def->post_attach) {
    e = (*w)->def->post_attach(*w,parent,rship);
    errorcheck;
  }

  return success;
}
void menuitem_rebuild_screen_slider(MenuItem *item, Screen *s)
{
	Widget *w;

	debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__,
			((item != NULL) ? item->id : "(null)"),
			((s != NULL) ? s->id : "(null)"));

	if ((item == NULL) || (s == NULL))
		return;

	if (display_props->height >= 2) {
		/* Only add a title if enough space... */
		w = widget_create("text", WID_STRING, s);
		screen_add_widget(s, w);
		w->text = strdup(item->text);
		w->x = 1;
		w->y = 1;
	}

	w = widget_create("bar", WID_HBAR, s);
	screen_add_widget(s, w);
	w->width = display_props->width;
	if (display_props->height > 2) {
		/* This is option 1: we have enought space, so the bar and
		 * min/max texts can be on separate lines.
		 */
		w->x = 2;
		w->y = display_props->height / 2 + 1;
		w->width = display_props->width - 2;
	}

	w = widget_create("min", WID_STRING, s);
	screen_add_widget(s, w);
	w->text = NULL;
	w->x = 1;
	if (display_props->height > 2) {
		w->y = display_props->height / 2 + 2;
	} else {
		w->y = display_props->height / 2 + 1;
	}

	w = widget_create("max", WID_STRING, s);
	screen_add_widget(s, w);
	w->text = NULL;
	w->x = 1;
	if (display_props->height > 2) {
		w->y = display_props->height / 2 + 2;
	} else {
		w->y = display_props->height / 2 + 1;
	}
}
Beispiel #4
0
void
gameend_init ()
{
  widget_t framepoint, pmframes[6];
  widget_t point_cell[4];
  integer_t i;
  framepoint =
    create_basic_info_frame ("frame", gameend, pmframes, 400, 0, 1);
  widget_configure (pmframes[4], resource_frame_start, 270);
  gameendokbutton = pmframes[5];

  gameend_header = widget_create ("pmcontainer", framepoint);
  widget_set_geometry (gameend_header, xwidth - (LEFTMARGIN * 2), YAKUHEAD_H);

  gameend_pos = widget_create ("pmcontainer", framepoint);
  widget_set_geometry (gameend_pos, xwidth - (LEFTMARGIN * 2), 73);

  for (i = 0; i < 4; i++)
    {
      widget_t w;

      point_cell[i] = widget_create ("frame", framepoint);
      widget_configure (point_cell[i], resource_packed, resource_horizontal);
      widget_set_geometry (point_cell[i], xwidth, RESULTHOME_H);

      gameend_name[i] = widget_create ("text", point_cell[i]);
      widget_set_geometry (gameend_name[i], 160, RESULTHOME_H);
      widget_configure (gameend_name[i], resource_textfont, MEDIUMJP);
      widget_configure (gameend_name[i], resource_textcolor, white);

      w = widget_create ("frame", point_cell[i]);
      widget_configure (w, resource_packed, resource_virtical);

      gameend_tpoint1[i] = widget_create ("pmcontainer", w);
      gameend_tpoint2[i] = widget_create ("pmcontainer", w);
      widget_set_geometry (gameend_tpoint1[i], 110, 14);
      widget_set_geometry (gameend_tpoint2[i], 110, 14);

      gameend_rpoint[i] = widget_create ("text", point_cell[i]);
      widget_set_geometry (gameend_rpoint[i], 110, RESULTHOME_H);
      widget_configure (gameend_rpoint[i], resource_textfont, TIMESIB);
      widget_configure (gameend_rpoint[i], resource_textcolor, white);

      gameend_xpoint[i] = widget_create ("text", point_cell[i]);
      widget_set_geometry (gameend_xpoint[i], 110, RESULTHOME_H);
      widget_configure (gameend_xpoint[i], resource_textfont, TIMESIB);
      widget_configure (gameend_xpoint[i], resource_textcolor, white);
    }

  pmcontainer_print (gameend_header, pm_gameend_header);
  widget_pack (gameend);
  widget_fix (gameend);

  widget_set_geometry (gameend, xwidth, xheight);
}
Beispiel #5
0
component* textinput_create(const text_settings *tconf, const char *text, const char *initialvalue) {
    component *c = widget_create();

    textinput *tb = malloc(sizeof(textinput));
    memset(tb, 0, sizeof(textinput));
    tb->text = strdup(text);
    memcpy(&tb->tconf, tconf, sizeof(text_settings));
    tb->pos = &tb->pos_;

    // Background for field
    int tsize = text_char_width(&tb->tconf);
    image img;
    image_create(&img, 15*tsize+2, tsize+3);
    image_clear(&img, COLOR_MENU_BG);
    image_rect(&img, 0, 0, 15*tsize+1, tsize+2, COLOR_MENU_BORDER);
    surface_create_from_image(&tb->sur, &img);
    image_free(&img);

    // Copy over the initial value
    memcpy(tb->buf, initialvalue, strlen(initialvalue)+1);

    // Widget stuff
    widget_set_obj(c, tb);
    widget_set_render_cb(c, textinput_render);
    widget_set_event_cb(c, textinput_event);
    widget_set_tick_cb(c, textinput_tick);
    widget_set_free_cb(c, textinput_free);
    return c;
}
widget_t*
controller_settings_screen_create(temp_controller_id_t controller)
{
  controller_settings_screen_t* s = calloc(1, sizeof(controller_settings_screen_t));

  s->screen = widget_create(NULL, &controller_settings_widget_class, s, display_rect);
  widget_set_background(s->screen, BLACK, FALSE);

  char* title;
  temp_controller_id_t other_controller;
  if (controller == CONTROLLER_1) {
    title = "Controller 1 Setup";
    other_controller = CONTROLLER_2;
  }
  else {
    title = "Controller 2 Setup";
    other_controller = CONTROLLER_1;
  }
  s->button_list = button_list_screen_create(s->screen, title, back_button_clicked, s);

  s->controller = controller;
  s->settings = *app_cfg_get_controller_settings(controller);

  /* Convert enabled flags to selection enum */
  if (s->settings.output_settings[OUTPUT_1].enabled &&
      s->settings.output_settings[OUTPUT_2].enabled)
    s->output_selection = SELECT_1_2;
  else if (s->settings.output_settings[OUTPUT_1].enabled)
    s->output_selection = SELECT_1;
  else if (s->settings.output_settings[OUTPUT_2].enabled)
    s->output_selection = SELECT_2;
  else
    s->output_selection = SELECT_NONE;

  /* Figure out which output selections are allowed by checking which outputs are currently
   * being controlled by the other controller.
   */
  const controller_settings_t* other_controller_settings = app_cfg_get_controller_settings(other_controller);
  s->output_selection_valid[SELECT_NONE] = true;
  if (!other_controller_settings->output_settings[OUTPUT_1].enabled)
    s->output_selection_valid[SELECT_1] = true;
  if (!other_controller_settings->output_settings[OUTPUT_2].enabled)
    s->output_selection_valid[SELECT_2] = true;
  if (!other_controller_settings->output_settings[OUTPUT_1].enabled &&
      !other_controller_settings->output_settings[OUTPUT_2].enabled)
    s->output_selection_valid[SELECT_1_2] = true;

  /* If the current output selection is not valid, set it to none */
  if (!s->output_selection_valid[s->output_selection])
    s->output_selection = SELECT_NONE;

  set_controller_settings(s);

  return s->screen;
}
Beispiel #7
0
void
screen_saver_create()
{
  screen_saver_t* s = calloc(1, sizeof(screen_saver_t));

  s->screen = widget_create(NULL, &screen_saver_widget_class, s, display_rect);

  chThdCreateFromHeap(NULL, 1024, NORMALPRIO, screen_saver_thread, s);

  gui_msg_subscribe(MSG_TOUCH_INPUT, s->screen);
}
Beispiel #8
0
widget_t*
icon_create(widget_t* parent, rect_t rect, const Image_t* image, uint16_t icon_color, uint16_t bg_color)
{
  icon_t* i = calloc(1, sizeof(icon_t));

  i->image = image;
  i->icon_color = icon_color;

  widget_t* w = widget_create(parent, &icon_widget_class, i, rect);
  widget_set_background(w, bg_color, FALSE);

  return w;
}
Beispiel #9
0
widget_t*
calib_screen_create()
{
  calib_screen_t* s = calloc(1, sizeof(calib_screen_t));

  s->widget = widget_create(NULL, &calib_widget_class, s, display_rect);
  widget_set_background(s->widget, BLACK);

  rect_t rect = {
      .x = 15,
      .y = 15,
      .width = 56,
      .height = 56,
  };
  s->complete_button = button_create(s->widget, rect, img_left, WHITE, BLACK, complete_calib);
  widget_hide(s->complete_button);
  button_set_up_bg_color(s->complete_button, BLACK);
  button_set_up_icon_color(s->complete_button, WHITE);
  button_set_down_bg_color(s->complete_button, BLACK);
  button_set_down_icon_color(s->complete_button, LIGHT_GRAY);
  button_set_disabled_bg_color(s->complete_button, BLACK);
  button_set_disabled_icon_color(s->complete_button, DARK_GRAY);

  rect.x = 320 - 56 - 15;
  rect.y = 240 - 56 - 15;
  s->recal_button = button_create(s->widget, rect, img_update, WHITE, BLACK, restart_calib);
  widget_hide(s->recal_button);
  button_set_up_bg_color(s->recal_button, BLACK);
  button_set_up_icon_color(s->recal_button, WHITE);
  button_set_down_bg_color(s->recal_button, BLACK);
  button_set_down_icon_color(s->recal_button, LIGHT_GRAY);
  button_set_disabled_bg_color(s->recal_button, BLACK);
  button_set_disabled_icon_color(s->recal_button, DARK_GRAY);

  rect.x = 50;
  rect.y = 100;
  rect.width = 175;
  s->lbl_instructions = label_create(s->widget, rect, "Touch and hold the marker until it turns green", font_opensans_regular_18, WHITE, 3);

  gui_msg_subscribe(MSG_TOUCH_INPUT, s->widget);

  return s->widget;
}

static void
calib_widget_destroy(widget_t* w)
{
  calib_screen_t* s = widget_get_instance_data(w);
  gui_msg_unsubscribe(MSG_TOUCH_INPUT, s->widget);
  free(s);
}
Beispiel #10
0
LOCAL ICACHE_FLASH_ATTR int handleCommandAdd(clientInfo_t *cl)
{
    int x, y;
    char *end;

    if (cl->argc<5) {
        client_senderror(cl,"INVALIDARGS");
    }
    screen_t *s = screen_find(cl->argv[0]);
    if (!s) {
        client_senderror(cl,"NOTFOUND");
        return -1;
    }

    const widgetdef_t *c = widgetdef_find(cl->argv[1]);
    if (!c) {
        client_senderror(cl,"INVALID");
        return -1;
    }

    widget_t *w = widget_find(cl->argv[2]);
    if (w) {
        client_senderror(cl,"ALREADY");
        return -1;
    }

    x = (int)strtol(cl->argv[3],&end,10);
    if (*end !='\0') {
        client_senderror(cl,"INVALID");
        return -1;
    }

    y = (int)strtol(cl->argv[4],&end,10);
    if (*end !='\0') {
        client_senderror(cl,"INVALID");
        return -1;
    }

    /* Ok, create it. */

    w = widget_create(cl->argv[1], cl->argv[2]);
    if (!w) {
        client_senderror(cl,"INVALID");
        return -1;
    }

    screen_add_widget(s, w, x, y);
    client_sendOK(cl,"ADD");
    return 0;
}
Beispiel #11
0
widget_t*
offset_screen_create()
{
  offset_screen_t* s = calloc(1, sizeof(offset_screen_t));

  s->screen = widget_create(NULL, &offset_widget_class, s, display_rect);
  widget_set_background(s->screen, BLACK);

  char* title = "Set Probe Offset";
  s->button_list = button_list_screen_create(s->screen, title, back_button_clicked, s);

  gui_msg_subscribe(MSG_SENSOR_SAMPLE, s->screen);
  gui_msg_subscribe(MSG_SENSOR_TIMEOUT, s->screen);

  rebuild_offset_screen(s);

  return s->screen;
}
Beispiel #12
0
component* textbutton_create(const text_settings *tconf, const char *text, int disabled, textbutton_click_cb cb, void *userdata) {
    component *c = widget_create();
    component_disable(c, disabled);

    textbutton *tb = malloc(sizeof(textbutton));
    memset(tb, 0, sizeof(textbutton));
    tb->text = strdup(text);
    memcpy(&tb->tconf, tconf, sizeof(text_settings));
    tb->click_cb = cb;
    tb->userdata = userdata;
    widget_set_obj(c, tb);

    widget_set_render_cb(c, textbutton_render);
    widget_set_action_cb(c, textbutton_action);
    widget_set_tick_cb(c, textbutton_tick);
    widget_set_free_cb(c, textbutton_free);

    return c;
}
Beispiel #13
0
component* spritebutton_create(const text_settings *tconf, const char *text, surface *img, int disabled, spritebutton_click_cb cb, void *userdata) {
    component *c = widget_create();
    component_disable(c, disabled);

    spritebutton *sb = malloc(sizeof(spritebutton));
    memset(sb, 0, sizeof(spritebutton));
    if(text != NULL)
        sb->text = strdup(text);
    memcpy(&sb->tconf, tconf, sizeof(text_settings));
    sb->click_cb = cb;
    sb->img = img;
    sb->userdata = userdata;
    widget_set_obj(c, sb);

    widget_set_render_cb(c, spritebutton_render);
    widget_set_action_cb(c, spritebutton_action);
    widget_set_tick_cb(c, spritebutton_tick);
    widget_set_free_cb(c, spritebutton_free);

    return c;
}
Beispiel #14
0
g_error tabpage_install(struct widget *self) {
  g_error e;
  struct widget *tab;

  WIDGET_INSTALL_PARENT(PG_WIDGET_BOX);
  WIDGET_ALLOC_DATA(tabpagedata);

  /* Set custom defaults */
  e = widget_base_set(self, PG_WP_THOBJ, PGTH_O_TAB_PAGE);
  errorcheck;
  e = widget_base_set(self, PG_WP_SIZE, 0);
  errorcheck;

  /* Go ahead and create the tab. We will attach the tab
   * later when we're attached ourselves, but create it early so the
   * properties can be set.
   */
  e = widget_create(&tab, &DATA->htab, PG_WIDGET_BUTTON,
		    self->dt, self->container, self->owner);
  errorcheck;
  e = widget_set(tab, PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE | PG_EXEV_EXCLUSIVE);
  errorcheck;
  e = widget_set(tab, PG_WP_THOBJ_BUTTON, PGTH_O_TAB);
  errorcheck;
  e = widget_set(tab, PG_WP_THOBJ_BUTTON_HILIGHT, PGTH_O_TAB_HILIGHT);
  errorcheck;
  e = widget_set(tab, PG_WP_THOBJ_BUTTON_ON, PGTH_O_TAB_ON);
  errorcheck;
  e = widget_set(tab, PG_WP_THOBJ_BUTTON_ON_NOHILIGHT, PGTH_O_TAB_ON_NOHILIGHT);
  errorcheck;

  tab->callback = &tabpage_tab_callback;
  tab->callback_owner = self;

  return success;
}
Beispiel #15
0
widget_t*
listbox_create(widget_t* parent, rect_t rect, int item_height)
{
  listbox_t* l = calloc(1, sizeof(listbox_t));

  widget_t* lb = widget_create(parent, NULL, l, rect);

  l->pos = 0;
  l->item_height = item_height;

  rect_t container_rect = {
      .x = 0,
      .y = 0,
      .width = rect.width - 52,
      .height = rect.height
  };
  l->item_container = widget_create(lb, &listbox_widget_class, l, container_rect);

  int button_pad = (rect.height - (2 * 52)) / 3;
  rect_t button_rect = {
      .x = rect.width - 52,
      .y = button_pad,
      .width = 52,
      .height = 52
  };
  l->up_button = button_create(lb, button_rect, img_up, WHITE, BLACK, up_button_event);
  button_set_up_bg_color(l->up_button, BLACK);
  button_set_up_icon_color(l->up_button, WHITE);
  button_set_down_bg_color(l->up_button, BLACK);
  button_set_down_icon_color(l->up_button, LIGHT_GRAY);
  button_set_disabled_bg_color(l->up_button, BLACK);
  button_set_disabled_icon_color(l->up_button, DARK_GRAY);

  button_rect.y += 52 + button_pad;
  l->dn_button = button_create(lb, button_rect, img_down, WHITE, BLACK, down_button_event);
  button_set_up_bg_color(l->dn_button, BLACK);
  button_set_up_icon_color(l->dn_button, WHITE);
  button_set_down_bg_color(l->dn_button, BLACK);
  button_set_down_icon_color(l->dn_button, LIGHT_GRAY);
  button_set_disabled_bg_color(l->dn_button, BLACK);
  button_set_disabled_icon_color(l->dn_button, DARK_GRAY);

  return lb;
}

void
listbox_clear(widget_t* lb)
{
  listbox_t* l = widget_get_instance_data(lb);
  while (1) {
    widget_t* w = widget_get_child(l->item_container, 0);
    if (w == NULL)
      break;

    widget_unparent(w);
    widget_destroy(w);
  }
  widget_invalidate(lb);
}

static void
listbox_destroy(widget_t* w)
{
  listbox_t* l = widget_get_instance_data(w);
  free(l);
}
Beispiel #16
0
widget_t
bdcolor_init ()
{
  widget_t frame;
  widget_t aframe, bframe, cframe;
  widget_t xframe, yframe, zframe, w;
  widget_t texts[N_COMBO];

  frame = widget_create ("frame", root_widget);

  aframe = widget_create ("text", frame);
  widget_set_geometry (aframe, xwidth, 54);
  widget_configure (aframe, resource_textcolor, tomato);
  widget_configure (aframe, resource_textfont, XLARGETIMESIB);
  widget_configure (aframe, resource_textshadow, 1);
  widget_configure (aframe, resource_text, "  Board Color Selection");

  bframe = widget_create ("frame", frame);
  widget_configure (bframe, resource_packed, resource_horizontal);
  widget_set_geometry (bframe, xwidth, 20 * N_COMBO);

  xframe = widget_create ("frame", bframe);
  widget_set_geometry (xframe, 100, 20 * N_COMBO);
  widget_configure (xframe, resource_wrap, 0);

  yframe = widget_create ("frame", bframe);
  widget_set_geometry (yframe, xwidth - 200, 20 * N_COMBO);

  zframe = widget_create ("frame", bframe);
  widget_set_geometry (zframe, 100, 20 * N_COMBO);
  widget_configure (zframe, resource_wrap, 0);

  {
    int i;
    for (i = 0; i < N_COMBO; i++)
      {
        char buffer[64];
        texts[i] = widget_create ("text", yframe);
        sprintf (buffer, "Click me!! %s", colorcombo[i].name);
        widget_model_change (texts[i], colorcombo[i].color,
                             black, black, black);
        widget_set_geometry (texts[i], xwidth - 200, 20);
        widget_configure (texts[i], resource_relief, relief_raised);
        widget_configure (texts[i], resource_border_width, 2);
        widget_configure (texts[i], resource_text, buffer);
        widget_configure (texts[i], resource_cannot_change_model, 1);
        if (colorcombo[i].color != white)
          widget_configure (texts[i], resource_textcolor, white);
        else
          widget_configure (texts[i], resource_textcolor, black);
        widget_configure (texts[i], resource_textfont, HELVB);
        widget_add_callback (texts[i], resource_buttonpress_callback,
                             select_bdcolor, i);
      }
  }
  widget_pack (yframe);
  widget_pack (bframe);
  widget_pack (frame);
  widget_fix (frame);
  widget_set_geometry (frame, xwidth, xheight);
  return frame;
}
Beispiel #17
0
void
textentry_screen_show(textentry_format_t format, text_handler_t text_handler, void* user_data)
{
  int i;
  textentry_screen_t* screen = calloc(1, sizeof(textentry_screen_t));

  screen->text_handler = text_handler;
  screen->user_data = user_data;

  switch (format) {
    case TXT_FMT_IP:
      screen->btn_layout = btn_layout_numeric;
      screen->num_rows = NUM_ROWS_NUMERIC;
      break;

    default:
    case TXT_FMT_ANY:
      screen->btn_layout = btn_layout_all;
      screen->num_rows = NUM_ROWS_ALL;
      break;
  }

  screen->widget = widget_create(NULL, &textentry_screen_widget_class, screen, display_rect);

  rect_t rect = {
      .x = 7,
      .y = 5,
      .width = 48,
      .height = 48,
  };
  widget_t* back_btn = button_create(screen->widget, rect, img_cancel, WHITE, BLACK, back_button_clicked);
  button_set_up_bg_color(back_btn, BLACK);
  button_set_up_icon_color(back_btn, WHITE);
  button_set_down_bg_color(back_btn, BLACK);
  button_set_down_icon_color(back_btn, LIGHT_GRAY);
  button_set_disabled_bg_color(back_btn, BLACK);
  button_set_disabled_icon_color(back_btn, DARK_GRAY);

  rect.x = 7;
  rect.y = 65;
  for (i = 0; i < NUM_VISIBLE_ROWS; ++i) {
    int j;
    for (j = 0; j < NUM_BUTTONS_PER_ROW; ++j) {
      widget_t* b = button_create(screen->widget, rect, img_circle, WHITE, BLACK, char_button_clicked);
      button_set_font(b, font_opensans_regular_22);
      button_set_up_bg_color(b, BLACK);
      button_set_up_icon_color(b, WHITE);
      button_set_down_bg_color(b, BLACK);
      button_set_down_icon_color(b, LIGHT_GRAY);
      button_set_disabled_bg_color(b, BLACK);
      button_set_disabled_icon_color(b, DARK_GRAY);

      screen->buttons[i][j] = b;
      rect.x += 52;
    }
    rect.y += 58;
    rect.x = 7;
  }

  rect.x = 268;
  rect.y = 5;
  widget_t* b = button_create(screen->widget, rect, img_check, WHITE, BLACK, ok_button_clicked);
  button_set_up_bg_color(b, BLACK);
  button_set_up_icon_color(b, WHITE);
  button_set_down_bg_color(b, BLACK);
  button_set_down_icon_color(b, LIGHT_GRAY);
  button_set_disabled_bg_color(b, BLACK);
  button_set_disabled_icon_color(b, DARK_GRAY);

  rect.y = 65;
  b = button_create(screen->widget, rect, img_backspace, WHITE, BLACK, backspace_button_clicked);
  button_set_up_bg_color(b, BLACK);
  button_set_up_icon_color(b, WHITE);
  button_set_down_bg_color(b, BLACK);
  button_set_down_icon_color(b, LIGHT_GRAY);
  button_set_disabled_bg_color(b, BLACK);
  button_set_disabled_icon_color(b, DARK_GRAY);

  rect.y += 58;
  b = button_create(screen->widget, rect, img_up, WHITE, BLACK, up_button_clicked);
  button_set_up_bg_color(b, BLACK);
  button_set_up_icon_color(b, WHITE);
  button_set_down_bg_color(b, BLACK);
  button_set_down_icon_color(b, LIGHT_GRAY);
  button_set_disabled_bg_color(b, BLACK);
  button_set_disabled_icon_color(b, DARK_GRAY);

  rect.y += 58;
  b = button_create(screen->widget, rect, img_down, WHITE, BLACK, down_button_clicked);
  button_set_up_bg_color(b, BLACK);
  button_set_up_icon_color(b, WHITE);
  button_set_down_bg_color(b, BLACK);
  button_set_down_icon_color(b, LIGHT_GRAY);
  button_set_disabled_bg_color(b, BLACK);
  button_set_disabled_icon_color(b, DARK_GRAY);

  update_input_buttons(screen);

  rect.x = 60;
  rect.y = 8;
  rect.width = 200;
  screen->text_label = label_create(screen->widget, rect, "", font_opensans_regular_22, WHITE, 2);
  widget_set_background(screen->text_label, LIGHT_GRAY);

  gui_push_screen(screen->widget);
}

static void
update_input_buttons(textentry_screen_t* screen)
{
  int i;
  for (i = 0; i < NUM_VISIBLE_ROWS; ++i) {
    btn_row_t* row = &screen->btn_layout[screen->row_idx + i];

    int j;
    for (j = 0; j < NUM_BUTTONS_PER_ROW; ++j) {
      widget_t* btn = screen->buttons[i][j];
      const char* btn_text = (*row)[j];

      if (btn_text == NULL)
        widget_hide(btn);
      else {
        if (*btn_text == ' ')
          button_set_icon(btn, img_space);
        else
          button_set_icon(btn, img_circle);

        button_set_text(btn, btn_text);
        widget_show(btn);
      }
    }
  }
}
Beispiel #18
0
widget_t*
home_screen_create()
{
  home_screen_t* s = calloc(1, sizeof(home_screen_t));

  s->sample_timestamp = chTimeNow();

  s->screen = widget_create(NULL, &home_widget_class, s, display_rect);
  widget_set_background(s->screen, BLACK);

  rect_t rect = {
      .x      = TILE_X(0),
      .y      = TILE_Y(0),
      .width  = TILE_SPAN(3),
      .height = TILE_SPAN(2),
  };
  s->stage_widget = widget_create(s->screen, NULL, NULL, rect);
  widget_set_background(s->stage_widget, GREEN);

  rect.x = TILE_X(3);
  rect.width = TILE_SPAN(1);
  rect.height = TILE_SPAN(1);
  s->sensors[SENSOR_1].button = button_create(s->screen, rect, img_temp_med, WHITE, STEEL, click_sensor_button);

  rect.y = TILE_Y(1);
  s->sensors[SENSOR_2].button = button_create(s->screen, rect, img_temp_med, WHITE, STEEL, click_sensor_button);

  rect.x = TILE_X(0);
  rect.y = TILE_Y(2);
  s->outputs[OUTPUT_1].button = button_create(s->screen, rect, img_plug, WHITE, STEEL, click_output_button);

  rect.x = TILE_X(1);
  s->outputs[OUTPUT_2].button = button_create(s->screen, rect, img_plug, WHITE, STEEL, click_output_button);

  rect.x = TILE_X(2);
  s->conn_button = button_create(s->screen, rect, img_signal, RED, STEEL, click_conn_button);

  rect.x = TILE_X(3);
  s->settings_button = button_create(s->screen, rect, img_settings, WHITE, COBALT, click_settings_button);

  rect.x = 0;
  rect.width = TILE_SPAN(3);
  s->sensors[SENSOR_1].quantity_widget = quantity_widget_create(s->stage_widget, rect, app_cfg_get_temp_unit());
  widget_disable(s->sensors[SENSOR_1].quantity_widget);

  s->sensors[SENSOR_2].quantity_widget = quantity_widget_create(s->stage_widget, rect, app_cfg_get_temp_unit());
  widget_disable(s->sensors[SENSOR_2].quantity_widget);

  place_quantity_widgets(s);

  set_output_settings(s, OUTPUT_1,
      temp_control_get_output_function(OUTPUT_1));
  set_output_settings(s, OUTPUT_2,
      temp_control_get_output_function(OUTPUT_2));

  gui_msg_subscribe(MSG_SENSOR_SAMPLE, s->screen);
  gui_msg_subscribe(MSG_SENSOR_TIMEOUT, s->screen);
  gui_msg_subscribe(MSG_OUTPUT_STATUS, s->screen);
  gui_msg_subscribe(MSG_TEMP_UNIT, s->screen);
  gui_msg_subscribe(MSG_NET_STATUS, s->screen);
  gui_msg_subscribe(MSG_API_STATUS, s->screen);
  gui_msg_subscribe(MSG_CONTROLLER_SETTINGS, s->screen);
  gui_msg_subscribe(MSG_API_CONTROLLER_SETTINGS, s->screen);

  return s->screen;
}

void
home_screen_destroy(widget_t* w)
{
  home_screen_t* s = widget_get_instance_data(w);

  gui_msg_unsubscribe(MSG_SENSOR_SAMPLE, s->screen);
  gui_msg_unsubscribe(MSG_SENSOR_TIMEOUT, s->screen);
  gui_msg_unsubscribe(MSG_OUTPUT_STATUS, s->screen);
  gui_msg_unsubscribe(MSG_TEMP_UNIT, s->screen);
  gui_msg_unsubscribe(MSG_NET_STATUS, s->screen);
  gui_msg_unsubscribe(MSG_API_STATUS, s->screen);
  gui_msg_unsubscribe(MSG_CONTROLLER_SETTINGS, s->screen);
  gui_msg_unsubscribe(MSG_API_CONTROLLER_SETTINGS, s->screen);

  free(s);
}
Beispiel #19
0
g_error panel_install(struct widget *self) {
  struct widget *bar, *title;
  g_error e;

  WIDGET_ALLOC_DATA(paneldata);

  /* This split determines the size of the main panel area */
  e = newdiv(&self->in,self);
  errorcheck;
  self->in->flags &= ~(DIVNODE_SIZE_AUTOSPLIT | DIVNODE_SIZE_RECURSIVE);
  self->in->flags |= PG_S_TOP;

  /* An optional border inside that main panel area */
  e = newdiv(&self->in->div,self);
  errorcheck;
  self->in->div->flags &= ~(DIVNODE_SIZE_AUTOSPLIT | DIVNODE_SIZE_RECURSIVE);
  self->in->div->flags |= DIVNODE_SPLIT_BORDER;
  self->in->div->build = &build_panel_border;

  /* Create the panelbar widget */
  e = widget_create(&bar,&DATA->hbar,PG_WIDGET_PANELBAR,
		    self->dt,self->container,self->owner);
  errorcheck;
  e = widget_attach(bar,self->dt,&self->in->div->div,0);
  errorcheck;
  e = widget_set(bar,PG_WP_BIND,self->h);
  errorcheck;

  /* This draws the panel background  */
  e = newdiv(bar->out,self);
  errorcheck;
  DATA->bg = *bar->out;
  DATA->bg->flags |= DIVNODE_SPLIT_BORDER;
  DATA->bg->flags &= ~DIVNODE_SIZE_AUTOSPLIT;
  DATA->bg->build = &build_bgfill_only;
  DATA->bg->state = PGTH_O_PANEL;

  /* Set up us the container! */
  self->out = &self->in->next;
  self->sub = &DATA->bg->div;

  /* Firstly, create a label widget in the panelbar to present the title */

  title = NULL;
  e = widget_derive(&title,&DATA->hlabel,PG_WIDGET_LABEL,bar,DATA->hbar,
		    PG_DERIVE_INSIDE,self->owner);
  errorcheck;
  widget_set(title,PG_WP_SIDE,PG_S_ALL);
  widget_set(title,PG_WP_THOBJ,PGTH_O_PANELBAR);

  /* Nextly, create the standard buttons for a panel app */

  e = panel_std_button(&DATA->hzoom, self, 
		       PGTH_O_ZOOMBTN,
		       PGTH_O_ZOOMBTN_ON,
		       PGTH_O_ZOOMBTN_HILIGHT,
		       PG_EXEV_TOGGLE,
		       &panel_zoom_callback);
  errorcheck;

  e = panel_std_button(&DATA->hrotate, self, 
		       PGTH_O_ROTATEBTN,
		       PGTH_O_ROTATEBTN_ON,
		       PGTH_O_ROTATEBTN_HILIGHT,
		       0,
		       &panel_rotate_callback);
  errorcheck;

  e = panel_std_button(&DATA->hclose, self, 
		       PGTH_O_CLOSEBTN,
		       PGTH_O_CLOSEBTN_ON,
		       PGTH_O_CLOSEBTN_HILIGHT,
		       0,
		       &panel_close_callback);
  errorcheck;

  /* Make sure we default to our minimum rolled-up size */
  widget_set(self, PG_WP_SIZE, 0);

  return success;
}
Beispiel #20
0
void
point_init ()
{
  widget_t framepoint, frames[6], button;
  widget_t point_cell[30];
  integer_t i, x, y;
  integer_t n_point_idx_count;  /* calculation maximam cell */
  extern integer_t yellow;

  memset (point_cell, 0, sizeof (point_cell));

  read_result_name ();

  framepoint =
    create_basic_info_frame ("frame", point, frames, PAI_W * 18, 0, 1);
  widget_configure (frames[4], resource_frame_start, 270);
  pointokbutton = frames[5];

  quicklogbutton = button = widget_create ("button", frames[4]);
  widget_set_geometry (button, BUTTON_W, BUTTON_H);
  widget_configure (button, resource_text, "quicklog");
  widget_configure (button, resource_textcolor, yellow);
  widget_configure (button, resource_textfont, TIMESI);
  widget_add_callback (button,
                       resource_buttonpress_callback,
                       (void *) quick_log_button_callback, "");
  if (!PAICARD)
    {
      point_header = widget_create ("pmcontainer", framepoint);
      widget_set_geometry (point_header, 100, YAKUHEAD_H);
      pmcontainer_print (point_header, pm_point_header);
    }

  widget_get_geometry (frames[1], &x, &y);

  n_point_idx_count = ((y - ((HEAD_H + 4) * 2) - (PAI_H + 4) * 3) / CELL_H);
  for (i = 0; i < 24; i++)
    {
      point_cell[i] = widget_create ("frame", framepoint);
      widget_configure (point_cell[i], resource_packed, resource_horizontal);

      if (i == 0)
        {
          widget_configure (point_cell[i],
                            resource_packed, resource_virtical);
          point_results = widget_create ("pmcontainer", point_cell[i]);
          widget_set_geometry (point_results, xwidth, HEAD_H + 4);
          hora_init (point_cell[i], xwidth - 100);
        }
      else if (1 <= i && i <= 4)
        {
          widget_set_geometry (point_cell[i], xwidth, CELLHOME_H);
          point_home[i - 1] = widget_create ("pmcontainer", point_cell[i]);
          point_home_user[i - 1] = widget_create ("text", point_cell[i]);
          point_home_point[i - 1] = widget_create ("text", point_cell[i]);
          widget_set_geometry (point_home[i - 1], 100, CELLHOME_H);
          widget_set_geometry (point_home_user[i - 1], 100, CELLHOME_H);
          widget_set_geometry (point_home_point[i - 1], 150, CELLHOME_H);

          widget_configure (point_home_user[i - 1], resource_textfont,
                            MEDIUMJP);
          widget_configure (point_home_point[i - 1], resource_textfont,
                            TIMESIB);
        }
      else if (i == 5)
        {
          /* spaceing */
          widget_t graph;
          widget_set_geometry (point_cell[i], xwidth, CELL_H);
          graph = widget_create ("pmcontainer", point_cell[i]);
          widget_set_geometry (graph, xwidth, CELL_H);
        }
      else if (i == 6)
        {
          point_fubase = point_cell[i];
          point_fu = widget_create ("text", point_cell[i]);
          point_fustr = widget_create ("pmcontainer", point_cell[i]);
          point_fan = widget_create ("text", point_cell[i]);
          point_fanstr = widget_create ("pmcontainer", point_cell[i]);
          widget_set_geometry (point_fu, 48, HEAD_H);
          widget_set_geometry (point_fustr, 48, HEAD_H);
          widget_set_geometry (point_fan, 48, HEAD_H);
          widget_set_geometry (point_fanstr, 48, HEAD_H);
          widget_configure (point_fu, resource_textfont, LUCIDA);
          widget_configure (point_fan, resource_textfont, LUCIDA);
        }
#define YB 7
#define YL 5
      else if (0 <= (i - YB) && (i - YB) < YL)
        {
          widget_t *wk;
          point_yaku[i - YB] = widget_create ("text", point_cell[i]);
          point_yaku_point[i - YB] = widget_create ("text", point_cell[i]);
          point_yaku[i - YB + YL] = widget_create ("text", point_cell[i]);
          point_yaku_point[i - YB + YL] =
            widget_create ("text", point_cell[i]);


          widget_configure (point_yaku[i - YB], resource_textfont, MEDIUMJP);
          widget_configure (point_yaku[i - YB + YL], resource_textfont,
                            MEDIUMJP);
          widget_configure (point_yaku_point[i - YB], resource_textfont,
                            TIMESIB);
          widget_configure (point_yaku_point[i - YB + YL], resource_textfont,
                            TIMESIB);
          widget_set_geometry (point_yaku[i - YB], 200, CELL_H);
          widget_set_geometry (point_yaku[i - YB + YL], 200, CELL_H);
          widget_set_geometry (point_yaku_point[i - YB], 100, CELL_H);
          widget_set_geometry (point_yaku_point[i - YB + YL], 100, CELL_H);
        }
    }                           /* for */

  pmcontainer_print (point_fustr, pm_point_fu_sfx);
  pmcontainer_print (point_fanstr, pm_point_fan_sfx);

  widget_pack (point);
  widget_fix (point);

  widget_set_geometry (point, xwidth, xheight);
}
Beispiel #21
0
widget_t
create_basic_info_frame (char *type, widget_t parent, widget_t pmframes[6],
                         integer_t centerwidth, integer_t frame3_p,
                         integer_t button_p)
{
  widget_t frame1, frame2, frame3, frame2left, frame2center, frame2right, frame4;
  widget_t okbutton, quitbutton;
  integer_t x;
  integer_t frame1h, frame2h, frame3h, frame4h;

  frame1 = widget_create ("frame", parent);
  frame2 = widget_create ("frame", parent);
  frame3 = widget_create ("pmcontainer", parent);
  frame4 = widget_create ("frame", parent);

  widget_configure (frame1, resource_packed, resource_horizontal);
  widget_set_geometry (frame1, xwidth, TOPMARGIN);
  widget_configure (frame1, resource_wrap, 0);

  widget_configure (frame2, resource_packed, resource_horizontal);
  widget_configure (frame4, resource_packed, resource_horizontal);
  frame2left = widget_create ("pmcontainer", frame2);
  frame2center = widget_create (type, frame2);
  frame2right = widget_create ("pmcontainer", frame2);

  frame1h = TOPMARGIN;
  if (frame3_p)
    {
      frame3h = BOTTOMMARGIN;
    }
  else
    {
      frame3h = 5;
    }

  if (frame1h < 0)
    {
      frame1h = 5, frame3h = 5;
    }

  frame4h = BUTTON_H;
  frame2h = xheight - (frame1h + frame3h + frame4h + BUTTON_H);

  widget_set_geometry (frame1, xwidth, frame1h);
  widget_configure (frame1, resource_wrap, 0);
  widget_set_geometry (frame3, xwidth, frame3h);
  widget_set_geometry (frame2, xwidth, frame2h);
  {
    integer_t leftmargin = (xwidth - centerwidth) / 2;
    widget_set_geometry (frame2left, leftmargin, frame2h);
    widget_set_geometry (frame2center, xwidth - leftmargin * 2, frame2h);
    widget_set_geometry (frame2right, leftmargin, frame2h);
  }

  if (button_p)
    {
      okbutton = widget_create ("button", frame4);
/*    quitbutton = widget_create ("button", frame4);  */
      widget_set_geometry (okbutton, BUTTON_W, BUTTON_H);
/*    widget_set_geometry (quitbutton, BUTTON_W, BUTTON_H); */
      widget_configure (okbutton, resource_text, "ok");
      widget_configure (okbutton, resource_textcolor, yellow);
      widget_configure (okbutton, resource_textfont, TIMESI);
      widget_add_callback (okbutton,
                           resource_buttonpress_callback,
                           (void *) keywait_callback, "");
/*
   widget_configure (quitbutton, resource_text, "quit");
   widget_configure (quitbutton, resource_textcolor, yellow);
   widget_configure (quitbutton, resource_textfont, TIMESI);
   widget_add_callback (quitbutton,
   resource_buttonpress_callback,
   (void *) quit_callback, ""); */
    }

  pmframes[0] = frame1;
  pmframes[1] = frame2left;
  pmframes[2] = frame2right;
  pmframes[3] = frame3;
  pmframes[4] = frame4;
  pmframes[5] = okbutton;

  return frame2center;
}