1 /**********************************************************************************************/
5 connect one prop gadget with two other prop gadgets,
6 one string gadget, and the IDCMP.
8 This interconnection is done with modelclass and icclass objects
12 /**********************************************************************************************/
14 #include <intuition/intuition.h>
15 #include <intuition/classes.h>
16 #include <intuition/classusr.h>
17 #include <intuition/gadgetclass.h>
18 #include <intuition/icclass.h>
19 #include <proto/exec.h>
20 #include <proto/intuition.h>
25 /**********************************************************************************************/
27 struct IntuitionBase
*IntuitionBase
;
28 static struct Window
*win
;
29 static struct Gadget
*gad1
, *gad2
, *gad3
, *gad4
;
30 static Object
*model
, *ic1
;
31 static BOOL gadgets_added_to_model
= FALSE
;
33 /**********************************************************************************************/
35 static struct TagItem prop_to_idcmp
[] =
37 {PGA_Top
, ICSPECIAL_CODE
},
41 static struct TagItem prop_to_string
[] =
43 {PGA_Top
, STRINGA_LongVal
},
48 /**********************************************************************************************/
50 static void cleanup(char *msg
)
52 if (msg
) printf("modelclass: %s\n",msg
);
54 if (win
) RemoveGList(win
, gad1
, -1);
55 if (gad1
) DisposeObject((Object
*)gad1
);
56 if (gad3
) DisposeObject((Object
*)gad3
);
58 if (!gadgets_added_to_model
)
60 if (gad2
) DisposeObject((Object
*)gad2
);
61 if (gad4
) DisposeObject((Object
*)gad4
);
62 if (ic1
) DisposeObject((Object
*)ic1
);
65 if (model
) DisposeObject(model
);
69 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
73 /**********************************************************************************************/
75 static void openlibs(void)
77 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",39);
78 if (!IntuitionBase
) cleanup("can't open intuition.library V39!");
81 /**********************************************************************************************/
83 static void makegadgets(void)
85 model
= NewObject(0, MODELCLASS
, ICA_TARGET
, ICTARGET_IDCMP
,
86 ICA_MAP
, (IPTR
)prop_to_idcmp
,
89 if (!model
) cleanup("can't create modelclass object!");
91 ic1
= NewObject(0, ICCLASS
, TAG_DONE
);
93 if (!ic1
) cleanup("can't create icclass object!");
95 gad1
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 10,
99 PGA_Freedom
, FREEVERT
,
103 ICA_TARGET
, (IPTR
)model
,
105 if (!gad1
) cleanup("can't create gadget 1!");
107 gad2
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 40,
111 PGA_Freedom
, FREEVERT
,
115 GA_Previous
, (IPTR
)gad1
,
117 if (!gad2
) cleanup("can't create gadget 2!");
119 gad3
= (struct Gadget
*)NewObject(0, STRGCLASS
, GA_Left
, 80,
124 GA_Previous
, (IPTR
)gad2
,
127 if (!gad3
) cleanup("can't create gadget 3!");
129 gad4
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 80,
133 PGA_Freedom
, FREEHORIZ
,
137 GA_Previous
, (IPTR
)gad3
,
139 if (!gad4
) cleanup("can't create gadget 4!");
141 SetAttrs(ic1
, ICA_TARGET
, (IPTR
) gad3
,
142 ICA_MAP
, (IPTR
) prop_to_string
,
145 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) gad2
);
146 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) ic1
);
147 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) gad4
);
149 gadgets_added_to_model
= TRUE
;
153 /**********************************************************************************************/
155 static void makewin(void)
157 win
= OpenWindowTags(0, WA_Title
, (IPTR
) "Modelclass demo: Use first prop gadget!",
162 WA_AutoAdjust
, TRUE
,
163 WA_CloseGadget
, TRUE
,
164 WA_DepthGadget
, TRUE
,
166 WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_IDCMPUPDATE
,
168 WA_Gadgets
, (IPTR
) gad1
,
172 if (!win
) cleanup("can't open window!");
176 /**********************************************************************************************/
178 static void handleall(void)
180 struct IntuiMessage
*msg
;
185 WaitPort(win
->UserPort
);
186 while((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
190 case IDCMP_CLOSEWINDOW
:
194 case IDCMP_IDCMPUPDATE
:
195 printf("IDCMP_IDCMPUPDATE: code = %d\n", msg
->Code
);
198 } /* switch msg->Class */
200 ReplyMsg((struct Message
*)msg
);
202 } /* while msg = getmsg */
204 } /* while (!quitme) */
207 /**********************************************************************************************/
220 /**********************************************************************************************/