コード例 #1
0
ファイル: macros.c プロジェクト: macssh/macssh
short ModalMacros(NewMacroInfo *macrost)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	SetUpMovableModalMenus();
	dtemp=GetNewMyDialog( MacroDLOG + 2, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);
	HideDialogItem(dtemp, 25); // no save default in session macros dialog

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = macrost->handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = *macrost;

	// 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, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}

	TelInfo->macrosModeless = dtemp;

	dItem = 0;
	while ((dItem != 1) && (dItem != 2)) {
		movableModalDialog(0, &dItem);
		MacroDialog(macrost, dtemp, 0, dItem);
	}

	if (dItem == 2) CancelMacros(macrost, dtemp);
	else CloseMacros(macrost, dtemp);
	ResetMenus();
	return dItem;
}
コード例 #2
0
ファイル: SAMENU.CPP プロジェクト: JamesMakela-NOAA/PyGnome
/****************************************************************
   ShowDPopup() shows the given popup item and its label item.
 ****************************************************************/
void ShowDPopup(DialogPtr theDialog, short item)
{
      short          i;

      for ( i = 0 ; i < sa_numPopUps ; i++ )
         if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == item) )
            break;

      if (i < sa_numPopUps) {
         ShowDialogItem(theDialog, sa_popTable[i].popupItemNum);
         if (sa_popTable[i].titleItemNum)
            ShowDialogItem(theDialog, sa_popTable[i].titleItemNum);
      }
}
コード例 #3
0
ファイル: macros.c プロジェクト: macssh/macssh
void	Macros( void)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	setLastCursor(theCursors[normcurs]);

	if (TelInfo->macrosModeless) {
		SelectWindow(TelInfo->macrosModeless);
		return;
	}

	dtemp=GetNewMyDialog( MacroDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = TelInfo->newMacros.handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = TelInfo->newMacros;

	// 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(&TelInfo->newMacros, i, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}
	TelInfo->macrosModeless = dtemp;
}
コード例 #4
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
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);
}
コード例 #5
0
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);
}
コード例 #6
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;
	}
}