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 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>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> |
---|
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: G4Xt.cc,v 1.11 2006/06/29 19:10:28 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="preprocessor">#if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)</span> |
---|
40 | 00033 <span class="preprocessor"></span> |
---|
41 | 00034 <span class="preprocessor">#include <stdlib.h></span> |
---|
42 | 00035 <span class="preprocessor">#include <string.h></span> |
---|
43 | 00036 |
---|
44 | 00037 <span class="preprocessor">#include <X11/Intrinsic.h></span> |
---|
45 | 00038 <span class="preprocessor">#include <X11/Shell.h></span> |
---|
46 | 00039 |
---|
47 | 00040 <span class="preprocessor">#include "G4ios.hh"</span> |
---|
48 | 00041 |
---|
49 | 00042 <span class="preprocessor">#include "<a class="code" href="G4Xt_8hh.html">G4Xt.hh</a>"</span> |
---|
50 | 00043 |
---|
51 | 00044 <span class="preprocessor">#define NewString(str) \</span> |
---|
52 | 00045 <span class="preprocessor"> ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)</span> |
---|
53 | 00046 <span class="preprocessor"></span> |
---|
54 | 00047 <span class="comment">//static void XWidgetIconify (Widget);</span> |
---|
55 | 00048 <span class="comment">//static void XWidgetUniconify (Widget);</span> |
---|
56 | 00049 <span class="comment">//static void XDisplaySetWindowToNormalState (Display*,Window);</span> |
---|
57 | 00050 |
---|
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; |
---|
59 | 00052 |
---|
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; |
---|
65 | 00058 <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> ( |
---|
67 | 00060 ) |
---|
68 | 00061 <span class="comment">/***************************************************************************/</span> |
---|
69 | 00063 { |
---|
70 | 00064 <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>); |
---|
71 | 00065 } |
---|
72 | 00066 <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> ( |
---|
74 | 00068 <span class="keywordtype">int</span> a_argn |
---|
75 | 00069 ,<span class="keywordtype">char</span>** a_args |
---|
76 | 00070 ,<span class="keywordtype">char</span>* a_class |
---|
77 | 00071 ) |
---|
78 | 00072 <span class="comment">/***************************************************************************/</span> |
---|
79 | 00074 { |
---|
80 | 00075 <span class="keywordflow">if</span> (<a class="code" href="classG4Xt.html#v0">instance</a>==NULL) { |
---|
81 | 00076 <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); |
---|
82 | 00077 } |
---|
83 | 00078 <span class="keywordflow">return</span> <a class="code" href="classG4Xt.html#v0">instance</a>; |
---|
84 | 00079 } |
---|
85 | 00080 <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> ( |
---|
87 | 00082 <span class="keywordtype">int</span> a_argn |
---|
88 | 00083 ,<span class="keywordtype">char</span>** a_args |
---|
89 | 00084 ,<span class="keywordtype">char</span>* a_class |
---|
90 | 00085 ) |
---|
91 | 00086 <span class="comment">/***************************************************************************/</span> |
---|
92 | 00088 { |
---|
93 | 00089 <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> |
---|
94 | 00090 <span class="keywordflow">if</span>(a_argn!=0) { <span class="comment">//Save args.</span> |
---|
95 | 00091 <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>*)); |
---|
96 | 00092 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a2">args</a>!=NULL) { |
---|
97 | 00093 <a class="code" href="G4Xt_8cc.html#a1">argn</a> = a_argn; |
---|
98 | 00094 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> argi=0;argi<a_argn;argi++) { |
---|
99 | 00095 <a class="code" href="G4Xt_8cc.html#a2">args</a>[argi] = (<span class="keywordtype">char</span>*)NewString (a_args[argi]); |
---|
100 | 00096 } |
---|
101 | 00097 } |
---|
102 | 00098 } |
---|
103 | 00099 <span class="preprocessor">#if XtSpecificationRelease == 4</span> |
---|
104 | 00100 <span class="preprocessor"></span> Cardinal narg; |
---|
105 | 00101 narg = (Cardinal)a_argn; |
---|
106 | 00102 <span class="preprocessor">#else</span> |
---|
107 | 00103 <span class="preprocessor"></span> <span class="keywordtype">int</span> narg; |
---|
108 | 00104 narg = a_argn; |
---|
109 | 00105 <span class="preprocessor">#endif</span> |
---|
110 | 00106 <span class="preprocessor"></span> Arg xargs[1]; |
---|
111 | 00107 XtSetArg (xargs[0],XtNgeometry,<span class="stringliteral">"100x100"</span>); |
---|
112 | 00108 <a class="code" href="G4Xt_8cc.html#a4">topWidget</a> = XtAppInitialize (&<a class="code" href="G4Xt_8cc.html#a3">appContext</a>,a_class, |
---|
113 | 00109 NULL,(Cardinal)0, |
---|
114 | 00110 &narg,a_args,NULL, |
---|
115 | 00111 xargs,1); |
---|
116 | 00112 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) { |
---|
117 | 00113 G4cout << <span class="stringliteral">"G4Xt : Unable to init Xt."</span> << G4endl; |
---|
118 | 00114 } |
---|
119 | 00115 <span class="comment">// Restore a_args. XtAppInitialize corrupts the given ones !!!</span> |
---|
120 | 00116 <span class="keywordflow">if</span>( (a_argn!=0) && (<a class="code" href="G4Xt_8cc.html#a2">args</a>!=NULL)) { |
---|
121 | 00117 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> argi=0;argi<a_argn;argi++) { |
---|
122 | 00118 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a2">args</a>[argi]!=NULL) |
---|
123 | 00119 strcpy(a_args[argi],<a class="code" href="G4Xt_8cc.html#a2">args</a>[argi]); |
---|
124 | 00120 <span class="keywordflow">else</span> |
---|
125 | 00121 a_args[argi] = NULL; |
---|
126 | 00122 } |
---|
127 | 00123 } |
---|
128 | 00124 <span class="comment">// If topWidget not realized, pbs with Inventor shells.</span> |
---|
129 | 00125 XtSetMappedWhenManaged (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>,False); |
---|
130 | 00126 XtRealizeWidget (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>); |
---|
131 | 00127 <a class="code" href="G4Xt_8cc.html#a0">XtInited</a> = TRUE; |
---|
132 | 00128 } |
---|
133 | 00129 <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>); |
---|
134 | 00130 <a class="code" href="classG4VInteractorManager.html#a4">SetMainInteractor</a> (<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>); |
---|
135 | 00131 <a class="code" href="classG4VInteractorManager.html#a6">AddDispatcher</a> ((<a class="code" href="G4VInteractorManager_8hh.html#a1">G4DispatchFunction</a>)XtDispatchEvent); |
---|
136 | 00132 } |
---|
137 | 00133 <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> ( |
---|
139 | 00135 ) |
---|
140 | 00136 <span class="comment">/***************************************************************************/</span> |
---|
141 | 00138 { |
---|
142 | 00139 <span class="keywordflow">if</span>(<span class="keyword">this</span>==<a class="code" href="classG4Xt.html#v0">instance</a>) { |
---|
143 | 00140 <a class="code" href="classG4Xt.html#v0">instance</a> = NULL; |
---|
144 | 00141 } |
---|
145 | 00142 } |
---|
146 | 00143 <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> ( |
---|
148 | 00145 ) |
---|
149 | 00146 <span class="comment">/***************************************************************************/</span> |
---|
150 | 00148 { |
---|
151 | 00149 <span class="keywordflow">return</span> <a class="code" href="G4Xt_8cc.html#a0">XtInited</a>; |
---|
152 | 00150 } |
---|
153 | 00151 <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> ( |
---|
155 | 00153 ) |
---|
156 | 00154 <span class="comment">/***************************************************************************/</span> |
---|
157 | 00156 { |
---|
158 | 00157 <span class="keyword">static</span> XEvent event; |
---|
159 | 00158 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a3">appContext</a>==NULL) <span class="keywordflow">return</span> NULL; |
---|
160 | 00159 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span> NULL; |
---|
161 | 00160 XtAppNextEvent (<a class="code" href="G4Xt_8cc.html#a3">appContext</a>, &event); |
---|
162 | 00161 <span class="keywordflow">return</span> &event; |
---|
163 | 00162 } |
---|
164 | 00163 <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> ( |
---|
166 | 00165 <span class="keywordtype">char</span>* a_string |
---|
167 | 00166 ) |
---|
168 | 00167 <span class="comment">/***************************************************************************/</span> |
---|
169 | 00169 { |
---|
170 | 00170 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span>; |
---|
171 | 00171 <span class="keywordflow">if</span>(a_string==NULL) <span class="keywordflow">return</span>; |
---|
172 | 00172 Display* dpy = XtDisplay(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>); |
---|
173 | 00173 XrmDatabase dbres = XrmGetStringDatabase (a_string); |
---|
174 | 00174 <span class="keywordflow">if</span>(dbres==NULL) <span class="keywordflow">return</span>; |
---|
175 | 00175 XrmDatabase database = XrmGetDatabase (dpy); |
---|
176 | 00176 <span class="keywordflow">if</span>(database!=NULL) { |
---|
177 | 00177 XrmMergeDatabases (dbres,&database); |
---|
178 | 00178 } <span class="keywordflow">else</span> { |
---|
179 | 00179 XrmSetDatabase (dpy,dbres); |
---|
180 | 00180 } |
---|
181 | 00181 } |
---|
182 | 00182 <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> ( |
---|
184 | 00184 ) |
---|
185 | 00185 <span class="comment">/***************************************************************************/</span> |
---|
186 | 00187 { |
---|
187 | 00188 <span class="keywordflow">if</span>(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>==NULL) <span class="keywordflow">return</span>; |
---|
188 | 00189 XSync(XtDisplay(<a class="code" href="G4Xt_8cc.html#a4">topWidget</a>),False); |
---|
189 | 00190 } |
---|
190 | 00191 |
---|
191 | 00192 <span class="preprocessor">#endif</span> |
---|
192 | 00193 <span class="preprocessor"></span> |
---|
193 | 00194 |
---|
194 | 00195 |
---|
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> |
---|