示例#1
0
static void winDialogTrayBalloonMessage(Ihandle *ih, const char* value)
{
    NOTIFYICONDATA tnd;
    memset(&tnd, 0, sizeof(NOTIFYICONDATA));

    tnd.cbSize  = sizeof(NOTIFYICONDATA);
    tnd.hWnd    = ih->handle;
    tnd.uID     = 1000;
    tnd.uFlags |= NIF_INFO;

    /* set to NULL to remove the tooltip */
    if (value)
    {
        char* balloon_title;

        iupStrCopyN((char*)tnd.szInfo, sizeof(tnd.szInfo), value);

        tnd.uTimeout = IupGetInt(ih, "TRAYTIPBALLOONDELAY"); /* must use IupGetInt to use inheritance */

        balloon_title = IupGetAttribute(ih, "TRAYTIPBALLOONTITLE");
        if (balloon_title)
            iupStrCopyN((char*)tnd.szInfoTitle, sizeof(tnd.szInfoTitle), balloon_title);

        tnd.dwInfoFlags = IupGetInt(ih, "TRAYTIPBALLOONTITLEICON");
    }

    Shell_NotifyIcon(NIM_MODIFY, &tnd);
}
示例#2
0
static void winDialogTrayMessage(HWND hWnd, DWORD dwMessage, HICON hIcon, const char* value)
{
    NOTIFYICONDATA tnd;
    memset(&tnd, 0, sizeof(NOTIFYICONDATA));

    tnd.cbSize  = sizeof(NOTIFYICONDATA);
    tnd.hWnd    = hWnd;
    tnd.uID     = 1000;

    if (dwMessage == NIM_ADD)
    {
        tnd.uFlags = NIF_MESSAGE;
        tnd.uCallbackMessage = WM_USER+IUPWIN_TRAY_NOTIFICATION;
    }
    else if (dwMessage == NIM_MODIFY)
    {
        if (hIcon)
        {
            tnd.uFlags |= NIF_ICON;
            tnd.hIcon = hIcon;
        }

        if (value)
        {
            tnd.uFlags |= NIF_TIP;
            iupStrCopyN((char*)tnd.szTip, sizeof(tnd.szTip), value);
        }
    }

    Shell_NotifyIcon(dwMessage, &tnd);
}
示例#3
0
文件: iuplua_api.c 项目: LuaDist/iup
static int GetFile (lua_State *L)
{
  const char *fname = luaL_checkstring(L,1);
  char returned_fname[4096];
  int ret;
  iupStrCopyN(returned_fname, 4096, fname);
  ret = IupGetFile(returned_fname);
  lua_pushstring(L, returned_fname);
  lua_pushinteger(L, ret);
  return 2;
}
示例#4
0
文件: iuplua_api.c 项目: LuaDist/iup
static int GetText(lua_State *L)
{
  char buffer[10240];
  const char *title = luaL_checkstring(L,1);
  const char *text = luaL_checkstring(L,2);
  iupStrCopyN(buffer, 10240, text);
  if (IupGetText(title, buffer))
  {
    lua_pushstring(L, buffer);
    return 1;
  }
  return 0;
}
示例#5
0
static int GetText(lua_State *L)
{
  char* buffer;
  const char *title = luaL_checkstring(L,1);
  const char *text = luaL_checkstring(L,2);
  int maxsize = (int)luaL_optinteger(L, 3, 10240);
  buffer = malloc(maxsize+1);
  iupStrCopyN(buffer, maxsize, text);
  if (IupGetText(title, buffer, maxsize))
  {
    lua_pushstring(L, buffer);
    free(buffer);
    return 1;
  }
  free(buffer);
  return 0;
}
int IupGetFile(char* filename)
{
  Ihandle *dlg = 0;
  int ret;
  char filter[4096] = "*.*";
  static char dir[4096] = "";  /* static will make the dir persist from one call to another if not defined */

  if (!filename) return -1;

  dlg = IupFileDlg();

  iupStrFileNameSplit(filename, dir, filter);

  IupSetAttribute(dlg, "FILTER", filter);
  IupSetAttribute(dlg, "DIRECTORY", dir);
  IupSetAttribute(dlg, "ALLOWNEW", "YES");
  IupSetAttribute(dlg, "NOCHANGEDIR", "YES");
  IupSetAttribute(dlg, "PARENTDIALOG", IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg, "ICON", IupGetGlobal("ICON"));

  IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  ret = IupGetInt(dlg, "STATUS");
  if (ret != -1)
  {
    char* value = IupGetAttribute(dlg, "VALUE");
    if (value) 
    {
      iupStrCopyN(filename, 4096, value);
      iupStrFileNameSplit(filename, dir, NULL);
    }
  }

  IupDestroy(dlg);

  return ret;
}
int IupGetText(const char* title, char* text)
{
  Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dlg;
  int bt;

  multi_text = IupMultiLine(NULL);
  IupSetAttribute(multi_text,"EXPAND", "YES");
  IupSetAttribute(multi_text,"VALUE", text);
  IupSetAttribute(multi_text,"FONT", "Courier, 12");
  IupSetAttribute(multi_text, "VISIBLELINES", "10");
  IupSetAttribute(multi_text, "VISIBLECOLUMNS", "50");

  ok = IupButton("_@IUP_OK", NULL);
  IupSetAttribute(ok, "PADDING", "20x0");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);

  cancel  = IupButton("_@IUP_CANCEL", NULL);
  IupSetAttribute(cancel, "PADDING", "20x0");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);

  button_box = IupHbox(
    IupFill(),
    ok,
    cancel,
    NULL);
  IupSetAttribute(button_box,"MARGIN","0x0");
  IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL");

  dlg_box = IupVbox(
    multi_text,
    button_box,
    NULL);

  IupSetAttribute(dlg_box,"MARGIN","10x10");
  IupSetAttribute(dlg_box,"GAP","10");

  dlg = IupDialog (dlg_box);

  IupSetStrAttribute(dlg,"TITLE", title);
  IupSetAttribute(dlg,"MINBOX","NO");
  IupSetAttribute(dlg,"MAXBOX","NO");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", ok);
  IupSetAttributeHandle(dlg,"DEFAULTESC", cancel);
  IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON"));

  IupMap(dlg);

  IupSetAttribute(multi_text, "VISIBLELINES", NULL);
  IupSetAttribute(multi_text, "VISIBLECOLUMNS", NULL);

  IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  bt = IupGetInt(dlg, "STATUS");
  if (bt==1)
    iupStrCopyN(text, 10240, IupGetAttribute(multi_text, "VALUE"));
  else
    bt = 0; /* return 0 instead of -1 */

  IupDestroy(dlg);
  return bt;
}
int  iupDataEntry(int    maxlin,
                  int*   maxcol,
                  int*   maxscr,
                  char*  title,
                  char** text,
                  char** data)
{
  int i, bt;
  Ihandle *ok, *cancel, *dlg, *vb, *hb, **txt, **lbl, *button_box, *dlg_box;

  txt = (Ihandle **)calloc(maxlin, sizeof(Ihandle*));
  if (txt == NULL) return -2;
  lbl = (Ihandle **)calloc(maxlin+1, sizeof(Ihandle*));

  vb = IupVbox(NULL);

  for (i=0; i<maxlin; i++)
  {
    txt[i] = IupText(NULL);
    IupSetAttribute(txt[i],"VALUE",data[i]);
    IupSetInt(txt[i],"VISIBLECOLUMNS", maxscr[i]);
    IupSetInt(txt[i],"NC", maxcol[i]);
    IupSetAttribute(txt[i],"EXPAND","HORIZONTAL");

    hb = IupHbox(lbl[i] = IupLabel(text[i]), txt[i], NULL);
    IupSetAttribute(hb,"MARGIN","0x0");
    IupSetAttribute(hb,"ALIGNMENT","ACENTER");
    IupAppend(vb, hb);
  }
  lbl[i] = NULL;
  IupInsert(vb, NULL, IupNormalizerv(lbl));

  ok = IupButton("_@IUP_OK", NULL);
  IupSetAttribute(ok, "PADDING", "20x0");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);

  cancel = IupButton("_@IUP_CANCEL", NULL);
  IupSetAttribute(cancel, "PADDING", "20x0");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);

  button_box = IupHbox(
    IupFill(), 
    ok,
    cancel,
    NULL);
  IupSetAttribute(button_box,"MARGIN","0x0");
  IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL");

  dlg_box = IupVbox(
    IupFrame(vb),
    button_box,
    NULL);
  IupSetAttribute(dlg_box,"MARGIN","10x10");
  IupSetAttribute(dlg_box,"GAP","5");

  dlg = IupDialog(dlg_box);

  IupSetStrAttribute(dlg,"TITLE",title);
  IupSetAttribute(dlg,"MINBOX","NO");
  IupSetAttribute(dlg,"MAXBOX","NO");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", ok);
  IupSetAttributeHandle(dlg,"DEFAULTESC", cancel);
  IupSetAttribute(dlg,"PARENTDIALOG",IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON"));

  IupMap(dlg);

  IupSetfAttribute(dlg,"MAXSIZE", "65535x%d", IupGetInt2(dlg, "RASTERSIZE"));
  IupSetAttribute(dlg,"MINSIZE", IupGetAttribute(dlg, "RASTERSIZE"));

  IupPopup(dlg,IUP_CENTERPARENT,IUP_CENTERPARENT);

  for (i=0; i<maxlin; i++)
  {
    iupStrCopyN(data[i], maxcol[i]+1, IupGetAttribute(txt[i], "VALUE"));
  }

  free(lbl);
  free(txt);

  bt = IupGetInt(dlg, "STATUS");
  IupDestroy(dlg);
  return bt;
}