Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TextAreaItem Class Reference

#include <text_area.h>

Public Member Functions

 TextAreaItem (const char *new_name="blank", const char *desc="", TextAreaItem *parent_class=0)
 
 ~TextAreaItem (void)
 
TextAreaItemFindChild (const char *search_name)
 
TextAreaItemFindCount (int count, int cur)
 
void AddChild (const char *new_name, const char *desc, const GFXColor col=GFXColor(1, 1, 1, 1))
 
void ExpandTree (void)
 
void Sort (void)
 

Public Attributes

GFXColor col
 
char * name
 
char * description
 
int child_count_multiplier
 
int child_count
 
TextAreaItem ** child
 
TextAreaItemparent
 

Detailed Description

Definition at line 220 of file text_area.h.

Constructor & Destructor Documentation

TextAreaItem::TextAreaItem ( const char *  new_name = "blank",
const char *  desc = "",
TextAreaItem parent_class = 0 
)

Definition at line 579 of file text_area.cpp.

References child, child_count, child_count_multiplier, description, and name.

Referenced by AddChild().

579  :
580  col( 1, 1, 1, 1 )
581 {
582 //{ col = GFXColor (rnd,rnd,rnd,1);
583  if (new_name != 0) name = strdup( new_name );
584 
585  else name = 0;
586  if (desc != 0) description = strdup( desc );
587 
588  else description = 0;
590  child_count = 0;
591  child = NULL;
592  parent = NULL;
593 //if (parent == NULL) { expanded = 1; }
594 }
TextAreaItem::~TextAreaItem ( void  )

Definition at line 596 of file text_area.cpp.

References child, child_count, description, and name.

597 {
598  int cur = 0;
599  if (name != NULL) free( name );
600  if (description != NULL) free( description ); //if there are no children, it won't run through this for
601  for (cur = 0; cur < child_count; cur++)
602  if (child[cur] != NULL) delete child[cur];
603  if (child != NULL) delete child;
604 }

Member Function Documentation

void TextAreaItem::AddChild ( const char *  new_name,
const char *  desc,
const GFXColor  col = GFXColor( 1, 1, 1, 1 ) 
)

Definition at line 651 of file text_area.cpp.

References child, child_count, child_count_multiplier, col, and TextAreaItem().

Referenced by TextArea::AddTextItem().

652 {
653  TextAreaItem **newlist;
654  int cur = 0;
655  child_count++;
658  newlist = new TextAreaItemStr[child_count_multiplier*10];
659  if (child != NULL) {
660  for (cur = 0; cur < child_count-1; cur++)
661  newlist[cur] = child[cur];
662  delete child;
663  }
664  child = newlist;
665  }
666  child[child_count-1] = new TextAreaItem( new_name, desc, NULL );
667  child[child_count-1]->col = col;
668 }
void TextAreaItem::ExpandTree ( void  )
TextAreaItem * TextAreaItem::FindChild ( const char *  search_name)

Definition at line 606 of file text_area.cpp.

References child, child_count, FindChild(), and name.

Referenced by TextArea::AddTextItem(), TextArea::ChangeTextItem(), TextArea::ChangeTextItemColor(), and FindChild().

607 {
608  int cur = 0;
609  //int max = child_count_multiplier * 10;
610  TextAreaItem *match;
611  if (search_name == NULL) return this;
612  if (strcmp( name, search_name ) == 0) return this;
613  for (cur = 0; cur < child_count; cur++) {
614  match = child[cur]->FindChild( search_name );
615  if (match != NULL) return match;
616  }
617  return NULL;
618 }
TextAreaItem * TextAreaItem::FindCount ( int  count,
int  cur 
)

Definition at line 635 of file text_area.cpp.

References child, child_count, and FindCount().

Referenced by FindCount().

636 {
637  static int current = 0;
638  if (cur == 0) current = 0; //int max = child_count_multiplier * 10;
639  TextAreaItem *match;
640  if (count == current) return this;
641  current++;
642  for (cur = 0; cur < child_count; cur++) {
643  match = child[cur]->FindCount( count, cur+1 );
644  if (match != NULL) return match;
645  }
646  return NULL;
647 }
void TextAreaItem::Sort ( void  )

Definition at line 620 of file text_area.cpp.

References child, child_count, description, and Sort().

Referenced by Sort(), and TextArea::SortList().

621 {
622  int cur, cur2;
623  TextAreaItem *temp;
624  for (cur = 0; cur < child_count; cur++) {
625  child[cur]->Sort();
626  for (cur2 = 0; cur2 < child_count-1; cur2++)
627  if (strcmp( child[cur2]->description, child[cur2+1]->description ) > 0) {
628  temp = child[cur2];
629  child[cur2] = child[cur2+1];
630  child[cur2+1] = temp;
631  }
632  }
633 }

Member Data Documentation

TextAreaItem** TextAreaItem::child

Definition at line 243 of file text_area.h.

Referenced by AddChild(), FindChild(), FindCount(), Sort(), TextAreaItem(), and ~TextAreaItem().

int TextAreaItem::child_count

Definition at line 242 of file text_area.h.

Referenced by AddChild(), FindChild(), FindCount(), Sort(), TextAreaItem(), and ~TextAreaItem().

int TextAreaItem::child_count_multiplier

Definition at line 241 of file text_area.h.

Referenced by AddChild(), and TextAreaItem().

GFXColor TextAreaItem::col

Definition at line 236 of file text_area.h.

Referenced by AddChild(), and TextArea::ChangeTextItemColor().

char* TextAreaItem::description

Definition at line 238 of file text_area.h.

Referenced by TextArea::ChangeTextItem(), Sort(), TextAreaItem(), and ~TextAreaItem().

char* TextAreaItem::name

Definition at line 237 of file text_area.h.

Referenced by FindChild(), TextAreaItem(), and ~TextAreaItem().

TextAreaItem* TextAreaItem::parent

Definition at line 245 of file text_area.h.


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