Example #1
0
int IupGetInt2 (Ihandle *n, const char* a)
{
  int d, i=0;
  char *s=IupGetAttribute (n,a);
  if (s)
  {
    if (!iupStrToIntInt(s,&d,&i,'x'))
      iupStrToIntInt(s,&d,&i,':');
  }
  return i;
}
Example #2
0
int IupGetInt2(Ihandle *ih, const char* name)
{
  int i1 = 0, i2 = 0;
  char *value = IupGetAttribute(ih, name);
  if (value)
  {
    if (!iupStrToIntInt(value, &i1, &i2, 'x'))
      iupStrToIntInt(value, &i1, &i2, ':');
  }
  return i2;
}
Example #3
0
static int gtkDialogSetMaxSizeAttrib(Ihandle* ih, const char* value)
{
  int min_w = 1, min_h = 1;          /* MINSIZE default value */
  int max_w = 65535, max_h = 65535;  /* MAXSIZE default value */
  iupStrToIntInt(value, &max_w, &max_h, 'x');

  /* if MINSIZE also set, must be also updated here */
  iupStrToIntInt(iupAttribGet(ih, "MINSIZE"), &min_w, &min_h, 'x');

  gtkDialogSetMinMax(ih, min_w, min_h, max_w, max_h);
  return 1;
}
Example #4
0
static int iSplitButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status)
{
  Ihandle* ih = bar->parent;

  if (button!=IUP_BUTTON1)
    return IUP_DEFAULT;

  if (!ih->data->is_holding && pressed)
  {
    int cur_x, cur_y;

    ih->data->is_holding = 1;

    iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

    /* Save the cursor position and size */
    if (ih->data->orientation == ISPLIT_VERT)
    {
      ih->data->start_bar = ih->firstchild->x;
      ih->data->start_pos = cur_x;
      ih->data->start_size = iSplitGetWidth1(ih);
    }
    else
    {
      ih->data->start_bar = ih->firstchild->y;
      ih->data->start_pos = cur_y;
      ih->data->start_size = iSplitGetHeight1(ih);
    }
  }
  else if (ih->data->is_holding && !pressed)
  {
    ih->data->is_holding = 0;

    if (!ih->data->layoutdrag)
    {
      if (ih->data->autohide)
      {
        int cur_x, cur_y;
        iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');
        iSplitSetBarPosition(ih, cur_x, cur_y, 0);
        iSplitAutoHideXY(ih);
      }

      IupRefreshChildren(ih);  
    }
  }

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
Example #5
0
int IupGetIntInt(Ihandle *ih, const char* name, int *i1, int *i2)
{
  int _i1 = 0, _i2 = 0;
  char *value = IupGetAttribute(ih, name);
  if (value)
  {
    int count = iupStrToIntInt(value, &_i1, &_i2, 'x');
    if (!count) count = iupStrToIntInt(value, &_i1, &_i2, ':');
    if (i1) *i1 = _i1;
    if (i2) *i2 = _i2;
    return count;
  }
  return 0;
}
Example #6
0
static int iScintillaSetColoriseAttrib(Ihandle* ih, const char* value)
{
  int start = 0, end = -1;
  iupStrToIntInt(value, &start, &end, ':');
  IupScintillaSendMessage(ih, SCI_COLOURISE, start, end);
  return 0;
}
Example #7
0
static int iListSetMaskIntAttrib(Ihandle* ih, const char* value)
{
  if (!ih->data->has_editbox)
    return 0;

  if (!value)
  {
    if (ih->data->mask)
      iupMaskDestroy(ih->data->mask);

    iupAttribSetStr(ih, "MASK", NULL);
  }
  else
  {
    Imask* mask;
    int min, max;

    if (iupStrToIntInt(value, &min, &max, ':')!=2)
      return 0;

    mask = iupMaskCreateInt(min,max);

    if (ih->data->mask)
      iupMaskDestroy(ih->data->mask);

    ih->data->mask = mask;

    if (min < 0)
      iupAttribSetStr(ih, "MASK", IUP_MASK_INT);
    else
      iupAttribSetStr(ih, "MASK", IUP_MASK_UINT);
  }

  return 0;
}
Example #8
0
static int iMatrixSetShowAttrib(Ihandle* ih, const char* value)
{
  int lin = -1, col = -1;

 /* Get the parameters. The '*' indicates that want to keep the table in
    the same line or column */
  if (iupStrToIntInt(value, &lin, &col, ':') != 2)
  {
    if (lin != -1)
      col = ih->data->columns.first;
    else if (col != -1)
      lin = ih->data->lines.first;
    else
      return 0;
  }

  /* Check if the cell exists */
  if (!iupMatrixCheckCellPos(ih, lin, col))
    return 0;

  /* Can not be a title */
  if((lin < 1) || (col < 1))
    return 0;

  if (!iupMatrixAuxIsCellStartVisible(ih, lin, col))
    iupMatrixScrollToVisible(ih, lin, col);

  return 0;
}
Example #9
0
static int iMatrixExSetPasteAttrib(Ihandle *ih, const char* value)
{
  int lin=0, col=0;

  Ihandle* clipboard = IupClipboard();
  char* data = IupGetAttribute(clipboard, "TEXT");
  IupDestroy(clipboard);

  if (iupStrEqualNoCase(value, "FOCUS"))
    IupGetIntInt(ih, "FOCUS_CELL", &lin, &col);
  else if (iupStrEqualNoCase(value, "MARKED"))
  {
    char *marked = IupGetAttribute(ih,"MARKED");
    if (marked)
    {
      int num_lin = IupGetInt(ih, "NUMLIN");
      int num_col = IupGetInt(ih, "NUMCOL");
      iMatrixExCellMarkedStart(marked, num_lin, num_col, &lin, &col);
    }
  }
  else
  {
    if (iupStrToIntInt(value, &lin, &col, ':')!=2)
      return 0;
  }

  iMatrixExPasteData(ih, data, lin, col, "PASTECLIP");
  return 0;
}
Example #10
0
static int winListSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int start=0, end=0;
  HWND cbedit;
  if (!ih->data->has_editbox)
    return 0;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
    SendMessage(cbedit, EM_SETSEL, (WPARAM)-1, (LPARAM)0);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
    SendMessage(cbedit, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
    return 0;
  }

  if (iupStrToIntInt(value, &start, &end, ':')!=2) 
    return 0;

  if(start<0 || end<0) 
    return 0;

  cbedit = (HWND)iupAttribGet(ih, "_IUPWIN_EDITBOX");
  SendMessage(cbedit, EM_SETSEL, (WPARAM)start, (LPARAM)end);

  return 0;
}
static int iMatrixExUndoDataSwap(ImatExData* matex_data, IundoData* undo_data)
{
  char* id = iupTableFirst(undo_data->data_table);
  while (id)
  {
    char *value, *old_value;
    int lin=1, col=1;
    iupStrToIntInt(id, &lin, &col, ':');

    value = (char*)iupTableGetCurr(undo_data->data_table);

    old_value = iupStrDup(iupMatrixExGetCellValue(matex_data->ih, lin, col, 0));  /* get internal value */

    iupMatrixExSetCellValue(matex_data->ih, lin, col, value);

    if (!old_value)
      iupTableSetCurr(undo_data->data_table, (void*)"", IUPTABLE_POINTER);
    else
    {
      iupTableSetCurr(undo_data->data_table, (void*)old_value, IUPTABLE_STRING);
      free(old_value);
    }

    if (!iupMatrixExBusyInc(matex_data))
      return 0;

    id = iupTableNext(undo_data->data_table);
  }

  return 1;
}
Example #12
0
static int motTextSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int start=0, end=0;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    XmTextClearSelection(ih->handle, CurrentTime);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    XmTextSetSelection(ih->handle, (XmTextPosition)0, (XmTextPosition)XmTextGetLastPosition(ih->handle), CurrentTime);
    return 0;
  }

  if (iupStrToIntInt(value, &start, &end, ':')!=2) 
    return 0;

  if(start<0 || end<0) 
    return 0;

  /* end is inside the selection, in IUP is outside */
  end--;

  XmTextSetSelection(ih->handle, (XmTextPosition)start, (XmTextPosition)end, CurrentTime);

  return 0;
}
Example #13
0
static int winButtonSetPaddingAttrib(Ihandle* ih, const char* value)
{
  iupStrToIntInt(value, &ih->data->horiz_padding, &ih->data->vert_padding, 'x');
  if (ih->handle)
    iupdrvRedrawNow(ih);
  return 0;
}
Example #14
0
static int iScintillaSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int anchorPos = 0, currentPos = 0;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    iupScintillaSendMessage(ih, SCI_SETEMPTYSELECTION, 0, 0);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    iupScintillaSendMessage(ih, SCI_SELECTALL, 0, 0);
    return 0;
  }

  if (iupStrToIntInt(value, &anchorPos, &currentPos, ':') != 2) 
    return 0;

  if(anchorPos<0 || currentPos<0) 
    return 0;

  iupScintillaSendMessage(ih, SCI_SETSEL, anchorPos, currentPos);

  return 0;
}
Example #15
0
static int gtkListSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int start=0, end=0;
  GtkEntry* entry;
  if (!ih->data->has_editbox)
    return 0;
  if (!value)
    return 0;

  entry = (GtkEntry*)iupAttribGet(ih, "_IUPGTK_ENTRY");
  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    gtk_editable_select_region(GTK_EDITABLE(entry), 0, 0);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
    return 0;
  }

  if (iupStrToIntInt(value, &start, &end, ':')!=2) 
    return 0;

  if(start<0 || end<0) 
    return 0;

  gtk_editable_select_region(GTK_EDITABLE(entry), start, end);

  return 0;
}
Example #16
0
static int motListSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int start=0, end=0;
  Widget cbedit;
  if (!ih->data->has_editbox)
    return 0;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    XmTextFieldClearSelection(cbedit, CurrentTime);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    XmTextFieldSetSelection(cbedit, (XmTextPosition)0, (XmTextPosition)XmTextFieldGetLastPosition(cbedit), CurrentTime);
    return 0;
  }

  if (iupStrToIntInt(value, &start, &end, ':')!=2) 
    return 0;

  if(start<0 || end<0) 
    return 0;

  /* end is inside the selection, in IUP is outside */
  end--;

  XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
  XmTextFieldSetSelection(cbedit, (XmTextPosition)start, (XmTextPosition)end, CurrentTime);

  return 0;
}
Example #17
0
int iupdrvSetGlobal(const char *name, const char *value)
{
  if (iupStrEqual(name, "LANGUAGE"))
  {
    iupStrMessageUpdateLanguage(value);
    return 1;
  }
  if (iupStrEqual(name, "AUTOREPEAT"))
  {
    XKeyboardControl values;
    if (iupStrBoolean(value))
      values.auto_repeat_mode = 1;
    else
      values.auto_repeat_mode = 0;
    XChangeKeyboardControl(iupmot_display, KBAutoRepeatMode, &values);
    return 0;
  }
  if (iupStrEqual(name, "CURSORPOS"))
  {
    int x, y;
    if (iupStrToIntInt(value, &x, &y, 'x') == 2)
      XWarpPointer(iupmot_display,None,RootWindow(iupmot_display, iupmot_screen),0,0,0,0,x,y);
    return 0;
  }
  return 1;
}
Example #18
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;
}
Example #19
0
static int motTextSetScrollToAttrib(Ihandle* ih, const char* value)
{
  int pos = 1;

  if (!value)
    return 0;

  if (ih->data->is_multiline)
  {
    int lin = 1, col = 1, pos;
    char* str;

    iupStrToIntInt(value, &lin, &col, ',');
    if (lin < 1) lin = 1;
    if (col < 1) col = 1;

    str = XmTextGetString(ih->handle);
    pos = motTextSetLinColToPosition(str, lin, col);
    XtFree(str);
  }
  else
  {
    sscanf(value,"%i",&pos);
    if (pos < 1) pos = 1;
    pos--;  /* return to Motif referece */
  }

  XmTextShowPosition(ih->handle, (XmTextPosition)pos);

  return 0;
}
Example #20
0
static int iMatrixSetFlagsAttrib(Ihandle* ih, const char* name_id, const char* value, unsigned char attr)
{
  if (name_id[0]==0)
    return 1;
  if (name_id[0]=='*' && name_id[1]==':')
  {
    int col;
    name_id += 2; /* skip '*' and ':' */
    if (iupStrToInt(name_id, &col))
      iupMatrixCellSetFlag(ih, -1, col, attr, value!=NULL);
  }
  else if (name_id[strlen(name_id)-1]=='*')
  {
    int lin;
    if (iupStrToInt(name_id, &lin))
      iupMatrixCellSetFlag(ih, lin, -1, attr, value!=NULL);
  }
  else 
  {
    int lin, col;
    if (iupStrToIntInt(name_id, &lin, &col, ':') == 2)
      iupMatrixCellSetFlag(ih, lin, col, attr, value!=NULL);
  }
  return 1;
}
Example #21
0
int iupMatrixDrawSetRedrawAttrib(Ihandle* ih, const char* value)
{
    int type;

    if (value == NULL)
        type = 0;
    else if(value[0] == 'L' || value[0] == 'l')
        type = IMAT_PROCESS_LIN;
    else if(value[0] == 'C' || value[0] == 'c')
        type = IMAT_PROCESS_COL;
    else
        type = 0;

    if (type)  /* lines or columns, inluding their titles */
    {
        int min = 0, max = 0;
        value++;

        if(iupStrToIntInt(value, &min, &max, ':') != 2)
            max = min;

        if (min > max)
            return 0;

        iupMatrixPrepareDrawData(ih);

        if (ih->data->need_calcsize)
            iupMatrixAuxCalcSizes(ih);

        /* ignore empty area, draw only cells */

        iMatrixDrawTitleCorner(ih);

        if (type == IMAT_PROCESS_LIN)
        {
            iupMatrixDrawLineTitle(ih, min, max);
            if (ih->data->columns.num_noscroll>1)
                iupMatrixDrawCells(ih, min, 1, max, ih->data->columns.num_noscroll-1);
            iupMatrixDrawCells(ih, min, ih->data->columns.first, max, ih->data->columns.last);
        }
        else
        {
            iupMatrixDrawColumnTitle(ih, min, max);
            if (ih->data->lines.num_noscroll>1)
                iupMatrixDrawCells(ih, 1, min, ih->data->lines.num_noscroll-1, max);
            iupMatrixDrawCells(ih, ih->data->lines.first, min, ih->data->lines.last, max);
        }
    }
    else
    {
        /* Force CalcSize */
        iupMatrixAuxCalcSizes(ih);

        iMatrixDrawMatrix(ih);
    }

    ih->data->need_redraw = 0;
    iupMatrixDrawUpdate(ih);
    return 0;
}
Example #22
0
static int iSboxButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status)
{
  Ihandle* ih = bar->parent;

  if (button!=IUP_BUTTON1)
    return IUP_DEFAULT;

  if (!ih->data->isholding && pressed)
  {
    ih->data->isholding = 1;

    /* Save the cursor position */
    iupStrToIntInt(IupGetGlobal("CURSORPOS"), &ih->data->start_x, &ih->data->start_y, 'x');

    /* Save the initial size */
    ih->data->start_w = ih->data->w;
    ih->data->start_h = ih->data->h;
  }
  else if (ih->data->isholding && !pressed)
    ih->data->isholding = 0;

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
Example #23
0
static int motTextSetCaretAttrib(Ihandle* ih, const char* value)
{
  int pos = 1;

  if (!value)
    return 0;

  if (ih->data->is_multiline)
  {
    int lin = 1, col = 1;
    char *str;

    iupStrToIntInt(value, &lin, &col, ',');

    str = XmTextGetString(ih->handle);
    pos = motTextSetLinColToPosition(str, lin, col);
    XtFree(str);
  }
  else
  {
    sscanf(value,"%i",&pos);
    pos--; /* IUP starts at 1 */
  }

  XmTextSetInsertionPosition(ih->handle, (XmTextPosition)pos);
  XmTextShowPosition(ih->handle, (XmTextPosition)pos);

  return 0;
}
Example #24
0
static int iTextSetMaskIntAttrib(Ihandle* ih, const char* value)
{
  if (!value)
  {
    if (ih->data->mask)
    {
      iupMaskDestroy(ih->data->mask);
      ih->data->mask = NULL;
    }
  }
  else
  {
    Imask* mask;
    int min, max;

    if (iupStrToIntInt(value, &min, &max, ':')!=2)
      return 0;

    mask = iupMaskCreateInt(min,max);

    if (ih->data->mask)
      iupMaskDestroy(ih->data->mask);

    ih->data->mask = mask;
  }

  return 0;
}
Example #25
0
static int motTabsSetPaddingAttrib(Ihandle* ih, const char* value)
{
  iupStrToIntInt(value, &ih->data->horiz_padding, &ih->data->vert_padding, 'x');

  if (ih->handle)
    motTabsUpdateButtonsPadding(ih);
  return 0;
}
Example #26
0
static int iDialogSetSizeAttrib(Ihandle* ih, const char* value)
{
  if (!value)
  {
    ih->userwidth = 0;
    ih->userheight = 0;
  }
  else
  {
    char *sh, sw[40];
    strcpy(sw, value);
    sh = strchr(sw, 'x');
    if (!sh)
      sh = "";
    else
    {
      *sh = '\0';  /* to mark the end of sw */
      ++sh;
    }

    {
      int charwidth, charheight;
      int screen_width, screen_height;
      int wscale = iDialogSizeGetScale(sw);
      int hscale = iDialogSizeGetScale(sh);

      int width = 0, height = 0; 
      iupStrToIntInt(value, &width, &height, 'x');
      if (width < 0) width = 0;
      if (height < 0) height = 0;

      iupdrvFontGetCharSize(ih, &charwidth, &charheight);

      /* desktop size, excluding task bars and menu bars */
      iupdrvGetScreenSize(&screen_width, &screen_height);

      if (wscale)
        width = screen_width/wscale;
      else
        width = iupWIDTH2RASTER(width, charwidth);

      if (hscale)
        height = screen_height/hscale;
      else
        height = iupHEIGHT2RASTER(height, charheight);

      ih->userwidth = width;
      ih->userheight = height;
    }
  }

  /* must reset the current size,  */
  /* so the user or the natural size will be used to resize the dialog */
  ih->currentwidth = 0;
  ih->currentheight = 0;

  return 0;
}
Example #27
0
static int iCellsSetOriginAttrib(Ihandle* ih, const char* value)
{
  int lin = -9;
  int col = -9;
  iupStrToIntInt(value, &lin, &col, ':');
  iCellsAdjustOrigin(ih, lin, col);
  iCellsRepaint(ih);
  return 1;
}
Example #28
0
static int winDialogCheckMinMaxInfo(Ihandle* ih, MINMAXINFO* minmax)
{
    int min_w = 1, min_h = 1;          /* MINSIZE default value */
    int max_w = 65535, max_h = 65535;  /* MAXSIZE default value */

    iupStrToIntInt(iupAttribGet(ih, "MINSIZE"), &min_w, &min_h, 'x');
    iupStrToIntInt(iupAttribGet(ih, "MAXSIZE"), &max_w, &max_h, 'x');

    minmax->ptMinTrackSize.x = min_w;
    minmax->ptMinTrackSize.y = min_h;
    minmax->ptMaxTrackSize.x = max_w;
    minmax->ptMaxTrackSize.y = max_h;

    if (winMinMaxHandle == ih)
        winMinMaxHandle = NULL;

    return 1;
}
Example #29
0
static int iScintillaSetScrollByAttrib(Ihandle *ih, const char *value)
{
  int lin, col;
  iupStrToIntInt(value, &lin, &col, ',');

  IupScintillaSendMessage(ih, SCI_LINESCROLL, col, lin);

  return 0;
}
static int winToggleSetPaddingAttrib(Ihandle* ih, const char* value)
{
    iupStrToIntInt(value, &ih->data->horiz_padding, &ih->data->vert_padding, 'x');

    if (ih->handle && iupwin_comctl32ver6 && ih->data->type==IUP_TOGGLE_IMAGE)
        iupdrvRedrawNow(ih);

    return 0;
}