implement nsITooltipListener with baloon help r=saari, sr=sfraser

git-svn-id: svn://10.0.0.236/trunk@85332 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pinkerton%netscape.com 2001-01-23 00:48:35 +00:00
parent 3ef2f816f0
commit 961cbd5d2d
2 changed files with 42 additions and 3 deletions

View File

@ -85,7 +85,7 @@ CWebBrowserPrompter::~CWebBrowserPrompter()
//*****************************************************************************
CWebBrowserChrome::CWebBrowserChrome() :
mBrowserWindow(nsnull), mBrowserShell(nsnull)
mBrowserWindow(nsnull), mBrowserShell(nsnull), mPreviousBalloonState(false)
{
NS_INIT_REFCNT();
@ -114,6 +114,7 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
NS_INTERFACE_MAP_END
//*****************************************************************************
@ -1123,3 +1124,36 @@ CBrowserShell*& CWebBrowserChrome::BrowserShell()
return mBrowserShell;
}
NS_IMETHODIMP
CWebBrowserChrome::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
{
nsAutoString tipText ( aTipText );
const char* printable = tipText.ToNewCString();
printf("--------- SHOW TOOLTIP AT %ld %ld, |%s|\n", aXCoords, aYCoords, printable );
Point where;
::GetMouse ( &where );
::LocalToGlobal ( &where );
HMMessageRecord helpRec;
helpRec.hmmHelpType = khmmString;
helpRec.u.hmmString[0] = strlen(printable);
memcpy ( &helpRec.u.hmmString[1], printable, strlen(printable) );
mPreviousBalloonState = ::HMGetBalloons();
::HMSetBalloons ( true );
OSErr err = ::HMShowBalloon ( &helpRec, where, NULL, NULL, 0, 0, 0 );
nsMemory::Free( (void*)printable );
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserChrome::OnHideTooltip()
{
printf("--------- HIDE TOOLTIP\n");
::HMRemoveBalloon();
::HMSetBalloons ( mPreviousBalloonState );
return NS_OK;
}

View File

@ -34,6 +34,7 @@
#include "nsIInterfaceRequestor.h"
#include "nsIPrompt.h"
#include "nsIContextMenuListener.h"
#include "nsITooltipListener.h"
// Other
#include "nsIWebBrowser.h"
@ -49,7 +50,8 @@ class CWebBrowserChrome : public nsIWebBrowserChrome,
public nsIBaseWindow,
public nsIPrompt,
public nsIInterfaceRequestor,
public nsIContextMenuListener
public nsIContextMenuListener,
public nsITooltipListener
{
friend class CBrowserWindow;
@ -61,7 +63,8 @@ public:
NS_DECL_NSIPROMPT
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSITOOLTIPLISTENER
protected:
CWebBrowserChrome();
virtual ~CWebBrowserChrome();
@ -73,6 +76,8 @@ protected:
CBrowserWindow* mBrowserWindow;
CBrowserShell* mBrowserShell;
Boolean mPreviousBalloonState; // are balloons on or off?
nsCOMPtr<nsIPrompt> mPrompter;
static vector<CWebBrowserChrome*> mgBrowserList;