diff options
author | jestin | 2004-06-25 18:26:19 +0000 |
---|---|---|
committer | jestin | 2004-06-25 18:26:19 +0000 |
commit | cfc602e2408bf90cce7be62f3f1e940cd5af7172 (patch) | |
tree | f3b3078f308ff676acfee099aa3c0a4268e15b9a /examples/motifButtonIvy.c | |
parent | 43eaf35871578ea498e20ed4f945cce14f8f3032 (diff) | |
download | ivy-c-cfc602e2408bf90cce7be62f3f1e940cd5af7172.zip ivy-c-cfc602e2408bf90cce7be62f3f1e940cd5af7172.tar.gz ivy-c-cfc602e2408bf90cce7be62f3f1e940cd5af7172.tar.bz2 ivy-c-cfc602e2408bf90cce7be62f3f1e940cd5af7172.tar.xz |
j'ajoute des exemples de code dans le CVS. il faudra les intégrer à la doc...
Diffstat (limited to 'examples/motifButtonIvy.c')
-rw-r--r-- | examples/motifButtonIvy.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/motifButtonIvy.c b/examples/motifButtonIvy.c new file mode 100644 index 0000000..f4336aa --- /dev/null +++ b/examples/motifButtonIvy.c @@ -0,0 +1,37 @@ +#include <stdlib.h> +#include <stdio.h> +#include <strings.h> +#include <Xm/PushB.h> +#include <ivy.h> +#include <ivyxtloop.h> + +void myMotifCallback(Widget w,XtPointer client_d,XtPointer call_d){ + // sends the string on the bus + IvySendMsg (*((char**)client_d)); +} + +void textCallback(IvyClientPtr app, void *user_data, int argc, char *argv[]){ + printf("%s sent %s\n",IvyGetApplicationName(app),argv[0]); + // updates the string we want to send + *((char **)user_data)=argv[0]; +} + +void DieCallback (IvyClientPtr app, void *data, int id){ exit(0); } + +int main(int argc,char *argv[]){ + Widget toplevel,pushb; + XtAppContext app_context; + Arg myargs[10]; + char *bus=getenv("IVYBUS"); + char *tosend="foo"; + toplevel=XtAppInitialize(&app_context,"Ivy Button",NULL,0,&argc,argv,NULL,myargs,0); + pushb=XmCreatePushButton(toplevel,"send message",myargs,1); + XtManageChild(pushb); + XtAddCallback(pushb,XmNactivateCallback,myMotifCallback,&tosend); + XtRealizeWidget(toplevel); + IvyXtChannelAppContext(app_context); + IvyInit("IvyMotif","IvyMotif connected",NULL,NULL,DieCallback,NULL); + IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)"); + IvyStart(bus); + XtAppMainLoop(app_context); +} |