[PATCH] libXt add example to XtSetValues man page

walter harms wharms at bfs.de
Sun Jan 23 08:22:03 PST 2011


Add example for
Signed-off-by: walter harms <wharms at bfs.de>
---
 man/XtSetValues.man |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/man/XtSetValues.man b/man/XtSetValues.man
index a07e9b6..56f7ab2 100644
--- a/man/XtSetValues.man
+++ b/man/XtSetValues.man
@@ -1,3 +1,6 @@
+.\" $Xorg: XtSetVal.man,v 1.3 2000/08/17 19:42:03 cpqbld Exp $
+.\" $XdotOrg: $
+.\"
 .\" Copyright (c) 1993, 1994  X Consortium
 .\"
 .\" Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,6 +26,8 @@
 .\" dealing in this Software without prior written authorization from the
 .\" X Consortium.
 .\"
+.\" $XFree86: xc/doc/man/Xt/XtSetVal.man,v 1.3 2001/02/09 03:47:52 tsi Exp $
+.\"
 .ds tk X Toolkit
 .ds xT X Toolkit Intrinsics \- C Language Interface
 .ds xI Intrinsics
@@ -271,7 +276,59 @@ This permits a subclass to provide nonwidget resource data to
 The
 .ZN XtGetSubvalues
 function obtains resource values from the structure identified by base.
+.SH EXAMPLE
+The example shows the use of XtVaSetValues(). As soon as the command widget
+is pressed it will change its label.
+.nf
+
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <Intrinsic.h>
+#include <StringDefs.h>
+#include <Xaw/Command.h>
+#include <Shell.h>
+/* gcc -I /usr/include/X11/ sample.c -lX11 -lXaw */
+
+void click_cb(Widget w, XtPointer c_data, XtPointer calld)
+{
+  char buf[40];
+  static int i;
+  i++;
+  snprintf(buf,sizeof(buf),"got:%d ",i);
+  XtVaSetValues(w,XtNlabel,buf,NULL);
+}
+
+
+int main(int argc, char *argv[])
+{
+  Widget top,cmd;
+  XtAppContext app;
+  char buf[40];
+
+  top=XtOpenApplication(&app, "Xtdemo",
+                         NULL,0,
+                         &argc,argv,
+                         NULL,
+                         applicationShellWidgetClass,
+                         NULL,0);
+
+  snprintf(buf,sizeof(buf),"PID:%d ",getpid());
+
+  cmd=XtVaCreateManagedWidget ("commando", commandWidgetClass, top,
+     				XtNlabel,buf,
+     				NULL);
+
+  XtAddCallback(cmd,XtNcallback,click_cb,NULL);
+  XtRealizeWidget(top);
+  XtAppMainLoop(app);
+  return 0;
+}
+
+.fi
 .SH "SEE ALSO"
+.BR XtSetArg (3Xt)
 .br
 \fI\*(xT\fP
 .br
-- 
1.6.0.2



More information about the xorg-devel mailing list