summaryrefslogtreecommitdiff
path: root/iup/src/iup_dialog.c
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-09-09 02:26:30 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-09-09 02:32:26 +0200
commit7505e88db66798b2b8fcdff2d92a7136cd826b5b (patch)
treeb6ced565318f8e8112e35cb0ad53abe4212ef8de /iup/src/iup_dialog.c
parente9a184546b18cf3b796bd560561f312934004c54 (diff)
Upgrading to IUP 3.2 - and cleaning up.
Diffstat (limited to 'iup/src/iup_dialog.c')
-rwxr-xr-xiup/src/iup_dialog.c54
1 files changed, 52 insertions, 2 deletions
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 */