source: trunk/source/interfaces/html/G4UIXaw_8cc-source.html@ 806

Last change on this file since 806 was 571, checked in by garnier, 18 years ago

r581@mac-90108: laurentgarnier | 2007-08-17 17:30:26 +0200
deplacement de frame

  • Property svn:mime-type set to text/html
File size: 19.4 KB
Line 
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&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;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>
900002 <span class="comment">// ********************************************************************</span>
1000003 <span class="comment">// * License and Disclaimer *</span>
1100004 <span class="comment">// * *</span>
1200005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span>
1300006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span>
1400007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span>
1500008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span>
1600009 <span class="comment">// * include a list of copyright holders. *</span>
1700010 <span class="comment">// * *</span>
1800011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span>
1900012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span>
2000013 <span class="comment">// * work make any representation or warranty, express or implied, *</span>
2100014 <span class="comment">// * regarding this software system or assume any liability for its *</span>
2200015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span>
2300016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span>
2400017 <span class="comment">// * *</span>
2500018 <span class="comment">// * This code implementation is the result of the scientific and *</span>
2600019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span>
2700020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span>
2800021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span>
2900022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span>
3000023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span>
3100024 <span class="comment">// ********************************************************************</span>
3200025 <span class="comment">//</span>
3300026 <span class="comment">//</span>
3400027 <span class="comment">// $Id: G4UIXaw.cc,v 1.6 2006/06/29 19:09:47 gunter Exp $</span>
3500028 <span class="comment">// GEANT4 tag $Name: geant4-08-01-patch-01 $</span>
3600029 <span class="comment">//</span>
3700030 <span class="comment">// G.Barrand</span>
3800031
3900032 <span class="comment">//#define DEBUG</span>
4000033
4100034 <span class="preprocessor">#ifdef G4UI_BUILD_XAW_SESSION</span>
4200035 <span class="preprocessor"></span>
4300036 <span class="preprocessor">#include &lt;X11/Intrinsic.h&gt;</span>
4400037 <span class="preprocessor">#include &lt;X11/StringDefs.h&gt;</span>
4500038 <span class="preprocessor">#include &lt;X11/Shell.h&gt;</span>
4600039
4700040 <span class="preprocessor">#include &lt;Xaw/Dialog.h&gt;</span>
4800041 <span class="preprocessor">#include &lt;Xaw/Command.h&gt;</span>
4900042
5000043 <span class="preprocessor">#include "<a class="code" href="G4UIXaw_8hh.html">G4UIXaw.hh</a>"</span>
5100044 <span class="preprocessor">#include "G4UImanager.hh"</span>
5200045 <span class="preprocessor">#include "G4StateManager.hh"</span>
5300046 <span class="preprocessor">#include "G4UIcommandTree.hh"</span>
5400047 <span class="preprocessor">#include "G4UIcommandStatus.hh"</span>
5500048 <span class="preprocessor">#include "<a class="code" href="G4Xt_8hh.html">G4Xt.hh</a>"</span>
5600049
5700050 <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>&amp;);
5800051
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>;
6200055 <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> (
6400057 <span class="keywordtype">int</span> argc
6500058 ,<span class="keywordtype">char</span>** argv
6600059 )
6700060 :fHelp(false)
6800061 ,fHelpChoice(0)
6900062 <span class="comment">/***************************************************************************/</span>
7000064 {
7100065 G4UImanager* UI = G4UImanager::GetUIpointer();
7200066 <span class="keywordflow">if</span>(UI!=NULL) UI-&gt;SetSession(<span class="keyword">this</span>);
7300067
7400068 <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>);
7500069 Widget top = (Widget)interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a5">GetMainInteractor</a>();
7600070
7700071 <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);
7800072
7900073 Arg args[2];
8000074 XtSetArg (args[0],XtNlabel,<span class="stringliteral">"G4 command"</span>);
8100075 XtSetArg (args[1],XtNvalue,<span class="stringliteral">""</span>); <span class="comment">// Needed to have a text Area.</span>
8200076 <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);
8300077
8400078 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>);
8500079
8600080 XtRealizeWidget (<a class="code" href="classG4UIXaw.html#r0">shell</a>);
8700081 }
8800082 <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> (
9000084 )
9100085 <span class="comment">/***************************************************************************/</span>
9200087 {
9300088 XtDestroyWidget (<a class="code" href="classG4UIXaw.html#r0">shell</a>);
9400089 G4UImanager* UI = G4UImanager::GetUIpointer();
9500090 <span class="keywordflow">if</span>(UI!=NULL) UI-&gt;SetSession(NULL);
9600091 }
9700092 <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> (
9900094 )
10000095 <span class="comment">/***************************************************************************/</span>
10100097 {
10200098 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> ();
10300099 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (<span class="stringliteral">"session"</span>);
10400100 <a class="code" href="G4UIXaw_8cc.html#a0">exitSession</a> = <span class="keyword">false</span>;
10500101 interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a13">DisableSecondaryLoop</a> ();
10600102 <span class="keywordtype">void</span>* event;
10700103 <span class="keywordflow">while</span>((event = interactorManager-&gt;<a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) {
10800104 interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event);
10900105 <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>;
11000106 }
11100107 interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a12">EnableSecondaryLoop</a> ();
11200108 <span class="keywordflow">return</span> <span class="keyword">this</span>;
11300109 }
11400110 <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> (
11600112 G4String aPrompt
11700113 )
11800114 <span class="comment">/***************************************************************************/</span>
11900116 {
12000117 Arg args[1];
12100118 XtSetArg (args[0],XtNlabel,aPrompt.data());
12200119 XtSetValues (<a class="code" href="classG4UIXaw.html#r1">dialog</a>,args,1);
12300120 }
12400121 <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> (
12600123 )
12700124 <span class="comment">/***************************************************************************/</span>
12800126 {
12900127 }
13000128 <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> (
13200130 G4String a_state
13300131 )
13400132 <span class="comment">/***************************************************************************/</span>
13500134 {
13600135 <span class="keywordflow">if</span>(a_state==<span class="stringliteral">"G4_pause&gt; "</span>) {
13700136 <a class="code" href="classG4UIXaw.html#d0">SecondaryLoop</a> (<span class="stringliteral">"Pause, type continue to exit this state"</span>);
13800137 }
13900138
14000139 <span class="keywordflow">if</span>(a_state==<span class="stringliteral">"EndOfEvent"</span>) {
14100140 <span class="comment">// Picking with feed back in event data Done here !!!</span>
14200141 <a class="code" href="classG4UIXaw.html#d0">SecondaryLoop</a> (<span class="stringliteral">"End of event, type continue to exit this state"</span>);
14300142 }
14400143 }
14500144 <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> (
14700146 G4String a_prompt
14800147 )
14900148 <span class="comment">/***************************************************************************/</span>
15000150 {
15100151 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> ();
15200152 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (a_prompt);
15300153 <a class="code" href="G4UIXaw_8cc.html#a1">exitPause</a> = <span class="keyword">false</span>;
15400154 <span class="keywordtype">void</span>* event;
15500155 <span class="keywordflow">while</span>((event = interactorManager-&gt;<a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) {
15600156 interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event);
15700157 <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>;
15800158 }
15900159 <a class="code" href="classG4UIXaw.html#a3">Prompt</a> (<span class="stringliteral">"session"</span>);
16000160 }
16100161 <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> (
16300163 )
16400164 <span class="comment">/***************************************************************************/</span>
16500166 {
16600167 <span class="keywordflow">return</span> <a class="code" href="classG4UIXaw.html#r1">dialog</a>;
16700168 }
16800169 <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>(
17000171 G4int&amp; aInt
17100172 )
17200173 <span class="comment">/***************************************************************************/</span>
17300175 {
17400176 <a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <span class="keyword">true</span>;
17500177 <span class="comment">//</span>
17600178 <a class="code" href="classG4Xt.html">G4Xt</a>* interactorManager = <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> ();
17700179 <a class="code" href="classG4UIXaw.html#a3">Prompt</a>(<span class="stringliteral">"Help"</span>);
17800180 <a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a> = <span class="keyword">false</span>;
17900181 <span class="keywordtype">void</span>* event;
18000182 <span class="keywordflow">while</span>((event = interactorManager-&gt;<a class="code" href="classG4Xt.html#a2">GetEvent</a>())!=NULL) {
18100183 interactorManager-&gt;<a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event);
18200184 <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>;
18300185 }
18400186 <a class="code" href="classG4UIXaw.html#a3">Prompt</a>(<span class="stringliteral">"session"</span>);
18500187 <span class="comment">//</span>
18600188 <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>;
18700189 aInt = <a class="code" href="classG4UIXaw.html#r3">fHelpChoice</a>;
18800190 <a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <span class="keyword">false</span>;
18900191 <span class="keywordflow">return</span> <span class="keyword">true</span>;
19000192 }
19100193 <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>(
19300195 )
19400196 <span class="comment">/***************************************************************************/</span>
19500198 {
19600199 }
19700200 <span class="comment">/***************************************************************************/</span>
19800201 <span class="comment">/***************************************************************************/</span>
19900202 <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> (
20100204 Widget a_widget
20200205 ,XtPointer a_tag
20300206 ,XtPointer a_data
20400207 )
20500208 <span class="comment">/***************************************************************************/</span>
20600210 {
20700211 <a class="code" href="classG4UIXaw.html">G4UIXaw</a>* This = (<a class="code" href="classG4UIXaw.html">G4UIXaw</a>*)a_tag;
20800212 Widget <a class="code" href="classG4UIXaw.html#r1">dialog</a> = This-&gt;<a class="code" href="classG4UIXaw.html#a6">GetDialog</a>();
20900213 <span class="keywordtype">char</span>* value = XawDialogGetValueString(dialog);
21000214 <span class="keywordflow">if</span>(value==NULL) <span class="keywordflow">return</span>;
21100215 G4String command (value);
21200216
21300217 <span class="keywordflow">if</span>(This-&gt;<a class="code" href="classG4UIXaw.html#r2">fHelp</a>==<span class="keyword">true</span>) {
21400218 <a class="code" href="G4UIXaw_8cc.html#a2">exitHelp</a> = <span class="keyword">true</span>;
21500219 This-&gt;<a class="code" href="classG4UIXaw.html#r2">fHelp</a> = <a class="code" href="G4UIXm_8cc.html#a6">ConvertStringToInt</a>(command.data(),This-&gt;<a class="code" href="classG4UIXaw.html#r3">fHelpChoice</a>);
21600220 } <span class="keywordflow">else</span> {
21700221 This-&gt;<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>);
21800222 }
21900223
22000224 Arg args[1];
22100225 XtSetArg (args[0],XtNvalue,<span class="stringliteral">""</span>);
22200226 XtSetValues (dialog,args,1);
22300227
22400228 a_widget = NULL;
22500229 a_data = NULL;
22600230 }
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>(
22800233 <span class="keyword">const</span> <span class="keywordtype">char</span>* aString
22900234 ,<span class="keywordtype">int</span>&amp; aInt
23000235 )
23100238 {
23200239 aInt = 0;
23300240 <span class="keywordflow">if</span>(aString==NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>;
23400241 <span class="keywordtype">char</span>* s;
23500242 <span class="keywordtype">long</span> value = strtol(aString,&amp;s,10);
23600243 <span class="keywordflow">if</span>(s==aString) <span class="keywordflow">return</span> <span class="keyword">false</span>;
23700244 aInt = value;
23800245 <span class="keywordflow">return</span> <span class="keyword">true</span>;
23900246 }
24000247
24100248 <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>
Note: See TracBrowser for help on using the repository browser.