
/* getictext.c
 *
 * Wimp function library
 *  Joseph Heenan, 1998.
 *
 *
 *
 *
 * $Log: getictext,v $
 * Revision 1.2  1998/05/10 20:13:10  jogu
 * Added names to file headers
 * Added implicit cast for frontend_taskname to wimp_report_error
 *   (it defines 'name' without 'const')
 *
 * Revision 1.1.1.1  1998/05/10 19:56:03  jogu
 * WimpCLib V1.00 (created from newshound c.wimpc rev 1.2)
 *
 *
 */

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include "swis.h"
#include "wimplib.h"

#include "wimpclib.h"


char *wimpc_geticontext( int win, int icon )
{
  WimpGetIconStateBlock block;
  const int flags = WimpIcon_Text | WimpIcon_Indirected;
  char *ptr;

  block.window_handle = win;
  block.icon_handle   = icon;
  wimp_get_icon_state( &block );

  if ( (block.icon.flags & flags) != flags )
  {
    E_REPORT( "Icon is not a text icon or is not indirected" );
    return NULL;
  }

  ptr = block.icon.data.it.buffer;
  while ( *ptr >= 32 ) ptr++;
  *ptr=0; /* make sure string is null terminated, not \n or anything silly */

  return block.icon.data.it.buffer;
}
