* 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:
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TOOL_TIP_H
|
||||
#define _TOOL_TIP_H
|
||||
|
||||
|
||||
#include <Alignment.h>
|
||||
#include <Archivable.h>
|
||||
#include <Point.h>
|
||||
#include <Referenceable.h>
|
||||
|
||||
|
||||
class BView;
|
||||
class BTextView;
|
||||
|
||||
|
||||
class BToolTip : public BArchivable, public BReferenceable {
|
||||
public:
|
||||
BToolTip();
|
||||
BToolTip(BMessage* archive);
|
||||
virtual ~BToolTip();
|
||||
|
||||
virtual status_t Archive(BMessage* archive,
|
||||
bool deep = true) const;
|
||||
|
||||
virtual BView* View() const = 0;
|
||||
|
||||
virtual void SetSticky(bool enable);
|
||||
bool IsSticky() const;
|
||||
virtual void SetMouseRelativeLocation(BPoint location);
|
||||
BPoint MouseRelativeLocation() const;
|
||||
virtual void SetAlignment(BAlignment alignment);
|
||||
BAlignment Alignment() const;
|
||||
|
||||
private:
|
||||
BToolTip(const BToolTip& other);
|
||||
BToolTip& operator=(const BToolTip &other);
|
||||
|
||||
void _InitData();
|
||||
|
||||
private:
|
||||
bool fIsSticky;
|
||||
BPoint fRelativeLocation;
|
||||
BAlignment fAlignment;
|
||||
};
|
||||
|
||||
|
||||
class BTextToolTip : public BToolTip {
|
||||
public:
|
||||
BTextToolTip(const char* text);
|
||||
BTextToolTip(BMessage* archive);
|
||||
virtual ~BTextToolTip();
|
||||
|
||||
static BTextToolTip* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive,
|
||||
bool deep = true) const;
|
||||
|
||||
virtual BView* View() const;
|
||||
|
||||
const char* Text() const;
|
||||
void SetText(const char* text);
|
||||
|
||||
private:
|
||||
void _InitData(const char* text);
|
||||
|
||||
private:
|
||||
BTextView* fTextView;
|
||||
};
|
||||
|
||||
|
||||
#endif // _TOOL_TIP_H
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TOOL_TIP_MANAGER_H
|
||||
#define _TOOL_TIP_MANAGER_H
|
||||
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <Point.h>
|
||||
|
||||
|
||||
class BToolTip;
|
||||
|
||||
|
||||
class BToolTipManager {
|
||||
public:
|
||||
static BToolTipManager* Manager();
|
||||
|
||||
void ShowTip(BToolTip* tip, BPoint point);
|
||||
void HideTip();
|
||||
|
||||
void SetShowDelay(bigtime_t time);
|
||||
bigtime_t ShowDelay() const;
|
||||
void SetHideDelay(bigtime_t time);
|
||||
bigtime_t HideDelay() const;
|
||||
|
||||
private:
|
||||
BToolTipManager();
|
||||
virtual ~BToolTipManager();
|
||||
|
||||
BMessenger fWindow;
|
||||
|
||||
bigtime_t fShowDelay;
|
||||
bigtime_t fHideDelay;
|
||||
|
||||
static BToolTipManager* sDefaultInstance;
|
||||
};
|
||||
|
||||
|
||||
#endif // _TOOL_TIP_MANAGER_H
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TOOL_TIP_WINDOW_H
|
||||
#define TOOL_TIP_WINDOW_H
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class ToolTipWindow : public BWindow {
|
||||
public:
|
||||
ToolTipWindow(BToolTip* tip, BPoint where);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // TOOL_TIP_WINDOW_H
|
||||
Reference in New Issue
Block a user