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,
"Prog3",
NULL,
0,
65 &argc, argv,
NULL,
NULL,
0);
66
67 progress = XtVaCreateManagedWidget(
"progress",
68 xmlProgressWidgetClass, shell,
69 XtVaTypedArg, XmNbackground, XmRString,
"white",
6,
70 XtVaTypedArg, XmNforeground, XmRString,
"#000080",
8,
71 XtVaTypedArg, XmNtopShadowColor, XmRString,
"#D0D0D0",
8,
72 XtVaTypedArg, XmNbottomShadowColor, XmRString,
"black",
6,
73 XmNmeterStyle, XmMETER_BOXES,
74 XmNnumBoxes,
20,
75 XmNwidth,
300,
76 XmNheight,
20,
77 XmNshadowThickness,
1,
78 NULL);
79
80 XtAppAddWorkProc(app, compute,
NULL);
81 XtRealizeWidget(shell);
82 XtAppMainLoop(app);
83 }
84
85 Boolean compute(clientData)
86 XtPointer clientData;
87 {
88 int i;
89
90 XtVaSetValues(progress,
91 XmNvalue,
0,
92 XmNcompleteValue,
7,
93 NULL);
94 for (i =
0; i <
7; i++)
95 {
96 XtVaSetValues(progress,
97 XmNvalue, i,
98 NULL);
99
100 sleep(
1);
101 }
102 XtVaSetValues(progress,
103 XmNvalue, i,
104 NULL);
105 return(
FALSE);
106 }
107