Esempio n. 1
0
int IupOpen(int *argc, char ***argv)
{
  if (iup_opened)
    return IUP_OPENED;
  iup_opened = 1;

  if (!argc || !(*argc) || !argv)
  {
    argc = &iup_dummy_argc;
    argv = &iup_dummy_argv;
  }

  iupNamesInit();
  iupFuncInit();
  iupStrMessageInit();
  iupGlobalAttribInit(); 
  iupRegisterInit();
  iupKeyInit();
  iupImageStockInit();

  IupSetLanguage("ENGLISH");
  IupSetGlobal("VERSION", IupVersion());
  IupSetGlobal("COPYRIGHT",  IUP_COPYRIGHT);

  if (iupdrvOpen(argc, argv) == IUP_NOERROR)
  {
    char* value;

    iupdrvFontInit();

    IupStoreGlobal("SYSTEM", iupdrvGetSystemName());
    IupStoreGlobal("SYSTEMVERSION", iupdrvGetSystemVersion());
    IupStoreGlobal("COMPUTERNAME", iupdrvGetComputerName());
    IupStoreGlobal("USERNAME", iupdrvGetUserName());
    IupSetGlobal("DEFAULTFONT", iupdrvGetSystemFont());  /* Use SetGlobal because iupdrvGetSystemFont returns a static string */

    iupRegisterInternalClasses();

    value = getenv("IUP_QUIET");
    if (value && !iupStrBoolean(value)) /* if not defined do NOT print */
      printf("IUP %s %s\n", IupVersion(), IUP_COPYRIGHT);

    value = getenv("IUP_VERSION");
    if (iupStrBoolean(value))
      iupVersionDlg();

    return IUP_NOERROR;
  }
  else
  {
#ifdef  IUP_ASSERT
    /* can not use pre-defined dialogs here, so only output to console. */
    fprintf(stderr, "IUP ERROR: IupOpen failed.\n");
#endif
    return IUP_ERROR;
  }
}
Esempio n. 2
0
int iupdrvOpen(int *argc, char ***argv)
{
  GtkStyle* style;

  if (!gtk_init_check(argc, argv))
    return IUP_ERROR;
  
  IupSetGlobal("DRIVER", "GTK");

  IupStoreGlobal("SYSTEMLANGUAGE", pango_language_to_string(gtk_get_default_language()));

  /* driver system version */
  IupSetfAttribute(NULL, "GTKVERSION", "%d.%d.%d", gtk_major_version, 
                                                   gtk_minor_version, 
                                                   gtk_micro_version);
  IupSetfAttribute(NULL, "GTKDEVVERSION", "%d.%d.%d", GTK_MAJOR_VERSION, 
                                                      GTK_MINOR_VERSION, 
                                                      GTK_MICRO_VERSION);

  gtkSetDrvGlobalAttrib();

  style = gtk_style_new();
  iupgtkUpdateGlobalColors(style);
  IupSetGlobal("_IUP_RESET_GLOBALCOLORS", "YES");  /* will update the global colors when the first dialog is mapped */
  g_object_unref(style);

  return IUP_NOERROR;
}
Esempio n. 3
0
static int StoreGlobal(lua_State *L)
{
  const char *a = luaL_checkstring(L,1);
  const char *v = luaL_checkstring(L,2);
  IupStoreGlobal(a,v);
  return 0;
}
Esempio n. 4
0
void IupStoreAttribute(Ihandle *ih, const char* name, const char *value)
{
  int inherit;

  if (!name)
    return;

  if (!ih)
  {
    IupStoreGlobal(name, value);
    return;
  }

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (iupAttribIsInternal(name))
    iupAttribStoreStr(ih, name, value);
  else
  {
    if (iupClassObjectSetAttribute(ih, name, value, &inherit)==1) /* store only strings */
      iupAttribStoreStr(ih, name, value);

    if (inherit)
      iAttribNotifyChildren(ih, name, value);
  }
}
Esempio n. 5
0
int iupdrvOpen(int *argc, char ***argv)
{
  char* value;

  if (!gtk_init_check(argc, argv))
    return IUP_ERROR;

#if defined(IUPGTK_DEBUG)
  g_log_set_default_handler(iupgtk_log, NULL);
#endif

  IupSetGlobal("DRIVER", "GTK");

  IupStoreGlobal("SYSTEMLANGUAGE", pango_language_to_string(gtk_get_default_language()));

  /* driver system version */
  IupSetfAttribute(NULL, "GTKVERSION", "%d.%d.%d", gtk_major_version, 
                                                   gtk_minor_version, 
                                                   gtk_micro_version);
  IupSetfAttribute(NULL, "GTKDEVVERSION", "%d.%d.%d", GTK_MAJOR_VERSION, 
                                                      GTK_MINOR_VERSION, 
                                                      GTK_MICRO_VERSION);

  gtkSetGlobalAttrib();

  gtkSetGlobalColors();

  IupSetGlobal("SHOWMENUIMAGES", "YES");

  value = getenv("UBUNTU_MENUPROXY");  /* for now only in Ubuntu */
  if (value && (iupStrEqualNoCase(value, "libappmenu.so") || iupStrEqualNoCase(value, "1")))
    IupSetGlobal("GLOBALMENU", "Yes");
  
  return IUP_NOERROR;
}
Esempio n. 6
0
void IupSetAttributeHandle(Ihandle *ih, const char* name, Ihandle *ih_named)
{
  int inherit;
  char* handle_name;

  iupASSERT(name!=NULL);
  if (!name)
    return;

  handle_name = IupGetName(ih_named);
  if (!handle_name)
  {
    iupAttribSetHandleName(ih_named);
    handle_name = IupGetName(ih_named);
  }

  if (ih)
  {
    iupASSERT(iupObjectCheck(ih));
    if (!iupObjectCheck(ih))
      return;

    iupClassObjectSetAttribute(ih, name, handle_name, &inherit);
    iupAttribStoreStr(ih, name, handle_name);
  }
  else
    IupStoreGlobal(name, handle_name);
}
Esempio n. 7
0
// parse arguments and set globals
// only checks for argument style, no extra validation is done
BOOL parseArgs(int argc, char* argv[]) {
    int ix = 0;
    char *key, *value;
    // begin parsing "--key value" args. 
    // notice that quoted arg with spaces in between is already handled by shell
    if (argc == 1) return 0;
    for (;;) {
        if (++ix >= argc) break;
        key = argv[ix];
        if (key[0] != '-' || key[1] != '-' || key[2] == '\0') {
            return 0;
        }
        key = &(key[2]); // skip "--"
        if (++ix >= argc) {
            return 0;
        }
        value = argv[ix];
        IupStoreGlobal(key, value);
        LOG("option: %s : %s", key, value);
    }

    return 1;
}
Esempio n. 8
0
void iupSetDefaultFontSizeGlobalAttrib(const char* value)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char new_standardfont[1024];
  char* standardfont; 

  if (!value)
    return;
  
  standardfont = IupGetGlobal("DEFAULTFONT");

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return;

  sprintf(new_standardfont, "%s, %s%s%s%s%s", typeface, is_bold?"Bold ":"", is_italic?"Italic ":"", is_underline?"Underline ":"", is_strikeout?"Strikeout ":"", value);
  IupStoreGlobal("DEFAULTFONT", new_standardfont);

  return;
}
Esempio n. 9
0
int IupOpen (int *argc, char ***argv)
{
  (void)argc;
  (void)argv;

  if (iup_opened)
    return IUP_OPENED;
  iup_opened = 1;

  iupwin_hinstance = GetModuleHandle(NULL);

  CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

  {
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);  
  }

  iupNamesInit();
  iupFuncInit();
  iupLexInit();
  iupCpiInit();
  iupGlobalEnvInit(); 

  iupwinHandleInit();

  /* Iup default global atributes */
  if(IupGetLanguage() == NULL)
    IupSetLanguage(IUP_PORTUGUESE);

  IupSetGlobal("HINSTANCE", (char*) iupwin_hinstance);
  IupSetGlobal("VERSION", IUP_VERSION);
  IupSetGlobal("COPYRIGHT",  IUP_COPYRIGHT );
  IupSetGlobal(IUP_DRIVER,  "Win32" );
  IupStoreGlobal( IUP_SYSTEM, iupwinGetSystemName());
  IupStoreGlobal( "SYSTEMVERSION", iupwinGetSystemVersion());
  IupStoreGlobal( IUP_SYSTEMLANGUAGE, iupwinGetSystemLanguage());
  IupStoreGlobal( IUP_COMPUTERNAME, iupwinGetComputerName());
  IupStoreGlobal( IUP_USERNAME, iupwinGetUserName());

  /* Windows default driver attribute */
  {
    static char sysfont[100];
    char* facename;
    int size = 8, dpi;
    HDC screen = GetDC(0);
    dpi = GetDeviceCaps(screen, LOGPIXELSX);
    ReleaseDC(0, screen);

    if(iupwinGetSystemMajorVersion() >= 4)
      facename = "Tahoma";
    else
      facename = "MS Sans Serif";

    if (dpi > 100) size += 2;

    sprintf(sysfont, "%s::%d", facename, size);
    IupSetGlobal("DEFAULTFONT", sysfont);
  }

  /* Initialization of internal CPI controls */
  IupFileDlgOpen();
  IupTimerOpen();
  IupSpinOpen();
  IupCboxOpen();
  IupSboxOpen();

  /* 
  * Gets dialog background color
  */
  {
    COLORREF color;
    int wincolor;
    unsigned char r, g, b;
    static char val[15];
    static char buffer[12];

    if(iupwinGetSystemMajorVersion() >= 4)
      wincolor = COLOR_BTNFACE;
    else
      wincolor = COLOR_WINDOW;

    sprintf(buffer,"%d", wincolor);
    IupSetGlobal("_IUPWIN_DLGBGCOLOR", buffer);

    color = GetSysColor(wincolor);
    r = GetRValue(color);
    g = GetGValue(color);
    b = GetBValue(color);
    sprintf(val,"%d %d %d", (int)r, (int)g, (int)b);
    IupSetGlobal("DLGBGCOLOR", val);
  }

  iupwinSetInit();
  iupwinHookInit();
  iupwinCreatInit();

  {
    static int first = 1;
    char* env = getenv("IUP_QUIET");
    if (first && env && strcmp(env, "NO")==0)
    {
      printf("IUP "IUP_VERSION" "IUP_COPYRIGHT"\n");
      first = 0;
    }
  }

  if (getenv("IUP_VERSION"))
  {
    iupwinVersion();
  }

#ifdef __WATCOMC__ 
  {
    /* this is used to force Watcom to link the winmain.c module. */
    void iupwinMainDummy(void);
    iupwinMainDummy();
  }
#endif

  return IUP_NOERROR;
}
Esempio n. 10
0
static void SetGlobal(void)
{
  IupStoreGlobal(luaL_check_string(1), luaL_check_string(2));
}