Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Win32.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4Win32 implementation
27//
28// Original author: G.Barrand, 1998
29// --------------------------------------------------------------------
30
31// this :
32#include "G4Win32.hh"
33
34#include "G4ios.hh"
35
36static char className[] = "G4Win32";
37
38G4Win32* G4Win32::instance = NULL;
39
40static G4bool Win32Inited = FALSE;
41static HWND topWindow = NULL;
42/***************************************************************************/
44)
45/***************************************************************************/
46/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
47{
48 if (instance==NULL) {
49 instance = new G4Win32();
50 }
51 return instance;
52}
53/***************************************************************************/
54G4Win32::G4Win32 (
55)
56/***************************************************************************/
57/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
58{
59 if(Win32Inited==FALSE) { // Should be Done once.
60
61 WNDCLASS wc;
62 wc.style = CS_HREDRAW | CS_VREDRAW;
63 wc.lpfnWndProc = (WNDPROC)DefWindowProc;
64 wc.cbClsExtra = 0;
65 wc.cbWndExtra = 0;
66 wc.hInstance = ::GetModuleHandle(NULL);
67 wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
68 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
69 wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
70 wc.lpszMenuName = className;
71 wc.lpszClassName = className;
72 ::RegisterClass (&wc);
73
74 topWindow = ::CreateWindowEx(WS_EX_CLIENTEDGE,
75 className,
76 "Test",
77 WS_OVERLAPPEDWINDOW,
78 CW_USEDEFAULT,
79 CW_USEDEFAULT,
80 CW_USEDEFAULT,
81 CW_USEDEFAULT,
82 NULL,
83 NULL,
84 ::GetModuleHandle(NULL),
85 NULL);
86
87 if(topWindow==NULL) {
88 G4cout << "G4Win32: Unable to create Win32 window." << G4endl;
89 }
90
91 Win32Inited = TRUE;
92 }
93
95 SetMainInteractor(topWindow);
96}
97/***************************************************************************/
99)
100/***************************************************************************/
101/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
102{
103 if(this==instance) {
104 instance = NULL;
105 }
106}
107/***************************************************************************/
109)
110/***************************************************************************/
111/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
112{
113 return Win32Inited;
114}
115/***************************************************************************/
117)
118/***************************************************************************/
119/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
120{
121 static MSG event;
122 BOOL status = ::GetMessage(&event, NULL, 0, 0);
123 if(status==FALSE) return NULL;
124 return &event;
125}
126/***************************************************************************/
128)
129/***************************************************************************/
130/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
131{
132 MSG event;
133 while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
134 ::TranslateMessage(&event);
135 ::DispatchMessage (&event);
136 }
137}
138/***************************************************************************/
140 void* a_event
141)
142/***************************************************************************/
143/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
144{
145 ::TranslateMessage((MSG*)a_event);
146 ::DispatchMessage ((MSG*)a_event);
147 return TRUE;
148}
bool G4bool
Definition: G4Types.hh:86
G4bool(* G4DispatchFunction)(void *)
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void AddDispatcher(G4DispatchFunction)
void SetMainInteractor(G4Interactor)
void * GetEvent()
Definition: G4Win32.cc:116
static G4bool DispatchWin32Event(void *)
Definition: G4Win32.cc:139
static G4Win32 * getInstance()
Definition: G4Win32.cc:43
G4bool Inited()
Definition: G4Win32.cc:108
virtual ~G4Win32()
Definition: G4Win32.cc:98
void FlushAndWaitExecution()
Definition: G4Win32.cc:127
#define TRUE
Definition: globals.hh:41
#define FALSE
Definition: globals.hh:38