///////////////////////////////////////////////////////////////////////////////
// Name:        CollectionTest
// Purpose:     excercise wxList and wxString
// Author:      PyoungGwan Chun
// Modified by:
// Created:     27/06/2008
// RCS-ID:      $Id: colltest.h,v 1.000 2008/06/27 14:57:09 MBN Exp $
// Copyright:   (c) 2008 PyoungGwan Chun <stekilove@gmail.com>
// Licence:     GNU licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _COLLECTIONTESTH__
#define _COLLECTIONTESTH__

#include <wx/string.h>
#include <wx/list.h>

class MyListElement {
private:
    int b;
public:
    MyListElement(int a) { b=a; }
    int get() { return b; }
};

WX_DECLARE_LIST(MyListElement, MyList);


#include <wx/listimpl.cpp>
WX_DEFINE_LIST(MyList);

class CollectionTest {
private:
         MyList list;

public:      
      CollectionTest(){}
      virtual ~CollectionTest(){
              list.DeleteContents(true);
      }
        
      wxString *doIt(){
            MyListElement *element = new MyListElement(10);
            list.Append(element);
            
            wxString s;
            wxString *str = new wxString("");
            str->Append("BEGIN").Append("\n");
            
            for ( MyList::Node *node = list.GetFirst(); node; node = node->GetNext() ){
                MyListElement *current = node->GetData();
                
                s.sprintf("%d",current->get());
                str->Append( s ).Append("\n");
            }
            
            str->Append("END");
            return str;
        }
};      


#endif

Posted by stekilove
,