1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #include <Xm/Xm.h>
51 #include <XmL/Progress.h>
52
53 Boolean compute();
54
55 Widget progress;
56
57 main(argc, argv)
58 int argc;
59 char *argv[];
60 {
61 XtAppContext app;
62 Widget shell;
63
64 shell = XtAppInitialize(&app,
"Prog2",
NULL,
0,
65 &argc, argv,
NULL,
NULL,
0);
66
67 progress = XtVaCreateManagedWidget(
"progress",
68 xmlProgressWidgetClass, shell,
69 XmNshowTime, True,
70 XtVaTypedArg, XmNbackground, XmRString,
"white",
6,
71 XtVaTypedArg, XmNforeground, XmRString,
"#800000",
8,
72 XmNwidth,
300,
73 XmNheight,
25,
74 NULL);
75
76 XtAppAddWorkProc(app, compute,
NULL);
77 XtRealizeWidget(shell);
78 XtAppMainLoop(app);
79 }
80
81 Boolean compute(clientData)
82 XtPointer clientData;
83 {
84 int i;
85
86 XtVaSetValues(progress,
87 XmNvalue,
0,
88 XmNcompleteValue,
7,
89 NULL);
90 for (i =
0; i <
7; i++)
91 {
92 XtVaSetValues(progress,
93 XmNvalue, i,
94 NULL);
95
96
97 sleep(
1);
98 }
99 XtVaSetValues(progress,
100 XmNvalue, i,
101 NULL);
102 return(
FALSE);
103 }
104