2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
8 #include <AutoLocker.h>
10 #include "SubWindowManager.h"
13 // #pragma mark - SubWindowKey
16 SubWindowKey::~SubWindowKey()
21 // #pragma mark - ObjectSubWindowKey
24 ObjectSubWindowKey::ObjectSubWindowKey(void* object
)
32 ObjectSubWindowKey::Equals(const SubWindowKey
* other
) const
37 const ObjectSubWindowKey
* key
38 = dynamic_cast<const ObjectSubWindowKey
*>(other
);
39 return key
!= NULL
&& fObject
== key
->fObject
;
44 ObjectSubWindowKey::HashCode() const
46 return (size_t)(addr_t
)fObject
;
50 // #pragma mark - SubWindow
53 SubWindow::SubWindow(SubWindowManager
* manager
, BRect frame
, const char* title
,
54 window_type type
, uint32 flags
, uint32 workspace
)
56 BWindow(frame
, title
, type
, flags
, workspace
),
57 fSubWindowManager(manager
),
61 fSubWindowManager
->AcquireReference();
65 SubWindow::~SubWindow()
67 RemoveFromSubWindowManager();
68 fSubWindowManager
->ReleaseReference();
73 SubWindow::AddToSubWindowManager(SubWindowKey
* key
)
75 AutoLocker
<SubWindowManager
> locker(fSubWindowManager
);
79 if (!fSubWindowManager
->AddSubWindow(this)) {
89 SubWindow::RemoveFromSubWindowManager()
91 if (fSubWindowKey
== NULL
)
94 fSubWindowManager
->RemoveSubWindow(this);