From 7505e88db66798b2b8fcdff2d92a7136cd826b5b Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 9 Sep 2010 02:26:30 +0200 Subject: Upgrading to IUP 3.2 - and cleaning up. --- iup/src/iup_dialog.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'iup/src/iup_dialog.c') 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 */ -- cgit v1.2.3