1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
---|
3 | <title>G4UIXaw.cc Source File</title> |
---|
4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
5 | </head><body> |
---|
6 | <!-- Generated by Doxygen 1.3.4 --> |
---|
7 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
---|
8 | <h1>G4UIXaw.cc</h1><a href="G4UIXaw_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">//</span> |
---|
9 | 00002 <span class="comment">// ********************************************************************</span> |
---|
10 | 00003 <span class="comment">// * License and Disclaimer *</span> |
---|
11 | 00004 <span class="comment">// * *</span> |
---|
12 | 00005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span> |
---|
13 | 00006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span> |
---|
14 | 00007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span> |
---|
15 | 00008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span> |
---|
16 | 00009 <span class="comment">// * include a list of copyright holders. *</span> |
---|
17 | 00010 <span class="comment">// * *</span> |
---|
18 | 00011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span> |
---|
19 | 00012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span> |
---|
20 | 00013 <span class="comment">// * work make any representation or warranty, express or implied, *</span> |
---|
21 | 00014 <span class="comment">// * regarding this software system or assume any liability for its *</span> |
---|
22 | 00015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span> |
---|
23 | 00016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span> |
---|
24 | 00017 <span class="comment">// * *</span> |
---|
25 | 00018 <span class="comment">// * This code implementation is the result of the scientific and *</span> |
---|
26 | 00019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span> |
---|
27 | 00020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span> |
---|
28 | 00021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span> |
---|
29 | 00022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span> |
---|
30 | 00023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span> |
---|
31 | 00024 <span class="comment">// ********************************************************************</span> |
---|
32 | 00025 <span class="comment">//</span> |
---|
33 | 00026 <span class="comment">//</span> |
---|
34 | 00027 <span class="comment">// $Id: G4UIXaw.cc,v 1.6 2006/06/29 19:09:47 gunter Exp $</span> |
---|
35 | 00028 <span class="comment">// GEANT4 tag $Name: geant4-08-01-patch-01 $</span> |
---|
36 | 00029 <span class="comment">//</span> |
---|
37 | 00030 <span class="comment">// G.Barrand</span> |
---|
38 | 00031 |
---|
39 | 00032 <span class="comment">//#define DEBUG</span> |
---|
40 | 00033 |
---|
41 | 00034 <span class="preprocessor">#ifdef G4UI_BUILD_XAW_SESSION</span> |
---|
42 | 00035 <span class="preprocessor"></span> |
---|
43 | 00036 <span class="preprocessor">#include <X11/Intrinsic.h></span> |
---|
44 | 00037 <span class="preprocessor">#include <X11/StringDefs.h></span> |
---|
45 | 00038 <span class="preprocessor">#include <X11/Shell.h></span> |
---|
46 | 00039 |
---|
47 | 00040 <span class="preprocessor">#include <Xaw/Dialog.h></span> |
---|
48 | 00041 <span class="preprocessor">#include <Xaw/Command.h></span> |
---|
49 | 00042 |
---|
50 | 00043 <span class="preprocessor">#include "<a class="code" href="G4UIXaw_8hh.html">G4UIXaw.hh</a>"</span> |
---|
51 | 00044 <span class="preprocessor">#include "G4UImanager.hh"</span> |
---|
52 | 00045 <span class="preprocessor">#include "G4StateManager.hh"</span> |
---|
53 | 00046 <span class="preprocessor">#include "G4UIcommandTree.hh"</span> |
---|
54 | 00047 <span class="preprocessor">#include "G4UIcommandStatus.hh"</span> |
---|
55 | 00048 <span class="preprocessor">#include "<a class="code" href="G4Xt_8hh.html">G4Xt.hh</a>"</span> |
---|
56 | 00049 |
---|
57 | 00050 <span class="keyword">static</span> G4bool <a class="code" href="G4UIXm_8cc.html#a6">ConvertStringToInt</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>*,<span class="keywordtype">int</span>&); |
---|
58 | 00051 |
---|
59 | <a name="l00052"></a><a class="code" href="G4UIXaw_8cc.html#a0">00052</a> <span class="keyword">static</span> G4bool <a class="code" href="G4UIXaw_8cc.html#a0">exitSession</a> = <span class="keyword">true</span>; |
---|
60 | <a name="l00053"></a><a class="code" href="G4UIXaw_8cc.html#a1">00053</a> <span class="keyword">static</span> G4bool <a class="code" href="G4UIXaw_8cc.html#a1">exitPause</a> = <span class="keyword">true</span>; |
---|
61 | <a name="l00054"></a><a class="code" href="G4UIXaw_8cc.html#a2">00054</a> <span class="keyword">static</span> G4bool <a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a> = <span class="keyword">true</span>; |
---|
62 | 00055 <span class="comment">/***************************************************************************/</span> |
---|
63 | <a name="l00056"></a><a class="code" href="classG4UIXaw.html#a0">00056</a> <a class="code" href="classG4UIXaw.html#a0">G4UIXaw::G4UIXaw</a> ( |
---|
64 | 00057 <span class="keywordtype">int</span> argc |
---|
65 | 00058 ,<span class="keywordtype">char</span>** argv |
---|
66 | 00059 ) |
---|
67 | 00060 :fHelp(false) |
---|
68 | 00061 ,fHelpChoice(0) |
---|
69 | 00062 <span class="comment">/***************************************************************************/</span> |
---|
70 | 00064 { |
---|
71 | 00065 G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
72 | 00066 <span class="keywordflow">if</span>(UI!=NULL) UI->SetSession(<span class="keyword">this</span>); |
---|
73 | 00067 |
---|
74 | 00068 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (argc,argv,(<span class="keywordtype">char</span>*)<span class="stringliteral">"Xaw"</span>); |
---|
75 | 00069 Widget top = (Widget)interactorManager-><a class="code" href="classG4VInteractorManager.html#a5">GetMainInteractor</a>(); |
---|
76 | 00070 |
---|
77 | 00071 <a class="code" href="classG4UIXaw.html#r0">shell</a> = XtAppCreateShell (<span class="stringliteral">"G4UIXaw"</span>,<span class="stringliteral">"G4UIXaw"</span>,topLevelShellWidgetClass,XtDisplay(top),NULL,0); |
---|
78 | 00072 |
---|
79 | 00073 Arg args[2]; |
---|
80 | 00074 XtSetArg (args[0],XtNlabel,<span class="stringliteral">"G4 command"</span>); |
---|
81 | 00075 XtSetArg (args[1],XtNvalue,<span class="stringliteral">""</span>); <span class="comment">// Needed to have a text Area.</span> |
---|
82 | 00076 <a class="code" href="classG4UIXaw.html#r1">dialog</a> = XtCreateManagedWidget (<span class="stringliteral">"dialog"</span>,dialogWidgetClass,<a class="code" href="classG4UIXaw.html#r0">shell</a>,args,2); |
---|
83 | 00077 |
---|
84 | 00078 XawDialogAddButton (<a class="code" href="classG4UIXaw.html#r1">dialog</a>,<span class="stringliteral">"Ok"</span>,<a class="code" href="classG4UIXaw.html#h0">Callback</a>,(XtPointer)<span class="keyword">this</span>); |
---|
85 | 00079 |
---|
86 | 00080 XtRealizeWidget (<a class="code" href="classG4UIXaw.html#r0">shell</a>); |
---|
87 | 00081 } |
---|
88 | 00082 <span class="comment">/***************************************************************************/</span> |
---|
89 | <a name="l00083"></a><a class="code" href="classG4UIXaw.html#a1">00083</a> <a class="code" href="classG4UIXaw.html#a1">G4UIXaw::~G4UIXaw</a> ( |
---|
90 | 00084 ) |
---|
91 | 00085 <span class="comment">/***************************************************************************/</span> |
---|
92 | 00087 { |
---|
93 | 00088 XtDestroyWidget (<a class="code" href="classG4UIXaw.html#r0">shell</a>); |
---|
94 | 00089 G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
95 | 00090 <span class="keywordflow">if</span>(UI!=NULL) UI->SetSession(NULL); |
---|
96 | 00091 } |
---|
97 | 00092 <span class="comment">/***************************************************************************/</span> |
---|
98 | <a name="l00093"></a><a class="code" href="classG4UIXaw.html#a2">00093</a> G4UIsession* <a class="code" href="classG4UIXaw.html#a2">G4UIXaw::SessionStart</a> ( |
---|
99 | 00094 ) |
---|
100 | 00095 <span class="comment">/***************************************************************************/</span> |
---|
101 | 00097 { |
---|
102 | 00098 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (); |
---|
103 | 00099 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (<span class="stringliteral">"session"</span>); |
---|
104 | 00100 <a class="code" href="G4UIXaw_8cc.html#a0">exitSession</a> = <span class="keyword">false</span>; |
---|
105 | 00101 interactorManager-><a class="code" href="classG4VInteractorManager.html#a13">DisableSecondaryLoop</a> (); |
---|
106 | 00102 <span class="keywordtype">void</span>* event; |
---|
107 | 00103 <span class="keywordflow">while</span>((event = interactorManager-><a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) { |
---|
108 | 00104 interactorManager-><a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event); |
---|
109 | 00105 <span class="keywordflow">if</span>(<a class="code" href="G4UIXaw_8cc.html#a0">exitSession</a>==<span class="keyword">true</span>) <span class="keywordflow">break</span>; |
---|
110 | 00106 } |
---|
111 | 00107 interactorManager-><a class="code" href="classG4VInteractorManager.html#a12">EnableSecondaryLoop</a> (); |
---|
112 | 00108 <span class="keywordflow">return</span> <span class="keyword">this</span>; |
---|
113 | 00109 } |
---|
114 | 00110 <span class="comment">/***************************************************************************/</span> |
---|
115 | <a name="l00111"></a><a class="code" href="classG4UIXaw.html#a3">00111</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#a3">G4UIXaw::Prompt</a> ( |
---|
116 | 00112 G4String aPrompt |
---|
117 | 00113 ) |
---|
118 | 00114 <span class="comment">/***************************************************************************/</span> |
---|
119 | 00116 { |
---|
120 | 00117 Arg args[1]; |
---|
121 | 00118 XtSetArg (args[0],XtNlabel,aPrompt.data()); |
---|
122 | 00119 XtSetValues (<a class="code" href="classG4UIXaw.html#r1">dialog</a>,args,1); |
---|
123 | 00120 } |
---|
124 | 00121 <span class="comment">/***************************************************************************/</span> |
---|
125 | <a name="l00122"></a><a class="code" href="classG4UIXaw.html#a4">00122</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#a4">G4UIXaw::SessionTerminate</a> ( |
---|
126 | 00123 ) |
---|
127 | 00124 <span class="comment">/***************************************************************************/</span> |
---|
128 | 00126 { |
---|
129 | 00127 } |
---|
130 | 00128 <span class="comment">/***************************************************************************/</span> |
---|
131 | <a name="l00129"></a><a class="code" href="classG4UIXaw.html#a5">00129</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#a5">G4UIXaw::PauseSessionStart</a> ( |
---|
132 | 00130 G4String a_state |
---|
133 | 00131 ) |
---|
134 | 00132 <span class="comment">/***************************************************************************/</span> |
---|
135 | 00134 { |
---|
136 | 00135 <span class="keywordflow">if</span>(a_state==<span class="stringliteral">"G4_pause> "</span>) { |
---|
137 | 00136 <a class="code" href="classG4UIXaw.html#d0">SecondaryLoop</a> (<span class="stringliteral">"Pause, type continue to exit this state"</span>); |
---|
138 | 00137 } |
---|
139 | 00138 |
---|
140 | 00139 <span class="keywordflow">if</span>(a_state==<span class="stringliteral">"EndOfEvent"</span>) { |
---|
141 | 00140 <span class="comment">// Picking with feed back in event data Done here !!!</span> |
---|
142 | 00141 <a class="code" href="classG4UIXaw.html#d0">SecondaryLoop</a> (<span class="stringliteral">"End of event, type continue to exit this state"</span>); |
---|
143 | 00142 } |
---|
144 | 00143 } |
---|
145 | 00144 <span class="comment">/***************************************************************************/</span> |
---|
146 | <a name="l00145"></a><a class="code" href="classG4UIXaw.html#d0">00145</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#d0">G4UIXaw::SecondaryLoop</a> ( |
---|
147 | 00146 G4String a_prompt |
---|
148 | 00147 ) |
---|
149 | 00148 <span class="comment">/***************************************************************************/</span> |
---|
150 | 00150 { |
---|
151 | 00151 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (); |
---|
152 | 00152 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (a_prompt); |
---|
153 | 00153 <a class="code" href="G4UIXaw_8cc.html#a1">exitPause</a> = <span class="keyword">false</span>; |
---|
154 | 00154 <span class="keywordtype">void</span>* event; |
---|
155 | 00155 <span class="keywordflow">while</span>((event = interactorManager-><a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) { |
---|
156 | 00156 interactorManager-><a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event); |
---|
157 | 00157 <span class="keywordflow">if</span>(<a class="code" href="G4UIXaw_8cc.html#a1">exitPause</a>==<span class="keyword">true</span>) <span class="keywordflow">break</span>; |
---|
158 | 00158 } |
---|
159 | 00159 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (<span class="stringliteral">"session"</span>); |
---|
160 | 00160 } |
---|
161 | 00161 <span class="comment">/***************************************************************************/</span> |
---|
162 | <a name="l00162"></a><a class="code" href="classG4UIXaw.html#a6">00162</a> Widget <a class="code" href="classG4UIXaw.html#a6">G4UIXaw::GetDialog</a> ( |
---|
163 | 00163 ) |
---|
164 | 00164 <span class="comment">/***************************************************************************/</span> |
---|
165 | 00166 { |
---|
166 | 00167 <span class="keywordflow">return</span> <a class="code" href="classG4UIXaw.html#r1">dialog</a>; |
---|
167 | 00168 } |
---|
168 | 00169 <span class="comment">/***************************************************************************/</span> |
---|
169 | <a name="l00170"></a><a class="code" href="classG4UIXaw.html#d1">00170</a> G4bool <a class="code" href="classG4UIXaw.html#d1">G4UIXaw::GetHelpChoice</a>( |
---|
170 | 00171 G4int& aInt |
---|
171 | 00172 ) |
---|
172 | 00173 <span class="comment">/***************************************************************************/</span> |
---|
173 | 00175 { |
---|
174 | 00176 <a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <span class="keyword">true</span>; |
---|
175 | 00177 <span class="comment">//</span> |
---|
176 | 00178 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (); |
---|
177 | 00179 <a class="code" href="classG4UIXaw.html#a3">Prompt</a>(<span class="stringliteral">"Help"</span>); |
---|
178 | 00180 <a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a> = <span class="keyword">false</span>; |
---|
179 | 00181 <span class="keywordtype">void</span>* event; |
---|
180 | 00182 <span class="keywordflow">while</span>((event = interactorManager-><a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) { |
---|
181 | 00183 interactorManager-><a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event); |
---|
182 | 00184 <span class="keywordflow">if</span>(<a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a>==<span class="keyword">true</span>) <span class="keywordflow">break</span>; |
---|
183 | 00185 } |
---|
184 | 00186 <a class="code" href="classG4UIXaw.html#a3">Prompt</a>(<span class="stringliteral">"session"</span>); |
---|
185 | 00187 <span class="comment">//</span> |
---|
186 | 00188 <span class="keywordflow">if</span>(<a class="code" href="classG4UIXaw.html#r2">fHelp</a>==<span class="keyword">false</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
187 | 00189 aInt = <a class="code" href="classG4UIXaw.html#r3">fHelpChoice</a>; |
---|
188 | 00190 <a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <span class="keyword">false</span>; |
---|
189 | 00191 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
190 | 00192 } |
---|
191 | 00193 <span class="comment">/***************************************************************************/</span> |
---|
192 | <a name="l00194"></a><a class="code" href="classG4UIXaw.html#d2">00194</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#d2">G4UIXaw::ExitHelp</a>( |
---|
193 | 00195 ) |
---|
194 | 00196 <span class="comment">/***************************************************************************/</span> |
---|
195 | 00198 { |
---|
196 | 00199 } |
---|
197 | 00200 <span class="comment">/***************************************************************************/</span> |
---|
198 | 00201 <span class="comment">/***************************************************************************/</span> |
---|
199 | 00202 <span class="comment">/***************************************************************************/</span> |
---|
200 | <a name="l00203"></a><a class="code" href="classG4UIXaw.html#h0">00203</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIXaw.html#h0">G4UIXaw::Callback</a> ( |
---|
201 | 00204 Widget a_widget |
---|
202 | 00205 ,XtPointer a_tag |
---|
203 | 00206 ,XtPointer a_data |
---|
204 | 00207 ) |
---|
205 | 00208 <span class="comment">/***************************************************************************/</span> |
---|
206 | 00210 { |
---|
207 | 00211 <a class="code" href="classG4UIXaw.html">G4UIXaw</a>* This = (<a class="code" href="classG4UIXaw.html">G4UIXaw</a>*)a_tag; |
---|
208 | 00212 Widget <a class="code" href="classG4UIXaw.html#r1">dialog</a> = This-><a class="code" href="classG4UIXaw.html#a6">GetDialog</a>(); |
---|
209 | 00213 <span class="keywordtype">char</span>* value = XawDialogGetValueString(dialog); |
---|
210 | 00214 <span class="keywordflow">if</span>(value==NULL) <span class="keywordflow">return</span>; |
---|
211 | 00215 G4String command (value); |
---|
212 | 00216 |
---|
213 | 00217 <span class="keywordflow">if</span>(This-><a class="code" href="classG4UIXaw.html#r2">fHelp</a>==<span class="keyword">true</span>) { |
---|
214 | 00218 <a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a> = <span class="keyword">true</span>; |
---|
215 | 00219 This-><a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <a class="code" href="G4UIXm_8cc.html#a6">ConvertStringToInt</a>(command.data(),This-><a class="code" href="classG4UIXaw.html#r3">fHelpChoice</a>); |
---|
216 | 00220 } <span class="keywordflow">else</span> { |
---|
217 | 00221 This-><a class="code" href="classG4VBasicShell.html#b10">ApplyShellCommand</a> (command,<a class="code" href="G4UIXaw_8cc.html#a0">exitSession</a>,<a class="code" href="G4UIXaw_8cc.html#a1">exitPause</a>); |
---|
218 | 00222 } |
---|
219 | 00223 |
---|
220 | 00224 Arg args[1]; |
---|
221 | 00225 XtSetArg (args[0],XtNvalue,<span class="stringliteral">""</span>); |
---|
222 | 00226 XtSetValues (dialog,args,1); |
---|
223 | 00227 |
---|
224 | 00228 a_widget = NULL; |
---|
225 | 00229 a_data = NULL; |
---|
226 | 00230 } |
---|
227 | <a name="l00232"></a><a class="code" href="G4UIXaw_8cc.html#a3">00232</a> G4bool <a class="code" href="G4UIXm_8cc.html#a6">ConvertStringToInt</a>( |
---|
228 | 00233 <span class="keyword">const</span> <span class="keywordtype">char</span>* aString |
---|
229 | 00234 ,<span class="keywordtype">int</span>& aInt |
---|
230 | 00235 ) |
---|
231 | 00238 { |
---|
232 | 00239 aInt = 0; |
---|
233 | 00240 <span class="keywordflow">if</span>(aString==NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
234 | 00241 <span class="keywordtype">char</span>* s; |
---|
235 | 00242 <span class="keywordtype">long</span> value = strtol(aString,&s,10); |
---|
236 | 00243 <span class="keywordflow">if</span>(s==aString) <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
237 | 00244 aInt = value; |
---|
238 | 00245 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
239 | 00246 } |
---|
240 | 00247 |
---|
241 | 00248 <span class="preprocessor">#endif</span> |
---|
242 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by |
---|
243 | <a href="http://www.doxygen.org/index.html"> |
---|
244 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
---|
245 | </a>1.3.4 </small></address> |
---|
246 | </body> |
---|
247 | </html> |
---|