* Made the BToolTip interface a bit more convenient to use when subclassing it.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32249 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-11 12:32:12 +00:00
parent 60286ab2f8
commit 5ffbab2aff
3 changed files with 57 additions and 17 deletions

View File

@ -34,6 +34,13 @@ public:
virtual void SetAlignment(BAlignment alignment);
BAlignment Alignment() const;
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
protected:
bool Lock();
void Unlock();
private:
BToolTip(const BToolTip& other);
BToolTip& operator=(const BToolTip &other);
@ -41,6 +48,7 @@ private:
void _InitData();
private:
bool fLockedLooper;
bool fIsSticky;
BPoint fRelativeLocation;
BAlignment fAlignment;

View File

@ -91,6 +91,50 @@ BToolTip::Alignment() const
}
void
BToolTip::AttachedToWindow()
{
}
void
BToolTip::DetachedFromWindow()
{
}
bool
BToolTip::Lock()
{
bool lockedLooper;
while (true) {
lockedLooper = View()->LockLooper();
if (!lockedLooper) {
BToolTipManager::Lock();
if (View()->Window() != NULL) {
BToolTipManager::Unlock();
continue;
}
}
break;
}
fLockedLooper = lockedLooper;
return true;
}
void
BToolTip::Unlock()
{
if (fLockedLooper)
View()->UnlockLooper();
else
BToolTipManager::Unlock();
}
void
BToolTip::_InitData()
{
@ -158,26 +202,12 @@ BTextToolTip::Text() const
void
BTextToolTip::SetText(const char* text)
{
bool lockedLooper;
while (true) {
lockedLooper = fTextView->LockLooper();
if (!lockedLooper) {
BToolTipManager::Lock();
if (fTextView->Window() != NULL) {
BToolTipManager::Unlock();
continue;
}
}
break;
}
if (!Lock())
return;
fTextView->SetText(text);
if (lockedLooper)
fTextView->UnlockLooper();
else
BToolTipManager::Unlock();
Unlock();
}

View File

@ -52,6 +52,7 @@ public:
virtual void AttachedToWindow()
{
SetEventMask(B_POINTER_EVENTS, 0);
fToolTip->AttachedToWindow();
}
virtual void DetachedFromWindow()
@ -60,6 +61,7 @@ public:
RemoveChild(fToolTip->View());
// don't delete this one!
fToolTip->DetachedFromWindow();
BToolTipManager::Unlock();
}