if( EDT_IS_EDITOR(context) && !bCursorSet ){   SetCursor(theApp.LoadCursor(IDC_ARROW_HAND)); bCursorSet = TRUE;
if( !bCursorSet ){      BOOL bHaveEditorWindow = bIsEditor; if( !bHaveEditorWindow ) {  CGenericFrame * f; for(f = theApp.m_pFrameList; f; f = f->m_pNext) { MWContext *pMWContext = f->GetMainContext()->GetContext();  if ( pMWContext && EDT_IS_EDITOR(pMWContext) ) { bHaveEditorWindow = TRUE; break; } } }   if( !bIsEditor && bHaveEditorWindow || (bIsEditor && (image_struct->ele_attrmask & LO_ELE_SELECTED) != 0) ) { SetCursor(theApp.LoadCursor(IDC_ARROW_HAND)); bCursorSet = TRUE;    wfe_Progress(context, XP_GetString(XP_EDT_CLICK_AND_DRAG_IMAGE)); bTextSet = TRUE; } else if( bIsEditor ) { SetCursor(theApp.LoadStandardCursor(IDC_ARROW)); bCursorSet = TRUE;   wfe_Progress(context, XP_GetString(XP_EDT_CLICK_TO_SELECT_IMAGE)); bTextSet = TRUE; }
mouse_over_callback(MWContext * context, LO_Element * lo_element, int32 event,                     void * pObj, ETEventStatus status){#ifdef MOZ_NGLAYOUT  XP_ASSERT(0);#else    // keep track of what we have done already so that we    //   don't thrash    BOOL bTextSet = FALSE;    BOOL bCursorSet = FALSE;    LO_EmbedStruct *pEmbed = NULL;    LO_ImageStruct * image_struct = NULL;    LO_TextStruct * text_struct = NULL;    // get our stashed data    mouse_over_closure * pClose = (mouse_over_closure *) pObj;    CWinCX * pWin = pClose->pWin;        // make sure the document didn't disappear    if(status == EVENT_PANIC) {        XP_FREE(pClose);        return;    }    // if the status is OK then that means the backend set the    //   status bar text    if(status == EVENT_OK)        bTextSet = TRUE;        CPoint DocPoint(CASTINT(pClose->xVal), CASTINT(pClose->yVal));    BOOL bMouseInSelection = pClose->pWin->PtInSelectedRegion( DocPoint );#ifdef EDITOR    // First check for Table mouse-over events - we don't need the current element    //  since we will look for closest table hit region    // Don't do this if ALT key is pressed - this allows sizing images (and other objects)    //   which are tightly surrounded by a cell boundary.    //  TODO: Alt key leaves menu select mode on - how do we defeat that behavior?    if( EDT_IS_EDITOR(context) && !EDT_IsSizing(context) )    {        ED_HitType iTableHit = ED_HIT_NONE;        if( pWin->m_bSelectingCells )        {            // User is dragging mouse to select table cells            // Return value tells us what kind of cursor to use            iTableHit = EDT_ExtendTableCellSelection(context, pClose->xVal, pClose->yVal);        }        else if( GetAsyncKeyState(VK_MENU) >= 0 ) // Alt key test        {            // See if we are over a table or cell "hit" region and need a special cursor            // Get hit region - we don't need to know element, so use NULL for 4th param            // If 5th param is TRUE, then select all cells if in upper left corner of table,            //   or select/unselect cell if mouse is ANYWHERE inside of the cell            iTableHit = EDT_GetTableHitRegion(context, pClose->xVal, pClose->yVal, NULL, GetAsyncKeyState(VK_CONTROL));        }        if( iTableHit )        {            UINT nID_Status = 0;            switch( iTableHit )            {                case ED_HIT_SEL_TABLE:      // Upper left corner                    SetCursor(theApp.LoadCursor(IDC_TABLE_SEL));                    nID_Status =  XP_EDT_SEL_TABLE;                    break;                case ED_HIT_SEL_ALL_CELLS:  // Upper left corner with Ctrl pressed                    SetCursor(theApp.LoadCursor(IDC_ALL_CELLS_SEL));                    nID_Status =  XP_EDT_SEL_ALL_CELLS;                    break;                case ED_HIT_SEL_COL:        // Near Top table border                    SetCursor(theApp.LoadCursor(IDC_COL_SEL));                    nID_Status =  XP_EDT_SEL_COL;                    break;                case ED_HIT_SEL_ROW:        // Near left table border                    SetCursor(theApp.LoadCursor(IDC_ROW_SEL));                    nID_Status =  XP_EDT_SEL_ROW;                    break;                case ED_HIT_SEL_CELL:       // Remaining cell border not matching other regions                    SetCursor(theApp.LoadCursor(IDC_CELL_SEL));                    nID_Status =  XP_EDT_SEL_CELL;                    break;                case ED_HIT_SIZE_TABLE_WIDTH:     // Right edge of table                    SetCursor(theApp.LoadCursor(IDC_TABLE_SIZE));                    nID_Status =  XP_EDT_SIZE_TABLE_WIDTH;                    break;                case ED_HIT_SIZE_TABLE_HEIGHT:    // Bottom edge of table                    SetCursor(theApp.LoadCursor(IDC_TABLE_VSIZE));                    nID_Status =  XP_EDT_SIZE_TABLE_HEIGHT;                    break;                case ED_HIT_SIZE_COL:       // Right border of a cell                    SetCursor(theApp.LoadCursor(IDC_COL_SIZE));                    nID_Status =  XP_EDT_SIZE_COL;                    break;                case ED_HIT_SIZE_ROW:       // Right border of a cell                    SetCursor(theApp.LoadCursor(IDC_ROW_SIZE));                    nID_Status =  XP_EDT_SIZE_ROW;                    break;                case ED_HIT_ADD_ROWS:       // Lower left corner                    SetCursor(theApp.LoadCursor(IDC_ADD_ROWS));                    nID_Status =  XP_EDT_ADD_ROWS;                    break;                case ED_HIT_ADD_COLS:       // Lower right corner                    SetCursor(theApp.LoadCursor(IDC_ADD_COLS));                    nID_Status =  XP_EDT_ADD_COLS;                    break;                case ED_HIT_DRAG_TABLE: // Inside a selected cell or table                    SetCursor(theApp.LoadCursor(IDC_IBEAM_HAND));                    nID_Status =  XP_EDT_DRAG_TABLE;                    break;                            }            // Give user text feedback for table cursors            if( nID_Status )            {                wfe_Progress(context, XP_GetString(nID_Status));                bTextSet = TRUE;            }            bCursorSet = TRUE;            goto FINISH_MOUSE_OVER;        }    }#endif // EDITOR    // See if we are over some text that is a link    text_struct = (LO_TextStruct *) lo_element;    // Imagemaps send their mouseover events as dummy text structs.  Be very careful    // about what you try to use from this text struct as many of the fields are    // invalid.    if(text_struct && text_struct->type == LO_TEXT && text_struct->text)    {        BOOL bIsLink = (text_struct->anchor_href && text_struct->anchor_href->anchor);        if(bIsLink && !bTextSet)        {#ifdef EDITOR            if( EDT_IS_EDITOR(context) )            {                // Condense the URL of the link and append hint that                //   pressing Ctrl + mouse click will edit the link                CString csStatus = (char*)text_struct->anchor_href->anchor;                WFE_CondenseURL(csStatus, 40, FALSE);                csStatus += szLoadString(IDS_EDIT_LINK_HINT);                wfe_Progress(context, csStatus);            }            else#endif // EDITOR            wfe_Progress(context, (char *) text_struct->anchor_href->anchor);            bTextSet = TRUE;        }        if( EDT_IS_EDITOR(context) )        {#ifdef EDITOR            if( bMouseInSelection )            {                // Indicate that user can drag selected text with special cursor                SetCursor(theApp.LoadCursor(IDC_IBEAM_HAND));                bCursorSet = TRUE;            }#else            XP_ASSERT(0);#endif // EDITOR        } else if( bIsLink )        {            // Set anchor cursor only if not in editor            SetCursor(theApp.LoadCursor(IDC_SELECTANCHOR));            bCursorSet = TRUE;        }        if( !bCursorSet )        {            // We have 2 text cursor sizes -- more visible for large fonts            SetCursor( theApp.LoadCursor(                            text_struct->height > 20 ? IDC_EDIT_IBEAM_LARGE : IDC_EDIT_IBEAM) );            bCursorSet = TRUE;        }    } #ifdef EDITOR    else if( EDT_IS_EDITOR(context) &&               lo_element &&                !EDT_IsSizing(context) )    {        // Test for proximity to border of sizeable objects        // This sets the cursor to system sizing cursor        // Note: X, Y are in View coordinates        int sizing = EDT_CanSizeObject(context, lo_element, pClose->xVal, pClose->yVal);        if( sizing )        {            switch ( sizing )            {                case ED_SIZE_TOP:                case ED_SIZE_BOTTOM:                    SetCursor(theApp.LoadStandardCursor(IDC_SIZENS));                    break;                case ED_SIZE_RIGHT:                    // Tables and cells can only size from the right border                    if( lo_element->type == LO_TABLE )                    {                        SetCursor(theApp.LoadCursor(IDC_TABLE_SIZE));                        break;                    }                    if( lo_element->type == LO_CELL )                    {                        SetCursor(theApp.LoadCursor(IDC_COL_SIZE));                        break;                    }                    // If not Table or Cell, fall through                     //  to set horizontal sizing cursor                case ED_SIZE_LEFT:                    SetCursor(theApp.LoadStandardCursor(IDC_SIZEWE));                    break;                case ED_SIZE_TOP_RIGHT:                case ED_SIZE_BOTTOM_LEFT:                    SetCursor(theApp.LoadStandardCursor(IDC_SIZENESW));                    break;                case ED_SIZE_TOP_LEFT:                case ED_SIZE_BOTTOM_RIGHT:                    SetCursor(theApp.LoadStandardCursor(IDC_SIZENWSE));                    break;            }            bCursorSet = TRUE;        }    }#endif // EDITOR    // NOTE: We set the imagemap and status line stuff even if we set a "sizing" cursor    // See if we are over an image that is a link    image_struct = (LO_ImageStruct *) lo_element;    if(image_struct && image_struct->type == LO_IMAGE && image_struct->image_attr)	{		if(image_struct->image_attr->usemap_name != NULL)	{			CPoint image_offset;			image_offset.x = CASTINT(pClose->xVal - (image_struct->x + image_struct->x_offset + image_struct->border_width));			image_offset.y = CASTINT(pClose->yVal - (image_struct->y + image_struct->y_offset + image_struct->border_width));			LO_AnchorData *pAnchorData = LO_MapXYToAreaAnchor(pWin->GetDocumentContext(), image_struct,				image_offset.x, image_offset.y);			if(pAnchorData != NULL)	{                if( !EDT_IS_EDITOR(context) && !bMouseInSelection ){                    SetCursor(theApp.LoadCursor(IDC_SELECTANCHOR));                    bCursorSet = TRUE;                }		        if( pAnchorData->anchor && !bTextSet ) {		            wfe_Progress(context, (char *) pAnchorData->anchor);                    bTextSet = TRUE;                }			}		}        else if((image_struct->image_attr->attrmask & LO_ATTR_ISMAP) && image_struct->anchor_href) {            // if its an ismap print the coordinates too            char buf[32];            CPoint point;            point.x = (int) (pClose->xVal - (image_struct->x + image_struct->x_offset));            point.y = (int) (pClose->yVal - (image_struct->y + image_struct->y_offset));            sprintf(buf, "?%d,%d", point.x, point.y);            CString anchor;            anchor = (char *) image_struct->anchor_href->anchor;            anchor += buf;            if( !EDT_IS_EDITOR(context) && !bMouseInSelection ){                SetCursor(theApp.LoadCursor(IDC_SELECTANCHOR));                bCursorSet = TRUE;            }            //  Set progress text if mocha allows it.            if(!bTextSet) {                wfe_Progress(context, (const char *)anchor);                bTextSet = TRUE;            }        }        else if(image_struct->anchor_href) {            // Set anchor cursor only if not in editor and not in a selection            if( !EDT_IS_EDITOR(context) && !bMouseInSelection ) {    	        SetCursor(theApp.LoadCursor(IDC_SELECTANCHOR));                bCursorSet = TRUE;            }	        if (image_struct->anchor_href->anchor && !bTextSet) {    	        wfe_Progress(context, (char *) image_struct->anchor_href->anchor);    	        bTextSet = TRUE;	        }		}        else if(image_struct->image_attr->attrmask & LO_ATTR_INTERNAL_IMAGE                 && EDT_IS_EDITOR(context)                 && image_struct->alt != NULL ){            char *str;            if(!bTextSet)   {                PA_LOCK(str, char *, image_struct->alt);                if( str != 0 ){                    wfe_Progress( context, str );                    bTextSet = TRUE;                }                PA_UNLOCK(image_struct->alt);            }        }        if( EDT_IS_EDITOR(context) && !bCursorSet ){            // Experimental: Image can  be dragged, so if no cursor set above,            // use Open Hand with arrow to indicate "draggability" of the image            SetCursor(theApp.LoadCursor(IDC_ARROW_HAND));            bCursorSet = TRUE;        }    }    //  See if we are over an embedded item.    pEmbed = (LO_EmbedStruct *)lo_element;    if(pEmbed && pEmbed->objTag.type == LO_EMBED && pEmbed->objTag.FE_Data)  {		NPEmbeddedApp *pPluginShim = (NPEmbeddedApp *)pEmbed->objTag.FE_Data;		if(pPluginShim != NULL && wfe_IsTypePlugin(pPluginShim) == FALSE)	{	        CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pPluginShim->fe_data;	        if(pItem != NULL && pItem->m_bLoading == FALSE && pItem->m_bBroken == FALSE &&	            pItem->m_bDelayed == FALSE && pItem->m_lpObject != NULL)   	        {	            if( !bMouseInSelection ){                    SetCursor(theApp.LoadCursor(IDC_ACTIVATE_EMBED));	                bCursorSet = TRUE;                }                if(!bTextSet)   {	                CString csEmbed;	                csEmbed.LoadString(IDS_ACTIVATE_EMBED_STATUS);	                CString csDescrip;	                pItem->GetUserType(USERCLASSTYPE_FULL, csDescrip);	                csEmbed += csDescrip;	                wfe_Progress(context, (char *)(const char *)csEmbed);	                bTextSet = TRUE;                }	        }		}    }#ifdef EDITOR    // The IBeam cursor is normally displayed only when over text,    //  but if we arrive here and have not set cursor, use the IBeam, except    //  if we are in a location to select the entire line: use right-facing arrow    // Otherwise we get the default left-facing arrow, which is confusing    if( EDT_IS_EDITOR(context) && !bCursorSet )    {        SetCursor( theApp.LoadCursor(LO_CanSelectLine(context, pClose->xVal, pClose->yVal) ?                                      IDC_ARROW_RIGHT : IDC_EDIT_IBEAM) );        bCursorSet = TRUE;    }#endifFINISH_MOUSE_OVER:    // If nothing set yet blank it out and make sure we have the     //   normal cursor.  Do we really want to reset the cursor     //   here????    // We want to show link text but keep edit cursor in Editor    if(!bCursorSet){        SetCursor(theApp.LoadStandardCursor(IDC_ARROW));    }    if(!bTextSet) {        wfe_Progress(context, "");        bTextSet = TRUE;    }    // For mouse overs on anchors we may have created a fake    //   LO_Element structure.  If so, blow it away now    if(pClose->bDeleteLO_Element)        XP_FREE(lo_element);    XP_FREE(pClose);    //  Have the mouse timer handler do some dirty work.    //  Please don't return in the above code, I'd like this to get called    //      in all cases with the state of the buttons set correctly.    MouseTimerData mt(context);    FEU_MouseTimer(&mt);#endif /* MOZ_NGLAYOUT */}