19.06.2013 Views

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TUTORIAL<br />

UserPort because this is the message<br />

port at which Intuition IDCMP event messages<br />

will arrive. This address obviously<br />

needs to be available to the event handler<br />

and is obtained from the window<br />

Structure set up by Intuition by using the<br />

window pointer in conjunction with a<br />

wd _UserPort displacement like this<br />

movect windom_p,e1<br />

movecl md_UserPortfolt,o2<br />

address<br />

Within the event handler proper two<br />

events. namelY the user hitting the window's<br />

'close' gadget or selecting a 'Quit to<br />

Workbench' menu option, result in an exit<br />

flag being set that eventually causes the<br />

program to terminate. You'll see from the<br />

source that a check is also made for menu<br />

events whose code field is set to<br />

MENUNULL This is important since these<br />

events are generated whenever a<br />

user activates the menu, but then fails to<br />

make a selection (such events need to be<br />

recognised in order lo be safely ignored).<br />

The other menu option, incidentally, is just<br />

tags<br />

workbench_p<br />

gad too LI i It<br />

IcA<br />

dt.t<br />

dc.1<br />

dc.1<br />

dt.l<br />

dc.l<br />

dc.l<br />

dc.i<br />

dc.1<br />

dc.1<br />

did<br />

dc,t<br />

dc.t<br />

dc.1<br />

dc.1<br />

dc.l<br />

dc.l<br />

dc.l<br />

user pert<br />

VA_Pub S r e<br />

1<br />

WO_Lef 1,300<br />

WA_Top.,0<br />

VO_Ii1dth,340<br />

WSJ i gh I o<br />

il) WO_Oraggar,ttlti<br />

OhJeo th Godge I, RUE<br />

1101_0 loseadge t Ritt<br />

itA_SI refiadget,IllfiE<br />

1111_61dge to<br />

Mat<br />

Listing 2 :<br />

tag-based<br />

window<br />

description<br />

littjoom,1 om_do es<br />

WA _II WI IRWIN<br />

WAJI , 10<br />

Ojai& 4th,640<br />

VAJlaell I gh ,256<br />

PA_IPCNP,ICICAPJEMPP1(K I IEMP_CLOSEVIIIDOW<br />

t e,o indoo_name<br />

TAG _DOME,MUL<br />

Listing Cl<br />

The e ve nt<br />

handling<br />

code from<br />

this month's<br />

•sompto<br />

program<br />

<strong>Amiga</strong> <strong>Computing</strong><br />

OCTOBER 1995_<br />

Even Oland er<br />

Eventliand le a<br />

fietliessage<br />

Menuttessage<br />

title bar (olap5ed window5<br />

With the preliminary program layout discussions now<br />

safely out of the way we can deal with the real topic<br />

of the month — namely, how to produce windows that<br />

initially reside in, or can be made to collapse into, a<br />

window's title bar. Perhaps surprisingly. it is very<br />

easy to do because all it takes is a few well chosen<br />

tag list entnes in the window definition_<br />

Firstly, provide a zero WA_Top value and set<br />

WA_Left to a value which places the 'window' at a<br />

suitable position within the title bar. Then set the<br />

Window initial width and height tags. WA_Width and<br />

WA_Height, to define a window which has only a 10<br />

pixel height (i.e. the height of a window title bar). For<br />

instance:<br />

dc.t MI_Top,(1<br />

did Majeft,300<br />

dc .1 lia_llidth,340<br />

dc 11A_Keigh , 10<br />

Having clone that you then just arrange for the real<br />

co-ordinates of your window to be stored as the<br />

'alternate' zoom gadget set, This involves using a<br />

nevem, t d0-11a0-a1,-te1)<br />

e tr. t<br />

Fovea, I 12,10<br />

tatCSYS goitPortp.AbsisecOott<br />

Ji<br />

cmpi.l , OTIOE,d2<br />

brics Eventliandltri<br />

G<br />

Noyes. 1 to7t4,d1)-111 Jog-12<br />

e<br />

rts<br />

t<br />

l<br />

i<br />

soota.l 12,10 g e t port 14<br />

e MASTS ietgag,_AblEettliole<br />

s tit.l d 0<br />

sbtu.<br />

s Sttesnageit<br />

o 0411<br />

g@ave.(<br />

e _ t loss lot ),d3<br />

e<br />

w o_tode tot 1,0X<br />

CALLSti Itepleltsg,_fibtElectis se<br />

110CMP_CLOSEWINfiall,d3<br />

linea Menullessage<br />

Mfg 111100,d2<br />

bras centime<br />

cool I E K , d 3<br />

Unt.i e t M e s s a ge<br />

cow .11<br />

boo.' fietMessage<br />

15,6<br />

andil •SIF,di<br />

btu.' DoRenulten0<br />

move; et1eUE,d2<br />

bro • s f,tttniage<br />

tollenultes0 ! s r Wiothirg<br />

bra s 6 . ttle ssage<br />

ie e ss a peE s t r t s d i holds slit flog<br />

lied to a dummy routine so nothing actually<br />

happens when the menu item is selected.<br />

This act of tying a menu option to a 'do<br />

nothing routine in this way is actually a<br />

very useful trick dunng development of fully<br />

fledged applications. You may have<br />

dozens of menu options that relate to code<br />

sections that are as yet unwritten, and tying<br />

such options to dummy routines allows<br />

the event handler and overall structure of<br />

WA Zoom tag in the window definition to identify a<br />

pointer to a set of alternate window dimensions that<br />

will be used when the window's zoom gadget is<br />

selected_ These dimensions have to be provided as<br />

an array of word (16-bit) entries, so in the example<br />

program you'll find this lag entry:<br />

de. t WO_Loom soon_dato<br />

along with this cicw directive which identities the corresponding<br />

set of alternate window co-ordinates:<br />

toom_dota dt.o ISO<br />

4<br />

50,140,200<br />

The result? The window opens initially inside the fille<br />

bar and can be expanded to normal use Size by<br />

selecting the zoom gadget, You will, of course, be<br />

able to see the effect of these statements when you<br />

run this month's example program. To get the<br />

reverse effect, namely initially having the window<br />

open normally, but collapsing into the tale bar when<br />

the zoom gadget is activated, you just reverse the<br />

original and alternate sets of window co-ordinatesl<br />

preserve registers<br />

tteer etit 'Rog<br />

port address<br />

exit Slag set!<br />

restore registers<br />

Logical end of routine<br />

drext in if<br />

pet tbe messoge<br />

did it /tilt?<br />

opy pointer to it<br />

cops ',mot cleft<br />

copy mug. coot<br />

then seld lessege back<br />

net kW signa l. to e xit routine<br />

check mesoage class<br />

ignore other 'estop types<br />

ignore il MENUPOLL<br />

Wren menu tel number<br />

Nitt be either 0 or<br />

net GOIT tignal to exit routine<br />

Chia foe Ore Se M ge s<br />

,<br />

the code to be developed, even thoug<br />

many associated routines may not yet<br />

written.<br />

As the corresponding real routine<br />

become available, you just replace the<br />

appropriate call to the dummy routine w<br />

a call to the real version. Another benefit<br />

this type of approach is that it automatic<br />

provides an 'incremental testing' pathway<br />

It for example, your program works<br />

until you swap, say a... jsr DoNothing c<br />

with a call to a real routine, then you'll k<br />

straightaway that any faults that appear a<br />

almost certainly connected with the co<br />

present in the newly added routine!<br />

Most of the event handling code shou<br />

be easy enough to follow, but it may help<br />

examine the diagram shown in figure I<br />

This provides a fairly high-level, gener<br />

description of the code's operation in I<br />

chart form<br />

•11.160, 1 1 6 1 11.1 .<br />

NI M PW4 4<br />

7197<br />

- • buss<br />

St I L J 1<br />

1 t S 5<br />

Figure I ; ba sic progra m structure<br />

in flowcha rt form<br />

• I<br />

s<br />

t i<br />

M<br />

is

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!