Пример #1
0
Int DialogChooseTwo( CharPtr fText, CharPtr bOne, CharPtr bTwo ) {
    FormPtr prevForm, frm;
    Word hitButton;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmChooseTwo );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Fill it...
    CtlSetLabel( GetObjectPtr(btnChooseTwo1), bOne );
    CtlSetLabel( GetObjectPtr(btnChooseTwo2), bTwo );
    SetFieldTextFromStr( fldChooseTwo, fText );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    if( hitButton == btnChooseTwo1 ) return 1;
    if( hitButton == btnChooseTwo2 ) return 2;
    return ( -1 );
}
Пример #2
0
static Err ModImport(UInt16 volRefNum, UInt8 engine, Boolean *armP) {
#ifndef _DEBUG_ENGINE
	char filename[256];
	UInt16 cardNo;
	LocalID dbID;
	UInt32 result;
	FileRef file;
#endif
	char msg[256];
	FormPtr ofmP, frmP;
	Err e = errNone;

	ofmP = FrmGetActiveForm();
	frmP = FrmInitForm(ImportForm);
	FrmSetActiveForm(frmP);
	FrmDrawForm(frmP);

	// In debug mode, the engine files are directly uploaded to the simulator
#ifndef _DEBUG_ENGINE
	// engine file ?
	BUILD_FILE(engines[engine].fileP, ".engine");
	CHECK_FILE("ScummVM engine file was not found !");
	IMPRT_FILE("Cannot import engine file !");

	// need more files ?
	dbID = DmFindDatabase(0, "ScummVM-Engine");	// be sure to have the correct dbID
	e = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCustomEngineGetInfo, 0, &result);
	*armP = ((result & GET_MODEARM) == GET_MODEARM);

	// common file ?
	if (!e && (result & GET_DATACOMMON)) {
		BUILD_FILE("common", ".data");
		CHECK_FILE("Common data file was not found !");
		IMPRT_FILE("Cannot import common data file !");
	}
	// data file ?
	if (!e && (result & GET_DATAENGINE)) {
		BUILD_FILE(engines[engine].fileP, ".data");
		CHECK_FILE("Engine data file was not found !");
		IMPRT_FILE("Cannot import engine data file !");
	}
#endif
	// if error, cleanup
	if (e) ModDelete();

onError:
	FrmEraseForm(frmP);
	FrmDeleteForm(frmP);
	if (e) {
		if (ofmP) FrmSetActiveForm(ofmP);
		FrmCustomAlert(FrmErrorAlert, msg, 0, 0);
	}

	return e;
}
Пример #3
0
// Return the id of the button pressed.
static UInt16 display_modal_form(FormPtr form) {
  FormPtr prev_form = FrmGetActiveForm();
  UInt16 button_id;

  FrmSetActiveForm(form);
  
  // We do not need an eventhandler
  button_id = FrmDoDialog(form);
  
  // We do not read any values from the form.
  if (prev_form)
    FrmSetActiveForm(prev_form);
  FrmDeleteForm(form);
  
  return button_id;
}
Пример #4
0
static Boolean AppHandleEvent(EventPtr event)
{
    FormPtr frm;
    Int32 formId;
    Boolean handled;

    handled = false;

    if (event->eType == frmLoadEvent)
    {
	formId = event->data.frmLoad.formID;
	frm = FrmInitForm(formId);
	FrmSetActiveForm(frm);
	switch (formId)
	{
	case FlopForm:
	    FrmSetEventHandler(frm, FlopFormHandleEvent);
	    handled = true;
	    break;
				
	default:
	    break;
	}
    }

    return handled;
}
Пример #5
0
static Boolean ApplicationHandleEvent( EventPtr event )
{
	FormPtr frm;
	FieldPtr fld;
	FieldAttrType fldattr;
	Int formId;
	Boolean handled = false;

	if( event->eType == frmLoadEvent ) {
		formId = event->data.frmLoad.formID;
		frm = FrmInitForm( formId );
		FrmSetActiveForm( frm );

		switch( formId ) {
			case mainFormID:
				FrmSetEventHandler( frm, MyMainFormHandleEvent );

				fld = FrmGetObjectPtr( frm, FrmGetObjectIndex( frm,
					dataFieldID ) );
				FldGetAttributes( fld, &fldattr );
				fldattr.hasScrollBar=true;
				FldSetAttributes( fld, &fldattr );

				break;
			default:
				break;
		}

		handled = true;
	}

	return handled;
}
Пример #6
0
/*********************************************************************
 * Function: ApplicationHandleEvent
 * Description: this is the event handler that we use to 
 * set up forms on frmLoadEvents. It sets the event handlers
 * for every other non modal form in the program
 * *******************************************************************/ 
static Boolean 
ApplicationHandleEvent (EventType *event) 
{
	FormType *frm;
	Int16 formId;
	Boolean handled = false;
	if (event->eType == frmLoadEvent)
		
	{
		
			// load and activate the requested form
			formId = event->data.frmLoad.formID;
		frm = FrmInitForm (formId);
		FrmSetActiveForm (frm);
		
			// set an event handler
			switch (formId)
			
		{
			case PasswordForm:
				FrmSetEventHandler (frm, PasswordHandleEvent);
				break;
		}
		handled = true;
	}
	return handled;
}
Пример #7
0
Файл: gmi.c Проект: miellaby/v4p
Boolean Application_EventHandler(EventPtr event)
{
    FormPtr frm;
    int     formId;
    Boolean handled = false;

    switch (event->eType) {
       case frmLoadEvent : 
       {
           formId = event->data.frmLoad.formID;
           frm = FrmInitForm(formId);
           FrmSetActiveForm(frm);
                         
           switch(formId) {
                        
               case _GmF:
                   FrmSetEventHandler(frm, GmF_EventHandler);
                   break;
                
           }
           handled = true;
       }
       case menuEvent : 
       {
            switch (event->data.menu.itemID) {
            }
            handled = true;
       }
       default:
           break;
    }
    return handled;
}
/***********************************************************************
 *
 * FUNCTION:    AppHandleEvent
 *
 * DESCRIPTION: This routine loads form resources and set the event
 *              handler for the form loaded.
 *
 * PARAMETERS:  event  - a pointer to an EventType structure
 *
 * RETURNED:    true if the event has handle and should not be passed
 *              to a higher level handler.
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static Boolean AppHandleEvent(EventPtr eventP)
{
	UInt16 formId;
	FormPtr frmP;

	if (eventP->eType == frmLoadEvent)
		{
		// Load the form resource.
		formId = eventP->data.frmLoad.formID;
		frmP = FrmInitForm(formId);
		FrmSetActiveForm(frmP);

		// Set the event handler for the form.  The handler of the currently
		// active form is called by FrmHandleEvent each time is receives an
		// event.
		switch (formId)
			{
			case MainForm:
				FrmSetEventHandler(frmP, MainFormHandleEvent);
				break;

			default:
//				ErrFatalDisplay("Invalid Form Load Event");
				break;

			}
		return true;
		}
	
	return false;
}
Пример #9
0
static Boolean AppHandleEvent(EventPtr eventP) {
	Boolean handled = false;
	FormType *frmP;
	
	if (eventP->eType == frmLoadEvent) { /* Initialize and activate the form resource. */
		frmP = FrmInitForm(eventP->data.frmLoad.formID);

		FrmSetActiveForm(frmP);
		
		if (eventP->data.frmLoad.formID == MainForm) {
			dynInputOnMainFormLoad(frmP);
			FrmSetEventHandler(frmP, MainFormHandleEvent);
		}
		handled = true;
	} else if (eventP->eType == frmOpenEvent) { /* Load the form resource. */
		frmP = FrmGetActiveForm();
		FrmDrawForm(frmP);
		handled = true;
	} else if (eventP->eType == appStopEvent) { /* Unload the form resource. */
		frmP = FrmGetActiveForm();
		FrmEraseForm(frmP);
		FrmDeleteForm(frmP);
		handled = true;
	}
	
	return(handled);
}
Пример #10
0
static Boolean
ApplicationHandleEvent (EventPtr event)
{
    Word formId;
    FormPtr frm;

    if (event->eType == frmLoadEvent)
    {
        // Load the form resource.
        formId = event->data.frmLoad.formID;
        frm = FrmInitForm (formId);
        if (frm)
        {
            switch (formId) {
            case mainForm:
                mainFrm = frm;
                FrmSetEventHandler (frm, MainFormHandleEvent);
                break;
            }
            FrmSetActiveForm (frm);
        }
        // Set the event handler for the form.  The handler of the currently
        // active form is called by FrmHandleEvent each time is receives an
        // event.
        return (true);
    }
    return (false);
}
Пример #11
0
/* how to exit a popup form that you can enter from more than one place */
void LeaveForm()
{
   FormPtr frm;
   frm = FrmGetActiveForm();
   FrmEraseForm (frm);
   FrmDeleteForm (frm);
   FrmSetActiveForm (FrmGetFirstForm ());
}
Пример #12
0
bool wxTopLevelWindowPalm::Create(wxWindow *parent,
                                  wxWindowID id,
                                  const wxString& title,
                                  const wxPoint& pos,
                                  const wxSize& size,
                                  long style,
                                  const wxString& name)
{
    // this is a check for limitation mentioned before FrameFormHandleEvent() code
    if(wxTopLevelWindows.GetCount()>0)
        return false;

    ActiveParentFrame=NULL;

    wxTopLevelWindows.Append(this);

    if ( parent )
        parent->AddChild(this);

    SetId( id == wxID_ANY ? NewControlId() : id );

    WinConstraintsType constraints;
    memset(&constraints, 0, sizeof(WinConstraintsType));
    // position
    constraints.x_pos = ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x;
    constraints.y_pos = ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y;
    // size
    constraints.x_min = winUndefConstraint;
    constraints.x_max = winMaxConstraint;
    constraints.x_pref = ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x;
    constraints.y_min = winUndefConstraint;
    constraints.y_max = winMaxConstraint;
    constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y;

    FrameForm = FrmNewFormWithConstraints(
                    GetId(),
                    title.c_str(),
                    winFlagBackBuffer,
                    &constraints,
                    0,
                    NULL,
                    0,
                    NULL,
                    0
                );

    if(FrameForm==NULL)
        return false;

    FrmSetEventHandler(FrameForm,FrameFormHandleEvent);

    FrmSetActiveForm(FrameForm);

    ActiveParentFrame=this;

    return true;
}
Пример #13
0
static Boolean AppHandleEvent(EventPtr event){
  FormPtr pfrm;
  Boolean handled = false;
  switch (event->eType){
    case frmLoadEvent:
      prevFormId = formId;
      formId = event->data.frmLoad.formID;
      pfrm = FrmInitForm(formId);
      FrmSetActiveForm(pfrm);
      switch (formId){
       case GraffitiForm:
          FrmSetEventHandler(pfrm, GraffitiFormHandleEvent);
          handled = true;
          break;
        case HelpForm:
          offset = 0;
          FrmSetEventHandler(pfrm, HelpFormHandleEvent);
          handled = true;
          break;
        case WinForm:
          FrmSetEventHandler(pfrm, WinFormHandleEvent);
          handled = true;
          break;
        case GraffitiHelpForm:
          FrmSetEventHandler(pfrm, GraffitiHelpFormHandleEvent);
          handled = true;
          break;
        default:
          break;
      }
      break;
    case menuEvent:
      MenuEraseStatus(NULL);
      switch (event->data.menu.itemID) {
        case MainMenuGraffitiHelpCmd:
          FrmGotoForm(GraffitiHelpForm);
          handled = true;
          break;
         case MainMenuRestartCmd:
          FrmGotoForm(HelpForm);
          handled = true;
          break;
        default:
          break;
      }
      break;
    case keyDownEvent:
      if (event->data.keyDown.chr == vchrHardPower){
        FrmGotoForm(HelpForm);
      }
      break;
    default:
      break;
  }
  return handled;
}
Пример #14
0
DieType DialogChooseThree( Char* fText, DieType c1, DieType c2, DieType c3 )
{

    FormPtr prevForm, frm;
    UInt16 hitButton;

    if( IsAI( GetCurrPlayer() ) ) {
        return AIChooseThree( c1, c2, c3 );
    }

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmChooseThree );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Fill it...
    CtlSetLabel( GetObjectPtr(btnChooseThree1), val2name[c1] );
    CtlSetLabel( GetObjectPtr(btnChooseThree2), val2name[c2] );
    CtlSetLabel( GetObjectPtr(btnChooseThree3), val2name[c3] );
    SetFieldTextFromStr( fldChooseThree, fText );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    if( hitButton == btnChooseThree1 ) return c1;
    if( hitButton == btnChooseThree2 ) return c2;
    if( hitButton == btnChooseThree3 ) return c3;
    return c1;
}
Пример #15
0
void DialogPreferences() {
    FormPtr prevForm, frm;
    UInt16 hitButton;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmPreferences);

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);

    // Set Controls
    CtlSetValue( GetObjectPtr(check_NextPlayerPopUp ),
                 GetFlag(flag_NextPlayerPopUp) );

    CtlSetValue( GetObjectPtr(check_ForceSoundOff ),
                 GetFlag(flag_NoSound) );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Get Controls
    SetFlag( flag_NextPlayerPopUp,
             CtlGetValue( GetObjectPtr(check_NextPlayerPopUp) ) );
    SetFlag( flag_NoSound,
             CtlGetValue( GetObjectPtr(check_ForceSoundOff) ) );

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    // We don't care, as long as the dialog quits.
}
Пример #16
0
Err MainFormLoad(AppContext* appContext)
{
    Err error=errNone;
    FormType* form=FrmInitForm(formDictMain);
    if (!form)
    {
        error=memErrNotEnoughSpace;
        goto OnError;
    }
    FrmSetActiveForm(form);
    error=DefaultFormInit(appContext, form);
    if (!error)
    {
        FrmSetActiveForm(form);
        FrmSetEventHandler(form, MainFormHandleEvent);
    }
    else 
        FrmDeleteForm(form);
OnError:
    return error;    
}
Пример #17
0
static Err FlickrGetUserCredentials(FlickrPrefs& prefs)
{
    Err err = errNone;
    FormType* form = NULL;
    bool formStateSaved = false;

    FormActiveStateType activeState;
    FrmSaveActiveState(&activeState);
    formStateSaved = true;

    MenuEraseStatus(NULL);
    form = FrmInitForm(userCredentialsForm);
    if (NULL == form)
    {
        DMSG("FlickrGetUserCredentials(): unable to initialize form");DENDL;
        err = exgMemError;
        goto Finish;
    }

    err = UserCredentialsFormInit(form, prefs);
    if (errNone != err)
        goto Finish;

    FrmSetActiveForm(form);
    FrmDrawForm(form);

    UInt16 button = FrmDoDialog(form);
    switch (button)
    {
        case cancelButton:
            err = exgErrUserCancel;
            goto Finish;

        case okButton:
            UserCredentialsFormValidate(form, prefs);
            break;

        default:
            assert(false);
    }

    FlickrSavePrefs(prefs);

Finish:
    if (NULL != form)
        FrmDeleteForm(form);

    if (formStateSaved)
        FrmRestoreActiveState(&activeState);

    return err;
}
Пример #18
0
Word ChooseReader( Word itemNum )
{
	FormPtr prevFrm = FrmGetActiveForm();
	FormPtr frm = FrmInitForm( readerFormID );
	ListPtr lst = FrmGetObjectPtr( frm, FrmGetObjectIndex( frm,
		readerListID ) );
	Word hitButton;
	Word newSel;

	FrmSetActiveForm( frm );

	LstSetSelection( lst, itemNum );

	hitButton = FrmDoDialog( frm );

	newSel = LstGetSelection( lst );
	if( newSel==noListSelection ) newSel=-1;

	if( prevFrm ) FrmSetActiveForm( prevFrm );
	FrmDeleteForm( frm );

	if( hitButton==readerOkButtonID ) return( newSel );
	else return( itemNum );
}
Пример #19
0
Boolean DoRenameFigure(void)
{
    FormPtr prevFrm = FrmGetActiveForm();
    int numFigures = TFigurerecordGetCount();
    if ((currentFigure != noListSelection) && (currentFigure < numFigures)) {
	TFigure_type *t1 = TFigurerecordGet(currentFigure);
	if (t1) {
	    FormPtr frm = FrmInitForm(formRenameFigure);
	    FieldPtr field = (FieldPtr) FrmGetObjectPtr(frm,
							FrmGetObjectIndex
							(frm,
							 fieldFigureName));
	    MemHandle oldhText=FldGetTextHandle(field);
	    MemHandle hText = MemHandleNew(DESCSIZE);
	    char *titleptr = (char *) MemHandleLock(hText);
	    StrNCopy(titleptr, t1->name, DESCSIZE);
	    titleptr[DESCSIZE - 1] = 0;

	    MemPtrUnlock(titleptr);
	    FldSetTextHandle(field, (MemHandle) hText);
	    if (oldhText!=NULL) {
	      MemHandleFree(oldhText);
	    }

	    if (FrmDoDialog(frm) == buttonRFOK) {
		hText = FldGetTextHandle(field);
		titleptr = (char *) MemHandleLock(hText);
		if ((titleptr) && StrLen(titleptr) > 0) {

		    StrNCopy(t1->name, titleptr, DESCSIZE);
		    t1->name[DESCSIZE - 1] = 0;
		    TFigurerecordChange(currentFigure, t1);
		}
		MemPtrUnlock(titleptr);
	    }

	    TFigureFree(t1);
	    if (prevFrm)
		FrmSetActiveForm(prevFrm);
	    FrmDeleteForm(frm);
	}
	return true;
    }

    return false;
}
Пример #20
0
Err FlickrShowUploadCompleted(FlickrSocketContext& context)
{
    if (NULL != context.progress)
    {
        PrgStopDialog(context.progress, false);
        context.progress = NULL;
    }
    Err err = errNone;
    FormType* form = NULL;
    bool formStateSaved = false;
    FormActiveStateType activeState;
    FrmSaveActiveState(&activeState);
    formStateSaved = true;

    MenuEraseStatus(NULL);
    form = FrmInitForm(uploadCompletedForm);
    if (NULL == form)
    {
        err = exgMemError;
        goto Finish;
    }

    FrmSetActiveForm(form);
    FrmDrawForm(form);

    FrmDoDialog(form);

    ControlType* control = (ControlType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, dontShowUploadCompletedFormCheckbox));
    if (NULL != control)
    {
        Int16 val = CtlGetValue(control);
        if (0 != val)
            err = FlickrDisableUploadCompletedForm();
    }


Finish:
    if (NULL != form)
        FrmDeleteForm(form);

    if (formStateSaved)
        FrmRestoreActiveState(&activeState);

    return err;
}
Пример #21
0
UInt16 DisplayDialog( UInt16 formID, FormEventHandlerPtr handler ) 
{ 
	FormPtr active = FrmGetActiveForm();
    
	UInt16 activeID = ( active != NULL ) ? FrmGetFormId( active ) : 0;
	FormPtr dialog = FrmInitForm( formID );
	UInt16 buttonPressed = 0;
    
	FrmSetActiveForm( dialog ); 
	if( handler ){ 
		FrmSetEventHandler( dialog, handler ); 
	} 
	FrmPopupForm( formID ); 
	buttonPressed = FrmDoDialog( dialog ); 
	FrmReturnToForm( activeID );
    
	return buttonPressed;
} 
Пример #22
0
static Boolean ApplicationHandleEvent(EventPtr e)
{
        FormPtr frm;
        UInt16	formId;
        Boolean handled = false;

        if (e->eType == frmLoadEvent) {
                formId = e->data.frmLoad.formID;
                frm = FrmInitForm(formId);
                FrmSetActiveForm(frm);

                switch(formId) {
                case MainForm:
                        FrmSetEventHandler(frm, MainFormHandleEvent);
                        break;
                }
                handled = true;
        }

        return handled;
}
Пример #23
0
/* This routine handles the loading of forms */
static void HandleFormLoad
    (
    EventType* event
    )
{
    FormType*  form;
    UInt16     formID;

    formID  = event->data.frmLoad.formID;
    form    = FrmInitForm( formID );
    FrmSetActiveForm( form );

    switch( formID ) {
        case frmMain:
            FrmSetEventHandler( form, FormHandleEvent );
            break;

        default:
            ErrFatalDisplay( "Unknown form ID" );
            break;
    }
}
Пример #24
0
static void
EventLoop (void)
{
    short err;
    int fid;
    FormPtr form;
    EventType event;

    do
    {
	EvtGetEvent(&event, 200);

	// let the system handle it's own events
	if (SysHandleEvent(&event)) continue;

	// same for menu events
	if (MenuHandleEvent((void *)0, &event, &err)) continue;

	// set up our handler when our main form is loaded
	if (event.eType == frmLoadEvent) {
	    fid = event.data.frmLoad.formID;
	    form = FrmInitForm(fid);
	    FrmSetActiveForm(form);

	    switch (fid) {
	    case fid_kartrando:
		FrmSetEventHandler(form, mainEventHandler);
		break;
	    case fid_prefs:
		FrmSetEventHandler(form, prefsEventHandler);
		break;
	    }
	}

	FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);
}
Пример #25
0
static Boolean AppHandleEvent(EventType *eventP)
{
    UInt16 formId;
    FormType *frmP;

    if (eventP->eType == frmLoadEvent) {
        /* Load the form resource. */
        formId = eventP->data.frmLoad.formID;
        frmP = FrmInitForm(formId);
        FrmSetActiveForm(frmP);

        /* 
         * Set the event handler for the form.  The handler of the
         * currently active form is called by FrmHandleEvent each
         * time is receives an event. 
         */
        switch (formId) {
            case kMainForm:
                FrmSetEventHandler(frmP, MainFormHandleEvent);
                FrmSetGadgetHandler(frmP, FrmGetObjectIndex(frmP, kTabGadget), TabGadgetHandler);
                break;
            case kURLForm:
                FrmSetEventHandler(frmP, URLFormHandleEvent);
                break;
            case kPrivacyForm:
                FrmSetEventHandler(frmP, PrivacyFormHandleEvent);
                break;
            case kPrefsForm:
                FrmSetEventHandler(frmP, PrefsFormHandleEvent);
                FrmSetGadgetHandler(frmP, FrmGetObjectIndex(frmP, kPrefsTabGadget), TabGadgetHandler);
                break;
        }
        return true;
    }

    return false;
}
Пример #26
0
int event_loop(void) {
  UInt16 error;
  EventType event;
  FormPtr form;
  int form_id;
  Regiondesc rd;

  do {
    EvtGetEvent(&event, 0); // No timeout - return immediately
    if (!SysHandleEvent(&event))
      if (!MenuHandleEvent(NULL, &event, &error))
	if (event.eType == frmLoadEvent) {
	  // Load and activate form.
	  form_id = event.data.frmLoad.formID;
	  form = FrmInitForm(form_id);
	  FrmSetActiveForm(form);
	  switch (form_id) {
	  case formID_main_ri_sim: FrmSetEventHandler(form, (FormEventHandlerPtr) ri_sim_event); break;
	  case formID_sys_info: FrmSetEventHandler(form, (FormEventHandlerPtr) sys_info_event); break;
	  }
	} else
	    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Пример #27
0
/***********************************************************************
 *
 * FUNCTION:    SelectTime
 *
 * DESCRIPTION: Display a form showing a start and end time.
 *					 Allow the user to change the time and then
 *              return them.
 *					 pTimeDiff.
 *
 * PARAMETERS:  pStartTime	- pointer to TimeType
 *              pEndTime   - pointer to TimeType
 *              untimed  	- true if there isn't a time.
 *              title	   - string containing the title
 *              startOfDay - used when "All Day" button selected.
 *					 endOfDay	- our used when "All Day" button selected.
 *              startOfDisplay - first hour initially visible
 *
 * RETURNED:	 True if the time was changed by the user.
 * 				 The first three parameters may change.
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			roger	12/2/94	Initial Revision
 *			trev	08/12/97	made non modified passed variables constant
 *			css	06/08/99	added new parameter & "All Day" button for gromit change.
 *
 ***********************************************************************/
Boolean SelectTime (TimeType * startTimeP, TimeType * endTimeP, 
	Boolean untimed, const Char * titleP, Int16 startOfDay, Int16 endOfDay, 
	Int16 startOfDisplay)
{
	Int16							firstHour;
	Char 							startTimeText [timeStringLength];
	Char 							endTimeText [timeStringLength];
	Char							timeChars [timeStringLength];
	TimePtr						timeP;
	FormType 					*originalForm, *frm;
	ListPtr 						hoursLst, minutesLst;
	ControlPtr 					startTimeCtl, endTimeCtl;
	EventType 					event;
	Boolean 						confirmed = false;
	MemHandle 						hoursItems;
	TimeType 					startTime, endTime, timeDiff;
	TimeFormatType 			timeFormat;
	ChangingTimeType			changingTime;

	// Get the time format from the system preerances;
	timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat);


	// Because this routine only deals with minutes in five minute
	// intervals we convert the proposed times from those passed.
	startTime.hours = startTimeP->hours;
	startTime.minutes = startTimeP->minutes;
	endTime.hours = endTimeP->hours;
	endTime.minutes = endTimeP->minutes;
	TimeDifference (&endTime, &startTime, &timeDiff);
	
	// Make sure the end time is displayable (clips at 11:55 pm)
	AdjustTimes (&startTime, &endTime, &timeDiff, changingStartTime);
	
	// Clear the buffer that holds written characters.
	*timeChars = 0;

	startOfDisplay = min (startOfDisplay, 12);

	originalForm = FrmGetActiveForm();
	frm = (FormType *) FrmInitForm (TimeSelectorForm);
	FrmSetActiveForm (frm);

	hoursLst = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorHourList));
	minutesLst = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorMinuteList));
	startTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorStartTimeButton));
	endTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorEndTimeButton));


	// Set list to use either 12 or 24 hour time
	hoursItems = SysFormPointerArrayToStrings (
		((timeFormat == tfColon24h) || (timeFormat == tfDot24h)) ? 
			(Char *) Hours24Array() : (Char *) Hours12Array(), 24);
 
 	LstSetListChoices (hoursLst, MemHandleLock(hoursItems), 24);
	LstSetTopItem (hoursLst, startOfDisplay);
	//	Used to do LstMakeItemVisible (hoursLst, startTime.hours); no longer.


	if (! untimed)
		{
		LstSetSelection (hoursLst, startTime.hours);
		LstSetSelection (minutesLst, startTime.minutes / 5);

		CtlSetValue (startTimeCtl, true);
		changingTime = changingStartTime;
		}
	else
		{
		// The hour list is dynamically created and doesn't have a selection
		LstSetSelection (minutesLst, noListSelection);

		changingTime = changingNoTime;
		}


	// Set the start and end time buttons to the current times or blank them
	// if No Time is selected.
	SetTimeTriggers (startTime, endTime, startTimeText, endTimeText, 
		timeFormat, untimed);
		

	// This needs to be taken out when SelectTimeV33 goes away.  It allows for backward 
	// compatibility for this change of adding the end of day variable as a parameter.
	if (endOfDay != noDisplayOfAllDay)
	{
	  FrmShowObject (frm, FrmGetObjectIndex (frm, TimeSelectorAllDayButton));
	}
	
	FrmSetTitle (frm, (Char *) titleP);
	FrmDrawForm (frm);
	
	
	while (true)
		{
		EvtGetEvent (&event, evtWaitForever);

		if (SysHandleEvent ((EventType *)&event))
			continue;
			
		if (event.eType == appStopEvent)
			{
			// Cancel the dialog and repost this event for the app
			EvtAddEventToQueue(&event);
			confirmed = false;
			break;
			}
			
		// Handle these before the form does to overide the default behavior
		if (changingTime == changingNoTime &&
			event.eType == lstEnterEvent && 
			event.data.lstEnter.listID == TimeSelectorMinuteList)
			{
			SndPlaySystemSound(sndError);
			continue;
			}

		FrmHandleEvent (frm, &event);


		// If the start or end time buttons are pressed then change
		// the time displayed in the lists.
		if (event.eType == ctlSelectEvent)
			{
			// "Ok" button pressed?
			if (event.data.ctlSelect.controlID == TimeSelectorOKButton)
				{
				confirmed = true;
				}

			// "Cancel" button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorCancelButton)
				{
				break;
				}

			// Start time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorStartTimeButton)
				{
				if (changingTime != changingStartTime)
					{
					if (changingTime == changingNoTime)
						{
						SetTimeTriggers (startTime, endTime, startTimeText, 
							endTimeText, timeFormat, false);
						}

					CtlSetValue (endTimeCtl, false);
					LstSetSelection (hoursLst, startTime.hours);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					changingTime = changingStartTime;
					}
				else
					CtlSetValue(startTimeCtl, true);
				}

			// End time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorEndTimeButton)
				{
				if (changingTime != changingEndTime)
					{
					if (changingTime == changingNoTime)
						{
						SetTimeTriggers (startTime, endTime, startTimeText, 
							endTimeText, timeFormat, false);
						}

					CtlSetValue(startTimeCtl, false);
					LstSetSelection (hoursLst, endTime.hours);
					LstSetSelection (minutesLst, endTime.minutes / 5);
					changingTime = changingEndTime;
					}
				else
					CtlSetValue(endTimeCtl, true);
				}

			// No time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorNoTimeButton)
				{
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue(startTimeCtl, false);
					else
						CtlSetValue(endTimeCtl, false);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
					// Get us out of this form display now.
					confirmed = true;
				}

			// All day button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorAllDayButton)
				{
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue(startTimeCtl, false);
					else
						CtlSetValue(endTimeCtl, false);
					
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
											
					// No matter what, the minutes are 0 for both because only the hour is registered for start/end
					// times.
					startTime.minutes = 0;
					endTime.minutes 	= 0;
					startTime.hours 	= startOfDay;
					endTime.hours 		= endOfDay;
					
					// Set the times to the new times.
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					// Get us out of this form display now.  First set the changing time to anything but the changingNoTime value
					// so that the pointers at the end of this function get set correctly.
					changingTime = changingStartTime;
					confirmed = true;
				}

			// Clear the buffer that holds written characters.
			*timeChars = 0;
			}


		// If either list is changed then get the new time.  If the
		// start time is changed then change the end time so that the
		// the time difference remains the same.  If the end time is
		// changed then make sure the end time isn't before the start
		// time.  Also calculate a new time difference.
		else if (event.eType == lstSelectEvent)
			{
         // First, get the info from the list which has changed.
			if (event.data.lstSelect.listID == TimeSelectorHourList)
				{
				if (changingTime == changingStartTime)
               startTime.hours = (UInt8) LstGetSelection (hoursLst);
           	else if (changingTime == changingEndTime)
               endTime.hours = (UInt8) LstGetSelection (hoursLst);
           	else if (changingTime == changingNoTime)
           		{
               startTime.hours = (UInt8) LstGetSelection (hoursLst);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, false);
					CtlSetValue (endTimeCtl, false);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					changingTime = changingStartTime;
					}
				}
         else if (event.data.lstSelect.listID == TimeSelectorMinuteList)
				{
				if (changingTime == changingStartTime)
               startTime.minutes = (UInt8) LstGetSelection (minutesLst) * 5;
           	else if (changingTime == changingEndTime)
					endTime.minutes = (UInt8) LstGetSelection (minutesLst) * 5;
           	else if (changingTime == changingNoTime)
           		{
               ErrNonFatalDisplay("lstEnterEvent not being filtered.");
               }
				}


			if (AdjustTimes (&startTime, &endTime, &timeDiff, changingTime))
				{
				if (changingTime == changingStartTime)
					{
					TimeToAscii (startTime.hours, startTime.minutes, timeFormat, 
						startTimeText);
					CtlSetLabel (startTimeCtl, startTimeText);
					}
				else if (changingTime == changingEndTime)
					{
					LstSetSelection (hoursLst, startTime.hours);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					}
				}
			TimeToAscii(endTime.hours, endTime.minutes, timeFormat, endTimeText);
			CtlSetLabel(endTimeCtl, endTimeText);


			// Clear the buffer that holds written characters.
			*timeChars = 0;
			}


		// Handle character written in the time picker.
		else if (event.eType == keyDownEvent)
			{
			if (changingTime == changingEndTime)
				{
				timeP = &endTime;
				firstHour = startTime.hours;
				}
			else
				{
				timeP = &startTime;
				firstHour = startOfDisplay;
				}
		
			// If a backspace character was written, change the time picker's
			// current setting to "no-time".
			if (event.data.keyDown.chr == backspaceChr)
				{
				*timeChars = 0;
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue (startTimeCtl, false);
					else
						CtlSetValue (endTimeCtl, false);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
				}

			// A linefeed character confirms the dialog box.
			else if (event.data.keyDown.chr == linefeedChr)
				{
				confirmed = true;
				}

			// If next-field character toggle between start time in end
			// time.
			else if (event.data.keyDown.chr == nextFieldChr)
				{
				*timeChars = 0;
				if (changingTime == changingStartTime)
					{
					CtlSetValue (startTimeCtl, false);
					CtlSetValue (endTimeCtl, true);
					changingTime = changingEndTime;
					}
				else
					{
					CtlSetValue (endTimeCtl, false);
					CtlSetValue (startTimeCtl, true);
					changingTime = changingStartTime;
					}
				}


			// If a valid time character was written, translate the written 
			// character into a time and update the time picker's UI.
			else if (TranslateTime (timeFormat, event.data.keyDown.chr, 
				firstHour, timeChars, timeP))
				{
				if (changingTime == changingNoTime)
					{
					changingTime = changingStartTime;
					CtlSetValue (startTimeCtl, true);
					}

				AdjustTimes (&startTime, &endTime, &timeDiff, changingTime);
				
				SetTimeTriggers (startTime, endTime, startTimeText, 
					endTimeText, timeFormat, false);

				LstSetSelection (hoursLst, timeP->hours);
				LstSetSelection (minutesLst, timeP->minutes / 5);
				}
			}

		// Has the dialog been confirmed.
		if (confirmed)
			{
			if (changingTime != changingNoTime)
				{
				*startTimeP = startTime;
				*endTimeP = endTime;
				}
			else
				{
				TimeToInt(*startTimeP) = noTime;
				TimeToInt(*endTimeP) = noTime;
				}
			break;
			}

		}

	FrmEraseForm (frm);
	FrmDeleteForm (frm);
	MemHandleFree (hoursItems);
	
	FrmSetActiveForm(originalForm);
	
	return (confirmed);
	}
Пример #28
0
/***********************************************************************
 *
 * FUNCTION:    SelectOneTime
 *
 * DESCRIPTION: Display a form showing a time and allow the user
 *              to select a different time. This is the single time
 *					 dialog as seen in general panel
 *
 * PARAMETERS:  hour	- pointer to hour to change
 					 minute - pointer to minute to change
 *				title	- string title for the dialog
 *
 * RETURNED:	 true if the OK button was pressed
 *					 if true the parameters passed are changed
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			roger	12/2/94		Initial Revision in General Panel
 *			gavin	3/20/98		Extracted into separate system function
 *
 ***********************************************************************/
Boolean SelectOneTime(Int16 *hour,Int16 *minute, const Char * titleP)
{
	FormType * originalForm, * frm;
	EventType event;
	Boolean confirmed = false;
	Boolean handled = false;
	Boolean done = false;
	TimeFormatType timeFormat;			// Format to display time in
	Int16   curHour;
	UInt16	currentTimeButton;
	UInt8	hoursTimeButtonValue;
	Char	hoursTimeButtonString[3];
	UInt8	minuteTensButtonValue;
	Char	minuteTensButtonString[2];
	UInt8	minuteOnesButtonValue;
	Char	minuteOnesButtonString[2];
	Char	separatorString[3];

	timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat);

	originalForm = FrmGetActiveForm();
	frm = (FormType *) FrmInitForm (SelectOneTimeDialog); 
	if (titleP)
		FrmSetTitle (frm, (Char *) titleP);

	FrmSetActiveForm (frm);
	
	curHour = *hour;
	
	if (Use24HourFormat(timeFormat))
		{
		// Hide the AM & PM ui
		FrmHideObject (frm, FrmGetObjectIndex (frm, timeAMCheckbox));
		FrmHideObject (frm, FrmGetObjectIndex (frm, timePMCheckbox));
		}
	else 
		{
		if (curHour < 12)
			CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeAMCheckbox)), true);
		else
			{
			CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timePMCheckbox)), true);
			curHour -= 12;
			}
		
		if (curHour == 0)
			curHour = 12;
		}

	// Set the time seperator to the system defined one
	separatorString[0] = TimeSeparator(timeFormat);
	separatorString[1] = '\0';
	FrmCopyLabel(frm, timeSeparatorLabel, separatorString);


	// Now set the time displayed in the push buttons.
	hoursTimeButtonValue = curHour;
	StrIToA(hoursTimeButtonString, hoursTimeButtonValue);
	CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeHourButton)),
		hoursTimeButtonString);
		
	minuteTensButtonValue = *minute / 10;
	StrIToA(minuteTensButtonString, minuteTensButtonValue);
	CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesTensButton)),
		minuteTensButtonString);
		
	minuteOnesButtonValue = *minute % 10;
	StrIToA(minuteOnesButtonString, minuteOnesButtonValue);
	CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, timeMinutesOnesButton)),
		minuteOnesButtonString);


	// Set the hour time button to be the one set by the arrows
	currentTimeButton = defaultTimeButton;
	CtlSetValue(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, defaultTimeButton)), true);

	
	FrmDrawForm (frm);

	
	while (!done)
		{
		EvtGetEvent (&event, evtWaitForever);

		if (! SysHandleEvent ((EventType *)&event))	
			FrmHandleEvent (frm,&event); 

		if (event.eType == ctlSelectEvent)
			{
			switch (event.data.ctlSelect.controlID)
				{
				case timeOkButton:
					frm = FrmGetActiveForm();

					// Set the new time (seconds are cleared).
					if (Use24HourFormat(timeFormat))
						*hour = hoursTimeButtonValue;
					else
						{
						*hour = hoursTimeButtonValue % 12 + // 12am is 0 hours!
							(CtlGetValue(FrmGetObjectPtr (frm,
																	FrmGetObjectIndex (frm,
																					timePMCheckbox)))
							? 12 : 0);
						}

					*minute = minuteTensButtonValue * 10 + minuteOnesButtonValue;

					done = true;
					confirmed = true;
					break;

				case timeCancelButton:
					done = true;
					break;
					
				case timeDecreaseButton:
				case timeIncreaseButton:
					frm = FrmGetActiveForm();
					switch (currentTimeButton)
						{
						// MemHandle increasing and decreasing the time for each time digit
						case timeHourButton:
							if (event.data.ctlSelect.controlID == timeDecreaseButton)
								{
								if (Use24HourFormat(timeFormat))
									if (hoursTimeButtonValue > 0)
										hoursTimeButtonValue--;
									else
										hoursTimeButtonValue = 23;
								else
									if (hoursTimeButtonValue > 1)
										hoursTimeButtonValue--;
									else
										hoursTimeButtonValue = 12;
								}
							else
								{
								if (Use24HourFormat(timeFormat))
									if (hoursTimeButtonValue < 23)
										hoursTimeButtonValue++;
									else
										hoursTimeButtonValue = 0;
								else
									if (hoursTimeButtonValue < 12)
										hoursTimeButtonValue++;
									else
										hoursTimeButtonValue = 1;
								}
								
							StrIToA(hoursTimeButtonString, hoursTimeButtonValue);
							CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, 
								timeHourButton)),	hoursTimeButtonString);
							break;

						case timeMinutesTensButton:
							if (event.data.ctlSelect.controlID == timeDecreaseButton)
								{
								if (minuteTensButtonValue > 0)
									minuteTensButtonValue--;
								else
									minuteTensButtonValue = 5;
								}
							else
								{
								if (minuteTensButtonValue < 5)
									minuteTensButtonValue++;
								else
									minuteTensButtonValue = 0;
								}

							StrIToA(minuteTensButtonString, minuteTensButtonValue);
							CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, 
								timeMinutesTensButton)), minuteTensButtonString);
							break;
							
						case timeMinutesOnesButton:
							if (event.data.ctlSelect.controlID == timeDecreaseButton)
								{
								if (minuteOnesButtonValue > 0)
									minuteOnesButtonValue--;
								else
									minuteOnesButtonValue = 9;
								}
							else
								{
								if (minuteOnesButtonValue < 9)
									minuteOnesButtonValue++;
								else
									minuteOnesButtonValue = 0;
								}

							StrIToA(minuteOnesButtonString, minuteOnesButtonValue);
							CtlSetLabel(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, 
								timeMinutesOnesButton)), minuteOnesButtonString);
							break;
						}

					handled = true;
					break;	// timeDecreaseButton & timeIncreaseButton
		
				case timeHourButton:
					currentTimeButton = timeHourButton;
					break;
					
				case timeMinutesTensButton:
					currentTimeButton = timeMinutesTensButton;
					break;
					
				case timeMinutesOnesButton:
					currentTimeButton = timeMinutesOnesButton;
					break;
					
				}
			}

		else if (event.eType == appStopEvent)
			{
			EvtAddEventToQueue (&event);
			done = true;
			break;
			}
			
		}	// end while true
		
	FrmEraseForm (frm);
	FrmDeleteForm (frm);
	
	FrmSetActiveForm(originalForm);
	
	return (confirmed);
}
Пример #29
0
Boolean DialogGetNames() {
    FormPtr prevForm, frm;
    Word hitButton;
    Boolean retVal = false;
    CharPtr text;
    Int i;
    FieldPtr fp;
    VoidPtr vPtr;
    Word oIdx;

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmGetNames);

    // Set it
    FrmSetActiveForm(frm);

    // Set Controls
    for( i = stor.tmpplayers ; i<MaxPlayers ; i++ ) {
        fp = GetObjectPtr( fieldGetNamesPlayer[i] );
        FldSetUsable ( fp, false );
        FldEraseField( fp );
        ShowControl( fieldGetNamesLabel[i], 0 );
    }

    FrmDrawForm(frm);

    for( i=0; i < stor.tmpplayers ; i++ ) {
        SetFieldTextFromStr( fieldGetNamesPlayer[i], stor.player[i].name );
    }
    FrmSetFocus( frm, FrmGetObjectIndex(frm, fieldGetNamesPlayer[0]) );


    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Get Controls
    if ( hitButton == btn_OK_frmGetNames ) {

        for( i=0 ; i<stor.tmpplayers ; i++ ) {
            oIdx = FrmGetObjectIndex( frm, fieldGetNamesPlayer[i]);
            vPtr = FrmGetObjectPtr( frm, oIdx );
            text = FldGetTextPtr( vPtr );
            StrCopy( stor.player[i].name, text );

        }

        retVal = true;
    }


    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    return retVal;
}
Пример #30
0
void DialogOK ( Word frmname, Short p1, Short p2 ) {
    FormPtr prevForm, frm;
    Word hitButton;
    Char msg[(MaxName * 2) + 128];
    Word fieldname = 0;

    switch ( frmname ) {
    case frmNextPlayer:
        fieldname = fldNextPlayer;
        if( (stor.numplayers + stor.numcomputers) > 1 ) {
            StrPrintF( msg, NextPlayerString,
                       stor.player[p1].name,
                       stor.player[p2].name,
                       NULL);
        } else {
            StrPrintF( msg, "%s", NextSoloPlayerString, NULL );
        }
        break;

    case frmSuspend:
        if( (stor.numplayers + stor.numcomputers) == 1 ) {
            return;
        }
        fieldname = fldSuspend;
        StrPrintF( msg, SuspendString,
                   stor.player[p1].name,
                   stor.player[p2].name,
                   NULL);
        break;


    case frmLost:
        fieldname = fldLost;
        StrPrintF( msg, LostString, stor.player[p1].name, NULL );
        break;

    case frmLeader:
        fieldname = fldLeader;
        StrPrintF( msg, LeaderString, stor.player[p1].name, NULL );
        break;

    case frmWinner:
        fieldname = fldWinner;
        StrPrintF( msg, WinnerString, stor.player[p1].name, NULL );
        break;

    case frmNobodyWon:
        fieldname = fldNobodyWon;
        StrPrintF( msg, NobodyWonString, NULL );
        break;

    case frmBump:
        fieldname = fldBump;
        StrPrintF( msg, BumpString,
                   stor.player[p2].name,
                   stor.player[p1].name,
                   stor.player[p2].score,
                   stor.player[p1].score,
                   NULL );
        break;

    case frmSampler:
        fieldname = fldSampler;
        StrPrintF( msg, SamplerString, stor.player[p1].name, NULL );
        break;


    case frmTrainWreck:
        fieldname = fldTrainWreck;
        StrPrintF( msg, TrainWreckString,
                   stor.player[p1].name,
                   stor.player[p1].TWcount,
                   stor.nTrainWrecks,
                   NULL );
        break;

    default:
        ErrDisplay( "DialogOK: fall through: Programmer sucks." );
        return;
    }

    // Save previous form
    prevForm = FrmGetActiveForm();
    // Init new form
    frm = FrmInitForm( frmname );

    // Set it
    FrmSetActiveForm(frm);
    FrmDrawForm(frm);


    // Fill it...
    ErrFatalDisplayIf( fieldname == 0,
                       "DialogOK: ZeroField: Programmer sucks." );
    SetFieldTextFromStr( fieldname, msg );

    // Set the handler
    // FrmSetEventHandler(frm, DialogNewGameHandleEvent);

    hitButton = FrmDoDialog(frm);

    // Delete the form, we're not using it
    FrmDeleteForm(frm);

    // Restore previous form.
    if (prevForm) {
        FrmSetActiveForm(prevForm);
    }

    // We don't care about which button, there is only one.
}