Geant4-11
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
39
41static HWND topWindow = NULL;
42/***************************************************************************/
44)
45/***************************************************************************/
47{
48 if (instance==NULL) {
49 instance = new G4Win32();
50 }
51 return instance;
52}
53/***************************************************************************/
55)
56/***************************************************************************/
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,
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
92 }
93
96}
97/***************************************************************************/
99)
100/***************************************************************************/
102{
103 if(this==instance) {
104 instance = NULL;
105 }
106}
107/***************************************************************************/
109)
110/***************************************************************************/
112{
113 return Win32Inited;
114}
115/***************************************************************************/
117)
118/***************************************************************************/
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/***************************************************************************/
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/***************************************************************************/
144{
145 ::TranslateMessage((MSG*)a_event);
146 ::DispatchMessage ((MSG*)a_event);
147 return TRUE;
148}
bool G4bool
Definition: G4Types.hh:86
G4bool(* G4DispatchFunction)(void *)
static HWND topWindow
Definition: G4Win32.cc:41
static G4bool Win32Inited
Definition: G4Win32.cc:40
static char className[]
Definition: G4Win32.cc:36
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define TRUE
Definition: Globals.hh:27
#define FALSE
Definition: Globals.hh:23
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
G4Win32()
Definition: G4Win32.cc:54
static G4Win32 * instance
Definition: G4Win32.hh:60
G4bool Inited()
Definition: G4Win32.cc:108
virtual ~G4Win32()
Definition: G4Win32.cc:98
void FlushAndWaitExecution()
Definition: G4Win32.cc:127