1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm-2.0/notebook/test3.c,v 1.2 2001/06/18 14:49:16 amai Exp $ */
2 /* from
3  *  http://techpubs.sgi.com:80/library/dynaweb_bin/ebt-bin/0650/nph-infosrch.cgi/infosrchtpl/SGI_Developer/Motif_Port_G/@InfoSearch__BookTextView/1094;he=0?DwebQuery=motif
4  */
5 
6 #include <stdlib.h>
7 #include <stdio.h>
8 
9 /* include init */
10 #include <Xm/Xm.h>
11 #include <Xm/Form.h>
12 #include <Xm/Label.h>
13 #include <Xm/List.h>
14 #include <Xm/MenuShell.h>
15 #include <Xm/Notebook.h>
16 #include <Xm/PushB.h>
17 #include <Xm/RowColumn.h>
18 #include <Xm/ScrolledW.h>
19 #include <Xm/Separator.h>
20 #include <Xm/TextF.h>
21 
22 #include "../../common/Test.h"
23 
24 
25 #define NUM_PAGES 8
26 #define APPNAME "Notebook"
27 
28 
29 static void pageChangeCB(Widget w, XtPointer client, XtPointer call);
30 
31 /* end init */
32 
33 
34 int
main(int argc,char ** argv)35 main(int argc, char ** argv)
36 {
37     XtAppContext AppContext;
38     Widget     TopLevel = XtVaOpenApplication(&AppContext,
39                                APPNAME,
40                                NULL, 0,
41                                &argc, argv,
42                                NULL,
43                                sessionShellWidgetClass,
44                                NULL);
45 
46 /* include notebook */
47     Widget notebook = XtVaCreateWidget("notebook",
48                                xmNotebookWidgetClass,
49                                TopLevel,
50                                NULL);
51     int i;
52     XmString xmstr;
53     char    labelString[32];
54 
55     for ( i=0; i< NUM_PAGES; i++ ) {
56 
57         sprintf(labelString,"Page %d\n",i);
58         xmstr = XmStringCreateLocalized(labelString);
59 
60         (void) XtVaCreateManagedWidget("label", xmLabelWidgetClass,
61                         notebook,
62                         XmNpageNumber, i+1,
63                         XmNlabelString, xmstr,
64                         NULL);
65 
66         XmStringFree(xmstr);
67     }
68 
69     for ( i=0; i< NUM_PAGES; i+=4 ) {
70         int j;
71 
72         sprintf(labelString,"Major\nTab %d\n",i);
73         xmstr = XmStringCreateLocalized(labelString);
74 
75         (void) XtVaCreateManagedWidget("button",
76                         xmPushButtonWidgetClass,
77                         notebook,
78                         XmNpageNumber, i+1,
79                         XmNlabelString, xmstr,
80                         XmNnotebookChildType,
81                         XmMAJOR_TAB,
82                         NULL);
83         XmStringFree(xmstr);
84 
85         for ( j=i; j<i+4; j++ ) {
86 
87             sprintf(labelString,"Minor\nTab %d\n",j);
88             xmstr = XmStringCreateLocalized(labelString);
89 
90             (void) XtVaCreateManagedWidget("button",
91                             xmPushButtonWidgetClass,
92                             notebook,
93                             XmNpageNumber, j+1,
94                             XmNlabelString, xmstr,
95                             XmNnotebookChildType,
96                             XmMINOR_TAB,
97                             NULL);
98             XmStringFree(xmstr);
99         }
100     }
101 
102     XtAddCallback(notebook, XmNpageChangedCallback,
103                   (XtCallbackProc) pageChangeCB, NULL);
104 
105     XtManageChild(notebook);
106 /* end notebook */
107 
108     XtRealizeWidget(TopLevel);
109 
110     LessTifTestMainLoop(TopLevel);
111 
112 }
113 
114 
115 /* pageChangeCB - comment */
116 static void
pageChangeCB(Widget w,XtPointer client,XtPointer call)117 pageChangeCB(Widget w, XtPointer client, XtPointer call)
118 {
119 
120 }
121