示例#1
0
文件: win.c 项目: svn2github/iup-iup
static void winEnableVisible(void)
{
  Ihandle *ih;
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (handle(ih))
    {
      int popup_level = iupGetEnvInt(ih, "_IUPWIN_POPUP_LEVEL");
      if (popup_level == win_popup_level-1)
      {
        EnableWindow((HWND)handle(ih),TRUE);
        iupSetEnv(ih, "_IUPWIN_POPUP_LEVEL", NULL);
      }
    }
  }
  win_popup_level--;
}
示例#2
0
文件: win.c 项目: svn2github/iup-iup
static void winDisableVisible(Ihandle* ih_popup)
{
  Ihandle *ih;
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (ih != ih_popup && 
        handle(ih) &&
        IsWindowVisible((HWND)handle(ih)) && 
        !iupGetEnv(ih, "_IUPWIN_POPUP_LEVEL"))
    {
      char str[50];
      EnableWindow((HWND)handle(ih),FALSE);
      sprintf(str, "%d", win_popup_level);
      iupStoreEnv(ih, "_IUPWIN_POPUP_LEVEL", str);
    }
  }
  win_popup_level++;
}
示例#3
0
static void iDialogSetModal(Ihandle* ih_popup)
{
  Ihandle *ih;
  iupAttribSetStr(ih_popup, "MODAL", "YES");

  /* disable all visible dialogs, and mark popup level */
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (ih != ih_popup && 
        ih->handle &&
        iupdrvDialogIsVisible(ih) && 
        ih->data->popup_level == 0)
    {
      iupdrvSetActive(ih, 0);
      ih->data->popup_level = dlg_popup_level;
    }
  }

  dlg_popup_level++;
}
示例#4
0
void iupDialogLeaveModal(int popup_level)
{
  Ihandle *ih;

  assert(popup_level == dlg_popup_level);

  /* must enable all visible dialogs at the marked popup level */
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (ih->handle)
    {
      if (ih->data->popup_level == dlg_popup_level - 1)
      {
        iupdrvSetActive(ih, 1);
        ih->data->popup_level = 0;
      }
    }
  }

  dlg_popup_level--;
}
示例#5
0
void iupDialogEnterModal(Ihandle* ih_popup, int popup_level)
{
  Ihandle *ih;

  assert(popup_level == dlg_popup_level);

  /* disable all visible dialogs, and mark popup level */
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (ih != ih_popup &&
      ih->handle &&
      iupdrvDialogIsVisible(ih) &&
      ih->data->popup_level == 0)
    {
      iupdrvSetActive(ih, 0);
      ih->data->popup_level = dlg_popup_level;
    }
  }

  dlg_popup_level++;
}
示例#6
0
static void iDialogUnSetModal(Ihandle* ih_popup)
{
  Ihandle *ih;
  if (!iupAttribGetInt(ih_popup, "MODAL"))
    return;

  iupAttribSetStr(ih_popup, "MODAL", NULL);

  /* must enable all visible dialogs at the marked popup level */
  for (ih = iupDlgListFirst(); ih; ih = iupDlgListNext())
  {
    if (ih->handle)
    {
      if (ih->data->popup_level == dlg_popup_level-1)
      {
        iupdrvSetActive(ih, 1);
        ih->data->popup_level = 0;
      }
    }
  }

  dlg_popup_level--;
}
示例#7
0
文件: win.c 项目: svn2github/iup-iup
static int winPopupMenu( Ihandle* h, int x, int y )
{
  HWND activehwnd = GetActiveWindow();
  HMENU hmenu = (HMENU) handle(h);
  int tray_menu = 0;
  POINT pt;
  int menuId;

  if (!hmenu)
  {
    iupwinCreatePopupMenu(h);
    hmenu = (HMENU)handle(h);
    if (!hmenu)
      return IUP_ERROR;
  }

  GetCursorPos( &pt );
  if (x == IUP_MOUSEPOS)
    x = pt.x;
 if (y == IUP_MOUSEPOS)
    y = pt.y;

  if (!activehwnd)
  {
    /* search for a valid handle */
    Ihandle* dlg = iupDlgListFirst();

    do 
    {
      if (handle(dlg))
      {
        activehwnd = handle(dlg);
        if (iupCheck(dlg, "TRAY")==YES) /* keep searching for a "TRAY" dialog */
          break;
      }
      dlg = iupDlgListNext();
    } while (dlg);
  }

  /* Necessary to avoid tray dialogs to lock popup menus (they get sticky after the 1st time) */
  if (activehwnd)
  {
    Ihandle* dlg = iupwinHandleGet(activehwnd);
    if (dlg && iupCheck(dlg, "TRAY")==YES)
    {
      /* To display a context menu for a notification icon, 
         the current window must be the foreground window. */
      SetForegroundWindow(activehwnd);
      tray_menu = 1;
    }
  }

  /* stop processing here. messages will not go to the message loop */
  menuId = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, activehwnd, NULL);

  if (tray_menu)
  {
    /* You must force a task switch to the application that 
       called TrackPopupMenu at some time in the near future. 
       This is done by posting a benign message to the window. */
    PostMessage(activehwnd, WM_NULL, 0, 0);
  }

  if (menuId)
  {
    IFni cb;
    Ihandle* n = iupwinGetMenuIhandle(menuId);
    if (!n) return IUP_NOERROR;

    cb = (IFni) IupGetCallback(n, IUP_ACTION);

    assert(number(n)>0);
    if (cb)
    {
      int ret = cb(n, GetMenuState ((HMENU)handle(n), number(n), MF_BYCOMMAND) == MF_CHECKED);
      if (ret == IUP_CLOSE)
        IupExitLoop();
    }
  }

  return IUP_NOERROR;
}
示例#8
0
int iupdrvMenuPopup(Ihandle* ih, int x, int y)
{
  HWND hWndActive = GetActiveWindow();
  int tray_menu = 0;
  int menuId;

  if (!hWndActive)
  {
    /* search for a valid handle */
    Ihandle* dlg = iupDlgListFirst();
    do 
    {
      if (dlg->handle)
      {
        hWndActive = dlg->handle;  /* found a valid handle */

        /* if not a "TRAY" dialog, keep searching, because TRAY is a special case */
        if (iupAttribGetBoolean(dlg, "TRAY")) 
          break;
      }
      dlg = iupDlgListNext();
    } while (dlg);
  }

  /* Necessary to avoid tray dialogs to lock popup menus (they get sticky after the 1st time) */
  if (hWndActive)
  {
    Ihandle* dlg = iupwinHandleGet(hWndActive);
    if (dlg && iupAttribGetBoolean(dlg, "TRAY"))
    {
      /* To display a context menu for a notification icon, 
         the current window must be the foreground window. */
      SetForegroundWindow(hWndActive);
      tray_menu = 1;
    }
  }

  /* stop processing here. messages will not go to the message loop */
  menuId = TrackPopupMenu((HMENU)ih->handle, TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, hWndActive, NULL);

  if (tray_menu)
  {
    /* You must force a task switch to the application that 
       called TrackPopupMenu at some time in the near future. 
       This is done by posting a benign message to the window. */
    PostMessage(hWndActive, WM_NULL, 0, 0);
  }

  if (menuId)
  {
    Icallback cb;
    Ihandle* ih_item = iupwinMenuGetItemHandle((HMENU)ih->handle, menuId);
    if (!ih_item) return IUP_NOERROR;

    winItemCheckToggle(ih_item);

    cb = IupGetCallback(ih_item, "ACTION");
    if (cb && cb(ih_item) == IUP_CLOSE)
      IupExitLoop();
  }

  return IUP_NOERROR;
}