
/* menuread.c
 *
 * Wimp function library
 *  Joseph Heenan, 1998.
 *
 * This function will read the text of one menu entry from a WimpMenu block.
 * Note, returns a pointer to the string inside the wimpmenu block -
 * changing it will change the menu
 *
 * $Log: menuread,v $
 * Revision 1.1  1998/06/06 21:49:56  joseph
 * menuread and menufade added
 * createmenu changed to allow raw mode and seperator to be specified
 *
 *
 */

#include <stdlib.h>

#include "wimplib.h"

#include "wimpclib.h"


char *wimpc_menuread( WimpMenu *menu, int item )
{
  int loop = 0;

  do
  {
    if ( item == loop )
    {
      int flags = menu->items[item].icon_flags;
      if ( !( flags & (WimpIcon_Sprite | WimpIcon_Text) ) || menu->items[item].icon_data.it.buffer_size==0 )
        return NULL;
      if ( flags & WimpIcon_Indirected )
        return menu->items[item].icon_data.it.buffer;

      return menu->items[item].icon_data.t;
    }
  }
  while ( ! (menu->items[loop++].flags & WimpMenuItem_Last) );

  return NULL;
}

