* Added a basic tool tip API, and implementation.
* The BView API can probably be regarded as good enough; the implementation might need to be improved over time (also, some things as archivability aren't fully implemented yet). The ToolTip.h header should get public once finalized. * Added new B_MOUSE_IDLE message that is sent to a BView after a certain time has passed (BToolTipManager::ShowDelay()). * Added small test app (ToolTipTest) that shows what is already working. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32078 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+113
-6
@@ -54,6 +54,8 @@
|
||||
#include <ServerProtocol.h>
|
||||
#include <ServerProtocolStructs.h>
|
||||
#include <ShapePrivate.h>
|
||||
#include <ToolTip.h>
|
||||
#include <ToolTipManager.h>
|
||||
#include <TokenSpace.h>
|
||||
#include <ViewPrivate.h>
|
||||
|
||||
@@ -579,6 +581,9 @@ BView::~BView()
|
||||
|
||||
RemoveSelf();
|
||||
|
||||
if (fToolTip != NULL)
|
||||
fToolTip->ReleaseReference();
|
||||
|
||||
// TODO: see about BShelf! must I delete it here? is it deleted by
|
||||
// the window?
|
||||
|
||||
@@ -4171,6 +4176,18 @@ BView::MessageReceived(BMessage* msg)
|
||||
FrameMoved(fParentOffset);
|
||||
break;
|
||||
|
||||
case B_MOUSE_IDLE:
|
||||
{
|
||||
BPoint where;
|
||||
if (msg->FindPoint("be:view_where", &where) != B_OK)
|
||||
break;
|
||||
|
||||
BToolTip* tip;
|
||||
if (GetToolTipAt(where, &tip))
|
||||
ShowToolTip(tip);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_MOUSE_WHEEL_CHANGED:
|
||||
{
|
||||
BScrollBar* horizontal = ScrollBar(B_HORIZONTAL);
|
||||
@@ -4339,6 +4356,14 @@ BView::Perform(perform_code code, void* _data)
|
||||
BView::DoLayout();
|
||||
return B_OK;
|
||||
}
|
||||
case PERFORM_CODE_GET_TOOL_TIP_AT:
|
||||
{
|
||||
perform_data_get_tool_tip_at* data
|
||||
= (perform_data_get_tool_tip_at*)_data;
|
||||
data->return_value
|
||||
= BView::GetToolTipAt(data->point, data->tool_tip);
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return BHandler::Perform(code, _data);
|
||||
@@ -4612,6 +4637,74 @@ BView::DoLayout()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::SetToolTip(const char* text)
|
||||
{
|
||||
SetToolTip(new BTextToolTip(text));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::SetToolTip(BToolTip* tip)
|
||||
{
|
||||
if (fToolTip == tip)
|
||||
return;
|
||||
|
||||
if (fToolTip != NULL)
|
||||
fToolTip->ReleaseReference();
|
||||
fToolTip = tip;
|
||||
if (fToolTip != NULL)
|
||||
fToolTip->AcquireReference();
|
||||
}
|
||||
|
||||
|
||||
BToolTip*
|
||||
BView::ToolTip() const
|
||||
{
|
||||
return fToolTip;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::ShowToolTip(BToolTip* tip)
|
||||
{
|
||||
if (tip == NULL)
|
||||
return;
|
||||
|
||||
fVisibleToolTip = tip;
|
||||
|
||||
BPoint where;
|
||||
GetMouse(&where, NULL, false);
|
||||
|
||||
BToolTipManager::Manager()->ShowTip(tip, ConvertToScreen(where));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::HideToolTip()
|
||||
{
|
||||
BToolTipManager::Manager()->HideTip();
|
||||
fVisibleToolTip = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BView::GetToolTipAt(BPoint point, BToolTip** _tip)
|
||||
{
|
||||
if (fVisibleToolTip != NULL) {
|
||||
*_tip = fVisibleToolTip;
|
||||
return true;
|
||||
}
|
||||
if (fToolTip != NULL) {
|
||||
*_tip = fToolTip;
|
||||
return true;
|
||||
}
|
||||
|
||||
*_tip = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::_Layout(bool force, BLayoutContext* context)
|
||||
{
|
||||
@@ -4715,6 +4808,9 @@ BView::_InitData(BRect frame, const char* name, uint32 resizingMode,
|
||||
fMouseEventOptions = 0;
|
||||
|
||||
fLayoutData = new LayoutData;
|
||||
|
||||
fToolTip = NULL;
|
||||
fVisibleToolTip = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -5494,12 +5590,23 @@ _ReservedView10__5BView(BView* view)
|
||||
}
|
||||
|
||||
|
||||
void BView::_ReservedView11(){}
|
||||
void BView::_ReservedView12(){}
|
||||
void BView::_ReservedView13(){}
|
||||
void BView::_ReservedView14(){}
|
||||
void BView::_ReservedView15(){}
|
||||
void BView::_ReservedView16(){}
|
||||
extern "C" bool
|
||||
_ReservedView11__5BView(BView* view, BPoint point, BToolTip** _toolTip)
|
||||
{
|
||||
// GetToolTipAt()
|
||||
perform_data_get_tool_tip_at data;
|
||||
data.point = point;
|
||||
data.tool_tip = _toolTip;
|
||||
view->Perform(PERFORM_CODE_GET_TOOL_TIP_AT, &data);
|
||||
return data.return_value;
|
||||
}
|
||||
|
||||
|
||||
void BView::_ReservedView12() {}
|
||||
void BView::_ReservedView13() {}
|
||||
void BView::_ReservedView14() {}
|
||||
void BView::_ReservedView15() {}
|
||||
void BView::_ReservedView16() {}
|
||||
|
||||
|
||||
BView::BView(const BView& other)
|
||||
|
||||
Reference in New Issue
Block a user