Example #1
0
nsresult nsWidget::CreateWidget(nsIWidget *aParent,
                                const nsRect &aRect,
                                EVENT_CALLBACK aHandleEventFunction,
                                nsIDeviceContext *aContext,
                                nsIAppShell *aAppShell,
                                nsIToolkit *aToolkit,
                                nsWidgetInitData *aInitData,
                                nsNativeWidget aNativeParent)
{

    PtWidget_t *parentWidget = nsnull;



    if( aNativeParent ) {
        parentWidget = (PtWidget_t*)aNativeParent;
        // we've got a native parent so listen for resizes
        mListenForResizes = PR_TRUE;
    }
    else if( aParent ) {
        parentWidget = (PtWidget_t*) (aParent->GetNativeData(NS_NATIVE_WIDGET));
        mListenForResizes = aInitData ? aInitData->mListenForResizes : PR_FALSE;
    }

    if( aInitData->mWindowType == eWindowType_child && !parentWidget ) return NS_ERROR_FAILURE;

    nsIWidget *baseParent = aInitData &&
                            (aInitData->mWindowType == eWindowType_dialog ||
                             aInitData->mWindowType == eWindowType_toplevel ||
                             aInitData->mWindowType == eWindowType_invisible) ?
                            nsnull : aParent;

    BaseCreate( baseParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData );

    mParent = aParent;
    mBounds = aRect;

    CreateNative (parentWidget);

    if( aRect.width > 1 && aRect.height > 1 ) Resize(aRect.width, aRect.height, PR_FALSE);

    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 );
#ifdef PHOTON_DND
        PtAddCallback( mWidget, Pt_CB_DND, DndCallback, this );
#endif
    }

    DispatchStandardEvent(NS_CREATE);

    return NS_OK;
}
Example #2
0
NxsFilePath::NxsFilePath(const std::string &s, bool shouldBeDir )
	:sourceOfName(kProgrammer),
	isAbsolute(false),
	isDirty(true),
	path(),
	pathAsEntered(),
	nativePath(),
	queryUserOnError(true)
	{
	PHYCAS_ASSERT(!shouldBeDir);	// file paths without filenames aren't supported yet
	if (ReadNewPathString(s))
		CreateNative();
	}