1 | /* $Id: win32wndchild.cpp,v 1.1 1999-09-15 23:19:02 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 | //******************************************************************************
|
---|
17 | //******************************************************************************
|
---|
18 | ChildWindow::ChildWindow()
|
---|
19 | {
|
---|
20 | parent = 0;
|
---|
21 | nextchild = 0;
|
---|
22 | children = 0;
|
---|
23 | }
|
---|
24 | //******************************************************************************
|
---|
25 | //******************************************************************************
|
---|
26 | ChildWindow::~ChildWindow()
|
---|
27 | {
|
---|
28 | if(parent) {
|
---|
29 | parent->RemoveChild(this);
|
---|
30 | }
|
---|
31 | if(children != 0) {
|
---|
32 | dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
|
---|
33 | DestroyChildren();
|
---|
34 | }
|
---|
35 | }
|
---|
36 | //******************************************************************************
|
---|
37 | //FIFO insertion
|
---|
38 | //******************************************************************************
|
---|
39 | BOOL ChildWindow::AddChild(ChildWindow *child)
|
---|
40 | {
|
---|
41 | ChildWindow *curchild;
|
---|
42 |
|
---|
43 | mutex.enter();
|
---|
44 |
|
---|
45 | curchild = children;
|
---|
46 | if(curchild == NULL) {
|
---|
47 | children = child;
|
---|
48 | }
|
---|
49 | else {
|
---|
50 | while(curchild->getNextChild()) {
|
---|
51 | curchild = curchild->getNextChild();
|
---|
52 | }
|
---|
53 | curchild->setNextChild(child);
|
---|
54 | }
|
---|
55 | child->setNextChild(NULL);
|
---|
56 |
|
---|
57 | mutex.leave();
|
---|
58 | return TRUE;
|
---|
59 | }
|
---|
60 | //******************************************************************************
|
---|
61 | //Remove child from linked list. Doesn't delete it!
|
---|
62 | //******************************************************************************
|
---|
63 | BOOL ChildWindow::RemoveChild(ChildWindow *child)
|
---|
64 | {
|
---|
65 | ChildWindow *curchild = children;
|
---|
66 |
|
---|
67 | mutex.enter();
|
---|
68 |
|
---|
69 | if(curchild == child) {
|
---|
70 | children = child->getNextChild();
|
---|
71 | }
|
---|
72 | else {
|
---|
73 | if(curchild == NULL) {
|
---|
74 | dprintf(("ChildWindow::RemoveChild, children == NULL"));
|
---|
75 | DebugInt3();
|
---|
76 | mutex.leave();
|
---|
77 | return FALSE;
|
---|
78 | }
|
---|
79 | while(curchild->getNextChild() != child) {
|
---|
80 | curchild = curchild->getNextChild();
|
---|
81 | if(curchild == NULL) {
|
---|
82 | dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
|
---|
83 | DebugInt3();
|
---|
84 | mutex.leave();
|
---|
85 | return FALSE;
|
---|
86 | }
|
---|
87 | }
|
---|
88 | curchild->setNextChild(child->getNextChild());
|
---|
89 | }
|
---|
90 | mutex.leave();
|
---|
91 | return TRUE;
|
---|
92 | }
|
---|
93 | //******************************************************************************
|
---|
94 | //******************************************************************************
|
---|
95 | BOOL ChildWindow::DestroyChildren()
|
---|
96 | {
|
---|
97 | while(children) {
|
---|
98 | delete children; //child dtor removes itself from the linked list
|
---|
99 | }
|
---|
100 | return TRUE;
|
---|
101 | }
|
---|
102 | //******************************************************************************
|
---|
103 | //******************************************************************************
|
---|