* 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:
@@ -34,6 +34,13 @@ public:
|
|||||||
virtual void SetAlignment(BAlignment alignment);
|
virtual void SetAlignment(BAlignment alignment);
|
||||||
BAlignment Alignment() const;
|
BAlignment Alignment() const;
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void DetachedFromWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool Lock();
|
||||||
|
void Unlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BToolTip(const BToolTip& other);
|
BToolTip(const BToolTip& other);
|
||||||
BToolTip& operator=(const BToolTip &other);
|
BToolTip& operator=(const BToolTip &other);
|
||||||
@@ -41,6 +48,7 @@ private:
|
|||||||
void _InitData();
|
void _InitData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fLockedLooper;
|
||||||
bool fIsSticky;
|
bool fIsSticky;
|
||||||
BPoint fRelativeLocation;
|
BPoint fRelativeLocation;
|
||||||
BAlignment fAlignment;
|
BAlignment fAlignment;
|
||||||
|
|||||||
@@ -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
|
void
|
||||||
BToolTip::_InitData()
|
BToolTip::_InitData()
|
||||||
{
|
{
|
||||||
@@ -158,26 +202,12 @@ BTextToolTip::Text() const
|
|||||||
void
|
void
|
||||||
BTextToolTip::SetText(const char* text)
|
BTextToolTip::SetText(const char* text)
|
||||||
{
|
{
|
||||||
bool lockedLooper;
|
if (!Lock())
|
||||||
while (true) {
|
return;
|
||||||
lockedLooper = fTextView->LockLooper();
|
|
||||||
if (!lockedLooper) {
|
|
||||||
BToolTipManager::Lock();
|
|
||||||
|
|
||||||
if (fTextView->Window() != NULL) {
|
|
||||||
BToolTipManager::Unlock();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fTextView->SetText(text);
|
fTextView->SetText(text);
|
||||||
|
|
||||||
if (lockedLooper)
|
Unlock();
|
||||||
fTextView->UnlockLooper();
|
|
||||||
else
|
|
||||||
BToolTipManager::Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
virtual void AttachedToWindow()
|
virtual void AttachedToWindow()
|
||||||
{
|
{
|
||||||
SetEventMask(B_POINTER_EVENTS, 0);
|
SetEventMask(B_POINTER_EVENTS, 0);
|
||||||
|
fToolTip->AttachedToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DetachedFromWindow()
|
virtual void DetachedFromWindow()
|
||||||
@@ -60,6 +61,7 @@ public:
|
|||||||
|
|
||||||
RemoveChild(fToolTip->View());
|
RemoveChild(fToolTip->View());
|
||||||
// don't delete this one!
|
// don't delete this one!
|
||||||
|
fToolTip->DetachedFromWindow();
|
||||||
|
|
||||||
BToolTipManager::Unlock();
|
BToolTipManager::Unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user