Copyright ã 1994 by Sean Luke

COWS_IBConnectors.palette
COWS Version 1.4
May 20, 1994

The IBConnectors palette is an experimental palette of three objects to make life easier for you as you incorporate COWS into Interface Builder.  This palette requires the existence of COWSPalette.  Note that this palette must be loaded after the COWSPalette.  This is why there's the _ in the nameÐto make it alphabetically later than COWSPalette.  Note that this palette is buggy and may cause IB to crash for reasons I can't quite explain yet.

The Example nib file demonstrates some of these objects in use.  To use these objects in an application, be sure to include the COWS and COWSIBConnectors subprojects (in the Subprojects directory) in your project.

Radio

Radio is a library that allows you to spread your COWS libraries amongst many nib files.  Place the radio in the main nib file, connect it as a library to some COWS Connector, and set other libraries in this palette to "tune in" if they're in foreign nib files.  This way, you don't have to connect them to the Connector in the main nib file, which is impossible if they're not located in that file.  Useful, eh?

Splitter

Interface Builder doesn't allow one to make Controllers or User Controllers with a dynamic number of library outlets without making your own connection inspector, which is a mess.  My answer is Splitter.  Splitter hooks into a Controller, or "tunes in" (see above), or hooks into another splitter, an allows many libraries to connect into that one slot by hooking directly into splitter.  In essence, it's an expansion module for Controller's limited number of slots.

Control Interface

The Control Interface is a library that allows you to hook IB controls (menu buttons, buttons, scroll bars, text fields, etc.) as library functions, so you can control and query them through a COWS script.  You connect the Control Interface to a COWS Controller of COWS User Controller like all libraries.  You can alternately "tune in" to a Radio (see above).  The interface can be connected to a control in one of two ways:

	Input
	Manipulating a control starts up a COWS function call.   To set this up, connect the Control 
	Interface as the target of the Control.  Pick a method to callÐto tell a COWS function to do
	something with the value of a text field, you might use takeStringValueFrom:.  To tell a COWS
	function to do something with the value of a scroller, you might use takeDoubleValueFrom:.  To
	just run some COWS function with no arguments from pressing a button, you'd probably use
	do:, a special method for just that purpose.
	
	Now, you've got to tell the Control Interface what function to call.  If you're hooking just one
	control to the Control Interface, you put that function name in Default Input COWS Function.
	Let's say you entered the function name heck.  If you hooked a button to the function heck 
	through the method do:, every time you pressed that button, the COWS function (heck) would
	be called.  If you hooked a text field and used the method takeStringValueFrom:, when you
	pressed Return in the text field, the COWS function (heck foo) would be called, where foo
	was the string value of the text field.  Got it?
	
	If you're connecting several controls to the Control Interface (say, you're building a multi-
	button calculator), the Interface needs to know which is which.  You do this by putting functions
	in each of the Input Function slots, and also connecting the Control Interface to each control
	using some input field corresponding to the slot.  Of course, remember to connect the Control
	Interface as the target of the control, specifying some action.  This way, when you press one of
	several buttons, the interface wakes up and says "aha!  It's button number 5.  That means call
	function foo."
	
	Output
	You can also manipulate controls through a COWS function.  Before you start, parse the file
	NewControls.h, supplied with this palette.  This file adds some special methods to query
	controls for values instead of just setting controls to values.  Be certain not to call these 
	methods with anything but Control Interfaces.
	
	Once you've established the Control Interface as a library to your Controller or User Controller,
	you can manipulate a control with a COWS function as follows.  Say you want to set a text
	field to a string value using the function foo which takes bar as the argument to set the field to.
	Put the word foo the Control Interface's Output COWS Function field.  Then connect the
	control as the target of the Control Interface, using takeStringValueFrom: as your selector
	(in this case).  This is all you need to do.  Now if you called (foo "hello"), the word hello
	appears in the text field!
	
	Assuming you've parsed NewControls.h, if you wanted to return the value of this text field
	as the return value of the function foo, you'd use something like returnStringValue: instead.
	So if the text field contained the word "hello", and you wanted to, say, print the value of the
	text field, you could call (print (foo)) to print it out!
	
	Note that all the return: functions are provided because of the modified Control and Cell
	classes in NewControls.h, and only work with the COWS Control Interface.  Don't get caught
	in the trap of using them elsewhere!
	
	Unlike inputs, you can only have one output per Control Interface because of limitations of
	Interface Builder (not very good design).  Sorry for the inconvenience.
	
Note that you are free to use both the input and output functions of a Control Interface at the same time.