static DialogRef DrawDialogTheSystem6or7Way(void) { DialogItemType itemType; Handle itemHandle; Rect itemBox; DialogRef theDialog = GetNewDialog(256, NULL, (WindowRef)-1L); if (theDialog == NULL) return(NULL); // Move it! MoveWindow(GetDialogWindow(theDialog), 10, 271, false); // Setting the check box GetDialogItem(theDialog, 2, &itemType, &itemHandle, &itemBox); SetControlValue((ControlHandle)itemHandle, 1); // Setting a radio button GetDialogItem(theDialog, 3, &itemType, &itemHandle, &itemBox); SetControlValue((ControlHandle)itemHandle, 1); // Setting the draw proc for the user item GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox); gUserH = (itemBox.left + itemBox.right) / 2; gUserV = (itemBox.top + itemBox.bottom) / 2; SetDialogItem(theDialog, 13, itemType, (Handle)&MyDrawUserItem, &itemBox); // Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work GetDialogItem(theDialog, 14, &itemType, &itemHandle, &itemBox); SetControlAction((ControlHandle)itemHandle, ScrollBarActionProc); ShowWindow(GetDialogWindow(theDialog)); return(theDialog); }
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); }
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); }
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; }
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; }
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(); //} } }
void AboutBox::DrawUserItem( const short item ) { short itemType; Handle itemHand; Rect itemBox; GetDialogItem( mDialogPtr, item, &itemType, &itemHand, &itemBox ); if (item == kUrlItem) { if (!mUrlPane) { mUrlPane = MakeURLPane(itemBox); } mUrlPane->Draw(); } else if (kVersionItem == item) { MoveTo(itemBox.left, itemBox.bottom - 3); TextFont(kFontIDGeneva); TextSize(9); DrawVersion(); } else { inherited::DrawUserItem(item); return; } }
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); } }
static pascal Boolean about_filter(DialogPtr dptr, EventRecord *theEvent, short *theItem){ if( theEvent->what == keyDown || theEvent->what == autoKey){ unsigned char theKey = (unsigned char)(theEvent->message & charCodeMask); if( theKey == 0x0D || (theKey == 0x03 && !(theEvent->modifiers & controlKey))){ short itemType; ControlHandle okHdl; Rect itemRect; #if UNIVERSAL_INTERFACES_VERSION >= 0x0301 unsigned long Ticks; #else long Ticks; #endif GetDialogItem( dptr, ok, &itemType, (Handle*) &okHdl, &itemRect); HiliteControl( okHdl, kControlButtonPart); #ifdef __cplusplus Delay( 3, &Ticks); #else Delay( 3, (void *)&Ticks); #endif HiliteControl( okHdl, 0); *theItem = ok; return true; } } return false; }
static void MyDrawUserItem(DialogRef theDialog, DialogItemIndex itemNo) { DialogItemType itemType; Handle itemHandle; Rect itemBox; GetDialogItem(theDialog, itemNo, &itemType, &itemHandle, &itemBox); CGrafPtr savePort; GetPort(&savePort); SetPortDialogPort(theDialog); PenState penState; GetPenState(&penState); PenSize(3, 3); if (itemType & itemDisable) { Pattern gray; PenPat(GetQDGlobalsGray(&gray)); } FrameRect(&itemBox); Rect userRect = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; PaintRect(&userRect); SetPenState(&penState); SetPort(savePort); }
/* GetDBox(theDialog, itemNumber, box) Thread Safety: GetDBox is not thread-safe. */ void GetDBox(DialogPtr theDialog, int itemNumber, Rect *box) { short type; Handle item; GetDialogItem(theDialog, itemNumber, &type, &item, box); }
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; }
static pascal void outline_hook(DialogRef dptr, short theItem){ short itemType; Handle itemHdl; Rect itemRect; PenState oldpen; GetDialogItem( dptr, theItem, &itemType, &itemHdl, &itemRect); GetPenState( &oldpen); PenSize( 3, 3); FrameRoundRect( &itemRect, 16, 16); SetPenState( &oldpen); }
/* Flash a dialog button when its accelerator key is pressed */ void FlashButton(DialogRef wind, short item) { short type; Handle handle; Rect rect; unsigned long ticks; /* Apple recommends 8 ticks */ GetDialogItem(wind, item, &type, &handle, &rect); HiliteControl((ControlHandle)handle, kControlButtonPart); Delay(8, &ticks); HiliteControl((ControlHandle)handle, 0); return; }
static void mac_activatekey(WindowPtr window, EventRecord *event) { DialogRef dialog; DialogItemType itemtype; Handle itemhandle; short item; Rect itemrect; int active; dialog = GetDialogFromWindow(window); active = (event->modifiers & activeFlag) != 0; GetDialogItem(dialog, wiKeyGenerate, &itemtype, &itemhandle, &itemrect); HiliteControl((ControlHandle)itemhandle, active ? 0 : 255); DialogSelect(event, &dialog, &item); }
/* 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); }
/**************************************************************** PopErase() erases the given popup and its shadow. ****************************************************************/ void PopErase(DialogPtr theDialog, short itemNum) { GrafPtr savePort; short itemType; Handle itemHandle; Rect itemBox; GetPortGrafPtr(&savePort); SetPortDialogPort(theDialog); GetDialogItem(theDialog, itemNum, &itemType, &itemHandle, &itemBox); itemBox.right++; itemBox.bottom++; EraseRect(&itemBox); SetPortGrafPort(savePort); }
/**************************************************************** UnRegisterPopUpDialog() is used when you have a popup that you want to turn off, not in the sense of being static but in the sense of not being there at all. You should erase the popup on the screen with PopErase, and then call this procedure to set the handle to nil (instead of PopDraw) so it won't get redrawn. ****************************************************************/ void UnRegisterPopUpDialog(long dialogID, DialogPtr theDialog) { #ifndef IBM short theType; Handle itemHandle; Rect itemBox; short i; #endif #ifdef IBM return; #else for ( i = 0 ; i < sa_numPopUps ; i++ ) if (sa_popTable[i].dialogID == dialogID) { GetDialogItem(theDialog, sa_popTable[i].popupItemNum, &theType, &itemHandle, &itemBox); SetDialogItem(theDialog, sa_popTable[i].popupItemNum, userItem, nil, &itemBox); } #endif }
void mac_newkey(void) { KeyState *ks; WinInfo *wi; Handle h; short type; Rect rect; ks = snew(KeyState); ks->box = GetNewDialog(wKey, NULL, (WindowPtr)-1); GetDialogItem(ks->box, wiKeyProgress, &type, &h, &rect); ks->progress = (ControlHandle)h; wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->ks = ks; wi->wtype = wKey; wi->update = &mac_updatekey; wi->click = &mac_clickkey; wi->activate = &mac_activatekey; SetWRefCon(GetDialogWindow(ks->box), (long)wi); ShowWindow(GetDialogWindow(ks->box)); }
void do_about_box( void) { GrafPtr oldPort; DialogPtr dptr; short item, itemType; Handle itemHdl; Rect itemRect; dptr = GetNewDialog( rAboutBox, nil, (WindowPtr)-1L); if( dptr == (DialogPtr)0){ Handle items = NewHandle( sizeof(missing_DITL)); static Rect bounds = {40, 20, 150, 340}; if( ! items) return; BlockMove( missing_DITL, *items, sizeof(missing_DITL)); dptr = NewColorDialog( nil, &bounds, (unsigned char*)"\005About", false, dBoxProc, (WindowPtr)-1L, false, 0, items); } if( dptr == (DialogPtr)0) return; GetPort (&oldPort); SetPort (GetDialogPort(dptr)); GetDialogItem( dptr, ok, &itemType, &itemHdl, &itemRect); InsetRect( &itemRect, -4, -4); SetDialogItem( dptr, 6, userItem + itemDisable, (Handle)outline_hook_upp, &itemRect); FlushEvents( everyEvent, 0); ShowWindow( GetDialogWindow(dptr)); do { ModalDialog( about_filter_upp, &item); } while( item != ok); DisposeDialog( dptr); SetPort( oldPort); }
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 */ } } }
/**************************************************************** RegisterPopUpDialog() is used to fill in the dialogPtr field of a PopTable entry and to set the user item procs of that dialog's popup items once you have loaded the dialog and have the dialog pointer. ****************************************************************/ void RegisterPopUpDialog(long dialogID, DialogPtr theDialog) { short i; #ifndef IBM short theType; Handle itemHandle; Rect itemBox; #endif for ( i = 0 ; i < sa_numPopUps ; i++ ) if (sa_popTable[i].dialogID == dialogID) { sa_popTable[i].dialogPtr = theDialog; #ifndef IBM GetDialogItem(theDialog, sa_popTable[i].popupItemNum, &theType, &itemHandle, &itemBox); SetDialogItem(theDialog, sa_popTable[i].popupItemNum, userItem, nil, &itemBox); SetDialogItemHandle(theDialog, sa_popTable[i].popupItemNum, (Handle)PopDraw); #else PopDraw(theDialog, sa_popTable[i].popupItemNum); LoadPopupMenu(theDialog, sa_popTable[i].menuID, sa_popTable[i].popupItemNum); #endif } }
/**************************************************************** PopInvert() inverts the given popup. ****************************************************************/ void PopInvert(DialogPtr theDialog, short itemNum) { GrafPtr savePort; short itemType; Handle itemHandle; Rect itemBox; //SysEnvRec theWorld; RGBColor SaveBack, DefaultBack, DefaultFore, saveHilite; GetPortGrafPtr(&savePort); SetPortDialogPort(theDialog); GetDialogItem(theDialog, itemNum, &itemType, &itemHandle, &itemBox); // SysEnvirons(curSysEnvVers,&theWorld); //if (!theWorld.hasColorQD) { if (ColorQDAvailable()) { InvertRect( &itemBox ); return; } GetBackColor(&SaveBack); LMGetHiliteRGB(&saveHilite); DefaultMenuColors(&DefaultFore, &DefaultBack); RGBBackColor(&DefaultBack); HiliteColor(&DefaultFore); LMSetHiliteMode(LMGetHiliteMode() & 0x7F); // clear 0th bit = pHiliteBit InvertRect( &itemBox ); HiliteColor(&saveHilite); RGBBackColor(&SaveBack); SetPortGrafPort(savePort); }
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); }
// 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; } }
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 int DoDialogItem(DialogPtr dlog, short itemHit) { short type,okay=FALSE,keepGoing=TRUE,val; Handle hndl; Rect box; Point pt; unsigned char *p,str[256]; if (itemHit<1 || itemHit>=LASTITEM) return(keepGoing); /* Only legal items, please */ GetDialogItem(dlog,itemHit,&type,&hndl,&box); switch(type) { case ctrlItem+btnCtrl: switch(itemHit) { case BUT1_OK: // the default is that we're done keepGoing = FALSE; okay = TRUE; // check to see if the name that has been entered can be resolved { extern InetSvcRef gInetService; Str255 theString; InetHostInfo theHost; short aShort; OSStatus err; GetDlgString(dlog, EDIT5, theString); // machine name ParamText(theString, "\p", "\p", "\p"); // show the name in the dialog p2cstr(theString); OTSetSynchronous(gInetService); err = OTInetStringToAddress(gInetService, theString, &theHost); OTSetAsynchronous(gInetService); if (err != noErr) { // the name cannot be looked up, ask the user if they want // to add the entry anyway aShort = CautionAlert(1501, nil); // returns 1 if OK to add if (aShort != 1) { keepGoing = TRUE; okay = FALSE; } } } break; case BUT2_Cancel: keepGoing = FALSE; break; } break; case ctrlItem+chkCtrl: break; case ctrlItem+radCtrl: break; case ctrlItem+resCtrl: break; case statText: switch(itemHit) { case STXT3_Host: /* NOT Enabled */ break; case STXT4_Notes: /* NOT Enabled */ break; case STXT7_Enter: /* NOT Enabled */ break; } break; case editText: switch(itemHit) { case EDIT5: break; case EDIT6: break; } break; case iconItem: break; case picItem: break; case userItem: break; } if (okay) keepGoing = AnyBadValues(dlog); return(keepGoing); }
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; }
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); }
static Boolean MySystem6or7DialogFilter(DialogRef theDialog, EventRecord *inEvent, DialogItemIndex *itemHit) { if ((inEvent->what == keyDown) || (inEvent->what == autoKey)) { char c = (inEvent->message & charCodeMask); // return or enter key? if ((c == kReturnCharCode) || (c == kEnterCharCode)) { *itemHit = 1; return true; } // tab key or arrow keys? if (c == kTabCharCode) return false; if (c == kLeftArrowCharCode) return false; if (c == kRightArrowCharCode) return false; if (c == kUpArrowCharCode) return false; if (c == kDownArrowCharCode) return false; // digits only for edittext box item #9 ? // pre-Carbon, this would have been: ((DialogPeek)theDialog)->editField+1 == 9 if (GetDialogKeyboardFocusItem(theDialog) == 9) { if ((c < '0') || (c > '9')) { SysBeep(1); return true; } } } // we got a click! if (inEvent->what == mouseDown) { DialogItemType itemType; Handle itemHandle; Rect itemBox; GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox); // is the user item enabled? if (!(itemType & itemDisable)) { CGrafPtr savePort; GetPort(&savePort); SetPortDialogPort(theDialog); Point thePoint = inEvent->where; GlobalToLocal(&thePoint); Boolean inside = PtInRect(thePoint, &itemBox); // is the click inside the user item? if (inside) { // let's constrain and move the spot! // it's possible to track the spot here but it's complex // so we just move on the click and don't track. // that's typical of dialog's user items of that era. Rect userRect1 = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; EraseRect(&userRect1); InvalWindowRect(GetDialogWindow(theDialog), &userRect1); gUserH = thePoint.h; gUserV = thePoint.v; if (gUserH < itemBox.left+4) gUserH = itemBox.left+4; if (gUserH > itemBox.right-4) gUserH = itemBox.right-4; if (gUserV < itemBox.top+4) gUserV = itemBox.top+4; if (gUserV > itemBox.bottom-4) gUserV = itemBox.bottom-4; Rect userRect2 = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; InvalWindowRect(GetDialogWindow(theDialog), &userRect2); } SetPort(savePort); } } return false; }