1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
//===============================================================
// vThislst.cpp - vThisList class functions - Windows
//
// Copyright (C) 1995,1996, 1997, 1998 Bruce E. Wampler
//
// This file is part of the V C++ GUI Framework, and is covered
// under the terms of the GNU Library General Public License,
// Version 2. This library has NO WARRANTY. See the source file
// vapp.cxx for more complete information about license terms.
//===============================================================
#include <v/vwin32.h> // for Win 32 stuff
#include <v/vthislst.h>
//======================>>> vThisList::vThisList <<<=======================
vThisList::vThisList()
{
// This will keep a list of this pointers accessed by some id
_cur = 0; // empty list
_list = 0;
}
//======================>>> vThisList::~vThisList <<<=======================
vThisList::~vThisList()
{
// This will keep a list of this pointers accessed by some id
thisList* next;
for (thisList* tl = _list ; tl != 0 ; tl = next)
{
next = tl->next; // get next one
delete tl;
}
}
//======================>>> vThisList::Add <<<=======================
void vThisList::Add(ThisId id, void* This)
{
// Add to list
thisList* newList = new thisList;
newList->id = id;
newList->thisPtr = This;
newList->next = _list;
_cur = _list = newList;
}
//======================>>> vThisList::Delete <<<=======================
void vThisList::Delete(ThisId id)
{
// delete from the list
thisList* next, *prev;
prev = 0;
for (thisList* tl = _list ; tl != 0 ; tl = next)
{
next = tl->next;
if (tl->id == id)
{
if (prev == 0)
_list = next;
else
prev->next = next;
delete tl;
_cur = _list; // keep _cur valid
return;
}
prev = tl;
}
}
//======================>>> vThisList::GetThis <<<=======================
void* vThisList::GetThis(ThisId id) VCONST
{
for (thisList* tl = _list ; tl != 0 ; tl = tl->next)
{
if (tl->id == id)
{
_cur = tl; // keep cur valid
return tl->thisPtr;
}
}
return 0;
}
//======================>>> vThisList::GetFirstThis <<<=======================
void* vThisList::GetFirstThis() VCONST
{
_cur = _list; // start at front
if (_cur)
return _cur->thisPtr;
else
return 0;
}
//======================>>> vThisList::GetNextThis <<<=======================
void* vThisList::GetNextThis() VCONST
{
if (_cur)
{
_cur = _cur->next; // point to next entry
if (_cur)
return _cur->thisPtr;
}
return 0;
}
|