Пример #1
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 (!iupStrToFloatDef(value, &dy, 0.1f))
      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);

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagey, SB_VERT, iupAttribGetBoolean(ih, "YAUTOHIDE"));

    if (dy >= (ymax-ymin))
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        iupAttribSet(ih, "YHIDDEN", "YES");
        ShowScrollBar(ih->handle, SB_VERT, FALSE);
        SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, FALSE);
      }
      else
      {
        EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH);
        SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, TRUE);
      }

      ih->data->posy = (float)ymin;
      return 1;
    }
    else
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        iupAttribSet(ih, "YHIDDEN", "NO");
        ShowScrollBar(ih->handle, SB_VERT, TRUE);
      }
      else
        EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH);

      /* also update position because it could have being changed */
      iupCanvasCalcScrollRealPos(ymin, ymax, &posy,
                                 IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy);
      SetScrollPos(ih->handle, SB_VERT, iposy, TRUE);
      ih->data->posy = (float)posy;
    }
  }
  return 1;
}
Пример #2
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 (!iupStrToFloatDef(value, &dx, 0.1f))
      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);

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagex, SB_HORZ, iupAttribGetBoolean(ih, "XAUTOHIDE"));

    if (dx >= (xmax-xmin))
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        iupAttribSet(ih, "XHIDDEN", "YES");
        ShowScrollBar(ih->handle, SB_HORZ, FALSE);
        SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, FALSE);
      }
      else
      {
        EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH);
        SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE);
      }

      ih->data->posx = (float)xmin;
    }
    else
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        iupAttribSet(ih, "XHIDDEN", "NO");
        ShowScrollBar(ih->handle, SB_HORZ, TRUE);
      }
      else
        EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH);

      /* also update position because it could have being changed */
      iupCanvasCalcScrollRealPos(xmin, xmax, &posx, 
                                 IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx);
      SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE);
      ih->data->posx = (float)posx;
    }
  }
  return 1;
}
Пример #3
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;
}
Пример #4
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);
      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;
}