1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/** \file
* \brief Windows Driver Core
*
* See Copyright Notice in "iup.h"
*/
#include <stdio.h>
#include <stdlib.h>
#include "iup.h"
#include "iup_str.h"
#include "iup_globalattrib.h"
#include "iup_names.h"
#include "iup_func.h"
#include "iup_drv.h"
#include "iup_drvinfo.h"
#include "iup_drvfont.h"
#include "iup_predial.h"
#include "iup_class.h"
#include "iup_register.h"
#include "iup_key.h"
#include "iup_image.h"
#include "iup_dlglist.h"
#include "iup_assert.h"
#include "iup_strmessage.h"
static int iup_opened = 0;
static int iup_dummy_argc = 0;
static char ** iup_dummy_argv = {0};
int iupIsOpened(void)
{
return iup_opened;
}
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;
}
}
void IupClose(void)
{
if (!iup_opened)
return;
iup_opened = 0;
iupdrvSetIdleFunction(NULL); /* stop any idle */
iupDlgListDestroyAll(); /* destroy all dialogs and their children */
iupNamesDestroyHandles(); /* destroy everything that do not belong to a dialog */
iupImageStockFinish(); /* release stock images hash table and the images */
iupRegisterFinish(); /* release native classes */
iupdrvFontFinish(); /* release font cache */
iupdrvClose(); /* release native handles and allocated memory */
iupGlobalAttribFinish(); /* release global hash table */
iupStrMessageFinish(); /* release messages hash table */
iupFuncFinish(); /* release callbacks hash table */
iupNamesFinish(); /* release names hash table */
iupStrGetMemory(-1); /* Frees internal buffer */
}
|