Exemplo n.º 1
0
static pascal_ifMac OSErr AddMyNavDialogItems (DialogRef dialog, short ditlResID, NavDialogRef context)
{
	OSErr err = noErr;
	
	Handle ditl = GetResource ('DITL',ditlResID);
	
	if (!ditl) {
		//MESSAGE("Resource not found");
		return -1;
	}

	if (context)
		err = NavCustomControl (context, kNavCtlAddControlList, ditl);
	else
		AppendDITL (dialog, ditl, appendDITLBottom);
	
	ReleaseResource (ditl);
	
	return err;
}
Exemplo n.º 2
0
NMErr
NMSetupDialog(NMDialogPtr dialog, short frame,  short inBaseItem,NMConfigRef config)
{
    DEBUG_ENTRY_EXIT("NMSetupDialog");

    NMErr				status = kNMNoError;
    Handle				ourDITL;
    NMIPConfigPriv		*theConfig = (NMIPConfigPriv *) config;
    SetupLibraryState	duh;	// Make sure we're accessing the right resource fork
    Str255				hostName;
    Str255				portText;

    NMSInt16			kind;
    Handle				h;
    Rect				r;

    SetTempPort			port(dialog);

    op_vassert_return((theConfig != NULL),"Config ref is NULL!",kNMParameterErr);
    op_vassert_return((dialog != NULL),"Dialog ptr is NULL!",kNMParameterErr);

    gBaseItem = inBaseItem;

    //	Try to load in our DITL.  If we fail, we should bail
    ourDITL = Get1Resource('DITL', kDITLID);
    if (ourDITL == NULL) {
        status = kNMBadStateErr;
        goto error;
    }

    if (ourDITL == NULL)
    {
        NMSInt16 err = ResError();
        return kNMResourceErr;
    }

    //	Append our DITL relative to the frame by passing the negative of the frame's id
    AppendDITL(dialog, ourDITL, -frame);
    ReleaseResource(ourDITL);

    //	Setup our dialog info.
    if (theConfig->address.fHost != 0)
    {
        //	Try to get the canonical name
        status = OTUtils::MakeInetNameFromAddress(theConfig->address.fHost, (char *) hostName);

        //	if that fails, just use the string version of the dotted quad
        if (status != kNMNoError)
            OTInetHostToString(theConfig->address.fHost, (char *) hostName);

        c2pstr((char *) hostName);
    }
    else
    {
        doCopyPStr("\p0.0.0.0", hostName);
    }

    //	get the port
    NumToString(theConfig->address.fPort, portText);

    GetDialogItem(dialog, gBaseItem + kHostText, &kind, &h, &r);
    SetDialogItemText(h, hostName);

    GetDialogItem(dialog, gBaseItem + kPortText, &kind, &h, &r);
    SetDialogItemText(h, portText);

error:
    return status;
}