home *** CD-ROM | disk | FTP | other *** search
- #include "Wimp.h"
- #include "WimpSWIs.h"
-
- #include <stdio.h>
- #include "string.h"
-
-
- extern void Icon_SetDouble(window_handle w, icon_handle i,
- double value, int decimalplaces)
- /*
- * Sets the given icon's text to hold the number in "value". (and redraws icon)
- * After the decimal place, up to "decimalplaces" digits will be printed
- * If the number is too big (too many digits), it will be truncated to fit
- * (which may completely destroy the value you wished to represent, or
- * just reduce its accuracy)
- * If unable to set the text (incorrect icon type), it returns quietly
- */
- {
- icon_block istate;
- char temp[32], format[16];
-
- Wimp_GetIconState(w, i, &istate);
- if (istate.flags.value & (icon_TEXT | icon_INDIRECTED))
- {
- /* Indirected text icon, so set text field - ensure no buffer overflow */
- sprintf(format, "%%.%df", decimalplaces);
- sprintf(temp, format, value);
- strncpy(istate.data.indirecttext.buffer, temp,
- istate.data.indirecttext.bufflen - 1);
- istate.data.indirecttext.buffer[istate.data.indirecttext.bufflen-1] = 0;
-
- Wimp_SetIconState(w, i, 0, 0);
- }
- }
-