Esempio n. 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;
}
Esempio n. 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;
}
Esempio n. 3
0
static void motCanvasScrollbarCallback(Widget w, XtPointer client_data, XtPointer call_data)
{
  int op = (int)client_data, ipage, ipos;
  Ihandle *ih;
  IFniff cb;
  double posx, posy;
  (void)call_data;

  XtVaGetValues(w, XmNuserData, &ih, NULL);
  if (!ih) 
    return;

  XtVaGetValues(w, 
    XmNvalue, &ipos, 
    XmNpageIncrement, &ipage,
    NULL);

  if (op > IUP_SBDRAGV)
  {
    iupCanvasCalcScrollRealPos(iupAttribGetFloat(ih,"XMIN"), iupAttribGetFloat(ih,"XMAX"), &posx, 
                               IUP_SB_MIN, IUP_SB_MAX, ipage, &ipos);
    ih->data->posx = (float)posx;
    posy = ih->data->posy;
  }
  else
  {
    iupCanvasCalcScrollRealPos(iupAttribGetFloat(ih,"YMIN"), iupAttribGetFloat(ih,"YMAX"), &posy, 
                               IUP_SB_MIN, IUP_SB_MAX, ipage, &ipos);
    ih->data->posy = (float)posy;
    posx = ih->data->posx;
  }

  cb = (IFniff)IupGetCallback(ih,"SCROLL_CB");
  if (cb)
    cb(ih, op, (float)posx, (float)posy);
  else
  {
    IFnff cb = (IFnff)IupGetCallback(ih,"ACTION");
    if (cb)
      cb (ih, (float)posx, (float)posy);
  }
}
Esempio n. 4
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;
}
Esempio n. 5
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;
}
Esempio n. 6
0
static void winCanvasUpdateVerScroll(Ihandle* ih, WORD winop)
{
  IFniff cb;
  double ymin, ymax, posy, liney;
  int ipagey, iposy, iliney, op;

  /* unused */
  if (winop == SB_TOP ||
      winop == SB_BOTTOM ||
      winop == SB_ENDSCROLL)
    return;

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

  winCanvasGetScrollInfo(ih->handle, &iposy, &ipagey, SB_VERT, winop==SB_THUMBTRACK||winop==SB_THUMBPOSITION? 1: 0);

  if (!iupAttribGet(ih, "LINEY"))
  {
    iliney = ipagey/10;
    if (!iliney)
      iliney = 1;
  }
  else
  {
    /* line and page convertions are the same */
    liney = iupAttribGetFloat(ih,"LINEY");
    iupCanvasCalcScrollIntPos(ymin, ymax, liney, 0, 
                              IUP_SB_MIN, IUP_SB_MAX, &iliney,  NULL);
  }

  switch (winop)
  {
  case SB_LINEDOWN:
    iposy = iposy + iliney;
    op = IUP_SBDN;
    break;
  case SB_LINEUP:
    iposy = iposy - iliney;
    op = IUP_SBUP;
    break;
  case SB_PAGEDOWN:
    iposy = iposy + ipagey;
    op = IUP_SBPGDN;
    break;
  case SB_PAGEUP:
    iposy = iposy - ipagey;
    op = IUP_SBPGUP;
    break;
  case SB_THUMBTRACK:
    op = IUP_SBDRAGV;
    break;
  case SB_THUMBPOSITION:
    op = IUP_SBPOSV;
    break;
  default:
    return;
  }

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

  SetScrollPos(ih->handle, SB_VERT, iposy, TRUE);
  ih->data->posy = (float)posy;

  cb = (IFniff)IupGetCallback(ih,"SCROLL_CB");
  if (cb)
    cb(ih, op, ih->data->posx,(float)posy);
  else
  {
    IFnff cb = (IFnff)IupGetCallback(ih,"ACTION");
    if (cb)
      cb (ih, ih->data->posx, (float)posy);
  }
}
Esempio n. 7
0
static void winCanvasUpdateHorScroll(Ihandle* ih, WORD winop)
{
  IFniff cb;
  double xmin, xmax, posx, linex;
  int ipagex, iposx, ilinex, op;

  /* unused */
  if (winop == SB_TOP ||
      winop == SB_BOTTOM ||
      winop == SB_ENDSCROLL)
    return;

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

  winCanvasGetScrollInfo(ih->handle, &iposx, &ipagex, SB_HORZ, winop==SB_THUMBTRACK||winop==SB_THUMBPOSITION? 1: 0);

  if (!iupAttribGet(ih,"LINEX"))
  {
    ilinex = ipagex/10;
    if (!ilinex)
      ilinex = 1;
  }
  else
  {
    /* line and page convertions are the same */
    linex = iupAttribGetFloat(ih,"LINEX");
    iupCanvasCalcScrollIntPos(xmin, xmax, linex, 0, 
                              IUP_SB_MIN, IUP_SB_MAX, &ilinex,  NULL);
  }

  switch (winop)
  {
  case SB_LINEDOWN:
    iposx = iposx + ilinex;
    op = IUP_SBRIGHT;
    break;
  case SB_LINEUP:
    iposx = iposx - ilinex;
    op = IUP_SBLEFT;
    break;
  case SB_PAGEDOWN:
    iposx = iposx + ipagex;
    op = IUP_SBPGRIGHT;
    break;
  case SB_PAGEUP:
    iposx = iposx - ipagex;
    op = IUP_SBPGLEFT;
    break;
  case SB_THUMBTRACK:
    op = IUP_SBDRAGH;
    break;
  case SB_THUMBPOSITION:
    op = IUP_SBPOSH;
    break;
  default:
    return;
  }

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

  SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE);
  ih->data->posx = (float)posx;

  cb = (IFniff)IupGetCallback(ih,"SCROLL_CB");
  if (cb)
    cb(ih,op,(float)posx,ih->data->posy);
  else
  {
    IFnff cb = (IFnff)IupGetCallback(ih,"ACTION");
    if (cb)
      cb (ih, (float)posx, ih->data->posy);
  }
}
Esempio n. 8
0
static int motCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double posy, ymin, ymax, liney;
    float dy;
    int iposy, ipagey, iliney;
    Widget sb_vert = (Widget)iupAttribGet(ih, "_IUPMOT_SBVERT");
    if (!sb_vert) return 1;

    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);

    if (!iupAttribGet(ih,"LINEY"))
    {
      iliney = ipagey/10;
      if (!iliney)
        iliney = 1;
    }
    else
    {
      /* line and page conversions are the same */
      liney = iupAttribGetFloat(ih,"LINEY");
      iupCanvasCalcScrollIntPos(ymin, ymax, liney, 0, 
                                IUP_SB_MIN, IUP_SB_MAX, &iliney,  NULL);
    }

    if (dy >= (ymax-ymin))
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        if (XtIsManaged(sb_vert))
        {
          XtUnmanageChild(sb_vert);
          motCanvasUpdateScrollLayout(ih);
        }

        iupAttribSet(ih, "YHIDDEN", "YES");
      }
      else
        XtSetSensitive(sb_vert, False);

      ih->data->posy = (float)ymin;
      XtVaSetValues(sb_vert, XmNvalue, IUP_SB_MIN, NULL);
    }
    else
    {
      if (!XtIsManaged(sb_vert))
      {
        XtManageChild(sb_vert);
        motCanvasUpdateScrollLayout(ih);
      }
      XtSetSensitive(sb_vert, True);

      motCanvasSetScrollInfo(sb_vert, IUP_SB_MIN, IUP_SB_MAX, iposy, ipagey, iliney);

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

      iupAttribSet(ih, "YHIDDEN", "NO");

      ih->data->posy = (float)posy;
    }
  }
  return 1;
}
Esempio n. 9
0
static int motCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double posx, xmin, xmax, linex;
    float dx;
    int iposx, ipagex, ilinex;
    Widget sb_horiz = (Widget)iupAttribGet(ih, "_IUPMOT_SBHORIZ");
    if (!sb_horiz) return 1;

    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);

    if (!iupAttribGet(ih,"LINEX"))
    {
      ilinex = ipagex/10;
      if (!ilinex)
        ilinex = 1;
    }
    else
    {
      /* line and page conversions are the same */
      linex = iupAttribGetFloat(ih,"LINEX");
      iupCanvasCalcScrollIntPos(xmin, xmax, linex, 0, 
                                IUP_SB_MIN, IUP_SB_MAX, &ilinex,  NULL);
    }

    if (dx >= (xmax-xmin))
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        if (XtIsManaged(sb_horiz))
        {
          XtUnmanageChild(sb_horiz);
          motCanvasUpdateScrollLayout(ih);
        }

        iupAttribSet(ih, "XHIDDEN", "YES");
      }
      else
        XtSetSensitive(sb_horiz, False);

      ih->data->posx = (float)xmin;
      XtVaSetValues(sb_horiz, XmNvalue, IUP_SB_MIN, NULL);
    }
    else
    {
      if (!XtIsManaged(sb_horiz))
      {
        XtManageChild(sb_horiz);
        motCanvasUpdateScrollLayout(ih);
      }
      XtSetSensitive(sb_horiz, True);

      motCanvasSetScrollInfo(sb_horiz, IUP_SB_MIN, IUP_SB_MAX, iposx, ipagex, ilinex);

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

      iupAttribSet(ih, "XHIDDEN", "NO");

      ih->data->posx = (float)posx;
    }
  }
  return 1;
}