예제 #1
0
NMBoolean
NMTeardownDialog(
    NMDialogPtr	dialog,
    NMBoolean	inUpdateConfig,
    NMConfigRef	ioConfig)
{
    DEBUG_ENTRY_EXIT("NMTeardownDialog");

    NMIPConfigPriv	*theConfig = (NMIPConfigPriv *) ioConfig;
    NMErr		status;
    InetAddress		addr;
    Str255			hostText;
    Str255			portText;

    NMSInt16		kind;
    Rect 			r;
    Handle 			h;
    NMSInt32		theVal;
    SetTempPort		port(dialog);

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

    if (inUpdateConfig)
    {
        // 	Get the host text
        GetDialogItem(dialog, gBaseItem + kHostText, &kind, &h, &r);
        GetDialogItemText(h, hostText);

        p2cstr(hostText);

        //	resolve it into a host addr
        status = OTUtils::MakeInetAddressFromString((const char *)hostText, &addr);
        op_warn(status == kNMNoError);

        if (status != kNMNoError)
            return false;

        theConfig->address = addr;

        //	Get the port text
        GetDialogItem(dialog, gBaseItem + kPortText, &kind, &h, &r);
        GetDialogItemText(h, portText);
        StringToNum(portText, &theVal);

        if (theVal != 0)
            theConfig->address.fPort = theVal;
    }

    return true;
}
예제 #2
0
파일: macros.c 프로젝트: macssh/macssh
void CloseMacros(NewMacroInfo *macrost, DialogPtr dtemp)
{
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10];

	if ( TelInfo->macrosModeless == dtemp ) {
		for (i=0; i<10; i++) {
			GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
			GetDialogItemText( MacString[i], temp);
			p2cstr(temp);
			setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}

		DisposeHandle(oldMacros);
		DisposeDialog(dtemp);
		
		//if ( TelInfo->macrosModeless ) {
			TelInfo->macrosModeless = 0;
			AdjustMenus();
			DoTheMenuChecks();
		//}
	}
}
예제 #3
0
/*	GetDText(theDialog, theItem, theText)

	Gets text from text item in dialog.
	Returns the number of characters in the text.

	Thread Safety: GetDText is not thread-safe.
*/
int
GetDText(DialogPtr theDialog, int theItem, char *theText)
{
	short type;
	Handle item;
	Rect box;

	// According to Apple, this is the correct routine to use to get a handle
	// to pass to GetDialogItemText, even if embedding (kDialogFlagsUseControlHierarchy)
	// is on.
	GetDialogItem(theDialog, theItem, &type, &item, &box);

	GetDialogItemText(item, (unsigned char*)theText);
	CopyPascalStringToC((unsigned char*)theText, theText);
	return strlen(theText);
}
예제 #4
0
파일: macros.c 프로젝트: macssh/macssh
// NB: As of 2.0fc1, theEvent can be NULL! It isn't used anywhere, so don't _let_ it be
// used anywhere!
void MacroDialog(NewMacroInfo *macrost, DialogPtr dtemp, EventRecord *theEvent, short dItem)
{
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	switch (dItem) {
		case 27: // switch keyset (pane) - RAB BetterTelnet 2.0b5
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			dialogPane = GetCntlVal(dtemp, 27) - 1;
			// now fix the strings
			for (i=0; i<10; i++) {
				GetIndString(temp, 7100, i + (10 * dialogPane) + 1);
				GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox);
				if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); }
				else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); }
				SetDialogItemText(rubbish, temp);
			}
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
		break;

		case (MacroExport):
			// we _used_ to get all the macros out, but now only the current set of 10
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
								// RAB BetterTelnet 2.0b5 (revised)
			}
			saveMacros(macrost, (FSSpec *) NULL);
			break;
		case 25:
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			SaveGlobalMacros(macrost);
			break;
		case (MacroImport):
			loadMacros(macrost, (FSSpec *) NULL);
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
			break;
		case 1:
		case 2:
			break;
		default:
			if (dItem >2 && dItem <13) 
			{
				i=dItem-3;
				getmacro(macrost, i + (dialogPane * 10), (char *) &temp, 256); /* BYU LSC */
				c2pstr((char *)temp);
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );				/* BYU LSC - Revert the mother */
				SelectDialogItemText( dtemp, i+13, 0, 32767);				/* And select it... */
			}	
			break;
	}
}
char *QTTarg_GetStringFromUser (short thePromptStringIndex)
{
	short 			myItem;
	short 			mySavedResFile;
	GrafPtr			mySavedPort;
	DialogPtr		myDialog = NULL;
	short			myItemKind;
	Handle			myItemHandle;
	Rect			myItemRect;
	Str255			myString;
	char			*myCString = NULL;
	OSErr			myErr = noErr;

	//////////
	//
	// save the current resource file and graphics port
	//
	//////////

	mySavedResFile = CurResFile();
	GetPort(&mySavedPort);

	// set the application's resource file
	UseResFile(gAppResFile);

	//////////
	//
	// create the dialog box in which the user will enter a URL
	//
	//////////

	myDialog = GetNewDialog(kGetStr_DLOGID, NULL, (WindowPtr)-1L);
	if (myDialog == NULL)
		goto bail;

	QTFrame_ActivateController(QTFrame_GetFrontMovieWindow(), false);
	
	MacSetPort(GetDialogPort(myDialog));
	
	SetDialogDefaultItem(myDialog, kGetStr_OKButton);
	SetDialogCancelItem(myDialog, kGetStr_CancelButton);
	
	// set the prompt string	
	GetIndString(myString, kTextKindsResourceID, thePromptStringIndex);

	GetDialogItem(myDialog, kGetStr_StrLabelItem, &myItemKind, &myItemHandle, &myItemRect);
	SetDialogItemText(myItemHandle, myString);
	
	MacShowWindow(GetDialogWindow(myDialog));
	
	//////////
	//
	// display and handle events in the dialog box until the user clicks OK or Cancel
	//
	//////////
	
	do {
		ModalDialog(gModalFilterUPP, &myItem);
	} while ((myItem != kGetStr_OKButton) && (myItem != kGetStr_CancelButton));
	
	//////////
	//
	// handle the selected button
	//
	//////////
	
	if (myItem != kGetStr_OKButton) {
		myErr = userCanceledErr;
		goto bail;
	}
	
	// retrieve the edited text
	GetDialogItem(myDialog, kGetStr_StrTextItem, &myItemKind, &myItemHandle, &myItemRect);
	GetDialogItemText(myItemHandle, myString);
	myCString = QTUtils_ConvertPascalToCString(myString);
	
bail:
	// restore the previous resource file and graphics port
	MacSetPort(mySavedPort);
	UseResFile(mySavedResFile);
	
	if (myDialog != NULL)
		DisposeDialog(myDialog);

	return(myCString);
}
예제 #6
0
void dialog_scropt(void) {

	DialogPtr		hDlg;
	ControlHandle	chipbtn[2];
	ControlHandle	grcgbtn[4];
	ControlHandle	lcdbtn[2];
	ControlHandle	skipbtn;
	ControlHandle	c16btn;
	UINT			chip;
	UINT			grcg;
	UINT			color16;
	UINT			lcd;
	UINT			skipline;
	UINT			val;
	char			work[32];
	Str255			workstr;
	int				done;
	short			item;
	UINT			update;
	UINT			renewal;
	BYTE			waitval[6];

	hDlg = GetNewDialog(IDD_SCREENOPT, NULL, (WindowPtr)-1);
	if (!hDlg) {
		return;
	}
	chipbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_GDC7220);
	chipbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_GDC72020);

	grcgbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCGNON);
	grcgbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCG);
	grcgbtn[2] = (ControlHandle)GetDlgItem(hDlg, IDC_GRCG2);
	grcgbtn[3] = (ControlHandle)GetDlgItem(hDlg, IDC_EGC);

	c16btn = (ControlHandle)GetDlgItem(hDlg, IDC_PC980124);

	lcdbtn[0] = (ControlHandle)GetDlgItem(hDlg, IDC_LCD);
	lcdbtn[1] = (ControlHandle)GetDlgItem(hDlg, IDC_LCDX);
	skipbtn = (ControlHandle)GetDlgItem(hDlg, IDC_SKIPLINE);

	chip = (np2cfg.uPD72020)?1:0;
	setchip(chipbtn, chip);
	grcg = np2cfg.grcg & 3;
	setgrcg(grcgbtn, grcg);
	color16 = (np2cfg.color16)?1:0;
	SetControlValue(c16btn, color16);

	val = np2cfg.wait[0];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_TRAMWAIT), workstr);
	val = np2cfg.wait[2];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_VRAMWAIT), workstr);
	val = np2cfg.wait[4];
	if (val > 32) {
		val = 32;
	}
	SPRINTF(work, str_u, val);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_GRCGWAIT), workstr);
	val = np2cfg.realpal;
	if (val > 64) {
		val = 64;
	}
	SPRINTF(work, str_d, val - 32);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_REALPAL), workstr);

	lcd = np2cfg.LCD_MODE & 3;
	SetControlValue(lcdbtn[0], lcd & 1);
	SetControlValue(lcdbtn[1], (lcd & 2) >> 1);
	skipline = (np2cfg.skipline)?1:0;
	SetControlValue(skipbtn, skipline);
	SPRINTF(work, str_u, np2cfg.skiplight);
	mkstr255(workstr, work);
	SetDialogItemText(GetDlgItem(hDlg, IDC_SKIPLIGHT), workstr);

	SetDialogDefaultItem(hDlg, IDOK);
	SetDialogCancelItem(hDlg, IDCANCEL);

	done = 0;
	while(!done) {
		ModalDialog(NULL, &item);
		switch(item) {
			case IDOK:
				update = 0;
				if (np2cfg.uPD72020 != chip) {
					np2cfg.uPD72020 = chip;
					update |= SYS_UPDATECFG;
					gdc_restorekacmode();
					gdcs.grphdisp |= GDCSCRN_ALLDRAW2;
				}
				if (np2cfg.grcg != grcg) {
					np2cfg.grcg = grcg;
					update |= SYS_UPDATECFG;
					gdcs.grphdisp |= GDCSCRN_ALLDRAW2;
				}
				if (np2cfg.color16 != color16) {
					np2cfg.color16 = color16;
					update |= SYS_UPDATECFG;
				}

				GetDialogItemText(GetDlgItem(hDlg, IDC_TRAMWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[0] = val;
				waitval[1] = (val)?1:0;
				GetDialogItemText(GetDlgItem(hDlg, IDC_VRAMWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[2] = val;
				waitval[3] = (val)?1:0;
				GetDialogItemText(GetDlgItem(hDlg, IDC_GRCGWAIT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 32) {
					val = 32;
				}
				waitval[4] = val;
				waitval[5] = (val)?1:0;
				if (memcmp(np2cfg.wait, waitval, 6)) {
					CopyMemory(np2cfg.wait, waitval, 6);
					update |= SYS_UPDATECFG;
				}
				GetDialogItemText(GetDlgItem(hDlg, IDC_REALPAL), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work) + 32;
				if (val > 64) {
					val = 64;
				}
				if (np2cfg.realpal != val) {
					np2cfg.realpal = val;
					update |= SYS_UPDATECFG;
				}

				renewal = 0;
				if (np2cfg.skipline != skipline) {
					np2cfg.skipline = skipline;
					renewal = 1;
				}
				GetDialogItemText(GetDlgItem(hDlg, IDC_SKIPLIGHT), workstr);
				mkcstr(work, sizeof(work), workstr);
				val = milstr_solveINT(work);
				if (val > 255) {
					val = 255;
				}
				if (np2cfg.skiplight != val) {
					np2cfg.skiplight = val;
					renewal = 1;
				}
				if (renewal) {
					pal_makeskiptable();
				}
				if (np2cfg.LCD_MODE != lcd) {
					np2cfg.LCD_MODE = lcd;
					pal_makelcdpal();
					renewal = 1;
				}
				if (renewal) {
					update |= SYS_UPDATECFG;
					scrndraw_redraw();
				}

				sysmng_update(update);
				done = IDOK;
				break;

			case IDCANCEL:
				done = IDCANCEL;
				break;

			case IDC_LCD:
				lcd ^= 1;
				SetControlValue(lcdbtn[0], lcd & 1);
				break;

			case IDC_LCDX:
				lcd ^= 2;
				SetControlValue(lcdbtn[1], (lcd & 2) >> 1);
				break;

			case IDC_SKIPLINE:
				skipline ^= 1;
				SetControlValue(skipbtn, skipline);
				break;

			case IDC_GDC7220:
				chip = 0;
				setchip(chipbtn, chip);
				break;

			case IDC_GDC72020:
				chip = 1;
				setchip(chipbtn, chip);
				break;

			case IDC_GRCGNON:
				grcg = 0;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_GRCG:
				grcg = 1;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_GRCG2:
				grcg = 2;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_EGC:
				grcg = 3;
				setgrcg(grcgbtn, grcg);
				break;

			case IDC_PC980124:
				color16 ^= 1;
				SetControlValue(c16btn, color16);
				break;
		}
	}
	DisposeDialog(hDlg);
}
예제 #7
0
Boolean QTInfo_EditAnnotation (Movie theMovie, OSType theType)
{
    DialogPtr		myDialog = NULL;
    short 			myItem;
    short 			mySavedResFile;
    GrafPtr			mySavedPort;
    Handle			myHandle = NULL;
    short			myItemKind;
    Handle			myItemHandle;
    UserData		myUserData = NULL;
    Rect			myItemRect;
    Str255			myString;
    Boolean			myIsChanged = false;
    OSErr			myErr = noErr;

    //////////
    //
    // save the current resource file and graphics port
    //
    //////////

    mySavedResFile = CurResFile();
    GetPort(&mySavedPort);

    // set the application's resource file
    UseResFile(gAppResFile);

    // get the movie user data
    myUserData = GetMovieUserData(theMovie);
    if (myUserData == NULL)
        goto bail;

    //////////
    //
    // create the dialog box in which the user will add or edit the annotation
    //
    //////////

    myDialog = GetNewDialog(kEditTextResourceID, NULL, (WindowPtr)-1L);
    if (myDialog == NULL)
        goto bail;

    MacSetPort(GetDialogPort(myDialog));

    SetDialogDefaultItem(myDialog, kEditTextItemOK);
    SetDialogCancelItem(myDialog, kEditTextItemCancel);

    // get a string for the specified annotation type
    switch (theType) {
    case kUserDataTextFullName:
        GetIndString(myString, kTextKindsResourceID, kTextKindsFullName);
        break;

    case kUserDataTextCopyright:
        GetIndString(myString, kTextKindsResourceID, kTextKindsCopyright);
        break;

    case kUserDataTextInformation:
        GetIndString(myString, kTextKindsResourceID, kTextKindsInformation);
        break;
    }

    GetDialogItem(myDialog, kEditTextItemEditLabel, &myItemKind, &myItemHandle, &myItemRect);
    SetDialogItemText(myItemHandle, myString);

    //////////
    //
    // set the current annotation of the specified type, if it exists
    //
    //////////

    myHandle = NewHandleClear(4);
    if (myHandle != NULL) {
        myErr = GetUserDataText(myUserData, myHandle, theType, 1, GetScriptManagerVariable(smRegionCode));
        if (myErr == noErr) {
            QTInfo_TextHandleToPString(myHandle, myString);
            GetDialogItem(myDialog, kEditTextItemEditBox, &myItemKind, &myItemHandle, &myItemRect);
            SetDialogItemText(myItemHandle, myString);
            SelectDialogItemText(myDialog, kEditTextItemEditBox, 0, myString[0]);
        }

        DisposeHandle(myHandle);
    }

    MacShowWindow(GetDialogWindow(myDialog));

    //////////
    //
    // display and handle events in the dialog box until the user clicks OK or Cancel
    //
    //////////

    do {
        ModalDialog(gModalFilterUPP, &myItem);
    } while ((myItem != kEditTextItemOK) && (myItem != kEditTextItemCancel));

    //////////
    //
    // handle the selected button
    //
    //////////

    if (myItem != kEditTextItemOK)
        goto bail;

    // retrieve the edited text
    myHandle = NewHandleClear(4);
    if (myHandle != NULL) {
        GetDialogItem(myDialog, kEditTextItemEditBox, &myItemKind, &myItemHandle, &myItemRect);
        GetDialogItemText(myItemHandle, myString);
        QTInfo_PStringToTextHandle(myString, myHandle);
        myErr = AddUserDataText(myUserData, myHandle, theType, 1, GetScriptManagerVariable(smRegionCode));
        myIsChanged = (myErr == noErr);
        DisposeHandle(myHandle);
    }

bail:
    // restore the previous resource file and graphics port
    MacSetPort(mySavedPort);
    UseResFile(mySavedResFile);

    if (myDialog != NULL)
        DisposeDialog(myDialog);

    return(myIsChanged);
}
예제 #8
0
파일: maclook.c 프로젝트: macssh/macssh
void setupkeys( void)
{
	DialogPtr dtemp;
	Rect dBox;
	short dItem,kItem,sItem,eItem;
	Handle kbox,sbox,ebox;
	
	char *tempspot;
	
	tempspot = (char *) myNewPtr(256);
	if (tempspot == NULL)
		return; //BUGG signal error here
		
	SetUpMovableModalMenus();
	dtemp=GetNewMyDialog( SetupDLOG, NULL, kInFront, (void *)ThirdCenterDialog);

	setLastCursor(theCursors[normcurs]);
	
	GetDialogItem( dtemp, killbox, &kItem, &kbox, &dBox);	
	GetDialogItem( dtemp, stopbox, &eItem, &ebox, &dBox);	
	GetDialogItem( dtemp, startbox, &sItem, &sbox, &dBox);	

	*tempspot = 0;
	if (screens[scrn].TELstop > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELstop^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( ebox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, stopbox, 0, 32767);
		}
	if (screens[scrn].TELgo > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELgo^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( sbox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, startbox, 0, 32767);
		}
	if (screens[scrn].TELip > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELip^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( kbox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, killbox, 0, 32767);
		}
	
		dItem=0;								/* initially no hits */
		while((dItem>3) || (dItem==0)) {		/* While we are in the loop */
			/*ModalDialog(DLOGwOK_CancelUPP,&dItem);*/
			movableModalDialog(DLOGwOK_CancelUPP,&dItem);

/*
*  intermediate check.  If they hit a key, put its number in the box.
*/
			GetDialogItemText( kbox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( kbox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, killbox, 0, 32767 );
				}
			GetDialogItemText( ebox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( ebox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, stopbox, 0, 32767);
				}
			GetDialogItemText( sbox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( sbox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, startbox, 0, 32767);
				}
				
			}
				
	
		if (dItem==DLOGCancel) {
			DisposeDialog( dtemp);
			ResetMenus();
			return;
			}
			
		GetDialogItemText( kbox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELip = -1;
		else
			screens[scrn].TELip = toupper(*(tempspot+1)) ^ 64;
			
		GetDialogItemText( ebox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELstop = -1;
		else
			screens[scrn].TELstop = toupper(*(tempspot+1)) ^ 64;

		GetDialogItemText( sbox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELgo = -1;
		else
			screens[scrn].TELgo = toupper(*(tempspot+1)) ^ 64;
			
	DisposeDialog( dtemp);
	ResetMenus();
	updateCursor(1);
}
static bool GetFloat(ControlHandle Hdl, float& Value)
{
	GetDialogItemText((Handle)Hdl,ptemporary);
	ptemporary[ptemporary[0]+1] = 0;
	return (sscanf(temporary+1,"%f",&Value) == 1);
}
예제 #10
0
void
OpenProxySettings(void)
{
    short itemHit = 999;
    short itemType;
    Handle item;
    Rect itemBox;
    Str255 itemText, pswdBuf, blindPswdText;
    DialogPtr psDlg;
    Boolean bDefault = true;
    
    /* show dialog */
    psDlg = GetNewDialog(rDlgProxySettg, NULL, (WindowPtr) -1);

    /* show dialog title, button and lable from install.ini */
    GetResourcedString(itemText, rInstList, sProxyDlg);
    SetWTitle(psDlg, itemText);
    GetDialogItem(psDlg, rProxyStrOK, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sOKBtn);
    SetControlTitle((ControlRecord **)item, itemText);
    SetControlData((ControlRecord **)item, kControlNoPart, 
            kControlPushButtonDefaultTag, sizeof(bDefault),(Ptr) &bDefault);
    GetDialogItem(psDlg, rProxyStrCancel, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sCancel);
    SetControlTitle((ControlRecord **)item, itemText);
    GetDialogItem(psDlg, rProxyStrHostLab, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sProxyHost);
    SetDialogItemText(item, itemText);
    GetDialogItem(psDlg, rProxyStrPortLab, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sProxyPort);
    SetDialogItemText(item, itemText);
    GetDialogItem(psDlg, rProxyStrUserLab, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sProxyUsername);
    SetDialogItemText(item, itemText);
    GetDialogItem(psDlg, rProxyStrPswdLab, &itemType, &item, &itemBox);
    GetResourcedString(itemText, rInstList, sProxyPassword);
    SetDialogItemText(item, itemText);

    /* pre-populate text fields */
    if (gControls->opt->proxyHost)
    {
        my_c2pstrcpy(gControls->opt->proxyHost, itemText);
        GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox);
        SetDialogItemText(item, itemText);
    }
    
    if (gControls->opt->proxyPort)
    {
        my_c2pstrcpy(gControls->opt->proxyPort, itemText);
        GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox);
        SetDialogItemText(item, itemText);    
    }
    
    if (gControls->opt->proxyUsername)
    {
        my_c2pstrcpy(gControls->opt->proxyUsername, itemText);
        GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox);
        SetDialogItemText(item, itemText);    
    }
    
    if (gControls->opt->proxyPassword)
    {
        int pswdLen = strlen(gControls->opt->proxyPassword);
        memset(&blindPswdText[1], '¥', pswdLen);
        blindPswdText[0] = pswdLen;
        GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox);
        SetDialogItemText(item, blindPswdText);    
    }
    
    if (gControls->opt->proxyPassword)
        my_c2pstrcpy(gControls->opt->proxyPassword, pswdBuf);
    else
        pswdBuf[0] = 0;
    do
    {
        ModalDialog(NULL, &itemHit);
        
        /* special handling for "blind" password field */
        if (itemHit == rProxyPswdItem)
        {
            GetDialogItem(psDlg, rProxyPswdItem, &itemType, &item, &itemBox);
            GetDialogItemText(item, itemText);
            
            /* char deleted ? */
            if (itemText[0] < pswdBuf[0])
            {
                /* truncate password buffer */
                pswdBuf[0] = itemText[0];
            }
            else
            {
                /* store new char in password buffer */
                pswdBuf[itemText[0]] = itemText[itemText[0]];
                pswdBuf[0] = itemText[0];
            }
            
            memset(&blindPswdText[1], '¥', pswdBuf[0]);
            blindPswdText[0] = itemText[0];
            
            SetDialogItemText(item, blindPswdText);
        }
    } while(itemHit != 1 && itemHit != 2);
    
    /* if OK was hit then take changed settings */
    if (itemHit == 1)
    {
        GetDialogItem(psDlg, rProxyHostItem, &itemType, &item, &itemBox);
        GetDialogItemText(item, itemText);
        if (itemText[0] > 0)
        {
            if (gControls->opt->proxyHost)
                free(gControls->opt->proxyHost);
            gControls->opt->proxyHost = (char *) malloc(itemText[0] + 1);
            strncpy(gControls->opt->proxyHost, (const char *)&itemText[1], itemText[0]);
            *(gControls->opt->proxyHost + itemText[0]) = 0;
        }
        
        GetDialogItem(psDlg, rProxyPortItem, &itemType, &item, &itemBox);
        GetDialogItemText(item, itemText);
        if (itemText[0] > 0)
        {
            if (gControls->opt->proxyPort)
                free(gControls->opt->proxyPort);        
            gControls->opt->proxyPort = (char *) malloc(itemText[0] + 1);
            strncpy(gControls->opt->proxyPort, (const char *)&itemText[1], itemText[0]);
            *(gControls->opt->proxyPort + itemText[0]) = 0;
        }
            
        GetDialogItem(psDlg, rProxyUserItem, &itemType, &item, &itemBox);
        GetDialogItemText(item, itemText);
        if (itemText[0] > 0)
        {
            if (gControls->opt->proxyUsername)
                free(gControls->opt->proxyUsername);        
            gControls->opt->proxyUsername = (char *) malloc(itemText[0] + 1);
            strncpy(gControls->opt->proxyUsername, (const char *)&itemText[1], itemText[0]);
            *(gControls->opt->proxyUsername + itemText[0]) = 0;
        }
            
        if (pswdBuf[0] > 0)
        {
            if (gControls->opt->proxyPassword)
                free(gControls->opt->proxyPassword);        
            gControls->opt->proxyPassword = (char *) malloc(pswdBuf[0] + 1);
            strncpy(gControls->opt->proxyPassword, (const char *)&pswdBuf[1], pswdBuf[0]);
            *(gControls->opt->proxyPassword + pswdBuf[0]) = 0;
        }
    }
        
    DisposeDialog(psDlg);
}