source: trunk/src/user32/win32wndchild.cpp

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 2.9 KB
RevLine 
[10587]1/* $Id: win32wndchild.cpp,v 1.8 2004-04-20 10:11:44 sandervl Exp $ */
[2469]2/*
3 * Win32 Child/Parent window class for OS/2
4 *
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#include <os2win.h>
[21916]13#include "win32wndchild.h"
[2469]14#include <misc.h>
15
[2803]16#define DBG_LOCALLOG DBG_win32wndchild
17#include "dbglocal.h"
18
[2469]19//******************************************************************************
20//******************************************************************************
[10587]21ChildWindow::ChildWindow(VMutex *pLock)
[2469]22{
[5935]23 parent = 0;
24 nextchild = 0;
25 children = 0;
26 pLockChild = pLock;
[2469]27}
28//******************************************************************************
29//******************************************************************************
30ChildWindow::~ChildWindow()
31{
32 if(parent) {
[3663]33 parent->removeChild(this);
[2469]34 }
35//SvL: PM sends WM_DESTROY for all the children
36#if 0
37 if(children != 0) {
38 dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
39 DestroyChildren();
40 }
41#endif
42}
43//******************************************************************************
44//FIFO insertion
45//******************************************************************************
[3663]46BOOL ChildWindow::addChild(ChildWindow *child)
[2469]47{
48 ChildWindow *curchild;
49
[5935]50 Lock();
[2469]51
52 curchild = children;
53 if(curchild == NULL) {
54 children = child;
55 }
56 else {
57 while(curchild->getNextChild()) {
58 curchild = curchild->getNextChild();
59 }
60 curchild->setNextChild(child);
61 }
62 child->setNextChild(NULL);
63
[5935]64 Unlock();
[2469]65 return TRUE;
66}
67//******************************************************************************
68//Remove child from linked list. Doesn't delete it!
69//******************************************************************************
[3663]70BOOL ChildWindow::removeChild(ChildWindow *child)
[2469]71{
72 ChildWindow *curchild = children;
73
[5935]74 Lock();
[2469]75
76 if(curchild == child) {
77 children = child->getNextChild();
78 }
79 else {
80 if(curchild == NULL) {
81 dprintf(("ChildWindow::RemoveChild, children == NULL"));
82 DebugInt3();
[5935]83 Unlock();
[2469]84 return FALSE;
85 }
86 while(curchild->getNextChild() != child) {
87 curchild = curchild->getNextChild();
88 if(curchild == NULL) {
89 dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
90 DebugInt3();
[5935]91 Unlock();
[2469]92 return FALSE;
93 }
94 }
95 curchild->setNextChild(child->getNextChild());
96 }
[5935]97 Unlock();
[2469]98 return TRUE;
99}
100//******************************************************************************
101//******************************************************************************
[3663]102BOOL ChildWindow::destroyChildren()
[2469]103{
104 while(children) {
105 delete children; //child dtor removes itself from the linked list
106 }
107 return TRUE;
108}
109//******************************************************************************
110//******************************************************************************
Note: See TracBrowser for help on using the repository browser.