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