Exemplo n.º 1
0
static int winCanvasSetPosYAttrib(Ihandle *ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double ymin, ymax, dy;
    float posy;
    int iposy, ipagey;

    if (!iupStrToFloat(value, &posy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    dy = iupAttribGetFloat(ih, "DY");

    if (posy < ymin) posy = (float)ymin;
    if (posy > (ymax - dy)) posy = (float)(ymax - dy);
    ih->data->posy = posy;

    iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy);

    SetScrollPos(ih->handle, SB_VERT, iposy, TRUE);
  }
  return 1;
}
Exemplo n.º 2
0
static int gtkCanvasSetPosYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    float posy, ymin, ymax, dy;
    GtkAdjustment* sb_vert_adjust;
    GtkWidget* sb_vert = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBVERT");
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &posy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    dy = iupAttribGetFloat(ih, "DY");

    if (posy < ymin) posy = ymin;
    if (posy > (ymax - dy)) posy = ymax - dy;
    ih->data->posy = posy;

    sb_vert_adjust = gtk_range_get_adjustment(GTK_RANGE(sb_vert));
    gtkCanvasAdjustmentSetValue(ih, sb_vert_adjust, posy);
  }
  return 1;
}
Exemplo n.º 3
0
static int motCanvasSetPosXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double xmin, xmax, dx;
    float posx;
    int iposx, ipagex;
    Widget sb_horiz = (Widget)iupAttribGet(ih, "_IUPMOT_SBHORIZ");
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &posx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    dx = iupAttribGetFloat(ih, "DX");

    if (posx < xmin) posx = (float)xmin;
    if (posx > (xmax - dx)) posx = (float)(xmax - dx);
    ih->data->posx = posx;

    iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx);

    XtVaSetValues(sb_horiz, XmNvalue, iposx, NULL);
  }
  return 1;
}
Exemplo n.º 4
0
static int motCanvasSetPosYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double ymin, ymax, dy;
    float posy;
    int iposy, ipagey;
    Widget sb_vert = (Widget)iupAttribGet(ih, "_IUPMOT_SBVERT");
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &posy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    dy = iupAttribGetFloat(ih, "DY");

    if (posy < ymin) posy = (float)ymin;
    if (posy > (ymax - dy)) posy = (float)(ymax - dy);
    ih->data->posy = posy;

    iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy);

    XtVaSetValues(sb_vert, XmNvalue, iposy, NULL);
  }
  return 1;
}
Exemplo n.º 5
0
static int gtkCanvasSetPosXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    float posx, xmin, xmax, dx;
    GtkAdjustment* sb_horiz_adjust;
    GtkWidget* sb_horiz = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBHORIZ");
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &posx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    dx = iupAttribGetFloat(ih, "DX");

    if (posx < xmin) posx = xmin;
    if (posx > (xmax - dx)) posx = xmax - dx;
    ih->data->posx = posx;

    sb_horiz_adjust = gtk_range_get_adjustment(GTK_RANGE(sb_horiz));
    gtkCanvasAdjustmentSetValue(ih, sb_horiz_adjust, posx);
  }
  return 1;
}
Exemplo n.º 6
0
static int winCanvasSetPosXAttrib(Ihandle *ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double xmin, xmax, dx;
    float posx;
    int iposx, ipagex;

    if (!iupStrToFloat(value, &posx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    dx = iupAttribGetFloat(ih, "DX");

    if (posx < xmin) posx = (float)xmin;
    if (posx > (xmax - dx)) posx = (float)(xmax - dx);
    ih->data->posx = posx;

    iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx);

    SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE);
  }
  return 1;
}
Exemplo n.º 7
0
static void iVboxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
{
  Ihandle* child;
  int empty_h0 = 0, empty_h1 = 0, client_width;

  if (ih->data->expand_children)
    ih->expand |= ih->data->expand_children;

  if (ih->data->is_homogeneous)
    ih->data->homogeneous_size = iHboxCalcHomogeneousHeight(ih);
  else
  {
    ih->data->homogeneous_size = 0;

    /* must calculate the space left for each control to grow inside the container */
    /* H1 means there is an EXPAND enabled inside */
    if (ih->expand & IUP_EXPAND_H1)
      empty_h1 = iVboxCalcEmptyHeight(ih, IUP_EXPAND_H1);
    /* Not H1 and H0 means that EXPAND is not enabled, but there are some IupFill inside */
    else if (ih->expand & IUP_EXPAND_H0)
      empty_h0 = iVboxCalcEmptyHeight(ih, IUP_EXPAND_H0);
  }

  client_width = ih->currentwidth - 2*ih->data->margin_x;
  if (client_width<0) client_width=0;

  for (child = ih->firstchild; child; child = child->brother)
  {
    if (!(child->flags & IUP_FLOATING))
    {
      int old_expand = child->expand;
      if (ih->data->expand_children)
        child->expand |= ih->data->expand_children;

      if (ih->data->homogeneous_size)
        iupBaseSetCurrentSize(child, client_width, ih->data->homogeneous_size, shrink);
      else
      {
        int empty = (child->expand & IUP_EXPAND_H1)? empty_h1: ((child->expand & IUP_EXPAND_H0)? empty_h0: 0);
        char* weight_str = iupAttribGet(child, "EXPANDWEIGHT");
        if (weight_str)
        {
          float weight; 
          if (iupStrToFloat(weight_str, &weight))
            empty = iupROUND(empty * weight);
        }
        iupBaseSetCurrentSize(child, client_width, child->naturalheight+empty, shrink);
      }

      if (ih->data->expand_children)
        child->expand = old_expand;
    }
    else if (!(child->flags & IUP_FLOATING_IGNORE))
    {
      /* update children to their own natural size */
      iupBaseSetCurrentSize(child, child->naturalwidth, child->naturalheight, shrink);
    }
  }
}
Exemplo n.º 8
0
float IupGetFloat(Ihandle *ih, const char* name)
{
  float f = 0;
  char *value = IupGetAttribute(ih, name);
  if (value)
    iupStrToFloat(value, &f);
  return f;
}
Exemplo n.º 9
0
float iupAttribGetFloat(Ihandle* ih, const char* name)
{
  float f = 0;
  char *value = iupAttribGetStr(ih, name);
  if (value)
    iupStrToFloat(value, &f);
  return f;
}
Exemplo n.º 10
0
float IupGetFloatId2(Ihandle* ih, const char* name, int lin, int col)
{
  float f = 0;
  char *value = IupGetAttributeId2(ih, name, lin, col);
  if (value)
    iupStrToFloat(value, &f);
  return f;
}
Exemplo n.º 11
0
int iupScintillaSetFontSizeFracStyleAttrib(Ihandle* ih, int style, const char* value)
{
  float size;

  if(style == IUP_INVALID_ID)
    style = 0;  /* Lexer style default */

  iupStrToFloat(value, &size);

  iupScintillaSendMessage(ih, SCI_STYLESETSIZEFRACTIONAL, style, (int)(size*SC_FONT_SIZE_MULTIPLIER));

  return 0;
}
Exemplo n.º 12
0
static int gtkCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double xmin, xmax, linex;
    float dx;
    int value_changed;
    GtkAdjustment* sb_horiz = gtk_scrolled_window_get_hadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &dx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");

    if (!iupAttribGet(ih,"LINEX"))
    {
      linex = dx/10;
      if (linex==0)
        linex = 1;
    }
    else
      linex = iupAttribGetFloat(ih,"LINEX");

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dx;
      double dvalue = gtk_adjustment_get_value(sb_horiz);
      value_changed = gtkCanvasCheckScroll(xmin, xmax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_horiz, dvalue, xmin, xmax, linex, page_size, dx);
    }
#else
    sb_horiz->lower = xmin;
    sb_horiz->upper = xmax;
    sb_horiz->step_increment = linex;
    sb_horiz->page_size = dx;

    value_changed = gtkCanvasCheckScroll(xmin, xmax, &sb_horiz->page_size, &sb_horiz->value);
    sb_horiz->page_increment = sb_horiz->page_size;

    gtk_adjustment_changed(sb_horiz);
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_horiz);
  }
  return 1;
}
Exemplo n.º 13
0
static int gtkCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double ymin, ymax, liney;
    float dy;
    int value_changed;
    GtkAdjustment* sb_vert = gtk_scrolled_window_get_vadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &dy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");

    if (!iupAttribGet(ih,"LINEY"))
    {
      liney = dy/10;
      if (liney==0)
        liney = 1;
    }
    else
      liney = iupAttribGetFloat(ih,"LINEY");

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dy;
      double dvalue = gtk_adjustment_get_value(sb_vert);
      value_changed = gtkCanvasCheckScroll(ymin, ymax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_vert, dvalue, ymin, ymax, liney, page_size, dy);
    }
#else
    sb_vert->lower = ymin;
    sb_vert->upper = ymax;
    sb_vert->step_increment = liney;
    sb_vert->page_size = dy;

    value_changed = gtkCanvasCheckScroll(ymin, ymax, &sb_vert->page_size, &sb_vert->value);
    sb_vert->page_increment = sb_vert->page_size;

    gtk_adjustment_changed(sb_vert);
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_vert);
  }
  return 1;
}
Exemplo n.º 14
0
static int winCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double posy, ymin, ymax;
    float dy;
    int iposy, ipagey;

    if (!iupStrToFloat(value, &dy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    posy = ih->data->posy;

    iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy);

    if (dy >= (ymax-ymin))
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
        ShowScrollBar(ih->handle, SB_VERT, FALSE);
      else
        EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH);

      ih->data->posy = (float)ymin;
      SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, TRUE);
      return 1;
    }
    else
    {
      ShowScrollBar(ih->handle, SB_VERT, TRUE);
      EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH);
    }

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, iposy, ipagey, SB_VERT);

    /* update position because it could be corrected */
    iupCanvasCalcScrollRealPos(ymin, ymax, &posy, 
                               IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy);

    ih->data->posy = (float)posy;
  }
  return 1;
}
Exemplo n.º 15
0
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double posx, xmin, xmax;
    float dx;
    int iposx, ipagex;

    if (!iupStrToFloat(value, &dx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    posx = ih->data->posx;

    iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx);

    if (dx >= (xmax-xmin))
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
        ShowScrollBar(ih->handle, SB_HORZ, FALSE);
      else
        EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH);

      ih->data->posx = (float)xmin;
      SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE);
      return 1;
    }
    else
    {
      ShowScrollBar(ih->handle, SB_HORZ, TRUE);
      EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH);
    }

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, iposx, ipagex, SB_HORZ);

    /* update position because it could be corrected */
    iupCanvasCalcScrollRealPos(xmin, xmax, &posx, 
                               IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx);

    ih->data->posx = (float)posx;
  }
  return 1;
}
Exemplo n.º 16
0
static int gtkCanvasSetPosYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    float posy, ymin, ymax, dy;
    GtkAdjustment* sb_vert = gtk_scrolled_window_get_vadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &posy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    dy = iupAttribGetFloat(ih, "DY");

    if (posy < ymin) posy = ymin;
    if (posy > (ymax - dy)) posy = ymax - dy;
    ih->data->posy = posy;

    gtk_adjustment_set_value(sb_vert, posy);
  }
  return 1;
}
Exemplo n.º 17
0
static int gtkCanvasSetPosXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    float posx, xmin, xmax, dx;
    GtkAdjustment* sb_horiz = gtk_scrolled_window_get_hadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &posx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    dx = iupAttribGetFloat(ih, "DX");

    if (posx < xmin) posx = xmin;
    if (posx > (xmax - dx)) posx = xmax - dx;
    ih->data->posx = posx;

    gtk_adjustment_set_value(sb_horiz, posx);
  }
  return 1;
}
Exemplo n.º 18
0
int iupMaskCheck(Imask* mask, const char *val)
{
  int ret;

  /* empty text or no mask */
  if (!val || !(*val) || !mask) 
    return 1;

  ret = iupMaskMatch(val,mask->fsm,0,NULL,NULL,NULL,mask->casei);
  if (ret == IMASK_PARTIALMATCH)
    return -1;
  if (ret != (int)strlen(val))
    return 0;

  switch(mask->type)
  {
  case 'I':
    {
      int ival = 0;
      iupStrToInt(val, &ival);
      if(ival < mask->imin || ival > mask->imax)
        return 0;
      break;
    }
  case 'F':
    {
      float fval = 0;
      iupStrToFloat(val, &fval);
      if(fval < mask->fmin || fval > mask->fmax)
        return 0;
      break;
    }
  }

  return 1;
}
Exemplo n.º 19
0
static int gtkCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double ymin, ymax, liney;
    float dy;
    int value_changed;
    GtkAdjustment* sb_vert_adjust;
    GtkWidget* sb_vert = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBVERT");
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &dy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");

    if (!iupAttribGet(ih,"LINEY"))
    {
      liney = dy/10;
      if (liney==0)
        liney = 1;
    }
    else
      liney = iupAttribGetFloat(ih,"LINEY");

    sb_vert_adjust = gtk_range_get_adjustment(GTK_RANGE(sb_vert));

    if (dy >= (ymax-ymin))
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        if (iupgtkIsVisible(sb_vert))
        {
          gtk_widget_hide(sb_vert);
          gtkCanvasUpdateChildLayout(ih);
        }
      }
      else
        gtk_widget_set_sensitive(sb_vert, FALSE);

      ih->data->posy = (float)ymin;
      gtkCanvasAdjustmentSetValue(ih, sb_vert_adjust, ymin);
      return 1;
    }
    else
    {
      if (!iupgtkIsVisible(sb_vert))
      {
        gtk_widget_show(sb_vert);
        gtkCanvasUpdateChildLayout(ih);
      }
      gtk_widget_set_sensitive(sb_vert, TRUE);
    }

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dy;
      double dvalue = gtk_adjustment_get_value(sb_vert_adjust);
      value_changed = gtkCanvasCheckScroll(ymin, ymax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_vert_adjust, dvalue, ymin, ymax, liney, page_size, dy);
    }
#else
    {
      sb_vert_adjust->lower = ymin;
      sb_vert_adjust->upper = ymax;
      sb_vert_adjust->step_increment = liney;
      sb_vert_adjust->page_size = dy;

      value_changed = gtkCanvasCheckScroll(ymin, ymax, &sb_vert_adjust->page_size, &sb_vert_adjust->value);
      sb_vert_adjust->page_increment = sb_vert_adjust->page_size;

      gtk_adjustment_changed(sb_vert_adjust);
    }
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_vert_adjust);
  }
  return 1;
}
Exemplo n.º 20
0
static int gtkCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double xmin, xmax, linex;
    float dx;
    int value_changed;
    GtkAdjustment* sb_horiz_adjust;
    GtkWidget* sb_horiz = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_SBHORIZ");
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &dx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");

    if (!iupAttribGet(ih,"LINEX"))
    {
      linex = dx/10;
      if (linex==0)
        linex = 1;
    }
    else
      linex = iupAttribGetFloat(ih,"LINEX");

    sb_horiz_adjust = gtk_range_get_adjustment(GTK_RANGE(sb_horiz));

    if (dx >= (xmax-xmin))
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        if (iupgtkIsVisible(sb_horiz))
        {
          gtk_widget_hide(sb_horiz);
          gtkCanvasUpdateChildLayout(ih);
        }
      }
      else
        gtk_widget_set_sensitive(sb_horiz, FALSE);

      ih->data->posx = (float)xmin;
      gtkCanvasAdjustmentSetValue(ih, sb_horiz_adjust, xmin);
      return 1;
    }
    else
    {
      if (!iupgtkIsVisible(sb_horiz))
      {
        gtk_widget_show(sb_horiz);
        gtkCanvasUpdateChildLayout(ih);
      }
      gtk_widget_set_sensitive(sb_horiz, TRUE);
    }

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dx;
      double dvalue = gtk_adjustment_get_value(sb_horiz_adjust);
      value_changed = gtkCanvasCheckScroll(xmin, xmax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_horiz_adjust, dvalue, xmin, xmax, linex, page_size, dx);
    }
#else
    {
      sb_horiz_adjust->lower = xmin;
      sb_horiz_adjust->upper = xmax;
      sb_horiz_adjust->step_increment = linex;
      sb_horiz_adjust->page_size = dx;

      value_changed = gtkCanvasCheckScroll(xmin, xmax, &sb_horiz_adjust->page_size, &sb_horiz_adjust->value);
      sb_horiz_adjust->page_increment = sb_horiz_adjust->page_size;

      gtk_adjustment_changed(sb_horiz_adjust);
    }
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_horiz_adjust);
  }
  return 1;
}