summaryrefslogtreecommitdiff
path: root/iup/src/iup_attrib.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2010-06-15 00:59:57 -0700
committerPixel <pixel@nobis-crew.org>2010-06-15 00:59:57 -0700
commiteed0eb6a476d54ce19aeff137984aa981d9e3976 (patch)
tree807891636efd2f87dcbd261e971216269973ae07 /iup/src/iup_attrib.c
parentccc8261e4d48de89da4ddfe7b55e378ae0cd6f47 (diff)
Upgrading to iup 3.1
Diffstat (limited to 'iup/src/iup_attrib.c')
-rwxr-xr-xiup/src/iup_attrib.c73
1 files changed, 62 insertions, 11 deletions
diff --git a/iup/src/iup_attrib.c b/iup/src/iup_attrib.c
index 2bbb80a..bf9576e 100755
--- a/iup/src/iup_attrib.c
+++ b/iup/src/iup_attrib.c
@@ -63,7 +63,7 @@ char* IupGetAttributes(Ihandle *ih)
name = iupTableFirst(ih->attrib);
while (name)
{
- if (!iupAttribIsInternal(name))
+ if (!iupATTRIB_ISINTERNAL(name))
{
if (buffer[0] != 0)
strcat(buffer,",");
@@ -115,6 +115,14 @@ void iupAttribUpdateFromParent(Ihandle* ih)
}
}
+static int iAttribIsInherit(Ihandle* ih, const char* name)
+{
+ int inherit;
+ char *def_value;
+ iupClassObjectGetAttributeInfo(ih, name, &def_value, &inherit);
+ return inherit;
+}
+
static void iAttribNotifyChildren(Ihandle *ih, const char* name, const char *value)
{
int inherit;
@@ -123,17 +131,36 @@ static void iAttribNotifyChildren(Ihandle *ih, const char* name, const char *val
{
if (!iupTableGet(child->attrib, name))
{
- /* set on the class */
- iupClassObjectSetAttribute(child, name, value, &inherit);
+ /* set only if an inheritable attribute at the child */
+ if (iAttribIsInherit(child, name))
+ {
+ /* set on the class */
+ iupClassObjectSetAttribute(child, name, value, &inherit);
- if (inherit) /* inherit can be different for the child */
iAttribNotifyChildren(child, name, value);
+ }
}
child = child->brother;
}
}
+void iupAttribUpdateChildren(Ihandle* ih)
+{
+ char *name = iupTableFirst(ih->attrib);
+ while (name)
+ {
+ if (!iupATTRIB_ISINTERNAL(name) && iAttribIsInherit(ih, name))
+ {
+ /* retrieve from the table */
+ char* value = iupTableGet(ih->attrib, name);
+ iAttribNotifyChildren(ih, name, value);
+ }
+
+ name = iupTableNext(ih->attrib);
+ }
+}
+
void iupAttribUpdate(Ihandle* ih)
{
char** name_array;
@@ -159,7 +186,7 @@ void iupAttribUpdate(Ihandle* ih)
for (i = 0; i < count; i++)
{
name = name_array[i];
- if (!iupAttribIsInternal(name))
+ if (!iupATTRIB_ISINTERNAL(name))
{
/* retrieve from the table */
value = iupTableGet(ih->attrib, name);
@@ -196,7 +223,7 @@ void IupSetAttribute(Ihandle *ih, const char* name, const char *value)
if (!iupObjectCheck(ih))
return;
- if (iupAttribIsInternal(name))
+ if (iupATTRIB_ISINTERNAL(name))
iupAttribSetStr(ih, name, value);
else
{
@@ -225,7 +252,7 @@ void IupStoreAttribute(Ihandle *ih, const char* name, const char *value)
if (!iupObjectCheck(ih))
return;
- if (iupAttribIsInternal(name))
+ if (iupATTRIB_ISINTERNAL(name))
iupAttribStoreStr(ih, name, value);
else
{
@@ -257,7 +284,7 @@ char* IupGetAttribute(Ihandle *ih, const char* name)
if (!value)
value = iupAttribGet(ih, name);
- if (!value && !iupAttribIsInternal(name))
+ if (!value && !iupATTRIB_ISINTERNAL(name))
{
if (inherit)
{
@@ -346,6 +373,16 @@ void iupAttribSetHandleName(Ihandle *ih)
IupSetHandle(str_name, ih);
}
+char* iupAttribGetHandleName(Ihandle *ih)
+{
+ char str_name[100];
+ sprintf(str_name, "_IUP_NAME(%p)", ih);
+ if (IupGetHandle(str_name)==ih)
+ return iupStrGetMemoryCopy(str_name);
+ else
+ return NULL;
+}
+
void IupSetAttributeHandle(Ihandle *ih, const char* name, Ihandle *ih_named)
{
int inherit;
@@ -426,7 +463,7 @@ void iupAttribSetInt(Ihandle *ih, const char* name, int num)
void iupAttribSetFloat(Ihandle *ih, const char* name, float num)
{
- iupAttribSetStrf(ih, name, "%f", (double)num);
+ iupAttribSetStrf(ih, name, "%g", (double)num);
}
int iupAttribGetBoolean(Ihandle* ih, const char* name)
@@ -479,7 +516,7 @@ char* iupAttribGetStr(Ihandle* ih, const char* name)
value = iupTableGet(ih->attrib, name);
- if (!value && !iupAttribIsInternal(name))
+ if (!value && !iupATTRIB_ISINTERNAL(name))
{
int inherit;
char *def_value;
@@ -555,6 +592,15 @@ static void iAttribCapture(char* env_buffer, char* dlm)
env_buffer[i-1]='\0'; /* discard delimiter */
}
+static void iAttribSkipComment(void)
+{
+ int c;
+ do
+ {
+ c = *env_str; ++env_str;
+ } while ((c > 0) && (c != '\n'));
+}
+
static int iAttribToken(char* env_buffer)
{
for (;;)
@@ -565,6 +611,11 @@ static int iAttribToken(char* env_buffer)
case 0:
return IUPLEX_TK_END;
+ case '#': /* Skip comment */
+ case '%': /* Skip comment */
+ iAttribSkipComment();
+ continue;
+
case ' ': /* ignore whitespace */
case '\t':
case '\n':
@@ -609,7 +660,7 @@ static void iAttribParse(Ihandle *ih, const char* str)
{
switch (iAttribToken(env_buffer))
{
- case IUPLEX_TK_END: /* procedimento igual ao IUPLEX_TK_COMMA */
+ case IUPLEX_TK_END: /* same as IUPLEX_TK_COMMA */
end = 1;
case IUPLEX_TK_COMMA:
if (name)