From a799c2e203f6780953c89e997448cf9357c177c5 Mon Sep 17 00:00:00 2001 From: "briane%qnx.com" Date: Wed, 14 Mar 2001 19:46:53 +0000 Subject: [PATCH] PHOTON BUILD ONLY Numerous bug fixes and code cleanup for photon related memory leaks and bugs. --- widget/src/photon/PtRawDrawContainer.cpp | 2 +- widget/src/photon/nsAppShell.cpp | 7 - widget/src/photon/nsButton.cpp | 23 +- widget/src/photon/nsClipboard.cpp | 300 +-- widget/src/photon/nsDragService.cpp | 29 - widget/src/photon/nsFileWidget.cpp | 60 +- widget/src/photon/nsFontRetrieverService.cpp | 22 - widget/src/photon/nsMenuBar.cpp | 41 +- widget/src/photon/nsScrollbar.cpp | 37 - widget/src/photon/nsSound.cpp | 8 - widget/src/photon/nsTextAreaWidget.cpp | 20 +- widget/src/photon/nsTextHelper.cpp | 39 +- widget/src/photon/nsTextWidget.cpp | 12 - widget/src/photon/nsToolkit.cpp | 22 +- widget/src/photon/nsWidget.cpp | 2213 ++++++----------- widget/src/photon/nsWidget.h | 4 +- widget/src/photon/nsWidgetFactory.cpp | 64 +- widget/src/photon/nsWindow.cpp | 2245 ++++-------------- widget/src/photon/nsWindow.h | 9 +- 19 files changed, 1215 insertions(+), 3942 deletions(-) diff --git a/widget/src/photon/PtRawDrawContainer.cpp b/widget/src/photon/PtRawDrawContainer.cpp index 7bcec143c645..9f519b0623ec 100644 --- a/widget/src/photon/PtRawDrawContainer.cpp +++ b/widget/src/photon/PtRawDrawContainer.cpp @@ -37,7 +37,7 @@ static void raw_draw_container_draw( PtWidget_t *widget, PhTile_t *damage ) } if( rdc->draw_f ) - rdc->draw_f( widget, damage ); + rdc->draw_f( widget, damage ); } // diff --git a/widget/src/photon/nsAppShell.cpp b/widget/src/photon/nsAppShell.cpp index c092c12c80a9..df85790ea450 100644 --- a/widget/src/photon/nsAppShell.cpp +++ b/widget/src/photon/nsAppShell.cpp @@ -121,8 +121,6 @@ NS_IMETHODIMP nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListe static int event_processor_callback(int fd, void *data, unsigned mode) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsAppShell::event_processor_callback fd=<%d> data=<%p> mode=<%d>\n", fd, data, mode)); - nsIEventQueue *eventQueue = (nsIEventQueue*)data; if (eventQueue) eventQueue->ProcessPendingEvents(); @@ -147,8 +145,6 @@ NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav) PhWidLog = PR_NewLogModule("PhWidLog"); } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsAppShell::Create\n")); - int argc = bac ? *bac : 0; char **argv = bav; @@ -289,9 +285,6 @@ NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void * aEvent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsAppShell::DispatchNativeEvent aRealEvent=<%d> aEvent=<%p> mEventQueue=<%p>\n", aRealEvent, aEvent, mEventQueue)); - - if (!mEventQueue) return NS_ERROR_NOT_INITIALIZED; diff --git a/widget/src/photon/nsButton.cpp b/widget/src/photon/nsButton.cpp index dfd6d927fe19..634b147acf02 100644 --- a/widget/src/photon/nsButton.cpp +++ b/widget/src/photon/nsButton.cpp @@ -61,7 +61,6 @@ nsButton::nsButton() : nsWidget(), nsIButton() //------------------------------------------------------------------------- nsButton::~nsButton() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::~nsButton this=<%p> - Not Implemented!\n", this)); } //------------------------------------------------------------------------- @@ -71,7 +70,6 @@ nsButton::~nsButton() //------------------------------------------------------------------------- NS_METHOD nsButton::SetLabel(const nsString& aText) { - nsresult res = NS_ERROR_FAILURE; mLabel = aText; if( mWidget ) @@ -80,16 +78,13 @@ NS_METHOD nsButton::SetLabel(const nsString& aText) NS_ALLOC_STR_BUF(label, aText, aText.Length()); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsButton:SetLabel - aText=<%s> mWidget=%p mRefCnt=<%d>\n", label, mWidget, mRefCnt)); - PtSetArg( &arg, Pt_ARG_TEXT_STRING, label, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - res = NS_OK; + PtSetResources( mWidget, 1, &arg ); NS_FREE_STR_BUF(label); } - return res; + return NS_OK; } //------------------------------------------------------------------------- @@ -99,10 +94,6 @@ NS_METHOD nsButton::SetLabel(const nsString& aText) //------------------------------------------------------------------------- NS_METHOD nsButton::GetLabel(nsString& aBuffer) { - NS_ALLOC_STR_BUF(label, mLabel, mLabel.Length()); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::GetLabel label=<%s> mRefCnt=<%d>\n", label, mRefCnt)); - NS_FREE_STR_BUF(label); - aBuffer = mLabel; return NS_OK; } @@ -112,21 +103,21 @@ NS_METHOD nsButton::GetLabel(nsString& aBuffer) // move, paint, resizes message - ignore // //------------------------------------------------------------------------- +// Not Implemented PRBool nsButton::OnMove(PRInt32, PRInt32) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::OnMove - Not Implemented\n")); return PR_FALSE; } +// Not Implemented PRBool nsButton::OnPaint() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::OnPaint - Not Implemented\n")); return PR_FALSE; } +// Not Implemented PRBool nsButton::OnResize(nsRect &aWindowRect) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::OnResize - Not Implemented\n")); return PR_FALSE; } @@ -135,10 +126,10 @@ PRBool nsButton::OnResize(nsRect &aWindowRect) * Renders the Button for Printing * **/ +// Not Implemented NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsButton::Paint - Not Implemented\n")); return NS_OK; } @@ -151,8 +142,6 @@ NS_METHOD nsButton::CreateNative( PtWidget_t* aParent ) PhDim_t dim; const unsigned short BorderWidth = 2; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsButton::CreateNative at (%d,%d) for (%d,%d) with mRefCnt=<%d>\n",mBounds.x,mBounds.y, mBounds.width, mBounds.height, mRefCnt)); - NS_PRECONDITION(aParent, "nsButton::CreateNative aParent is NULL"); pos.x = mBounds.x; diff --git a/widget/src/photon/nsClipboard.cpp b/widget/src/photon/nsClipboard.cpp index f2fbf0994866..af5c1eb07cf2 100644 --- a/widget/src/photon/nsClipboard.cpp +++ b/widget/src/photon/nsClipboard.cpp @@ -41,10 +41,6 @@ // Initialize the class statics: -#if defined(DEBUG) -#define DEBUG_CLIPBOARD -#endif - //------------------------------------------------------------------------- // // nsClipboard constructor @@ -52,7 +48,6 @@ //------------------------------------------------------------------------- nsClipboard::nsClipboard() : nsBaseClipboard() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::nsClipboard this=<%p>\n", this)); } //------------------------------------------------------------------------- @@ -60,19 +55,12 @@ nsClipboard::nsClipboard() : nsBaseClipboard() //------------------------------------------------------------------------- nsClipboard::~nsClipboard() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::~nsClipboard this=<%p>\n", this)); } //------------------------------------------------------------------------- NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::ForceDataToClipboard this=<%p>\n", this)); - -#ifdef DEBUG_CLIPBOARD - printf("nsClipboard::ForceDataToClipboard this=<%p>\n", this); -#endif - // make sure we have a good transferable if (nsnull == mTransferable) { return NS_ERROR_FAILURE; @@ -85,167 +73,93 @@ NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard) //------------------------------------------------------------------------- NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::SetNativeClipboardData this=<%p>\n", this)); - -#ifdef DEBUG_CLIPBOARD - printf("nsClipboard::SetNativeClipboardData this=<%p>\n", this); -#endif - nsresult res = NS_ERROR_FAILURE; // make sure we have a good transferable - if (nsnull == mTransferable) - { - printf("nsClipboard::SetNativeClipboardData(): no transferable!\n"); - return NS_ERROR_FAILURE; - } + if( nsnull == mTransferable ) return NS_ERROR_FAILURE; // get flavor list that includes all flavors that can be written (including ones // obtained through conversion) nsCOMPtr flavorList; nsresult errCode = mTransferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) ); - if ( NS_FAILED(errCode) ) - return NS_ERROR_FAILURE; + if ( NS_FAILED(errCode) ) return NS_ERROR_FAILURE; PRUint32 cnt; flavorList->Count(&cnt); - if (cnt) - { - PhClipHeader *cliphdr = (PhClipHeader *) malloc( cnt * sizeof( PhClipHeader )); + if (cnt) { + PhClipHeader *cliphdr = (PhClipHeader *) calloc( cnt, sizeof( PhClipHeader )); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::SetNativeClipboardData cnt=<%d> cliphdr=<%p>\n", cnt, cliphdr)); - - if( cliphdr ) - { + if( cliphdr ) { PRUint32 i=0, index=0; nsString *df; void *data = nsnull; PRUint32 dataLen; - mIgnoreEmptyNotification = PR_TRUE; + mIgnoreEmptyNotification = PR_TRUE; - for ( PRUint32 i=0; i genericFlavor; flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); nsCOMPtr currentFlavor ( do_QueryInterface(genericFlavor) ); if ( currentFlavor ) - { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - nsresult err = GetFormat( flavorStr, &cliphdr[index] ); - if (err != NS_OK) - continue; + { + nsXPIDLCString flavorStr; + currentFlavor->ToString(getter_Copies(flavorStr)); + nsresult err = GetFormat( flavorStr, &cliphdr[index] ); + if( err != NS_OK ) continue; - // Get data out of transferable. - nsCOMPtr genericDataWrapper; - mTransferable->GetTransferData(flavorStr, - getter_AddRefs(genericDataWrapper), - &dataLen); + // Get data out of transferable. + nsCOMPtr genericDataWrapper; + mTransferable->GetTransferData( flavorStr, getter_AddRefs(genericDataWrapper), &dataLen ); - nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, dataLen ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::SetNativeClipboardData adding %d index=<%d> type=<%s> length=%d data=<%s>\n", i, index, cliphdr[index].type, dataLen, data)); + nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, dataLen ); + + int len = 0; + char *plain; + nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText( (PRUnichar*)data, dataLen/2, &plain, &len ); -printf("nsClipboard::setNativeClipboardData 1 data=<%s> dataLen=<%d> \n", data, dataLen ); + cliphdr[index].length = len+1; + cliphdr[index].data = plain; -#if defined(DEBUG) && 0 -{ - unsigned char *ptr = data; - int i=0; - printf("nsClipboard::setNativeClipboardData before: "); - for(i=0; i < dataLen; ptr++,i++) - { - printf("%x ",*ptr); - } - printf("\n"); -} -#endif - - int len; - char *mbsbuffer = (char *) calloc(dataLen,1); /* MEMORY LEAK */ - len = wcstombs (mbsbuffer, (const wchar_t*) data, dataLen); - -printf("nsClipboard::setNativeClipboardData 2 mbsbuffer=<%s> dataLen=<%d> len=<%d> \n", mbsbuffer, dataLen, len ); - -#if defined(DEBUG) && 0 -{ - unsigned char *ptr = mbsbuffer; - int i=0; - printf("nsClipboard::setNativeClipboardData after: "); - for(i=0; i < len; ptr++,i++) - { - printf("%x ",*ptr); - } - printf("\n"); - -} -#endif - -#if 0 - cliphdr[index].length = dataLen; - cliphdr[index].data = data; -#endif - -#if 0 - cliphdr[index].length = len; - cliphdr[index].data = mbsbuffer; -#endif - -#if 1 - cliphdr[index].length = strlen(mbsbuffer) + 1; /* Add the NULL */ - cliphdr[index].data = mbsbuffer; -#endif - - index++; - } - } - PhClipboardCopy( 1, index, cliphdr ); - for(i=0; i\n", this)); -#ifdef DEBUG_CLIPBOARD - printf("nsClipboard::GetNativeClipboardData this=<%p>\n", this); -#endif +nsClipboard::GetNativeClipboardData( nsITransferable * aTransferable, PRInt32 aWhichClipboard ) { nsresult res = NS_ERROR_FAILURE; // make sure we have a good transferable - if (nsnull == aTransferable) { - printf(" GetNativeClipboardData: Transferable is null!\n"); - return NS_ERROR_FAILURE; - } + if( nsnull == aTransferable ) return NS_ERROR_FAILURE; // get flavor list that includes all acceptable flavors (including ones obtained through // conversion) nsCOMPtr flavorList; nsresult errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) ); - if ( NS_FAILED(errCode) ) - return NS_ERROR_FAILURE; + if ( NS_FAILED(errCode) ) return NS_ERROR_FAILURE; // Walk through flavors and see which flavor matches the one being pasted: PRUint32 cnt; flavorList->Count(&cnt); nsCAutoString foundFlavor; - if (cnt > 0) - { + if (cnt > 0) { void *clipPtr; PhClipHeader cliptype; PhClipHeader *cliphdr; @@ -254,66 +168,28 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, clipPtr = PhClipboardPasteStart( 1 ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::GetNativeClipboardData cnt=<%d>\n", cnt)); - - for ( PRUint32 i = 0; i < cnt; ++i ) - { + for ( PRUint32 i = 0; i < cnt; ++i ) { nsCOMPtr genericFlavor; flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); nsCOMPtr currentFlavor ( do_QueryInterface(genericFlavor) ); - if ( currentFlavor ) - { + + if ( currentFlavor ) { + nsXPIDLCString flavorStr; currentFlavor->ToString ( getter_Copies(flavorStr) ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::GetNativeClipboardData looking for=<%s>\n", (const char *) flavorStr)); + nsresult err = GetFormat( flavorStr, &cliptype); - if (err != NS_OK) - continue; + if (err != NS_OK) continue; cliphdr = PhClipboardPasteType( clipPtr, cliptype.type ); - if (cliphdr) - { - data = cliphdr->data; - dataLen = cliphdr->length; + if (cliphdr) { + data = cliphdr->data; + dataLen = cliphdr->length; -printf("nsClipboard::GetNativeClipboardData 1 data=<%s> dataLen=<%d> \n", data, dataLen ); - -#if defined(DEBUG) && 0 -{ - unsigned char *ptr = data; - int i=0; - printf("nsClipboard::GetNativeClipboardData before: "); - for(i=0; i < dataLen; ptr++,i++) - { - printf("%x ",*ptr); - } - printf("\n"); -} -#endif - - int len; - wchar_t *wbuffer = (wchar_t *) calloc(dataLen*3, 1); /* MEMORY LEAK */ - len = mbstowcs(wbuffer, (const char *) data, dataLen*3); - - printf("nsClipboard::GetNativeClipboardData %s(%d)\n", data, len ); - - data = wbuffer; - dataLen = len*2; - -printf("nsClipboard::GetNativeClipboardData 2 data=<%s> dataLen=<%d>\n", data, dataLen ); - -#if defined(DEBUG) && 0 -{ - unsigned char *ptr = data; - int i=0; - printf("nsClipboard::GetNativeClipboardData after: "); - for(i=0; i < dataLen; ptr++,i++) - { - printf("%x ",*ptr); - } - printf("\n"); -} -#endif + int len_unicode; + PRUnichar *unicode; + nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode( (char*) data, dataLen, &unicode, &len_unicode ); + len_unicode *= 2; #if 0 /* Kirk - 2/25/99 Disable this for unicode text */ @@ -327,80 +203,44 @@ printf("nsClipboard::GetNativeClipboardData 2 data=<%s> dataLen=<%d>\n", data, d #endif - nsCOMPtr genericDataWrapper; - nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper) ); - aTransferable->SetTransferData(flavorStr, - genericDataWrapper, - dataLen); - printf("nsClipboard::GetNativeClipboardData flavorStr=<%s> length=<%d> data=<%s>\n", cliptype.type, dataLen, data ); - res = NS_OK; - break; - } - } - } + nsCOMPtr genericDataWrapper; + nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, unicode, len_unicode, getter_AddRefs(genericDataWrapper) ); + aTransferable->SetTransferData(flavorStr, genericDataWrapper, len_unicode ); - PhClipboardPasteFinish( clipPtr ); - } + res = NS_OK; + break; + } + } + } + + PhClipboardPasteFinish( clipPtr ); + } return res; -} + } NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, PRInt32 aWhichClipboard, - PRBool * outResult) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::HasDataMatchingFlavors this=<%p>\n", this)); - -#ifdef DEBUG_CLIPBOARD - PRUint32 cnt; - aFlavorList->Count(&cnt); - if (cnt) - { - PRUint32 i; - - for ( PRUint32 i=0; i genericFlavor; - aFlavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); - nsCOMPtr currentFlavor ( do_QueryInterface(genericFlavor) ); - if ( currentFlavor ) - { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - printf("nsClipboard::HasDataMatchingFlavors : <%s>\n", (const char *) flavorStr); - } - } - } -#endif - + PRBool * outResult) { *outResult = PR_TRUE; // say we always do. return NS_OK; -} + } //========================================================================= //------------------------------------------------------------------------- -nsresult nsClipboard::GetFormat(const char* aMimeStr, PhClipHeader *cliphdr ) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsClipboard::GetFormat this=<%p> aMimeStr=<%s>\n", this, aMimeStr)); - -#ifdef DEBUG_CLIPBOARD - printf("nsClipboard::GetFormat this=<%p> aMimeStr=<%s>\n", this, aMimeStr); -#endif - +nsresult nsClipboard::GetFormat(const char* aMimeStr, PhClipHeader *cliphdr ) { nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) ); cliphdr->type[0]=0; if (mimeStr.Equals(kUnicodeMime)) - { strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_TEXT ); - } - if (cliphdr->type[0] == 0) - return NS_ERROR_FAILURE; - else - return NS_OK; -} + if (cliphdr->type[0] == 0) + return NS_ERROR_FAILURE; + else + return NS_OK; + } diff --git a/widget/src/photon/nsDragService.cpp b/widget/src/photon/nsDragService.cpp index 0b5ed83b06e5..25b4be371094 100644 --- a/widget/src/photon/nsDragService.cpp +++ b/widget/src/photon/nsDragService.cpp @@ -48,8 +48,6 @@ NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession) //------------------------------------------------------------------------- nsDragService::nsDragService() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::nsDragService this=<%p>\n", this)); - NS_INIT_REFCNT(); mWidget = nsnull; mNumFlavors = 0; @@ -62,8 +60,6 @@ nsDragService::nsDragService() //------------------------------------------------------------------------- nsDragService::~nsDragService() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::~nsDragService this=<%p>\n", this)); - if (mWidget) { PtDestroyWidget(mWidget); @@ -75,8 +71,6 @@ nsDragService::~nsDragService() NS_IMETHODIMP nsDragService::StartDragSession() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::StartDragSession this=<%p>\n", this)); - NS_WARNING("nsDragService::StartDragSession() - Not Supported Yet"); nsBaseDragService::StartDragSession(); @@ -85,8 +79,6 @@ NS_IMETHODIMP nsDragService::StartDragSession() NS_IMETHODIMP nsDragService::EndDragSession() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::EndDragSession this=<%p>\n", this)); - NS_WARNING("nsDragService::EndDragSession()\n"); nsBaseDragService::EndDragSession(); @@ -104,7 +96,6 @@ NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode, { nsBaseDragService::InvokeDragSession ( aDOMNode, aTransferableArray, aRegion, aActionType ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::InvokeDragSession this=<%p> aActionType=<%d>\n", this, aActionType)); //mWidget = gtk_invisible_new(); //gtk_widget_show(mWidget); @@ -228,8 +219,6 @@ PRBool nsDragService::DoConvert(GdkAtom type) //------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::GetNumDropItems (PRUint32 * aNumItems) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::GetNumDropItems this=<%p>\n", this)); - *aNumItems = 0; return NS_OK; } @@ -237,13 +226,6 @@ NS_IMETHODIMP nsDragService::GetNumDropItems (PRUint32 * aNumItems) //------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 anItem) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::GetData this=<%p>\n", this)); - -#ifdef DEBUG_DRAG - printf("nsClipboard::GetNativeClipboardData()\n"); -#endif /* DEBUG_CLIPBOARD */ - - #if 0 // make sure we have a good transferable @@ -277,11 +259,6 @@ NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 } } -#ifdef DEBUG_CLIPBOARD - printf(" Got the callback: '%s', %d\n", - mSelectionData.data, mSelectionData.length); -#endif /* DEBUG_CLIPBOARD */ - // We're back from the callback, no longer blocking: mBlocking = PR_FALSE; @@ -320,9 +297,6 @@ NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 //------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBool *_retval) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported this=<%p>\n", this)); - - printf("nsDragService::IsDataFlavorSupported\n"); if (!aDataFlavor || !_retval) return NS_ERROR_FAILURE; @@ -334,9 +308,6 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo //------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::GetCurrentSession (nsIDragSession **aSession) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsDragService::GetCurrentSession this=<%p>\n", this)); - - printf("nsDragService::GetCurrentSession\n"); if (!aSession) return NS_ERROR_FAILURE; diff --git a/widget/src/photon/nsFileWidget.cpp b/widget/src/photon/nsFileWidget.cpp index 5582ad8fe18a..f99f358b03eb 100644 --- a/widget/src/photon/nsFileWidget.cpp +++ b/widget/src/photon/nsFileWidget.cpp @@ -36,8 +36,6 @@ NS_IMPL_ISUPPORTS(nsFileWidget, kIFileWidgetIID); //------------------------------------------------------------------------- nsFileWidget::nsFileWidget() : nsIFileWidget() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::nsFileWidget - Constructor Called this=<%p>\n", this)); - NS_INIT_REFCNT(); mWidget = nsnull; mParent = nsnull; @@ -51,8 +49,6 @@ nsFileWidget::nsFileWidget() : nsIFileWidget() //------------------------------------------------------------------------- nsFileWidget::~nsFileWidget() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::~nsFileWidget - Destructor Called this=<%p>\n", this)); - if (mWidget) PtDestroyWidget(mWidget); } @@ -64,8 +60,6 @@ nsFileWidget::~nsFileWidget() //------------------------------------------------------------------------- PRBool nsFileWidget::Show() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::Show this=<%p> mMode=<%d>\n", this, mMode)); - int err; PRBool res = PR_FALSE; char *title = mTitle.ToNewCString(); @@ -74,7 +68,6 @@ PRBool nsFileWidget::Show() if (mParent) { myParent = (PtWidget_t *) mParent->GetNativeData(NS_NATIVE_WIDGET); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::Show myParent=<%p>\n", myParent)); } PhPoint_t thePos= {100,100}; @@ -115,21 +108,14 @@ PRBool nsFileWidget::Show() PtSetParentWidget( NULL ); err = PtFileSelection(myParent, &thePos, title, root_dir, file_spec, btn1, btn2, format, &info, flags); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::Show 2 err=<%d>\n", err)); - if (err == 0) { /* Successfully selected a file or directory */ if (info.ret == Pt_FSDIALOG_BTN1) { mSelectedFile.SetLength(0); - mSelectedFile.AppendWithConversion(info.path); - - char *str = mSelectedFile.ToNewCString(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::Create Success from PtFileSelection str=<%s>\n", str)); - delete [] str; - - res = PR_TRUE; + mSelectedFile.AppendWithConversion(info.path); + res = PR_TRUE; } else { @@ -152,7 +138,6 @@ PRBool nsFileWidget::Show() //------------------------------------------------------------------------- PRBool nsFileWidget::AskReplace() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::AskReplace this=<%p> - Not Implemented\n", this)); PRBool res = PR_FALSE; /* Almost the same as ::Show Just different button labels */ @@ -169,25 +154,6 @@ NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters, const nsString aTitles[], const nsString aFilters[]) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::SetFilterList numFilters=<%d>\n", aNumberOfFilters)); - -#if defined(DEBUG) -{ - int i; - for(i=0; i Filter=<%s>\n", i, str1, str2)); - - delete [] str1; - delete [] str2; - } - -} -#endif - mNumberOfFilters = aNumberOfFilters; mTitles = aTitles; mFilters = aFilters; @@ -203,10 +169,6 @@ NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters, //------------------------------------------------------------------------- NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) { - char *str = aString.ToNewCString(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::SetDefaultString new string=<%s> - Not Implemented\n", str)); - delete [] str; - mDefault = aString; return NS_OK; } @@ -219,8 +181,6 @@ NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) //------------------------------------------------------------------------- NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec & aDirectory) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::SetDisplayDirectory to <%s> - Not Implemented\n", aDirectory.GetCString())); - mDisplayDirectory = (const PRUnichar *) aDirectory.GetCString(); /* LEAK? */ return NS_OK; } @@ -232,8 +192,6 @@ NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec & aDirectory) //------------------------------------------------------------------------- NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetDisplayDirectory - Not Implemented\n")); - aDirectory = mDisplayDirectory; return NS_OK; } @@ -248,8 +206,6 @@ NS_METHOD nsFileWidget::Create(nsIWidget *aParent, nsIToolkit *aToolkit, void *aInitData) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::Create aParent=<%p>\n", aParent)); - mMode = aMode; mTitle.SetLength(0); mTitle.Append(aTitle); @@ -262,10 +218,7 @@ NS_METHOD nsFileWidget::Create(nsIWidget *aParent, NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetFile with nsFileSpec this=<%p>\n", this)); - char *str = mSelectedFile.ToNewCString(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetFile with nsFileSpec filename=<%s>\n", str)); aFile = strdup(str); delete [] str; @@ -274,10 +227,9 @@ NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) //------------------------------------------------------------------------- //------------------------------------------------------------------------- +// Not Implemented NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetSelectedType - Not Implemented\n")); - theType = mSelectedType; return NS_OK; } @@ -288,8 +240,6 @@ nsFileDlgResults nsFileWidget::GetFile( const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec) // Populate with initial path for file dialog { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetFile with nsIWidget this=<%p> aParent=<%p>\n", this, aParent)); - Create(aParent, promptString, eMode_load, nsnull, nsnull); if (Show() == PR_TRUE) { @@ -305,8 +255,6 @@ nsFileDlgResults nsFileWidget::GetFolder( const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec) // Populate with initial path for file dialog { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::GetFolder with nsIWidget\n")); - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); if (Show() == PR_TRUE) { @@ -322,8 +270,6 @@ nsFileDlgResults nsFileWidget::PutFile( const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec) // Populate with initial path for file dialog { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFileWidget::PutFile with nsIWidget\n")); - nsFileDlgResults theResult = nsFileDlgResults_Cancel; Create(aParent, promptString, eMode_save, nsnull, nsnull); diff --git a/widget/src/photon/nsFontRetrieverService.cpp b/widget/src/photon/nsFontRetrieverService.cpp index f48ca2865153..954f86824ed0 100644 --- a/widget/src/photon/nsFontRetrieverService.cpp +++ b/widget/src/photon/nsFontRetrieverService.cpp @@ -39,8 +39,6 @@ NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameI //---------------------------------------------------------- nsFontRetrieverService::nsFontRetrieverService() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::nsFontRetrieverService this=<%p>\n", this)); - NS_INIT_REFCNT(); mFontList = nsnull; mSizeIter = nsnull; @@ -51,8 +49,6 @@ nsFontRetrieverService::nsFontRetrieverService() //---------------------------------------------------------- nsFontRetrieverService::~nsFontRetrieverService() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::~nsFontRetrieverService this=<%p>\n",this)); - if (nsnull != mFontList) { for (PRInt32 i=0;iCount();i++) { FontInfo * font = (FontInfo *)mFontList->ElementAt(i); @@ -73,8 +69,6 @@ nsFontRetrieverService::~nsFontRetrieverService() //---------------------------------------------------------- NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::CreateFontNameIterator this=<%p>\n",this)); - if (nsnull == aIterator) { return NS_ERROR_FAILURE; } @@ -91,8 +85,6 @@ NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterato NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::CreateFontNameIterator 2 this=<%p>\n",this)); - // save value in case someone externally is using it PRInt32 saveIterInx = mNameIterInx; @@ -130,8 +122,6 @@ NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & a //---------------------------------------------------------- NS_IMETHODIMP nsFontRetrieverService::Reset() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::Reset this=<%p>\n",this)); - mNameIterInx = 0; return NS_OK; } @@ -139,8 +129,6 @@ NS_IMETHODIMP nsFontRetrieverService::Reset() //---------------------------------------------------------- NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::Get this=<%p>\n",this)); - if (mNameIterInx < mFontList->Count()) { FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); *aFontName = fontInfo->mName; @@ -152,8 +140,6 @@ NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) //---------------------------------------------------------- NS_IMETHODIMP nsFontRetrieverService::Advance() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::Advance this=<%p>\n",this)); - if (mNameIterInx < mFontList->Count()-1) { mNameIterInx++; return NS_OK; @@ -164,8 +150,6 @@ NS_IMETHODIMP nsFontRetrieverService::Advance() //------------------------------ static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::GetFontInfo\n")); - nsAutoString name((const PRUnichar *) aName, strlen(aName) ); PRInt32 i; PRInt32 cnt = aFontList->Count(); @@ -188,8 +172,6 @@ static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) //------------------------------ static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::AddSizeToFontInfo\n")); - nsVoidArray * sizes; if (nsnull == aFontInfo->mSizes) { sizes = new nsVoidArray(); @@ -228,8 +210,6 @@ static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) //-------------------------------------------------- NS_IMETHODIMP nsFontRetrieverService::LoadFontList() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::LoadFontList this=<%p>\n",this)); - #if 0 char * pattern = "*"; int nnames = 1024; @@ -392,8 +372,6 @@ NS_IMETHODIMP nsFontRetrieverService::LoadFontList() NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName, PRBool* aResult ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsFontRetrieverService::IsFontScalable this=<%p>\n",this)); - // save value in case someone externally is using it PRInt32 saveIterInx = mNameIterInx; diff --git a/widget/src/photon/nsMenuBar.cpp b/widget/src/photon/nsMenuBar.cpp index c49fc40cd411..233248ebb0e3 100644 --- a/widget/src/photon/nsMenuBar.cpp +++ b/widget/src/photon/nsMenuBar.cpp @@ -108,8 +108,6 @@ nsMenuBar::nsMenuBar() : nsIMenuBar(), nsIMenuListener() //------------------------------------------------------------------------- nsMenuBar::~nsMenuBar() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::~nsMenuBar Destructor Called - Not Implmenented\n")); - // Remove all references to menus on this menubar mItems->Clear(); @@ -136,12 +134,10 @@ NS_METHOD nsMenuBar::Create(nsIWidget *aParent) mMenuBar = PtCreateWidget( PtMenuBar, parent, 1, arg); if (!mMenuBar) { - PR_LOG(PhWidLog, PR_LOG_ERROR, ("nsMenuBar::Create Failed to create the PtMenuBar\n")); return NS_ERROR_FAILURE; } else { - PR_LOG(PhWidLog, PR_LOG_ERROR, ("nsMenuBar::Create with nsIWidget parent=%p, this=%p Photon menuBar=<%p>\n", aParent, this, mMenuBar)); SetParent(aParent); // PtRealizeWidget(mMenuBar); @@ -152,8 +148,6 @@ NS_METHOD nsMenuBar::Create(nsIWidget *aParent) //------------------------------------------------------------------------- NS_METHOD nsMenuBar::GetParent(nsIWidget *&aParent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::GetParent mParent=<%p>\n", mParent)); - aParent = mParent; return NS_OK; } @@ -161,8 +155,6 @@ NS_METHOD nsMenuBar::GetParent(nsIWidget *&aParent) //------------------------------------------------------------------------- NS_METHOD nsMenuBar::SetParent(nsIWidget *aParent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::SetParent aParent=<%p>\n", aParent)); - mParent = aParent; return NS_OK; } @@ -172,20 +164,9 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) { NS_ASSERTION(aMenu, "NULL Pointer in nsMenuBar::AddMenu"); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::AddMenu aMenu=<%p>\n", aMenu)); - /* Add the nsMenu to our list */ mItems->AppendElement(aMenu); NS_ADDREF(aMenu); - -#ifdef DEBUG - nsString Label; - aMenu->GetLabel(Label); - char *labelStr = Label.ToNewCString(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::AddMenu Label is <%s>\n", labelStr)); - delete[] labelStr; -#endif - return NS_OK; } @@ -193,14 +174,12 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) NS_METHOD nsMenuBar::GetMenuCount(PRUint32 &aCount) { aCount = mItems->Count();; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::GetMenuCount aCount=<%d>\n", aCount)); return NS_OK; } //------------------------------------------------------------------------- NS_METHOD nsMenuBar::GetMenuAt(const PRUint32 aPos, nsIMenu *& aMenu) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::GetMenuAt %d\n", aPos)); aMenu = (nsIMenu *) mItems->ElementAt(aPos); NS_ADDREF(aMenu); return NS_OK; @@ -209,8 +188,6 @@ NS_METHOD nsMenuBar::GetMenuAt(const PRUint32 aPos, nsIMenu *& aMenu) //------------------------------------------------------------------------- NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aPos, nsIMenu *& aMenu) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::InsertMenuAt aPos=<%d> - Not Implemented\n", aPos)); - mItems->InsertElementAt(aMenu, aPos); NS_ADDREF(aMenu); @@ -229,8 +206,6 @@ NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aPos, nsIMenu *& aMenu) //------------------------------------------------------------------------- NS_METHOD nsMenuBar::RemoveMenu(const PRUint32 aPos) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::RemoveMenu aPos=<%d>\n", aPos)); - nsIMenu * menu = (nsIMenu *) mItems->ElementAt(aPos); NS_RELEASE(menu); mItems->RemoveElementAt(aPos); @@ -240,8 +215,6 @@ NS_METHOD nsMenuBar::RemoveMenu(const PRUint32 aPos) //------------------------------------------------------------------------- NS_METHOD nsMenuBar::RemoveAll() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::RemoveAll\n")); - while (mItems->Count()) { nsISupports * supports = (nsISupports *)mItems->ElementAt(0); NS_RELEASE(supports); @@ -254,34 +227,33 @@ NS_METHOD nsMenuBar::RemoveAll() //------------------------------------------------------------------------- NS_METHOD nsMenuBar::GetNativeData(void *& aData) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::GetNativeData this=<%p> mMenuBar=<%p>\n", this, mMenuBar)); aData = (void *)mMenuBar; return NS_OK; } //------------------------------------------------------------------------- +// Not Implemented NS_METHOD nsMenuBar::SetNativeData(void * aData) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::SetNativeData to <%p> - Not Implemented\n", aData)); return NS_OK; } //------------------------------------------------------------------------- NS_METHOD nsMenuBar::Paint() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::Paint\n")); mParent->Invalidate(PR_TRUE); return NS_OK; } //------------------------------------------------------------------------- +// Not Implemented nsEventStatus nsMenuBar::MenuItemSelected(const nsMenuEvent & aMenuEvent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::MenuItemSelected - Not Implemented\n")); return nsEventStatus_eIgnore; } //------------------------------------------------------------------------- +// Not Implemented nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent) { // I should determine which menu was selected and call MenuConstruct @@ -289,8 +261,6 @@ nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent) // Not really sure what to do here, will have to wait until someone // calls it! - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::MenuSelected aMenuEvent->nativeMsg=<%p> - Not Implemented\n", aMenuEvent.nativeMsg)); - /* I have no idea what this really is... */ // PtWidget_t *PhMenu = (PtWidget_t *) aMenuEvent.nativeMsg; @@ -298,9 +268,9 @@ nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent) } //------------------------------------------------------------------------- +// Not Implemented nsEventStatus nsMenuBar::MenuDeselected(const nsMenuEvent & aMenuEvent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::MenuDeSelected - Not Implemented\n")); return nsEventStatus_eIgnore; } @@ -311,7 +281,6 @@ nsEventStatus nsMenuBar::MenuConstruct( void * menubarNode, void * aWebShell) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::MenuConstruct\n")); mWebShell = (nsIWebShell*) aWebShell; mDOMNode = (nsIDOMNode*)menubarNode; @@ -382,8 +351,8 @@ nsEventStatus nsMenuBar::MenuConstruct( return nsEventStatus_eIgnore; } +// Not Implemented nsEventStatus nsMenuBar::MenuDestruct(const nsMenuEvent & aMenuEvent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuBar::MenuDeconstruct - Not Implemented\n")); return nsEventStatus_eIgnore; } diff --git a/widget/src/photon/nsScrollbar.cpp b/widget/src/photon/nsScrollbar.cpp index 33ee94c5e474..2f5c8d5d52ac 100644 --- a/widget/src/photon/nsScrollbar.cpp +++ b/widget/src/photon/nsScrollbar.cpp @@ -40,8 +40,6 @@ NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget) //------------------------------------------------------------------------- nsScrollbar::nsScrollbar (PRBool aIsVertical):nsWidget (), nsIScrollbar () { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::nsScrollbar this=<%p> IsVertical=<%d>\n", this, aIsVertical)); - NS_INIT_REFCNT (); mOrientation = (aIsVertical) ? Pt_VERTICAL : Pt_HORIZONTAL; @@ -54,7 +52,6 @@ nsScrollbar::nsScrollbar (PRBool aIsVertical):nsWidget (), nsIScrollbar () //------------------------------------------------------------------------- nsScrollbar::~nsScrollbar () { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::~nsScrollbar this=<%p>\n", this)); } //------------------------------------------------------------------------- @@ -64,8 +61,6 @@ nsScrollbar::~nsScrollbar () //------------------------------------------------------------------------- NS_METHOD nsScrollbar::CreateNative (PtWidget_t * parentWindow) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::CreateNative this=<%p>\n", this)); - nsresult res = NS_ERROR_FAILURE; PhPoint_t pos; PhDim_t dim; @@ -76,9 +71,6 @@ NS_METHOD nsScrollbar::CreateNative (PtWidget_t * parentWindow) dim.w = mBounds.width; dim.h = mBounds.height; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::CreateNative at (%d,%d) w,h=(%d,%d)\n", - mBounds.x, mBounds.y, mBounds.width, mBounds.height)); - PtSetArg( &arg[0], Pt_ARG_ORIENTATION, mOrientation, 0 ); PtSetArg( &arg[1], Pt_ARG_POS, &pos, 0 ); PtSetArg( &arg[2], Pt_ARG_DIM, &dim, 0 ); @@ -104,8 +96,6 @@ NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange) { nsresult res = NS_ERROR_FAILURE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::SetMaxRange to %d\n", aEndRange)); - if( mWidget ) { PtArg_t arg; @@ -127,8 +117,6 @@ NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange) { nsresult res = NS_ERROR_FAILURE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::GetMaxRange\n")); - if( mWidget ) { PtArg_t arg; @@ -153,8 +141,6 @@ NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange) //------------------------------------------------------------------------- NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::SetPosition to <%d>\n", aPos)); - nsresult res = NS_ERROR_FAILURE; if( mWidget ) @@ -198,8 +184,6 @@ NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos) #endif } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::GetPosition position=<%d>\n", aPos)); - return res; } @@ -211,7 +195,6 @@ NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos) //------------------------------------------------------------------------- NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::SetThumbSize aSize=<%d>\n", aSize)); nsresult res = NS_ERROR_FAILURE; if( mWidget ) @@ -238,8 +221,6 @@ NS_METHOD nsScrollbar::GetThumbSize (PRUint32 & aThumbSize) { nsresult res = NS_ERROR_FAILURE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::GetThumbSize\n")); - if( mWidget ) { PtArg_t arg; @@ -264,8 +245,6 @@ NS_METHOD nsScrollbar::GetThumbSize (PRUint32 & aThumbSize) //------------------------------------------------------------------------- NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::SetLineIncrement to %d \n", aLineIncrement)); - nsresult res = NS_ERROR_FAILURE; if( mWidget ) @@ -290,8 +269,6 @@ NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement) //------------------------------------------------------------------------- NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::GetLineIncrement\n")); - nsresult res = NS_ERROR_FAILURE; if( mWidget ) @@ -319,9 +296,6 @@ NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc) NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize, PRUint32 aPosition, PRUint32 aLineIncrement) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::SetParameters this=<%p> MaxRange=<%d> ThumbSize=<%d> Position=<%d> LineIncrement=<%d>\n", - this, aMaxRange, aThumbSize, aPosition, aLineIncrement)); - nsresult res = NS_ERROR_FAILURE; if( mWidget ) @@ -352,20 +326,12 @@ NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize, PRBool nsScrollbar::OnScroll (nsScrollbarEvent & aEvent, PRUint32 cPos) { PRBool result = PR_TRUE; -// float newPosition; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::OnScroll cPos=<%d> aEvent.message=<%d>\n", cPos, aEvent.message)); - if (mEventCallback) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsScrollbar::OnScroll Inside mEventCallback portion\n", cPos)); - aEvent.position = cPos; result = ConvertStatus((*mEventCallback)(&aEvent)); -// newPosition = aEvent.position; } - else - PR_LOG(PhWidLog, PR_LOG_ERROR, ("nsScrollbar::OnScroll Error no mEventCallback defined\n")); return result; } @@ -382,8 +348,6 @@ int nsScrollbar::handle_scroll_move_event (PtWidget_t *aWidget, void *aData, PtC PRUint32 thePos = 0; PtScrollbarCallback_t *theScrollbarCallback = (PtScrollbarCallback_t *) aCbinfo->cbdata; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsScrollbar::handle_activate_event me=<%p> new position=<%d>\n",me, theScrollbarCallback->position)); - scroll_event.message = NS_SCROLLBAR_POS; scroll_event.widget = (nsWidget *) me; scroll_event.eventStructType = NS_SCROLLBAR_EVENT; @@ -407,7 +371,6 @@ int nsScrollbar::handle_scroll_move_event (PtWidget_t *aWidget, void *aData, PtC scroll_event.message = NS_SCROLLBAR_POS; break; default: - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsScrollbar::handle_activate_event Invalid Scroll Type!\n")); break; } diff --git a/widget/src/photon/nsSound.cpp b/widget/src/photon/nsSound.cpp index 27ee12e3e5b1..fb15e5c85030 100644 --- a/widget/src/photon/nsSound.cpp +++ b/widget/src/photon/nsSound.cpp @@ -40,22 +40,16 @@ NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver); //////////////////////////////////////////////////////////////////////// nsSound::nsSound() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsSound::nsSound this=<%p>\n", this)); - NS_INIT_REFCNT(); mInited = PR_FALSE; } nsSound::~nsSound() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsSound::~nsSound this=<%p>\n", this)); - } nsresult nsSound::Init() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsSound::Init this=<%p> mInited=<%d>\n", this, mInited)); - if (mInited) return NS_OK; mInited = PR_TRUE; @@ -82,13 +76,11 @@ nsresult NS_NewSound(nsISound** aSound) NS_METHOD nsSound::Beep() { ::PtBeep(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsSound::Beep this=<%p>\n", this)); return NS_OK; } NS_METHOD nsSound::Play(nsIURL *aURL) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsSound::Play - Not Implemented\n")); NS_NOTYETIMPLEMENTED("nsSound::Play"); return NS_OK; } diff --git a/widget/src/photon/nsTextAreaWidget.cpp b/widget/src/photon/nsTextAreaWidget.cpp index d79528487785..4923fe4679d0 100644 --- a/widget/src/photon/nsTextAreaWidget.cpp +++ b/widget/src/photon/nsTextAreaWidget.cpp @@ -61,7 +61,6 @@ nsTextAreaWidget::nsTextAreaWidget() : nsTextHelper() //------------------------------------------------------------------------- nsTextAreaWidget::~nsTextAreaWidget() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::~nsTextAreaWidget Destructor called.\n")); } //------------------------------------------------------------------------- @@ -89,13 +88,12 @@ nsresult nsTextAreaWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr //------------------------------------------------------------------------- PRBool nsTextAreaWidget::OnPaint() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::OnPaint - Not Implemented\n")); return PR_FALSE; } +// Not Implemented PRBool nsTextAreaWidget::OnResize(nsRect &aWindowRect) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::OnResize - Not Implemented\n")); return PR_FALSE; } @@ -106,8 +104,6 @@ NS_METHOD nsTextAreaWidget::CreateNative( PtWidget_t* aParent ) PhPoint_t pos; PhDim_t dim; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::CreateNative")); - pos.x = mBounds.x; pos.y = mBounds.y; dim.w = mBounds.width - 4; // Correct for border width @@ -133,8 +129,6 @@ int nsTextAreaWidget::RawEventHandler(PtWidget_t *aWidget, void *aData, PtCallba { nsTextAreaWidget *me = (nsTextAreaWidget *) aData; /* Mozilla object that created the event */ -//PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::RawEventHandler\n")); - if( aCbInfo->reason == Pt_CB_RAW ) { PhEvent_t* event = aCbInfo->event; @@ -148,21 +142,9 @@ int nsTextAreaWidget::RawEventHandler(PtWidget_t *aWidget, void *aData, PtCallba break; } default: - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::RawEventHandler Unknown event\n")); break; } } return (Pt_CONTINUE); } - -#if 0 -int nsTextAreaWidget::handle_activate_event (PtWidget_t *aWidget, void *aData, PtCallbackInfo_t *aCbinfo ) -{ - nsTextAreaWidget *me = (nsTextAreaWidget *) aData; - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextAreaWidget::handle_activate_event me=<%p> - Not Implemented\n",me)); - - return (Pt_CONTINUE); -} -#endif diff --git a/widget/src/photon/nsTextHelper.cpp b/widget/src/photon/nsTextHelper.cpp index a71c5eeb8099..09b839a8e4d1 100644 --- a/widget/src/photon/nsTextHelper.cpp +++ b/widget/src/photon/nsTextHelper.cpp @@ -32,8 +32,6 @@ NS_METHOD nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::PreCreateWidget\n")); - if (nsnull != aInitData) { nsTextWidgetInitData* data = (nsTextWidgetInitData *) aInitData; @@ -48,8 +46,6 @@ NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars) { PtArg_t arg[2]; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetMaxLength to %d\n", aChars)); - if (mWidget) { PtSetArg(&arg[0], Pt_ARG_MAX_LENGTH, aChars, 0); @@ -61,8 +57,6 @@ NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars) NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::GetText\n")); - PtArg_t arg[2]; int length; char *string; @@ -91,8 +85,6 @@ NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize) { NS_ALLOC_STR_BUF(buf, aText, aText.Length()); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetText to <%s> for <%p>\n", buf, mWidget)); - PtSetArg(&arg[0], Pt_ARG_TEXT_STRING, buf, 0); PtSetResources(mWidget, 1, arg); @@ -105,21 +97,13 @@ NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize) NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::InsertText from %d to %d\n", aStartPos, aEndPos)); - PtArg_t arg[2]; - int ret; nsString currentText; PRUint32 currentTextLength; if (mWidget) { NS_ALLOC_STR_BUF(buf, aText, aText.Length()); - ret=PtTextModifyText(mWidget,0,0,aStartPos,buf,aText.Length()); - if (!ret) - { - PR_LOG(PhWidLog, PR_LOG_ERROR,("nsTextHelper::InsertText failed in call to PtTextModifyText\n")); - } - + PtTextModifyText(mWidget,0,0,aStartPos,buf,aText.Length()); NS_FREE_STR_BUF(buf); } aActualSize = aText.Length(); @@ -133,7 +117,6 @@ NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, P NS_METHOD nsTextHelper::RemoveText() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::RemoveText\n")); PtArg_t arg[2]; mText.SetLength(0); @@ -155,8 +138,6 @@ NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword) NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldFlag) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetReadOnnly %d %d\n", aReadOnlyFlag, mIsReadOnly)); - PtArg_t arg[2]; int temp; @@ -180,8 +161,6 @@ NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldFlag) NS_METHOD nsTextHelper::SelectAll() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SelectAll\n")); - int start, end; if (mWidget) @@ -196,18 +175,15 @@ NS_METHOD nsTextHelper::SelectAll() NS_METHOD nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetSelection %d to %d\n", aStartSel, aEndSel)); - /* The text widget is 0 based! */ if (mWidget) { - int start, end, err=0; + int start, end; start = aStartSel; end = aEndSel; - err=PtTextSetSelection(mWidget, &start, &end); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetSelection after err=%d start=%d end=%d\n", err, start, end)); + PtTextSetSelection(mWidget, &start, &end); } return NS_OK; @@ -229,15 +205,11 @@ NS_METHOD nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) } - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::GetSelection aStartSel=<%d> aEndSel=<%d>\n", *aStartSel, *aEndSel)); - return NS_OK; } NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::SetCaretPosition at %d", aPosition)); - PtArg_t arg[2]; if (mWidget) @@ -253,8 +225,6 @@ NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition) NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPos) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::GetCaretPosition\n")); - PtArg_t arg[2]; short *CaretPosition; @@ -266,8 +236,6 @@ NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPos) aPos = PRUint32(*CaretPosition); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::GetCaretPosition aPos=<%d>\n", aPos)); - return NS_OK; } @@ -290,5 +258,4 @@ nsTextHelper::nsTextHelper() : nsWidget(), nsITextAreaWidget(), nsITextWidget() //------------------------------------------------------------------------- nsTextHelper::~nsTextHelper() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextHelper::~nsTextHelper Destructor called for <%p>\n", mWidget)); } diff --git a/widget/src/photon/nsTextWidget.cpp b/widget/src/photon/nsTextWidget.cpp index 97f3a8575f25..7b7079135c40 100644 --- a/widget/src/photon/nsTextWidget.cpp +++ b/widget/src/photon/nsTextWidget.cpp @@ -61,7 +61,6 @@ nsTextWidget::nsTextWidget() : nsTextHelper() //------------------------------------------------------------------------- nsTextWidget::~nsTextWidget() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::~nsTextWidget Destructor called.\n")); } //------------------------------------------------------------------------- @@ -89,13 +88,11 @@ nsresult nsTextWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) //------------------------------------------------------------------------- PRBool nsTextWidget::OnPaint() { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::OnPaint - Not Implemented\n")); return PR_FALSE; } PRBool nsTextWidget::OnResize(nsRect &aWindowRect) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::OnResize - Not Implemented\n")); return PR_FALSE; } @@ -106,8 +103,6 @@ NS_METHOD nsTextWidget::CreateNative( PtWidget_t* aParent ) PhPoint_t pos; PhDim_t dim; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::CreateNative")); - pos.x = mBounds.x; pos.y = mBounds.y; dim.w = mBounds.width - 4; // Correct for border width @@ -133,8 +128,6 @@ int nsTextWidget::RawEventHandler(PtWidget_t *aWidget, void *aData, PtCallbackIn { nsTextWidget *me = (nsTextWidget *) aData; /* Mozilla object that created the event */ -//PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::RawEventHandler\n")); - if( aCbInfo->reason == Pt_CB_RAW ) { PhEvent_t* event = aCbInfo->event; @@ -148,7 +141,6 @@ int nsTextWidget::RawEventHandler(PtWidget_t *aWidget, void *aData, PtCallbackIn break; } default: - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::RawEventHandler Unknown event\n")); break; } } @@ -158,9 +150,5 @@ int nsTextWidget::RawEventHandler(PtWidget_t *aWidget, void *aData, PtCallbackIn int nsTextWidget::handle_activate_event (PtWidget_t *aWidget, void *aData, PtCallbackInfo_t *aCbinfo ) { - nsTextWidget *me = (nsTextWidget *) aData; - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsTextWidget::handle_activate_event me=<%p> - Not Implemented\n",me)); - return (Pt_CONTINUE); } diff --git a/widget/src/photon/nsToolkit.cpp b/widget/src/photon/nsToolkit.cpp index 7dd665e992e0..aa30ec13bae0 100644 --- a/widget/src/photon/nsToolkit.cpp +++ b/widget/src/photon/nsToolkit.cpp @@ -43,8 +43,6 @@ NS_IMPL_ISUPPORTS1(nsToolkit,nsIToolkit); //------------------------------------------------------------------------- nsToolkit::nsToolkit() { -// PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsToolkit::nsToolkit this=<%p>\n", this)); - NS_INIT_REFCNT(); } @@ -58,7 +56,6 @@ nsToolkit::~nsToolkit() { // Remove the TLS reference to the toolkit... PR_SetThreadPrivate(gToolkitTLSIndex, nsnull); -// PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsToolkit::~nsToolkit this=<%p>\n", this)); } @@ -81,7 +78,6 @@ NS_METHOD nsToolkit::Init(PRThread *aThread) mDefaultPhotonDrawContext = PhDCGetCurrent(); } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsToolkit::Init this=<%p> aThread=<%p>\n", this, aThread)); return NS_OK; } @@ -96,22 +92,12 @@ PhDrawContext_t *nsToolkit::GetDefaultPhotonDrawContext() return nsToolkit::mDefaultPhotonDrawContext; } -PhPoint_t nsToolkit::GetConsoleOffset() -{ +PhPoint_t nsToolkit::GetConsoleOffset( ) { PhRect_t console; - char *p = NULL; - int inp_grp = 0; - - p = getenv("PHIG"); - if (p) - { - inp_grp = atoi(p); - if (PhWindowQueryVisible( Ph_QUERY_GRAPHICS, 0, inp_grp, &console ) == 0) - return(PhPoint_t) {console.ul.x, console.ul.y}; - } - + if( PhWindowQueryVisible( Ph_QUERY_GRAPHICS, 0, 1, &console ) == 0 ) + return(PhPoint_t) {console.ul.x, console.ul.y}; return(PhPoint_t) {0,0}; -} + } //------------------------------------------------------------------------- // diff --git a/widget/src/photon/nsWidget.cpp b/widget/src/photon/nsWidget.cpp index 4802e71c5570..571ef2f983cd 100644 --- a/widget/src/photon/nsWidget.cpp +++ b/widget/src/photon/nsWidget.cpp @@ -93,16 +93,8 @@ extern unsigned long IgnoreEvent; //#define ENABLE_DAMAGE_QUEUE_HOLDOFF -/* Enable experimental direct draw code, this bypasses PtDamageExtent */ -/* and calls doPaint method which calls nsWindow::RawDrawFunc */ -//#define ENABLE_DOPAINT - nsWidget::nsWidget() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::nsWidget this=(%p)\n", this)); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("%p C nsWidget CONSTRUCTOR LEAK_CHECK time=(%ld)\n", this, PR_IntervalNow())); - // XXX Shouldn't this be done in nsBaseWidget? // NS_INIT_REFCNT(); @@ -111,12 +103,11 @@ nsWidget::nsWidget() nsnull, NS_GET_IID(nsILookAndFeel), (void**)&sLookAndFeel)) - sLookAndFeel = nsnull; - } + sLookAndFeel = nsnull; + } - if (sLookAndFeel) - sLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground, - mBackground); + if( sLookAndFeel ) + sLookAndFeel->GetColor( nsILookAndFeel::eColor_WindowBackground, mBackground ); mWidget = nsnull; mParent = nsnull; @@ -147,24 +138,17 @@ nsWidget::nsWidget() } -nsWidget::~nsWidget() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::~nsWidget this=(%p) mWidget=<%p>\n", this, mWidget)); - +nsWidget::~nsWidget( ) { NS_IF_RELEASE(mUpdateArea); // it's safe to always call Destroy() because it will only allow itself // to be called once Destroy(); - if (!sWidgetCount--) - { - NS_IF_RELEASE(sLookAndFeel); - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("%p D nsWidget DESTRUCTOR LEAK_CHECK time=(%ld)\n", this, PR_IntervalNow())); - -} + if( !sWidgetCount-- ) { + NS_IF_RELEASE( sLookAndFeel ); + } + } //------------------------------------------------------------------------- // @@ -173,25 +157,19 @@ nsWidget::~nsWidget() //------------------------------------------------------------------------- NS_IMPL_ISUPPORTS_INHERITED(nsWidget, nsBaseWidget, nsIKBStateControl) -NS_METHOD nsWidget::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WidgetToScreen - Not Implemented.\n" )); - - if (mWidget) - { +NS_METHOD nsWidget::WidgetToScreen( const nsRect& aOldRect, nsRect& aNewRect ) { + if( mWidget ) { /* This is NOT correct */ aNewRect.x = aOldRect.x; aNewRect.y = aOldRect.y; - } - + } return NS_OK; -} + } -NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::ScreenToWidget - Not Implemented.\n" )); +// nsWidget::ScreenToWidget - Not Implemented +NS_METHOD nsWidget::ScreenToWidget( const nsRect& aOldRect, nsRect& aNewRect ) { return NS_OK; -} + } //------------------------------------------------------------------------- // @@ -199,13 +177,10 @@ NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) // //------------------------------------------------------------------------- -NS_IMETHODIMP nsWidget::Destroy(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Destroy this=<%p> mRefCnt=<%d> mWidget=<%p> mIsDestroying=<%d>\n",this,mRefCnt, mWidget, mIsDestroying)); +NS_IMETHODIMP nsWidget::Destroy( void ) { // make sure we don't call this more than once. - if (mIsDestroying) - return NS_OK; + if( mIsDestroying ) return NS_OK; // ok, set our state mIsDestroying = PR_TRUE; @@ -218,54 +193,38 @@ NS_IMETHODIMP nsWidget::Destroy(void) DestroyNative(); // make sure to call the OnDestroy if it hasn't been called yet - if (mOnDestroyCalled == PR_FALSE) - OnDestroy(); + if( mOnDestroyCalled == PR_FALSE ) OnDestroy(); // make sure no callbacks happen mEventCallback = nsnull; return NS_OK; -} + } // this is the function that will destroy the native windows for this widget. /* virtual */ -void nsWidget::DestroyNative(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::DestroyNative this=<%p> mRefCnt=<%d> mWidget=<%p>\n", this, mRefCnt, mWidget )); - - if (mWidget) - { +void nsWidget::DestroyNative( void ) { + if( mWidget ) { // prevent the widget from causing additional events mEventCallback = nsnull; RemoveDamagedWidget(mWidget); PtDestroyWidget( mWidget ); mWidget = nsnull; - } -} + } + } // make sure that we clean up here -void nsWidget::OnDestroy() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::OnDestroy this=<%p> mRefCnt=<%d>\n", this, mRefCnt )); - +void nsWidget::OnDestroy( ) { mOnDestroyCalled = PR_TRUE; // release references to children, device context, toolkit + app shell nsBaseWidget::OnDestroy(); -#if 1 nsCOMPtr kungFuDeathGrip = this; DispatchStandardEvent(NS_DESTROY); -#else - NS_ADDREF_THIS(); - DispatchStandardEvent(NS_DESTROY); - NS_RELEASE_THIS(); -#endif - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::OnDestroy Exiting this=<%p> mRefCnt=<%d>\n", this, mRefCnt )); - -} + } //------------------------------------------------------------------------- // @@ -273,17 +232,11 @@ void nsWidget::OnDestroy() // //------------------------------------------------------------------------- -nsIWidget *nsWidget::GetParent(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParent - this=<%p> mParent=<%p> \n", this, mParent)); - +nsIWidget *nsWidget::GetParent( void ) { nsIWidget* result = mParent; - if (mParent) { - NS_ADDREF(result); - } - + if( mParent ) NS_ADDREF( result ); return result; -} + } @@ -295,13 +248,14 @@ nsIWidget *nsWidget::GetParent(void) // ////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsWidget::ResetInputState() -{ - nsresult res = NS_OK; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::ResetInputState - Not Implemented this=<%p>\n", this)); +NS_IMETHODIMP nsWidget::ResetInputState( ) { + return NS_OK; + } - return res; -} +// to be implemented +NS_IMETHODIMP nsWidget::PasswordFieldInit( ) { + return NS_OK; + } //------------------------------------------------------------------------- // @@ -309,17 +263,9 @@ NS_IMETHODIMP nsWidget::ResetInputState() // //------------------------------------------------------------------------- -NS_METHOD nsWidget::Show(PRBool bState) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Show this=<%p> State=<%d> mRefCnt=<%d> mWidget=<%p>\n", this, bState, mRefCnt, mWidget)); +NS_METHOD nsWidget::Show( PRBool bState ) { - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Show - mWidget is NULL!\n" )); - return NS_OK; // Will be null durring printing - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Show this=<%p> IsRealized=<%d>\n", this, PtWidgetIsRealized(mWidget) )); + if( !mWidget ) return NS_OK; // Will be null durring printing /* Note: Calling PtWidgetIsRealized(mWidget) is not valid because usually the parent window has not been realized yet when we get into this code. Also @@ -329,62 +275,42 @@ the PtRealizeWidget functions */ PtArg_t arg; - if (bState) - { - int err = 0; + if( bState ) { + EnableDamage( mWidget, PR_FALSE ); + PtRealizeWidget(mWidget); - EnableDamage( mWidget, PR_FALSE ); - err=PtRealizeWidget(mWidget); - if (err == -1) - { - PtWidget_t *parent = PtWidgetParent(mWidget); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Show Failed to Realize this=<%p> mWidget=<%p> mWidget->Parent=<%p> parent->IsRealized=<%d> \n", this, mWidget,parent, PtWidgetIsRealized(parent) )); - //printf("nsWidget::Show Failed to Realize this=<%p> mWidget=<%p> mWidget->Parent=<%p> parent->IsRealized=<%d> \n", this, mWidget,parent, PtWidgetIsRealized(parent) ); - } + if( mWidget->rid == -1 ) { + PtRegionWidget_t *region = (PtRegionWidget_t *) mWidget; - if (mWidget->rid == -1) - { - PtRegionWidget_t *region = (PtRegionWidget_t *) mWidget; + NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n"); + mShown = PR_FALSE; + return NS_ERROR_FAILURE; + } - printf("nsWidget::errno = %s\n", strerror(errno)); - printf("nsWidget PtRealizeWidget <%p> rid=<%d> parent rid <%d>\n", mWidget, mWidget->rid, region->parent); - NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n"); - //DebugBreak(); - //abort(); - mShown = PR_FALSE; - return NS_ERROR_FAILURE; - } + EnableDamage( mWidget, PR_TRUE ); - EnableDamage( mWidget, PR_TRUE ); + PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE); + PtSetResources(mWidget, 1, &arg); - PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE); - PtSetResources(mWidget, 1, &arg); - - /* Always add it to the Widget Damage Queue when it gets realized */ - QueueWidgetDamage(); - } - else - { + /* Always add it to the Widget Damage Queue when it gets realized */ + QueueWidgetDamage(); + } + else { EnableDamage( mWidget, PR_FALSE ); - if (PtWidgetIsClass(mWidget, PtRegion)) - { + if( PtWidgetIsClass( mWidget, PtRegion ) ) { PtWidget_t *w=nsnull, *w1=nsnull; gLastUnrealizedRegion = PtWidgetRid(mWidget); w = mWidget; - while (1) - { + while( 1 ) { w1 = PtWidgetParent(w); - if (w1==0) - { + if( w1 == 0 ) { gLastUnrealizedRegionsParent = PtWidgetRid(w); break; - } + } w = w1; - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Show _EXPOSE gLastUnrealizedRegion=<%d> gLastUnrealizedRegionsParent=<%d> \n", gLastUnrealizedRegion, gLastUnrealizedRegionsParent)); + } } PtUnrealizeWidget(mWidget); @@ -392,210 +318,147 @@ the PtRealizeWidget functions */ PtSetArg(&arg, Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE); PtSetResources(mWidget, 1, &arg); - } + } mShown = bState; return NS_OK; -} + } -NS_IMETHODIMP nsWidget::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CaptureRollupEvents() this = %p , doCapture = %i\n", this, aDoCapture)); - /* This got moved to nsWindow.cpp */ +/* This got moved to nsWindow.cpp */ +NS_IMETHODIMP nsWidget::CaptureRollupEvents( nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent ) { return NS_OK; -} + } -NS_IMETHODIMP nsWidget::SetModal(PRBool aModal) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetModal - Not Implemented\n")); +// nsWidget::SetModal - Not Implemented +NS_IMETHODIMP nsWidget::SetModal( PRBool aModal ) { return NS_ERROR_FAILURE; -} + } -NS_METHOD nsWidget::IsVisible(PRBool &aState) -{ - if (mWidget) - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::IsVisible this=<%p> IsRealized=<%d> mShown=<%d>\n", this, PtWidgetIsRealized(mWidget), mShown)); - - /* Try a simpler algorthm */ +NS_METHOD nsWidget::IsVisible( PRBool &aState ) { + /* Try a simpler algorithm */ aState = mShown; - return NS_OK; -} + } //------------------------------------------------------------------------- // // Constrain a potential move to see if it fits onscreen // //------------------------------------------------------------------------- -NS_METHOD nsWidget::ConstrainPosition(PRInt32 *aX, PRInt32 *aY) -{ +NS_METHOD nsWidget::ConstrainPosition( PRInt32 *aX, PRInt32 *aY ) { return NS_OK; -} + } //------------------------------------------------------------------------- // // Move this component // //------------------------------------------------------------------------- -NS_METHOD nsWidget::Move(PRInt32 aX, PRInt32 aY) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Move (%p) from (%ld,%ld) to (%ld,%ld)\n", this, mBounds.x, mBounds.y, aX, aY )); +NS_METHOD nsWidget::Move( PRInt32 aX, PRInt32 aY ) { - if (( mBounds.x == aX ) && ( mBounds.y == aY )) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Move already there.\n" )); - return NS_OK; - } + if( ( mBounds.x == aX ) && ( mBounds.y == aY ) ) return NS_OK; mBounds.x = aX; mBounds.y = aY; - if (mWidget) - { - PtArg_t arg; - PhPoint_t *oldpos; - PhPoint_t pos; + if(mWidget) { + PtArg_t arg; + PhPoint_t *oldpos; + PhPoint_t pos; - pos.x = aX; - pos.y = aY; + pos.x = aX; + pos.y = aY; - EnableDamage( mWidget, PR_FALSE ); +// EnableDamage( mWidget, PR_FALSE ); PtSetArg( &arg, Pt_ARG_POS, &oldpos, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - if(( oldpos->x != pos.x ) || ( oldpos->y != pos.y )) - { - int err; - PtSetArg( &arg, Pt_ARG_POS, &pos, 0 ); - err=PtSetResources( mWidget, 1, &arg ); - if (err==-1) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::Move ERROR in PtSetRes (%p) to (%ld,%ld)\n", this, aX, aY )); - } - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Move (%p) already at (%d,%d)\n", this, pos.x, pos.y )); - } - } + PtGetResources( mWidget, 1, &arg ); - EnableDamage( mWidget, PR_TRUE ); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Move - mWidget is NULL!\n" )); - } + + if(( oldpos->x != pos.x ) || ( oldpos->y != pos.y )) { + PtSetArg( &arg, Pt_ARG_POS, &pos, 0 ); + PtSetResources( mWidget, 1, &arg ); + } + +// EnableDamage( mWidget, PR_TRUE ); + } return NS_OK; } -NS_METHOD nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Resize (%p) to <%d, %d>\n", this, aWidth, aHeight )); +NS_METHOD nsWidget::Resize( PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) { + + if( ( mBounds.width != aWidth ) || ( mBounds.height != aHeight ) ) { - if(( mBounds.width != aWidth ) || ( mBounds.height != aHeight )) - { mBounds.width = aWidth; mBounds.height = aHeight; - if( mWidget ) - { + if( mWidget ) { PtArg_t arg; int *border; PtSetArg( &arg, Pt_ARG_BORDER_WIDTH, &border, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - /* Add the border to the size of the widget */ -#if 1 - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Resize broder size =<%d>\n", border)); - PhDim_t dim = {aWidth - 2*(*border), aHeight - 2*(*border)}; -#else - PhDim_t dim = {0,0}; - - dim.w = aWidth; - dim.h = aHeight; -#endif - EnableDamage( mWidget, PR_FALSE ); + PtGetResources( mWidget, 1, &arg ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Resize (%p) actually resizing to <%d, %d>\n", this, dim.w, dim.h )); + /* Add the border to the size of the widget */ + PhDim_t dim = {aWidth - 2*(*border), aHeight - 2*(*border)}; + EnableDamage( mWidget, PR_FALSE ); - PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 ); - PtSetResources( mWidget, 1, &arg ); + PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 ); + PtSetResources( mWidget, 1, &arg ); - EnableDamage( mWidget, PR_TRUE ); - } - -#if 0 - /* GTK Does not bother doing this... */ - if (mShown) - Invalidate( aRepaint ); -#endif - - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Resize FAILED- mWidget is NULL!\n" )); + EnableDamage( mWidget, PR_TRUE ); + } + } + return NS_OK; } - } - - return NS_OK; -} -NS_METHOD nsWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) -{ - Move(aX,aY); - Resize(aWidth,aHeight,aRepaint); - return NS_OK; -} +NS_METHOD nsWidget::Resize( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) { + Move(aX,aY); + Resize(aWidth,aHeight,aRepaint); + return NS_OK; + } //------------------------------------------------------------------------- // // Send a resize message to the listener // //------------------------------------------------------------------------- -PRBool nsWidget::OnResize(nsRect &aRect) -{ +PRBool nsWidget::OnResize( nsRect &aRect ) { + PRBool result = PR_FALSE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::OnResize\n")); - // call the event callback - if (mEventCallback) - { - nsSizeEvent event; + if( mEventCallback ) { + nsSizeEvent event; - /* Stole this from GTK */ - InitEvent(event, NS_SIZE); - event.eventStructType = NS_SIZE_EVENT; + /* Stole this from GTK */ + InitEvent(event, NS_SIZE); + event.eventStructType = NS_SIZE_EVENT; - nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height); - event.windowSize = foo; + nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height); + event.windowSize = foo; - event.point.x = 0; - event.point.y = 0; - event.mWinWidth = aRect.width; - event.mWinHeight = aRect.height; + event.point.x = 0; + event.point.y = 0; + event.mWinWidth = aRect.width; + event.mWinHeight = aRect.height; - NS_ADDREF_THIS(); - result = DispatchWindowEvent(&event); - NS_RELEASE_THIS(); - delete foo; - } + NS_ADDREF_THIS(); + result = DispatchWindowEvent(&event); + NS_RELEASE_THIS(); + delete foo; + } - return result; -} + return result; + } //------ // Move //------ -PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::OnMove to (%d,%d)\n", aX, aY)); - +PRBool nsWidget::OnMove( PRInt32 aX, PRInt32 aY ) { nsGUIEvent event; InitEvent(event, NS_MOVE); @@ -605,32 +468,20 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY) PRBool result = DispatchWindowEvent(&event); return result; -} + } //------------------------------------------------------------------------- // // Enable/disable this component // //------------------------------------------------------------------------- -NS_METHOD nsWidget::Enable(PRBool bState) -{ - if (mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Enable this=<%p> being set to %d\n", this, bState)); - +NS_METHOD nsWidget::Enable( PRBool bState ) { + if( mWidget ) { PtArg_t arg; - if( bState ) - PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_BLOCKED ); - else - PtSetArg( &arg, Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED ); - + if( bState ) PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_BLOCKED ); + else PtSetArg( &arg, Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED ); PtSetResources( mWidget, 1, &arg ); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Enable - mWidget is NULL!\n" )); - } - + } return NS_OK; } @@ -640,38 +491,26 @@ NS_METHOD nsWidget::Enable(PRBool bState) // Give the focus to this component // //------------------------------------------------------------------------- -NS_METHOD nsWidget::SetFocus(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFocus - mWidget=<%p>!\n", mWidget)); +NS_METHOD nsWidget::SetFocus( void ) { // call this so that any cleanup will happen that needs to... LooseFocus(); - if (mWidget) - { - if (!PtIsFocused(mWidget)) - PtContainerGiveFocus( mWidget, NULL ); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFocus - mWidget is NULL!\n" )); - } + if( mWidget ) { + PtContainerGiveFocus( mWidget, NULL ); + } return NS_OK; } -void nsWidget::LooseFocus(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::LooseFocus - this=<%p> mWidget=<%p> mHasFocus=<%d>\n", this, mWidget, mHasFocus)); +void nsWidget::LooseFocus( void ) { // doesn't do anything. needed for nsWindow housekeeping, really. - if (mHasFocus == PR_FALSE) { - return; - } + if( mHasFocus == PR_FALSE ) return; mHasFocus = PR_FALSE; -} + } //------------------------------------------------------------------------- @@ -679,12 +518,10 @@ void nsWidget::LooseFocus(void) // Get this component font // //------------------------------------------------------------------------- -nsIFontMetrics *nsWidget::GetFont(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetFont - Not Implemented.\n" )); +nsIFontMetrics *nsWidget::GetFont( void ) { NS_NOTYETIMPLEMENTED("nsWidget::GetFont"); return nsnull; -} + } //------------------------------------------------------------------------- @@ -692,407 +529,219 @@ nsIFontMetrics *nsWidget::GetFont(void) // Set this component font // //------------------------------------------------------------------------- -NS_METHOD nsWidget::SetFont(const nsFont &aFont) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFont\n" )); -#if 1 -{ - char *str = nsnull; - str = aFont.name.ToNewCString(); - if (str) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFont aFont.name=<%s>\n",str)); - delete [] str; - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFont aFont.size=<%d>\n",aFont.size)); - -} -#endif +NS_METHOD nsWidget::SetFont( const nsFont &aFont ) { nsIFontMetrics* mFontMetrics; mContext->GetMetricsFor(aFont, mFontMetrics); - if (mFontMetrics) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFont Get a FontMetrics\n" )); - PtArg_t arg; + if( mFontMetrics ) { + PtArg_t arg; - nsFontHandle aFontHandle; - mFontMetrics->GetFontHandle(aFontHandle); - nsString *aString; - aString = (nsString *) aFontHandle; - char *str = aString->ToNewCString(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetFont Get a FontMetrics font name=<%s>\n",str )); + nsFontHandle aFontHandle; + mFontMetrics->GetFontHandle(aFontHandle); + nsString *aString; + aString = (nsString *) aFontHandle; + char *str = aString->ToNewCString(); - PtSetArg( &arg, Pt_ARG_TEXT_FONT, str, 0 ); - PtSetResources( mWidget, 1, &arg ); + PtSetArg( &arg, Pt_ARG_TEXT_FONT, str, 0 ); + PtSetResources( mWidget, 1, &arg ); - delete [] str; - NS_RELEASE(mFontMetrics); - } - - return NS_OK; -} + delete [] str; + NS_RELEASE(mFontMetrics); + } + return NS_OK; + } -NS_METHOD nsWidget::SetBackgroundColor( const nscolor &aColor ) -{ +NS_METHOD nsWidget::SetBackgroundColor( const nscolor &aColor ) { nsBaseWidget::SetBackgroundColor( aColor ); - if( mWidget ) - { + if( mWidget ) { PtArg_t arg; PgColor_t color = NS_TO_PH_RGB( aColor ); PtSetArg( &arg, Pt_ARG_FILL_COLOR, color, 0 ); PtSetResources( mWidget, 1, &arg ); - } + } return NS_OK; -} + } //------------------------------------------------------------------------- // // Set this component cursor // //------------------------------------------------------------------------- -NS_METHOD nsWidget::SetCursor(nsCursor aCursor) -{ +NS_METHOD nsWidget::SetCursor( nsCursor aCursor ) { unsigned short curs = 0; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetCursor to <%d> was <%d>\n", aCursor, mCursor)); + PgColor_t color = Ph_CURSOR_DEFAULT_COLOR; // Only change cursor if it's changing - if (aCursor != mCursor) { - switch( aCursor ) - { - case eCursor_sizeNW: - curs = Ph_CURSOR_DRAG_TL; - break; - case eCursor_sizeSE: - curs = Ph_CURSOR_DRAG_BR; - break; - case eCursor_sizeNE: - curs = Ph_CURSOR_DRAG_TL; - break; - case eCursor_sizeSW: - curs = Ph_CURSOR_DRAG_BL; - break; + if( aCursor != mCursor ) { + switch( aCursor ) { + case eCursor_sizeNW: + curs = Ph_CURSOR_DRAG_TL; + break; + case eCursor_sizeSE: + curs = Ph_CURSOR_DRAG_BR; + break; + case eCursor_sizeNE: + curs = Ph_CURSOR_DRAG_TL; + break; + case eCursor_sizeSW: + curs = Ph_CURSOR_DRAG_BL; + break; - case eCursor_crosshair: - curs = Ph_CURSOR_CROSSHAIR; - break; + case eCursor_crosshair: + curs = Ph_CURSOR_CROSSHAIR; + break; - case eCursor_copy: - case eCursor_alias: - case eCursor_context_menu: - break; + case eCursor_copy: + case eCursor_alias: + case eCursor_context_menu: + break; - case eCursor_cell: - break; + case eCursor_cell: + break; - case eCursor_spinning: - break; + case eCursor_spinning: + break; - case eCursor_count_up: - case eCursor_count_down: - case eCursor_count_up_down: - break; + case eCursor_count_up: + case eCursor_count_down: + case eCursor_count_up_down: + break; - case eCursor_move: - curs = Ph_CURSOR_MOVE; - break; + case eCursor_move: + curs = Ph_CURSOR_MOVE; + break; - case eCursor_help: - curs = Ph_CURSOR_QUESTION_POINT; - break; + case eCursor_help: + curs = Ph_CURSOR_QUESTION_POINT; + break; - case eCursor_grab: - case eCursor_grabbing: - curs = Ph_CURSOR_FINGER; - break; + case eCursor_grab: + case eCursor_grabbing: + curs = Ph_CURSOR_FINGER; + break; - case eCursor_select: - curs = Ph_CURSOR_INSERT; - break; + case eCursor_select: + curs = Ph_CURSOR_INSERT; + color = Pg_BLACK; + break; - case eCursor_wait: - curs = Ph_CURSOR_LONG_WAIT; - break; + case eCursor_wait: + curs = Ph_CURSOR_LONG_WAIT; + break; - case eCursor_hyperlink: - curs = Ph_CURSOR_FINGER; - break; + case eCursor_hyperlink: + curs = Ph_CURSOR_FINGER; + break; - case eCursor_standard: - curs = Ph_CURSOR_POINTER; - break; + case eCursor_standard: + curs = Ph_CURSOR_POINTER; + break; - case eCursor_sizeWE: - curs = Ph_CURSOR_DRAG_HORIZONTAL; - break; + case eCursor_sizeWE: + curs = Ph_CURSOR_DRAG_HORIZONTAL; + break; - case eCursor_sizeNS: - curs = Ph_CURSOR_DRAG_VERTICAL; - break; + case eCursor_sizeNS: + curs = Ph_CURSOR_DRAG_VERTICAL; + break; - // REVISIT - Photon does not have the following cursor types... - case eCursor_arrow_north: - case eCursor_arrow_north_plus: - curs = Ph_CURSOR_DRAG_TOP; - break; + // REVISIT - Photon does not have the following cursor types... + case eCursor_arrow_north: + case eCursor_arrow_north_plus: + curs = Ph_CURSOR_DRAG_TOP; + break; - case eCursor_arrow_south: - case eCursor_arrow_south_plus: - curs = Ph_CURSOR_DRAG_BOTTOM; - break; + case eCursor_arrow_south: + case eCursor_arrow_south_plus: + curs = Ph_CURSOR_DRAG_BOTTOM; + break; - case eCursor_arrow_east: - case eCursor_arrow_east_plus: - curs = Ph_CURSOR_DRAG_RIGHT; - break; + case eCursor_arrow_east: + case eCursor_arrow_east_plus: + curs = Ph_CURSOR_DRAG_RIGHT; + break; - case eCursor_arrow_west: - case eCursor_arrow_west_plus: - curs = Ph_CURSOR_DRAG_LEFT; - break; + case eCursor_arrow_west: + case eCursor_arrow_west_plus: + curs = Ph_CURSOR_DRAG_LEFT; + break; - default: - NS_ASSERTION(0, "Invalid cursor type"); - break; - } + default: + NS_ASSERTION(0, "Invalid cursor type"); + break; + } - if( mWidget && curs) - { - PtArg_t arg; + if( mWidget && curs ) { + PtArg_t args[2]; - PtSetArg( &arg, Pt_ARG_CURSOR_TYPE, curs, 0 ); - PtSetResources( mWidget, 1, &arg ); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetCursor - mWidget is NULL!\n" )); - } - - mCursor = aCursor; + PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, curs, 0 ); + PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR, color, 0 ); + PtSetResources( mWidget, 2, args ); + } + mCursor = aCursor; + } - } - return NS_OK; -} - - -NS_METHOD nsWidget::Invalidate(PRBool aIsSynchronous) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 1 this=<%p> IsSynch=<%d> mBounds=(%d,%d,%d,%d)\n", this, aIsSynchronous, - mBounds.x, mBounds.y, mBounds.width, mBounds.height)); - - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 1 - mWidget is NULL!\n" )); - return NS_OK; // mWidget will be null during printing. - } - - if (!PtWidgetIsRealized(mWidget)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 1 - mWidget is not realized\n")); - return NS_OK; - } - - nsRect rect = mBounds; - PtWidget_t *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - long widgetFlags = PtWidgetFlags(aWidget); - - /* Damage has to be relative Widget coords */ - mUpdateArea->SetTo( rect.x - mBounds.x, rect.y - mBounds.y, rect.width, rect.height ); - - if (aIsSynchronous) - UpdateWidgetDamage(); - else - QueueWidgetDamage(); - - return NS_OK; -} - -// This is a experimental routine to see if I can bypass calls to PtDamageExtent -// and call RawDrawFunc directly... -NS_METHOD nsWidget::doPaint() -{ - nsresult res = NS_OK; - PhTile_t * nativeRegion = nsnull; - PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::doPaint this=<%p> mWidget=<%p> widget=<%p> PtWidgetIsRealized(widget)=<%d>\n", this, mWidget, widget,PtWidgetIsRealized(widget) )); - - if ((widget) && (PtWidgetIsRealized(widget))) - { - if (mUpdateArea && (!mUpdateArea->IsEmpty())) - { - PhTile_t * nativeRegion = nsnull; - - mUpdateArea->GetNativeRegion((void *&) nativeRegion ); - - PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - - nsWindow::RawDrawFunc(widget, PhCopyTiles(nativeRegion)); - } - else - { - /* mUpdateArea is Empty so re-draw the whole widget */ - PhTile_t *nativeRegion = PhGetTile(); - /* This rect probably needs to be differnt depending on what this */ - /* widget really is.... widget vs PtWindow vs PtRawDrawContainer */ - nativeRegion->rect.ul.x = mBounds.x; - nativeRegion->rect.ul.y = mBounds.y; - nativeRegion->rect.lr.x = mBounds.width - 1; - nativeRegion->rect.lr.y = mBounds.height - 1; - nativeRegion->next = NULL; - - nsWindow::RawDrawFunc(widget, nativeRegion); + return NS_OK; } - } - else - { - //printf("nsWidget::doPaint ERROR widget=<%p> PtWidgetIsRealized(widget)=<%d>\n", widget, PtWidgetIsRealized(widget)); - } - - return res; -} -NS_METHOD nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 2 this=<%p> dmg rect=(%ld,%ld,%ld,%ld) IsSync=<%d>\n", this, aRect.x, aRect.y, aRect.width, aRect.height, aIsSynchronous)); +NS_METHOD nsWidget::Invalidate( PRBool aIsSynchronous ) { - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 2 - mWidget is NULL!\n" )); - return NS_OK; // mWidget will be null during printing. - } + if( !mWidget ) return NS_OK; // mWidget will be null during printing + if( !PtWidgetIsRealized( mWidget ) ) return NS_OK; + + nsRect rect = mBounds; + PtWidget_t *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); + long widgetFlags = PtWidgetFlags(aWidget); + + /* Damage has to be relative Widget coords */ + mUpdateArea->SetTo( rect.x - mBounds.x, rect.y - mBounds.y, rect.width, rect.height ); + + if( aIsSynchronous ) UpdateWidgetDamage(); + else QueueWidgetDamage(); + + return NS_OK; + } + +NS_METHOD nsWidget::Invalidate( const nsRect & aRect, PRBool aIsSynchronous ) { + + if( !mWidget ) return NS_OK; // mWidget will be null during printing + if( !PtWidgetIsRealized( mWidget ) ) return NS_OK; - if (!PtWidgetIsRealized(mWidget)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 2 - mWidget is not realized\n")); - return NS_OK; -// return NS_ERROR_FAILURE; - } - - nsRect rect = aRect; + nsRect rect = aRect; - /* convert to parent coords */ - rect.x += mBounds.x; - rect.y += mBounds.y; + /* convert to parent coords */ + rect.x += mBounds.x; + rect.y += mBounds.y; - if ( GetParentClippedArea(rect) == PR_TRUE ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 2 before Clipped rect=(%d,%d,%d,%d) mBounds=(%d,%d)\n", rect.x, rect.y, rect.width, rect.height, mBounds.x, mBounds.y)); + if( GetParentClippedArea( rect ) == PR_TRUE ) { + /* convert back widget coords */ + rect.x -= mBounds.x; + rect.y -= mBounds.y; - /* convert back widget coords */ - rect.x -= mBounds.x; - rect.y -= mBounds.y; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Invalidate 2 Clipped rect=(%i,%i,%i,%i)\n", rect.x, rect.y, rect.width, rect.height )); - - mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); - - if (PtWidgetIsRealized(mWidget)) -/* GTK only allows Queue'd damage here ... */ -// if( aIsSynchronous) -// { -// UpdateWidgetDamage(); -// } -// else - { - QueueWidgetDamage(); - } - - } - - return NS_OK; -} - -NS_IMETHODIMP nsWidget::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::InvalidateRegion isSync=<%d>\n",aIsSynchronous)); - //printf("nsWidget::InvalidateRegion isSync=<%d> mWidget=<%p> mUpdateArea=<%p> IsRealized=<%d> \n",aIsSynchronous, mWidget, mUpdateArea, PtWidgetIsRealized(mWidget) ); -#if 1 - mUpdateArea->Union(*aRegion); - if (aIsSynchronous) - { - UpdateWidgetDamage(); - } - else - { - QueueWidgetDamage(); - } -#else - if (!PtWidgetIsRealized(mWidget)) - { - return NS_OK; - } - - nsRegionRectSet *regionRectSet = nsnull; - PhRect_t extent; - PhArea_t area; - nsRect temp_rect; - PRUint32 len; - PRUint32 i; - - mUpdateArea->Union(*aRegion); - if (NS_FAILED(mUpdateArea->GetRects(®ionRectSet))) - { - return NS_ERROR_FAILURE; - } - - PtWidgetArea( mWidget, &area ); // parent coords - //printf("nsWidget::InvalidateRegion mWidget=<%p> area=<%d,%d,%d,%d>\n", mWidget, area.pos.x, area.pos.y, area.size.w, area.size.h); - if ((PtWidgetIsClass(mWidget, PtWindow)) || (PtWidgetIsClass(mWidget, PtRegion))) - { - printf("nsWidget::InvalidateRegion mWidget=<%p> is a PtWindow\n"); - area.pos.x = area.pos.y = 0; - } - - len = regionRectSet->mRectsLen; - for (i=0;imRects[i]); - - //printf("nsWidget::InvalidateRegion r=<%d,%d,%d,%d>\n",r->x, r->y, r->width, r->height ); - - temp_rect.SetRect(r->x, r->y, r->width, r->height); - - extent.ul.x = temp_rect.x + area.pos.x; // convert widget coords to parent - extent.ul.y = temp_rect.y + area.pos.y; - extent.lr.x = extent.ul.x + temp_rect.width - 1; - extent.lr.y = extent.ul.y + temp_rect.height - 1; + mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); - //printf("nsWidget::InvalidateRegion damaging widget=<%p> %d rect=<%d,%d,%d,%d>\n", mWidget, i,extent.ul.x, extent.ul.y, extent.lr.x, extent.lr.y); -#if 0 - PtDamageExtent( mWidget, &extent ); -#else - if (aIsSynchronous) - { - UpdateWidgetDamage(); - } - else - { - QueueWidgetDamage(); - } -#endif - } + if( PtWidgetIsRealized( mWidget ) ) QueueWidgetDamage( ); + } + return NS_OK; + } - // drop the const.. whats the right thing to do here? - ((nsIRegion*)aRegion)->FreeRects(regionRectSet); +NS_IMETHODIMP nsWidget::InvalidateRegion( const nsIRegion *aRegion, PRBool aIsSynchronous ) { - ((nsIRegion*)aRegion)->SetTo(0,0,0,0); -#endif + mUpdateArea->Union( *aRegion ); + if( aIsSynchronous ) UpdateWidgetDamage(); + else QueueWidgetDamage(); return NS_OK; -} + } /* Returns only the rect that is inside of all my parents, problem on test 9 */ -PRBool nsWidget::GetParentClippedArea( nsRect &rect ) -{ -// Traverse parent heirarchy and clip the passed-in rect bounds +/* Traverse parent heirarchy and clip the passed-in rect bounds */ +PRBool nsWidget::GetParentClippedArea( nsRect &rect ) { PtArg_t arg; PhArea_t *area; @@ -1101,80 +750,58 @@ PRBool nsWidget::GetParentClippedArea( nsRect &rect ) nsRect rect2; PtWidget_t *disjoint = PtFindDisjoint( mWidget ); -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea Clipping widget (%p) rect: %d,%d,%d,%d disjointParent=<%p>\n", this, rect.x, rect.y, rect.width, rect.height, disjoint )); - // convert passed-in rect to absolute window coords first... PtWidgetOffset( mWidget, &offset ); rect.x += offset.x; rect.y += offset.y; -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea screen coords: %d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height )); - parent = PtWidgetParent( mWidget ); - while( parent ) - { + while( parent ) { + PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - if( PtGetResources( parent, 1, &arg ) == 0 ) - { - rect2.width = area->size.w; - rect2.height = area->size.h; + PtGetResources( parent, 1, &arg ); - if ((parent == disjoint) || (PtWidgetIsClass(parent, PtWindow)) - || (PtWidgetIsClass(parent, PtRegion))) - { - rect2.x = rect2.y = 0; - } - else - { - PtWidgetOffset( parent, &offset ); - rect2.x = area->pos.x + offset.x; - rect2.y = area->pos.y + offset.y; - } + rect2.width = area->size.w; + rect2.height = area->size.h; -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea parent at: %d,%d,%d,%d\n", rect2.x, rect2.y, rect2.width, rect2.height )); + if( (parent == disjoint) || (PtWidgetIsClass(parent, PtWindow)) || (PtWidgetIsClass(parent, PtRegion)) ) + rect2.x = rect2.y = 0; + else { + PtWidgetOffset( parent, &offset ); + rect2.x = area->pos.x + offset.x; + rect2.y = area->pos.y + offset.y; + } - if( ( rect.x >= ( rect2.x + rect2.width )) || // rect is out of bounds to right - (( rect.x + rect.width ) <= rect2.x ) || // rect is out of bounds to left - ( rect.y >= ( rect2.y + rect2.height )) || // rect is out of bounds to bottom - (( rect.y + rect.height ) <= rect2.y ) ) // rect is out of bounds to top - { - rect.width = 0; - rect.height = 0; - //printf( " Out of bounds !\n" ); - break; - } - else - { - if( rect.x < rect2.x ) - { - rect.width -= ( rect2.x - rect.x ); - rect.x = rect2.x; - } + if( ( rect.x >= ( rect2.x + rect2.width )) || // rect is out of bounds to right + (( rect.x + rect.width ) <= rect2.x ) || // rect is out of bounds to left + ( rect.y >= ( rect2.y + rect2.height )) || // rect is out of bounds to bottom + (( rect.y + rect.height ) <= rect2.y ) ) // rect is out of bounds to top + { + rect.width = 0; + rect.height = 0; + //printf( " Out of bounds !\n" ); + break; + } + else { + if( rect.x < rect2.x ) { + rect.width -= ( rect2.x - rect.x ); + rect.x = rect2.x; + } + if( rect.y < rect2.y ) { + rect.height -= ( rect2.y - rect.y ); + rect.y = rect2.y; + } - if( rect.y < rect2.y ) - { - rect.height -= ( rect2.y - rect.y ); - rect.y = rect2.y; - } + if(( rect.x + rect.width ) > ( rect2.x + rect2.width )) + rect.width = (rect2.x + rect2.width) - rect.x; - if(( rect.x + rect.width ) > ( rect2.x + rect2.width )) - { - rect.width = (rect2.x + rect2.width) - rect.x; - } + if(( rect.y + rect.height ) > ( rect2.y + rect2.height )) + rect.height = (rect2.y + rect2.height) - rect.y; + } - if(( rect.y + rect.height ) > ( rect2.y + rect2.height )) - { - rect.height = (rect2.y + rect2.height) - rect.y; - } - -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea new widget coords: %d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height )); - - } - } - - parent = PtWidgetParent( parent ); - } + parent = PtWidgetParent( parent ); + } // convert rect back to widget coords... @@ -1182,25 +809,20 @@ PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea new widget coord rect.x -= offset.x; rect.y -= offset.y; -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetParentClippedArea final widget coords: %d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height )); - if( rect.width && rect.height ) return PR_TRUE; - else - return PR_FALSE; -} + else return PR_FALSE; + } -NS_METHOD nsWidget::Update(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Update this=<%p> mWidget=<%p>\n", this, mWidget)); +NS_METHOD nsWidget::Update( void ) { - /* if the widget has been invalidated or damaged then re-draw it */ - UpdateWidgetDamage(); + /* if the widget has been invalidated or damaged then re-draw it */ + UpdateWidgetDamage(); return NS_OK; -} + } //------------------------------------------------------------------------- @@ -1208,105 +830,77 @@ NS_METHOD nsWidget::Update(void) // Return some native data according to aDataType // //------------------------------------------------------------------------- -void *nsWidget::GetNativeData(PRUint32 aDataType) -{ - switch(aDataType) - { - case NS_NATIVE_WINDOW: - case NS_NATIVE_WIDGET: - case NS_NATIVE_PLUGIN_PORT: - if( !mWidget ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetNativeData(mWidget) - mWidget is NULL!\n" )); - } - return (void *)mWidget; +void *nsWidget::GetNativeData( PRUint32 aDataType ) { - case NS_NATIVE_DISPLAY: - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetNativeData(NS_NATIVE_DISPLAY) - Not Implemented.\n" )); - return nsnull; + switch( aDataType ) { + case NS_NATIVE_WINDOW: + case NS_NATIVE_WIDGET: + case NS_NATIVE_PLUGIN_PORT: + return (void *)mWidget; + + case NS_NATIVE_DISPLAY: + return nsnull; - case NS_NATIVE_GRAPHIC: - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetNativeData(NS_NATIVE_GRAPHIC) - Not Implemented.\n" )); - return nsnull; + case NS_NATIVE_GRAPHIC: + return nsnull; + + default: + break; + } - default: - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::GetNativeData() - ERROR Bad ID.\n" )); - break; - } return nsnull; -} + } //------------------------------------------------------------------------- // // Set the colormap of the window // //------------------------------------------------------------------------- -NS_METHOD nsWidget::SetColorMap(nsColorMap *aColorMap) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetColorMap - Not Implemented.\n" )); +NS_METHOD nsWidget::SetColorMap( nsColorMap *aColorMap ) { return NS_OK; -} - -NS_METHOD nsWidget::ScrollWidgets(PRInt32 aDx, PRInt32 aDy) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::ScrollWidgets - Not Implemented this=<%p> mWidget=<%p> aDx=<%d aDy=<%d>\n", - this, mWidget, aDx, aDy)); + } +NS_METHOD nsWidget::ScrollWidgets( PRInt32 aDx, PRInt32 aDy ) { return NS_OK; -} + } -NS_METHOD nsWidget::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::Scroll - Not Implemented.\n" )); +NS_METHOD nsWidget::Scroll( PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect ) { return NS_OK; -} + } -NS_METHOD nsWidget::BeginResizingChildren(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::BeginResizingChildren - Not Implemented.\n" )); +NS_METHOD nsWidget::BeginResizingChildren( void ) { return NS_OK; -} + } -NS_METHOD nsWidget::EndResizingChildren(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::EndResizingChildren - Not Implemented.\n" )); +NS_METHOD nsWidget::EndResizingChildren( void ) { return NS_OK; -} + } -NS_METHOD nsWidget::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) -{ +NS_METHOD nsWidget::GetPreferredSize( PRInt32& aWidth, PRInt32& aHeight ) { aWidth = mPreferredWidth; aHeight = mPreferredHeight; return (mPreferredWidth != 0 && mPreferredHeight != 0)?NS_OK:NS_ERROR_FAILURE; -} + } -NS_METHOD nsWidget::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) -{ +NS_METHOD nsWidget::SetPreferredSize( PRInt32 aWidth, PRInt32 aHeight ) { mPreferredWidth = aWidth; mPreferredHeight = aHeight; return NS_OK; -} + } -NS_IMETHODIMP nsWidget::SetTitle(const nsString &aTitle) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetTitle - this=<%p> aTitle=<%s>\n", this, nsAutoCString(aTitle) )); - - //gtk_widget_set_name(mWidget, "foo"); +NS_IMETHODIMP nsWidget::SetTitle( const nsString &aTitle ) { return NS_OK; -} + } -NS_METHOD nsWidget::SetMenuBar(nsIMenuBar * aMenuBar) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::SetMenuBar - Not Implemented.\n" )); +// nsWidget::SetMenuBar - Not Implemented +NS_METHOD nsWidget::SetMenuBar( nsIMenuBar * aMenuBar ) { return NS_ERROR_FAILURE; -} + } -NS_METHOD nsWidget::ShowMenuBar( PRBool aShow) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::ShowMenuBar aShow=<%d>\n",aShow)); +NS_METHOD nsWidget::ShowMenuBar( PRBool aShow) { return NS_ERROR_FAILURE; -} + } nsresult nsWidget::CreateWidget(nsIWidget *aParent, const nsRect &aRect, @@ -1317,76 +911,44 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent, nsWidgetInitData *aInitData, nsNativeWidget aNativeParent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget this=<%p> mRefCnt=<%d> aRect=<%d,%d,%d,%d> aContext=<%p>\n", this, mRefCnt, aRect.x, aRect.y, aRect.width, aRect.height, aContext)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget this=<%p> aParent=<%p> aNativeParent=<%p> mParent=<%p>\n", this, aParent, aNativeParent, mParent)); - if (aParent) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget (%p) nsIWidget parent\n", this)); - } - else if (aNativeParent) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget (%p) native parent\n",this)); - } - else if(aAppShell) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::CreateWidget (%p) nsAppShell parent\n",this)); - } - PtWidget_t *parentWidget = nsnull; nsIWidget *baseParent = aInitData && (aInitData->mWindowType == eWindowType_dialog || aInitData->mWindowType == eWindowType_toplevel ) ? nsnull : aParent; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget before BaseCreate this=<%p> mParent=<%p> baseParent=<%p>\n", this, mParent, baseParent)); - - BaseCreate(baseParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData); + BaseCreate( baseParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData ); mParent = aParent; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget after BaseCreate mRefCnt=<%d> mBounds=<%d,%d,%d,%d> mContext=<%p> mParent=<%p> baseParent=<%p> aParent=<%p>\n", - mRefCnt, mBounds.x, mBounds.y, mBounds.width, mBounds.height, mContext, mParent, baseParent, aParent)); - - if( aNativeParent ) - { + if( aNativeParent ) { parentWidget = (PtWidget_t*)aNativeParent; // we've got a native parent so listen for resizes mListenForResizes = PR_TRUE; - } - else if( aParent ) - { + } + else if( aParent ) { parentWidget = (PtWidget_t*) (aParent->GetNativeData(NS_NATIVE_WIDGET)); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget - No parent specified!\n" )); - } + } mBounds = aRect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget before CreateNative this=<%p> mParent=<%p> baseParent=<%p>\n", this, mParent, baseParent)); CreateNative (parentWidget); Resize(aRect.width, aRect.height, PR_FALSE); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget - bounds=(%i,%i,%i,%i) mRefCnt=<%d>\n", mBounds.x, mBounds.y, mBounds.width, mBounds.height, mRefCnt)); - - if( mWidget ) - { + if( mWidget ) { SetInstance(mWidget, this); PtAddCallback( mWidget, Pt_CB_GOT_FOCUS, GotFocusCallback, this ); PtAddCallback( mWidget, Pt_CB_LOST_FOCUS, LostFocusCallback, this ); PtAddCallback( mWidget, Pt_CB_IS_DESTROYED, DestroyedCallback, this ); - } + } DispatchStandardEvent(NS_CREATE); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::CreateWidget end mRefCnt=<%d>\n", mRefCnt)); - InitCallbacks(); return NS_OK; -} + } //------------------------------------------------------------------------- @@ -1427,34 +989,30 @@ NS_METHOD nsWidget::Create(nsNativeWidget aParent, } +// nsWidget::ConvertToDeviceCoordinates - Not Implemented void nsWidget::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::ConvertToDeviceCoordinates - Not Implemented.\n" )); } -void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) -{ - event.widget = this; +void nsWidget::InitEvent( nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint ) { + event.widget = this; - if (aPoint == nsnull) - { - event.point.x = 0; - event.point.y = 0; - } - else - { - event.point.x = aPoint->x; - event.point.y = aPoint->y; - } + if( aPoint == nsnull ) { + event.point.x = 0; + event.point.y = 0; + } + else { + event.point.x = aPoint->x; + event.point.y = aPoint->y; + } - event.time = PR_IntervalNow(); - event.message = aEventType; -} + event.time = PR_IntervalNow(); + event.message = aEventType; + } -PRBool nsWidget::ConvertStatus(nsEventStatus aStatus) -{ +PRBool nsWidget::ConvertStatus( nsEventStatus aStatus ) { switch(aStatus) { case nsEventStatus_eIgnore: return(PR_FALSE); @@ -1465,21 +1023,19 @@ PRBool nsWidget::ConvertStatus(nsEventStatus aStatus) default: NS_ASSERTION(0, "Illegal nsEventStatus enumeration value"); break; - } - return(PR_FALSE); -} + } + return PR_FALSE; + } -PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event) -{ +PRBool nsWidget::DispatchWindowEvent( nsGUIEvent* event ) { nsEventStatus status; PRBool ret; DispatchEvent(event, status); - //printf("nsWidget::DispatchWindowEvent status=<%d> convtered=<%d>\n", status, ConvertStatus(status) ); ret = ConvertStatus(status); return ret; -} + } //------------------------------------------------------------------------- @@ -1487,14 +1043,13 @@ PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event) // Dispatch standard event // //------------------------------------------------------------------------- -PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg) -{ +PRBool nsWidget::DispatchStandardEvent( PRUint32 aMsg ) { nsGUIEvent event; event.eventStructType = NS_GUI_EVENT; InitEvent(event, aMsg); PRBool result = DispatchWindowEvent(&event); return result; -} + } //------------------------------------------------------------------------- @@ -1503,40 +1058,27 @@ PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg) // //------------------------------------------------------------------------- -NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent, - nsEventStatus &aStatus) -{ -#if 0 - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::DispatchEvent this=<%p> widget=<%p> eventType=<%d> message=<%d> <%s>\n", - this, aEvent->widget, aEvent->eventStructType, aEvent->message, - (const char *) nsCAutoString(GuiEventToString(aEvent)) )); -#endif +NS_IMETHODIMP nsWidget::DispatchEvent( nsGUIEvent *aEvent, nsEventStatus &aStatus ) { -/* Stolen from GTK */ + /* Stolen from GTK */ NS_ADDREF(aEvent->widget); - if (nsnull != mMenuListener) - { - if (NS_MENU_EVENT == aEvent->eventStructType) - { + if( nsnull != mMenuListener ) { + if( NS_MENU_EVENT == aEvent->eventStructType ) aStatus = mMenuListener->MenuSelected(NS_STATIC_CAST(nsMenuEvent&, *aEvent)); - } - } + } aStatus = nsEventStatus_eIgnore; - if (nsnull != mEventCallback) { - aStatus = (*mEventCallback)(aEvent); - } + if( nsnull != mEventCallback ) aStatus = (*mEventCallback)(aEvent); // Dispatch to event listener if event was not consumed - if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) { + if( (aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener) ) aStatus = mEventListener->ProcessEvent(*aEvent); - } NS_RELEASE(aEvent->widget); return NS_OK; -} + } //============================================================== void nsWidget::InitMouseEvent(PhPointerEvent_t *aPhButtonEvent, @@ -1544,65 +1086,41 @@ void nsWidget::InitMouseEvent(PhPointerEvent_t *aPhButtonEvent, nsMouseEvent &anEvent, PRUint32 aEventType) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::InitMouseEvent \n")); - - //printf("nsWidget::InitMouseEvent click_count=%d\n", aPhButtonEvent->click_count); - anEvent.message = aEventType; anEvent.widget = aWidget; anEvent.eventStructType = NS_MOUSE_EVENT; - if (aPhButtonEvent != nsnull) - { + if (aPhButtonEvent != nsnull) { anEvent.time = PR_IntervalNow(); anEvent.isShift = ( aPhButtonEvent->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE; anEvent.isControl = ( aPhButtonEvent->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE; anEvent.isAlt = ( aPhButtonEvent->key_mods & Pk_KM_Alt ) ? PR_TRUE : PR_FALSE; - anEvent.isMeta = PR_FALSE; + anEvent.isMeta = PR_FALSE; anEvent.point.x = aPhButtonEvent->pos.x; anEvent.point.y = aPhButtonEvent->pos.y; anEvent.clickCount = aPhButtonEvent->click_count; - } -} + } + } //------------------------------------------------------------------------- // // Deal with all sort of mouse event // //------------------------------------------------------------------------- -PRBool nsWidget::DispatchMouseEvent(nsMouseEvent& aEvent) -{ - //printf("nsWidget::DispatchMouseEvent \n"); +PRBool nsWidget::DispatchMouseEvent( nsMouseEvent& aEvent ) { PRBool result = PR_FALSE; - if (nsnull == mEventCallback && nsnull == mMouseListener) { - return result; - } + if (nsnull == mEventCallback && nsnull == mMouseListener) return result; // call the event callback if (nsnull != mEventCallback) { result = DispatchWindowEvent(&aEvent); - return result; - } + } if (nsnull != mMouseListener) { + switch (aEvent.message) { - case NS_MOUSE_MOVE: { -// result = ConvertStatus(mMouseListener->MouseMoved(aEvent)); -// nsRect rect; -// GetBounds(rect); -// if (rect.Contains(event.point.x, event.point.y)) { -// if (mCurrentWindow == NULL || mCurrentWindow != this) { -// printf("Mouse enter"); -// mCurrentWindow = this; -// } -// } else { -// printf("Mouse exit"); -// } - - } break; - case NS_MOUSE_LEFT_BUTTON_DOWN: case NS_MOUSE_MIDDLE_BUTTON_DOWN: case NS_MOUSE_RIGHT_BUTTON_DOWN: @@ -1616,30 +1134,28 @@ PRBool nsWidget::DispatchMouseEvent(nsMouseEvent& aEvent) result = ConvertStatus(mMouseListener->MouseClicked(aEvent)); break; - case NS_DRAGDROP_DROP: - printf("nsWidget::DispatchMouseEvent, NS_DRAGDROP_DROP\n"); - break; + case NS_DRAGDROP_DROP: + break; - default: - break; + case NS_MOUSE_MOVE: + break; - } // switch - } + default: + break; + + } // switch + } return result; -} + } //------------------------------------------------------------------------- // Old icky code I am trying to replace! //------------------------------------------------------------------------- -PRBool nsWidget::DispatchMouseEvent( PhPoint_t &aPos, PRUint32 aEvent ) -{ -// printf( ">>> nsWidget::DispatchMouseEvent\n" ); fflush( stdout ); +PRBool nsWidget::DispatchMouseEvent( PhPoint_t &aPos, PRUint32 aEvent ) { PRBool result = PR_FALSE; - if( nsnull == mEventCallback && nsnull == mMouseListener ) - { - return result; - } + + if( nsnull == mEventCallback && nsnull == mMouseListener ) return result; nsMouseEvent event; @@ -1654,17 +1170,14 @@ PRBool nsWidget::DispatchMouseEvent( PhPoint_t &aPos, PRUint32 aEvent ) event.clickCount = 0; /* hack makes the mouse not work */ // call the event callback - if (nsnull != mEventCallback) { + if( nsnull != mEventCallback ) { result = DispatchWindowEvent( &event ); NS_IF_RELEASE(event.widget); - return result; - } + } - if (nsnull != mMouseListener) - { - switch (aEvent) - { + if( nsnull != mMouseListener ) { + switch( aEvent ) { case NS_MOUSE_MOVE: result = ConvertStatus(mMouseListener->MouseMoved(event)); break; @@ -1681,56 +1194,47 @@ PRBool nsWidget::DispatchMouseEvent( PhPoint_t &aPos, PRUint32 aEvent ) result = ConvertStatus(mMouseListener->MouseReleased(event)); result = ConvertStatus(mMouseListener->MouseClicked(event)); break; - } // switch - } + } // switch + } return result; -} + } -void nsWidget::InitCallbacks( char * aName ) -{ -} +void nsWidget::InitCallbacks( char * aName ) { + } -PRBool nsWidget::SetInstance( PtWidget_t * pWidget, nsWidget * inst ) -{ +PRBool nsWidget::SetInstance( PtWidget_t * pWidget, nsWidget * inst ) { PRBool res = PR_FALSE; - if( pWidget ) - { + if( pWidget ) { PtArg_t arg; void *data = (void *)inst; PtSetArg(&arg, Pt_ARG_USER_DATA, &data, sizeof(void *) ); if( PtSetResources( pWidget, 1, &arg) == 0 ) res = PR_TRUE; - } - + } return res; -} + } -nsWidget* nsWidget::GetInstance( PtWidget_t * pWidget ) -{ - if( pWidget ) - { +nsWidget* nsWidget::GetInstance( PtWidget_t * pWidget ) { + if( pWidget ) { PtArg_t arg; void **data; PtSetArg( &arg, Pt_ARG_USER_DATA, &data, 0 ); - if( PtGetResources( pWidget, 1, &arg ) == 0 ) - { + if( PtGetResources( pWidget, 1, &arg ) == 0 ) { if( data ) return (nsWidget *) *data; - } - } - + } + } return NULL; -} + } // Input keysym is in gtk format; output is in NS_VK format -PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) -{ +PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) { struct nsKeyConverter { PRUint32 vkCode; // Platform independent key code @@ -1794,13 +1298,10 @@ PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) const int length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter); - //printf("nsWidget::nsConvertKey - Looking for <%x> length=<%d>\n", keysym, length); - - if (aIsChar) - { + if (aIsChar) { /* Default this to TRUE */ *aIsChar = PR_TRUE; - } + } // First, try to handle alphanumeric input, not listed in nsKeycodes: if (keysym >= Pk_a && keysym <= Pk_z) @@ -1812,37 +1313,28 @@ PRUint32 nsWidget::nsConvertKey(unsigned long keysym, PRBool *aIsChar ) if (keysym >= Pk_0 && keysym <= Pk_9) return keysym - Pk_0 + NS_VK_0; - if (keysym >= Pk_F1 && keysym <= Pk_F24) - { + if (keysym >= Pk_F1 && keysym <= Pk_F24) { *aIsChar = PR_FALSE; return keysym - Pk_F1 + NS_VK_F1; - } + } for (int i = 0; i < length; i++) { - if (nsKeycodes[i].keysym == keysym) - { - //printf("nsWidget::nsConvertKey - Converted <%x> to <%x>\n", keysym, nsKeycodes[i].vkCode); - if (aIsChar) - *aIsChar = (nsKeycodes[i].isChar); + if( nsKeycodes[i].keysym == keysym ) { + if( aIsChar ) *aIsChar = (nsKeycodes[i].isChar); return (nsKeycodes[i].vkCode); - } - } - - //NS_WARNING("nsWidget::nsConvertKey - Did not Find Key! - Not Implemented\n"); + } + } return((int) 0); -} + } //============================================================== void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, nsWidget * aWidget, nsKeyEvent &anEvent, - PRUint32 aEventType) -{ -// PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::InitKeyEvent\n")); + PRUint32 aEventType) { - if (aPhKeyEvent != nsnull) - { + if( aPhKeyEvent != nsnull ) { anEvent.message = aEventType; anEvent.widget = aWidget; @@ -1863,61 +1355,46 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar); - //printf("nsWidget::InitKeyEvent EventType=<%d> key_cap=<%lu> converted=<%lu> IsChar=<%d>\n", aEventType, aPhKeyEvent->key_cap, keysym, IsChar); anEvent.isShift = ( aPhKeyEvent->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE; anEvent.isControl = ( aPhKeyEvent->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE; anEvent.isAlt = ( aPhKeyEvent->key_mods & Pk_KM_Alt ) ? PR_TRUE : PR_FALSE; anEvent.isMeta = PR_FALSE; - if ((aEventType == NS_KEY_PRESS) && (IsChar == PR_TRUE)) - { + if ((aEventType == NS_KEY_PRESS) && (IsChar == PR_TRUE)) { anEvent.charCode = aPhKeyEvent->key_sym; anEvent.keyCode = 0; /* I think the spec says this should be 0 */ //printf("nsWidget::InitKeyEvent charCode=<%d>\n", anEvent.charCode); if ((anEvent.isControl) || (anEvent.isAlt)) - { anEvent.charCode = aPhKeyEvent->key_cap; - } - else - { - anEvent.isShift = anEvent.isControl = anEvent.isAlt = anEvent.isMeta = PR_FALSE; - } - } - else - { - anEvent.charCode = 0; - anEvent.keyCode = (keysym & 0x00FF); - } - - //printf("nsWidget::InitKeyEvent Modifiers Valid=<%d,%d,%d> Shift=<%d> Control=<%d> Alt=<%d> Meta=<%d>\n", (aPhKeyEvent->key_flags & Pk_KF_Scan_Valid), (aPhKeyEvent->key_flags & Pk_KF_Sym_Valid), (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid), anEvent.isShift, anEvent.isControl, anEvent.isAlt, anEvent.isMeta); - } -} + else + anEvent.isShift = anEvent.isControl = anEvent.isAlt = anEvent.isMeta = PR_FALSE; + } + else { + anEvent.charCode = 0; + anEvent.keyCode = (keysym & 0x00FF); + } + } + } -PRBool nsWidget::DispatchKeyEvent(PhKeyEvent_t *aPhKeyEvent) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::DispatchKeyEvent Got a Key Event aPhEkyEvent->key_mods:<%x> aPhEkyEvent->key_flags:<%x> aPhEkyEvent->key_sym=<%x> aPhEkyEvent->key_caps=<%x>\n",aPhKeyEvent->key_mods, aPhKeyEvent->key_flags, aPhKeyEvent->key_sym, aPhKeyEvent->key_cap)); +PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) { NS_ASSERTION(aPhKeyEvent, "nsWidget::DispatchKeyEvent a NULL PhKeyEvent was passed in"); nsKeyEvent keyEvent; PRBool result = PR_FALSE; - if ( (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid) == 0) - { - //printf("nsWidget::DispatchKeyEvent throwing away invalid key: Modifiers Valid=<%d,%d,%d> this=<%p>\n", - // (aPhKeyEvent->key_flags & Pk_KF_Scan_Valid), (aPhKeyEvent->key_flags & Pk_KF_Sym_Valid), (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid), this ); + if ( (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid) == 0) { + //printf("nsWidget::DispatchKeyEvent throwing away invalid key: Modifiers Valid=<%d,%d,%d> this=<%p>\n", + //(aPhKeyEvent->key_flags & Pk_KF_Scan_Valid), (aPhKeyEvent->key_flags & Pk_KF_Sym_Valid), (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid), this ); + return PR_TRUE; + } - return PR_TRUE; - } - - - if ( PtIsFocused(mWidget) != 2) - { + if ( PtIsFocused(mWidget) != 2) { //printf("nsWidget::DispatchKeyEvent Not on focus leaf! PtIsFocused(mWidget)=<%d>\n", PtIsFocused(mWidget)); return PR_FALSE; - } + } if ( ( aPhKeyEvent->key_cap == Pk_Shift_L ) || ( aPhKeyEvent->key_cap == Pk_Shift_R ) @@ -1926,50 +1403,32 @@ PRBool nsWidget::DispatchKeyEvent(PhKeyEvent_t *aPhKeyEvent) || ( aPhKeyEvent->key_cap == Pk_Num_Lock ) || ( aPhKeyEvent->key_cap == Pk_Scroll_Lock ) ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::DispatchKeyEvent Ignoring SHIFT or CONTROL keypress\n")); return PR_TRUE; - } nsWindow *w = (nsWindow *) this; -#if 0 -printf("nsWidget::DispatchKeyEvent KeyEvent Info: this=<%p> key_flags=<%lu> key_mods=<%lu> key_sym=<%lu> key_cap=<%lu> key_scan=<%d> Focused=<%d>\n", - this, aPhKeyEvent->key_flags, aPhKeyEvent->key_mods, aPhKeyEvent->key_sym, aPhKeyEvent->key_cap, aPhKeyEvent->key_scan, PtIsFocused(mWidget)); -#endif - w->AddRef(); - if (aPhKeyEvent->key_flags & Pk_KF_Key_Down) - { - //printf("nsWidget::DispatchKeyEvent Before Key Down \n"); + if (aPhKeyEvent->key_flags & Pk_KF_Key_Down) { InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_DOWN); result = w->OnKey(keyEvent); - //printf("nsWidget::DispatchKeyEvent after Key_Down event result=<%d>\n", result); - //printf("nsWidget::DispatchKeyEvent Before Key Press\n"); InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_PRESS); result = w->OnKey(keyEvent); - } - else if (aPhKeyEvent->key_flags & Pk_KF_Key_Repeat) - { - //printf("nsWidget::DispatchKeyEvent Before Key Press\n"); + } + else if (aPhKeyEvent->key_flags & Pk_KF_Key_Repeat) { InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_PRESS); result = w->OnKey(keyEvent); - } - else if (PkIsKeyDown(aPhKeyEvent->key_flags) == 0) - { - //printf("nsWidget::DispatchKeyEvent Before Key Up\n"); + } + else if (PkIsKeyDown(aPhKeyEvent->key_flags) == 0) { InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_UP); result = w->OnKey(keyEvent); - } + } w->Release(); - //printf("nsWidget::DispatchKeyEvent after events result=<%d>\n", result); - return result; -} + } @@ -1978,10 +1437,7 @@ printf("nsWidget::DispatchKeyEvent KeyEvent Info: this=<%p> key_flags=<%lu> key_ // the nsWidget raw event callback for all nsWidgets in this toolkit // //------------------------------------------------------------------------- -int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) -{ - //PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::RawEventHandler raweventhandler widget=<%p> this=<%p> IsFocused=<%d>\n", widget, data, PtIsFocused(widget) )); - //printf("nsWidget::RawEventHandler raweventhandler widget=<%p> this=<%p> IsFocused=<%d>\n", widget, data, PtIsFocused(widget)); +int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { // Get the window which caused the event and ask it to process the message nsWidget *someWidget = (nsWidget*) data; @@ -1991,185 +1447,66 @@ int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t (someWidget->mIsDestroying == PR_FALSE) && (someWidget->HandleEvent( cbinfo )) ) - { return( Pt_END ); // Event was consumed - } return( Pt_CONTINUE ); -} + } -PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) -{ +PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) { PRBool result = PR_TRUE; // call the default nsWindow proc int err; PhEvent_t* event = aCbInfo->event; + /* Photon 2 added a Consumed flag which indicates a previous receiver of the */ + /* event has processed it */ + if (event->processing_flags & Ph_CONSUMED) return PR_TRUE; -//printf("nsWidget::HandleEvent entering this=<%p> mWidget=<%p> Event Consumed=<%d> Event=<%s>\n", -// this, mWidget, (event->processing_flags & Ph_CONSUMED), (const char *) nsCAutoString(PhotonEventToString(event)) ); + if (IgnoreEvent == event->timestamp) return PR_TRUE; -#if 0 -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent entering this=<%p> mWidget=<%p> Event Consumed=<%d> Event=<%s>\n", - this, mWidget, (event->processing_flags & Ph_CONSUMED), (const char *) nsCAutoString( (const PRUnichar *) PhotonEventToString(event)) )); -#endif - - /* Photon 2 added a Consumed flag which indicates a previous receiver of the */ - /* event has processed it */ - if (event->processing_flags & Ph_CONSUMED) - { - return PR_TRUE; - } - - if (IgnoreEvent == event->timestamp) - { - //printf("nsWidget::HandleEvent Ignoring Event!\n"); - return PR_TRUE; - } - switch ( event->type ) - { - case Ph_EV_KEY: - { - PhKeyEvent_t* keyev = (PhKeyEvent_t*) PhGetData( event ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent keyev=<%p>\n", keyev)); - result = DispatchKeyEvent(keyev); - } - break; - - case Ph_EV_DRAG: - { - PhDragEvent_t* ptrev = (PhDragEvent_t*) PhGetData( event ); - nsMouseEvent theMouseEvent; - - //printf("nsWidget::HandleEvent Ph_EV_DRAG subtype=<%d> flags=<%d>\n", event->subtype, ptrev->flags ); - switch(event->subtype) - { - case Ph_EV_DRAG_BOUNDARY: - //printf("nsWidget::HandleEvent Ph_EV_DRAG_BOUNDARY\n"); - break; - case Ph_EV_DRAG_COMPLETE: - { - nsMouseEvent theMouseEvent; - PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); - - //printf("nsWidget::HandleEvent Ph_EV_DRAG_COMPLETE\n"); - ScreenToWidget( ptrev2->pos ); - InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); - result = DispatchMouseEvent(theMouseEvent); - } - break; - case Ph_EV_DRAG_INIT: - //printf("nsWidget::HandleEvent Ph_EV_DRAG_INIT\n"); - break; - case Ph_EV_DRAG_KEY_EVENT: - //printf("nsWidget::HandleEvent Ph_EV_DRAG_KEY_EVENT\n"); - break; - case Ph_EV_DRAG_MOTION_EVENT: - { - PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); - ScreenToWidget( ptrev2->pos ); - //printf("nsWidget::HandleEvent Ph_EV_DRAG_MOTION_EVENT pos=(%d,%d)\n", ptrev2->pos.x,ptrev2->pos.y ); - InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_MOVE ); - result = DispatchMouseEvent(theMouseEvent); - } - break; - case Ph_EV_DRAG_MOVE: - //printf("nsWidget::HandleEvent Ph_EV_DRAG_BOUNDARY\n"); - break; - case Ph_EV_DRAG_START: - //printf("nsWidget::HandleEvent Ph_EV_DRAG_START\n"); - break; - } - } - break; - - case Ph_EV_PTR_MOTION_BUTTON: - { - PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); - nsMouseEvent theMouseEvent; - - //printf("nsWidget::HandleEvent Ph_EV_PTR_MOTION_BUTTON\n"); - -#if 0 - if( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button - { - /* Initiate a PhInitDrag() */ - /* I am not sure what rect and boundary should be but this works */ - PhRect_t rect = {0,0,0,0}; - PhRect_t boundary = {0,0,640,480}; - err=PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL); - if (err==-1) - { - NS_WARNING("nsWidget::HandleEvent PhInitDrag Failed!\n"); - result = NS_ERROR_FAILURE; - } - } -#endif - - if( ptrev ) - { - ScreenToWidget( ptrev->pos ); - //printf("nsWidget::HandleEvent Ph_EV_PTR_MOTION_BUTTON pos=(%d,%d)\n", ptrev->pos.x,ptrev->pos.y ); - - InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); - result = DispatchMouseEvent(theMouseEvent); - } - } - break; + switch ( event->type ) { case Ph_EV_PTR_MOTION_NOBUTTON: - { - PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); - nsMouseEvent theMouseEvent; + { + PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); + nsMouseEvent theMouseEvent; - //printf("nsWidget::HandleEvent Ph_EV_PTR_MOTION_NOBUTTON\n"); - - if( ptrev ) - { - ScreenToWidget( ptrev->pos ); - //printf("nsWidget::HandleEvent Ph_EV_PTR_MOTION_NOBUTTON pos=(%d,%d)\n", ptrev->pos.x,ptrev->pos.y ); - - InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); - result = DispatchMouseEvent(theMouseEvent); - } - } - break; + if( ptrev ) { + ScreenToWidget( ptrev->pos ); + InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); + result = DispatchMouseEvent(theMouseEvent); + } + } + break; case Ph_EV_BUT_PRESS: { - PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); + PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent; - //printf("nsWidget::HandleEvent Ph_EV_BUT_PRESS this=<%p>\n", this); - - if (ptrev) - { + if( ptrev ) { ScreenToWidget( ptrev->pos ); if( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button - InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN ); + InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN ); else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button - InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_DOWN ); + InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_DOWN ); else // middle button - InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_DOWN ); + InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_DOWN ); - result = DispatchMouseEvent(theMouseEvent); - } - } - break; + result = DispatchMouseEvent(theMouseEvent); + } + } + break; case Ph_EV_BUT_RELEASE: - { - PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); - nsMouseEvent theMouseEvent; + { + PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); + nsMouseEvent theMouseEvent; - //printf("nsWidget::HandleEvent Ph_EV_BUT_RELEASE this=<%p> event->subtype=<%d>\n", this,event->subtype); - - if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) - { - if (ptrev) - { + if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) { + if (ptrev) { ScreenToWidget( ptrev->pos ); if ( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); @@ -2179,29 +1516,87 @@ PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent entering this=<%p> mWidge InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_UP ); result = DispatchMouseEvent(theMouseEvent); - } - } - else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) - { - if( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button - { + } + } + else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) { + if( ptrev->buttons & Ph_BUTTON_SELECT ) { // Normally the left mouse button + /* Initiate a PhInitDrag() */ /* I am not sure what rect and boundary should be but this works */ - PhRect_t rect = {0,0,0,0}; - PhRect_t boundary = {0,0,640,480}; - err=PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL); - if (err==-1) - { - NS_WARNING("nsWidget::HandleEvent PhInitDrag Failed!\n"); - result = NS_ERROR_FAILURE; - } - } - } - } + PhRect_t rect = {0,0,0,0}; + PhRect_t boundary = {0,0,640,480}; + err=PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL); + if( err==-1 ) { + NS_WARNING("nsWidget::HandleEvent PhInitDrag Failed!\n"); + result = NS_ERROR_FAILURE; + } + } + } + } break; + + case Ph_EV_PTR_MOTION_BUTTON: + { + PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); + nsMouseEvent theMouseEvent; + + + if( ptrev ) { + ScreenToWidget( ptrev->pos ); + InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE ); + result = DispatchMouseEvent(theMouseEvent); + } + } + break; + + case Ph_EV_KEY: + { + PhKeyEvent_t* keyev = (PhKeyEvent_t*) PhGetData( event ); + result = DispatchKeyEvent(keyev); + } + break; + + case Ph_EV_DRAG: + { + PhDragEvent_t* ptrev = (PhDragEvent_t*) PhGetData( event ); + nsMouseEvent theMouseEvent; + + switch(event->subtype) { + + case Ph_EV_DRAG_BOUNDARY: + break; + case Ph_EV_DRAG_COMPLETE: + { + nsMouseEvent theMouseEvent; + PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); + + ScreenToWidget( ptrev2->pos ); + InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP ); + result = DispatchMouseEvent(theMouseEvent); + } + break; + case Ph_EV_DRAG_INIT: + break; + case Ph_EV_DRAG_KEY_EVENT: + break; + case Ph_EV_DRAG_MOTION_EVENT: + { + PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event ); + ScreenToWidget( ptrev2->pos ); + InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_MOVE ); + result = DispatchMouseEvent(theMouseEvent); + } + break; + case Ph_EV_DRAG_MOVE: + break; + case Ph_EV_DRAG_START: + break; + } + } + break; + case Ph_EV_BOUNDARY: - switch( event->subtype ) - { + switch( event->subtype ) { case Ph_EV_PTR_ENTER: result = DispatchStandardEvent( NS_MOUSE_ENTER ); break; @@ -2210,60 +1605,28 @@ PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent entering this=<%p> mWidge break; default: break; - } + } break; -#if 0 - case Ph_EV_WM: - { - PhWindowEvent_t* wmev = (PhWindowEvent_t*) PhGetData( event ); - printf("nsWidget::HandleEvent Ph_EV_WM this=<%p> subtype=<%d> vent_f=<%d>\n", - this, event->subtype, wmev->event_f); - - switch( wmev->event_f ) - { - case Ph_WM_FOCUS: - if ( wmev->event_state == Ph_WM_EVSTATE_FOCUS ) - result = DispatchStandardEvent(NS_GOTFOCUS); - else - result = DispatchStandardEvent(NS_LOSTFOCUS); - break; - } - - } - break; -#endif - case Ph_EV_EXPOSE: - { + { int reg; int parreg; reg = event->emitter.rid; parreg = PtWidgetRid(mWidget); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent Ph_EV_EXPOSE reg=<%d> gLastUnrealizedRegion=<%d> parreg=<%d> gLastUnrealizedRegionsParent=<%d>\n",reg, gLastUnrealizedRegion, parreg, gLastUnrealizedRegionsParent)); -// if (parreg == gLastUnrealizedRegionsParent) - if (reg == gLastUnrealizedRegion && parreg == gLastUnrealizedRegionsParent) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent Ph_EV_EXPOSE returning TRUE\n")); - result = PR_TRUE; - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::HandleEvent Ph_EV_EXPOSE returning FALSE\n")); - result = PR_FALSE; - } - } - break; - } + if (reg == gLastUnrealizedRegion && parreg == gLastUnrealizedRegionsParent) result = PR_TRUE; + else result = PR_FALSE; + } + break; + } return result; -} + } -void nsWidget::ScreenToWidget( PhPoint_t &pt ) -{ +void nsWidget::ScreenToWidget( PhPoint_t &pt ) { // pt is in screen coordinates // convert it to be relative to ~this~ widgets origin short x=0,y=0; @@ -2272,7 +1635,7 @@ void nsWidget::ScreenToWidget( PhPoint_t &pt ) pt.x -= x; pt.y -= y; -} + } //--------------------------------------------------------------------------- @@ -2281,28 +1644,20 @@ void nsWidget::ScreenToWidget( PhPoint_t &pt ) // Starts a Photon background task that will flush widget damage when the // app goes idle. //--------------------------------------------------------------------------- -void nsWidget::InitDamageQueue() -{ +void nsWidget::InitDamageQueue( ) { mDmgQueue = nsnull; mWorkProcID = PtAppAddWorkProc( nsnull, WorkProc, &mDmgQueue ); - if( mWorkProcID ) - { + if( mWorkProcID ) { mDmgQueueInited = PR_TRUE; #ifdef ENABLE_DAMAGE_QUEUE_HOLDOFF - int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtHold(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::InitDamageQueue PtHold Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); + PtHold(); #endif - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("*********** damage queue failed to init. ***********\n" )); - } -} + } + } //--------------------------------------------------------------------------- @@ -2311,18 +1666,10 @@ void nsWidget::InitDamageQueue() // Adds this widget to the damage queue. The damage is accumulated in // mUpdateArea. //--------------------------------------------------------------------------- -void nsWidget::QueueWidgetDamage() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::QueueWidgetDamage this=<%p> mDmgQueueInited=<%d>\n", this, mDmgQueueInited)); +void nsWidget::QueueWidgetDamage( ) { + if( !mDmgQueueInited ) InitDamageQueue(); - if( !mDmgQueueInited ) - InitDamageQueue(); - - if( mWidget && mDmgQueueInited ) - { - /* This keeps everything from drawing */ - //if (!PtWidgetIsRealized(mWidget)) - // return; + if( mWidget && mDmgQueueInited ) { // See if we're already in the queue, if so don't add us again DamageQueueEntry *dqe; @@ -2330,29 +1677,25 @@ void nsWidget::QueueWidgetDamage() dqe = mDmgQueue; - while( dqe ) - { - if( dqe->widget == mWidget ) - { + while( dqe ) { + if( dqe->widget == mWidget ) { found = PR_TRUE; break; - } + } dqe = dqe->next; - } + } - if( !found ) - { + if( !found ) { dqe = new DamageQueueEntry; - if( dqe ) - { + if( dqe ) { dqe->widget = mWidget; dqe->inst = this; dqe->next = mDmgQueue; mDmgQueue = dqe; - } - } - } -} + } + } + } + } //--------------------------------------------------------------------------- @@ -2361,167 +1704,101 @@ void nsWidget::QueueWidgetDamage() // Cause the current widget damage to be repaired now. If this widget was // queued, remove it from the queue. //--------------------------------------------------------------------------- -void nsWidget::UpdateWidgetDamage() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged this=<%p> mWidget=<%p>\n", this, mWidget)); +void nsWidget::UpdateWidgetDamage( ) { - if (mWidget == NULL) - { - NS_ASSERTION(0, "nsWidget::UpdateWidgetDamaged mWidget is NULL"); - return; - } + PhRect_t extent; + PhArea_t area; + nsRegionRectSet *regionRectSet = nsnull; + PRUint32 len; + PRUint32 i; + nsRect temp_rect; - if( !PtWidgetIsRealized( mWidget )) - { - //NS_ASSERTION(0, "nsWidget::UpdateWidgetDamaged skipping update because widget is not Realized"); - return; - } + if( mWidget == NULL ) return; + if( !PtWidgetIsRealized( mWidget ) ) return; + + RemoveDamagedWidget( mWidget ); + + if( mUpdateArea->IsEmpty( ) ) return; + + + + PtWidgetArea( mWidget, &area ); - RemoveDamagedWidget( mWidget ); + if( PtWidgetIsClass(mWidget, PtWindow ) || PtWidgetIsClass( mWidget, PtRegion ) ) { + area.pos.x = area.pos.y = 0; + } - if (mUpdateArea->IsEmpty()) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged skipping update because mUpdateArea IsEmpty() this=<%p>\n", this)); - return; - } - - PhRect_t extent; - PhArea_t area; - nsRegionRectSet *regionRectSet = nsnull; - PRUint32 len; - PRUint32 i; - nsRect temp_rect; - - PtWidgetArea( mWidget, &area ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged mWidget=<%p> area=<%d,%d,%d,%d>\n", mWidget, area.pos.x, area.pos.y, area.size.w, area.size.h)); - -#if 1 - if ((PtWidgetIsClass(mWidget, PtWindow)) || (PtWidgetIsClass(mWidget, PtRegion))) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::UpdateWidgetDamaged mWidget=<%p> is a PtWindow, set x,y=0\n", mWidget)); - area.pos.x = area.pos.y = 0; - } -#endif - -#if defined(ENABLE_DOPAINT) - // HACK, call RawDrawFunc directly instead of Damaging the widget - printf("nsWidget::UpdateWidgetDamaged calling doPaint\n"); - doPaint(); -#else - if (NS_FAILED(mUpdateArea->GetRects(®ionRectSet))) - { - NS_ASSERTION(0,"nsWidget::UpdateWidgetDamaged Error mUpdateArea->GetRects returned NULL"); - return; - } + if (NS_FAILED(mUpdateArea->GetRects(®ionRectSet))) { + NS_ASSERTION(0,"nsWidget::UpdateWidgetDamaged Error mUpdateArea->GetRects returned NULL"); + return; + } -#if 0 - int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtContainerHold(mWidget); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged PtHold Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); -#endif + len = regionRectSet->mRectsLen; - len = regionRectSet->mRectsLen; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::UpdateWidgetDamaged %d rects to damage\n", len)); - - for (i=0;imRects[i]); temp_rect.SetRect(r->x, r->y, r->width, r->height); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::UpdateWidgetDamaged %d temp_rect=(%d,%d,%d,%d)\n", i, r->x, r->y, r->width, r->height)); - - if( GetParentClippedArea(temp_rect)) - { + if( GetParentClippedArea( temp_rect ) ) { extent.ul.x = temp_rect.x + area.pos.x; extent.ul.y = temp_rect.y + area.pos.y; extent.lr.x = extent.ul.x + temp_rect.width - 1; extent.lr.y = extent.ul.y + temp_rect.height - 1; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::UpdateWidgetDamaged this=<%p> mWidget=<%p> PtDamageExtent=(%d,%d,%d,%d)\n", this, mWidget, extent.ul.x, extent.ul.y, extent.lr.x, extent.lr.y)); - PtDamageExtent( mWidget, &extent ); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged SKIPPING due to GetParentClippedArea this=<%p> extent=(%d,%d,%d,%d)\n", this, extent.ul.x, extent.ul.y, extent.lr.x, extent.lr.y)); - } - } + } + } - // drop the const.. whats the right thing to do here? - mUpdateArea->FreeRects(regionRectSet); -#endif + // drop the const.. whats the right thing to do here? + mUpdateArea->FreeRects(regionRectSet); - //PtFlush(); //HOLD_HACK + //PtFlush(); //HOLD_HACK -#if 0 - Global_Widget_Hold_Count = PtContainerRelease(mWidget); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::UpdateWidgetDamaged PtHold/PtRelease Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); -#endif - - mUpdateArea->SetTo(0,0,0,0); -} + mUpdateArea->SetTo(0,0,0,0); + } -void nsWidget::RemoveDamagedWidget(PtWidget_t *aWidget) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::RemoveDamagedWidget Photon Widget=<%p>\n", aWidget)); +void nsWidget::RemoveDamagedWidget( PtWidget_t *aWidget ) { - if( mDmgQueueInited ) - { - DamageQueueEntry *dqe; - DamageQueueEntry *last_dqe = nsnull; + if( mDmgQueueInited ) { + DamageQueueEntry *dqe; + DamageQueueEntry *last_dqe = nsnull; - dqe = mDmgQueue; + dqe = mDmgQueue; - // If this widget is in the queue, remove it - while( dqe ) - { - if( dqe->widget == aWidget ) - { - if( last_dqe ) - last_dqe->next = dqe->next; - else - mDmgQueue = dqe->next; + // If this widget is in the queue, remove it + while( dqe ) { + if( dqe->widget == aWidget ) { + if( last_dqe ) last_dqe->next = dqe->next; + else mDmgQueue = dqe->next; - delete dqe; - break; - } - last_dqe = dqe; - dqe = dqe->next; - } + delete dqe; + break; + } + last_dqe = dqe; + dqe = dqe->next; + } - /* If removing the item empties the queue */ - if( nsnull == mDmgQueue ) - { - mDmgQueueInited = PR_FALSE; + /* If removing the item empties the queue */ + if( nsnull == mDmgQueue ) { + mDmgQueueInited = PR_FALSE; #ifdef ENABLE_DAMAGE_QUEUE_HOLDOFF - /* The matching PtHold is in nsWidget::InitDamageQueue */ - int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtRelease(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::RemoveDamagedWidget PtHold/PtRelease Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); + PtRelease(); #endif - if( mWorkProcID ) - PtAppRemoveWorkProc( nsnull, mWorkProcID ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::RemoveDamagedWidget finished removing last item\n")); - } - } -} + if( mWorkProcID ) PtAppRemoveWorkProc( nsnull, mWorkProcID ); + } + } + } int nsWidget::WorkProc( void *data ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::WorkProc begin\n")); - DamageQueueEntry **dq = (DamageQueueEntry **) data; - if( dq && (*dq)) - { + if( dq && (*dq) ) { DamageQueueEntry *dqe = *dq; DamageQueueEntry *last_dqe; PhRect_t extent; @@ -2530,55 +1807,31 @@ int nsWidget::WorkProc( void *data ) /* This uses the new mUpdateRect */ - while( dqe ) - { - if( PtWidgetIsRealized( dqe->widget )) - { -#if defined( ENABLE_DOPAINT) - printf("nsWidget::WorkProc calling doPaint\n"); - dqe->inst->doPaint(); -#else + while( dqe ) { + if( PtWidgetIsRealized( dqe->widget ) ) { nsRegionRectSet *regionRectSet = nsnull; PRUint32 len; PRUint32 i; nsRect temp_rect; PtWidgetArea( dqe->widget, &area ); // parent coords - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> area=<%d,%d,%d,%d>\n", dqe->widget, area.pos.x, area.pos.y, area.size.w, area.size.h)); -//printf("nsWidget::WorkProc PtWindow origin at (%d,%d) IsEmpty=<%d>\n", area.pos.x, area.pos.y, dqe->inst->mUpdateArea->IsEmpty()); - -// this was enabled... what was it doing? -#if 0 - /* Is forcing the damage to 0,0 really a good idea here?? */ - if ((PtWidgetIsClass(dqe->widget, PtWindow)) || (PtWidgetIsClass(dqe->widget, PtRegion))) - { - printf("nsWidget::WorkProc Forced PtWindow origin to 0,0\n"); - area.pos.x = area.pos.y = 0; - } -#endif - - if (dqe->inst->mUpdateArea->IsEmpty()) - { -PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> mUpdateArea empty\n")); + if( dqe->inst->mUpdateArea->IsEmpty( ) ) { extent.ul.x = 0; //area.pos.x; // convert widget coords to parent extent.ul.y = 0; //area.pos.y; extent.lr.x = extent.ul.x + area.size.w - 1; extent.lr.y = extent.ul.y + area.size.h - 1; PtWidget_t *aPtWidget; - nsWidget *aWidget = GetInstance( (PtWidget_t *) dqe->widget ); + nsWidget *aWidget = GetInstance( (PtWidget_t *) dqe->widget ); aPtWidget = (PtWidget_t *)aWidget->GetNativeData(NS_NATIVE_WIDGET); PtDamageExtent( aPtWidget, &extent); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> %d PtDamageExtent=<%d,%d,%d,%d> next=<%p>\n", aPtWidget, i, extent.ul.x, extent.ul.y, extent.lr.x, extent.lr.y, dqe->next)); - } - else - { + } + else { dqe->inst->mUpdateArea->GetRects(®ionRectSet); len = regionRectSet->mRectsLen; - for (i=0;imRects[i]); // convert widget coords to parent @@ -2589,17 +1842,14 @@ PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> mUpdate extent.lr.y = extent.ul.y + temp_rect.height - 1; PtWidget_t *aPtWidget; - nsWidget *aWidget = GetInstance( (PtWidget_t *) dqe->widget ); + nsWidget *aWidget = GetInstance( (PtWidget_t *) dqe->widget ); aPtWidget = (PtWidget_t *)aWidget->GetNativeData(NS_NATIVE_WIDGET); PtDamageExtent( aPtWidget, &extent); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> %d PtDamageExtent=<%d,%d,%d,%d> next=<%p>\n", aPtWidget, i, extent.ul.x, extent.ul.y, extent.lr.x, extent.lr.y, dqe->next)); - } + } dqe->inst->mUpdateArea->FreeRects(regionRectSet); dqe->inst->mUpdateArea->SetTo(0,0,0,0); - } -#endif //end of doPaint Hack + } } last_dqe = dqe; @@ -2609,90 +1859,57 @@ PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidget::WorkProc damaging widget=<%p> mUpdate *dq = nsnull; mDmgQueueInited = PR_FALSE; - int Global_Widget_Hold_Count; #ifdef ENABLE_DAMAGE_QUEUE_HOLDOFF - /* The matching PtHold is in nsWidget::InitDamageQueue */ - Global_Widget_Hold_Count = PtRelease(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::WorkProc end, PtHold/PtRelease Global_Widget_Hold_Count=<%d>\n", Global_Widget_Hold_Count)); + /* The matching PtHold is in nsWidget::InitDamageQueue */ + PtRelease(); #endif - -#if 0 - Global_Widget_Hold_Count = PtFlush(); /* this may not be necessary since after PtRelease */ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::WorkProc PtFlush Global_Widget_Hold_Count=<%d>\n", Global_Widget_Hold_Count)); -#endif - } + } return Pt_END; -} + } -int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) -{ +int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { nsWidget *pWidget = (nsWidget *) data; -/* - if (widget->parent) - printf("nsWidget::GotFocusCallback widget->parent=<%p> PtIsFocused(widget)=<%d>\n", widget->parent, PtIsFocused(widget)); - else - printf("nsWidget::GotFocusCallback widget->parent=<%p>\n", widget->parent); -*/ - - if ((!widget->parent) || (PtIsFocused(widget) != 2)) - { - //printf("nsWidget::GotFocusCallback widget->parent=<%p>\n", widget->parent); - return Pt_CONTINUE; - } + if( !widget->parent || PtIsFocused(widget) != 2 ) return Pt_CONTINUE; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::GotFocusCallback pWidget=<%p>\n", pWidget)); pWidget->DispatchStandardEvent(NS_GOTFOCUS); return Pt_CONTINUE; -} + } -int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) -{ +int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { nsWidget *pWidget = (nsWidget *) data; - if ((widget->parent) && (PtIsFocused(widget) != 2)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::LostFocusCallback Not on focus leaf! PtIsFocused(mWidget)=<%d>\n", PtIsFocused(widget) )); - return Pt_CONTINUE; - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::LostFocusCallback pWidget=<%p>\n", pWidget)); + if ((widget->parent) && (PtIsFocused(widget) != 2)) return Pt_CONTINUE; // pWidget->DispatchStandardEvent(NS_LOSTFOCUS); return Pt_CONTINUE; -} + } -int nsWidget::DestroyedCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) -{ +int nsWidget::DestroyedCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { nsWidget *pWidget = (nsWidget *) data; - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidget::DestroyedCallback pWidget=<%p> mWidget=<%p> mIsDestroying=<%d>\n", pWidget, pWidget->mWidget, pWidget->mIsDestroying)); - if (!pWidget->mIsDestroying) - { + if( !pWidget->mIsDestroying ) { pWidget->RemoveDamagedWidget(pWidget->mWidget); pWidget->OnDestroy(); - } - + } return Pt_CONTINUE; -} + } -void nsWidget::EnableDamage( PtWidget_t *widget, PRBool enable ) -{ +void nsWidget::EnableDamage( PtWidget_t *widget, PRBool enable ) { PtWidget_t *top = PtFindDisjoint( widget ); - if( top ) - { + if( top ) { if( PR_TRUE == enable ) PtEndFlux( top ); else PtStartFlux( top ); - } -} + } + } //#if defined(DEBUG) /**************************************************************/ diff --git a/widget/src/photon/nsWidget.h b/widget/src/photon/nsWidget.h index 49f6b57d8905..e74bfb9f1b02 100644 --- a/widget/src/photon/nsWidget.h +++ b/widget/src/photon/nsWidget.h @@ -146,6 +146,7 @@ public: // nsIKBStateControl NS_IMETHOD ResetInputState(); + NS_IMETHOD PasswordFieldInit(); void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull); @@ -164,9 +165,6 @@ public: static PRBool SetInstance( PtWidget_t *pWidget, nsWidget * inst ); static nsWidget* GetInstance( PtWidget_t *pWidget ); - // Raw Paint Method - NS_IMETHOD doPaint(); - protected: virtual void InitCallbacks(char * aName = nsnull); diff --git a/widget/src/photon/nsWidgetFactory.cpp b/widget/src/photon/nsWidgetFactory.cpp index 467aa22f6bd1..8c1aae3cbdc6 100644 --- a/widget/src/photon/nsWidgetFactory.cpp +++ b/widget/src/photon/nsWidgetFactory.cpp @@ -27,26 +27,15 @@ #include "nsWidgetsCID.h" #include "nsWindow.h" -#include "nsButton.h" -//#include "nsCheckButton.h" -#include "nsFileWidget.h" -#include "nsTextWidget.h" #include "nsAppShell.h" #include "nsToolkit.h" #include "nsLookAndFeel.h" -//#include "nsLabel.h" #include "nsTransferable.h" #include "nsClipboard.h" #include "nsHTMLFormatConverter.h" -#include "nsFontRetrieverService.h" #include "nsDragService.h" #include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" -#include "nsSound.h" - -#ifdef IBMBIDI -#include "nsBidiKeyboard.h" -#endif #include struct PRLogModuleInfo *PhWidLog = nsnull; @@ -54,32 +43,20 @@ struct PRLogModuleInfo *PhWidLog = nsnull; NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton) -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) -#ifdef IBMBIDI -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -#endif static nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult) { nsresult rv; nsISupports *inst = nsnull; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidgetFactory::nsHorizScrollbarConstructor\n")); - if ( NULL == aResult ) { rv = NS_ERROR_NULL_POINTER; @@ -109,7 +86,6 @@ static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, nsresult rv; nsISupports *inst = nsnull; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWidgetFactory::nsVertScrollbarConstructor\n")); if ( NULL == aResult ) { rv = NS_ERROR_NULL_POINTER; @@ -144,20 +120,6 @@ static nsModuleComponentInfo components[] = NS_CHILD_CID, "@mozilla.org/widgets/child_window/ph;1", ChildWindowConstructor }, - { "Ph Button", - NS_BUTTON_CID, - "@mozilla.org/widgets/button/ph;1", - nsButtonConstructor }, -/* - { "Ph Check Button", - NS_CHECKBUTTON_CID, - "@mozilla.org/widgets/checkbutton/ph;1", - nsCheckButtonConstructor }, -*/ - { "Ph File Widget", - NS_FILEWIDGET_CID, - "@mozilla.org/widgets/filewidget/ph;1", - nsFileWidgetConstructor }, { "Ph Horiz Scrollbar", NS_HORZSCROLLBAR_CID, "@mozilla.org/widgets/horizscroll/ph;1", @@ -166,10 +128,6 @@ static nsModuleComponentInfo components[] = NS_VERTSCROLLBAR_CID, "@mozilla.org/widgets/vertscroll/ph;1", nsVertScrollbarConstructor }, - { "Ph Text Widget", - NS_TEXTFIELD_CID, - "@mozilla.org/widgets/textwidget/ph;1", - nsTextWidgetConstructor }, { "Ph AppShell", NS_APPSHELL_CID, "@mozilla.org/widget/appshell/ph;1", @@ -182,17 +140,6 @@ static nsModuleComponentInfo components[] = NS_LOOKANDFEEL_CID, "@mozilla.org/widget/lookandfeel/ph;1", nsLookAndFeelConstructor }, -/* - { "Ph Label", - NS_LABEL_CID, - "@mozilla.org/widget/label/ph;1", - nsLabelConstructor }, -*/ - { "Ph Sound", - NS_SOUND_CID, - // "@mozilla.org/widget/sound/ph;1" - "@mozilla.org/sound;1", - nsSoundConstructor }, { "Transferrable", NS_TRANSFERABLE_CID, // "@mozilla.org/widget/transferrable/ph;1", @@ -207,21 +154,12 @@ static nsModuleComponentInfo components[] = NS_HTMLFORMATCONVERTER_CID, "@mozilla.org/widget/htmlformatconverter/ph;1", nsHTMLFormatConverterConstructor }, - { "Ph Font Retriever Service", - NS_FONTRETRIEVERSERVICE_CID, - "@mozilla.org/widget/fontretrieverservice/ph;1", - nsFontRetrieverServiceConstructor }, { "Ph Drag Service", NS_DRAGSERVICE_CID, // "@mozilla.org/widget/dragservice/ph;1", "@mozilla.org/widget/dragservice;1", nsDragServiceConstructor }, -#ifdef IBMBIDI - { "Ph Bidi Keyboard", - NS_BIDIKEYBOARD_CID, - "@mozilla.org/widget/bidikeyboard;1", - nsBidiKeyboardConstructor }, -#endif // IBMBIDI + { "File Spec with UI", NS_FILESPECWITHUI_CID, // "@mozilla.org/widget/filespecwithui/ph;1", diff --git a/widget/src/photon/nsWindow.cpp b/widget/src/photon/nsWindow.cpp index 7d17b8b67790..fcf886a429c6 100644 --- a/widget/src/photon/nsWindow.cpp +++ b/widget/src/photon/nsWindow.cpp @@ -25,6 +25,7 @@ #include "nsPhWidgetLog.h" #include +#include #include "PtRawDrawContainer.h" #include "nsWindow.h" @@ -67,9 +68,6 @@ unsigned long IgnoreEvent = 0; //------------------------------------------------------------------------- nsWindow::nsWindow() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::nsWindow (%p)\n", this )); - //NS_INIT_REFCNT(); - mClientWidget = nsnull; mShell = nsnull; mFontMetrics = nsnull; @@ -87,33 +85,21 @@ nsWindow::nsWindow() mFont = nsnull; mMenuBar = nsnull; mMenuBarVis = PR_FALSE; - mFrameLeft = 0; - mFrameRight = 0; - mFrameTop = 0; - mFrameBottom = 0; mIsDestroyingWindow = PR_FALSE; - if (mLastLeaveWindow == this) - mLastLeaveWindow = NULL; - if (mLastDragMotionWindow == this) - mLastDragMotionWindow = NULL; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" border=%X, window=%X\n", mBorderStyle, mWindowType )); + if( mLastLeaveWindow == this ) mLastLeaveWindow = NULL; + if( mLastDragMotionWindow == this ) mLastDragMotionWindow = NULL; } ChildWindow::ChildWindow() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("ChildWindow::ChildWindow this=(%p)\n", this )); mBorderStyle = eBorderStyle_none; mWindowType = eWindowType_child; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" border=%X, window=%X\n", mBorderStyle, mWindowType )); } ChildWindow::~ChildWindow() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("ChildWindow::~ChildWindow this=(%p)\n", this )); } PRBool ChildWindow::IsChild() const @@ -128,18 +114,14 @@ PRBool ChildWindow::IsChild() const //------------------------------------------------------------------------- nsWindow::~nsWindow() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::~nsWindow this=(%p)\n", this )); - // make sure that we release the grab indicator here if (mGrabWindow == this) { mIsGrabbing = PR_FALSE; mGrabWindow = NULL; - } + } // make sure that we unset the lastDragMotionWindow if // we are it. - if (mLastDragMotionWindow == this) { - mLastDragMotionWindow = NULL; - } + if (mLastDragMotionWindow == this) mLastDragMotionWindow = NULL; // always call destroy. if it's already been called, there's no harm // since it keeps track of when it's already been called. @@ -156,18 +138,12 @@ PRBool nsWindow::IsChild() const NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::WidgetToScreen this=<%p> mBounds=<%d,%d,%d,%d> aOldRect=<%d,%d>\n", this, mBounds.x, mBounds.y, mBounds.width, mBounds.height,aOldRect.x,aOldRect.y )); PhPoint_t p1; - if (mWidget) - { - PtWidgetOffset(mWidget,&p1); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::WidgetToScreen mWidget offset <%d,%d>\n", p1.x, p1.y)); - } + if( mWidget ) PtWidgetOffset(mWidget,&p1); - - aNewRect.x = p1.x + mBounds.x + aOldRect.x; - aNewRect.y = p1.y + mBounds.y + aOldRect.y; + aNewRect.x = p1.x + mBounds.x + aOldRect.x; + aNewRect.y = p1.y + mBounds.y + aOldRect.y; return NS_OK; } @@ -204,124 +180,33 @@ void nsWindow::DestroyNative(void) void nsWindow::DestroyNativeChildren(void) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::DestroyNativeChildren this=(%p)\n", this)); - for(PtWidget_t *w=PtWidgetChildFront( mWidget ); w; w=PtWidgetBrotherBehind( w )) { nsWindow *childWindow = NS_STATIC_CAST(nsWindow *, GetInstance(w) ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::DestroyNativeChildren this=(%p) childWindow=<%p> photon_widget=<%p>\n", this, childWindow, w)); - if (childWindow) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::DestroyNativeChildren \t mIsDestroying=<%d> mOnDestroyCalled=<%d> \n", childWindow->mIsDestroying, childWindow->mOnDestroyCalled)); - if (!childWindow->mIsDestroying) - { - childWindow->Destroy(); - } - } + if( childWindow && !childWindow->mIsDestroying) childWindow->Destroy(); } - -// PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::DestroyNativeChildren exiting this=(%p)\n", this)); } NS_IMETHODIMP nsWindow::Update(void) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Update this=<%p> mUpdateArea=<%p> mUpdateArea->IsEmpty()=<%d>\n", this, mUpdateArea, mUpdateArea->IsEmpty() )); - -#if 1 return nsWidget::Update(); -#else - -// if (mIsUpdating) -// UnqueueDraw(); - - if (mWidget == NULL) - { -// printf("nsWindow::Update mWidget is NULL\n"); - NS_ASSERTION(0, "nsWidget::UpdateWidgetDamaged mWidget is NULL"); - return; - } - - if( !PtWidgetIsRealized( mWidget )) - { - //NS_ASSERTION(0, "nsWidget::UpdateWidgetDamaged skipping update because widget is not Realized"); -// printf("nsWindow::Update mWidget is not realized\n"); - return; - } - - if ((mUpdateArea) && (!mUpdateArea->IsEmpty())) - { -#if 1 - - PhTile_t * nativeRegion = nsnull; - - mUpdateArea->GetNativeRegion((void *&) nativeRegion ); - - if (nativeRegion) - { - RawDrawFunc(mWidget, PhCopyTiles(nativeRegion)); - } - else - { - //printf("nsWindow::Update mWidget has NULL nativeRegion\n"); - } -#else - nsRegionRectSet *regionRectSet = nsnull; - - if (NS_FAILED(mUpdateArea->GetRects(®ionRectSet))) - return NS_ERROR_FAILURE; - - PRUint32 len; - PRUint32 i; - - len = regionRectSet->mRectsLen; - - for (i=0;imRects[i]); - //DoPaint (r->x, r->y, r->width, r->height, mUpdateArea); - } - mUpdateArea->FreeRects(regionRectSet); -#endif - - mUpdateArea->SetTo(0, 0, 0, 0); - return NS_OK; - } - - // While I'd think you should NS_RELEASE(aPaintEvent.widget) here, - // if you do, it is a NULL pointer. Not sure where it is getting - // released. - return NS_OK; -#endif } -NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, - PRBool aDoCapture, - PRBool aConsumeRollupEvent) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CaptureRollupEvents this=<%p> doCapture=<%i> aConsumeRollupEvent=<%d>\n", this, aDoCapture, aConsumeRollupEvent)); - +NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent ) { PtWidget_t *grabWidget; grabWidget = mWidget; - if (aDoCapture) - { - /* Create a pointer region */ + if (aDoCapture) { /* Create a pointer region */ mIsGrabbing = PR_TRUE; mGrabWindow = this; - } - else - { + } + else { // make sure that the grab window is marked as released - if (mGrabWindow == this) - { - mGrabWindow = NULL; - } - + if (mGrabWindow == this) mGrabWindow = NULL; mIsGrabbing = PR_FALSE; - } + } if (aDoCapture) { - // gtk_grab_add(mWidget); NS_IF_RELEASE(gRollupListener); NS_IF_RELEASE(gRollupWidget); gRollupConsumeRollupEvent = PR_TRUE; @@ -329,70 +214,38 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener, NS_ADDREF(aListener); gRollupWidget = this; NS_ADDREF(this); - } else { - // gtk_grab_remove(mWidget); + } + else { NS_IF_RELEASE(gRollupListener); //gRollupListener = nsnull; NS_IF_RELEASE(gRollupWidget); - } + } return NS_OK; } NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 1 this=<%p> IsSynch=<%d> mBounds=(%d,%d,%d,%d)\n", this, aIsSynchronous, - mBounds.x, mBounds.y, mBounds.width, mBounds.height)); - - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 1 - mWidget is NULL!\n" )); - return NS_OK; // mWidget will be null during printing. - } - - if (!PtWidgetIsRealized(mWidget)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 1 - mWidget is not realized\n")); - return NS_OK; - } + if (!mWidget) return NS_OK; // mWidget will be null during printing. + if (!PtWidgetIsRealized(mWidget)) return NS_OK; /* Damage has to be relative Widget coords */ mUpdateArea->SetTo( 0,0, mBounds.width, mBounds.height ); - if (aIsSynchronous) - { - UpdateWidgetDamage(); - } - else - { - QueueWidgetDamage(); - } + if (aIsSynchronous) UpdateWidgetDamage(); + else QueueWidgetDamage(); return NS_OK; } NS_IMETHODIMP nsWindow::Invalidate(const nsRect &aRect, PRBool aIsSynchronous) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 2 this=<%p> IsSynch=<%d> mBounds=(%d,%d,%d,%d) aRect=(%d,%d,%d,%d)\n", this, aIsSynchronous, - mBounds.x, mBounds.y, mBounds.width, mBounds.height,aRect.x, aRect.y, aRect.width, aRect.height)); - - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 2 - mWidget is NULL!\n" )); - return NS_OK; // mWidget will be null during printing. - } - - if (!PtWidgetIsRealized(mWidget)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Invalidate 2 - mWidget is not realized\n")); - return NS_OK; - } + if (!mWidget) return NS_OK; // mWidget will be null during printing. + if (!PtWidgetIsRealized(mWidget)) return NS_OK; /* Offset the rect by the mBounds X,Y to fix damaging inside widget in test14 */ - if (mWindowType == eWindowType_popup) - mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); - else - mUpdateArea->Union((aRect.x+mBounds.x), (aRect.y+mBounds.y), aRect.width, aRect.height); + if (mWindowType == eWindowType_popup) mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); + else mUpdateArea->Union((aRect.x+mBounds.x), (aRect.y+mBounds.y), aRect.width, aRect.height); if (aIsSynchronous) { @@ -410,95 +263,43 @@ NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSyn { nsIRegion *newRegion; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::InvalidateRegion this=<%p> IsSynch=<%d> mBounds=(%d,%d,%d,%d)\n", this, aIsSynchronous, - mBounds.x, mBounds.y, mBounds.width, mBounds.height)); + if (!mWidget) return NS_OK; // mWidget will be null during printing. + if (!PtWidgetIsRealized(mWidget)) return NS_OK; - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::InvalidateRegion - mWidget is NULL!\n" )); - return NS_OK; // mWidget will be null during printing. - } - - if (!PtWidgetIsRealized(mWidget)) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::InvalidateRegion - mWidget is not realized\n")); - return NS_OK; - } - - newRegion = GetRegion(); - newRegion->SetTo(*aRegion); + newRegion = GetRegion( ); + newRegion->SetTo( *aRegion ); -#if defined(DEBUG) && 1 -{ - PRUint32 len; - PRUint32 i; - nsRegionRectSet *regionRectSet = nsnull; - - newRegion->GetRects(®ionRectSet); - len = regionRectSet->mRectsLen; - for (i=0;imRects[i]); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::InvalidateRegion rect %d is <%d,%d,%d,%d>\n", i, r->x, r->y, r->width, r->height)); - } - - newRegion->FreeRects(regionRectSet); -} -#endif - - if (mWindowType != eWindowType_popup) newRegion->Offset(mBounds.x, mBounds.y); mUpdateArea->Union(*newRegion); - if (aIsSynchronous) - { - UpdateWidgetDamage(); - } - else - { - QueueWidgetDamage(); - } - + NS_RELEASE( newRegion ); + + if (aIsSynchronous) UpdateWidgetDamage(); + else QueueWidgetDamage(); + return NS_OK; } -NS_IMETHODIMP nsWindow::SetBackgroundColor(const nscolor &aColor) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetBackgroundColor this=<%p> color(RGB)=(%d,%d,%d)\n", this, NS_GET_R(aColor),NS_GET_G(aColor),NS_GET_B(aColor))); +NS_IMETHODIMP nsWindow::SetBackgroundColor( const nscolor &aColor ) { return nsWidget::SetBackgroundColor(aColor); -} + } -NS_IMETHODIMP nsWindow::SetFocus(void) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetFocus this=<%p>\n", this)); +NS_IMETHODIMP nsWindow::SetFocus( void ) { return nsWidget::SetFocus(); -} + } -NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData) -{ -// PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PreCreateWidget\n")); - - if (nsnull != aInitData) - { +NS_METHOD nsWindow::PreCreateWidget( nsWidgetInitData *aInitData ) { + if (nsnull != aInitData) { SetWindowType( aInitData->mWindowType ); SetBorderStyle( aInitData->mBorderStyle ); -// mClipChildren = aInitData->clipChildren; -// mClipSiblings = aInitData->clipSiblings; - -// if (mWindowType==1) mClipChildren = PR_FALSE; else mClipChildren = PR_TRUE; -// if (mWindowType==2) mClipSiblings = PR_TRUE; else mClipSiblings = PR_FALSE; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PreCreateWidget mClipChildren=<%d> mClipSiblings=<%d> mBorderStyle=<%d> mWindowType=<%d>\n", - mClipChildren, mClipSiblings, mBorderStyle, mWindowType)); - return NS_OK; - } + } return NS_ERROR_FAILURE; -} + } //------------------------------------------------------------------------- @@ -506,10 +307,7 @@ NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData) // Create the native widget // //------------------------------------------------------------------------- -NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CreateNative this=(%p) - PhotonParent=<%p> IsChild=<%d> mParent=<%p>\n", this, parentWidget, IsChild(), mParent)); - +NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) { PtArg_t arg[20]; int arg_count = 0; PhPoint_t pos; @@ -522,30 +320,22 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) dim.w = mBounds.width; dim.h = mBounds.height; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CreateNative - bounds = (%d,%d,%d,%d)\n", mBounds.x, mBounds.y, mBounds.width, mBounds.height )); - switch( mWindowType ) { case eWindowType_popup : - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("\twindow type = popup\n" )); mIsToplevel = PR_TRUE; break; case eWindowType_toplevel : - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("\twindow type = toplevel\n" )); mIsToplevel = PR_TRUE; break; case eWindowType_dialog : - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("\twindow type = dialog\n" )); mIsToplevel = PR_TRUE; - break; + break; case eWindowType_child : - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("\twindow type = child\n" )); mIsToplevel = PR_FALSE; - break; + break; } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("\tborder style = %X\n", mBorderStyle )); - if ( mWindowType == eWindowType_child ) { arg_count = 0; @@ -563,12 +353,8 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) // No border or decorations is the default render_flags = 0; - if( mWindowType == eWindowType_popup ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" Creating a pop-up (no decorations).\n" )); - } - else - { + if( mWindowType != eWindowType_popup ) { + #define PH_BORDER_STYLE_ALL \ Ph_WM_RENDER_TITLE | \ Ph_WM_RENDER_CLOSE | \ @@ -579,35 +365,17 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) Ph_WM_RENDER_MENU - if( mBorderStyle & eBorderStyle_all ) - { - render_flags = PH_BORDER_STYLE_ALL; - } + if( mBorderStyle & eBorderStyle_all ) render_flags = PH_BORDER_STYLE_ALL; else { - if( mBorderStyle & eBorderStyle_border ) - render_flags |= Ph_WM_RENDER_BORDER; - - if( mBorderStyle & eBorderStyle_title ) - render_flags |= ( Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER ); - - if( mBorderStyle & eBorderStyle_close ) - render_flags |= Ph_WM_RENDER_CLOSE; - - if( mBorderStyle & eBorderStyle_menu ) - render_flags |= Ph_WM_RENDER_MENU; - - if( mBorderStyle & eBorderStyle_resizeh ) - render_flags |= Ph_WM_RENDER_RESIZE; - - if( mBorderStyle & eBorderStyle_minimize ) - render_flags |= Ph_WM_RENDER_MIN; - - if( mBorderStyle & eBorderStyle_maximize ) - render_flags |= Ph_WM_RENDER_MAX; + if( mBorderStyle & eBorderStyle_border ) render_flags |= Ph_WM_RENDER_BORDER; + if( mBorderStyle & eBorderStyle_title ) render_flags |= ( Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER ); + if( mBorderStyle & eBorderStyle_close ) render_flags |= Ph_WM_RENDER_CLOSE; + if( mBorderStyle & eBorderStyle_menu ) render_flags |= Ph_WM_RENDER_MENU; + if( mBorderStyle & eBorderStyle_resizeh ) render_flags |= Ph_WM_RENDER_RESIZE; + if( mBorderStyle & eBorderStyle_minimize ) render_flags |= Ph_WM_RENDER_MIN; + if( mBorderStyle & eBorderStyle_maximize ) render_flags |= Ph_WM_RENDER_MAX; } - - /* Remove data members: mFrameLeft, mFrameTop, mFrameRight, mFrameBottom ? */ } arg_count = 0; @@ -622,9 +390,9 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) } else if ((mWindowType == eWindowType_toplevel) && parentWidget) { - PhPoint_t p = nsToolkit::GetConsoleOffset(); - pos.x += p.x; - pos.y += p.y; + PhPoint_t p = nsToolkit::GetConsoleOffset(); + pos.x += p.x; + pos.y += p.y; PtSetArg( &arg[arg_count++], Pt_ARG_POS, &pos, 0 ); } @@ -638,11 +406,8 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) if( mWindowType == eWindowType_popup ) { - int fields = Ph_REGION_PARENT|Ph_REGION_HANDLE| - Ph_REGION_FLAGS|Ph_REGION_ORIGIN| - Ph_REGION_EV_SENSE|Ph_REGION_EV_OPAQUE| - Ph_REGION_RECT; - + int fields = Ph_REGION_PARENT|Ph_REGION_HANDLE| Ph_REGION_FLAGS|Ph_REGION_ORIGIN| + Ph_REGION_EV_SENSE|Ph_REGION_EV_OPAQUE|Ph_REGION_RECT; int sense = Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_BUT_REPEAT; PtRawCallback_t callback; @@ -652,7 +417,7 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) PhRid_t rid; PhRegion_t region; - PhRect_t rect; + PhRect_t rect; PhArea_t area; PtArg_t args[20]; int arg_count2 = 0; @@ -686,8 +451,6 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) PtSetArg( &arg[arg_count++], Pt_ARG_REGION_OPAQUE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW, sense |Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW); PtSetArg( &arg[arg_count++], Pt_ARG_RAW_CALLBACKS, &callback, 1 ); PtSetArg( &args[arg_count++], Pt_ARG_FLAGS, 0, Pt_GETS_FOCUS); - // briane - //mWidget = PtCreateWidget( PtRegion, parentWidget, arg_count, arg); mWidget = PtCreateWidget( PtRegion, parentWidget, arg_count, arg); } else @@ -699,9 +462,7 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_RENDER_FLAGS, render_flags, 0xFFFFFFFF ); PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_CLOSE ); PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 ); - //PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 ); - //mWidget = PtCreateWidget( PtWindow, parentWidget, arg_count, arg ); mWidget = PtCreateWidget( PtWindow, NULL, arg_count, arg ); PtAddCallback(mWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); } @@ -710,7 +471,6 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) if( mWidget ) { arg_count = 0; -// PtSetArg( &arg[arg_count++], Pt_ARG_DIM, &dim, 0 ); PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_FLAGS, Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP | Pt_BOTTOM_ANCHORED_BOTTOM, 0xFFFFFFFF ); @@ -725,22 +485,18 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) { PtSetArg( &arg[arg_count++], RDC_DRAW_FUNC, RawDrawFunc, 0 ); PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, 0, (Pt_HIGHLIGHTED | Pt_GETS_FOCUS)); -// PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_MANAGED_FLAGS, Ph_WM_FFRONT, Ph_WM_FFRONT ); mClientWidget = PtCreateWidget( PtRawDrawContainer, mWidget, arg_count, arg ); } else { PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, 0, Pt_HIGHLIGHTED | Pt_GETS_FOCUS ); PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_YELLOW, 0 ); - //PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 ); } } } if( mWidget ) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CreateNative - mWidget=%p, mClientWidget=%p\n", mWidget, mClientWidget )); - SetInstance( mWidget, this ); if( mClientWidget ) @@ -751,9 +507,7 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) PtAddCallback(mWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); PtAddEventHandler( mWidget, Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON | - Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY|Ph_EV_DRAG -// | Ph_EV_WM -// | Ph_EV_EXPOSE + Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY|Ph_EV_DRAG /* | Ph_EV_WM | Ph_EV_EXPOSE */ , RawEventHandler, this ); PtArg_t arg; @@ -768,11 +522,9 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) else if (mWindowType == eWindowType_popup) { PtAddEventHandler( mClientWidget, - Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON | - Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY - | Ph_EV_WM - | Ph_EV_EXPOSE - , RawEventHandler, this ); + Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON | + Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY | Ph_EV_WM | Ph_EV_EXPOSE, + RawEventHandler, this ); PtArg_t arg; PtRawCallback_t callback; @@ -784,14 +536,10 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) PtSetResources( mClientWidget, 1, &arg ); PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); -// PtAddCallback(mWidget, Pt_CB_WINDOW_CLOSING, WindowCloseHandler, this ); } else if ( !parentWidget ) { - if (mClientWidget) - { - PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); - } + if (mClientWidget) PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); else { PtRawCallback_t filter_cb; @@ -819,8 +567,6 @@ NS_METHOD nsWindow::CreateNative(PtWidget_t *parentWidget) result = NS_OK; } - else - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CreateNative - FAILED TO CREATE WIDGET!\n" )); SetCursor( mCursor ); @@ -838,16 +584,11 @@ void *nsWindow::GetNativeData(PRUint32 aDataType) switch(aDataType) { case NS_NATIVE_WINDOW: - if( !mWidget ) - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetNativeData( NS_NATIVE_WINDOW ) - mWidget is NULL!\n")); - return (void *)mWidget; + if( !mWidget ) return (void *)mWidget; case NS_NATIVE_WIDGET: - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetNativeData( NS_NATIVE_WIDGET ) - this=<%p> mWidget=<%p> mClientWidget=<%p>\n", this, mWidget, mClientWidget)); - if (mClientWidget) - return (void *) mClientWidget; - else - return (void *) mWidget; + if (mClientWidget) return (void *) mClientWidget; + else return (void *) mWidget; } return nsWidget::GetNativeData(aDataType); @@ -860,7 +601,6 @@ void *nsWindow::GetNativeData(PRUint32 aDataType) //------------------------------------------------------------------------- NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetColorMap - Not Implemented.\n")); return NS_OK; } @@ -869,291 +609,84 @@ NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap) // // Scroll the bits of a window // -// This routine is extra-complicated because Photon does not clip PhBlit -// calls correctly. Mozilla expects blits (and other draw commands) to be -// clipped around sibling widgets (and child widgets in some cases). Photon -// does not do this. So most of the grunge below achieves this "clipping" -// manually by breaking the scrollable rect down into smaller, unobscured -// rects that can be safely blitted. To make it worse, the invalidation rects -// must be manually calulated... -// -// Ye have been warn'd -- enter at yer own risk. -// -// DVS -// //------------------------------------------------------------------------- -NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll this=<%p> mWidget=<%p> mClientWidget=<%p> aDx=<%d aDy=<%d> aClipRect=<%p>\n", - this, mWidget, mClientWidget, aDx, aDy, aClipRect)); +NS_METHOD nsWindow::Scroll( PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect ) { + PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - short count = 0; - PhRect_t rect,clip; - PhPoint_t offset = { aDx, aDy }; - PhArea_t area; - PhTile_t *clipped_tiles=nsnull, *sib_tiles=nsnull, *tile=nsnull; - PhTile_t *offset_tiles=nsnull, *intersection = nsnull; + /* If aDx and aDy are 0 then skip it or if widget == null */ + if( ( !aDx && !aDy ) || (!widget )) return NS_OK; - PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - PhRid_t rid = PtWidgetRid( widget ); + PtStartFlux( widget ); - /* If aDx and aDy are 0 then skip it or if widget == null */ - if ( ( !aDx && !aDy ) || (!widget )) - { - return NS_OK; - } + PtWidget_t *w; + for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) { + PtArg_t arg; + PhPoint_t p; + p.x = w->area.pos.x + aDx; + p.y = w->area.pos.y + aDy; + + PtSetArg( &arg, Pt_ARG_POS, &p, 0 ); + PtSetResources( w, 1, &arg ) ; + + nsWindow *pWin = (nsWindow *) GetInstance(w); + if (pWin) { + pWin->mBounds.x += aDx; + pWin->mBounds.y += aDy; + } + } + + PtEndFlux( widget); + + PhRect_t source = { 0, 0, widget->area.size.w, widget->area.size.h }; + PhPoint_t point = { aDx, aDy }; + PtBlit( widget, &source, &point ); -#if defined(DEBUG) && 0 -{ - PtWidget_t *w; + return NS_OK; + } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Children of w=<%p>\n", widget)); - for(count=0, w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w ),count++) - { - PhArea_t area; - PtWidgetArea(w, &area); - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::Scroll Child %d is <%p> at <%d,%d,%d,%d>\n", count, w, area.pos.x, area.pos.y, area.size.w, area.size.h)); +NS_METHOD nsWindow::ScrollWidgets( PRInt32 aDx, PRInt32 aDy ) { + PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - nsWindow *win = (nsWindow *) GetInstance(w); - if (win) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" Moz ptr=<%p> window_type=<%d>\n", win, win->mWindowType)); - } - } + if( ( !aDx && !aDy ) || (!widget )) return NS_OK; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Brothers in front of w=<%p>\n", widget)); - for(count=0, w=PtWidgetBrotherInFront( widget ); w; w=PtWidgetBrotherInFront(w), count++) - { - PhArea_t area; - PtWidgetArea(w, &area); - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::Scroll Brother %d is <%p> at <%d,%d,%d,%d>\n", count, w, area.pos.x, area.pos.y, area.size.w, area.size.h)); + PtStartFlux( widget ); - nsWindow *win = (nsWindow *) GetInstance(w); - if (win) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" Moz ptr=<%p> window_type=<%d>\n", win, win->mWindowType)); - } - } -} -#endif + PtWidget_t *w; + for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) { + PtArg_t arg; + PhPoint_t p; + p.x = w->area.pos.x + aDx; + p.y = w->area.pos.y + aDy; + PtSetArg( &arg, Pt_ARG_POS, &p, 0 ); + PtSetResources( w, 1, &arg ) ; + nsWindow *pWin = (nsWindow *) GetInstance(w); + if (pWin) { + pWin->mBounds.x += aDx; + pWin->mBounds.y += aDy; + } + } - // Manually move all the child-widgets - PtWidget_t *w; - PtArg_t arg; - PhPoint_t *pos; - PhPoint_t p; + PtEndFlux( widget); + return NS_OK; + } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Moving children...\n" )); - for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) - { - PtSetArg( &arg, Pt_ARG_POS, &pos, 0 ); - PtGetResources( w, 1, &arg ) ; - p = *pos; - p.x += aDx; - p.y += aDy; +NS_IMETHODIMP nsWindow::ScrollRect( nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy ) { + NS_WARNING("nsWindow::ScrollRect Not Implemented\n"); + return NS_OK; + } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Moving children PtWidget=<%p> to (%d,%d)\n", w, p.x, p.y)); - - PtSetArg( &arg, Pt_ARG_POS, &p, 0 ); - PtSetResources( w, 1, &arg ) ; - - nsWindow *pWin = (nsWindow *) GetInstance(w); - if (pWin) - { - pWin->mBounds.x += aDx; - pWin->mBounds.y += aDy; - } - } - - // Take our nice, clean client-rect and shatter it into lots (maybe) of - // unobscured tiles. sib_tiles represents the rects occupied by siblings - // in front of our window - but its not needed here. - if ( GetSiblingClippedRegion( &clipped_tiles, &sib_tiles ) == NS_OK ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll GetSiblingClippedRegion returned OK\n")); - -#if defined(DEBUG) && 0 -{ - PhTile_t *top = clipped_tiles; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Damage clipped_tiles Tiles List:\n")); - while (top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::Scroll tile %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } -} -#endif - -#if defined(DEBUG) && 0 -{ - PhTile_t *top = sib_tiles; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Damage sib_tiles Tiles List:\n")); - while (top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::Scroll tile %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } while (top); -} -#endif - - // Now we need to calc the actual blit tiles. We do this by making a copy - // of the client-rect tiles (clipped_tiles) and offseting them by (-aDx,-aDy) - // then intersecting them with the original clipped_tiles. These new tiles (there - // may be none) can be safely blitted to the new location (+aDx,+aDy). - - offset_tiles = PhCopyTiles( clipped_tiles ); - offset.x = -aDx; - offset.y = -aDy; - PhTranslateTiles( offset_tiles, &offset ); - tile = PhCopyTiles( offset_tiles ); // Just a temp copy for next cmd - if (( tile = PhClipTilings( tile, clipped_tiles, &intersection ) ) != NULL ) - { - PhFreeTiles( tile ); - } - - // Apply passed-in clipping, if available - // REVISIT - this wont work, PhBlits ignore clipping - - if( aClipRect ) - { - clip.ul.x = aClipRect->x; - clip.ul.y = aClipRect->y; - clip.lr.x = clip.ul.x + aClipRect->width - 1; - clip.lr.y = clip.ul.y + aClipRect->height - 1; - PgSetUserClip( &clip ); - } - - // Make sure video buffer is up-to-date - PgFlush(); - - offset.x = aDx; - offset.y = aDy; - - // Blit individual tiles - tile = intersection; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Bliting tiles...\n" )); - while( tile ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll blit tile (%i,%i,%i,%i) offset=<%d,%d>\n", - tile->rect.ul.x, tile->rect.ul.y, tile->rect.lr.x, tile->rect.lr.y, offset.x, offset.y)); - PhBlit( rid, &tile->rect, &offset ); - tile = tile->next; - } - - PhFreeTiles( offset_tiles ); - - if( aClipRect ) - PgSetUserClip( nsnull ); - - // Now we must invalidate all of the exposed areas. This is similar to the - // first processes: Make a copy of the clipped_tiles, offset by (+aDx,+aDy) - // then clip (not intersect) these from the original clipped_tiles. This - // results in the invalidated tile list. - - offset_tiles = PhCopyTiles( clipped_tiles ); - PhTranslateTiles( offset_tiles, &offset ); - clipped_tiles = PhClipTilings( clipped_tiles, offset_tiles, nsnull ); - tile = clipped_tiles; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll Damaging tiles...\n" )); - while( tile ) - { - PtDamageExtent( widget, &(tile->rect)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll tile (%i,%i,%i,%i)\n", tile->rect.ul.x, tile->rect.ul.y, tile->rect.lr.x, tile->rect.lr.y )); - tile = tile->next; - } - - PhFreeTiles( offset_tiles ); - PhFreeTiles( clipped_tiles ); - PhFreeTiles( sib_tiles ); - PtFlush(); /* This is really needed! */ - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Scroll clipped out!\n" )); - } - - - return NS_OK; -} - -NS_METHOD nsWindow::ScrollWidgets(PRInt32 aDx, PRInt32 aDy) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ScrollWidgets - Not Implemented this=<%p> mWidget=<%p> mClientWidget=<%p> aDx=<%d aDy=<%d>\n", - this, mWidget, mClientWidget, aDx, aDy)); - - PtWidget_t *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - - // Manually move all the child-widgets - PtWidget_t *w; - PtArg_t arg; - PhPoint_t *pos; - PhPoint_t p; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ScrollWidgets Moving children...\n" )); - for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) - { - PtSetArg( &arg, Pt_ARG_POS, &pos, 0 ); - PtGetResources( w, 1, &arg ) ; - p = *pos; - p.x += aDx; - p.y += aDy; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ScrollWidgets Moving children PtWidhet=<%p> to (%d,%d)\n", w, p.x, p.y)); - - PtSetArg( &arg, Pt_ARG_POS, &p, 0 ); - PtSetResources( w, 1, &arg ) ; - - nsWindow *pWin = (nsWindow *) GetInstance(w); - if (pWin) - { - pWin->mBounds.x += aDx; - pWin->mBounds.y += aDy; - } - } - - return NS_OK; -} - -NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) -{ - NS_WARNING("nsWindow::ScrollRect Not Implemented\n"); - return NS_OK; -} - -NS_METHOD nsWindow::SetTitle(const nsString& aTitle) -{ +NS_METHOD nsWindow::SetTitle( const nsString& aTitle ) { nsresult res = NS_ERROR_FAILURE; char * title = aTitle.ToNewUTF8String(); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetTitle this=<%p> mWidget=<%p> title=<%s>\n", this, mWidget, title)); + if( mWidget ) { + PtSetResource( mWidget, Pt_ARG_WINDOW_TITLE, title, 0 ); + res = NS_OK; + } - if( mWidget ) - { - PtArg_t arg; + if (title) nsCRT::free(title); - PtSetArg( &arg, Pt_ARG_WINDOW_TITLE, title, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - { - res = NS_OK; - } - } - else - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetTitle - mWidget is NULL!\n")); - - if (title) - nsCRT::free(title); - - if (res != NS_OK) - { - NS_ASSERTION(0,"nsWindow::SetTitle Error Setting page Title\n"); - } - return res; } @@ -1164,20 +697,17 @@ NS_METHOD nsWindow::SetTitle(const nsString& aTitle) **/ PRBool nsWindow::OnPaint(nsPaintEvent &event) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::OnPaint - Not Implemented.\n")); return NS_OK; } NS_METHOD nsWindow::BeginResizingChildren(void) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::BeginResizingChildren.\n")); return NS_OK; } NS_METHOD nsWindow::EndResizingChildren(void) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::EndResizingChildren.\n")); return NS_OK; } @@ -1185,37 +715,21 @@ NS_METHOD nsWindow::EndResizingChildren(void) PRBool nsWindow::OnKey(nsKeyEvent &aEvent) { - if (mEventCallback) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::OnKey - mEventCallback=<%p>\n", mEventCallback)); - return DispatchWindowEvent(&aEvent); - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" nsWindow::OnKey - mEventCallback=<%p> Discarding Event!\n", mEventCallback)); - //printf("nsWindow::OnKey Discarding Event, no mEventCallback\n"); - } + if( mEventCallback ) return DispatchWindowEvent(&aEvent); return PR_FALSE; } +// nsWindow::DispatchFocus - Not Implemented PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::DispatchFocus - Not Implemented.\n")); - - if( mEventCallback ) - { -// return DispatchWindowEvent(&aEvent); -// return DispatchStandardEvent(&aEvent); - } - return PR_FALSE; } +// nsWindow::OnScroll - Not Implemented PRBool nsWindow::OnScroll(nsScrollbarEvent &aEvent, PRUint32 cPos) { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::OnScroll - Not Implemented.\n")); return PR_FALSE; } @@ -1224,13 +738,10 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { PRBool nNeedToShow = PR_FALSE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Resize this=<%p> w/h=(%i,%i) Repaint=<%i> mWindowType=<%d>\n", this, aWidth, aHeight, aRepaint, mWindowType )); - mBounds.width = aWidth; mBounds.height = aHeight; // code to keep the window from showing before it has been moved or resized - // if we are resized to 1x1 or less, we will hide the window. Show(TRUE) will be ignored until a // larger resize has happened if (aWidth <= 1 || aHeight <= 1) @@ -1240,19 +751,14 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) aWidth = 1; aHeight = 1; mIsTooSmall = PR_TRUE; - if (mShown) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Resize Forcing small toplevel window window to Hide\n")); - //Show(PR_FALSE); - } +// if(mShown) Show(PR_FALSE); } else { aWidth = 1; aHeight = 1; mIsTooSmall = PR_TRUE; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Resize Forcing small non-toplevel window to Hide\n")); - //Show(PR_FALSE); + //Show(PR_FALSE); } } else @@ -1268,57 +774,40 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) PtArg_t arg; PhDim_t dim = { aWidth, aHeight }; - if( mWidget ) - { - EnableDamage( mWidget, PR_FALSE ); + if( mWidget ) { + EnableDamage( mWidget, PR_FALSE ); - // center the dialog - if (mWindowType == eWindowType_dialog) - { - PhPoint_t p; - PhPoint_t pos = nsToolkit::GetConsoleOffset(); - PtCalcAbsPosition(NULL, NULL, &dim, &p); - p.x -= pos.x; - p.y -= pos.y; - // the move should be in coordinates assuming the console is 0, 0 - Move(p.x, p.y); - } + // center the dialog + if( mWindowType == eWindowType_dialog ) { + PhPoint_t p, pos = nsToolkit::GetConsoleOffset( ); + PtCalcAbsPosition(NULL, NULL, &dim, &p); + p.x -= pos.x; + p.y -= pos.y; + Move(p.x, p.y); // the move should be in coordinates assuming the console is 0, 0 + } PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 ); PtSetResources( mWidget, 1, &arg ); - /* This fixes XUL dialogs */ - if (mClientWidget) - { + /* This fixes XUL dialogs */ + if (mClientWidget) { PtWidget_t *theClientChild = PtWidgetChildBack(mClientWidget); - if (theClientChild) - { + if (theClientChild) { nsWindow * pWin = (nsWindow*) GetInstance( theClientChild ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Resize Resizing mClientWidget->Child this=<%p> mClientWidget=<%p> ChildBack=<%p>\n", this, mClientWidget, pWin)); - pWin->Resize(aWidth, aHeight, aRepaint); - } - } + pWin->Resize(aWidth, aHeight, aRepaint); + } + } EnableDamage( mWidget, PR_TRUE ); -#if 0 - if (mShown) - Invalidate( aRepaint ); -#endif - - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Resize - mWidget is NULL!\n" )); - } + } - if (mIsToplevel || mListenForResizes) - { + if (mIsToplevel || mListenForResizes) { nsSizeEvent sevent; sevent.message = NS_SIZE; sevent.widget = this; sevent.eventStructType = NS_SIZE_EVENT; - sevent.windowSize = new nsRect (0, 0, aWidth, aHeight); + sevent.windowSize = new nsRect (0, 0, aWidth, aHeight); sevent.point.x = 0; sevent.point.y = 0; @@ -1330,91 +819,54 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) DispatchWindowEvent(&sevent); Release(); delete sevent.windowSize; - } + } - if (nNeedToShow) - { - //printf("nsWindow::Resize Forcing window to Show\n"); - Show(PR_TRUE); - } - + if( nNeedToShow ) Show(PR_TRUE); return NS_OK; -} + } -NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, - PRInt32 aHeight, PRBool aRepaint) -{ +NS_IMETHODIMP nsWindow::Resize( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) { Move(aX,aY); - // resize can cause a show to happen, so do this last Resize(aWidth,aHeight,aRepaint); return NS_OK; -} + } -/////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////// - -int nsWindow::WindowCloseHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::WindowCloseHandler this=(%p)\n", data)); +int nsWindow::WindowCloseHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { PhWindowEvent_t *we = (PhWindowEvent_t *) cbinfo->cbdata; nsWindow * win = (nsWindow*) data; - if (we->event_f == Ph_WM_CLOSE) - { - NS_ADDREF(win); + if( we->event_f == Ph_WM_CLOSE ) { + NS_ADDREF(win); - // dispatch an "onclose" event. to delete immediately, call win->Destroy() - nsGUIEvent event; - nsEventStatus status; + // dispatch an "onclose" event. to delete immediately, call win->Destroy() + nsGUIEvent event; + nsEventStatus status; - event.message = NS_XUL_CLOSE; - event.widget = win; - event.eventStructType = NS_GUI_EVENT; + event.message = NS_XUL_CLOSE; + event.widget = win; + event.eventStructType = NS_GUI_EVENT; - event.time = 0; - event.point.x = 0; - event.point.y = 0; + event.time = 0; + event.point.x = 0; + event.point.y = 0; - win->DispatchEvent(&event, status); - - NS_RELEASE(win); - } + win->DispatchEvent(&event, status); + NS_RELEASE(win); + } return Pt_CONTINUE; -} + } -NS_METHOD nsWindow::Show(PRBool bState) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Show this=<%p> State=<%d> mRefCnt=<%d> mWidget=<%p>\n", this, bState, mRefCnt, mWidget)); - - - if (!mWidget) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Show - mWidget is NULL!\n" )); - return NS_OK; // Will be null durring printing - } - - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Show this=<%p> IsRealized=<%d> mIsTooSmall=<%d>\n", this, PtWidgetIsRealized( mWidget ), mIsTooSmall)); - -#if 0 - // don't show if we are too small - if (mIsTooSmall) - return NS_OK; -#endif +NS_METHOD nsWindow::Show( PRBool bState ) { + if (!mWidget) return NS_OK; // Will be null durring printing EnableDamage(mWidget, PR_FALSE); - if (bState) - { - - if (mWindowType == eWindowType_popup) - { + if (bState) { + if (mWindowType == eWindowType_popup) { short arg_count=0; PtArg_t arg[2]; PhPoint_t pos = nsToolkit::GetConsoleOffset(); @@ -1425,792 +877,156 @@ NS_METHOD nsWindow::Show(PRBool bState) PtRealizeWidget(mMenuRegion); - /* Now that the MenuRegion is Realized make the popup menu a child in front of the big menu */ - PtSetArg( &arg[arg_count++], Pt_ARG_REGION_PARENT, mMenuRegion->rid, 0 ); - PtSetResources(mWidget, arg_count, arg); - } - } - else - { - - if ( (mWindowType == eWindowType_popup)) - - { - PtUnrealizeWidget(mMenuRegion); - } - } + /* Now that the MenuRegion is Realized make the popup menu a child in front of the big menu */ + PtSetArg( &arg[arg_count++], Pt_ARG_REGION_PARENT, mMenuRegion->rid, 0 ); + PtSetResources(mWidget, arg_count, arg); + } + } + else { + if( mWindowType == eWindowType_popup ) PtUnrealizeWidget(mMenuRegion); + } EnableDamage(mWidget, PR_TRUE); - return nsWidget::Show(bState); -} + } //------------------------------------------------------------------------- // // Process all nsWindows messages // //------------------------------------------------------------------------- -PRBool nsWindow::HandleEvent( PtCallbackInfo_t* aCbInfo ) -{ - PRBool result = PR_FALSE; // call the default nsWindow proc - PhEvent_t* event = aCbInfo->event; - - switch ( event->type ) - { - default: - result = nsWidget::HandleEvent(aCbInfo); - break; +PRBool nsWindow::HandleEvent( PtCallbackInfo_t* aCbInfo ) { + return nsWidget::HandleEvent(aCbInfo); } - - return result; -} - void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage ) { nsWindow * pWin = (nsWindow*) GetInstance( pWidget ); nsresult result; PhTile_t * dmg = NULL; - nsIRegion * ClipRegion; PRBool aClipState; nsPaintEvent pev; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc for mWidget=<%p> this=<%p> this->mContext=<%p> pWin->mParent=<%p> mClientWidget=<%p>\n", - pWidget, pWin, pWin->mContext, pWin->mParent, pWin->mClientWidget)); + if( !PtWidgetIsRealized( pWidget ) ) return; -#if defined(DEBUG) && 1 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = damage; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc Damage Tiles List:\n")); - do { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - //printf("nsWindow::%p RawDrawFunc photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", pWidget,index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next); - top=top->next; - } while (top); -} -#endif - - if ( !PtWidgetIsRealized( pWidget )) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc aborted because pWidget was not realized!\n")); - NS_ASSERTION(pWin, "nsWindow::RawDrawFunc aborted because pWidget was not realized!"); - abort(); - return; - } - - if ( !pWin ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc aborted because instance is NULL!\n")); - NS_ASSERTION(pWin, "nsWindow::RawDrawFunc aborted because instance is NULL!"); - return; - } - - /* Why did I think this was important? */ - if ( !pWin->mContext ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc pWin->mContext is NULL!\n")); - NS_ASSERTION(pWin->mContext, "nsWindow::RawDrawFunc pWin->mContext is NULL!"); - return; - } + if( !pWin || !pWin->mContext ) return; // This prevents redraws while any window is resizing, ie there are // windows in the resize queue - if ( pWin->mIsResizing ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc aborted due to hold-off!\n")); - //printf("nsWindow::RawDrawFunc aborted due to Resize holdoff\n"); - return; - } + if( pWin->mIsResizing ) return; - if ( pWin->mEventCallback ) - { - PhRect_t rect; - PhArea_t area = {{0,0},{0,0}}; - PhPoint_t offset = {0,0}; - nsRect nsDmg; + if ( pWin->mEventCallback ) { + PhRect_t rect; + PhArea_t area; + PhPoint_t offset; + nsRect nsDmg; - // Ok... I ~think~ the damage rect is in window coordinates and is not neccessarily clipped to - // the widgets canvas. Mozilla wants the paint coords relative to the parent widget, not the window. - PtWidgetArea( pWidget, &area ); - PtWidgetOffset( pWidget, &offset ); + // Ok... I ~think~ the damage rect is in window coordinates and is not neccessarily clipped to + // the widgets canvas. Mozilla wants the paint coords relative to the parent widget, not the window. + PtWidgetArea( pWidget, &area ); + PtWidgetOffset( pWidget, &offset ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc area=<%d,%d,%d,%d>\n", area.pos.x, area.pos.y, area.size.w, area.size.h)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc offset=<%d,%d>\n", offset.x, offset.y)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc mBounds=<%d,%d,%d,%d>\n", pWin->mBounds.x, pWin->mBounds.y, pWin->mBounds.width, pWin->mBounds.height)); + /* Build a List of Tiles that might be in front of me.... */ + PhTile_t *intersection = NULL, *clip_tiles = pWin->GetWindowClipping( ); - /* Add the X,Y of area to offset to fix the throbber drawing in Viewer */ - //offset.x += area.pos.x; - //offset.y += area.pos.y; + /* Intersect the Damage tile list w/ the clipped out list and see whats left! */ + PhTile_t *new_damage, *tiles; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc offset+area =<%d,%d>\n", offset.x, offset.y)); + if( damage->next ) tiles = PhCopyTiles( damage->next ); + else tiles = PhRectsToTiles( &damage->rect, 1 ); - /* Build a List of Tiles that might be in front of me.... */ - PhTile_t *clip_tiles=pWin->GetWindowClipping(offset); + /* new_damage is the same as tiles2... I need to release it later */ + new_damage = PhClipTilings( tiles, clip_tiles, &intersection ); - /* Intersect the Damage tile list w/ the clipped out list and */ - /* see whats left! */ - PhTile_t *new_damage; + PhFreeTiles( clip_tiles ); + if( intersection ) PhFreeTiles( intersection ); + if( new_damage == nsnull ) return; /* tiles and clip_tiles have been released */ - /* This could be leaking some memory */ - PhTile_t *tiles2, *tile3; - if (damage->next) - { - tiles2 = PhCopyTiles(damage->next); - tile3 = PhRectsToTiles(&damage->rect, 1); - tiles2 = PhIntersectTilings(tiles2, tile3, NULL); - } - else - { - tiles2 = PhRectsToTiles(&damage->rect, 1); - } + PhDeTranslateTiles( new_damage, &offset ); - /* Change to window relative coordinates */ - PhDeTranslateTiles(tiles2,&offset); + pWin->InitEvent(pev, NS_PAINT); + pev.eventStructType = NS_PAINT_EVENT; + pev.renderingContext = nsnull; + pev.renderingContext = pWin->GetRenderingContext(); - /* new_damage is the same as tiles2... I need to release it later */ - new_damage = PhClipTilings(tiles2, PhCopyTiles(clip_tiles), NULL); + for( dmg = new_damage; dmg; dmg = dmg->next ) { -#if 0 -/* There is a bug in merge or coalesce that causes rips when you move a window */ -/* down and to the right over Mozilla, these should be readded in when its fixed. */ - new_damage = PhCoalesceTiles( PhMergeTiles (PhSortTiles( new_damage ))); - //new_damage = PhMergeTiles (PhSortTiles( new_damage )); -#endif + /* Copy the Damage Rect - Do I need to Translate it?? If so by what? offset? offset+area? */ + nsDmg.x = dmg->rect.ul.x - area.pos.x; + nsDmg.y = dmg->rect.ul.y - area.pos.y; + nsDmg.width = dmg->rect.lr.x - dmg->rect.ul.x + 1; + nsDmg.height = dmg->rect.lr.y - dmg->rect.ul.y + 1; - if (new_damage == nsnull) - { - /* Nothing to Draw */ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc Nothing to Draw damage is NULL\n")); - return; - } + if( (nsDmg.width <= 0 ) || (nsDmg.height <= 0 ) ) { /* Move to the next Damage Tile */ + continue; + } -#if defined(DEBUG) && 1 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = new_damage; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc New Damage Tiles List <%p>:\n", new_damage)); - while (top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } -} -#endif + /* Re-Setup Paint Event */ + pWin->InitEvent(pev, NS_PAINT); + pev.eventStructType = NS_PAINT_EVENT; + pev.point.x = nsDmg.x; + pev.point.y = nsDmg.y; + pev.rect = &nsDmg; + if( pev.renderingContext ) { + nsIRegion *ClipRegion = pWin->GetRegion( ); + ClipRegion->SetTo( nsDmg.x, nsDmg.y, nsDmg.width, nsDmg.height ); + pev.renderingContext->SetClipRegion( NS_STATIC_CAST(const nsIRegion &, *(ClipRegion)), nsClipCombine_kReplace, aClipState ); - pWin->InitEvent(pev, NS_PAINT); - pev.eventStructType = NS_PAINT_EVENT; - pev.renderingContext = nsnull; - pev.renderingContext = pWin->GetRenderingContext(); - if (pev.renderingContext == NULL) - { - //printf("nsWindow::RawDrawFunc error getting RenderingContext\n"); - abort(); + NS_RELEASE( ClipRegion ); + + /* You can turn off most drawing if you take this out */ + result = pWin->DispatchWindowEvent(&pev); + } + } + NS_RELEASE(pev.renderingContext); + PhFreeTiles( new_damage ); + } } - /* Choose one... Usually the first rect is a bounding box and can */ - /* be ignored, but my special doPaint forgets the bounding box so .. */ - /* this is a quick hack.. */ - //dmg = damage->next; - //dmg = damage; /* if using my DoPaint that call RawDrawFunc directly */ - dmg = new_damage; - //dmg = BoundingDmg; - while(dmg) - { - /* Copy the Damage Rect */ - rect.ul.x = dmg->rect.ul.x; - rect.ul.y = dmg->rect.ul.y; - rect.lr.x = dmg->rect.lr.x; - rect.lr.y = dmg->rect.lr.y; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc damage rect = <%d,%d,%d,%d>\n", rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y)); - //printf("nsWindow::RawDrawFunc damage rect = <%d,%d,%d,%d>\n", rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y); - - /* Do I need to Translate it?? If so by what? offset? offset+area?*/ - rect.ul.x -= area.pos.x; - rect.ul.y -= area.pos.y; - rect.lr.x -= area.pos.x; - rect.lr.y -= area.pos.y; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc damage rect after translate = <%d,%d,%d,%d>\n", rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y)); - - /* If the damage tile is not within our bounds, do nothing */ - if(( rect.ul.x >= area.size.w ) || ( rect.ul.y >= area.size.h ) || ( rect.lr.x < 0 ) || ( rect.lr.y < 0 )) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc damage tile is not within our bounds, do nothing\n")); - //printf("nsWindow::RawDrawFunc damage tile is not within our bounds, do nothing\n"); - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc clipped damage <%d,%d,%d,%d>\n", rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y)); - - nsDmg.x = rect.ul.x; - nsDmg.y = rect.ul.y; - nsDmg.width = rect.lr.x - rect.ul.x + 1; - nsDmg.height = rect.lr.y - rect.ul.y + 1; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc nsDmg <%d,%d,%d,%d>\n", nsDmg.x, nsDmg.y, nsDmg.width, nsDmg.height)); - - if ( (nsDmg.width <= 0 ) || (nsDmg.height <= 0 ) ) - { - /* Move to the next Damage Tile */ - dmg = dmg->next; - continue; - } - -#if 1 - /* Re-Setup Paint Event */ - pWin->InitEvent(pev, NS_PAINT); - pev.eventStructType = NS_PAINT_EVENT; - pev.point.x = nsDmg.x; - pev.point.y = nsDmg.y; - pev.rect = new nsRect(nsDmg.x, nsDmg.y, nsDmg.width, nsDmg.height); - - if (pev.renderingContext) - { - ClipRegion = pWin->GetRegion(); - ClipRegion->SetTo(nsDmg.x, nsDmg.y, nsDmg.width, nsDmg.height); - pev.renderingContext->SetClipRegion(NS_STATIC_CAST(const nsIRegion &, *(ClipRegion)), - nsClipCombine_kReplace, aClipState); - - /* Not sure WHAT this sould be, probably nsDmg rect... */ - // pev.renderingContext->SetClipRegion(NS_STATIC_CAST(const nsIRegion &, *(ClipRegion)), - // pev.renderingContext->SetClipRegion(NS_STATIC_CAST(const nsIRegion &, *(pWin->mUpdateArea)), - // nsClipCombine_kReplace, aClipState); - - /* You can turn off most drawing if you take this out */ - result = pWin->DispatchWindowEvent(&pev); - } -#endif - /* Move to the next Damage Tile */ - dmg = dmg->next; - } - - NS_RELEASE(pev.renderingContext); - } - - PhFreeTiles(dmg); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::RawDrawFunc End of RawDrawFunc\n")); -} - -void nsWindow::ScreenToWidget( PhPoint_t &pt ) -{ +void nsWindow::ScreenToWidget( PhPoint_t &pt ) { // pt is in screen coordinates // convert it to be relative to ~this~ widgets origin - short x=0,y=0; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ScreenToWidget 1 pt=(%d,%d)\n", pt.x, pt.y)); + short x,y; if( mWindowType == eWindowType_child ) - { PtGetAbsPosition( mWidget, &x, &y ); - } - else - { - PtGetAbsPosition( mClientWidget, &x, &y ); - } + else PtGetAbsPosition( mClientWidget, &x, &y ); pt.x -= x; pt.y -= y; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ScreenToWidget 2 pt=(%d,%d)\n", pt.x, pt.y)); -} - - -NS_METHOD nsWindow::GetFrameSize(int *FrameLeft, int *FrameRight, int *FrameTop, int *FrameBottom) const -{ - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetFrameSize \n")); - - if (FrameLeft) - *FrameLeft = mFrameLeft; - if (FrameRight) - *FrameRight = mFrameRight; - if (FrameTop) - *FrameTop = mFrameTop; - if (FrameBottom) - *FrameBottom = mFrameBottom; - - - return NS_OK; -} - - - -/* Only called by nsWidget::Scroll */ -NS_METHOD nsWindow::GetSiblingClippedRegion( PhTile_t **btiles, PhTile_t **ctiles ) -{ - nsresult res = NS_ERROR_FAILURE; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion this=<%p> btiles=<%p> ctiles=<%p> mWidget=<%p>\n", this, btiles, ctiles, mWidget)); - - if(( btiles ) && ( ctiles )) - { - *btiles = PhGetTile(); - if( *btiles ) - { - PhTile_t *tile, *last; - PtWidget_t *w; - PhArea_t *area; - PtArg_t arg; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion 1\n")); - - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - nsRect rect( area->pos.x, area->pos.x, area->size.w, area->size.h ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion mWidget=<%p> area=<%d,%d,%d,%d>\n", mWidget,area->pos.x, area->pos.x, area->size.w, area->size.h)); - - GetParentClippedArea( rect ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion after GetParentClippedArea rect=(%d,%d,%d,%d)\n", rect.x, rect.y, rect.width, rect.height)); - - (*btiles)->rect.ul.x = rect.x; - (*btiles)->rect.ul.y = rect.y; - (*btiles)->rect.lr.x = rect.x + rect.width - 1; - (*btiles)->rect.lr.y = rect.y + rect.height - 1; - - (*btiles)->next = nsnull; - - *ctiles = last = nsnull; - - for( w=PtWidgetBrotherInFront( mWidget ); w; w=PtWidgetBrotherInFront( w )) - { - long flags = PtWidgetFlags(w); - - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( w, 1, &arg ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion BrotherInFront w=<%p> area=<%d,%d,%d,%d> IsOpaque=<%d> !=Disjoint=<%d> IsRealized=<%d>\n", - w, area->pos.x, area->pos.x, area->size.w, area->size.h, (flags & Pt_OPAQUE), (w != PtFindDisjoint(w)), PtWidgetIsRealized( w ) )); - - /* Is the widget OPAQUE and Window is not a disjoint window */ - if ((flags & Pt_OPAQUE) && (w != PtFindDisjoint(w))) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping widget w=<%p> is opaque IsRealized=<%d>\n", w, PtWidgetIsRealized(w))); - if ( PtWidgetIsRealized( w )) - { - - tile = PhGetTile(); - if( tile ) - { - tile->rect.ul.x = area->pos.x; - tile->rect.ul.y = area->pos.y; - tile->rect.lr.x = area->pos.x + area->size.w - 1; - tile->rect.lr.y = area->pos.y + area->size.h - 1; - tile->next = NULL; - if( !*ctiles ) - *ctiles = tile; - if( last ) - last->next = tile; - last = tile; - } - }} - } - - if( *ctiles ) - { - // We have siblings... now clip'em - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion 5\n")); - - *btiles = PhClipTilings( *btiles, *ctiles, nsnull ); - } - - res = NS_OK; - } - else - { - NS_ASSERTION(0,"nsWindow::GetSiblingClippedRegion Pt_ARG_AREA failed!"); - abort(); - } - } - else - { - NS_ASSERTION(0,"nsWindow::GetSiblingClippedRegion PhGetTile failed!"); - abort(); - } - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetSiblingClippedRegion the end res=<%d>\n", res)); - - return res; -} - - -NS_METHOD nsWindow::SetWindowClipping( PhTile_t *damage, PhPoint_t &offset ) -{ - nsresult res = NS_ERROR_FAILURE; - - PhTile_t *tile, *last, *clip_tiles; - PtWidget_t *w; - PhArea_t *area; - PtArg_t arg; - PtWidget_t *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); - PhTile_t *new_damage = nsnull; - - clip_tiles = last = nsnull; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping this=<%p> damage=<%p> offset=(%d,%d) mClipChildren=<%d> mClipSiblings=<%d>\n", this, damage, offset.x, offset.y, mClipChildren, mClipSiblings)); - -#if 0 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = damage; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping 1 Damage Tiles List:\n")); - do { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } while (top); -} -#endif - -#if 0 - tile = PhGetTile(); - if( tile ) - { - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( aWidget, 1, &arg ); - - tile->rect.ul.x = offset.x; - tile->rect.ul.y = offset.y; - tile->rect.lr.x = area->pos.x + area->size.w-1; - tile->rect.lr.y = area->pos.y + area->size.h-1; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping Adding Initial widget=<%d,%d,%d,%d>\n", tile->rect.ul.x, tile->rect.ul.y, tile->rect.lr.x, tile->rect.lr.y )); - - tile->next = NULL; - - damage = PhIntersectTilings(PhCopyTiles(damage), PhCopyTiles(tile), NULL); - } -#endif - -#if 0 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = damage; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping 2 Damage Tiles List: top=<%p>\n", top)); - while(top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - }; -} -#endif - - /* No damage left, nothing to draw */ - if (damage == nsnull) - return NS_ERROR_FAILURE; - - if ( mClipChildren ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" clipping children...\n")); - - for( w=PtWidgetChildFront( aWidget ); w; w=PtWidgetBrotherBehind( w )) - { - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( w, 1, &arg ); - - long flags = PtWidgetFlags(w); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping clipping children w=<%p> area=<%d,%d,%d,%d> flags=<%ld>\n", w, area->pos.x, area->pos.y, area->size.w, area->size.h, flags)); - - if (flags & Pt_OPAQUE) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping widget w=<%p> is opaque IsRealized=<%d>\n", w, PtWidgetIsRealized(w) )); - - if ( PtWidgetIsRealized( w )) - { - - tile = PhGetTile(); - if( tile ) - { -// HACK tried to offset the children... - tile->rect.ul.x = area->pos.x; // + offset.x; - tile->rect.ul.y = area->pos.y; // + offset.y; - tile->rect.lr.x = area->pos.x + area->size.w - 1; - tile->rect.lr.y = area->pos.y + area->size.h - 1; - tile->next = NULL; - if( !clip_tiles ) - clip_tiles = tile; - if( last ) - last->next = tile; - last = tile; - } - else - { - printf("Error failed to GetTile\n"); - abort(); - } - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping Widget isn't realized %p\n", w)); - } - } - } - } - - if ( mClipSiblings ) - { - PtWidget_t *node = aWidget; - PhPoint_t origin = { 0, 0 }; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, (" clipping siblings...\n")); - - while( node ) - { - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( node, 1, &arg ); - origin.x += area->pos.x; - origin.y += area->pos.y; - //printf ("parent: %p: %d %d %d %d\n",node,area->pos.x,area->pos.y,area->size.w,area->size.h); - - for( w=PtWidgetBrotherInFront( node ); w; w=PtWidgetBrotherInFront( w )) - { - if( PtWidgetIsRealized( w )) - { - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( w, 1, &arg ); - //printf ("sib: %p: %d %d %d %d\n",w,area->pos.x,area->pos.y,area->size.w,area->size.h); - tile = PhGetTile(); - if (area->size.w != 43 && area->size.h != 43) // oh god another HACK - if( tile ) - { - tile->rect.ul.x = area->pos.x - origin.x; - tile->rect.ul.y = area->pos.y - origin.y; - tile->rect.lr.x = tile->rect.ul.x + area->size.w - 1; - tile->rect.lr.y = tile->rect.ul.y + area->size.h - 1; - tile->next = NULL; - if( !clip_tiles ) - clip_tiles = tile; - if( last ) - last->next = tile; - last = tile; - } - } - } - node = PtWidgetParent( node ); - } - } - - int rect_count; - PhRect_t *rects; - PhTile_t *dmg; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping damage=<%p> damage->next=<%p> clip_tiles=<%p>\n", damage, damage->next, clip_tiles)); - -#if 1 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = damage; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping 3 Damage Tiles List:\n")); - while(top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping photon damage %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } -} -#endif - - /* Skip the first bounding tile if possible */ - if (damage->next) - dmg = PhCopyTiles( damage->next ); - else - dmg = PhCopyTiles( damage ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping after PhCopyTiles\n")); - - PhDeTranslateTiles( dmg, &offset ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping after PhDeTranslateTiles\n")); - - if( clip_tiles ) - { - // We have chiluns... now clip'em - dmg = PhClipTilings( dmg, clip_tiles, nsnull ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping after PhClipTilings\n")); - - PhFreeTiles( clip_tiles ); - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping after children clipping dmg=<%p>\n", dmg )); - - if( dmg ) - { - rects = PhTilesToRects( dmg, &rect_count ); -#if 1 -#ifdef DEBUG - /* Debug print out the tile list! */ - int index; - PhRect_t *tip = rects; - for(index=0; index < rect_count; index++) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetWindowClipping %d rect = <%d,%d,%d,%d>\n",index, - tip->ul.x, tip->ul.y, tip->lr.x, tip->lr.y)); - tip++; - } -#endif - - PgSetClipping( rect_count, rects ); - -#else - //PR_LOG(PhWidLog, PR_LOG_DEBUG, (" damage clipped to:\n")); - //printf(" damage clipped to:\n"); - - int bX=0, bY=0; - int aX=32767, aY=32767; - - for(int i=0;irect.ul.x = w->area.pos.x + w_offset.x; + tile->rect.ul.y = w->area.pos.y + w_offset.y; + tile->rect.lr.x = tile->rect.ul.x + w->area.size.w - 1; + tile->rect.lr.y = tile->rect.ul.y + w->area.size.h - 1; - clip_tiles = last = nsnull; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping this=<%p> offset=<%d,%d> mClipChildren=<%d> mClipSiblings=<%d>\n", this, offset.x, offset.y, mClipChildren, mClipSiblings)); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping clipping children...\n")); - - PtWidgetOffset(w=PtWidgetChildFront( aWidget ), &w_offset); - w_offset.x -= offset.x; - w_offset.y -= offset.y; - - for(; w; w=PtWidgetBrotherBehind( w )) - { - long flags = PtWidgetFlags(w); - -#if 0 - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( w, 1, &arg ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping clipping children w=<%p> area=<%d,%d,%d,%d> flags=<%ld>\n", w, area->pos.x, area->pos.y, area->size.w, area->size.h, flags)); - - PtWidgetArea(w, &w_area); - PtWidgetDim(w, &w_dim); - - PtGetAbsPosition(w, &abs_pos_x, &abs_pos_y); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping clipping children w=<%p> offset=<%d,%d> Abs Pos=<%d,%d> w_area=<%d,%d,%d,%d>\n", w, w_offset.x, w_offset.y, abs_pos_x, abs_pos_y, w_area.pos.x, w_area.pos.y, w_area.size.w, w_area.size.h)); -#endif - - /* Is the widget OPAQUE and Window is not a disjoint window */ - if ((flags & Pt_OPAQUE) && (w != PtFindDisjoint(w))) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping widget w=<%p> is opaque IsRealized=<%d>\n", w, PtWidgetIsRealized(w))); - if ( PtWidgetIsRealized( w )) - { -#if 1 - PtSetArg( &arg, Pt_ARG_AREA, &area, 0 ); - PtGetResources( w, 1, &arg ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping clipping children w=<%p> area=<%d,%d,%d,%d> flags=<%ld>\n", w, area->pos.x, area->pos.y, area->size.w, area->size.h, flags)); - - PtWidgetArea(w, &w_area); - PtWidgetDim(w, &w_dim); - - PtGetAbsPosition(w, &abs_pos_x, &abs_pos_y); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping clipping children w=<%p> offset=<%d,%d> Abs Pos=<%d,%d> w_area=<%d,%d,%d,%d>\n", w, w_offset.x, w_offset.y, abs_pos_x, abs_pos_y, w_area.pos.x, w_area.pos.y, w_area.size.w, w_area.size.h)); -#endif - - tile = PhGetTile(); - if( tile ) - { - tile->rect.ul.x = area->pos.x + w_offset.x; - tile->rect.ul.y = area->pos.y + w_offset.y; - tile->rect.lr.x = tile->rect.ul.x + area->size.w - 1; - tile->rect.lr.y = tile->rect.ul.y + area->size.h - 1; - - tile->next = NULL; - if( !clip_tiles ) - clip_tiles = tile; - if( last ) - last->next = tile; - last = tile; - } - else - { - printf("Error failed to GetTile\n"); - abort(); - } - } - else - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping Widget isn't realized %p\n", w)); - } - } - } - - -#if defined(DEBUG) && 1 -{ - /* Print out the Photon Damage tiles */ - PhTile_t *top = clip_tiles; - int index=0; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping Child+Sibling Tiles List:\n")); - while(top) - { - PhRect_t rect = top->rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetWindowClipping tiles to clip %d rect=<%d,%d,%d,%d> next=<%p>\n", index++,rect.ul.x,rect.ul.y,rect.lr.x,rect.lr.y, top->next)); - top=top->next; - } -} -#endif - - - return clip_tiles; -} + tile->next = NULL; + if( !clip_tiles ) clip_tiles = tile; + if( last ) last->next = tile; + last = tile; + } + } + return clip_tiles; + } int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { @@ -2218,8 +1034,6 @@ int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *c nsWindow *someWindow = (nsWindow *) GetInstance(widget); nsRect rect; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeHandler for someWindow=<%p>\n", someWindow)); - if( someWindow && extents) // kedl { rect.x = extents->ul.x; @@ -2230,8 +1044,7 @@ int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *c someWindow->mBounds.height = rect.height; /* This enables the resize holdoff */ - if (PtWidgetIsRealized(widget)) - { + if (PtWidgetIsRealized(widget)) { someWindow->ResizeHoldOff(); someWindow->OnResize( rect ); } @@ -2239,390 +1052,193 @@ int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *c return( Pt_CONTINUE ); } -void nsWindow::ResizeHoldOff() -{ - if( !mWidget ) - { - return; - } +void nsWindow::ResizeHoldOff() { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeHoldOff Entering this=<%p>\n", this )); + if( !mWidget ) return; - if( PR_FALSE == mResizeQueueInited ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeHoldOff Initing Queue this=<%p>\n", this )); - - // This is to guarantee that the Invalidation work-proc is in place prior to the - // Resize work-proc. - if( !mDmgQueueInited ) - { - Invalidate( PR_FALSE ); - } + if( PR_FALSE == mResizeQueueInited ) { + // This is to guarantee that the Invalidation work-proc is in place prior to the resize work-proc. + if( !mDmgQueueInited ) Invalidate( PR_FALSE ); PtWidget_t *top = PtFindDisjoint( mWidget ); - if ( (mResizeProcID = PtAppAddWorkProc( nsnull, ResizeWorkProc, top )) != nsnull ) - { -#if 1 - int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtHold(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWindow::ResizeHoldOff PtHold Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); -#endif - mResizeQueueInited = PR_TRUE; - } - else - { - printf( "*********** resize work proc failed to init. ***********\n" ); - } - } + if( (mResizeProcID = PtAppAddWorkProc( nsnull, ResizeWorkProc, top )) != nsnull ) { + int Global_Widget_Hold_Count; + Global_Widget_Hold_Count = PtHold(); + mResizeQueueInited = PR_TRUE; + } + } - if( PR_TRUE == mResizeQueueInited ) - { + if( PR_TRUE == mResizeQueueInited ) { DamageQueueEntry *dqe; PRBool found = PR_FALSE; - dqe = mResizeQueue; - - while( dqe ) - { - if( dqe->widget == mWidget ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeHoldOff Widget already in Queue this=<%p>\n", this )); - + for( dqe = mResizeQueue; dqe; dqe = dqe->next ) { + if( dqe->widget == mWidget ) { found = PR_TRUE; break; - } - dqe = dqe->next; - } + } + } - if( !found ) - { + if( !found ) { dqe = new DamageQueueEntry; - if( dqe ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeHoldOff Adding widget to Queue this=<%p> dqe=<%p> dqe->inst=<%p>\n", this, dqe, this )); - + if( dqe ) { mIsResizing = PR_TRUE; dqe->widget = mWidget; dqe->inst = this; dqe->next = mResizeQueue; mResizeQueue = dqe; - } - } - } -} + } + } + } + } -void nsWindow::RemoveResizeWidget() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWindow::RemoveResizeWidget (%p)\n", this)); - - if( mIsResizing ) - { +void nsWindow::RemoveResizeWidget( ) { + if( mIsResizing ) { DamageQueueEntry *dqe; DamageQueueEntry *last_dqe = nsnull; dqe = mResizeQueue; // If this widget is in the queue, remove it - while( dqe ) - { - if( dqe->widget == mWidget ) - { - if( last_dqe ) - last_dqe->next = dqe->next; - else - mResizeQueue = dqe->next; - -// NS_RELEASE( dqe->inst ); - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWindow::RemoveResizeWidget this=(%p) dqe=<%p>\n", this, dqe)); + while( dqe ) { + if( dqe->widget == mWidget ) { + if( last_dqe ) last_dqe->next = dqe->next; + else mResizeQueue = dqe->next; delete dqe; mIsResizing = PR_FALSE; break; - } + } last_dqe = dqe; dqe = dqe->next; - } + } - if( nsnull == mResizeQueue ) - { + if( nsnull == mResizeQueue ) { mResizeQueueInited = PR_FALSE; PtWidget_t *top = PtFindDisjoint( mWidget ); - -#if 1 - int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtRelease(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWindow::RemoveResizeWidget PtHold/PtRelease Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, this)); -#endif - - if( mResizeProcID ) - PtAppRemoveWorkProc( nsnull, mResizeProcID ); - } - } -} + int Global_Widget_Hold_Count = PtRelease( ); + if( mResizeProcID ) PtAppRemoveWorkProc( nsnull, mResizeProcID ); + } + } + } -int nsWindow::ResizeWorkProc( void *data ) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeWorkProc data=<%p> mResizeQueueInited=<%d>\n", data, mResizeQueueInited )); - - if ( mResizeQueueInited ) - { +int nsWindow::ResizeWorkProc( void *data ) { + + if ( mResizeQueueInited ) { DamageQueueEntry *dqe = nsWindow::mResizeQueue; DamageQueueEntry *last_dqe; - while( dqe ) - { - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeWorkProc before Invalidate dqe=<%p> dqe->inst=<%p>\n", dqe, dqe->inst)); - + while( dqe ) { ((nsWindow*)dqe->inst)->mIsResizing = PR_FALSE; dqe->inst->Invalidate( PR_FALSE ); last_dqe = dqe; dqe = dqe->next; delete last_dqe; - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeWorkProc after while loop\n")); + } nsWindow::mResizeQueue = nsnull; nsWindow::mResizeQueueInited = PR_FALSE; -#if 1 int Global_Widget_Hold_Count; - Global_Widget_Hold_Count = PtRelease(); - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWindow::ResizeWorkProc PtHold/PtRelease Global_Widget_Hold_Count=<%d> this=<%p>\n", Global_Widget_Hold_Count, NULL)); -#endif - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ResizeWorkProc after PtRelease\n")); - - } + Global_Widget_Hold_Count = PtRelease(); + } return Pt_END; -} + } -NS_METHOD nsWindow::GetClientBounds( nsRect &aRect ) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetClientBounds (%p) aRect=(%d,%d,%d,%d)\n", this, aRect.x, aRect.y, aRect.width, aRect.height)); - +NS_METHOD nsWindow::GetClientBounds( nsRect &aRect ) { aRect.x = 0; aRect.y = 0; aRect.width = mBounds.width; aRect.height = mBounds.height; - -/* kirkj took this out to fix sizing errors on pref. dialog. */ -#if 0 - if ( (mWindowType == eWindowType_toplevel) || - (mWindowType == eWindowType_dialog) ) - { - int h = GetMenuBarHeight(); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetClientBounds h=<%d> mFrameRight=<%d> mFrameLeft=<%d> mFrameTop=<%d> mFrameBottom=<%d>\n", - h, mFrameRight, mFrameLeft, mFrameTop, mFrameBottom)); - - - aRect.width -= (mFrameRight + mFrameLeft); - aRect.height -= (h + mFrameTop + mFrameBottom); - } -#endif - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetClientBounds the end bounds=(%ld,%ld,%ld,%ld)\n", aRect.x, aRect.y, aRect.width, aRect.height )); - return NS_OK; -} + } //------------------------------------------------------------------------- // // grab mouse events for this widget -// +// CaptureMouse Not Implemented //------------------------------------------------------------------------- -NS_IMETHODIMP nsWindow::CaptureMouse(PRBool aCapture) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::CaptureMouse this=<%p> aCapture=<%d>\n",this, aCapture )); - - NS_WARNING("nsWindow::CaptureMouse Not Implemented\n"); - +NS_IMETHODIMP nsWindow::CaptureMouse( PRBool aCapture ) { return NS_OK; -} + } -NS_METHOD nsWindow::ConstrainPosition(PRInt32 *aX, PRInt32 *aY) -{ +NS_METHOD nsWindow::ConstrainPosition( PRInt32 *aX, PRInt32 *aY ) { return NS_OK; -} + } //------------------------------------------------------------------------- // // Move this component // //------------------------------------------------------------------------- -NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move this=(%p) to (%ld,%ld) mClipChildren=<%d> mClipSiblings=<%d> mBorderStyle=<%d> mWindowType=<%d> mParent=<%p>\n", - this, aX, aY, mClipChildren, mClipSiblings, mBorderStyle, mWindowType, mParent)); +NS_METHOD nsWindow::Move( PRInt32 aX, PRInt32 aY ) { + PRInt32 origX, origY; - PRInt32 origX, origY; + /* Keep a untouched version of the coordinates laying around for comparison */ + origX=aX; + origY=aY; - /* Keep a untouched version of the coordinates laying around for comparison */ - origX=aX; - origY=aY; - -#if defined(DEBUG) && 0 - if (mWindowType==eWindowType_popup) - { - /* For Pop-Up Windows print out Area Ancestry */ - int count = 1; - PhArea_t area; - PtWidget_t *top; - PhPoint_t offset; + switch( mWindowType ) { + case eWindowType_popup: + { + PhPoint_t offset, total_offset = { 0, 0 }; - PtWidgetArea(mWidget, &area); - PtWidgetOffset(mWidget, &offset ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d mWidget area=<%d,%d,%d,%d>\n", count, area.pos.x,area.pos.y,area.size.w,area.size.h)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d mWidget offset=<%d,%d>", count, offset.x,offset.y)); - count++; - top = PtWidgetParent(mWidget); - while(top) - { - PtWidgetArea(top, &area); - PtWidgetOffset(top, &offset ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d parent area=<%d,%d,%d,%d>\n", count, area.pos.x,area.pos.y,area.size.w,area.size.h)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d parent offset=<%d,%d>", count, offset.x,offset.y)); - count++; - top = PtWidgetParent(top); - } - } -#endif + PtWidget_t *parent, *disjoint = PtFindDisjoint( mWidget ); + disjoint = PtFindDisjoint( PtWidgetParent( disjoint ) ); -#if defined(DEBUG) && 0 - if (mWindowType==eWindowType_popup) - { - /* For Pop-Up Windows print out Area Ancestry */ - int count = 1; - PhArea_t area; - PtWidget_t *top, *last=nsnull; - PhPoint_t offset; - - PtWidgetArea(mWidget, &area); - PtWidgetOffset(mWidget, &offset ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d mWidget area=<%d,%d,%d,%d>\n", count, area.pos.x,area.pos.y,area.size.w,area.size.h)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d mWidget offset=<%d,%d>", count, offset.x,offset.y)); - count++; - top = PtFindDisjoint(mWidget); - while((top != last) && top) - { - PtWidgetArea(top, &area); - PtWidgetOffset(top, &offset ); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d disjoint area=<%d,%d,%d,%d>\n", count, area.pos.x,area.pos.y,area.size.w,area.size.h)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move %d disjoint offset=<%d,%d>", count, offset.x,offset.y)); - if (PtWidgetIsClass(top, PtWindow)) - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move disjoint window is a PtWindow\n")); - if (PtWidgetIsClass(top, PtRegion)) - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move disjoint window is a PtRegion\n")); - count++; - last = top; - PtWidget_t *tmp = PtWidgetParent(top); - if (tmp) - top = PtFindDisjoint(tmp); - else - top = tmp; - } - } -#endif + while( disjoint ) { + PtGetAbsPosition( disjoint, &offset.x, &offset.y ); + total_offset.x += offset.x; + total_offset.y += offset.y; + if( PtWidgetIsClass( disjoint, PtWindow ) || PtWidgetIsClass( disjoint, PtServer ) ) break; /* Stop at the first PtWindow */ + parent = PtWidgetParent(disjoint); + if( parent ) disjoint = PtFindDisjoint( parent ); + else { + disjoint = parent; + break; + } + } + aX += total_offset.x; + aY += total_offset.y; - if (mWindowType==eWindowType_popup) - { - short int FrameLeft, FrameTop, FrameBottom; - PhArea_t area; - PhPoint_t offset, total_offset; - - FrameLeft = FrameTop = FrameBottom = 0; - /* Hard code these values for now */ - FrameLeft = 5; /* 5 looks the best? */ - FrameTop = 21; /* started with 21 */ + /* Add the Offset if the widget is offset from its parent.. */ + parent = PtWidgetParent( mWidget ); + PtWidgetOffset( parent, &offset ); + aX += offset.x; + aY += offset.y; - aX += FrameLeft; - aY += FrameTop; + offset = nsToolkit::GetConsoleOffset(); + aX -= offset.x; + aY -= offset.y; + } + break; - PtWidget_t *parent, *disjoint = PtFindDisjoint(mWidget); - disjoint = PtFindDisjoint(PtWidgetParent(disjoint)); - total_offset.x = 0; - total_offset.y = 0; - while(disjoint) - { - PtWidgetArea(disjoint, &area); - total_offset.x += area.pos.x; - total_offset.y += area.pos.y; - if (PtWidgetIsClass(disjoint, PtWindow)) - { - /* Stop at the first PtWindow */ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move disjoint window is a PtWindow exiting loop \n")); - break; - } - parent = PtWidgetParent(disjoint); - if (parent) - disjoint = PtFindDisjoint(parent); - else - { - disjoint = parent; - break; - } - } + case eWindowType_dialog: + case eWindowType_toplevel: + /* Offset to the current virtual console */ + PhPoint_t offset = nsToolkit::GetConsoleOffset(); + aX += offset.x; + aY += offset.y; + break; + } - aX += total_offset.x; - aY += total_offset.y; + /* Call my base class */ + nsresult res = nsWidget::Move(aX, aY); - /* Add the Offset if the widget is offset from its parent.. */ - parent = PtWidgetParent( mWidget ); - PtWidgetOffset(parent, &offset); - aX += offset.x; - aY += offset.y; - } + /* If I am a top-level window my origin should always be 0,0 */ + if( mWindowType != eWindowType_child ) { + mBounds.x = origX; + mBounds.y = origY; + } - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move this=(%p) to (%ld,%ld) \n", this, aX, aY )); - - /* Offset to the current virtual console */ - if ( (mWindowType == eWindowType_dialog) - || (mWindowType == eWindowType_toplevel) - ) - { - PhPoint_t offset = nsToolkit::GetConsoleOffset(); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move toplevel console offset=(%d,%d)\n", offset.x, offset.y)); - aX += offset.x; - aY += offset.y; - } - - /* Subtract off the console offset that got added earlier in this method */ - if (mWindowType == eWindowType_popup) - { - PhPoint_t offset = nsToolkit::GetConsoleOffset(); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move toplevel console offset=(%d,%d)\n", offset.x, offset.y)); - aX -= offset.x; - aY -= offset.y; - - } - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::Move this=(%p) after console offset to (%ld,%ld) \n", this, aX, aY )); - - /* Call my base class */ - nsresult res = nsWidget::Move(aX, aY); - - /* If I am a top-level window my origin should always be 0,0 */ - - if ( (mWindowType == eWindowType_dialog) || - (mWindowType == eWindowType_toplevel) || - (mWindowType == eWindowType_popup) ) - { - mBounds.x = origX; - mBounds.y = origY; - } - - return res; -} + return res; + } //------------------------------------------------------------------------- // @@ -2630,90 +1246,56 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY) // a modal window. // //------------------------------------------------------------------------- -NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent, - PRBool *aForWindow) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::ModalEventFilter aEvent=<%p> - Not Implemented.\n", aEvent)); +NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow) { + *aForWindow = PR_TRUE; + return NS_OK; + } - *aForWindow = PR_TRUE; - return NS_OK; -} +int nsWindow::MenuRegionCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { -int nsWindow::MenuRegionCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo) -{ nsWindow *pWin = (nsWindow*) data; nsWindow *pWin2 = (nsWindow*) GetInstance(widget); nsresult result; PhEvent_t *event = cbinfo->event; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::MenuRegionCallback this=<%p> widget=<%p> apinfo=<%p> mMenuRegion=<%p>\n", pWin, widget, data, pWin->mMenuRegion)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::MenuRegionCallback cbinfo->reason=<%d>\n", cbinfo->reason)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::MenuRegionCallback cbinfo->subtype=<%d>\n", cbinfo->reason_subtype)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::MenuRegionCallback cbinfo->cbdata=<%d>\n", cbinfo->cbdata)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::MenuRegionCallback event->type=<%d>\n", event->type)); + if( event->type == Ph_EV_BUT_PRESS ) { + if( pWin->gRollupWidget && pWin->gRollupListener ) { + /* Close the Window */ + pWin->gRollupListener->Rollup(); + IgnoreEvent = event->timestamp; + } + } + return Pt_CONTINUE; + } -#if 1 - if (event->type == Ph_EV_BUT_PRESS) - { - if (pWin->gRollupWidget && pWin->gRollupListener) - { - /* Close the Window */ - pWin->gRollupListener->Rollup(); - IgnoreEvent = event->timestamp; - } - } -#endif - - return (Pt_CONTINUE); -} - -NS_METHOD nsWindow::GetAttention() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::GetAttention this=(%p)\n", this )); - - NS_WARNING("nsWindow::GetAttention Called...\n"); - - if ((mWidget) && (mWidget->parent) && (!PtIsFocused(mWidget))) - { +NS_METHOD nsWindow::GetAttention( ) { + if( mWidget && mWidget->parent && !PtIsFocused( mWidget ) ) { /* Raise to the top */ PtWidgetToFront(mWidget); - } - + } return NS_OK; -} + } -NS_IMETHODIMP nsWindow::SetModal(PRBool aModal) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetModal this=<%p> mWidget=<%p>\n", this, mWidget)); +NS_IMETHODIMP nsWindow::SetModal( PRBool aModal ) { nsresult res = NS_ERROR_FAILURE; if (!mWidget) return NS_ERROR_FAILURE; PtWidget_t *toplevel = PtFindDisjoint(mWidget); - if (!toplevel) - return NS_ERROR_FAILURE; + if( !toplevel ) return NS_ERROR_FAILURE; - if (aModal) - { -// the following is done by the calling func -// if (mParent) -// mParent->Enable(PR_FALSE); + if( aModal ) { PtModalStart(); res = NS_OK; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetModal after call to PtModalStart\n")); - } - else - { -// if (mParent) -// mParent->Enable(PR_TRUE); - PtModalEnd(); + } + else { + PtModalEnd(); res = NS_OK; - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::SetModal after call to PtModalEnd\n")); - } + } return res; -} + } nsIRegion *nsWindow::GetRegion() @@ -2723,12 +1305,8 @@ nsIRegion *nsWindow::GetRegion() static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); - res = nsComponentManager::CreateInstance(kRegionCID, nsnull, - NS_GET_IID(nsIRegion), - (void **)®ion); - - if (NS_OK == res) - region->Init(); + res = nsComponentManager::CreateInstance( kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void **)®ion ); + if (NS_OK == res) region->Init(); NS_ASSERTION(NULL != region, "Null region context"); @@ -2738,20 +1316,5 @@ nsIRegion *nsWindow::GetRegion() int nsWindow::PopupMenuRegionCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo) { - nsWindow *pWin = (nsWindow*) data; - nsWindow *pWin2 = (nsWindow*) GetInstance(widget); - nsresult result; - PhEvent_t *event = cbinfo->event; - - /* eliminate 'unreferenced' warnings */ - widget = widget, data = data, cbinfo = cbinfo; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PopupMenuRegionCallback this=<%p> widget=<%p> data=<%p> mMenuRegion=<%p>\n", pWin, widget, data, pWin->mMenuRegion)); - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PMenuRegionCallback cbinfo->reason=<%d>\n", cbinfo->reason)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PMenuRegionCallback cbinfo->subtype=<%d>\n", cbinfo->reason_subtype)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PMenuRegionCallback cbinfo->cbdata=<%d>\n", cbinfo->cbdata)); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsWindow::PMenuRegionCallback event->type=<%d>\n", event->type)); - return RawEventHandler(widget, data, cbinfo); } diff --git a/widget/src/photon/nsWindow.h b/widget/src/photon/nsWindow.h index 9eb8307c3594..37df96541b3f 100644 --- a/widget/src/photon/nsWindow.h +++ b/widget/src/photon/nsWindow.h @@ -97,7 +97,6 @@ public: PRBool OnKey(nsKeyEvent &aEvent); PRBool DispatchFocus(nsGUIEvent &aEvent); virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); - NS_IMETHOD GetFrameSize(int *FrameLeft, int *FrameRight, int *FrameTop, int *FrameBottom) const; NS_IMETHOD SetColorMap(nsColorMap *aColorMap); NS_IMETHOD GetClientBounds( nsRect &aRect ); NS_IMETHOD SetModal(PRBool aModal); @@ -125,9 +124,7 @@ protected: static int ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ); static int WindowCloseHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ); PRBool HandleEvent( PtCallbackInfo_t* aCbInfo ); - NS_METHOD GetSiblingClippedRegion( PhTile_t **btiles, PhTile_t **ctiles ); - NS_METHOD SetWindowClipping( PhTile_t *damage, PhPoint_t &offset ); - PhTile_t *GetWindowClipping(PhPoint_t &offset); + PhTile_t *GetWindowClipping( ); void ResizeHoldOff(); void RemoveResizeWidget(); @@ -152,10 +149,6 @@ protected: nsFont *mFont; nsIMenuBar *mMenuBar; PRBool mMenuBarVis; - int mFrameLeft; - int mFrameRight; - int mFrameTop; - int mFrameBottom; PRBool mIsUpdating; // when this is PR_TRUE we will block focus