Beispiel #1
0
/*	SelEditItem(theDialog, itemNumber)

	Selects the entire text of the editText item specified by theItem.
	
	Prior to XOP Toolkit 4.0 (Carbon), if itemNumber was 0, this routine used
	the currently-selected edit item. This feature did not fit in with the Carbon
	way of doing things and is no longer supported. The itemNumber parameter must
	be the item number of an edit text item.

	Thread Safety: SelEditItem is not thread-safe.
*/
void
SelEditItem(DialogPtr theDialog, int itemNumber)
{
	char text[256];
	
	if (itemNumber == 0)
		return;
	
	SelectDialogItemText(theDialog, itemNumber, 0, GetDText(theDialog,itemNumber,text));
}
Beispiel #2
0
static void RunDialogTheSystem6or7Way(DialogRef theDialog)
{
	SInt16 itemHit;
	DialogItemType itemType;
	Handle itemHandle;
	Rect itemBox;
	
	BringToFront(GetDialogWindow(theDialog));
	
	do {
		ModalDialog(MySystem6or7DialogFilter, &itemHit);
		switch (itemHit)
		{
			case 2:
			{
				// we enable or disable the user item depending on whether the box is checked or not
				GetDialogItem(theDialog, itemHit, &itemType, &itemHandle, &itemBox);
				SInt16 enable = GetControlValue((ControlHandle)itemHandle);
				SetControlValue((ControlHandle)itemHandle, 1 - enable);
				GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox);
				SetDialogItem(theDialog, 13, enable?userItem+itemDisable:userItem, itemHandle, &itemBox);
				HideDialogItem(theDialog, 13);
				ShowDialogItem(theDialog, 13);
			}
				break;
			case 3: case 4: case 5: case 6: case 7:
			{
				// one radio button was chosen, let's adjust them all (we could also remember the last one...)
				int i;
				for (i = 3; i <= 7; i++)
				{
					GetDialogItem(theDialog, i, &itemType, &itemHandle, &itemBox);
					SetControlValue((ControlHandle)itemHandle, (i == itemHit)?1:0);
				}
			}
				break;
			case 14:
			{
				// the indicator of the scroll bar was moved so let's display the value in the first edit box
				// this is System 6 or 7 style so the controls can only handle 16 bits value (hence a max of 32767)
				GetDialogItem(theDialog, itemHit, &itemType, &itemHandle, &itemBox);
				SInt16 newValue = GetControlValue((ControlHandle)itemHandle);
				Str255 theStr;
				NumToString(newValue, theStr);
				GetDialogItem(theDialog, 9, &itemType, &itemHandle, &itemBox);
				SetDialogItemText(itemHandle, theStr);
				SelectDialogItemText(theDialog, 9, 0, 32767);
			}
				break;
		}
	} while (!(itemHit == ok));
	
	DisposeDialog(theDialog);
}
void MySelectDialogItemText(DialogRef theDialog, short editTextitemNum, short strtSel, short endSel)
{
#if TARGET_API_MAC_CARBON
	// with the new MAC code, the edit text item with the focus was not showing the text 
	// it acted like the text was invisible... like it had drawn it and didn't care to redraw it.
	// I don't know what is up with that, but Hiding and Showing the item seems to do the trick
	// even though InvalDialogItemRect didn't help
	if(!IsWindowVisible(GetDialogWindow(theDialog))) {
		// then this is being called when the window is being set up
		// and so we need to use our trick
		HideDialogItem(theDialog,editTextitemNum);
		ShowDialogItem(theDialog,editTextitemNum);
	}
#endif

	SelectDialogItemText(theDialog,editTextitemNum,strtSel,endSel);
}
Beispiel #4
0
// 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;
	}
}
Beispiel #5
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);
}
static pascal Boolean MyFilter(DialogPtr dlog, EventRecord *evt, short *itemHit)
	{
		Boolean ans=FALSE,doHilite=FALSE; WindowPtr w;
		short type,ch; Handle hndl; Rect box;
		static long then; static Point clickPt;

		w = (WindowPtr)(evt->message);
		switch(evt->what) {
			case updateEvt:
				if (w == dlog) {
					/* Update our dialog contents */
					DoDialogUpdate(dlog);
					ans = TRUE; *itemHit = 0;
					}
				 else {
					/*
					 *	Call your main event loop DoUpdate(w) routine here if you
					 *	don't want unsightly holes in background windows caused
					 *	by nested alerts, balloon help, or screen savers (see
					 *	Tech Note #304).
					 */
					}
				break;
			case activateEvt:
				if (w == dlog) {
					DoDialogActivate(dlog,(evt->modifiers & activeFlag)!=0);
					*itemHit = 0;
					}
				 else {
					/*
					 *	Call your main event loop DoActivate(w) routine here if
					 *	you want to deactivate the former frontmost window, in order
					 *	to unhighlight any selection, scroll bars, etc.
					 */
					}
				break;
			case mouseDown:
			case mouseUp:
				where = evt->where;		/* Make info available to DoDialog() */
				GlobalToLocal(&where);
				modifiers = evt->modifiers;
				ans = CheckUserItems(where,itemHit);
				break;
			case keyDown:
				if ((ch=(unsigned char)evt->message)=='\r' || ch==ENTERkey) {
					*itemHit = OK_ITEM /* Default Item Number here */;
					doHilite = ans = TRUE;
					}
				 else if (evt->modifiers & cmdKey) {
					ch = (unsigned char)evt->message;
					switch(ch) {
						case 'x':
						case 'X':
							if (TextSelected(dlog))
								{ SystemEdit(3); ZeroScrap(); DialogCut(dlog); TEToScrap(); }
							 else {
								/* Cut from anything else cuttable, like a list */
								}
							break;
						case 'c':
						case 'C':
							if (TextSelected(dlog))
								{ SystemEdit(3); ZeroScrap(); DialogCopy(dlog); TEToScrap(); }
							 else {
								/* Copy from anything else copyable, like a list */
								}
							break;
						case 'v':
						case 'V':
							if (CanPaste(1,'TEXT'))
								{ TEFromScrap(); DialogPaste(dlog); }
							 else {
							 	/* Deal with any other pasteable scraps here */
								}
							break;
						case 'a':
						case 'A':
							if (((DialogPeek)dlog)->editField >= 0) {
								/* Dialog has text edit item: select all */
								SelectDialogItemText(dlog,((DialogPeek)dlog)->editField+1,0,32767);
								}
							 else {
								}
							*itemHit = 0;
							break;
						case '.':
							*itemHit = CANCEL_ITEM;
							doHilite = TRUE;
							break;
						}
					ans = TRUE;		/* Other cmd-chars ignored */
					}
				break;
			}
		if (doHilite) {
			GetDialogItem(dlog,*itemHit,&type,&hndl,&box);
			/* Reality check */
			if (type == (btnCtrl+ctrlItem)) {
				long soon = TickCount() + 7;		/* Or whatever feels right */
				HiliteControl((ControlHandle)hndl,1);
				while (TickCount() < soon) ;		/* Leave hilited for a bit */
				}
			}
		return(ans);
	}
Beispiel #7
0
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);
}