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>
20 #include <proto/alib.h>
21 #include <proto/exec.h>
22 #include <proto/intuition.h>
27 /**********************************************************************************************/
29 struct IntuitionBase
*IntuitionBase
;
30 static struct Window
*win
;
31 static struct Gadget
*gad1
, *gad2
, *gad3
, *gad4
;
32 static Object
*model
, *ic1
;
33 static BOOL gadgets_added_to_model
= FALSE
;
35 /**********************************************************************************************/
37 static struct TagItem prop_to_idcmp
[] =
39 {PGA_Top
, ICSPECIAL_CODE
},
43 static struct TagItem prop_to_string
[] =
45 {PGA_Top
, STRINGA_LongVal
},
50 /**********************************************************************************************/
52 static void cleanup(char *msg
)
54 if (msg
) printf("modelclass: %s\n",msg
);
56 if (win
) RemoveGList(win
, gad1
, -1);
57 if (gad1
) DisposeObject((Object
*)gad1
);
58 if (gad3
) DisposeObject((Object
*)gad3
);
60 if (!gadgets_added_to_model
)
62 if (gad2
) DisposeObject((Object
*)gad2
);
63 if (gad4
) DisposeObject((Object
*)gad4
);
64 if (ic1
) DisposeObject((Object
*)ic1
);
67 if (model
) DisposeObject(model
);
71 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
75 /**********************************************************************************************/
77 static void openlibs(void)
79 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",39);
80 if (!IntuitionBase
) cleanup("can't open intuition.library V39!");
83 /**********************************************************************************************/
85 static void makegadgets(void)
87 model
= NewObject(0, MODELCLASS
, ICA_TARGET
, ICTARGET_IDCMP
,
88 ICA_MAP
, (IPTR
)prop_to_idcmp
,
91 if (!model
) cleanup("can't create modelclass object!");
93 ic1
= NewObject(0, ICCLASS
, TAG_DONE
);
95 if (!ic1
) cleanup("can't create icclass object!");
97 gad1
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 10,
101 PGA_Freedom
, FREEVERT
,
105 ICA_TARGET
, (IPTR
)model
,
107 if (!gad1
) cleanup("can't create gadget 1!");
109 gad2
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 40,
113 PGA_Freedom
, FREEVERT
,
117 GA_Previous
, (IPTR
)gad1
,
119 if (!gad2
) cleanup("can't create gadget 2!");
121 gad3
= (struct Gadget
*)NewObject(0, STRGCLASS
, GA_Left
, 80,
126 GA_Previous
, (IPTR
)gad2
,
129 if (!gad3
) cleanup("can't create gadget 3!");
131 gad4
= (struct Gadget
*)NewObject(0, PROPGCLASS
, GA_Left
, 80,
135 PGA_Freedom
, FREEHORIZ
,
139 GA_Previous
, (IPTR
)gad3
,
141 if (!gad4
) cleanup("can't create gadget 4!");
143 SetAttrs(ic1
, ICA_TARGET
, (IPTR
) gad3
,
144 ICA_MAP
, (IPTR
) prop_to_string
,
147 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) gad2
);
148 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) ic1
);
149 DoMethod(model
, OM_ADDMEMBER
, (IPTR
) gad4
);
151 gadgets_added_to_model
= TRUE
;
155 /**********************************************************************************************/
157 static void makewin(void)
159 win
= OpenWindowTags(0, WA_Title
, (IPTR
) "Modelclass demo: Use first prop gadget!",
164 WA_AutoAdjust
, TRUE
,
165 WA_CloseGadget
, TRUE
,
166 WA_DepthGadget
, TRUE
,
168 WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_IDCMPUPDATE
,
170 WA_Gadgets
, (IPTR
) gad1
,
174 if (!win
) cleanup("can't open window!");
178 /**********************************************************************************************/
180 static void handleall(void)
182 struct IntuiMessage
*msg
;
187 WaitPort(win
->UserPort
);
188 while((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
192 case IDCMP_CLOSEWINDOW
:
196 case IDCMP_IDCMPUPDATE
:
197 printf("IDCMP_IDCMPUPDATE: code = %d\n", msg
->Code
);
200 } /* switch msg->Class */
202 ReplyMsg((struct Message
*)msg
);
204 } /* while msg = getmsg */
206 } /* while (!quitme) */
209 /**********************************************************************************************/
222 /**********************************************************************************************/