Exemplo n.º 1
0
void iupwinTipsGetDispInfo(LPARAM lp)
{
  Ihandle* ih;
  HWND tips_hwnd;
  NMTTDISPINFO* tips_info;
  IFnii cb;

  if (!lp) 
    return;

  tips_info = (NMTTDISPINFO*)lp;
  ih = iupwinHandleGet(tips_info->hdr.hwndFrom);  /* hwndFrom is the tooltip window */
  if (!ih) 
    return;

  tips_hwnd = (HWND)iupAttribGet(ih, "_IUPWIN_TIPSWIN");
  if (tips_hwnd != tips_info->hdr.hwndFrom) 
    return;

  tips_info->hinst = NULL;

  cb = (IFnii)IupGetCallback(ih, "TIPS_CB");
  if (cb)
  {
    int x, y;
    iupdrvGetCursorPos(&x, &y);
    iupdrvScreenToClient(ih, &x, &y);
    cb(ih, x, y);
  }

  tips_info->lpszText = iupwinStrToSystem(iupAttribGet(ih, "TIP"));

  iupwinTipsUpdateInfo(ih, tips_hwnd);
}
Exemplo n.º 2
0
static void motListDragMotionCallback(Widget drop_context, Ihandle *ih, XmDragMotionCallbackStruct* drag_motion)
{
  (void)drop_context;
  if (!iupAttribGet(ih, "NODRAGFEEDBACK"))
  {
    int idDrop;
    int x = drag_motion->x;
    int y = drag_motion->y;
    iupdrvScreenToClient(ih, &x, &y);
    
    idDrop = motListConvertXYToPos(ih, x, y);  /* starts at 1 */
    iupAttribSetInt(ih, "_IUPLIST_DROPITEM", idDrop);  /* starts at 1 */

    XmListSelectPos(ih->handle, idDrop, FALSE);  /* starts at 1 */
  }
}
Exemplo n.º 3
0
static void motTipsShow(void)
{
  Window root, child;
  int cx, cy, x, y;
  unsigned int keys;
  char* value;

  XQueryPointer(iupmot_display, RootWindow(iupmot_display, iupmot_screen),
                &root, &child, &x, &y, &cx, &cy, &keys);

  value = iupAttribGet(mot_tips.ih, "TIPRECT");
  if (value)
  {
    int x1, x2, y1, y2, wx = x, wy = y;
    sscanf(value, "%d %d %d %d", &x1, &y1, &x2, &y2);
    iupdrvScreenToClient(mot_tips.ih, &wx, &wy);
    if (wx < x1 || wx > x2 || wy < y1 || wy > y2)
    {
      iupmotTipLeaveNotify();
      return;
    }
  }
  
  XtVaSetValues(mot_tips.Dialog, 
    XmNx, (XtArgVal)(x+TIP_X_OFFSET),
    XmNy, (XtArgVal)(y+TIP_Y_OFFSET), 
    NULL);

  if (mot_tips.Visible)
    XRaiseWindow(iupmot_display, XtWindow(mot_tips.Dialog));
  else
    XtMapWidget(mot_tips.Dialog);

  mot_tips.ShowTimerId = (XtIntervalId) NULL;
  mot_tips.Visible = TRUE;
}
Exemplo n.º 4
0
void iupwinTouchProcessInput(Ihandle* ih, int count, void* lp)
{
  HTOUCHINPUT hTouchInput = (HTOUCHINPUT)lp;
  IFniIIII mcb = (IFniIIII)IupGetCallback(ih, "MULTITOUCH_CB");
  IFniiis cb = (IFniiis)IupGetCallback(ih, "TOUCH_CB");

  if (mcb || cb)
  {
    int *px=NULL, *py=NULL, *pid=NULL, *pstate=NULL;
    TOUCHINPUT* ti = malloc(count*sizeof(TOUCHINPUT));

    if (mcb)
    {
      px = malloc(sizeof(int)*(count));
      py = malloc(sizeof(int)*(count));
      pid = malloc(sizeof(int)*(count));
      pstate = malloc(sizeof(int)*(count));
    }

    if (winGetTouchInputInfo(hTouchInput, count, ti, sizeof(TOUCHINPUT)))
    {
      int i, x, y;
      for (i = 0; i < count; i++)
      {
        x = ti[i].x / 100;
        y = ti[i].y / 100;
        iupdrvScreenToClient(ih, &x, &y);

        if (ti[i].dwFlags & TOUCHEVENTF_DOWN ||
            ti[i].dwFlags & TOUCHEVENTF_MOVE ||
            ti[i].dwFlags & TOUCHEVENTF_UP)
        {
          char* state = (ti[i].dwFlags & TOUCHEVENTF_DOWN)? "DOWN": ((ti[i].dwFlags & TOUCHEVENTF_UP)? "UP": "MOVE");
          if (cb)
          {
            if (ti[i].dwFlags & TOUCHEVENTF_PRIMARY)
              state = (ti[i].dwFlags & TOUCHEVENTF_DOWN)? "DOWN-PRIMARY": ((ti[i].dwFlags & TOUCHEVENTF_UP)? "UP-PRIMARY": "MOVE-PRIMARY");

            if (cb(ih, ti->dwID, x, y, state)==IUP_CLOSE)
            {
              IupExitLoop();

              if (mcb)
              {
                free(px);
                free(py);
                free(pid);
                free(pstate);
              }

              winCloseTouchInputHandle(hTouchInput);
              free(ti);

              return;
            }
          }

          if (mcb)
          {
            px[i] = x;
            py[i] = y;
            pid[i] = ti[i].dwID;
            pstate[i] = state[0];
          }
        }
      }
    }

    if (mcb)
    {
      if (mcb(ih, count, pid, px, py, pstate)==IUP_CLOSE)
        IupExitLoop();

      free(px);
      free(py);
      free(pid);
      free(pstate);
    }

    winCloseTouchInputHandle(hTouchInput);
    free(ti);
  }
}
Exemplo n.º 5
0
static void iDialogAdjustPos(Ihandle *ih, int *x, int *y)
{
  int cursor_x = 0, cursor_y = 0;
  int screen_width = 0, screen_height = 0;
  int current_x = 0, current_y = 0;
  int parent_x = 0, parent_y = 0;

  /* the dialog is already mapped here */

  if (*x == IUP_CURRENT || *y == IUP_CURRENT)
  {
    /* if first time, there is no current position */
    if (!ih->data->first_show)
    {
      int center = IUP_CENTER;
      InativeHandle* parent = iupDialogGetNativeParent(ih);
      if (parent)
        center = IUP_CENTERPARENT;

      if (*x == IUP_CURRENT) *x = center;
      if (*y == IUP_CURRENT) *y = center;
    }
    else
      iupdrvDialogGetPosition(ih, NULL, &current_x, &current_y);
  }

  if (*x == IUP_CENTER || *y == IUP_CENTER ||
      *x == IUP_RIGHT  || *y == IUP_RIGHT ||
      *x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
    iupdrvGetScreenSize(&screen_width, &screen_height);

  if (*x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
  {
    InativeHandle* parent = iupDialogGetNativeParent(ih);
    if (parent)
    {
      Ihandle* ih_parent = IupGetAttributeHandle(ih, "PARENTDIALOG");

      iupdrvDialogGetPosition(ih_parent, parent, &parent_x, &parent_y);

      if (*x == IUP_CENTERPARENT && *y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, &screen_width, &screen_height);
      else if (*x == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, &screen_width, NULL);
      else if (*y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, NULL, &screen_height);
    }
  }

  if (*x == IUP_MOUSEPOS || *y == IUP_MOUSEPOS)
    iupdrvGetCursorPos(&cursor_x, &cursor_y);

  if (iupAttribGetBoolean(ih, "MDICHILD"))
  {
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (client)
    {
      /* position is relative to mdi client */
      parent_x = 0; 
      parent_y = 0;

      /* screen size is now the size of the mdi client */
      screen_width = client->currentwidth;
      screen_height = client->currentheight;

      iupdrvScreenToClient(client, &current_x, &current_y);
      iupdrvScreenToClient(client, &cursor_x, &cursor_y);
    }
  }

  switch (*x)
  {
  case IUP_CENTERPARENT:
    *x = (screen_width - ih->currentwidth)/2 + parent_x;
    break;
  case IUP_CENTER:
    *x = (screen_width - ih->currentwidth)/2;
    break;
  case IUP_LEFT:
    *x = 0;
    break;
  case IUP_RIGHT:
    *x = screen_width - ih->currentwidth;
    break;
  case IUP_MOUSEPOS:
    *x = cursor_x;
    break;
  case IUP_CURRENT:
    *x = current_x;
    break;
  }

  switch (*y)
  {
  case IUP_CENTERPARENT:
    *y = (screen_height - ih->currentheight)/2 + parent_y;
    break;
  case IUP_CENTER:
    *y = (screen_height - ih->currentheight)/2;
    break;
  case IUP_LEFT:
    *y = 0;
    break;
  case IUP_RIGHT:
    *y = screen_height - ih->currentheight;
    break;
  case IUP_MOUSEPOS:
    *y = cursor_y;
    break;
  case IUP_CURRENT:
    *y = current_y;
    break;
  }

  iupdrvAddScreenOffset(x, y, 1);
}
Exemplo n.º 6
0
void iupDialogAdjustPos(Ihandle *ih, int *x, int *y)
{
  int cursor_x = 0, cursor_y = 0;
  int screen_width = 0, screen_height = 0;
  int current_x = 0, current_y = 0;
  int parent_x = 0, parent_y = 0;

  if (*x == IUP_CURRENT || *y == IUP_CURRENT)
    iupdrvDialogGetPosition(ih->handle, &current_x, &current_y);

  if (*x == IUP_CENTER || *y == IUP_CENTER ||
      *x == IUP_RIGHT  || *y == IUP_RIGHT ||
      *x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
    iupdrvGetScreenSize(&screen_width, &screen_height);

  if (*x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
  {
    InativeHandle* parent = iupDialogGetNativeParent(ih);
    if (parent)
    {
      iupdrvDialogGetPosition(parent, &parent_x, &parent_y);

      if (*x == IUP_CENTERPARENT && *y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, &screen_width, &screen_height);
      else if (*x == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, &screen_width, NULL);
      else if (*y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, NULL, &screen_height);
    }
  }

  if (*x == IUP_MOUSEPOS || *y == IUP_MOUSEPOS)
    iupdrvGetCursorPos(&cursor_x, &cursor_y);

  if (IupGetInt(ih, "MDICHILD"))
  {
    Ihandle* client = (Ihandle*)iupAttribGetStr(ih, "MDICLIENT_HANDLE");
    if (client)
    {
      /* position is relative to mdi client */
      parent_x = 0; 
      parent_y = 0;

      /* screen size is now the size of the mdi client */
      screen_width = client->currentwidth;
      screen_height = client->currentheight;

      iupdrvScreenToClient(client, &current_x, &current_y);
      iupdrvScreenToClient(client, &cursor_x, &cursor_y);
    }
  }

  switch (*x)
  {
  case IUP_CENTERPARENT:
    *x = (screen_width - ih->currentwidth)/2 + parent_x;
    break;
  case IUP_CENTER:
    *x = (screen_width - ih->currentwidth)/2;
    break;
  case IUP_LEFT:
    *x = 0;
    break;
  case IUP_RIGHT:
    *x = screen_width - ih->currentwidth;
    break;
  case IUP_MOUSEPOS:
    *x = cursor_x;
    break;
  case IUP_CURRENT:
    *x = current_x;
    break;
  }

  switch (*y)
  {
  case IUP_CENTERPARENT:
    *y = (screen_height - ih->currentheight)/2 + parent_y;
    break;
  case IUP_CENTER:
    *y = (screen_height - ih->currentheight)/2;
    break;
  case IUP_LEFT:
    *y = 0;
    break;
  case IUP_RIGHT:
    *y = screen_height - ih->currentheight;
    break;
  case IUP_MOUSEPOS:
    *y = cursor_y;
    break;
  case IUP_CURRENT:
    *y = current_y;
    break;
  }
}