Reading: Chapters 6-8 in Foster

Working extensively with resources

Our goal today is to get familiar with the Constructor, in particular, resources for UIs. I want to begin building a MemoPad type application. To do this, we will first build a major portion of the UI. We will provide enough functionality to make sure the UI works the way we want it to.

Here are the screen shots of what I want to produce.






We should be familiar with the Main form and Menu bar from the Starter app created by CodeWarrior. Remember, this looks like:

From here, we want to create a new form and the menu items that go along with that form.

Some shortcuts:

1) Ctl k creates a new resource such as a Form, Alert, Menu Bar, ...

2) Ctl m while in the Menu Bar creates a new menu such as View, Edit, ...

3) Ctl - creates a separator between menu items

4) Tabbing on a particular menu item allows the creation of a shortcut

Once you have created the resources and changed the App Icons to match the above example, we want to test to see that all pieces of the UI are working correctly. For that, we need to add some functionality as follows:

1) Each form will need an Event-handler, so for the Pad form, let's start with a basic event-handler as follows:

static Boolean PadFormHandleEvent (EventPtr eventP)
{
	Boolean handled = false;
	FormPtr frmP;
	
	switch (eventP->eType)
	{
		
		case frmOpenEvent:
			frmP = FrmGetActiveForm ();
			FrmDrawForm (frmP);
			handled = true;
			break;
			
		default:
			break;
	}
	
	return handled;
}
This basic event-handler will allow us to gain access to the Pad form and test the menus associated with this form.

We also need to add a ctlSelectEvent to the Main form so that if the user presses the New button, the Pad form is opened. This will look something like:

		case ctlSelectEvent:
			switch (eventP->data.ctlSelect.controlID)
			{
				case MainNewButton:
					FrmGotoForm (PadForm);
					handled = true;
					break;
			
				default:
					break;
			}
			break;
Finally, we need to add some code to the AppHandleEvent so that when control passes to the Pad Form, the event-handler for this form is set up. The code will look something like this:

			case PadForm:
				FrmSetEventHandler (frmP, PadFormHandleEvent);
				break;

Problem: By Tuesday of next week, I want each of you to implement and understand the above UI with the associated functionality just described. Test your application with the emulator using a debug ROM making sure that the app icons are correct. Make sure your application can run 1,000,000 gremlins on the emulator with the debug ROM. Finally, download the software onto an actual device.


©Douglas J. Ryan / ryandj@pacificu.edu