예제 #1
0
static int iGLValMOTION_CB(Ihandle* ih, int x, int y, char* status)
{
  int redraw = 0;
  int pressed = iupAttribGetInt(ih, "PRESSED");

  /* special highlight processing for handler area */
  if (iGLValIsInsideHandler(ih, x, y))
  {
    if (!iupAttribGet(ih, "HIGHLIGHT"))
    {
      redraw = 1;
      iupAttribSet(ih, "HIGHLIGHT", "1");
    }
  }
  else
  {
    if (iupAttribGet(ih, "HIGHLIGHT"))
    {
      redraw = 1;
      iupAttribSet(ih, "HIGHLIGHT", NULL);
    }
  }

  if (pressed)
  {
    int start_x = iupAttribGetInt(ih, "_IUP_START_X");
    int start_y = iupAttribGetInt(ih, "_IUP_START_Y");

    if (iGLValMoveHandler(ih, x - start_x, y - start_y))
    {
      iupGLSubCanvasRedraw(ih);
      redraw = 0;

      if (!iupAttribGet(ih, "_IUP_DRAG"))
      {
        IFni cb = (IFni)IupGetCallback(ih, "VALUECHANGING_CB");
        if (cb) cb(ih, 1);
      }

      iupBaseCallValueChangedCb(ih);

      iupAttribSet(ih, "_IUP_DRAG", "1");
    }

    iupAttribSetInt(ih, "_IUP_START_X", x);
    iupAttribSetInt(ih, "_IUP_START_Y", y);
  }

  if (redraw)
    iupGLSubCanvasRedraw(ih);

  (void)status;
  return IUP_DEFAULT;
}
예제 #2
0
static int iGLValBUTTON_CB(Ihandle* ih, int button, int pressed, int x, int y, char* status)
{
  if (button == IUP_BUTTON1)
  {
    if (pressed)
    {
      if (!iGLValIsInsideHandler(ih, x, y))
        iupAttribSet(ih, "PRESSED", NULL);
      else
      {
        iupAttribSetInt(ih, "_IUP_START_X", x);
        iupAttribSetInt(ih, "_IUP_START_Y", y);
      }
    }
    else
    {
      if (iupAttribGet(ih, "_IUP_DRAG"))
      {
        IFni cb = (IFni)IupGetCallback(ih, "VALUECHANGING_CB");
        if (cb) cb(ih, 0);

        iupAttribSet(ih, "_IUP_DRAG", NULL);
      }
    }

    iupGLSubCanvasRedraw(ih);
  }

  (void)status;
  return IUP_DEFAULT;
}
예제 #3
0
static int iGLScrollBoxMOTION_CB(Ihandle *ih, int x, int y, char* status)
{
  if (iupGLScrollbarsMotion(ih, x, y))
    iupGLSubCanvasRedraw(ih);

  (void)status;
  return IUP_DEFAULT;
}
예제 #4
0
static int iGLValENTERWINDOW_CB(Ihandle* ih, int x, int y)
{
  /* special highlight processing for handler area */
  if (iGLValIsInsideHandler(ih, x, y))
    iupAttribSet(ih, "HIGHLIGHT", "1");
  else
    iupAttribSet(ih, "HIGHLIGHT", NULL);

  return iupGLSubCanvasRedraw(ih);
}
예제 #5
0
static int iGLScrollBoxBUTTON_CB(Ihandle *ih, int button, int pressed, int x, int y, char* status)
{
  if (button != IUP_BUTTON1)
    return IUP_DEFAULT;

  if (iupGLScrollbarsButton(ih, pressed, x, y))
    iupGLSubCanvasRedraw(ih);

  (void)status;
  return IUP_DEFAULT;
}
예제 #6
0
파일: iup_glexpander.c 프로젝트: defdef/iup
static int iGLExpanderENTERWINDOW_CB(Ihandle* ih, int x, int y)
{
  int bar_size = iGLExpanderGetBarSize(ih);

  /* shift to bar position */
  if (ih->data->position == IEXPANDER_RIGHT)
    x += ih->currentwidth - 1 - bar_size;
  else if (ih->data->position == IEXPANDER_BOTTOM)
    y += ih->currentheight - 1 - bar_size;

  /* special highlight processing for handler area */
  if (iGLExpanderIsInsideHandler(ih, x, y, bar_size))
    iupAttribSet(ih, "HIGHLIGHT", "1");
  else
    iupAttribSet(ih, "HIGHLIGHT", NULL);

  return iupGLSubCanvasRedraw(ih);
}
예제 #7
0
파일: iup_glexpander.c 프로젝트: defdef/iup
static int iGLExpanderCallExtraButtonCb(Ihandle* ih, int button, int pressed)
{
  int old_state = ih->data->extra_buttons_state[button];
  ih->data->extra_buttons_state[button] = pressed;

  /* redraw only if state changed */
  if (old_state != ih->data->extra_buttons_state[button])
    iupGLSubCanvasRedraw(ih);

  if (!pressed)
    pressed = pressed;

  /* if pressed always call,
     if not pressed, call only if was pressed */
  if (pressed || old_state == 1)
  {
    IFnii cb = (IFnii)IupGetCallback(ih, "EXTRABUTTON_CB");
    if (cb)
      cb(ih, button, pressed);
  }

  return IUP_DEFAULT;
}
예제 #8
0
static int iGLButtonBUTTON_CB(Ihandle* ih, int button, int pressed, int x, int y, char* status)
{
  if (button == IUP_BUTTON1)
  {
    /* "PRESSED" was already updated */
    iupGLSubCanvasRedraw(ih);

    if (!pressed)
    {
      Icallback cb = IupGetCallback(ih, "ACTION");
      if (cb)
      {
        int ret = cb(ih);
        if (ret == IUP_CLOSE)
          IupExitLoop();
      }
    }
  }

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
예제 #9
0
파일: iup_glexpander.c 프로젝트: defdef/iup
static int iGLExpanderMOTION_CB(Ihandle* ih, int x, int y, char* status)
{
  int redraw = 0;
  int bar_size = iGLExpanderGetBarSize(ih);
  Ihandle* gl_parent = (Ihandle*)iupAttribGet(ih, "GL_CANVAS");

  /* shift to bar position */
  if (ih->data->position == IEXPANDER_RIGHT)
    x += ih->currentwidth - 1 - bar_size;
  else if (ih->data->position == IEXPANDER_BOTTOM)
    y += ih->currentheight - 1 - bar_size;

  /* special highlight processing for handler area */
  if (iGLExpanderIsInsideHandler(ih, x, y, bar_size))
  {
    if (!iupAttribGet(ih, "HIGHLIGHT"))
    {
      redraw = 1;
      iupAttribSet(ih, "HIGHLIGHT", "1");
    }
  }
  else
  {
    if (iupAttribGet(ih, "HIGHLIGHT"))
    {
      redraw = 1;
      iupAttribSet(ih, "HIGHLIGHT", NULL);
    }
  }

  if (ih->data->position == IEXPANDER_TOP && !ih->data->moving)
  {
    if (y >= IEXPAND_SPACING + IEXPAND_BACK_MARGIN && y <= bar_size - IEXPAND_SPACING - IEXPAND_BACK_MARGIN)
    {
      int old_state[4];
      old_state[1] = ih->data->extra_buttons_state[1];
      old_state[2] = ih->data->extra_buttons_state[2];
      old_state[3] = ih->data->extra_buttons_state[3];

      if ((x >= ih->currentwidth - (IEXPAND_BUTTON_SIZE + IEXPAND_SPACING) - IEXPAND_BACK_MARGIN) &&
        (x < ih->currentwidth - IEXPAND_SPACING - IEXPAND_BACK_MARGIN))
      {
        if (ih->data->extra_buttons_state[1] == 0)
          ih->data->extra_buttons_state[1] = -1;  /* highlight if not pressed */
      }
      else
      {
        if (ih->data->extra_buttons_state[1] != 0)
          ih->data->extra_buttons_state[1] = 0;
      }

      if (ih->data->extra_buttons > 1)
      {
        if ((x >= ih->currentwidth - 2 * (IEXPAND_BUTTON_SIZE + IEXPAND_SPACING) - IEXPAND_BACK_MARGIN) &&
          (x < ih->currentwidth - (IEXPAND_BUTTON_SIZE + 2 * IEXPAND_SPACING) - IEXPAND_BACK_MARGIN))
        {
          if (ih->data->extra_buttons_state[2] == 0)
            ih->data->extra_buttons_state[2] = -1;  /* highlight if not pressed */
        }
        else
        {
          if (ih->data->extra_buttons_state[2] != 0)
            ih->data->extra_buttons_state[2] = 0;
        }
      }

      if (ih->data->extra_buttons == 3)
      {
        if ((x >= ih->currentwidth - 3 * (IEXPAND_BUTTON_SIZE + IEXPAND_SPACING) - IEXPAND_BACK_MARGIN) &&
          (x < ih->currentwidth - (2 * IEXPAND_BUTTON_SIZE + 3 * IEXPAND_SPACING) - IEXPAND_BACK_MARGIN))
        {
          if (ih->data->extra_buttons_state[3] == 0)
            ih->data->extra_buttons_state[3] = -1;  /* highlight if not pressed */
        }
        else
        {
          if (ih->data->extra_buttons_state[3] != 0)
            ih->data->extra_buttons_state[3] = 0;
        }
      }

      if (old_state[1] != ih->data->extra_buttons_state[1] ||
        old_state[2] != ih->data->extra_buttons_state[2] ||
        old_state[3] != ih->data->extra_buttons_state[3])
      {
        iupGLSubCanvasRedraw(ih);
        redraw = 0;
      }
    }
  }

  if (ih->data->moving)
  {
    x += ih->x;
    y += ih->y;

    if ((x != ih->data->start_x) || (y != ih->data->start_y))
    {
      IFnii cb = (IFnii)IupGetCallback(ih, "MOVE_CB");

      /* clear canvas box alignment */
      iupAttribSet(ih, "VERTICALALIGN", NULL);
      iupAttribSet(ih, "HORIZONTALALIGN", NULL);

      iupBaseSetPosition(ih, ih->x + (x - ih->data->start_x), ih->y + (y - ih->data->start_y));

      IupSetAttribute(gl_parent, "REDRAW", NULL);  /* redraw the whole box */
      redraw = 0;

      if (cb)
        cb(ih, ih->x, ih->y);
    }

    ih->data->start_x = x;
    ih->data->start_y = y;
  }

  if (redraw)
    iupGLSubCanvasRedraw(ih);

  (void)status;
  return IUP_DEFAULT;
}
예제 #10
0
static int iGLScrollBoxLEAVEWINDOW_CB(Ihandle* ih)
{
  iupGLScrollbarsLeaveWindow(ih);

  return iupGLSubCanvasRedraw(ih);
}
예제 #11
0
static int iGLScrollBoxENTERWINDOW_CB(Ihandle* ih, int x, int y)
{
  iupGLScrollbarsEnterWindow(ih, x, y);

  return iupGLSubCanvasRedraw(ih);
}