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
Line 
1/* $Id: win32wndchild.cpp,v 1.8 2004-04-20 10:11:44 sandervl Exp $ */
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>
13#include "win32wndchild.h"
14#include <misc.h>
15
16#define DBG_LOCALLOG DBG_win32wndchild
17#include "dbglocal.h"
18
19//******************************************************************************
20//******************************************************************************
21ChildWindow::ChildWindow(VMutex *pLock)
22{
23 parent = 0;
24 nextchild = 0;
25 children = 0;
26 pLockChild = pLock;
27}
28//******************************************************************************
29//******************************************************************************
30ChildWindow::~ChildWindow()
31{
32 if(parent) {
33 parent->removeChild(this);
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//******************************************************************************
46BOOL ChildWindow::addChild(ChildWindow *child)
47{
48 ChildWindow *curchild;
49
50 Lock();
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
64 Unlock();
65 return TRUE;
66}
67//******************************************************************************
68//Remove child from linked list. Doesn't delete it!
69//******************************************************************************
70BOOL ChildWindow::removeChild(ChildWindow *child)
71{
72 ChildWindow *curchild = children;
73
74 Lock();
75
76 if(curchild == child) {
77 children = child->getNextChild();
78 }
79 else {
80 if(curchild == NULL) {
81 dprintf(("ChildWindow::RemoveChild, children == NULL"));
82 DebugInt3();
83 Unlock();
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();
91 Unlock();
92 return FALSE;
93 }
94 }
95 curchild->setNextChild(child->getNextChild());
96 }
97 Unlock();
98 return TRUE;
99}
100//******************************************************************************
101//******************************************************************************
102BOOL ChildWindow::destroyChildren()
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.