source: trunk/src/user32/win32wndchild.cpp@ 2803

Last change on this file since 2803 was 2803, checked in by sandervl, 26 years ago

Added new logging feature

File size: 2.9 KB
Line 
1/* $Id: win32wndchild.cpp,v 1.5 2000-02-16 14:28:25 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()
22{
23 parent = 0;
24 nextchild = 0;
25 children = 0;
26}
27//******************************************************************************
28//******************************************************************************
29ChildWindow::~ChildWindow()
30{
31 if(parent) {
32 parent->RemoveChild(this);
33 }
34//SvL: PM sends WM_DESTROY for all the children
35#if 0
36 if(children != 0) {
37 dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
38 DestroyChildren();
39 }
40#endif
41}
42//******************************************************************************
43//FIFO insertion
44//******************************************************************************
45BOOL ChildWindow::AddChild(ChildWindow *child)
46{
47 ChildWindow *curchild;
48
49 mutex.enter();
50
51 curchild = children;
52 if(curchild == NULL) {
53 children = child;
54 }
55 else {
56 while(curchild->getNextChild()) {
57 curchild = curchild->getNextChild();
58 }
59 curchild->setNextChild(child);
60 }
61 child->setNextChild(NULL);
62
63 mutex.leave();
64 return TRUE;
65}
66//******************************************************************************
67//Remove child from linked list. Doesn't delete it!
68//******************************************************************************
69BOOL ChildWindow::RemoveChild(ChildWindow *child)
70{
71 ChildWindow *curchild = children;
72
73 mutex.enter();
74
75 if(curchild == child) {
76 children = child->getNextChild();
77 }
78 else {
79 if(curchild == NULL) {
80 dprintf(("ChildWindow::RemoveChild, children == NULL"));
81 DebugInt3();
82 mutex.leave();
83 return FALSE;
84 }
85 while(curchild->getNextChild() != child) {
86 curchild = curchild->getNextChild();
87 if(curchild == NULL) {
88 dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
89 DebugInt3();
90 mutex.leave();
91 return FALSE;
92 }
93 }
94 curchild->setNextChild(child->getNextChild());
95 }
96 mutex.leave();
97 return TRUE;
98}
99//******************************************************************************
100//******************************************************************************
101BOOL ChildWindow::DestroyChildren()
102{
103 while(children) {
104 delete children; //child dtor removes itself from the linked list
105 }
106 return TRUE;
107}
108//******************************************************************************
109//******************************************************************************
Note: See TracBrowser for help on using the repository browser.