Example #1
0
int goto_ok_action_cb(Ihandle* bt_ok)
{
  int line_count = IupGetInt(bt_ok, "TEXT_LINECOUNT");
  Ihandle* txt = IupGetDialogChild(bt_ok, "LINE_TEXT");
  int line = IupGetInt(txt, "VALUE");
  if (line < 1 || line >= line_count)
  {
    IupMessage("Error", "Invalid line number.");
    return IUP_DEFAULT;
  }

  IupSetAttribute(IupGetDialog(bt_ok), "STATUS", "1");
  return IUP_CLOSE;
}
Example #2
0
void iupmotCBcaret (Widget w, XtPointer client_data, XtPointer call_data)
{
   IFnii cb;
   Iwidgetdata *d = NULL;
   Ihandle *n;
   XmTextVerifyCallbackStruct* textverify = (XmTextVerifyCallbackStruct*)call_data;

   if (iupmot_incallback) return;

   XtVaGetValues (w, XmNuserData, &d, NULL);
   if (!d) return;
   n = d->ihandle;

   if (n == NULL) return;
   cb = (IFnii) IupGetCallback(n, "CARET_CB");
   if (cb)
   {
      int old_col, old_row, col, row=1;
      long int pos;

      pos = textverify->newInsert;

      if (type(n) == TEXT_ || (type(n) == LIST_ && iupCheck(n, "EDITBOX")==YES))
      {
        col = pos+1;
      }
      else /* MULTILINE_ */
      {
        long int linText, colText;
        char *str = XmTextGetString((Widget)handle(n));
        iupmotLincol( str, pos, &linText, &colText );
        row = linText;
        col = colText;
      }

      old_col = IupGetInt(n, "_IUPMOT_CARETCOL");
      old_row = IupGetInt(n, "_IUPMOT_CARETROW");
      if (row != old_row || col != old_col)
      {
        IupSetfAttribute(n, "_IUPMOT_CARETCOL", "%d", col);
        IupSetfAttribute(n, "_IUPMOT_CARETROW", "%d", row);

        iupmot_incallback = TRUE;
        if (cb(n, row, col) == IUP_CLOSE) 
          iupmot_exitmainloop = 1;
        iupmot_incallback = FALSE;
      }
   }
}
Example #3
0
static void iMatrixDrawFeedbackImage(Ihandle* ih, int x1, int x2, int y1, int y2, int lin, int col, int active, int marked, const char*name, unsigned char* alpha)
{
  int x, y;
  Ihandle* image = IupGetHandle(name);
  if (image)
  {
    long bgcolor;
    int image_width = IupGetInt(image, "WIDTH");
    int image_height = IupGetInt(image, "HEIGHT");
    unsigned char r = 255, g = 255, b = 255;
    iupMatrixGetBgRGB(ih, lin, col, &r, &g, &b, marked, active);
    bgcolor = cdEncodeColor(r, g, b);

    y = (y2 + y1 + image_height) / 2;
    x = (x2 + x1 - image_width) / 2;

    cdIupDrawImage(ih->data->cd_canvas, image, x, iupMATRIX_INVERTYAXIS(ih, y), 0, 0, !active, bgcolor);
  }
  else
  {
    static unsigned char red[IMAT_FEEDBACK_SIZE * IMAT_FEEDBACK_SIZE];
    static unsigned char green[IMAT_FEEDBACK_SIZE * IMAT_FEEDBACK_SIZE];
    static unsigned char blue[IMAT_FEEDBACK_SIZE * IMAT_FEEDBACK_SIZE];
    static unsigned char last_r = 0, last_g = 0, last_b = 0;
    static int first = 1;

    unsigned char r = 0, g = 0, b = 0;
    iupMatrixGetFgRGB(ih, lin, col, &r, &g, &b, marked, active);

    if (first || last_r != r || last_g != g || last_b != b)
    {
      int count = IMAT_FEEDBACK_SIZE * IMAT_FEEDBACK_SIZE;

      memset(red, r, count);
      memset(green, g, count);
      memset(blue, b, count);

      last_r = r;
      last_g = g;
      last_b = b;
      first = 0;
    }

    y = (y2 + y1 + IMAT_FEEDBACK_SIZE) / 2;
    x = (x2 + x1 - IMAT_FEEDBACK_SIZE) / 2;

    cdCanvasPutImageRectRGBA(ih->data->cd_canvas, IMAT_FEEDBACK_SIZE, IMAT_FEEDBACK_SIZE, red, green, blue, alpha, x, iupMATRIX_INVERTYAXIS(ih, y), IMAT_FEEDBACK_SIZE, IMAT_FEEDBACK_SIZE, 0, 0, 0, 0);
  }
}
Example #4
0
/* Function used to calculate a cell limits */
static int iCellsGetLimits(Ihandle* ih, int i, int j, int* xmin, int* xmax, int* ymin, int* ymax)
{
  int result = 1;
  int xmin_sum = 0;
  int ymin_sum = 0;
  int w = ih->data->w;
  int h = ih->data->h;
  int _xmin, _xmax, _ymin, _ymax;

  /* Adjusting the inital position according to the cell's type. If it
   * is non-scrollable, the origin is always zero, otherwise the origin 
   * is the scrollbar position */
  int posx = (j <= ih->data->non_scrollable_cols)? 0: IupGetInt(ih, "POSX");
  int posy = (i <= ih->data->non_scrollable_lins)? 0: IupGetInt(ih, "POSY");
  int idx;

  /* Adding to the origin, the cells' width and height */
  for (idx = 1; idx < j; idx++)
    xmin_sum += iCellsGetWidth(ih, idx);
  
  for (idx = 1; idx < i; idx++)
    ymin_sum += iCellsGetHeight(ih, idx);

  /* Finding the cell origin */
  _xmin = xmin_sum - posx;
  _ymax = h - (ymin_sum - posy) - 1;

  /* Computing the cell limit, based on its origin and size */
  _xmax = _xmin + iCellsGetWidth(ih, j);
  _ymin = _ymax - iCellsGetHeight(ih, i);

  /* Checking if the cell is visible */
  if (_xmax < 0 || _xmin > w || _ymin > h || _ymax < 0)
    result = 0;

  if (xmin != NULL)
    *xmin = _xmin;

  if (xmax != NULL)
    *xmax = _xmax;

  if (ymin != NULL)
    *ymin = _ymin;

  if (ymax != NULL)
    *ymax = _ymax;

  return result;
}
Example #5
0
static int iScrollBoxScroll_CB(Ihandle *ih, int op, float posx, float posy)
{
  if (ih->firstchild)
  {
    if (IupGetInt(ih, "DX") > IupGetInt(ih, "XMAX")-iupdrvGetScrollbarSize())
      posx = 0;
    if (IupGetInt(ih, "DY") > IupGetInt(ih, "YMAX")-iupdrvGetScrollbarSize())
      posy = 0;

    iupBaseSetPosition(ih->firstchild, -(int)posx, -(int)posy);
    iupLayoutUpdate(ih->firstchild);
  }
  (void)op;
  return IUP_DEFAULT;
}
Example #6
0
static int iScrollBoxButton_CB(Ihandle *ih, int but, int pressed, int x, int y, char* status)
{
  if (but==IUP_BUTTON1 && pressed)
  {
    iupAttribSetInt(ih, "_IUP_START_X", x);
    iupAttribSetInt(ih, "_IUP_START_Y", y);
    iupAttribSetInt(ih, "_IUP_START_POSX", IupGetInt(ih, "POSX"));
    iupAttribSetInt(ih, "_IUP_START_POSY", IupGetInt(ih, "POSY"));
    iupAttribSet(ih, "_IUP_DRAG_SB", "1");
  }
  if (but==IUP_BUTTON1 && !pressed)
    iupAttribSet(ih, "_IUP_DRAG_SB", NULL);
  (void)status;
  return IUP_DEFAULT;
}
Example #7
0
static int iPlayTimer_CB(Ihandle* timer)
{
  FILE* file = (FILE*)IupGetAttribute(timer, "_IUP_PLAYFILE");
  if(feof(file) || ferror(file))
  {
    fclose(file);
    IupSetAttribute(timer, "RUN", "NO");
    IupDestroy(timer);
    IupSetGlobal("_IUP_PLAYTIMER", NULL);
    return IUP_IGNORE;
  }
  else
  {
    int cont = 1;
    int mode = IupGetInt(timer, "_IUP_PLAYMODE");

/*    while (cont)    //did not work, menus do not receive the click, why? */
    {
      cont = iPlayAction(file, mode);

      if (cont == -1)  /* error */
      {
        fclose(file);
        IupSetAttribute(timer, "RUN", "NO");
        IupDestroy(timer);
        IupSetGlobal("_IUP_PLAYTIMER", NULL);
        return IUP_IGNORE;
      }
    }

    IupFlush();
  }

  return IUP_DEFAULT;
}
Example #8
0
static void new_color(void)
{
  Ihandle* dlg = IupColorDlg();

  IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_");
  IupSetAttribute(dlg, "VALUE", "128 0 255");
  IupSetAttribute(dlg, "ALPHA", "142");
  //IupSetAttribute(dlg, "COLORTABLE", ";;177 29 234;;;0 0 23;253 20 119");
  IupSetAttribute(dlg, "SHOWHEX", "YES");
  IupSetAttribute(dlg, "SHOWCOLORTABLE", "YES");
  //IupSetAttribute(dlg, "SHOWALPHA", "YES");
  IupSetAttribute(dlg, "TITLE", "IupColorDlg Test");
  IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  if (IupGetInt(dlg, "STATUS"))
  {
    printf("OK\n");
    printf("  VALUE(%s)\n", IupGetAttribute(dlg, "VALUE"));
    printf("  COLORTABLE(%s)\n", IupGetAttribute(dlg, "COLORTABLE"));
  }
  else
    printf("CANCEL\n");

  IupDestroy(dlg);
}
Example #9
0
int edit_menu_open_cb(Ihandle* ih)
{
  Ihandle *clipboard = IupClipboard(); 

  Ihandle *item_paste = IupGetDialogChild(ih, "ITEM_PASTE");
  Ihandle *item_cut = IupGetDialogChild(ih, "ITEM_CUT");
  Ihandle *item_delete = IupGetDialogChild(ih, "ITEM_DELETE");
  Ihandle *item_copy = IupGetDialogChild(ih, "ITEM_COPY");
  Ihandle* multitext = IupGetDialogChild(ih, "MULTITEXT");

  if (!IupGetInt(clipboard, "TEXTAVAILABLE"))
    IupSetAttribute(item_paste, "ACTIVE", "NO");
  else
    IupSetAttribute(item_paste, "ACTIVE", "YES");

  if (!IupGetAttribute(multitext, "SELECTEDTEXT")) 
  {
    IupSetAttribute(item_cut, "ACTIVE", "NO");
    IupSetAttribute(item_delete, "ACTIVE", "NO");
    IupSetAttribute(item_copy, "ACTIVE", "NO");
  }
  else 
  {
    IupSetAttribute(item_cut, "ACTIVE", "YES");
    IupSetAttribute(item_delete, "ACTIVE", "YES");
    IupSetAttribute(item_copy, "ACTIVE", "YES");
  }

  IupDestroy(clipboard);
  return IUP_DEFAULT;
}
Example #10
0
int select_file(Ihandle* parent_dlg, int is_open)
{
  Ihandle* config = (Ihandle*)IupGetAttribute(parent_dlg, "CONFIG");
  Ihandle* canvas = IupGetDialogChild(parent_dlg, "CANVAS");
  const char* dir = IupConfigGetVariableStr(config, "MainWindow", "LastDirectory");

  Ihandle* filedlg = IupFileDlg();
  if (is_open)
    IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN");
  else
  {
    IupSetAttribute(filedlg, "DIALOGTYPE", "SAVE");
    IupSetStrAttribute(filedlg, "FILE", IupGetAttribute(canvas, "FILENAME"));
  }
  IupSetAttribute(filedlg, "EXTFILTER", "Image Files|*.bmp;*.jpg;*.png;*.tif;*.tga|All Files|*.*|");
  IupSetStrAttribute(filedlg, "DIRECTORY", dir);
  IupSetAttributeHandle(filedlg, "PARENTDIALOG", parent_dlg);

  IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT);
  if (IupGetInt(filedlg, "STATUS") != -1)
  {
    char* filename = IupGetAttribute(filedlg, "VALUE");
    if (is_open)
      open_file(parent_dlg, filename);
    else
      saveas_file(canvas, filename);

    dir = IupGetAttribute(filedlg, "DIRECTORY");
    IupConfigSetVariableStr(config, "MainWindow", "LastDirectory", dir);
  }

  IupDestroy(filedlg);
  return IUP_DEFAULT;
}
Example #11
0
File: tree.c Project: Airr/iup_mac
static int nodeinfo(Ihandle* ih)
{
  char attr[50], *kind;
  Ihandle* tree = IupGetHandle("tree");
  int branch = 0, id = IupGetInt(tree, "VALUE");
  printf("\nTree Info:\n");
  printf("  TOTALCOUNT=%s\n", IupGetAttribute(tree, "COUNT"));
  printf("Node Info:\n");
  printf("  ID=%d\n", id);
  printf("  TITLE=%s\n", IupGetAttribute(tree, "TITLE"));
  printf("  DEPTH=%s\n", IupGetAttribute(tree, "DEPTH"));
  sprintf(attr, "KIND%d", id);
  kind = IupGetAttribute(tree, "KIND");
  printf("  KIND=%s\n", kind);
  if (strcmp(kind, "BRANCH")==0) branch = 1;
  if (branch)
    printf("  STATE=%s\n", IupGetAttribute(tree, "STATE"));
  printf("  IMAGE=%s\n", IupGetAttribute(tree, "IMAGE"));
  if (branch)
    printf("  IMAGEBRANCHEXPANDED=%s\n", IupGetAttribute(tree, "IMAGEBRANCHEXPANDED"));
  printf("  MARKED=%s\n", IupGetAttribute(tree, "MARKED"));
  printf("  COLOR=%s\n", IupGetAttribute(tree, "COLOR"));
  printf("  PARENT=%s\n", IupGetAttribute(tree, "PARENT"));
  printf("  COUNT=%s\n", IupGetAttribute(tree, "CHILDCOUNT"));
  printf("  USERDATA=%p\n", IupGetAttribute(tree, "USERDATA"));
  return IUP_DEFAULT;
}
Example #12
0
/* Change the cursor when it passes over a group of the column titles.
   -> x,y : mouse coordinates (canvas coordinates)
*/
void iupMatrixColResChangeCursor(Ihandle* ih, int x, int y)
{
  int ativo = IupGetInt(ih, "RESIZEMATRIX");

  if(ih->data->lin.titlewh && y < ih->data->lin.titlewh && ativo)
  {
    /* It is in the column titles area and the resize mode is on */
    int found = 0, width = ih->data->col.titlewh, col;

    if(abs(width - x) < IMAT_TOL)
      found = 1;    /* line titles */
    else
    {
      for(col = ih->data->col.first; col <= ih->data->col.last && !found; col++)
      {
        width += ih->data->col.wh[col];
        if(abs(width - x) < IMAT_TOL)
          found = 1;
      }
    }

    if (found)
    {
      iupAttribStoreStr(ih, "_IUPMAT_CURSOR", iupAttribGetStr(ih, "CURSOR"));
      IupSetAttribute(ih, "CURSOR", "RESIZE_W");
    }
    else /* It is in the empty area after the last column */
      iMatrixColResResetMatrixCursor(ih); 
  }
  else
    iMatrixColResResetMatrixCursor(ih);
}
Example #13
0
static int cbHideThisTab(Ihandle* ih)
{
  Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS");
  int pos = IupGetInt(ih, "APP_THISTAB");
  IupSetAttributeId(tabs, "TABVISIBLE", pos, "No");
  return IUP_DEFAULT;
}
Example #14
0
int item_open_action_cb(Ihandle* item_open)
{
  Ihandle* multitext = IupGetDialogChild(item_open, "MULTITEXT");
  Ihandle *filedlg = IupFileDlg();
  IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN");
  IupSetAttribute(filedlg, "FILTER", "*.txt");
  IupSetAttribute(filedlg, "FILTERINFO", "Text Files");
  IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_open));

  IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  if (IupGetInt(filedlg, "STATUS") != -1)
  {
    char* filename = IupGetAttribute(filedlg, "VALUE");
    char* str = read_file(filename);
    if (str)
    {
      IupSetStrAttribute(multitext, "VALUE", str);
      free(str);
    }
  }

  IupDestroy(filedlg);
  return IUP_DEFAULT;
}
Example #15
0
void iupdrvActivate(Ihandle* ih)
{
  int is_toggle = IupClassMatch(ih, "toggle");
  int is_radio = 0;
  if (is_toggle)
    is_radio = IupGetInt(ih, "RADIO");

  /* do not use BM_CLICK because it changes the focus 
     and does not animates the button press */

  /* draw highlight */
  SendMessage(ih->handle, BM_SETSTATE, TRUE, 0);
  IupFlush();
  Sleep(150);

  /* must force a toggle change */
  if (is_toggle && !is_radio)
    IupSetAttribute(ih, "VALUE", "TOGGLE");

  /* notify */
  SendMessage(GetParent(ih->handle), WM_COMMAND, MAKEWPARAM(0, BN_CLICKED), (LPARAM)ih->handle);

  /* remove highlight */
  SendMessage(ih->handle, BM_SETSTATE, FALSE, 0);

  /* must force a radio change */
  if (is_toggle && is_radio)
    IupSetAttribute(ih, "VALUE", "TOGGLE");
}
Example #16
0
static void iDetachBoxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
{
  /* bar */
  if (ih->data->orientation == IDBOX_VERT)
  {
    ih->firstchild->currentwidth  = ih->data->barsize;
    ih->firstchild->currentheight = ih->currentheight;
  }
  else  /* IDBOX_HORIZ */
  {
    ih->firstchild->currentwidth  = ih->currentwidth;
    ih->firstchild->currentheight = ih->data->barsize;
  }

  /* child */
  if (ih->firstchild->brother)
  {
    int width = ih->currentwidth;
    int height = ih->currentheight;

    if (IupGetInt(ih->firstchild, "VISIBLE"))
    {
      if (ih->data->orientation == IDBOX_VERT)
        width -= ih->data->barsize;
      else
        height -= ih->data->barsize;
    }

    if (width < 0) width = 0;
    if (height < 0) height = 0;

    iupBaseSetCurrentSize(ih->firstchild->brother, width, height, shrink);
  }
}
Example #17
0
static int cbTest(Ihandle* ih)
{
  Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS");



#if 0
  char att[50];
  int m_handle_id = 1;
  char* title;
  sprintf(att, "TABTITLE%d", m_handle_id);
  {
    Ihandle* child = IupGetChild(tabs, 1);
    title = IupGetAttribute(child, "TABTITLE");
    printf("%s=%s\n", att, title);
  }
  title = IupGetAttribute(tabs, att);
  printf("%s=%s\n", att, title);
#endif

#if 0
  IupSetAttribute(tabs, "VALUEPOS", "0");
  IupSetAttribute(tabs, "TABTITLE0", "1asdasd");
  printf("VALUE=%s\n", IupGetAttribute(tabs, "VALUE"));
  if (IupGetInt(tabs, "TABVISIBLE2"))
    IupSetAttribute(tabs, "TABVISIBLE2", "No");
  else
    IupSetAttribute(tabs, "TABVISIBLE2", "Yes");
#endif

  return IUP_DEFAULT;
}
Example #18
0
static void iMatrixDrawSort(Ihandle* ih, int x2, int y1, int y2, int xc, int lin, int col, char* sort)
{
  int yc;

  /* Create an space between text and cell margin */
  x2 -= IMAT_DECOR_X / 2;       xc -= IMAT_DECOR_X / 2;

  /* Set the color used to draw the text */
  if((lin > 0 && ih->data->lin.inactive[lin-1]) ||
     (col > 0 && ih->data->col.inactive[col-1]) ||
     !IupGetInt(ih, "ACTIVE"))
    cdCanvasForeground(ih->data->cddbuffer, IMAT_CD_INACTIVE_COLOR);
  else
    iMatrixDrawSetFgColor(ih, lin, col, 0);

  yc = (int)( (y1 + y2 ) / 2.0 - .5);

  cdCanvasBegin(ih->data->cddbuffer, CD_FILL);

  if(iupStrEqualNoCase(sort, "UP"))
  {
    CdVertex(x2 - 5, yc + 2);
    CdVertex(x2 - 1, yc - 2);
    CdVertex(x2 - 9, yc - 2);
  }
  else
  {
    CdVertex(x2 - 1, yc + 2);
    CdVertex(x2 - 9, yc + 2);
    CdVertex(x2 - 5, yc - 2);
  }

  cdCanvasEnd(ih->data->cddbuffer);
}
Example #19
0
static void iGLExpanderDrawExtraButton(Ihandle* ih, int button, int x, int y, int height)
{
  char* image = iupAttribGetId(ih, "IMAGEEXTRA", button);
  int active = IupGetInt(ih, "ACTIVE");
  int img_height;

  if (!image)
    return;

  if (ih->data->extra_buttons_state[button] == 1)
  {
    char* impress = iupAttribGetId(ih, "IMAGEEXTRAPRESS", button);
    if (impress) image = impress;
  }
  else if (ih->data->extra_buttons_state[button] == -1)
  {
    char* imhighlight = iupAttribGetId(ih, "IMAGEEXTRAHIGHLIGHT", button);
    if (imhighlight) image = imhighlight;
  }

  iupGLImageGetInfo(image, NULL, &img_height, NULL);
  if (height > img_height)
    y += (height - img_height) / 2;

  iupGLDrawImage(ih, x, y, image, !active);
}
Example #20
0
// parameterized setter
void setFromParameter(Ihandle *ih, const char *field, const char *key) {
    char* val = IupGetGlobal(key);
    Icallback cb;
    IstateCallback scb;
    // FIXME there should be a way to trigger handler
    // manually trigger the callback, as iup won't call it
    // Notice that currently only works on IupToggle, IupText
    // and Iup lacks a way to get widget's type, so can't do much about this
    if (val) {
        IupSetAttribute(ih, field, val);
        cb = IupGetCallback(ih, "VALUECHANGED_CB");
        if (cb) {
            LOG("triggered VALUECHANGED_CB on key: %s", key);
            cb(ih);
            return;
        }
        // cb's argument type IS NOT ONLY Ihandle, receives a extra "state" int
        scb = (IstateCallback)IupGetCallback(ih, "ACTION");
        if (scb) {
            LOG("triggered ACTION on key: %s", key);
            // IupGetInt handles yes/no on/off upper lower case things.
            scb(ih, IupGetInt(ih, "VALUE"));
            return;
        }
    }
}
Example #21
0
static int addleaf(void)
{
  Ihandle* tree = IupGetHandle("tree");
  int id = IupGetInt(tree, "VALUE");
  IupTreeSetAttribute(tree, "ADDLEAF", id, "");
  return IUP_DEFAULT;
}
Example #22
0
static int iZboxSetValueHandleAttrib(Ihandle* ih, const char* value)
{
  int visible;
  Ihandle* old_handle, *new_handle, *child;

  new_handle = (Ihandle*)value;
  if (!iupObjectCheck(new_handle))
    return 0;

  old_handle = ih->data->value_handle;
  if (!iupObjectCheck(old_handle))
    old_handle = NULL;

  if (old_handle == new_handle)
    return 0;

  visible = IupGetInt(ih, "VISIBLE");

  for (child = ih->firstchild; child; child = child->brother)
  {
    if (child == new_handle) /* found child */
    {
      if (old_handle && old_handle != new_handle)
        IupSetAttribute(old_handle, "VISIBLE", "NO");

      IupSetAttribute(new_handle, "VISIBLE", visible? "YES": "NO");
      ih->data->value_handle = new_handle;
      return 0;
    }
  }
 
  return 0;
}
Example #23
0
static int insertbranch(void)
{
  Ihandle* tree = IupGetHandle("tree");
  int id = IupGetInt(tree, "VALUE");
  IupTreeSetAttribute(tree, "INSERTBRANCH", id, "");
  return IUP_DEFAULT;
}
Example #24
0
static int iMatrixExSetNumericUnitSymbolSearchAttrib(Ihandle* ih, const char* value)
{
  int q, u;

  int utf8 = IupGetInt(NULL, "UTF8MODE");

  iupAttribSet(ih, "NUMERICFOUNDQUANTITY", NULL);
  iupAttribSet(ih, "NUMERICFOUNDUNIT", NULL);
  iupAttribSet(ih, "NUMERICFOUNDUNITSYMBOL", NULL);

  for (q=0; q<imatex_quantity_count; q++)
  {
    ImatExUnit* units = (ImatExUnit*)(imatex_quantities[q].units);
    int units_count = imatex_quantities[q].units_count;
    for (u=0; u<units_count; u++)
    {
      const char* symbol;
      if (utf8 && units[u].symbol_utf8)
        symbol = units[u].symbol_utf8;
      else
        symbol = units[u].symbol;

      if (iupStrEqual(symbol, value))
      {
        iupAttribSet(ih, "NUMERICFOUNDQUANTITY", imatex_quantities[q].q_name);
        iupAttribSet(ih, "NUMERICFOUNDUNIT", units[u].u_name);
        iupAttribSetStr(ih, "NUMERICFOUNDUNITSYMBOL", symbol);
        return 0;
      }
    }
  }

  (void)ih;
  return 0;
}
Example #25
0
static int k_enter_cb(Ihandle*ih)
{
  int pos = IupGetInt(ih, "VALUE");
  if (pos > 0)
    test_list[pos-1].func();
  return IUP_DEFAULT;
}
Example #26
0
static void drawTest(Ihandle* ih)
{
  GC gc = (GC)IupGetAttribute(ih, "PREVIEWDC");
  Display* dpy = (Display*)IupGetAttribute(ih, "XDISPLAY");
  Drawable wnd = (Drawable)IupGetAttribute(ih, "XWINDOW");
  int w = IupGetInt(ih, "PREVIEWWIDTH");
  int h = IupGetInt(ih, "PREVIEWHEIGHT");

  XSetForeground(dpy, gc, xGetPixel(dpy, 255, 255, 255));
  XFillRectangle(dpy, wnd, gc, 0, 0, w, h);

  XSetForeground(dpy, gc, xGetPixel(dpy, 255, 0, 0));

  XDrawLine(dpy, wnd, gc, 0, 0, w-1, h-1);
  XDrawLine(dpy, wnd, gc, 0, h-1, w-1, 0);
}
Example #27
0
void guiSave( void )
{
  int i = ( guiMenu ? IupGetInt ( guiMenu, "MEDIT_I" ) : guiMenu_Org );
  char path[ PATH_MAX ] = {0};
  char opath[ PATH_MAX ] = {0};

  if ( !appMethods.OnDefPath || !appMethods.OnDefExt )
  {
    return;
  }

  copystri ( path, ipGetUsrDir(), PATH_MAX );
  appendstr ( path, DIR_SEP ".medit" DIR_SEP "data", PATH_MAX );
  copystri ( opath, path, PATH_MAX );
  appMethods.OnDefPath ( opath );
  appMethods.OnApply();
  appMethods.OnDefPath ( path );

  // Rename Directory
  if ( _access( opath, 0 ) == 0 && istrcmp( opath, path ).i )
  {
    rename( opath, path );
  }

  if ( i >= guiMenu_Hacks )
  {
    appendstr ( opath, "*.", PATH_MAX );
    appendstr ( path, "*.", PATH_MAX );
  }
  else
  {
    appendstr ( opath, ".", PATH_MAX );
    appendstr ( path, ".", PATH_MAX );
  }

  appMethods.OnDefExt ( path );
  appMethods.OnDefExt ( opath );

  // Rename File
  if ( i < guiMenu_Hacks && _access( opath, 0 ) == 0
       && istrcmp( opath, path ).i )
  {
    rename( opath, path );
  }

  if ( i >= guiMenu_Hacks )
  {
    if ( IupGetFile ( path ) == -1 )
    {
      return;
    }
  }

  if ( _access( path, 0 ) != 0 )
  {
    _creat( path, _S_IREAD | _S_IWRITE );
  }

  appMethods.OnSave ( path );
}
Example #28
0
static char* iMatrixGetValueAttrib(Ihandle* ih)
{
  if (IupGetInt(ih->data->datah, "VISIBLE"))
    return iupMatrixEditGetValue(ih);
  else 
    return iupMatrixCellGetValue(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell);
}
Example #29
0
static void iMatrixEditInitMenu(Ihandle* ih_menu)
{
    char *value;
    int i = 1;
    int v = IupGetInt(ih_menu, "VALUE");

    do
    {
        value = IupGetAttributeId(ih_menu, "", i);
        if (value)
        {
            Ihandle* item = IupItem(value, NULL);

            char* img = IupGetAttributeId(ih_menu, "IMAGE", i);
            if (img)
                IupSetAttribute(item, "IMAGE", img);

            IupSetCallback(item, "ACTION", (Icallback)iMatrixMenuItemAction_CB);

            if (v == i)   /* if v==0 no mark will be shown */
                IupSetAttribute(item, "VALUE", "On");

            IupAppend(ih_menu, item);
        }
        i++;
    } while (value);
}
Example #30
0
int IupGetText(const char* title, char* text)
{
  Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dialog;
  int bt;

  multi_text = IupMultiLine("do_nothing");
  IupSetAttribute(multi_text,IUP_EXPAND, IUP_YES);
  IupSetAttribute(multi_text, IUP_SIZE, "200x80");
  IupSetAttribute(multi_text,IUP_VALUE, text);
  IupSetAttribute(multi_text,IUP_FONT, IUP_COURIER_NORMAL_12);

  ok   = IupButton(strok, NULL);
  IupSetAttribute (ok   ,IUP_SIZE ,"50x");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);
  IupSetHandle( "IupGetTextOkButton", ok );

  cancel  = IupButton(strcancel, NULL);
  IupSetAttribute (cancel,IUP_SIZE ,"50x");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);
  IupSetHandle( "IupGetTextCancelButton", cancel );

  button_box = IupHbox(
    IupSetAttributes(IupFill(), "EXPAND=HORIZONTAL"),
    ok,
    IupSetAttributes(IupFill(), "SIZE=1x"),
    cancel,
    NULL);
  IupSetAttribute(button_box,IUP_MARGIN,"0x0");

  dlg_box = IupVbox(
    multi_text,
    IupSetAttributes(IupFill(), "SIZE=1x"),
    button_box,
    NULL);

  IupSetAttribute(dlg_box,IUP_MARGIN,"10x10");
  IupSetAttribute(dlg_box,IUP_GAP,"5");

  dialog = IupDialog (dlg_box);

  IupSetAttribute (dialog,IUP_TITLE,title);
  IupSetAttribute (dialog,IUP_MINBOX,IUP_NO);
  IupSetAttribute (dialog,IUP_MAXBOX,IUP_NO);
  IupSetAttribute (dialog,IUP_DEFAULTENTER,"IupGetTextOkButton");
  IupSetAttribute (dialog,IUP_DEFAULTESC,"IupGetTextCancelButton");
  IupSetAttribute (dialog,IUP_PARENTDIALOG, IupGetGlobal(IUP_PARENTDIALOG));
  IupSetAttribute (dialog, IUP_ICON, IupGetGlobal(IUP_ICON));

  IupPopup(dialog, IUP_CENTER, IUP_CENTER);

  bt = IupGetInt(dialog, IUP_STATUS);
  if (bt==1)
    strcpy(text, IupGetAttribute(multi_text, IUP_VALUE));
  else
    bt = 0;  /* return 0 instead of -1 */

  IupDestroy(dialog);
  return bt;
}