Beispiel #1
0
// naive fixed number of (short) * 0.01
int uiSyncFixed(Ihandle *ih) {
    short *fixedPointer = (short*)IupGetAttribute(ih, SYNCED_VALUE);
    const float maxFixedValue = IupGetFloat(ih, FIXED_MAX);
    const float minFixedValue = IupGetFloat(ih, FIXED_MIN);
    float value = IupGetFloat(ih, "VALUE");
    float newValue = value;
    short fixValue;
    char valueBuf[8];
    if (newValue > maxFixedValue) {
        newValue = maxFixedValue;
    } else if (newValue < minFixedValue) {
        newValue = minFixedValue;
    }

    if (newValue != value && value != 0) {
        sprintf(valueBuf, "%.2f", newValue);
        IupStoreAttribute(ih, "VALUE", valueBuf);
        // put caret at end to enable editing while normalizing
        IupStoreAttribute(ih, "CARET", "10");
    }
    // sync back
    fixValue = newValue / FIXED_EPSILON;
    InterlockedExchange16(fixedPointer, fixValue);
    return IUP_DEFAULT;
}
Beispiel #2
0
static int motFontDlgShow_CB(Ihandle* ih, int state)
{
  if (state == IUP_SHOW)
  {
    Ihandle* sample = IupGetDialogChild(ih, "SAMPLE");
    char* value = iupAttribGet(ih, "PREVIEWTEXT");
    if (value)
      IupStoreAttribute(sample, "TITLE", value);

    value = iupAttribGet(ih, "VALUE");
    if (value)
    {
      IupStoreAttribute(sample, "FONT", value);
      value = IupGetAttribute(sample, "FONTFACE");

      motFontDlgSelectFontFace(ih, value, 1);
    }

    if (!IupGetCallback(ih, "HELP_CB"))
    {
      Ihandle* help_bt = IupGetDialogChild(ih, "HELPBUT");
      IupSetAttribute(help_bt, "VISIBLE", "NO");
    }
  }
  return IUP_DEFAULT;
}
Beispiel #3
0
/** 
 * Function used to make a cell the first visible one. 
 */
static int adjust_origin(TCells* obj, char* attr) { 
  char buffer[ 15 ];
  int lin = -9, col = -9;

  /* Scanning the origin */
  iupStrToIntInt(attr, &lin, &col, ':');

  /* If the origin line is a non-scrollable one, the scrollbar position is
   * set to zero. Otherwise, the sum of the previous widths will be
   * set to the scrollbar position. This algorithm is applied to both
   * scrollbars */
  if (lin <= obj->non_scrollable_lins) {
     IupSetAttribute(obj->self, IUP_POSY, "0"); 
  }
  else if (lin <= get_nlines(obj)) { 
     int ymin_sum = get_ranged_height(obj, obj->non_scrollable_lins+1, lin-1);
     sprintf(buffer, "%d", ymin_sum);
     IupStoreAttribute(obj->self, IUP_POSY, buffer); 
  }

  /* As said before... */
  if (col <= obj->non_scrollable_cols) {
     IupSetAttribute(obj->self, IUP_POSX, "0"); 
  }
  else if (col <= get_ncols(obj)) { 
     int xmin_sum = get_ranged_width(obj, obj->non_scrollable_cols+1, col-1);
     sprintf(buffer, "%d", xmin_sum);
     IupStoreAttribute(obj->self, IUP_POSX, buffer); 
  }

  return 1;
}
Beispiel #4
0
/** 
 * Function used to turn a cell visible 
 * @param i cell line number.
 * @param j cell column number.
 */
static void set_full_visible(TCells* obj, int i, int j) {
  char buffer[ 32 ];
  int xmin, xmax, ymin, ymax;
  int posx = IupGetInt(obj->self, IUP_POSX);
  int posy = IupGetInt(obj->self, IUP_POSY);
  int dx = 0, dy = 0;
  
  /* Getting the frontiers positions for the visible cell */
  int min_x = get_ranged_width(obj, 1, obj->non_scrollable_cols);
  int max_y = obj->height - get_ranged_height(obj, 1, obj->non_scrollable_lins); 

  /* Getting the cell's area limit */
  get_cell_limit(obj, i, j, &xmin, &xmax, &ymin, &ymax);

  /* Adjusting the diference of the scrollbars' position (horizontal) */
  if (xmax > obj->width) dx = xmax - obj->width;
  /* Giving priority to xmin position. This can be seen by the usage
   * of dx at the left part of the expression (using the last dx).
   * This is the case wher the cell cannot be fitted. */
  if (xmin - dx < min_x) dx = - (min_x - xmin); 

  /* Adjusting the diference of the scrollbars' position (horizontal) */
  if (ymax > max_y) dy = - (ymax - max_y);
  if (ymin < 0) dy = -ymin;

  /* Adding the diference to scrollbars' position */
  posx += dx; posy += dy;

  /* Setting iup scrollbars' attributes */
  sprintf(buffer, "%.1f", (float)posx);
  IupStoreAttribute(obj->self, IUP_POSX, buffer); 
  sprintf(buffer, "%.1f", (float)posy);
  IupStoreAttribute(obj->self, IUP_POSY, buffer); 
}
Beispiel #5
0
Ihandle *IupQuakeScale(char *title, float min, float max, float step, char *key, float def)
{
    Ihandle *scale,*label_value,*label_min,*label_max;

    char buf[128];

    scale = IupVal("HORIZONTAL");
    snprintf(buf, 128, "EXPAND=HORIZONTAL, MIN=%.1f, MAX=%.1f, VALUE=%.1f, STEP=0.01", min, max, def);
    IupSetAttributes(scale, buf);
    IupSetCallback(scale, "VALUECHANGED_CB", (Icallback)IupQuakeScaleUpdate);

    snprintf(buf, 16, "%.1f", def);
    label_value = IupLabel(buf);
    IupStoreAttribute(label_value, "EXPAND", "HORIZONTAL");
    IupStoreAttribute(label_value, "ALIGNMENT", "ACENTER:ACENTER");

    snprintf(buf, 16, "%.1f", min);
    label_min = IupLabel(buf);
    IupStoreAttribute(label_min, "ALIGNMENT", "ACENTER:ACENTER");
    snprintf(buf, 16, "%.1f", max);
    label_max = IupLabel(buf);
    IupStoreAttribute(label_max, "ALIGNMENT", "ACENTER:ACENTER");

    return IupVbox(
            IupLabel(title),
            IupHbox(
                label_min,
                label_value,
                label_max,
                NULL
            ),
            scale,
            NULL
    );
}
Beispiel #6
0
Ihandle* IupButton (const char* label, const char* action)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = BUTTON_;
  IupStoreAttribute (n,IUP_TITLE,label);
  if (action) IupStoreAttribute (n,IUP_ACTION,action);
  return n;
}
Beispiel #7
0
// X zoom
int dial2_btndown_cb(Ihandle *self, double angle)
{
  int ii = tabs_get_index();

  IupStoreAttribute(plot[ii], "OLD_XMIN", IupGetAttribute(plot[ii], "AXS_XMIN"));
  IupStoreAttribute(plot[ii], "OLD_XMAX", IupGetAttribute(plot[ii], "AXS_XMAX"));

  return IUP_DEFAULT;
}
Beispiel #8
0
int main(int argc, char **argv)
{
    Ihandle *win,*tabs,*buttons;

    IupOpen(&argc, &argv);      

    tabs = IupTabs(
        IupQuakeBindingLayout(),
        IupQuakeMouseLayout(),
        IupFill(),
        IupFill(),
        IupFill(),
        NULL
    );
    IupStoreAttribute(tabs, "TABTITLE0", "Keyboard");
    IupStoreAttribute(tabs, "TABTITLE1", "Mouse");
    IupStoreAttribute(tabs, "TABTITLE2", "Audio");
    IupStoreAttribute(tabs, "TABTITLE3", "Video");
    IupStoreAttribute(tabs, "TABTITLE4", "Multiplayer");

    IupStoreAttribute(tabs, "MARGIN", "2x2");

    buttons = IupHbox(
        IupSetCallbacks(IupButton("&Quit", "ACTION"), "ACTION", (Icallback)IupExitLoop, NULL),
        IupFill(),
        IupButton("&Save", NULL),
        IupFill(),
        IupButton("&Launch game", NULL),
        NULL
    );

    win = IupDialog(
            IupSetAttributes(
                IupVbox(
                    IupSetAttributes(
                        IupLabel("Action Quake 2 Configuration"),
                        "EXPAND=YES, ALIGNMENT=ACENTER:ACENTER, FONT=\"sans-serif, Bold 18\""
                    ),
                    tabs,
                    //buttons,
                    NULL
                ),
                "GAP=5, MARGIN=3x3"
            )
    );

    IupStoreAttribute(win, "TITLE", "Action Quake 2 Configuration");
    IupStoreAttribute(win, "RESIZE", "NO");

    IupShow(win);

    /* bug? */
    IupStoreAttribute(win, "SIZE", NULL);
    IupRefresh(win);

    IupMainLoop();
}
Beispiel #9
0
void IupSetAttributeHandle(Ihandle *ih, const char* name, Ihandle *ih_named)
{
  char* handle_name = IupGetName(ih_named);
  if (handle_name)
    IupStoreAttribute(ih, name, handle_name);
  else
  {
    char str_name[100];
    sprintf(str_name, "_IUP_NAME(%p)", ih_named);
    IupSetHandle(str_name, ih_named);
    IupStoreAttribute(ih, name, str_name);
  }
}
Beispiel #10
0
static void SetAttribute(void)
{
  if (lua_isnil(lua_getparam(3)))
    IupSetAttribute(iuplua_checkihandle(1), luaL_check_string(2), NULL);
  else
    IupStoreAttribute(iuplua_checkihandle(1), luaL_check_string(2), luaL_check_string(3));
}
Beispiel #11
0
Ihandle* IupCanvas (const char* action)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = CANVAS_;
  if (action) IupStoreAttribute (n,IUP_ACTION,action);
  return n;
}
Beispiel #12
0
Ihandle* IupList (const char* action)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = LIST_;
  if (action) IupStoreAttribute (n,IUP_ACTION,action);
  return n;
}
void iupShowError(Ihandle* parent, const char* message)
{
  Ihandle* dlg = IupMessageDlg();
  char* title = NULL, *str_message;

  if (parent)
  {
    IupSetAttributeHandle(dlg, "PARENTDIALOG", parent);
    title = IupGetAttribute(parent, "TITLE");
  }

  if (!title)
    title = "_@IUP_ERROR";

  IupSetStrAttribute(dlg, "TITLE", title);
  IupSetAttribute(dlg, "DIALOGTYPE", "ERROR");
  IupSetAttribute(dlg, "BUTTONS", "OK");

  str_message = IupGetLanguageString(message);
  if (!str_message)
    str_message = (char*)message;
  IupStoreAttribute(dlg, "VALUE", str_message);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  IupDestroy(dlg);
}
Beispiel #14
0
static int iMatrixSetMultilineAttrib(Ihandle* ih, const char* value)
{
  IupStoreAttribute(ih->data->texth, "MULTILINE", value);
  if (iupStrBoolean(value))
    IupSetAttribute(ih->data->texth, "SCROLLBAR", "NO");
  return 1;
}
Beispiel #15
0
Ihandle *create_mat(void)
{
  int i, j;
  Ihandle *mat = IupMatrix(NULL); 
  
  IupSetAttribute(mat,IUP_NUMCOL,"2"); 
  IupSetAttribute(mat,IUP_NUMLIN,"100"); 
  
  IupSetAttribute(mat,IUP_NUMCOL_VISIBLE,"2") ;
  IupSetAttribute(mat,IUP_NUMLIN_VISIBLE,"20") ;

  for(i = 0; i < 100; i++)
  {
    for(j = 0; j <= 2; j++)
    {
      char pos[10];
      char pos2[10];
      sprintf(pos, "%d:%d", i, j);
      strcpy(pos2, pos);
      IupStoreAttribute(mat, pos, pos2);
    }
  }

  IupSetAttribute(mat,"WIDTHDEF","34");

  return mat;
}
Beispiel #16
0
int IupQuakeScaleUpdate(Ihandle *ih)
{
    char buf[16];
    Ihandle *label_value = IupGetChild(IupGetChild(IupGetParent(ih), 1), 1);
    snprintf(buf, 16, "%.1f", atof(IupGetAttribute(ih, "VALUE")));
    IupStoreAttribute(label_value, "TITLE", buf);
}
Beispiel #17
0
int edit_cb (Ihandle *self, int c, char *after)
{
  Ihandle *lbl = (Ihandle*)IupGetAttribute(self, "_LABEL");
  if (!c) return IUP_DEFAULT;
  IupStoreAttribute(lbl, "TITLE", after);
  return IUP_DEFAULT;
}
Beispiel #18
0
Ihandle* IupText (const char* action)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = TEXT_;
  if (action) IupStoreAttribute (n,IUP_ACTION,action);
  IupSetAttribute(n, IUP_ALIGNMENT, IUP_ALEFT);
  return n;
}
Beispiel #19
0
static int iMatrixSetValueAttrib(Ihandle* ih, const char* value)
{
  if (IupGetInt(ih->data->datah, "VISIBLE"))
    IupStoreAttribute(ih->data->datah, "VALUE", value);
  else 
    iupMatrixCellSetValue(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, value);
  return 0;
}
Beispiel #20
0
static void iMatrixColResResetMatrixCursor(Ihandle* ih)
{
  char *cursor = iupAttribGetStr(ih, "_IUPMAT_CURSOR");
  if (cursor)
    IupSetAttribute(ih, "CURSOR", "IupMatrixCrossCursor");
  else
    IupStoreAttribute(ih, "CURSOR", cursor);
}
Beispiel #21
0
Ihandle* IupLabel (const char* label)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = LABEL_;
  IupStoreAttribute (n,IUP_TITLE,label);
  IupSetAttribute(n, IUP_ALIGNMENT, IUP_ALEFT);
  return n;
}
Beispiel #22
0
Ihandle* IupMultiLine (const char* action)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = MULTILINE_;
  if (action) IupStoreAttribute (n,IUP_ACTION,action);
  IupSetAttribute(n, IUP_ALIGNMENT, IUP_ALEFT);
  return n;
}
Beispiel #23
0
void IupSetfAttribute(Ihandle *ih, const char* name, const char* f, ...)
{
  static char value[SHRT_MAX];
  va_list arglist;
  va_start(arglist, f);
  vsprintf(value, f, arglist);
  va_end(arglist);
  IupStoreAttribute(ih, name, value);
}
Beispiel #24
0
static void iMatrixColResResetMatrixCursor(Ihandle* ih)
{
  char *cursor = iupAttribGet(ih, "_IUPMAT_CURSOR");
  if (cursor)
  {
    IupStoreAttribute(ih, "CURSOR", cursor);
    iupAttribSetStr(ih, "_IUPMAT_CURSOR", NULL);
  }
}
Beispiel #25
0
Ihandle* IupSubmenu (const char* label, Ihandle* exp)
{
  Ihandle *n = iupTreeCreateNode(NULL);
  type(n) = SUBMENU_;
  child(n) = exp;
  if (exp) parent(exp)=n;
  IupStoreAttribute (n,IUP_TITLE,label);
  return n;
}
Beispiel #26
0
void IupSetfAttribute (Ihandle *n, const char* a, const char* f, ...)
{
  static char v[SHRT_MAX];
  va_list arglist;
  va_start(arglist, f);
  vsprintf(v, f, arglist);
  va_end (arglist);
  IupStoreAttribute(n, a, v);
}
Beispiel #27
0
static int motFontDlgList3_CB(Ihandle *list3, char *name, int item, int state)
{
  (void)item;
  if (state)
  {
    Ihandle* sample = IupGetDialogChild(list3, "SAMPLE");
    IupStoreAttribute(sample, "FONTSIZE", name);
  }
  return IUP_DEFAULT;
}
Beispiel #28
0
int iupSetFontAttrib(Ihandle* ih, const char* value)
{
  /* when set FONT can be an OLD IUP Font or a Native font */
  const char* standardfont = IupMapFont(value);
  if (!standardfont)
    standardfont = value;

  IupStoreAttribute(ih, "STANDARDFONT", standardfont);
  return 0;
}
Beispiel #29
0
// shared callbacks
int uiSyncChance(Ihandle *ih) {
    char valueBuf[8];
    float value = IupGetFloat(ih, "VALUE"), newValue = value;
    short *chancePtr = (short*)IupGetAttribute(ih, SYNCED_VALUE);
    if (newValue > 100.0f) {
       newValue = 100.0f;
    } else if (newValue < 0) {
       newValue = 0.0f;
    }
    if (newValue != value) { // equality compare is fine since newValue is a copy of value
        sprintf(valueBuf, "%.1f", newValue);
        IupStoreAttribute(ih, "VALUE", valueBuf);
        // put caret at end to enable editing while normalizing
        IupStoreAttribute(ih, "CARET", "10");
    }
    // and sync chance value
    InterlockedExchange16(chancePtr, (short)(newValue * 100));
    return IUP_DEFAULT;
}
Beispiel #30
0
int iupmaskSet(Ihandle* ih, const char* mask_str, int autofill, int casei)
{
    (void)autofill;
    IupSetAttribute(ih,"MASKCASEI", casei?"YES":"NO");
    IupStoreAttribute(ih,"MASK", mask_str);
    if (iupStrEqual(mask_str, IupGetAttribute(ih,"MASK")))
        return 1;
    else
        return 0;
}