wxList examples.
wxWidgets 2.6.1
colltest2.cpp
///////////////////////////////////////////////////////////////////////////////
// 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 _COLLECTIONTEST2H__
#define _COLLECTIONTEST2H__
#include <wx/string.h>
#include <wx/list.h>
class MyExListElement : public wxObject {
private:
int b;
public:
MyExListElement(int a) { b=a; }
virtual ~MyExListElement(){}
int get() { return b; }
};
class CollectionTest2 {
private:
wxList list;
public:
CollectionTest2(){}
virtual ~CollectionTest2(){
list.DeleteContents(true);
}
wxString *doIt();
};
#endif
colltest2.h
#include "colltest2.h"
wxString *CollectionTest2::doIt(){
MyExListElement *element = new MyExListElement(10);
list.Append(element);
wxString s;
wxString *str = new wxString("");
str->Append("BEGIN").Append("\n");
for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ){
MyExListElement *current = (MyExListElement *)node->GetData();
s.sprintf("%d",current->get());
str->Append( s ).Append("\n");
}
str->Append("END");
return str;
}