| 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>G4Win32.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>G4Win32.cc</h1><a href="G4Win32_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: G4Win32.cc,v 1.9 2006/06/29 19:10:26 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_WIN32) || defined(G4INTY_USE_WIN32)</span>
|
|---|
| 40 | 00033 <span class="preprocessor"></span>
|
|---|
| 41 | 00034 <span class="comment">// this :</span>
|
|---|
| 42 | 00035 <span class="preprocessor">#include "<a class="code" href="G4Win32_8hh.html">G4Win32.hh</a>"</span>
|
|---|
| 43 | 00036
|
|---|
| 44 | 00037 <span class="preprocessor">#include "G4ios.hh"</span>
|
|---|
| 45 | 00038
|
|---|
| 46 | <a name="l00039"></a><a class="code" href="G4Win32_8cc.html#a0">00039</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="G4Win32_8cc.html#a0">className</a>[] = <span class="stringliteral">"G4Win32"</span>;
|
|---|
| 47 | 00040
|
|---|
| 48 | <a name="l00041"></a><a class="code" href="classG4Win32.html#v0">00041</a> <a class="code" href="classG4Win32.html">G4Win32</a>* <a class="code" href="classG4Win32.html#v0">G4Win32::instance</a> = NULL;
|
|---|
| 49 | 00042
|
|---|
| 50 | <a name="l00043"></a><a class="code" href="G4Win32_8cc.html#a1">00043</a> <span class="keyword">static</span> G4bool <a class="code" href="G4Win32_8cc.html#a1">Win32Inited</a> = FALSE;
|
|---|
| 51 | <a name="l00044"></a><a class="code" href="G4Win32_8cc.html#a2">00044</a> <span class="keyword">static</span> HWND <a class="code" href="G4Win32_8cc.html#a2">topWindow</a> = NULL;
|
|---|
| 52 | 00045 <span class="comment">/***************************************************************************/</span>
|
|---|
| 53 | <a name="l00046"></a><a class="code" href="classG4Win32.html#e0">00046</a> <a class="code" href="classG4Win32.html">G4Win32</a>* <a class="code" href="classG4Win32.html#e0">G4Win32::getInstance</a> (
|
|---|
| 54 | 00047 )
|
|---|
| 55 | 00048 <span class="comment">/***************************************************************************/</span>
|
|---|
| 56 | 00050 {
|
|---|
| 57 | 00051 <span class="keywordflow">if</span> (<a class="code" href="classG4Win32.html#v0">instance</a>==NULL) {
|
|---|
| 58 | 00052 <a class="code" href="classG4Win32.html#v0">instance</a> = <span class="keyword">new</span> <a class="code" href="classG4Win32.html#d0">G4Win32</a>();
|
|---|
| 59 | 00053 }
|
|---|
| 60 | 00054 <span class="keywordflow">return</span> <a class="code" href="classG4Win32.html#v0">instance</a>;
|
|---|
| 61 | 00055 }
|
|---|
| 62 | 00056 <span class="comment">/***************************************************************************/</span>
|
|---|
| 63 | <a name="l00057"></a><a class="code" href="classG4Win32.html#d0">00057</a> <a class="code" href="classG4Win32.html#d0">G4Win32::G4Win32</a> (
|
|---|
| 64 | 00058 )
|
|---|
| 65 | 00059 <span class="comment">/***************************************************************************/</span>
|
|---|
| 66 | 00061 {
|
|---|
| 67 | 00062 <span class="keywordflow">if</span>(<a class="code" href="G4Win32_8cc.html#a1">Win32Inited</a>==FALSE) { <span class="comment">// Should be Done once.</span>
|
|---|
| 68 | 00063
|
|---|
| 69 | 00064 WNDCLASS wc;
|
|---|
| 70 | 00065 wc.style = CS_HREDRAW | CS_VREDRAW;
|
|---|
| 71 | 00066 wc.lpfnWndProc = (WNDPROC)DefWindowProc;
|
|---|
| 72 | 00067 wc.cbClsExtra = 0;
|
|---|
| 73 | 00068 wc.cbWndExtra = 0;
|
|---|
| 74 | 00069 wc.hInstance = ::GetModuleHandle(NULL);
|
|---|
| 75 | 00070 wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
|
|---|
| 76 | 00071 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|---|
| 77 | 00072 wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
|
|---|
| 78 | 00073 wc.lpszMenuName = <a class="code" href="G4Win32_8cc.html#a0">className</a>;
|
|---|
| 79 | 00074 wc.lpszClassName = <a class="code" href="G4Win32_8cc.html#a0">className</a>;
|
|---|
| 80 | 00075 ::RegisterClass (&wc);
|
|---|
| 81 | 00076
|
|---|
| 82 | 00077 <a class="code" href="G4Win32_8cc.html#a2">topWindow</a> = ::CreateWindow(<a class="code" href="G4Win32_8cc.html#a0">className</a>,<a class="code" href="G4Win32_8cc.html#a0">className</a>,
|
|---|
| 83 | 00078 WS_OVERLAPPEDWINDOW,
|
|---|
| 84 | 00079 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
|
|---|
| 85 | 00080 NULL, NULL,
|
|---|
| 86 | 00081 ::GetModuleHandle(NULL),
|
|---|
| 87 | 00082 NULL);
|
|---|
| 88 | 00083
|
|---|
| 89 | 00084 <span class="keywordflow">if</span>(<a class="code" href="G4Win32_8cc.html#a2">topWindow</a>==NULL) {
|
|---|
| 90 | 00085 G4cout << <span class="stringliteral">"G4Win32 : Unable to create Win32 window."</span> << G4endl;
|
|---|
| 91 | 00086 }
|
|---|
| 92 | 00087
|
|---|
| 93 | 00088 <a class="code" href="G4Win32_8cc.html#a1">Win32Inited</a> = TRUE;
|
|---|
| 94 | 00089 }
|
|---|
| 95 | 00090
|
|---|
| 96 | 00091 <a class="code" href="classG4VInteractorManager.html#a6">AddDispatcher</a>((<a class="code" href="G4VInteractorManager_8hh.html#a1">G4DispatchFunction</a>)<a class="code" href="classG4Win32.html#e1">G4Win32::dispatchWin32Event</a>);
|
|---|
| 97 | 00092 <a class="code" href="classG4VInteractorManager.html#a4">SetMainInteractor</a>(<a class="code" href="G4Win32_8cc.html#a2">topWindow</a>);
|
|---|
| 98 | 00093 }
|
|---|
| 99 | 00094 <span class="comment">/***************************************************************************/</span>
|
|---|
| 100 | <a name="l00095"></a><a class="code" href="classG4Win32.html#a3">00095</a> <a class="code" href="classG4Win32.html#a3">G4Win32::~G4Win32</a> (
|
|---|
| 101 | 00096 )
|
|---|
| 102 | 00097 <span class="comment">/***************************************************************************/</span>
|
|---|
| 103 | 00099 {
|
|---|
| 104 | 00100 <span class="keywordflow">if</span>(<span class="keyword">this</span>==<a class="code" href="classG4Win32.html#v0">instance</a>) {
|
|---|
| 105 | 00101 <a class="code" href="classG4Win32.html#v0">instance</a> = NULL;
|
|---|
| 106 | 00102 }
|
|---|
| 107 | 00103 }
|
|---|
| 108 | 00104 <span class="comment">/***************************************************************************/</span>
|
|---|
| 109 | <a name="l00105"></a><a class="code" href="classG4Win32.html#a0">00105</a> G4bool <a class="code" href="classG4Win32.html#a0">G4Win32::Inited</a> (
|
|---|
| 110 | 00106 )
|
|---|
| 111 | 00107 <span class="comment">/***************************************************************************/</span>
|
|---|
| 112 | 00109 {
|
|---|
| 113 | 00110 <span class="keywordflow">return</span> <a class="code" href="G4Win32_8cc.html#a1">Win32Inited</a>;
|
|---|
| 114 | 00111 }
|
|---|
| 115 | 00112 <span class="comment">/***************************************************************************/</span>
|
|---|
| 116 | <a name="l00113"></a><a class="code" href="classG4Win32.html#a1">00113</a> <span class="keywordtype">void</span>* <a class="code" href="classG4Win32.html#a1">G4Win32::GetEvent</a> (
|
|---|
| 117 | 00114 )
|
|---|
| 118 | 00115 <span class="comment">/***************************************************************************/</span>
|
|---|
| 119 | 00117 {
|
|---|
| 120 | 00118 <span class="keyword">static</span> MSG event;
|
|---|
| 121 | 00119 BOOL status = ::GetMessage(&event, NULL, 0, 0);
|
|---|
| 122 | 00120 <span class="keywordflow">if</span>(status==FALSE) <span class="keywordflow">return</span> NULL;
|
|---|
| 123 | 00121 <span class="keywordflow">return</span> &event;
|
|---|
| 124 | 00122 }
|
|---|
| 125 | 00123 <span class="comment">/***************************************************************************/</span>
|
|---|
| 126 | <a name="l00124"></a><a class="code" href="classG4Win32.html#a2">00124</a> <span class="keywordtype">void</span> <a class="code" href="classG4Win32.html#a2">G4Win32::FlushAndWaitExecution</a> (
|
|---|
| 127 | 00125 )
|
|---|
| 128 | 00126 <span class="comment">/***************************************************************************/</span>
|
|---|
| 129 | 00128 {
|
|---|
| 130 | 00129 MSG event;
|
|---|
| 131 | 00130 <span class="keywordflow">while</span> ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
|
|---|
| 132 | 00131 ::TranslateMessage(&event);
|
|---|
| 133 | 00132 ::DispatchMessage (&event);
|
|---|
| 134 | 00133 }
|
|---|
| 135 | 00134 }
|
|---|
| 136 | 00135 <span class="comment">/***************************************************************************/</span>
|
|---|
| 137 | <a name="l00136"></a><a class="code" href="classG4Win32.html#e1">00136</a> G4bool <a class="code" href="classG4Win32.html#e1">G4Win32::dispatchWin32Event</a> (
|
|---|
| 138 | 00137 <span class="keywordtype">void</span>* a_event
|
|---|
| 139 | 00138 )
|
|---|
| 140 | 00139 <span class="comment">/***************************************************************************/</span>
|
|---|
| 141 | 00141 {
|
|---|
| 142 | 00142 ::TranslateMessage((MSG*)a_event);
|
|---|
| 143 | 00143 ::DispatchMessage ((MSG*)a_event);
|
|---|
| 144 | 00144 <span class="keywordflow">return</span> TRUE;
|
|---|
| 145 | 00145 }
|
|---|
| 146 | 00146
|
|---|
| 147 | 00147 <span class="preprocessor">#endif //HAS_WIN32</span>
|
|---|
| 148 | 00148 <span class="preprocessor"></span>
|
|---|
| 149 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by
|
|---|
| 150 | <a href="http://www.doxygen.org/index.html">
|
|---|
| 151 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 >
|
|---|
| 152 | </a>1.3.4 </small></address>
|
|---|
| 153 | </body>
|
|---|
| 154 | </html>
|
|---|