home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Icon.GetText.c
- Author: Copyright © 1992, 1993 Jason Williams
- Version: 1.00 (14 Jul 1993)
- Purpose: Retrieves the text/spritename from an icon
- */
-
- #include "DeskLib:Wimp.h"
- #include "DeskLib:WimpSWIs.h"
- #include "DeskLib:Icon.h"
-
- #include <string.h>
-
-
- extern void Icon_GetText(window_handle w, icon_handle i, char *text)
- /*
- * Copies the text string from the icon (sprite name, text, or indirected)
- * into the array pointed to by "text"
- */
- {
- icon_block istate;
- char *buffer;
- int len = wimp_MAXNAME;
-
- text[0] = 0; /* return NULL string if anything goes wrong */
-
- Wimp_GetIconState(w, i, &istate);
- if (istate.flags.data.indirected)
- {
- if (istate.flags.data.text)
- {
- buffer = istate.data.indirecttext.buffer;
- len = istate.data.indirecttext.bufflen;
- }
- else
- if (istate.flags.data.sprite)
- buffer = (char *) istate.data.indirectsprite.name;
- }
- else
- buffer = istate.data.text; /* text/sprite name */
-
- strncpy(text, buffer, len); /* text/sprite name */
- text[len] = 0;
- }
-