Changed EnableDropFile to EnableDragDrop. D&D is now NOT automatically registered for all windows during

creation and initialization. The method EnableDragDrop is not used to "turn it on".
The method nsIView::CreateView has parameter that indicates whether it should be turned on or not
This make it configurable from the outside, it is needed for the editor
This commit is contained in:
rods%netscape.com 1999-08-26 14:41:17 +00:00
parent 394c235b4e
commit 4d8da33c9c
5 changed files with 33 additions and 23 deletions

View File

@ -650,7 +650,7 @@ class nsIWidget : public nsISupports {
* Enables the dropping of files to a widget (XXX this is temporary)
*
*/
NS_IMETHOD EnableFileDrop(PRBool aEnable) = 0;
NS_IMETHOD EnableDragDrop(PRBool aEnable) = 0;
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) = 0;

View File

@ -619,14 +619,14 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
gOLEInited = TRUE;
}
mNativeDragTarget = new nsNativeDragTarget(this);
/*mNativeDragTarget = new nsNativeDragTarget(this);
if (NULL != mNativeDragTarget) {
mNativeDragTarget->AddRef();
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
}
}
}
}*/
// call the event callback to notify about creation
@ -696,11 +696,7 @@ NS_METHOD nsWindow::Destroy()
nsBaseWidget::Destroy();
}
if (NULL != mNativeDragTarget) {
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
}
NS_RELEASE(mNativeDragTarget);
}
EnableDragDrop(PR_FALSE);
// destroy the HWND
if (mWnd) {
@ -1811,19 +1807,33 @@ nsresult nsWindow::MenuHasBeenSelected(
return NS_OK;
}
//---------------------------------------------------------
NS_METHOD nsWindow::EnableFileDrop(PRBool aEnable)
NS_METHOD nsWindow::EnableDragDrop(PRBool aEnable)
{
//::DragAcceptFiles(mWnd, (aEnable?TRUE:FALSE));
mNativeDragTarget = new nsNativeDragTarget(this);
if (NULL != mNativeDragTarget) {
mNativeDragTarget->AddRef();
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
}
}
}
nsresult rv = NS_ERROR_FAILURE;
return NS_OK;
if (aEnable) {
if (nsnull == mNativeDragTarget) {
mNativeDragTarget = new nsNativeDragTarget(this);
if (NULL != mNativeDragTarget) {
mNativeDragTarget->AddRef();
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
rv = NS_OK;
}
}
}
}
} else {
if (nsnull != mWnd && NULL != mNativeDragTarget) {
::RevokeDragDrop(mWnd);
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
rv = NS_OK;
}
NS_RELEASE(mNativeDragTarget);
}
}
return rv;
}

View File

@ -121,7 +121,7 @@ public:
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
NS_IMETHOD EnableFileDrop(PRBool aEnable);
NS_IMETHOD EnableDragDrop(PRBool aEnable);
virtual void SetUpForPaint(HDC aHDC);
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}

View File

@ -425,7 +425,7 @@ void nsBaseWidget::OnDestroy()
//-------------------------------------------------------------------------
nsBaseWidget::Enumerator::Enumerator(nsBaseWidget & inParent)
: mParent(inParent), mCurrentPosition(0)
: mCurrentPosition(0), mParent(inParent)
{
NS_INIT_REFCNT();
}
@ -761,7 +761,7 @@ NS_METHOD nsBaseWidget::SetVerticalScrollbar(nsIWidget * aWidget)
return NS_OK;
}
NS_METHOD nsBaseWidget::EnableFileDrop(PRBool aEnable)
NS_METHOD nsBaseWidget::EnableDragDrop(PRBool aEnable)
{
return NS_OK;
}

View File

@ -89,7 +89,7 @@ public:
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect);
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar);
NS_IMETHOD EnableFileDrop(PRBool aEnable);
NS_IMETHOD EnableDragDrop(PRBool aEnable);
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
protected: