Esempio n. 1
0
eolComponent *eol_line_entry_new(
    eolUint       id,
    eolWord       name,
    eolRectFloat  rect,
    eolRect       bounds,
    eolLine       output
)
{
  return eol_entry_new(
    id,
    name,
    rect,
    bounds,
    output,
    EOLLINELEN,
    eolJustifyLeft,
    eolFalse,
    3,
    "",
    eolFalse,
    eol_vec3d(0,1,0),
    1,
    eol_vec3d(0.1,0.1,0.1)
  );
}
Esempio n. 2
0
eolWindow *eol_dialog_text_prompt(char *output,
                                  eolUint bufferSize,
                                  eolUint lineWidth,  /*0 means no limit*/
                                  eolLine question,
                                  void * customData,
                                  eolWindowCallback onOk,
                                  eolWindowCallback onCancel)
{
  eolRect trect;  /*text dimensions*/
  eolRect brect;  /*buffer dimentions*/
  eolUint ww,wh;  /*window dimensions*/
  eolUint bw,bh;  /*button dimensions*/
  eolUint sw,sh;  /*screen dimensions*/
  eolBool wordWrap = eolFalse;
  eolEntryData *entryData;
  eolWindow *win = eol_window_new();
  eolComponent *comp = NULL;
  if (!output)
  {
    eol_logger_message(
      EOL_LOG_ERROR,
      "eol_dialog_text_prompt:no out parameter provided.");
    return NULL;
  }
  if (!win)
  {
    eol_logger_message(
      EOL_LOG_ERROR,
      "eol_dialog_text_prompt:failed to make test prompt dialog.");
    return NULL;
  }

  win->customData = malloc(sizeof(eolEntryData));
  if (!win->customData)
  {
    eol_logger_message(
      EOL_LOG_ERROR,
      "eol_dialog_text_prompt:failed to allocate window data");
    eol_window_free(&win);
    return NULL;
  }
  memset(win->customData,0,sizeof(eolEntryData));
  entryData = (eolEntryData*)win->customData;
  entryData->customData = customData;
  entryData->output = output;
  
  wordWrap = eolFalse;
  
  strncpy(win->name,"gettext",EOLLINELEN);
  eol_graphics_get_size(&sw, &sh);
  eol_button_get_stock_size(&bw, &bh);
  trect = eol_font_get_bounds(question,3);
  brect = eol_font_get_bounds("W",3);
  brect.w *= bufferSize;
  if (MAX(trect.w,brect.w) > ((bw*2) + 6))
  {
    ww = MAX(trect.w,brect.w) + 10;
  }
  else
  {
    ww = (bw*2) + 16;
  }
  if (ww > sw - 20)ww = sw - 20;
  wh = trect.h + brect.h + bh + 30;
  eol_rect_copy(&win->rect,eol_rect((sw/2) - (ww/2),(sh/2) - (wh/2),ww,wh));
  win->canHasFocus = eolTrue;
  win->drawGeneric = eolTrue;
  win->update = eol_dialog_text_prompt_update;
  win->custom_delete = eol_dialog_text_prompt_delete;
  
  comp = eol_label_new(0,"text_prompt_title",eol_rectf(0.5,0.1,1,1),win->rect,eolTrue,
                       question,eolJustifyCenter,eolFalse,3,NULL,eol_vec3d(1,1,1),1);
  eol_window_add_component(win,comp);
  
  comp = eol_button_stock_new(1,
                              "ok_button",
                              eol_rectf(0.25,0.7,1,1),
                              win->rect,
                              "OK",
                              -1,
                              SDLK_RETURN,
                              0,
                              eolTrue);
  eol_window_add_component(win,comp);
  
  comp = eol_button_stock_new(2,
                              "cancel_button",
                              eol_rectf(0.75,0.7,1,1),
                              win->rect,
                              "CANCEL",
                              -1,
                              SDLK_ESCAPE,
                              0,
                              eolTrue);
  eol_window_add_component(win,comp);
  
  comp = eol_entry_new(3,
                       "text_entry",
                       eol_rectf(0.025,0.25,0.95,0.25),
                       win->rect,
                       output,
                       bufferSize,
                       eolJustifyLeft,
                       wordWrap,
                       3,
                       "",
                       eolFalse,
                       eol_vec3d(1,1,1),
                       1,
                       eol_vec3d(0.2,0.2,0.2));
  comp->hasFocus = eolTrue;
  comp->canHasFocus = eolTrue;
  eol_window_add_component(win,comp);

  eol_window_allocat_callbacks(win,2);
  if ((win->callbacks != NULL) && (win->callbackCount == 2))
  {
    win->callbacks[0] = onOk;
    win->callbacks[1] = onCancel;
  }
  return win;
}