Ejemplo n.º 1
0
void SetPinDialogLabels(HWND windowHandle, LPARAM lParam) {
	WCHAR label[512];
	MultiByteToWideChar(CP_UTF8, 0, createDialogTitle(((DialogData *)lParam)->name), -1, label, sizeof(label) / sizeof(WCHAR));
	SetWindowText(windowHandle, label);

	SetDialogItemText(windowHandle, IDC_NAME, ((DialogData *)lParam)->name);
	if(((DialogData *)lParam)->message != NULL) {
		SetDialogItemText(windowHandle, IDC_ERROR, ((DialogData *)lParam)->message);
	}
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
INT_PTR CALLBACK PinPadDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {		
	switch(message) {
		case WM_INITDIALOG:
			dialogWindowHandle = hwnd;			

			SetPinDialogLabels(dialogWindowHandle, lParam);
			SetDialogItemText(hwnd, IDC_PINPAD_PIN2_LABEL, l10n("For signing enter PIN2 from PIN pad"));

			countdownValue = 30; // in seconds
			EstEID_log("initializing pinpad countdown timer with value %i", countdownValue);
			SendMessage(GetDlgItem(dialogWindowHandle, IDC_PROGRESSBAR), PBM_SETSTATE, (WPARAM)PBST_PAUSED, 0L);
			SendMessage(GetDlgItem(dialogWindowHandle, IDC_PROGRESSBAR), PBM_SETRANGE, 0, MAKELPARAM(0, countdownValue));
			UpdateProgerssBar(dialogWindowHandle, countdownValue);
			SendMessage(GetDlgItem(dialogWindowHandle, IDC_PROGRESSBAR), PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0L);
			SetTimer(dialogWindowHandle, 1, 1000, NULL);
			break;
		case WM_DESTROY:
			KillCountdownTimer();
			break;
		case WM_TIMER:
			CountdownTimerProc();
			break;
		case WM_CTLCOLORSTATIC:
			if(GetDlgItem(hwnd, IDC_ERROR) == ((HWND)lParam)){
				return SetMessageLabelColorToRed(wParam);
			}
		default:			
			return false;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);	
}
Ejemplo n.º 4
0
Archivo: ugView.c Proyecto: rolk/ug
static int OneButtonBox (char *text, char *button1)
{
  DialogPtr theDialog;
  short itemHit,itemType;
  Handle item;
  Rect box;
  char buffer[256];

  theDialog = GetNewDialog(oneButtonDialog,NULL,(WindowPtr) -1);

  /* draw OK Button */
  GetDialogItem(theDialog,OKButton,&itemType,&item,&box);
  SetPort((GrafPtr) theDialog);
  PenSize(3,3);
  InsetRect(&box,-4,-4);
  FrameRoundRect(&box,16,16);

  /* change text of button 1 */
  strcpy(buffer,button1);
  SetControlTitle((ControlHandle) item,c2pstr(buffer));

  GetDialogItem(theDialog,2,&itemType,&item,&box);
  strcpy(buffer,text);
  SetDialogItemText(item,c2pstr(buffer));
  itemHit=0;
  while (itemHit!=OKButton)
  {
    ModalDialog(NULL,&itemHit);
  }
  DisposeDialog(theDialog);
  return(itemHit);
}
Ejemplo n.º 5
0
void mac_openabout(void)
{
    DialogItemType itemtype;
    Handle item;
    VersRecHndl vers;
    Rect box;
    StringPtr longvers;
    WinInfo *wi;

    if (windows.about)
	SelectWindow(windows.about);
    else {
	windows.about =
	    GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
	wi = snew(WinInfo);
	memset(wi, 0, sizeof(*wi));
	wi->wtype = wAbout;
	wi->update = &mac_updateabout;
	wi->click = &mac_clickabout;
	wi->activate = &mac_activateabout;
	wi->close = &mac_closeabout;
	SetWRefCon(windows.about, (long)wi);
	vers = (VersRecHndl)Get1Resource('vers', 1);
	if (vers != NULL && *vers != NULL) {
	    longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
	    GetDialogItem(GetDialogFromWindow(windows.about), wiAboutVersion,
			  &itemtype, &item, &box);
	    assert(itemtype & kStaticTextDialogItem);
	    SetDialogItemText(item, longvers);
	}
	ShowWindow(windows.about);
    }
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
/*	SetDText(theDialog, theItem, theText)

	Sets text in text item in dialog.

	Thread Safety: SetDText is not thread-safe.
*/
void
SetDText(DialogPtr theDialog, int theItem, const char *theText)
{
	ControlHandle controlH;
	unsigned char temp[256];

	// According to Apple, this is the correct routine to use to get a handle
	// to pass to SetDialogItemText, when embedding (kDialogFlagsUseControlHierarchy)
	// is on.
	if (XOPGetDialogItemAsControl(theDialog, theItem, &controlH) == 0) {
		CopyCStringToPascal(theText, temp);
		SetDialogItemText((Handle)controlH, temp);
	}
}
Ejemplo n.º 9
0
static void Utils_Macintosh_DisplayMsg(char *msg)
{
	DialogPtr theDlog;
	Handle item = NULL;
	Rect box;

		theDlog = GetNewDialog(kMsgDialogRsrcID, NULL, (WindowPtr)-1);
		if (theDlog != NULL)
		{
			short itemType;
			
				GetDialogItem(theDlog, kMsgItemID, &itemType, &item, &box);
				if (item != NULL)
				{
					short itemHit;
					
						SetDialogItemText(item, c2pstr(msg));
						ModalDialog(NULL, &itemHit);
						DisposeDialog(theDlog);
						p2cstr((StringPtr)msg);	/* restore C-string */
				}
		}

}
Ejemplo n.º 10
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);
}
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);
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
INT_PTR CALLBACK Pin2DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {	
	static TCHAR *pin2;
	static unsigned int minPin2Length;

	switch(message) {
		case WM_INITDIALOG:			
			HWND previousWindowsHandle;
			HWND pin2EntryWindowHandle;
			HWND parentWindowHandle;

			EstEID_log("[WM_INITDIALOG] begin");
			parentWindowHandle = GetParent(hwnd);
			EstEID_log("parentWindowHandle = %08X, current focus is @ %08X, foregroud window %08X", parentWindowHandle, GetFocus(), GetForegroundWindow());			

			dialogWindowHandle = hwnd;
			EstEID_log("PIN2 dialog window handle = %08X", dialogWindowHandle);
			SetPinDialogLabels(dialogWindowHandle, lParam);				
			SetDialogItemText(dialogWindowHandle, IDC_PIN2_LABEL, l10n("For signing enter PIN2:"));
			SetDialogItemText(dialogWindowHandle, IDOK, l10n("Sign"));
			SetDialogItemText(dialogWindowHandle, IDCANCEL, l10n("Cancel"));
			minPin2Length = ((DialogData *)lParam)->minPin2Length;
			pin2 = ((DialogData *)lParam)->pin2;

			pin2EntryWindowHandle = GetDlgItem(hwnd, IDC_PIN2);
			EstEID_log("PIN2 entry field window handle = %08X", pin2EntryWindowHandle);
			
			previousWindowsHandle = SetFocus(hwnd);
			if (!previousWindowsHandle) {
				EstEID_log("error detected: SetFocus(%08X) returned 0, error code = %li", hwnd, GetLastError());
			}
			else {
				EstEID_log("focus taken from %08X and set to %08X ", previousWindowsHandle, GetFocus());
			}
			EstEID_log("confirming: focus is @ %08X - %s", GetFocus(), GetFocus() == pin2EntryWindowHandle ? "sehr gut!" : "SHOULD NOT BE LIKE THAT!");

			if (GetFocus() != pin2EntryWindowHandle) {
				EstEID_log("second attempt to set focus...");
				previousWindowsHandle = SetFocus(hwnd);
				if (!previousWindowsHandle) {
						EstEID_log("again, error detected: SetFocus(%08X) returned 0, error code = %li", hwnd, GetLastError());
				}
				else {
					EstEID_log("again, focus taken from %08X and set to %08X ", previousWindowsHandle, GetFocus());
				}
				EstEID_log("again, confirming: focus is @ %08X - %s", GetFocus(), GetFocus() == pin2EntryWindowHandle ? "bueno!" : "Firefox? Giving up... Better take Google Chrome.");
			}

			EnableWindow(parentWindowHandle, false); // hack to disable controls in browser window
			
			EstEID_log("[WM_INITDIALOG] end");
			return true;

		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDOK:
					GetDlgItemText(hwnd, IDC_PIN2, pin2, PIN2_MAX_LEN);
				case IDCANCEL:					
					dialogWindowHandle = 0;
					EndDialog(hwnd, LOWORD(wParam));					
					EstEID_log("closing PIN2 dialog, focus is back @ %08X", GetFocus());					
					return true;
			}
			if(HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == IDC_PIN2) {
				Button_Enable(GetDlgItem(hwnd, IDOK), isAcceptableLengthPIN2(hwnd, IDC_PIN2, minPin2Length));
			}
			return true;
		case WM_CTLCOLORSTATIC:			
			if(GetDlgItem(hwnd, IDC_ERROR) == ((HWND)lParam)){
				return SetMessageLabelColorToRed(wParam);
			}			
		default:
			return false;
	}	
}
static void SetShort(ControlHandle Hdl, short Value)
{
	NumToString(Value,ptemporary);
	SetDialogItemText((Handle)Hdl, ptemporary);
}
static void SetFloat(ControlHandle Hdl, float Value)
{
	psprintf(ptemporary, "%f",Value);
	SetDialogItemText((Handle)Hdl, ptemporary);
}
Ejemplo n.º 16
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);
}
Ejemplo n.º 17
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);
}
Ejemplo n.º 18
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;
	}
}
Ejemplo n.º 19
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);
}