summaryrefslogtreecommitdiff
path: root/iup/src
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src')
-rwxr-xr-xiup/src/config.mak132
-rwxr-xr-xiup/src/gtk/iupgtk_canvas.c4
-rwxr-xr-xiup/src/gtk/iupgtk_help.c2
-rwxr-xr-xiup/src/gtk/iupgtk_tree.c30
-rwxr-xr-xiup/src/iup.c5
-rwxr-xr-xiup/src/iup.def1
-rwxr-xr-xiup/src/iup_attrib.c33
-rwxr-xr-xiup/src/iup_classattrib.c31
-rwxr-xr-xiup/src/iup_classbase.c2
-rwxr-xr-xiup/src/iup_dialog.c54
-rwxr-xr-xiup/src/iup_dll.rc41
-rwxr-xr-xiup/src/iup_getparam.c95
-rwxr-xr-xiup/src/iup_hbox.c10
-rwxr-xr-xiup/src/iup_layout.c8
-rw-r--r--iup/src/iup_split.c126
-rwxr-xr-xiup/src/iup_text.c4
-rwxr-xr-xiup/src/iup_vbox.c10
-rwxr-xr-xiup/src/iupstub.mak12
-rwxr-xr-xiup/src/make_uname4
-rwxr-xr-xiup/src/make_uname.bat55
-rwxr-xr-xiup/src/mot/iupmot_filedlg.c9
-rwxr-xr-xiup/src/mot/iupmot_tree.c14
-rwxr-xr-xiup/src/mot/iupunix_help.c2
-rwxr-xr-xiup/src/mot/iupunix_info.c19
-rwxr-xr-xiup/src/win/iupwin_clipboard.c160
-rwxr-xr-xiup/src/win/iupwin_common.c10
-rwxr-xr-xiup/src/win/iupwin_dialog.c7
-rwxr-xr-xiup/src/win/iupwin_globalattrib.c88
-rwxr-xr-xiup/src/win/iupwin_loop.c21
-rwxr-xr-xiup/src/win/iupwin_tree.c50
30 files changed, 634 insertions, 405 deletions
diff --git a/iup/src/config.mak b/iup/src/config.mak
deleted file mode 100755
index 82b8452..0000000
--- a/iup/src/config.mak
+++ /dev/null
@@ -1,132 +0,0 @@
-PROJNAME = iup
-LIBNAME = iup
-OPT = YES
-
-ifdef GTK_DEFAULT
- ifdef USE_MOTIF
- # Build Motif version in Linux,Darwin,FreeBSD
- LIBNAME = iupmot
- else
- ifeq ($(findstring Win, $(TEC_SYSNAME)), )
- # Force definition if not in Windows
- USE_GTK = Yes
- endif
- endif
-else
- ifdef USE_GTK
- # Build GTK version in IRIX,SunOS,AIX,Win32
- LIBNAME = iupgtk
- else
- ifeq ($(findstring Win, $(TEC_SYSNAME)), )
- # Force definition if not in Windows
- USE_MOTIF = Yes
- endif
- endif
-endif
-
-ifdef DBG
- DEFINES += IUP_ASSERT
-endif
-
-INCLUDES = ../include .
-
-SRC = iup_array.c iup_callback.c iup_dlglist.c iup_attrib.c iup_focus.c iup_font.c \
- iup_globalattrib.c iup_object.c iup_key.c iup_layout.c iup_ledlex.c iup_names.c iup_open.c \
- iup_ledparse.c iup_predial.c iup_register.c iup_scanf.c iup_show.c iup_str.c iup_table.c \
- iup_func.c iup_childtree.c iup.c iup_classattrib.c iup_dialog.c iup_assert.c iup_canvas.c \
- iup_messagedlg.c iup_timer.c iup_image.c iup_label.c iup_fill.c iup_zbox.c \
- iup_colordlg.c iup_fontdlg.c iup_filedlg.c iup_strmessage.c iup_menu.c iup_frame.c \
- iup_user.c iup_button.c iup_radio.c iup_toggle.c iup_progressbar.c iup_text.c iup_val.c \
- iup_box.c iup_hbox.c iup_vbox.c iup_cbox.c iup_class.c iup_classbase.c iup_maskmatch.c \
- iup_mask.c iup_maskparse.c iup_tabs.c iup_spin.c iup_list.c iup_getparam.c \
- iup_sbox.c iup_normalizer.c iup_tree.c iup_split.c
-
-ifdef USE_GTK
- DEFINES += GTK_DISABLE_DEPRECATED
- INCLUDES += gtk
- SRC += gtk/iupgtk_common.c gtk/iupgtk_focus.c gtk/iupgtk_font.c gtk/iupgtk_clipboard.c \
- gtk/iupgtk_globalattrib.c gtk/iupgtk_key.c gtk/iupgtk_tips.c \
- gtk/iupgtk_loop.c gtk/iupgtk_open.c gtk/iupgtk_messagedlg.c gtk/iupgtk_draw.c \
- gtk/iupgtk_dialog.c gtk/iupgtk_timer.c gtk/iupgtk_image.c gtk/iupgtk_label.c \
- gtk/iupgtk_colordlg.c gtk/iupgtk_fontdlg.c gtk/iupgtk_filedlg.c \
- gtk/iupgtk_button.c gtk/iupgtk_toggle.c gtk/iupgtk_progressbar.c \
- gtk/iupgtk_text.c gtk/iupgtk_val.c gtk/iupgtk_frame.c gtk/iupgtk_canvas.c \
- gtk/iupgtk_tabs.c gtk/iupgtk_menu.c gtk/iupgtk_list.c gtk/iupgtk_tree.c
-
- ifneq ($(findstring Win, $(TEC_SYSNAME)), )
- DEFINES += _WIN32_WINNT=0x0500 _WIN32_IE=0x0500 WINVER=0x0500 NOTREEVIEW
- SRC += win/iupwindows_main.c win/iupwindows_help.c win/iupwindows_info.c
- else
- ifdef GTK_MAC
- SRC += gtk/iupmac_help.c gtk/iupmac_info.c
- else
- SRC += gtk/iupgtk_help.c mot/iupunix_info.c
- endif
- endif
-
- ifdef USE_HILDON
- DEFINES += HILDON
- INCLUDES += /usr/include/hildon-1
- LIBS += hildon-1
- endif
-else
-ifdef USE_MOTIF
- SRC += mot/iupmot_common.c mot/iupmot_color.c mot/iupmot_focus.c mot/iupmot_font.c \
- mot/iupmot_key.c mot/iupmot_loop.c mot/iupmot_open.c mot/iupmot_tips.c \
- mot/iupmot_globalattrib.c mot/iupmot_dialog.c mot/iupmot_messagedlg.c mot/iupmot_draw.c \
- mot/iupmot_timer.c mot/iupmot_image.c mot/iupmot_label.c mot/iupmot_canvas.c \
- mot/iupmot_colordlg.c mot/iupmot_fontdlg.c mot/iupmot_filedlg.c mot/iupmot_frame.c \
- mot/iupmot_button.c mot/iupmot_toggle.c mot/iupmot_progressbar.c mot/iupmot_clipboard.c \
- mot/iupmot_text.c mot/iupmot_val.c mot/iupmot_tabs.c mot/iupmot_menu.c \
- mot/iupmot_list.c mot/iupmot_tree.c
-
- SRC += mot/iupunix_help.c mot/iupunix_info.c
-
- INCLUDES += mot
-else
- SRC += win/iupwin_common.c win/iupwin_brush.c win/iupwin_focus.c win/iupwin_font.c \
- win/iupwin_globalattrib.c win/iupwin_handle.c win/iupwin_key.c \
- win/iupwin_loop.c win/iupwin_open.c win/iupwin_tips.c win/iupwin_info.c \
- win/iupwin_dialog.c win/iupwin_messagedlg.c win/iupwin_timer.c \
- win/iupwin_image.c win/iupwin_label.c win/iupwin_canvas.c win/iupwin_frame.c \
- win/iupwin_colordlg.c win/iupwin_fontdlg.c win/iupwin_filedlg.c \
- win/iupwin_button.c win/iupwin_draw.c win/iupwin_toggle.c win/iupwin_clipboard.c \
- win/iupwin_progressbar.c win/iupwin_text.c win/iupwin_val.c \
- win/iupwin_tabs.c win/iupwin_menu.c win/iupwin_list.c win/iupwin_tree.c
-
- SRC += win/iupwindows_main.c win/iupwindows_help.c win/iupwindows_info.c
-
- INCLUDES += win
- DEFINES += _WIN32_WINNT=0x0500 _WIN32_IE=0x0500 WINVER=0x0500 NOTREEVIEW
-endif
-endif
-
-ifeq "$(TEC_SYSNAME)" "SunOS"
- # Necessary or the fileopen will not work in SunOS (needs to be retested)
- #DEFINES += NO_PATH_MODE_RELATIVE
-endif
-
-ifneq ($(findstring dll, $(TEC_UNAME)), )
- DEFINES += IUP_DLL
- SRC += iup_dll.rc
- DEF_FILE = iup.def
-endif
-
-ifeq "$(TEC_UNAME)" "vc6"
- # Necessary because VC6 has an old WinSDK
- #WINSDK = d:/lng/vc7/PlatformSDK
- #INCLUDES += $(WINSDK)/include
- #LDIR = $(WINSDK)/lib
-endif
-
-ifeq "$(TEC_UNAME)" "dll"
- # Necessary because VC6 has an old WinSDK
- #WINSDK = d:/lng/vc7/PlatformSDK
- #INCLUDES += $(WINSDK)/include
- #LDIR = $(WINSDK)/lib
-endif
-
-ifeq "$(TEC_UNAME)" "owc1"
- # Necessary or IUP 3 will not work in Open Watcom
- DBG=Yes
-endif
diff --git a/iup/src/gtk/iupgtk_canvas.c b/iup/src/gtk/iupgtk_canvas.c
index 3af48a4..ed34d66 100755
--- a/iup/src/gtk/iupgtk_canvas.c
+++ b/iup/src/gtk/iupgtk_canvas.c
@@ -494,6 +494,10 @@ static int gtkCanvasMapMethod(Ihandle* ih)
if (!ih->handle)
return IUP_ERROR;
+#if GTK_CHECK_VERSION(2, 18, 0)
+ gtk_widget_set_has_window(ih->handle, TRUE); /* CD will NOT work without this, but this is NOT working... */
+#endif
+
scrolled_window = (GtkScrolledWindow*)gtk_scrolled_window_new(NULL, NULL);
if (!scrolled_window)
return IUP_ERROR;
diff --git a/iup/src/gtk/iupgtk_help.c b/iup/src/gtk/iupgtk_help.c
index 270677f..7ac60c6 100755
--- a/iup/src/gtk/iupgtk_help.c
+++ b/iup/src/gtk/iupgtk_help.c
@@ -29,7 +29,7 @@ int IupHelp(const char *url)
if (iupStrEqualNoCase(system, "Linux") ||
iupStrEqualNoCase(system, "FreeBSD"))
browser = "firefox";
- else if (iupStrEqualNoCase(system, "Darwin"))
+ else if (iupStrEqualNoCase(system, "MacOS"))
browser = "safari";
else if (iupStrEqualPartial(system, "CYGWIN"))
browser = "iexplore";
diff --git a/iup/src/gtk/iupgtk_tree.c b/iup/src/gtk/iupgtk_tree.c
index 9595ada..931c097 100755
--- a/iup/src/gtk/iupgtk_tree.c
+++ b/iup/src/gtk/iupgtk_tree.c
@@ -1446,7 +1446,7 @@ static int gtkTreeSetDelNodeAttrib(Ihandle* ih, const char* name_id, const char*
iupAttribSetStr(ih, "_IUPTREE_IGNORE_SELECTION_CB", "1");
- for(i = 1; i < ih->data->node_count; /* increment only if not removed */)
+ for(i = 0; i < ih->data->node_count; /* increment only if not removed */)
{
gtkTreeIterInit(ih, &iterItem, ih->data->node_cache[i].node_handle);
if (gtkTreeIsNodeSelected(model, &iterItem))
@@ -2141,6 +2141,24 @@ static void gtkTreeCallMultiUnSelectionCb(Ihandle* ih)
}
}
+static void gtkTreeCallRightClickCb(Ihandle* ih, int x, int y)
+{
+ GtkTreePath* path;
+ if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(ih->handle), x, y, &path, NULL))
+ {
+ IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
+ if (cbRightClick)
+ {
+ GtkTreeIter iterItem;
+ GtkTreeModel* model = gtk_tree_view_get_model(GTK_TREE_VIEW(ih->handle));
+ gtk_tree_model_get_iter(model, &iterItem, path);
+ cbRightClick(ih, gtkTreeFindNodeId(ih, &iterItem));
+ }
+
+ gtk_tree_path_free (path);
+ }
+}
+
static gboolean gtkTreeButtonEvent(GtkWidget *treeview, GdkEventButton *evt, Ihandle* ih)
{
if (iupgtkButtonEvent(treeview, evt, ih) == TRUE)
@@ -2148,14 +2166,8 @@ static gboolean gtkTreeButtonEvent(GtkWidget *treeview, GdkEventButton *evt, Iha
if (evt->type == GDK_BUTTON_PRESS && evt->button == 3) /* right single click */
{
- IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
- if (cbRightClick)
- {
- int id = gtkTreeConvertXYToPos(ih, (int)evt->x, (int)evt->y);
- if (id != -1)
- cbRightClick(ih, id);
- return TRUE;
- }
+ gtkTreeCallRightClickCb(ih, (int)evt->x, (int)evt->y);
+ return TRUE;
}
else if (evt->type == GDK_2BUTTON_PRESS && evt->button == 1) /* left double click */
{
diff --git a/iup/src/iup.c b/iup/src/iup.c
index d103af5..0cb25f5 100755
--- a/iup/src/iup.c
+++ b/iup/src/iup.c
@@ -62,6 +62,7 @@
/* This appears only here to avoid changing the iup.h header fo bug fixes */
#define IUP_VERSION_FIX ""
#define IUP_VERSION_FIX_NUMBER 0
+/*#define IUP_VERSION_FIX_DATE "2010/XX/XX" */
const char iup_ident[] =
"$IUP: " IUP_VERSION IUP_VERSION_FIX " " IUP_COPYRIGHT " $\n"
@@ -79,7 +80,11 @@ char* IupVersion(void)
char* IupVersionDate(void)
{
+#ifdef IUP_VERSION_FIX_DATE
+ return IUP_VERSION_FIX_DATE;
+#else
return IUP_VERSION_DATE;
+#endif
}
int IupVersionNumber(void)
diff --git a/iup/src/iup.def b/iup/src/iup.def
index 56e7225..acd93bb 100755
--- a/iup/src/iup.def
+++ b/iup/src/iup.def
@@ -55,6 +55,7 @@ IupOpen
IupPopup
IupPreviousField
IupRadio
+IupResetAttribute
IupScanf
IupSeparator
IupSetAttribute
diff --git a/iup/src/iup_attrib.c b/iup/src/iup_attrib.c
index bf9576e..cc7ff02 100755
--- a/iup/src/iup_attrib.c
+++ b/iup/src/iup_attrib.c
@@ -264,6 +264,39 @@ void IupStoreAttribute(Ihandle *ih, const char* name, const char *value)
}
}
+static void iAttribResetChildren(Ihandle *ih, const char* name)
+{
+ Ihandle* child = ih->firstchild;
+ while (child)
+ {
+ /* set only if an inheritable attribute at the child */
+ if (iAttribIsInherit(child, name))
+ {
+ iupAttribSetStr(child, name, NULL);
+
+ iAttribResetChildren(child, name);
+ }
+
+ child = child->brother;
+ }
+}
+
+void IupResetAttribute(Ihandle *ih, const char* name)
+{
+ iupASSERT(name!=NULL);
+ if (!name)
+ return;
+
+ iupASSERT(iupObjectCheck(ih));
+ if (!iupObjectCheck(ih))
+ return;
+
+ iupAttribSetStr(ih, name, NULL);
+
+ if (iAttribIsInherit(ih, name))
+ iAttribResetChildren(ih, name);
+}
+
char* IupGetAttribute(Ihandle *ih, const char* name)
{
int inherit;
diff --git a/iup/src/iup_classattrib.c b/iup/src/iup_classattrib.c
index 3ac780c..fc478bb 100755
--- a/iup/src/iup_classattrib.c
+++ b/iup/src/iup_classattrib.c
@@ -131,7 +131,8 @@ int iupClassObjectSetAttribute(Ihandle* ih, const char* name, const char * value
*inherit = 1; /* default is inheritable */
if (afunc)
{
- *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && !(afunc->flags & IUPAF_NO_STRING);
+ *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && /* is inheritable */
+ !(afunc->flags & IUPAF_NO_STRING); /* is a string */
if (afunc->flags & IUPAF_READONLY)
{
@@ -216,7 +217,8 @@ char* iupClassObjectGetAttribute(Ihandle* ih, const char* name, char* *def_value
if (afunc)
{
*def_value = iClassGetDefaultValue(afunc);
- *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && !(afunc->flags & IUPAF_NO_STRING);
+ *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && /* is inheritable */
+ !(afunc->flags & IUPAF_NO_STRING); /* is a string */
if (afunc->flags & IUPAF_WRITEONLY)
return NULL;
@@ -267,7 +269,8 @@ void iupClassObjectGetAttributeInfo(Ihandle* ih, const char* name, char* *def_va
if (afunc)
{
*def_value = iClassGetDefaultValue(afunc);
- *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && !(afunc->flags & IUPAF_NO_STRING);
+ *inherit = !(afunc->flags & IUPAF_NO_INHERIT) && /* is inheritable */
+ !(afunc->flags & IUPAF_NO_STRING); /* is a string */
}
}
@@ -411,7 +414,9 @@ void IupSetClassDefaultAttribute(const char* classname, const char *name, const
return;
afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
- if (afunc && (!(afunc->flags & IUPAF_NO_DEFAULTVALUE) || !(afunc->flags & IUPAF_NO_STRING) || !(afunc->flags & IUPAF_HAS_ID)))
+ if (afunc && !(afunc->flags & IUPAF_NO_DEFAULTVALUE) && /* can has default */
+ !(afunc->flags & IUPAF_NO_STRING) && /* is a string */
+ !(afunc->flags & IUPAF_HAS_ID))
{
if (default_value == IUPAF_SAMEASSYSTEM)
afunc->default_value = afunc->system_default;
@@ -423,7 +428,7 @@ void IupSetClassDefaultAttribute(const char* classname, const char *name, const
else
afunc->call_global_default = 0;
}
- else if (default_value)
+ else if (!afunc && default_value)
iupClassRegisterAttribute(ic, name, NULL, NULL, default_value, NULL, IUPAF_DEFAULT);
}
@@ -442,12 +447,15 @@ void IupSaveClassAttributes(Ihandle* ih)
while (name)
{
IattribFunc* afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
- if (afunc && !(afunc->flags & IUPAF_NO_STRING))
+ if (afunc && !(afunc->flags & IUPAF_NO_STRING) && /* is a string */
+ !(afunc->flags & IUPAF_HAS_ID))
{
int inherit;
char *def_value;
char *value = iupClassObjectGetAttribute(ih, name, &def_value, &inherit);
- if (value && value != iupAttribGet(ih, name))
+ if (value && /* NOT NULL */
+ !iupStrEqualNoCase(value, iupAttribGet(ih, name)) && /* NOT already stored */
+ !iupStrEqualNoCase(value, def_value)) /* NOT equal to the default value */
iupAttribStoreStr(ih, name, value);
}
@@ -466,8 +474,11 @@ void iupClassObjectEnsureDefaultAttributes(Ihandle* ih)
while (name)
{
IattribFunc* afunc = (IattribFunc*)iupTableGetCurr(ic->attrib_func);
- if (afunc && afunc->set && (afunc->default_value || afunc->system_default) &&
- (!(afunc->flags & IUPAF_NO_DEFAULTVALUE) || !(afunc->flags & IUPAF_NO_STRING) || !(afunc->flags & IUPAF_HAS_ID)))
+ if (afunc && afunc->set &&
+ (afunc->default_value || afunc->system_default) &&
+ !(afunc->flags & IUPAF_NO_DEFAULTVALUE) && /* can has default */
+ !(afunc->flags & IUPAF_NO_STRING) && /* is a string */
+ !(afunc->flags & IUPAF_HAS_ID))
{
if ((!iupStrEqualNoCase(afunc->default_value, afunc->system_default)) ||
(afunc->call_global_default && iupGlobalDefaultColorChanged(afunc->default_value)))
@@ -505,7 +516,7 @@ char* iupClassGetDefaultAttribute(const char* classname, const char *attrib_name
afunc = (IattribFunc*)iupTableGet(ic->attrib_func, attrib_name);
if (afunc)
- return (char*)afunc->default_value;
+ return iClassGetDefaultValue(afunc);
else
return NULL;
}
diff --git a/iup/src/iup_classbase.c b/iup/src/iup_classbase.c
index 03a98d1..049b775 100755
--- a/iup/src/iup_classbase.c
+++ b/iup/src/iup_classbase.c
@@ -409,7 +409,7 @@ void iupBaseRegisterCommonAttrib(Iclass* ic)
iupClassRegisterAttribute(ic, "FLOATING", iBaseGetFloatingAttrib, iBaseSetFloatingAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "EXPAND", iBaseGetExpandAttrib, iBaseSetExpandAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "NORMALIZERGROUP", NULL, iBaseSetNormalizerGroupAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
- iupClassRegisterAttribute(ic, "EXPANDWEIGTH", NULL, NULL, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "EXPANDWEIGHT", NULL, NULL, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
/* make sure everyone has the correct default value */
iupClassRegisterAttribute(ic, "ACTIVE", NULL, NULL, IUPAF_SAMEASSYSTEM, "YES", IUPAF_DEFAULT);
diff --git a/iup/src/iup_dialog.c b/iup/src/iup_dialog.c
index 1aaf095..981e908 100755
--- a/iup/src/iup_dialog.c
+++ b/iup/src/iup_dialog.c
@@ -563,6 +563,32 @@ static int iDialogSetSizeAttrib(Ihandle* ih, const char* value)
return 0;
}
+static char* iDialogGetSizeAttrib(Ihandle* ih)
+{
+ char* str;
+ int charwidth, charheight, width, height;
+
+ if (ih->handle)
+ {
+ /* ih->currentwidth and/or ih->currentheight could have been reset in SetSize */
+ iupdrvDialogGetSize(ih->handle, &width, &height);
+ }
+ else
+ {
+ width = ih->userwidth;
+ height = ih->userheight;
+ }
+
+ iupdrvFontGetCharSize(ih, &charwidth, &charheight);
+ if (charwidth == 0 || charheight == 0)
+ return NULL; /* if font failed get from the hash table */
+
+ str = iupStrGetMemory(50);
+ sprintf(str, "%dx%d", iupRASTER2WIDTH(width, charwidth),
+ iupRASTER2HEIGHT(height, charheight));
+ return str;
+}
+
static int iDialogSetRasterSizeAttrib(Ihandle* ih, const char* value)
{
if (!value)
@@ -588,6 +614,30 @@ static int iDialogSetRasterSizeAttrib(Ihandle* ih, const char* value)
return 0;
}
+static char* iDialogGetRasterSizeAttrib(Ihandle* ih)
+{
+ char* str;
+ int width, height;
+
+ if (ih->handle)
+ {
+ /* ih->currentwidth and/or ih->currentheight could have been reset in SetRasterSize */
+ iupdrvDialogGetSize(ih->handle, &width, &height);
+ }
+ else
+ {
+ width = ih->userwidth;
+ height = ih->userheight;
+ }
+
+ if (!width && !height)
+ return NULL;
+
+ str = iupStrGetMemory(50);
+ sprintf(str, "%dx%d", width, height);
+ return str;
+}
+
static int iDialogSetVisibleAttrib(Ihandle* ih, const char* value)
{
if (iupStrBoolean(value))
@@ -717,8 +767,8 @@ Iclass* iupDialogGetClass(void)
iupBaseRegisterCommonAttrib(ic);
/* Overwrite Common */
- iupClassRegisterAttribute(ic, "SIZE", iupBaseGetSizeAttrib, iDialogSetSizeAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
- iupClassRegisterAttribute(ic, "RASTERSIZE", iupBaseGetRasterSizeAttrib, iDialogSetRasterSizeAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "SIZE", iDialogGetSizeAttrib, iDialogSetSizeAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "RASTERSIZE", iDialogGetRasterSizeAttrib, iDialogSetRasterSizeAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "POSITION", NULL, NULL, NULL, NULL, IUPAF_WRITEONLY|IUPAF_READONLY|IUPAF_NO_INHERIT); /* forbidden in dialog */
/* Base Container */
diff --git a/iup/src/iup_dll.rc b/iup/src/iup_dll.rc
deleted file mode 100755
index a1c78d8..0000000
--- a/iup/src/iup_dll.rc
+++ /dev/null
@@ -1,41 +0,0 @@
-TECGRAF_ICON ICON "..\\etc\\tecgraf.ico"
-
-1 VERSIONINFO
- FILEVERSION 3,0,0,0
- PRODUCTVERSION 3,0,0,0
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", "www.tecgraf.puc-rio.br/iup\0"
- VALUE "CompanyName", "Tecgraf/PUC-Rio\0"
- VALUE "FileDescription", "IUP - Portable User Interface\0"
- VALUE "FileVersion", "3.0.0\0"
- VALUE "LegalCopyright", "Copyright © 1994-2009 Tecgraf, PUC-Rio.\0"
- VALUE "OriginalFilename", "iup.dll\0"
- VALUE "ProductName", "IUP for Windows\0"
- VALUE "ProductVersion", "3.0.0\0"
- END
- END
-END
-
-CURSOR_PEN CURSOR "..\\etc\\pen.cur"
-
-/* To avoid the inclusion of <winuser.h> */
-#define WS_CHILD 0x40000000L
-#define WS_VISIBLE 0x10000000L
-#define WS_CLIPSIBLINGS 0x04000000L
-#define DS_3DLOOK 0x0004L
-#define DS_CONTROL 0x0400L
-#define SS_OWNERDRAW 0x0000000DL
-#define WS_EX_STATICEDGE 0x00020000L
-
-#define IUP_PREVIEWCANVAS 3000
-
-iupPreviewDlg DIALOG DISCARDABLE 0, 0, 250, 95
-STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
-FONT 8, "MS Shell Dlg"
-BEGIN
- CONTROL "", IUP_PREVIEWCANVAS, "STATIC", SS_OWNERDRAW, 70, 0, 120, 90, WS_EX_STATICEDGE
-END
diff --git a/iup/src/iup_getparam.c b/iup/src/iup_getparam.c
index 7fd6a94..3680ed5 100755
--- a/iup/src/iup_getparam.c
+++ b/iup/src/iup_getparam.c
@@ -20,6 +20,7 @@
#define RAD2DEG 57.296f /* radians to degrees */
+enum {IPARAM_TYPE_STR, IPARAM_TYPE_INT, IPARAM_TYPE_FLOAT, IPARAM_TYPE_NONE=-1};
/*******************************************************************************************
Internal Callbacks
@@ -150,7 +151,7 @@ static int iParamValAction_CB(Ihandle *self)
char* type = iupAttribGet(param, "TYPE");
if (iupStrEqual(type, "INTEGER"))
{
- iupAttribSetStrf(param, "VALUE", "%d", (int)val);
+ iupAttribSetInt(param, "VALUE", (int)val);
}
else
{
@@ -161,7 +162,7 @@ static int iParamValAction_CB(Ihandle *self)
if (val == 0)
{
old_angle = iupAttribGetFloat(param, "VALUE");
- iupAttribSetStrf(param, "_IUPGP_OLD_ANGLE", "%g", old_angle);
+ iupAttribSetFloat(param, "_IUPGP_OLD_ANGLE", old_angle);
}
else
old_angle = iupAttribGetFloat(param, "_IUPGP_OLD_ANGLE");
@@ -185,13 +186,13 @@ static int iParamValAction_CB(Ihandle *self)
}
}
- iupAttribSetStrf(param, "VALUE", "%g", val);
+ iupAttribSetFloat(param, "VALUE", val);
}
if (cb && !cb(dlg, iupAttribGetInt(param, "INDEX"), (void*)iupAttribGet(dlg, "USER_DATA")))
{
/* Undo */
- iupAttribSetStrf(param, "VALUE", "%g", old_value);
+ iupAttribSetFloat(param, "VALUE", old_value);
if (!iupAttribGetInt(param, "ANGLE"))
IupSetfAttribute(self, "VALUE", "%g", old_value);
@@ -235,12 +236,12 @@ static int iParamListAction_CB(Ihandle *self, char *t, int i, int v)
Iparamcb cb = (Iparamcb)IupGetCallback(dlg, "PARAM_CB");
int old_i = iupAttribGetInt(param, "VALUE");
- iupAttribSetStrf(param, "VALUE", "%d", i-1);
+ iupAttribSetInt(param, "VALUE", i-1);
if (cb && !cb(dlg, iupAttribGetInt(param, "INDEX"), (void*)iupAttribGet(dlg, "USER_DATA")))
{
/* Undo */
- iupAttribSetStrf(param, "VALUE", "%d", old_i);
+ iupAttribSetInt(param, "VALUE", old_i);
IupSetfAttribute(self, "VALUE", "%d", old_i+1);
/* there is no IUP_IGNORE for IupList */
@@ -327,7 +328,7 @@ static int iParamSpinReal_CB(Ihandle *self, int pos)
if (val > max)
val = max;
- iupAttribSetStrf(param, "VALUE", "%g", (double)val);
+ iupAttribSetFloat(param, "VALUE", val);
if (cb)
{
@@ -437,7 +438,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetCallback(ctrl, "ACTION", (Icallback)iParamToggleAction_CB);
IupAppend(box, ctrl);
- iupAttribSetStr(param, "DATA_TYPE", "1");
}
else if (iupStrEqual(type, "SEPARATOR"))
{
@@ -445,7 +445,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetAttribute(ctrl, "SEPARATOR", "HORIZONTAL");
IupAppend(box, ctrl);
- iupAttribSetStr(param, "DATA_TYPE", "-1");
}
else if (iupStrEqual(type, "LIST"))
{
@@ -465,7 +464,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupStoreAttribute(ctrl, str, NULL);
IupAppend(box, ctrl);
- iupAttribSetStr(param, "DATA_TYPE", "1");
}
else if (iupStrEqual(type, "STRING"))
{
@@ -498,7 +496,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupStoreAttribute(ctrl, "MASK", mask);
}
- iupAttribSetStr(param, "DATA_TYPE", "0");
iupAttribSetStr(param, "EXPAND", "1");
}
else if (iupStrEqual(type, "FILE"))
@@ -513,7 +510,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetCallback(ctrl, "ACTION", (Icallback)iParamTextAction_CB);
IupStoreAttribute(ctrl, "VALUE", iupAttribGet(param, "VALUE"));
- iupAttribSetStr(param, "DATA_TYPE", "0");
iupAttribSetStr(param, "EXPAND", "1");
@@ -540,9 +536,7 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetAttribute(ctrl, "MASK", "(/d|/d/d|1/d/d|2(0|1|2|3|4)/d|25(0|1|2|3|4|5)) (/d|/d/d|1/d/d|2(0|1|2|3|4)/d|25(0|1|2|3|4|5)) (/d|/d/d|1/d/d|2(0|1|2|3|4)/d|25(0|1|2|3|4|5)) (/d|/d/d|1/d/d|2(0|1|2|3|4)/d|25(0|1|2|3|4|5))");
IupStoreAttribute(ctrl, "VALUE", iupAttribGet(param, "VALUE"));
- iupAttribSetStr(param, "DATA_TYPE", "0");
iupAttribSetStr(param, "EXPAND", "1");
-
aux = IupCanvas(NULL);
IupSetAttribute(aux, "SIZE", "20x10");
@@ -585,7 +579,7 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetfAttribute(ctrl, "SPINMAX", "%d", (int)((max-min)/step + 0.5));
IupSetfAttribute(ctrl, "SPINVALUE", "%d", (int)((val-min)/step + 0.5));
- iupAttribSetStrf(ctrl, "_IUPGP_INCSTEP", "%g", step);
+ iupAttribSetFloat(ctrl, "_IUPGP_INCSTEP", step);
iupAttribSetStr(ctrl, "_IUPGP_SPINREAL", "1");
}
else if (iupAttribGetInt(param, "PARTIAL"))
@@ -603,7 +597,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupAppend(box, ctrl);
}
- iupAttribSetStr(param, "DATA_TYPE", "2");
IupSetAttribute(ctrl, "SIZE", "50x");
}
else /* INTEGER*/
@@ -625,7 +618,7 @@ static Ihandle* iParamCreateBox(Ihandle* param)
int step = iupAttribGetInt(param, "STEP");
if (step)
{
- iupAttribSetStrf(ctrl, "_IUPGP_INCSTEP", "%d", step);
+ iupAttribSetInt(ctrl, "_IUPGP_INCSTEP", step);
IupSetfAttribute(ctrl, "SPININC", "%d", step);
}
IupSetfAttribute(ctrl, "SPINMAX", "%d", max);
@@ -649,7 +642,6 @@ static Ihandle* iParamCreateBox(Ihandle* param)
IupSetAttribute(ctrl, "MASK", IUP_MASK_INT);
}
- iupAttribSetStr(param, "DATA_TYPE", "1");
IupSetAttribute(ctrl, "SIZE", "50x");
}
@@ -790,13 +782,12 @@ static Ihandle* IupParamDlgP(Ihandle** params)
{
int w;
- char* type = iupAttribGet(params[i], "TYPE");
- if (!iupStrEqual(type, "SEPARATOR"))
+ if (IupGetInt(params[i], "DATA_TYPE") != IPARAM_TYPE_NONE)
{
char str[20];
sprintf(str, "PARAM%d", p);
- IupSetAttribute(dlg, str, (char*)params[i]);
- iupAttribSetStrf(params[i], "INDEX", "%d", p);
+ iupAttribSetStr(dlg, str, (char*)params[i]);
+ iupAttribSetInt(params[i], "INDEX", p);
p++;
}
@@ -810,9 +801,9 @@ static Ihandle* IupParamDlgP(Ihandle** params)
i = 0;
while (params[i] != NULL)
{
- char* type = iupAttribGet(params[i], "TYPE");
- if (!iupStrEqual(type, "SEPARATOR"))
+ if (IupGetInt(params[i], "DATA_TYPE") != IPARAM_TYPE_NONE)
{
+ char* type = iupAttribGet(params[i], "TYPE");
if (iupStrEqual(type, "LIST"))
{
/* set a minimum size for lists */
@@ -1040,6 +1031,7 @@ static int iParamCopyStrLine(char* line, const char* format)
return i+1;
}
+/* Used in IupLua also */
char iupGetParamType(const char* format, int *line_size)
{
char* type = strchr(format, '%');
@@ -1072,19 +1064,19 @@ static Ihandle *IupParamf(const char* format, int *line_size)
{
case 'b':
iupAttribSetStr(param, "TYPE", "BOOLEAN");
- iupAttribSetStr(param, "DATA_TYPE", "1"); /* integer */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_INT);
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetBoolNames(extra, param);
break;
case 'l':
iupAttribSetStr(param, "TYPE", "LIST");
- iupAttribSetStr(param, "DATA_TYPE", "1"); /* integer */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_INT);
extra = iParamGetStrExtra(line_ptr, '|', '|', &count); line_ptr += count;
iParamSetListItems(extra, param);
break;
case 'a':
iupAttribSetStr(param, "TYPE", "REAL");
- iupAttribSetStr(param, "DATA_TYPE", "2"); /* real */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_FLOAT);
iupAttribSetStr(param, "ANGLE", "1");
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetInterval(extra, param);
@@ -1094,7 +1086,7 @@ static Ihandle *IupParamf(const char* format, int *line_size)
/* continue */
case 's':
iupAttribSetStr(param, "TYPE", "STRING");
- iupAttribSetStr(param, "DATA_TYPE", "0"); /* string */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_STR);
mask = iParamGetNextStrItem(line_ptr, '{', &count);
if (*mask)
iupAttribStoreStr(param, "MASK", mask);
@@ -1103,33 +1095,33 @@ static Ihandle *IupParamf(const char* format, int *line_size)
break;
case 'i':
iupAttribSetStr(param, "TYPE", "INTEGER");
- iupAttribSetStr(param, "DATA_TYPE", "1"); /* integer */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_INT);
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetInterval(extra, param);
break;
case 'r':
iupAttribSetStr(param, "TYPE", "REAL");
- iupAttribSetStr(param, "DATA_TYPE", "2"); /* real */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_FLOAT);
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetInterval(extra, param);
break;
case 'f':
iupAttribSetStr(param, "TYPE", "FILE");
- iupAttribSetStr(param, "DATA_TYPE", "0"); /* string */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_STR);
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetFileOptions(extra, param);
break;
case 'c':
iupAttribSetStr(param, "TYPE", "COLOR");
- iupAttribSetStr(param, "DATA_TYPE", "0"); /* string */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_STR);
break;
case 't':
iupAttribSetStr(param, "TYPE", "SEPARATOR");
- iupAttribSetStr(param, "DATA_TYPE", "-1"); /* NONE */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_NONE);
break;
case 'u':
iupAttribSetStr(param, "TYPE", "BUTTONNAMES");
- iupAttribSetStr(param, "DATA_TYPE", "-1"); /* NONE */
+ iupAttribSetInt(param, "DATA_TYPE", IPARAM_TYPE_NONE);
extra = iParamGetStrExtra(line_ptr, '[', ']', &count); line_ptr += count;
iParamSetButtonNames(extra, param);
break;
@@ -1148,6 +1140,7 @@ static Ihandle *IupParamf(const char* format, int *line_size)
Exported Functions
*******************************************************************************************/
+/* Used in IupLua also */
int iupGetParamCount(const char *format, int *param_extra)
{
int param_count = 0, extra = 0;
@@ -1211,21 +1204,21 @@ int IupGetParamv(const char* title, Iparamcb action, void* user_data, const char
return 0;
data_type = IupGetInt(params[i], "DATA_TYPE");
- if (data_type == 2) /* float */
+ if (data_type == IPARAM_TYPE_FLOAT)
{
float *data_float = (float*)(param_data[p]);
if (!data_float) return 0;
- iupAttribSetStrf(params[i], "VALUE", "%g", *data_float);
+ iupAttribSetFloat(params[i], "VALUE", *data_float);
p++;
}
- else if (data_type == 1) /* integer */
+ else if (data_type == IPARAM_TYPE_INT)
{
int *data_int = (int*)(param_data[p]);
if (!data_int) return 0;
- iupAttribSetStrf(params[i], "VALUE", "%d", *data_int);
+ iupAttribSetInt(params[i], "VALUE", *data_int);
p++;
}
- else if (data_type == 0) /* string */
+ else if (data_type == IPARAM_TYPE_STR)
{
char *data_str = (char*)(param_data[p]);
if (!data_str) return 0;
@@ -1255,31 +1248,25 @@ int IupGetParamv(const char* title, Iparamcb action, void* user_data, const char
}
else
{
- for (i = 0, p = 0; i < param_count; i++)
+ for (i = 0, p = 0; i < param_count+param_extra; i++)
{
- Ihandle* param;
- int data_type;
- char str[20];
-
- sprintf(str, "PARAM%d", i);
- param = (Ihandle*)iupAttribGet(dlg, str);
-
- data_type = iupAttribGetInt(param, "DATA_TYPE");
- if (data_type == 1)
+ Ihandle* param = params[i];
+ int data_type = iupAttribGetInt(param, "DATA_TYPE");
+ if (data_type == IPARAM_TYPE_INT)
{
- int *data_int = (int*)(param_data[i]);
+ int *data_int = (int*)(param_data[p]);
*data_int = iupAttribGetInt(param, "VALUE");
p++;
}
- else if (data_type == 2)
+ else if (data_type == IPARAM_TYPE_FLOAT)
{
- float *data_float = (float*)(param_data[i]);
+ float *data_float = (float*)(param_data[p]);
*data_float = iupAttribGetFloat(param, "VALUE");
p++;
}
- else
+ else if (data_type == IPARAM_TYPE_STR)
{
- char *data_str = (char*)(param_data[i]);
+ char *data_str = (char*)(param_data[p]);
strcpy(data_str, iupAttribGet(param, "VALUE"));
p++;
}
diff --git a/iup/src/iup_hbox.c b/iup/src/iup_hbox.c
index a8a93a3..aaa8e4d 100755
--- a/iup/src/iup_hbox.c
+++ b/iup/src/iup_hbox.c
@@ -213,12 +213,12 @@ static void iHboxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
else
{
int empty = (child->expand & IUP_EXPAND_W1)? empty_w1: ((child->expand & IUP_EXPAND_W0)? empty_w0: 0);
- char* weigth_str = iupAttribGet(child, "EXPANDWEIGTH");
- if (weigth_str)
+ char* weight_str = iupAttribGet(child, "EXPANDWEIGHT");
+ if (weight_str)
{
- float weigth;
- if (iupStrToFloat(weigth_str, &weigth))
- empty = iupROUND(empty * weigth);
+ float weight;
+ if (iupStrToFloat(weight_str, &weight))
+ empty = iupROUND(empty * weight);
}
iupBaseSetCurrentSize(child, child->naturalwidth+empty, client_height, shrink);
}
diff --git a/iup/src/iup_layout.c b/iup/src/iup_layout.c
index 0ccd496..9387135 100755
--- a/iup/src/iup_layout.c
+++ b/iup/src/iup_layout.c
@@ -143,8 +143,8 @@ void iupLayoutSetMinMaxSize(Ihandle* ih, int *w, int *h)
char* value = iupAttribGet(ih, "MINSIZE");
int min_w = 0, min_h = 0; /* MINSIZE default value */
iupStrToIntInt(value, &min_w, &min_h, 'x');
- if (*w < min_w) *w = min_w;
- if (*h < min_h) *h = min_h;
+ if (w && *w < min_w) *w = min_w;
+ if (h && *h < min_h) *h = min_h;
}
if (ih->has_maxsize)
@@ -152,8 +152,8 @@ void iupLayoutSetMinMaxSize(Ihandle* ih, int *w, int *h)
char* value = iupAttribGet(ih, "MAXSIZE");
int max_w = 65535, max_h = 65535; /* MAXSIZE default value */
iupStrToIntInt(value, &max_w, &max_h, 'x');
- if (*w > max_w) *w = max_w;
- if (*h > max_h) *h = max_h;
+ if (w && *w > max_w) *w = max_w;
+ if (h && *h > max_h) *h = max_h;
}
}
diff --git a/iup/src/iup_split.c b/iup/src/iup_split.c
index 1829142..e8029cb 100644
--- a/iup/src/iup_split.c
+++ b/iup/src/iup_split.c
@@ -35,19 +35,71 @@ struct _IcontrolData
int layoutdrag, autohide, showgrip, barsize;
int direction; /* one of the types: ISPLIT_VERT, ISPLIT_HORIZ */
int val; /* split value: 0-1000, default 500 */
+ int min, max; /* used only to crop val */
};
+
+static void iSplitCropVal(Ihandle* ih)
+{
+ if (ih->data->val < ih->data->min) ih->data->val = ih->data->min;
+ if (ih->data->val > ih->data->max) ih->data->val = ih->data->max;
+}
+
static int iSplitGetWidth1(Ihandle* ih)
{
+ Ihandle *child1;
+
int width1 = ((ih->currentwidth-ih->data->barsize)*ih->data->val)/1000;
if (width1 < 0) width1 = 0;
+
+ child1 = ih->firstchild->brother;
+ if (child1)
+ {
+ Ihandle *child2 = child1->brother;
+ if (child2)
+ {
+ int width2 = (ih->currentwidth-ih->data->barsize)-width1;
+ if (width2 < 0) width2 = 0;
+
+ iupLayoutSetMinMaxSize(child2, &width2, NULL);
+
+ /* only check if child2 has a minsize */
+ if (width2 > (ih->currentwidth-ih->data->barsize)-width1)
+ width1 = (ih->currentwidth-ih->data->barsize)-width2;
+ }
+
+ iupLayoutSetMinMaxSize(child1, &width1, NULL);
+ }
+
return width1;
}
static int iSplitGetHeight1(Ihandle* ih)
{
+ Ihandle *child1;
+
int height1 = ((ih->currentheight-ih->data->barsize)*ih->data->val)/1000;
if (height1 < 0) height1 = 0;
+
+ child1 = ih->firstchild->brother;
+ if (child1)
+ {
+ Ihandle *child2 = child1->brother;
+ if (child2)
+ {
+ int height2 = (ih->currentheight-ih->data->barsize)-height1;
+ if (height2 < 0) height2 = 0;
+
+ iupLayoutSetMinMaxSize(child2, &height2, NULL);
+
+ /* only check if child2 has a minsize */
+ if (height2 > (ih->currentheight-ih->data->barsize)-height1)
+ height1 = (ih->currentheight-ih->data->barsize)-height2;
+ }
+
+ iupLayoutSetMinMaxSize(child1, NULL, &height1);
+ }
+
return height1;
}
@@ -232,8 +284,7 @@ static int iSplitMotion_CB(Ihandle* bar, int x, int y, char *status)
ih->data->val = (height1*1000)/(ih->currentheight-ih->data->barsize);
}
- if (ih->data->val < 0) ih->data->val = 0;
- if (ih->data->val > 1000) ih->data->val = 1000;
+ iSplitCropVal(ih);
if (ih->data->layoutdrag)
{
@@ -331,49 +382,49 @@ static int iSplitFocus_CB(Ihandle* bar, int focus)
static char* iSplitGetClientSize1Attrib(Ihandle* ih)
{
- int width, height;
+ int width1, height1;
char* str = iupStrGetMemory(20);
if (ih->data->direction == ISPLIT_VERT)
{
- width = iSplitGetWidth1(ih);
- height = ih->currentheight;
+ width1 = iSplitGetWidth1(ih);
+ height1 = ih->currentheight;
}
else /* ISPLIT_HORIZ */
{
- height = iSplitGetHeight1(ih);
- width = ih->currentwidth;
+ height1 = iSplitGetHeight1(ih);
+ width1 = ih->currentwidth;
}
- sprintf(str, "%dx%d", width, height);
+ sprintf(str, "%dx%d", width1, height1);
return str;
}
static char* iSplitGetClientSize2Attrib(Ihandle* ih)
{
- int width, height;
+ int width2, height2;
char* str = iupStrGetMemory(20);
if (ih->data->direction == ISPLIT_VERT)
{
int width1 = iSplitGetWidth1(ih);
- width = (ih->currentwidth-ih->data->barsize)-width1;
- if (width < 0) width = 0;
+ width2 = (ih->currentwidth-ih->data->barsize)-width1;
+ if (width2 < 0) width2 = 0;
- height = ih->currentheight;
+ height2 = ih->currentheight;
}
else /* ISPLIT_HORIZ */
{
int height1 = iSplitGetHeight1(ih);
- height = (ih->currentheight-ih->data->barsize)-height1;
- if (height < 0) height = 0;
+ height2 = (ih->currentheight-ih->data->barsize)-height1;
+ if (height2 < 0) height2 = 0;
- width = ih->currentwidth;
+ width2 = ih->currentwidth;
}
- sprintf(str, "%dx%d", width, height);
+ sprintf(str, "%dx%d", width2, height2);
return str;
}
@@ -406,7 +457,7 @@ static int iSplitSetValueAttrib(Ihandle* ih, const char* value)
{
if (!value)
{
- ih->data->val = -1;
+ ih->data->val = -1; /* reset to calculate in Natural size */
if (ih->data->autohide)
iSplitAutoHideVal(ih);
@@ -420,6 +471,7 @@ static int iSplitSetValueAttrib(Ihandle* ih, const char* value)
if (iupStrToInt(value, &val))
{
ih->data->val = val;
+ iSplitCropVal(ih);
if (ih->data->autohide)
iSplitAutoHideVal(ih);
@@ -459,6 +511,38 @@ static char* iSplitGetBarSizeAttrib(Ihandle* ih)
return str;
}
+static int iSplitSetMinMaxAttrib(Ihandle* ih, const char* value)
+{
+ if (iupStrToIntInt(value, &ih->data->min, &ih->data->max, ':'))
+ {
+ if (ih->data->min > ih->data->max)
+ {
+ int t = ih->data->min;
+ ih->data->min = ih->data->max;
+ ih->data->max = t;
+ }
+ if (ih->data->min < 0) ih->data->min = 0;
+ if (ih->data->max > 1000) ih->data->max = 1000;
+
+ if (ih->data->val != -1)
+ iSplitCropVal(ih);
+
+ if (ih->data->autohide)
+ iSplitAutoHideVal(ih);
+
+ if (ih->handle)
+ IupRefresh(ih); /* may affect all the elements in the dialog */
+ }
+ return 0; /* do not store value in hash table */
+}
+
+static char* iSplitGetMinMaxAttrib(Ihandle* ih)
+{
+ char* str = iupStrGetMemory(30);
+ sprintf(str, "%d:%d", ih->data->min, ih->data->max);
+ return str;
+}
+
static int iSplitSetLayoutDragAttrib(Ihandle* ih, const char* value)
{
if (iupStrBoolean(value))
@@ -600,11 +684,10 @@ static void iSplitComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *exp
else
ih->data->val = (child1->naturalheight*1000)/(natural_h-ih->data->barsize);
- if (ih->data->val < 0) ih->data->val = 0;
- if (ih->data->val > 1000) ih->data->val = 1000;
+ iSplitCropVal(ih);
}
else
- ih->data->val = 0;
+ ih->data->val = ih->data->min;
}
*w = natural_w;
@@ -707,6 +790,8 @@ static int iSplitCreateMethod(Ihandle* ih, void** params)
ih->data->autohide = 0;
ih->data->barsize = 5;
ih->data->showgrip = 1;
+ ih->data->min = 0;
+ ih->data->max = 1000;
bar = IupCanvas(NULL);
iupChildTreeAppend(ih, bar); /* bar will always be the firstchild */
@@ -766,6 +851,7 @@ Iclass* iupSplitGetClass(void)
iupClassRegisterAttribute(ic, "SHOWGRIP", iSplitGetShowGripAttrib, iSplitSetShowGripAttrib, IUPAF_SAMEASSYSTEM, "YES", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "AUTOHIDE", iSplitGetAutoHideAttrib, iSplitSetAutoHideAttrib, IUPAF_SAMEASSYSTEM, "NO", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "BARSIZE", iSplitGetBarSizeAttrib, iSplitSetBarSizeAttrib, IUPAF_SAMEASSYSTEM, "5", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "MINMAX", iSplitGetMinMaxAttrib, iSplitSetMinMaxAttrib, IUPAF_SAMEASSYSTEM, "0:1000", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
return ic;
}
diff --git a/iup/src/iup_text.c b/iup/src/iup_text.c
index 6cd7235..d2e2e36 100755
--- a/iup/src/iup_text.c
+++ b/iup/src/iup_text.c
@@ -365,9 +365,9 @@ static void iTextComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *expa
{
int sb_size = iupdrvGetScrollbarSize();
if (ih->data->sb & IUP_SB_HORIZ)
- natural_w += sb_size;
+ natural_h += sb_size; /* sb horizontal affects vertical size */
if (ih->data->sb & IUP_SB_VERT)
- natural_h += sb_size;
+ natural_w += sb_size; /* sb vertical affects horizontal size */
}
*w = natural_w;
diff --git a/iup/src/iup_vbox.c b/iup/src/iup_vbox.c
index 23e8e3a..5afd7e2 100755
--- a/iup/src/iup_vbox.c
+++ b/iup/src/iup_vbox.c
@@ -215,12 +215,12 @@ static void iVboxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
else
{
int empty = (child->expand & IUP_EXPAND_H1)? empty_h1: ((child->expand & IUP_EXPAND_H0)? empty_h0: 0);
- char* weigth_str = iupAttribGet(child, "EXPANDWEIGTH");
- if (weigth_str)
+ char* weight_str = iupAttribGet(child, "EXPANDWEIGHT");
+ if (weight_str)
{
- float weigth;
- if (iupStrToFloat(weigth_str, &weigth))
- empty = iupROUND(empty * weigth);
+ float weight;
+ if (iupStrToFloat(weight_str, &weight))
+ empty = iupROUND(empty * weight);
}
iupBaseSetCurrentSize(child, client_width, child->naturalheight+empty, shrink);
}
diff --git a/iup/src/iupstub.mak b/iup/src/iupstub.mak
deleted file mode 100755
index 9ca920f..0000000
--- a/iup/src/iupstub.mak
+++ /dev/null
@@ -1,12 +0,0 @@
-PROJNAME = iup
-LIBNAME = iupstub
-OPT = YES
-
-USE_DLL = Yes
-
-INCLUDES = ../include
-
-SRC = win/iupwindows_main.c
-
-iupstup-dll:
- @move /y ..\lib\vc6\iupstub.lib ..\lib\dll
diff --git a/iup/src/make_uname b/iup/src/make_uname
deleted file mode 100755
index 6542234..0000000
--- a/iup/src/make_uname
+++ /dev/null
@@ -1,4 +0,0 @@
-#This builds all the libraries of the folder for 1 uname
-
-tecmake USE_MOTIF=Yes $1 $2 $3 $4 $5 $6 $7
-tecmake USE_GTK=Yes $1 $2 $3 $4 $5 $6 $7
diff --git a/iup/src/make_uname.bat b/iup/src/make_uname.bat
deleted file mode 100755
index 1a79780..0000000
--- a/iup/src/make_uname.bat
+++ /dev/null
@@ -1,55 +0,0 @@
-@echo off
-REM This builds all the libraries of the folder for 1 uname
-
-call tecmake %1 %2 %3 %4 %5 %6
-call tecmake %1 "USE_GTK=Yes" %2 %3 %4 %5 %6
-
-if "%1"=="dll" goto stub_dll
-if "%1"=="dll7" goto stub_dll7
-if "%1"=="dll8" goto stub_dll8
-if "%1"=="dll8_64" goto stub_dll8_64
-if "%1"=="dll9" goto stub_dll9
-if "%1"=="dll9_64" goto stub_dll9_64
-if "%1"=="all" goto all_dll
-goto fim
-
-:stub_dll
-call tecmake vc6 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc6\iupstub.lib ..\lib\dll
-goto fim
-
-:stub_dll7
-call tecmake vc7 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc7\iupstub.lib ..\lib\dll7
-goto fim
-
-:stub_dll8
-call tecmake vc8 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc8\iupstub.lib ..\lib\dll8
-goto fim
-
-:stub_dll8_64
-call tecmake vc8_64 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc8_64\iupstub.lib ..\lib\dll8_64
-goto fim
-
-:stub_dll9
-call tecmake vc9 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc9\iupstub.lib ..\lib\dll9
-goto fim
-
-:stub_dll9_64
-call tecmake vc9_64 "MF=iupstub" %2 %3 %4 %5 %6 %7
-move /y ..\lib\vc9_64\iupstub.lib ..\lib\dll9_64
-goto fim
-
-:all_dll
-call make_uname dll %2 %3 %4 %5 %6
-call make_uname dll7 %2 %3 %4 %5 %6
-call make_uname dll8 %2 %3 %4 %5 %6
-call make_uname dll8_64 %2 %3 %4 %5 %6
-call make_uname dll9 %2 %3 %4 %5 %6
-call make_uname dll9_64 %2 %3 %4 %5 %6
-goto fim
-
-:fim
diff --git a/iup/src/mot/iupmot_filedlg.c b/iup/src/mot/iupmot_filedlg.c
index 0be6319..5d8ebe0 100755
--- a/iup/src/mot/iupmot_filedlg.c
+++ b/iup/src/mot/iupmot_filedlg.c
@@ -483,6 +483,7 @@ static int motFileDlgPopup(Ihandle* ih, int x, int y)
XtVaSetValues(filebox,
XmNdialogStyle, style,
XmNautoUnmanage, False,
+ XmNresizePolicy, XmRESIZE_GROW,
NULL);
if (dialogtype == IUP_DIALOGDIR)
@@ -620,6 +621,14 @@ static int motFileDlgPopup(Ihandle* ih, int x, int y)
file_cb(ih, NULL, "INIT");
}
+ if (ih->userwidth && ih->userheight)
+ {
+ XtVaSetValues(dialog,
+ XmNwidth, (XtArgVal)(ih->userwidth),
+ XmNheight, (XtArgVal)(ih->userheight),
+ NULL);
+ }
+
if (style == XmDIALOG_MODELESS)
XtPopup(dialog, XtGrabExclusive);
diff --git a/iup/src/mot/iupmot_tree.c b/iup/src/mot/iupmot_tree.c
index fa5ef09..0156974 100755
--- a/iup/src/mot/iupmot_tree.c
+++ b/iup/src/mot/iupmot_tree.c
@@ -1440,7 +1440,7 @@ static int motTreeSetDelNodeAttrib(Ihandle* ih, const char* name_id, const char*
else if(iupStrEqualNoCase(value, "MARKED")) /* Delete the array of marked nodes */
{
int i;
- for(i = 1; i < ih->data->node_count; /* increment only if not removed */)
+ for(i = 0; i < ih->data->node_count; /* increment only if not removed */)
{
if (motTreeIsNodeSelected(ih->data->node_cache[i].node_handle))
motTreeRemoveNode(ih, ih->data->node_cache[i].node_handle, 1, 1);
@@ -1770,13 +1770,13 @@ static int motTreeConvertXYToPos(Ihandle* ih, int x, int y)
static void motTreeCallRightClickCb(Ihandle* ih, int x, int y)
{
- IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
- if (cbRightClick)
+ Widget wItem = XmObjectAtPoint(ih->handle, (Position)x, (Position)y);
+ if (wItem)
{
- int id = motTreeConvertXYToPos(ih, x, y);
- if (id != -1)
- cbRightClick(ih, id);
- }
+ IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
+ if (cbRightClick)
+ cbRightClick(ih, iupTreeFindNodeId(ih, wItem));
+ }
}
static void motTreeCallRenameCb(Ihandle* ih)
diff --git a/iup/src/mot/iupunix_help.c b/iup/src/mot/iupunix_help.c
index 02be1da..ba268b7 100755
--- a/iup/src/mot/iupunix_help.c
+++ b/iup/src/mot/iupunix_help.c
@@ -26,7 +26,7 @@ int IupHelp(const char *url)
if (iupStrEqualNoCase(system, "Linux") ||
iupStrEqualNoCase(system, "FreeBSD"))
browser = "firefox";
- else if (iupStrEqualNoCase(system, "Darwin"))
+ else if (iupStrEqualNoCase(system, "MacOS"))
browser = "safari";
else if (iupStrEqualPartial(system, "CYGWIN"))
browser = "iexplore";
diff --git a/iup/src/mot/iupunix_info.c b/iup/src/mot/iupunix_info.c
index f09573c..3bfee08 100755
--- a/iup/src/mot/iupunix_info.c
+++ b/iup/src/mot/iupunix_info.c
@@ -274,7 +274,10 @@ char *iupdrvGetSystemName(void)
char *str = iupStrGetMemory(50);
uname(&un);
- strcpy(str, un.sysname);
+ if (iupStrEqualNoCase(un.sysname, "Darwin"))
+ strcpy(str, "MacOS");
+ else
+ strcpy(str, un.sysname);
return str;
}
@@ -285,9 +288,17 @@ char *iupdrvGetSystemVersion(void)
char *str = iupStrGetMemory(100);
uname(&un);
- strcpy(str, un.release);
- strcat(str, ".");
- strcat(str, un.version);
+ if (iupStrEqualNoCase(un.sysname, "Darwin"))
+ {
+ int release = atoi(un.release);
+ sprintf(str, "%d", release-4);
+ }
+ else
+ {
+ strcpy(str, un.release);
+ strcat(str, ".");
+ strcat(str, un.version);
+ }
return str;
}
diff --git a/iup/src/win/iupwin_clipboard.c b/iup/src/win/iupwin_clipboard.c
index 1e0fab4..debad0d 100755
--- a/iup/src/win/iupwin_clipboard.c
+++ b/iup/src/win/iupwin_clipboard.c
@@ -20,6 +20,136 @@
#include "iupwin_drv.h"
+typedef struct _APMFILEHEADER
+{
+ WORD key1,
+ key2,
+ hmf,
+ bleft, btop, bright, bbottom,
+ inch,
+ reserved1,
+ reserved2,
+ checksum;
+} APMFILEHEADER;
+
+static WORD winAPMChecksum(APMFILEHEADER* papm)
+{
+ WORD* pw = (WORD*)papm;
+ WORD wSum = 0;
+ int i;
+
+ /* The checksum in a Placeable Metafile header is calculated */
+ /* by XOR-ing the first 10 words of the header. */
+
+ for (i = 0; i < 10; i++)
+ wSum ^= *pw++;
+
+ return wSum;
+}
+
+static void winWritePlacebleFile(HANDLE hFile, unsigned char* buffer, DWORD dwSize, LONG mm, LONG xExt, LONG yExt)
+{
+ DWORD nBytesWrite;
+ APMFILEHEADER APMHeader;
+ int w = xExt, h = yExt;
+
+ if (mm == MM_ANISOTROPIC || mm == MM_ISOTROPIC)
+ {
+ int res = 30;
+ w = xExt / res;
+ h = yExt / res;
+ }
+
+ APMHeader.key1 = 0xCDD7;
+ APMHeader.key2 = 0x9AC6;
+ APMHeader.hmf = 0;
+ APMHeader.bleft = 0;
+ APMHeader.btop = 0;
+ APMHeader.bright = (short)w;
+ APMHeader.bbottom = (short)h;
+ APMHeader.inch = 100; /* this number works fine in Word, etc.. */
+ APMHeader.reserved1 = 0;
+ APMHeader.reserved2 = 0;
+ APMHeader.checksum = winAPMChecksum(&APMHeader);
+
+ WriteFile(hFile, (LPSTR)&APMHeader, sizeof(APMFILEHEADER), &nBytesWrite, NULL);
+ WriteFile(hFile, buffer, dwSize, &nBytesWrite, NULL);
+}
+
+static int winClipboardSetSaveEMFAttrib(Ihandle *ih, const char *value)
+{
+ HENHMETAFILE Handle;
+ DWORD dwSize, nBytesWrite;
+ unsigned char* buffer;
+ HANDLE hFile;
+ (void)ih;
+
+ OpenClipboard(NULL);
+ Handle = (HENHMETAFILE)GetClipboardData(CF_ENHMETAFILE);
+ if (Handle == NULL)
+ {
+ CloseClipboard();
+ return 0;
+ }
+
+ dwSize = GetEnhMetaFileBits(Handle, 0, NULL);
+
+ buffer = (unsigned char*)malloc(dwSize);
+
+ GetEnhMetaFileBits(Handle, dwSize, buffer);
+
+ hFile = CreateFile(value, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ if (hFile)
+ {
+ WriteFile(hFile, buffer, dwSize, &nBytesWrite, NULL);
+ CloseHandle(hFile);
+ }
+
+ free(buffer);
+
+ CloseClipboard();
+ return 0;
+}
+
+static int winClipboardSetSaveWMFAttrib(Ihandle *ih, const char *value)
+{
+ DWORD dwSize;
+ unsigned char* buffer;
+ METAFILEPICT* lpMFP;
+ HANDLE Handle;
+ HANDLE hFile;
+ (void)ih;
+
+ OpenClipboard(NULL);
+ Handle = (HENHMETAFILE)GetClipboardData(CF_METAFILEPICT);
+ if (Handle == NULL)
+ {
+ CloseClipboard();
+ return 0;
+ }
+
+ lpMFP = (METAFILEPICT*) GlobalLock(Handle);
+
+ dwSize = GetMetaFileBitsEx(lpMFP->hMF, 0, NULL);
+
+ buffer = (unsigned char*)malloc(dwSize);
+
+ GetMetaFileBitsEx(lpMFP->hMF, dwSize, buffer);
+
+ hFile = CreateFile(value, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ if (hFile)
+ {
+ winWritePlacebleFile(hFile, buffer, dwSize, lpMFP->mm, lpMFP->xExt, lpMFP->yExt);
+ CloseHandle(hFile);
+ }
+
+ GlobalUnlock(Handle);
+ free(buffer);
+
+ CloseClipboard();
+ return 0;
+}
+
static int winClipboardSetTextAttrib(Ihandle *ih, const char *value)
{
HANDLE hHandle;
@@ -162,6 +292,32 @@ static char* winClipboardGetImageAvailableAttrib(Ihandle *ih)
return "NO";
}
+static char* winClipboardGetWMFAvailableAttrib(Ihandle *ih)
+{
+ int check;
+ (void)ih;
+ OpenClipboard(NULL);
+ check = IsClipboardFormatAvailable(CF_METAFILEPICT);
+ CloseClipboard();
+ if (check)
+ return "YES";
+ else
+ return "NO";
+}
+
+static char* winClipboardGetEMFAvailableAttrib(Ihandle *ih)
+{
+ int check;
+ (void)ih;
+ OpenClipboard(NULL);
+ check = IsClipboardFormatAvailable(CF_ENHMETAFILE);
+ CloseClipboard();
+ if (check)
+ return "YES";
+ else
+ return "NO";
+}
+
/******************************************************************************/
Ihandle* IupClipboard(void)
@@ -185,6 +341,10 @@ Iclass* iupClipboardGetClass(void)
iupClassRegisterAttribute(ic, "IMAGE", NULL, winClipboardSetImageAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "TEXTAVAILABLE", winClipboardGetTextAvailableAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "IMAGEAVAILABLE", winClipboardGetImageAvailableAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "WMFAVAILABLE", winClipboardGetWMFAvailableAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "EMFAVAILABLE", winClipboardGetEMFAvailableAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "SAVEEMF", NULL, winClipboardSetSaveEMFAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
+ iupClassRegisterAttribute(ic, "SAVEWMF", NULL, winClipboardSetSaveWMFAttrib, NULL, NULL, IUPAF_WRITEONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
return ic;
}
diff --git a/iup/src/win/iupwin_common.c b/iup/src/win/iupwin_common.c
index ba68b78..0f53e68 100755
--- a/iup/src/win/iupwin_common.c
+++ b/iup/src/win/iupwin_common.c
@@ -372,7 +372,7 @@ int iupwinBaseContainerProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT
case WM_CTLCOLORSTATIC:
{
Ihandle* child = iupwinHandleGet((void*)lp);
- if (child)
+ if (child && iupChildTreeGetNativeParent(child)==ih)
{
IFctlColor cb = (IFctlColor)IupGetCallback(child, "_IUPWIN_CTLCOLOR_CB");
if (cb)
@@ -390,7 +390,11 @@ int iupwinBaseContainerProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT
if (wp == 0) /* a menu */
child = iupwinMenuGetItemHandle((HMENU)drawitem->hwndItem, drawitem->itemID);
else
+ {
child = iupwinHandleGet(drawitem->hwndItem);
+ if (child && iupChildTreeGetNativeParent(child)!=ih)
+ child = NULL;
+ }
if (child)
{
@@ -408,7 +412,7 @@ int iupwinBaseContainerProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT
case WM_VSCROLL:
{
Ihandle *child = iupwinHandleGet((void*)lp);
- if (child)
+ if (child && iupChildTreeGetNativeParent(child)==ih)
{
IFni cb = (IFni)IupGetCallback(child, "_IUPWIN_CUSTOMSCROLL_CB");
if (cb)
@@ -426,7 +430,7 @@ int iupwinBaseContainerProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT
break;
child = iupwinHandleGet(msg_info->hwndFrom);
- if (child)
+ if (child && iupChildTreeGetNativeParent(child)==ih)
{
IFnotify cb = (IFnotify)IupGetCallback(child, "_IUPWIN_NOTIFY_CB");
if (cb)
diff --git a/iup/src/win/iupwin_dialog.c b/iup/src/win/iupwin_dialog.c
index c13b88d..93fe404 100755
--- a/iup/src/win/iupwin_dialog.c
+++ b/iup/src/win/iupwin_dialog.c
@@ -423,6 +423,13 @@ static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESUL
*result = 0;
return 1;
}
+ case WM_COPYDATA: /* usually from SetGlobal("SINGLEINSTANCE") */
+ {
+ COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lp;
+ IFnsi cb = (IFnsi)IupGetCallback(ih, "COPYDATA_CB");
+ if (cb) cb(ih, cds->lpData, cds->cbData);
+ break;
+ }
case WM_SETCURSOR:
{
if (ih->handle == (HWND)wp && LOWORD(lp)==HTCLIENT)
diff --git a/iup/src/win/iupwin_globalattrib.c b/iup/src/win/iupwin_globalattrib.c
index bcd6355..2d27ca5 100755
--- a/iup/src/win/iupwin_globalattrib.c
+++ b/iup/src/win/iupwin_globalattrib.c
@@ -17,13 +17,81 @@
#include "iupwin_drv.h"
-static int win_monitor_index = 0;
-
/* Not defined in compilers older than VC9 */
#ifndef MAPVK_VK_TO_VSC
#define MAPVK_VK_TO_VSC (0)
#endif
+
+static int win_monitor_index = 0;
+static HANDLE win_singleintance = NULL;
+static HWND win_findwindow = NULL;
+
+
+static int winGlobalSetMutex(const char* name)
+{
+ if (win_singleintance)
+ ReleaseMutex(win_singleintance);
+
+ /* try to create a mutex (will fail if already one of that name) */
+ win_singleintance = CreateMutex(NULL, FALSE, name);
+
+ /* Return TRUE if existing semaphore opened */
+ if (win_singleintance != NULL && GetLastError()==ERROR_ALREADY_EXISTS)
+ {
+ CloseHandle(win_singleintance);
+ return 1;
+ }
+
+ /* wasn’t found, new one created therefore return FALSE */
+ return (win_singleintance == NULL);
+}
+
+static BOOL CALLBACK winGlobalEnumWindowProc(HWND hWnd, LPARAM lParam)
+{
+ char* name = (char*)lParam;
+ char str[256];
+ int len = GetWindowText(hWnd, str, 256);
+ if (len)
+ {
+ if (iupStrEqualPartial(str, name))
+ {
+ win_findwindow = hWnd;
+ return FALSE;
+ }
+ }
+
+ return TRUE; /* continue searching */
+}
+
+static HWND winGlobalFindWindow(const char* name)
+{
+ win_findwindow = NULL;
+ EnumWindows(winGlobalEnumWindowProc, (LPARAM)name);
+ return win_findwindow;
+}
+
+static void winGlobalFindInstance(const char* name)
+{
+ HWND hWnd = winGlobalFindWindow(name);
+ if (hWnd)
+ {
+ LPTSTR cmdLine = GetCommandLine();
+
+ SetForegroundWindow(hWnd);
+
+ /* Command line is not empty. Send it to the first instance. */
+ if (strlen(cmdLine) != 0)
+ {
+ COPYDATASTRUCT cds;
+ cds.dwData = (ULONG_PTR)"IUP_DATA";
+ cds.cbData = strlen(cmdLine)+1;
+ cds.lpData = cmdLine;
+ SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM)&cds);
+ }
+ }
+}
+
static void winGlobalSendKey(int key, int press)
{
unsigned int keyval, state;
@@ -103,7 +171,7 @@ static void winGlobalSendKey(int key, int press)
}
}
-static BOOL CALLBACK winMonitorInfoEnum(HMONITOR handle, HDC handle_dc, LPRECT rect, LPARAM data)
+static BOOL CALLBACK winGlobalMonitorInfoEnum(HMONITOR handle, HDC handle_dc, LPRECT rect, LPARAM data)
{
RECT* monitors_rect = (RECT*)data;
monitors_rect[win_monitor_index] = *rect;
@@ -153,6 +221,16 @@ int iupdrvSetGlobal(const char *name, const char *value)
iupwin_dll_hinstance = (HINSTANCE)value;
return 0;
}
+ if (iupStrEqual(name, "SINGLEINSTANCE"))
+ {
+ if (winGlobalSetMutex(value))
+ {
+ winGlobalFindInstance(value);
+ return 0; /* don't save the attribute, mutex already exist */
+ }
+ else
+ return 1; /* save the attribute, this is the first instance */
+ }
return 1;
}
@@ -230,7 +308,7 @@ char *iupdrvGetGlobal(const char *name)
char* pstr = str;
win_monitor_index = 0;
- EnumDisplayMonitors(NULL, NULL, winMonitorInfoEnum, (LPARAM)monitors_rect);
+ EnumDisplayMonitors(NULL, NULL, winGlobalMonitorInfoEnum, (LPARAM)monitors_rect);
for (i=0; i < monitors_count; i++)
pstr += sprintf(pstr, "%d %d %d %d\n", (int)monitors_rect[i].left, (int)monitors_rect[i].top, (int)(monitors_rect[i].right-monitors_rect[i].left), (int)(monitors_rect[i].bottom-monitors_rect[i].top));
@@ -245,6 +323,8 @@ char *iupdrvGetGlobal(const char *name)
return "NO";
}
if (iupStrEqual(name, "DLL_HINSTANCE"))
+ {
return (char*)iupwin_dll_hinstance;
+ }
return NULL;
}
diff --git a/iup/src/win/iupwin_loop.c b/iup/src/win/iupwin_loop.c
index fd25537..4bcf38c 100755
--- a/iup/src/win/iupwin_loop.c
+++ b/iup/src/win/iupwin_loop.c
@@ -30,6 +30,19 @@ void iupdrvSetIdleFunction(Icallback f)
win_idle_cb = (IFidle)f;
}
+static int winLoopCallIdle(void)
+{
+ int ret = win_idle_cb();
+ if (ret == IUP_CLOSE)
+ {
+ win_idle_cb = NULL;
+ return IUP_CLOSE;
+ }
+ if (ret == IUP_IGNORE)
+ win_idle_cb = NULL;
+ return ret;
+}
+
void IupExitLoop(void)
{
PostQuitMessage(0);
@@ -74,15 +87,11 @@ int IupMainLoop(void)
}
else
{
- int ret = win_idle_cb();
- if (ret == IUP_CLOSE)
+ if (winLoopCallIdle() == IUP_CLOSE)
{
- win_idle_cb = NULL;
win_main_loop--;
return IUP_CLOSE;
}
- if (ret == IUP_IGNORE)
- win_idle_cb = NULL;
}
}
else
@@ -123,6 +132,8 @@ int IupLoopStep(void)
MSG msg;
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
return winLoopProcessMessage(&msg);
+ else if (win_idle_cb)
+ return winLoopCallIdle();
return IUP_DEFAULT;
}
diff --git a/iup/src/win/iupwin_tree.c b/iup/src/win/iupwin_tree.c
index 4a5f8be..4a8d331 100755
--- a/iup/src/win/iupwin_tree.c
+++ b/iup/src/win/iupwin_tree.c
@@ -3,7 +3,6 @@
*
* See Copyright Notice in iup.h
*/
-
#undef NOTREEVIEW
#include <windows.h>
#include <commctrl.h>
@@ -85,16 +84,6 @@ static HTREEITEM winTreeFindNodeXY(Ihandle* ih, int x, int y)
return (HTREEITEM)SendMessage(ih->handle, TVM_HITTEST, 0, (LPARAM)(LPTVHITTESTINFO)&info);
}
-static HTREEITEM winTreeFindNodePointed(Ihandle* ih)
-{
- TVHITTESTINFO info;
- DWORD pos = GetMessagePos();
- info.pt.x = LOWORD(pos);
- info.pt.y = HIWORD(pos);
- ScreenToClient(ih->handle, &info.pt);
- return (HTREEITEM)SendMessage(ih->handle, TVM_HITTEST, 0, (LPARAM)(LPTVHITTESTINFO)&info);
-}
-
int iupwinGetColor(const char* value, COLORREF *color)
{
unsigned char r, g, b;
@@ -381,7 +370,7 @@ static void winTreeSelectRange(Ihandle* ih, HTREEITEM hItem1, HTREEITEM hItem2,
int i;
int id1 = iupTreeFindNodeId(ih, hItem1);
int id2 = iupTreeFindNodeId(ih, hItem2);
- if (id2 == -1) id2 = ih->data->node_count-1;
+
if (id1 > id2)
{
int tmp = id1;
@@ -403,13 +392,19 @@ static void winTreeSelectRange(Ihandle* ih, HTREEITEM hItem1, HTREEITEM hItem2,
static void winTreeSelectAll(Ihandle* ih)
{
- HTREEITEM hItemRoot = (HTREEITEM)SendMessage(ih->handle, TVM_GETNEXTITEM, TVGN_ROOT, 0);
- winTreeSelectRange(ih, hItemRoot, NULL, 0);
+ int i;
+ for (i = 0; i < ih->data->node_count; i++)
+ winTreeSelectNode(ih, ih->data->node_cache[i].node_handle, 1);
}
static void winTreeClearSelection(Ihandle* ih, HTREEITEM hItemExcept)
{
- winTreeSelectRange(ih, hItemExcept, hItemExcept, 1);
+ int i;
+ for (i = 0; i < ih->data->node_count; i++)
+ {
+ if (ih->data->node_cache[i].node_handle != hItemExcept)
+ winTreeSelectNode(ih, ih->data->node_cache[i].node_handle, 0);
+ }
}
static int winTreeInvertSelectFunc(Ihandle* ih, HTREEITEM hItem, int id, void* userdata)
@@ -1507,7 +1502,7 @@ static int winTreeSetDelNodeAttrib(Ihandle* ih, const char* name_id, const char*
iupAttribSetStr(ih, "_IUPTREE_IGNORE_SELECTION_CB", "1");
hItemFocus = iupdrvTreeGetFocusNode(ih);
- for(i = 1; i < ih->data->node_count; /* increment only if not removed */)
+ for(i = 0; i < ih->data->node_count; /* increment only if not removed */)
{
if (winTreeIsNodeSelected(ih, ih->data->node_cache[i].node_handle))
{
@@ -2009,6 +2004,17 @@ static int winTreeMouseMultiSelect(Ihandle* ih, int x, int y)
return 0;
}
+static void winTreeCallRightClickCb(Ihandle* ih, int x, int y)
+{
+ HTREEITEM hItem = winTreeFindNodeXY(ih, x, y);
+ if (hItem)
+ {
+ IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
+ if (cbRightClick)
+ cbRightClick(ih, iupTreeFindNodeId(ih, hItem));
+ }
+}
+
static int winTreeProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
switch (msg)
@@ -2150,8 +2156,11 @@ static int winTreeProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *res
}
}
break;
- case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
+ winTreeCallRightClickCb(ih, (int)(short)LOWORD(lp), (int)(short)HIWORD(lp));
+ *result = 0;
+ return 1; /* must abort the normal behavior, because it is weird and just causes trouble */
+ case WM_MBUTTONDOWN:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
@@ -2366,13 +2375,6 @@ static int winTreeWmNotify(Ihandle* ih, NMHDR* msg_info, int *result)
return 1;
}
}
- else if(msg_info->code == NM_RCLICK)
- {
- HTREEITEM hItem = winTreeFindNodePointed(ih);
- IFni cbRightClick = (IFni)IupGetCallback(ih, "RIGHTCLICK_CB");
- if (cbRightClick)
- cbRightClick(ih, iupTreeFindNodeId(ih, hItem));
- }
else if (msg_info->code == NM_CUSTOMDRAW)
{
NMTVCUSTOMDRAW *customdraw = (NMTVCUSTOMDRAW*)msg_info;