Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

win32wndchild.cpp

Go to the documentation of this file.
00001 /* $Id: win32wndchild.cpp,v 1.7 2001/06/09 14:50:24 sandervl Exp $ */
00002 /*
00003  * Win32 Child/Parent window class for OS/2
00004  *
00005  *
00006  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
00007  *
00008  *
00009  * Project Odin Software License can be found in LICENSE.TXT
00010  *
00011  */
00012 #include <os2win.h>
00013 #include <win32wndchild.h>
00014 #include <misc.h>
00015 
00016 #define DBG_LOCALLOG    DBG_win32wndchild
00017 #include "dbglocal.h"
00018 
00019 //******************************************************************************
00020 //******************************************************************************
00021 ChildWindow::ChildWindow(CRITICAL_SECTION *pLock) 
00022 {
00023   parent     = 0;
00024   nextchild  = 0;
00025   children   = 0;
00026   pLockChild = pLock;
00027 }
00028 //******************************************************************************
00029 //******************************************************************************
00030 ChildWindow::~ChildWindow()
00031 {
00032   if(parent) {
00033         parent->removeChild(this);
00034   }
00035 //SvL: PM sends WM_DESTROY for all the children
00036 #if 0
00037   if(children != 0) {
00038         dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
00039         DestroyChildren();
00040   }
00041 #endif
00042 }
00043 //******************************************************************************
00044 //FIFO insertion
00045 //******************************************************************************
00046 BOOL ChildWindow::addChild(ChildWindow *child)
00047 {
00048  ChildWindow *curchild;
00049 
00050    Lock();
00051 
00052    curchild = children;
00053    if(curchild == NULL) {
00054         children = child;
00055    }
00056    else {
00057         while(curchild->getNextChild()) {
00058                 curchild = curchild->getNextChild();
00059         }
00060         curchild->setNextChild(child);
00061    }
00062    child->setNextChild(NULL);
00063 
00064    Unlock();
00065    return TRUE;
00066 }
00067 //******************************************************************************
00068 //Remove child from linked list. Doesn't delete it!
00069 //******************************************************************************
00070 BOOL ChildWindow::removeChild(ChildWindow *child)
00071 {
00072  ChildWindow *curchild = children;
00073 
00074    Lock();
00075 
00076    if(curchild == child) {
00077         children = child->getNextChild();       
00078    }
00079    else {
00080         if(curchild == NULL) {
00081                 dprintf(("ChildWindow::RemoveChild, children == NULL"));
00082                 DebugInt3();
00083                 Unlock();
00084                 return FALSE;
00085         }
00086         while(curchild->getNextChild() != child) {
00087                 curchild = curchild->getNextChild();
00088                 if(curchild == NULL) {
00089                         dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
00090                         DebugInt3();
00091                         Unlock();
00092                         return FALSE;
00093                 }       
00094         }
00095         curchild->setNextChild(child->getNextChild());
00096    }
00097    Unlock();
00098    return TRUE;
00099 }
00100 //******************************************************************************
00101 //******************************************************************************
00102 BOOL ChildWindow::destroyChildren()
00103 {
00104    while(children) {
00105         delete children;        //child dtor removes itself from the linked list
00106    }
00107    return TRUE;
00108 }
00109 //******************************************************************************
00110 //******************************************************************************

Generated on Wed Jan 23 23:17:49 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001