Exemple #1
0
void  ThermDialog::RemoveTherm(void)
{

    HideWindow(dp);
    DisposDialog (dp);
    HPurge ((Handle) dt);
    ReleaseResource((Handle)dt);

    SetPort(olddp);

}
Exemple #2
0
McoStatus ThermDialog::SetUpTherm(int therm_num)
{

    Rect 		r;
    Handle 		h;
    short 		itemType;
    short 		wi,hi;
    short		ids1[] = THERM_IDs_1;
    short		ids2[] = THERM_IDs_2;
    int 		i;
    Str255		theString;

    Quit = FALSE;

    //if (therm_num == 3)
    for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids2[i];
    //else for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids1[i];

    GetPort(&olddp);

    dt = (DialogTHndl) GetResource ('DLOG',ids[THERM_DLG]);

    if (! dt) return(MCO_RSRC_ERROR);

    HNoPurge ((Handle) dt);

    r = (**dt).boundsRect;


#define menuHeight 20

    wi = qd.screenBits.bounds.right;
    hi = qd.screenBits.bounds.bottom;

    OffsetRect (&r, -r.left, -r.top);
    OffsetRect (&r, (wi - r.right) / 2,
                (hi - r.bottom - menuHeight) / 3 + menuHeight);
    (**dt).boundsRect = r;

#undef menuHeight


    dp = GetNewDialog (ids[THERM_DLG], nil, (WindowPtr) -1);



    if (! dp)
    {
        HPurge ((Handle) dt);
        return(MCO_RSRC_ERROR);
    }

    GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r);
    GetIndString(theString,THERM_MESS,therm_num);
    SetIText(h,theString);

    SetPort(dp);

    ShowWindow(dp);
    DrawDialog(dp);

    box_d_item(dp,ids[THERM_BOX]);
    return MCO_SUCCESS;
}
Exemple #3
0
Boolean DoUI (GPtr globals)
{		
	short item;
	Str255 hS = ""; //histstatus
	int16	currentResources = 0;

	DialogPtr dp;
	DialogTHndl dt;
	
	gStuff->theRect.top =
	gStuff->theRect.left =
	gStuff->theRect.bottom =
	gStuff->theRect.right = 0;
	
	dt = (DialogTHndl) GetResource ('DLOG', uiID);
	HNoPurge ((Handle) dt);
	
	CenterDialog (dt);

	dp = GetNewDialog (uiID, nil, (WindowPtr) -1);

	(void) SetDialogDefaultItem (dp, ok);
	(void) SetDialogCancelItem (dp, cancel);

	PIGetString(kHistStatus, hS); // get status string
	
	do
	{
		
		currentResources = CountPIResources(histResource);
		
		if (gCurrentHistory < 1)
			gCurrentHistory = 1;
		if (gCurrentHistory > currentResources)
			gCurrentHistory = currentResources;
		
		if (currentResources <= kDHistTotal || 
			gCurrentHistory+kDHistTotal > currentResources)
			PIDisableControl (dp, kDDownButton); // nothing extra to show
		else
			PIEnableControl (dp, kDDownButton);
		
		if (gCurrentHistory < 2)
			PIDisableControl (dp, kDUpButton);
		else
			PIEnableControl (dp, kDUpButton);
		
		if (currentResources >= gCurrentHistory && currentResources > 0)
			{
			PIEnableControl (dp, kDTrimFirst);
			PIEnableControl (dp, kDTrimLast);
			}
		else
		{
			PIDisableControl (dp, kDTrimFirst);
			PIDisableControl (dp, kDTrimLast);
		}
		
		UpdateHistories(globals, dp, currentResources, hS);

		MoveableModalDialog (dp, gStuff->processEvent, nil, &item);

		switch (item)
		{
			case cancel:
				gResult = userCanceledErr;
				// have to set this so we don't get recorded
				break;
			case kDTrimFirst:
				if (currentResources >= gCurrentHistory)
				{
					DeletePIResource (histResource, gCurrentHistory);
					gStuff->dirty = TRUE;
				}
				break;
			case kDTrimLast:
				if (currentResources >= gCurrentHistory + kDHistTotal-1)
				{
					DeletePIResource (histResource, gCurrentHistory+ kDHistTotal-1);
					gStuff->dirty = TRUE;
				}
				else if (currentResources > 0)
				{
					DeletePIResource (histResource, currentResources);
					gStuff->dirty = TRUE;
				}
				break;
			case kDUpButton:
				gCurrentHistory--;
				break;
			case kDDownButton:
				gCurrentHistory++;
				break;
		} // end switch (item)
	} while (item != ok && item != cancel);

	DisposeDialog (dp);
	HPurge ((Handle) dt);
	
	return (item == ok);
}
Boolean DoUI (GPtr globals)
{
	
	short 		item, lastitem;
	short		numberErr = noErr;
	long		x;
	DialogPtr	dp;
	DialogTHndl	dialogHdl;
	dialogHdl = (DialogTHndl) GetResource ('DLOG', uiID);

	if (dialogHdl == NULL || *dialogHdl == NULL)
		return false;
	else
	{
		
	HNoPurge ((Handle) dialogHdl);

	CenterDialog (dialogHdl);
	
	dp = GetNewDialog (uiID, nil, (WindowPtr) -1);
		
	/* I am throwing away the results from these routines. 
	   Toolbox TechNote 37 does not document what error values they return.
	   Also, the worst that happens is that the interface isn't quite right. */
	
	(void) SetDialogDefaultItem (dp, ok);
	(void) SetDialogCancelItem (dp, cancel);
	(void) SetDialogTracksCursor (dp, TRUE);
		
	SetRadioGroupState (dp,
						kFirstItem,
						kLastItem,
						kFirstItem + gWhatArea);
						
	SetRadioGroupState (dp,
						kUseRadio1,
						kUseRadioLast,
						kUseRadio1 + gWhatChannels);

	SetRadioGroupState (dp,
						kCreateRadio1,
						kCreateRadioLast,
						kCreateRadio1 + gCreate);
	
	ShowHideItem (dp, kPercentStatic, (gWhatArea == iSelectRandom));
	ShowHideItem (dp, kPercentEdit, (gWhatArea == iSelectRandom));
	ShowHideItem (dp, kPercentSymbol, (gWhatArea == iSelectRandom));
	StuffNumber(dp, kPercentEdit, gPercent);
	if (gWhatArea == iSelectRandom) SelectTextItem(dp, kPercentEdit);
		
	SelectWindow (GetDialogWindow(dp));
	
	do
	{
		
		MoveableModalDialog (dp, gStuff->processEvent, nil, &item);
		
		if (lastitem != item && item != cancel)
		{ /* we just left this area.  Check to make sure its within bounds. */
			switch (lastitem)
			{
				case kPercentEdit:
					numberErr = FetchNumber(dp,
										    kPercentEdit,
										    kPercentMin,
										    kPercentMax,
										    &x);
					if (numberErr != noErr)
					{ // shows alert if there's an error
						AlertNumber(dp,
									kPercentEdit,
									kPercentMin,
									kPercentMax,
									&x,
								    AlertID,
								    numberErr);
						item = kPercentEdit; // stay here
					}
					gPercent = x;						
					break;
			}
		}
		switch (item)
		{
			case ok:
				gWhatArea = GetRadioGroupState(dp, kFirstItem, kLastItem) - kFirstItem;
				gWhatChannels = GetRadioGroupState(dp, kUseRadio1, kUseRadioLast) - kUseRadio1;
				gCreate = GetRadioGroupState(dp, kCreateRadio1, kCreateRadioLast) - kCreateRadio1;
				if (gWhatArea == iSelectRandom)
				{
					numberErr = FetchNumber(dp,
										    kPercentEdit,
										    kPercentMin,
										    kPercentMax,
										    &x);
					if (numberErr != noErr)
					{ // shows alert if there's an error
						AlertNumber(dp,
									kPercentEdit,
									kPercentMin,
									kPercentMax,
									&x,
								    AlertID,
								    numberErr);
						item = kPercentEdit; // go back
					}
					else gPercent = x; // it's okay, move on
				}
				break;

			case cancel:
				gResult = userCanceledErr;
				break;
			case kPercentEdit:
				// grab the number whether it's right or not
				numberErr = FetchNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x);
				if (numberErr == noErr)
				{ // no errors getting the number
					gPercent = x;
					// update display here	 
				}
				break;

			default:
			if (item >= kFirstItem && item <= kLastItem)
			{
				SetRadioGroupState (dp, kFirstItem, kLastItem, item);
				ShowHideItem (dp, kPercentStatic, (item == iSelectRandom + kFirstItem));
				ShowHideItem (dp, kPercentEdit, (item == iSelectRandom + kFirstItem));
				ShowHideItem (dp, kPercentSymbol, (item == iSelectRandom + kFirstItem));
				if (item == iSelectRandom + kFirstItem) SelectTextItem(dp, kPercentEdit);
			}
			else if (item >= kUseRadio1 && item <= kUseRadioLast)
				SetRadioGroupState (dp, kUseRadio1, kUseRadioLast, item);
			else if (item >= kCreateRadio1 && item <= kCreateRadioLast)
				SetRadioGroupState (dp, kCreateRadio1, kCreateRadioLast, item);
			break;
		}
		lastitem = item;
	}
	while (item != ok && item != cancel);

	DisposeDialog (dp);
		
	if (dialogHdl != NULL && *dialogHdl != NULL)
		HPurge ((Handle) dialogHdl);
	
	dp = NULL;
	dialogHdl = NULL;
	
	return item == ok;
	
	
	} // else
}