source: trunk/geant4/interfaces/html/G4Xt_8cc-source.html@ 790

Last change on this file since 790 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: 15.7 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>G4Xt.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>G4Xt.cc</h1><a href="G4Xt_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: G4Xt.cc,v 1.11 2006/06/29 19:10:28 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="preprocessor">#if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)</span>
4000033 <span class="preprocessor"></span>
4100034 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
4200035 <span class="preprocessor">#include &lt;string.h&gt;</span>
4300036
4400037 <span class="preprocessor">#include &lt;X11/Intrinsic.h&gt;</span>
4500038 <span class="preprocessor">#include &lt;X11/Shell.h&gt;</span>
4600039
4700040 <span class="preprocessor">#include "G4ios.hh"</span>
4800041
4900042 <span class="preprocessor">#include "<a class="code" href="G4Xt_8hh.html">G4Xt.hh</a>"</span>
5000043
5100044 <span class="preprocessor">#define NewString(str) \</span>
5200045 <span class="preprocessor"> ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)</span>
5300046 <span class="preprocessor"></span>
5400047 <span class="comment">//static void XWidgetIconify (Widget);</span>
5500048 <span class="comment">//static void XWidgetUniconify (Widget);</span>
5600049 <span class="comment">//static void XDisplaySetWindowToNormalState (Display*,Window);</span>
5700050
58<a name="l00051"></a><a class="code" href="classG4Xt.html#v0">00051</a> <a class="code" href="classG4Xt.html">G4Xt</a>* <a class="code" href="classG4Xt.html#v0">G4Xt::instance</a> = NULL;
5900052
60<a name="l00053"></a><a class="code" href="G4Xt_8cc.html#a0">00053</a> <span class="keyword">static</span> G4bool <a class="code" href="G4Xt_8cc.html#a0">XtInited</a> = FALSE;
61<a name="l00054"></a><a class="code" href="G4Xt_8cc.html#a1">00054</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="G4Xt_8cc.html#a1">argn</a> = 0;
62<a name="l00055"></a><a class="code" href="G4Xt_8cc.html#a2">00055</a> <span class="keyword">static</span> <span class="keywordtype">char</span>** <a class="code" href="G4Xt_8cc.html#a2">args</a> = NULL;
63<a name="l00056"></a><a class="code" href="G4Xt_8cc.html#a3">00056</a> <span class="keyword">static</span> XtAppContext <a class="code" href="G4Xt_8cc.html#a3">appContext</a> = NULL;
64<a name="l00057"></a><a class="code" href="G4Xt_8cc.html#a4">00057</a> <span class="keyword">static</span> Widget <a class="code" href="G4Xt_8cc.html#a4">topWidget</a> = NULL;
6500058 <span class="comment">/***************************************************************************/</span>
66<a name="l00059"></a><a class="code" href="classG4Xt.html#e0">00059</a> <a class="code" href="classG4Xt.html">G4Xt</a>* <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (
6700060 )
6800061 <span class="comment">/***************************************************************************/</span>
6900063 {
7000064 <span class="keywordflow">return</span> <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (0,NULL,(<span class="keywordtype">char</span>*)<span class="stringliteral">"Geant4"</span>);
7100065 }
7200066 <span class="comment">/***************************************************************************/</span>
73<a name="l00067"></a><a class="code" href="classG4Xt.html#e1">00067</a> <a class="code" href="classG4Xt.html">G4Xt</a>* <a class="code" href="classG4Xt.html#e0">G4Xt::getInstance</a> (
7400068 <span class="keywordtype">int</span> a_argn
7500069 ,<span class="keywordtype">char</span>** a_args
7600070 ,<span class="keywordtype">char</span>* a_class
7700071 )
7800072 <span class="comment">/***************************************************************************/</span>
7900074 {
8000075 <span class="keywordflow">if</span> (<a class="code" href="classG4Xt.html#v0">instance</a>==NULL) {
8100076 <a class="code" href="classG4Xt.html#v0">instance</a> = <span class="keyword">new</span> <a class="code" href="classG4Xt.html#d0">G4Xt</a>(a_argn,a_args,a_class);
8200077 }
8300078 <span class="keywordflow">return</span> <a class="code" href="classG4Xt.html#v0">instance</a>;
8400079 }
8500080 <span class="comment">/***************************************************************************/</span>
86<a name="l00081"></a><a class="code" href="classG4Xt.html#d0">00081</a> <a class="code" href="classG4Xt.html#d0">G4Xt::G4Xt</a> (
8700082 <span class="keywordtype">int</span> a_argn
8800083 ,<span class="keywordtype">char</span>** a_args
8900084 ,<span class="keywordtype">char</span>* a_class
9000085 )
9100086 <span class="comment">/***************************************************************************/</span>
9200088 {
9300089 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a0">XtInited</a>==FALSE) { <span class="comment">//Xt should be Inited once !</span>
9400090 <span class="keywordflow">if</span>(a_argn!=0) { <span class="comment">//Save args.</span>
9500091 <a class="code" href="G4Xt_8cc.html#a2">args</a> = (<span class="keywordtype">char</span>**)malloc(a_argn * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>*));
9600092 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a2">args</a>!=NULL) {
9700093 <a class="code" href="G4Xt_8cc.html#a1">argn</a> = a_argn;
9800094 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> argi=0;argi&lt;a_argn;argi++) {
9900095 <a class="code" href="G4Xt_8cc.html#a2">args</a>[argi] = (<span class="keywordtype">char</span>*)NewString (a_args[argi]);
10000096 }
10100097 }
10200098 }
10300099 <span class="preprocessor">#if XtSpecificationRelease == 4</span>
10400100 <span class="preprocessor"></span> Cardinal narg;
10500101 narg = (Cardinal)a_argn;
10600102 <span class="preprocessor">#else</span>
10700103 <span class="preprocessor"></span> <span class="keywordtype">int</span> narg;
10800104 narg = a_argn;
10900105 <span class="preprocessor">#endif</span>
11000106 <span class="preprocessor"></span> Arg xargs[1];
11100107 XtSetArg (xargs[0],XtNgeometry,<span class="stringliteral">"100x100"</span>);
11200108 <a class="code" href="G4Xt_8cc.html#a4">topWidget</a> = XtAppInitialize (&amp;<a class="code" href="G4Xt_8cc.html#a3">appContext</a>,a_class,
11300109 NULL,(Cardinal)0,
11400110 &amp;narg,a_args,NULL,
11500111 xargs,1);
11600112 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) {
11700113 G4cout &lt;&lt; <span class="stringliteral">"G4Xt : Unable to init Xt."</span> &lt;&lt; G4endl;
11800114 }
11900115 <span class="comment">// Restore a_args. XtAppInitialize corrupts the given ones !!!</span>
12000116 <span class="keywordflow">if</span>( (a_argn!=0) &amp;&amp; (<a class="code" href="G4Xt_8cc.html#a2">args</a>!=NULL)) {
12100117 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> argi=0;argi&lt;a_argn;argi++) {
12200118 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a2">args</a>[argi]!=NULL)
12300119 strcpy(a_args[argi],<a class="code" href="G4Xt_8cc.html#a2">args</a>[argi]);
12400120 <span class="keywordflow">else</span>
12500121 a_args[argi] = NULL;
12600122 }
12700123 }
12800124 <span class="comment">// If topWidget not realized, pbs with Inventor shells.</span>
12900125 XtSetMappedWhenManaged (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>,False);
13000126 XtRealizeWidget (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>);
13100127 <a class="code" href="G4Xt_8cc.html#a0">XtInited</a> = TRUE;
13200128 }
13300129 <a class="code" href="classG4VInteractorManager.html#a2">SetArguments</a> (<a class="code" href="G4Xt_8cc.html#a1">argn</a>,<a class="code" href="G4Xt_8cc.html#a2">args</a>);
13400130 <a class="code" href="classG4VInteractorManager.html#a4">SetMainInteractor</a> (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>);
13500131 <a class="code" href="classG4VInteractorManager.html#a6">AddDispatcher</a> ((<a class="code" href="G4VInteractorManager_8hh.html#a1">G4DispatchFunction</a>)XtDispatchEvent);
13600132 }
13700133 <span class="comment">/***************************************************************************/</span>
138<a name="l00134"></a><a class="code" href="classG4Xt.html#a4">00134</a> <a class="code" href="classG4Xt.html#a4">G4Xt::~G4Xt</a> (
13900135 )
14000136 <span class="comment">/***************************************************************************/</span>
14100138 {
14200139 <span class="keywordflow">if</span>(<span class="keyword">this</span>==<a class="code" href="classG4Xt.html#v0">instance</a>) {
14300140 <a class="code" href="classG4Xt.html#v0">instance</a> = NULL;
14400141 }
14500142 }
14600143 <span class="comment">/***************************************************************************/</span>
147<a name="l00144"></a><a class="code" href="classG4Xt.html#a1">00144</a> G4bool <a class="code" href="classG4Xt.html#a1">G4Xt::Inited</a> (
14800145 )
14900146 <span class="comment">/***************************************************************************/</span>
15000148 {
15100149 <span class="keywordflow">return</span> <a class="code" href="G4Xt_8cc.html#a0">XtInited</a>;
15200150 }
15300151 <span class="comment">/***************************************************************************/</span>
154<a name="l00152"></a><a class="code" href="classG4Xt.html#a2">00152</a> <span class="keywordtype">void</span>* <a class="code" href="classG4Xt.html#a2">G4Xt::GetEvent</a> (
15500153 )
15600154 <span class="comment">/***************************************************************************/</span>
15700156 {
15800157 <span class="keyword">static</span> XEvent event;
15900158 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a3">appContext</a>==NULL) <span class="keywordflow">return</span> NULL;
16000159 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span> NULL;
16100160 XtAppNextEvent (<a class="code" href="G4Xt_8cc.html#a3">appContext</a>, &amp;event);
16200161 <span class="keywordflow">return</span> &amp;event;
16300162 }
16400163 <span class="comment">/***************************************************************************/</span>
165<a name="l00164"></a><a class="code" href="classG4Xt.html#a0">00164</a> <span class="keywordtype">void</span> <a class="code" href="classG4Xt.html#a0">G4Xt::PutStringInResourceDatabase</a> (
16600165 <span class="keywordtype">char</span>* a_string
16700166 )
16800167 <span class="comment">/***************************************************************************/</span>
16900169 {
17000170 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span>;
17100171 <span class="keywordflow">if</span>(a_string==NULL) <span class="keywordflow">return</span>;
17200172 Display* dpy = XtDisplay(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>);
17300173 XrmDatabase dbres = XrmGetStringDatabase (a_string);
17400174 <span class="keywordflow">if</span>(dbres==NULL) <span class="keywordflow">return</span>;
17500175 XrmDatabase database = XrmGetDatabase (dpy);
17600176 <span class="keywordflow">if</span>(database!=NULL) {
17700177 XrmMergeDatabases (dbres,&amp;database);
17800178 } <span class="keywordflow">else</span> {
17900179 XrmSetDatabase (dpy,dbres);
18000180 }
18100181 }
18200182 <span class="comment">/***************************************************************************/</span>
183<a name="l00183"></a><a class="code" href="classG4Xt.html#a3">00183</a> <span class="keywordtype">void</span> <a class="code" href="classG4Xt.html#a3">G4Xt::FlushAndWaitExecution</a> (
18400184 )
18500185 <span class="comment">/***************************************************************************/</span>
18600187 {
18700188 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span>;
18800189 XSync(XtDisplay(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>),False);
18900190 }
19000191
19100192 <span class="preprocessor">#endif</span>
19200193 <span class="preprocessor"></span>
19300194
19400195
195</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:03 2007 by
196<a href="http://www.doxygen.org/index.html">
197<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
198</a>1.3.4 </small></address>
199</body>
200</html>
Note: See TracBrowser for help on using the repository browser.