fltk::StringArray Class Reference

Inherits fltk::StringList.

List of all members.

Public Member Functions

void set (const char *s)
void set (const char *const *a)
void set (const char *const *a, int n)

Detailed Description

This subclass of List allows a Menu or Browser to display an array of const C strings. The array is given to the constructor of can be changed with set(). Using this is much more efficient than adding an Item() to the menu.

  const char* names[] = {"alpha", "beta", "gamma"};
  StringArray* list = new StringList(names,3);
  // Identical result can be made with this:
  // StringArray* list = new StringList("alpha\0beta\0gamma\0");

Member Function Documentation

void StringArray::set ( const char *const *  array)

Make it return labels from array, where the size of the array is determined by the first null pointer in it. The array and strings are not copied, they should be in static memory! If array is null then children is set to zero.

void StringArray::set ( const char *const *  array,
int  n 
) [inline]

Make it return n labels from array. The array and strings are not copied, they should be in static memory!

void StringArray::set ( const char *  s)

Sets the list to return each substring in the nul-seperated string. The list is terminated by two nul characters. If the string is null then children is set ot zero.

Warning: the string is not copied!

The current implementation leaks the created array when the StringList is deleted or if set() is called again. This really should be a subclass with a destructor, but I can't figure out a good name for it...

The documentation for this class was generated from the following files: