Geant4-11
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
G4UIWin32 Class Reference

#include <G4UIWin32.hh>

Inheritance diagram for G4UIWin32:
G4VBasicShell G4VInteractiveSession G4UIsession G4coutDestination

Public Types

using Transformer = std::function< G4bool(G4String &)>
 

Public Member Functions

void AddButton (const char *, const char *, const char *) override
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
virtual void AddIcon (const char *, const char *, const char *, const char *)
 
void AddInteractor (G4String, G4Interactor)
 
void AddMenu (const char *, const char *) override
 
virtual void ClearMenu ()
 
virtual void DefaultIcons (bool)
 
 G4UIWin32 ()
 
G4String GetCommand (G4int)
 
G4Interactor GetInteractor (G4String)
 
G4int GetLastReturnCode () const
 
virtual void NativeMenu (bool)
 
virtual void OutputStyle (const char *, const char *, const char *)
 
void PauseSessionStart (const G4String &) override
 
void Prompt (const G4String &)
 
G4int ReceiveG4cerr (const G4String &) override
 
G4int ReceiveG4cerr_ (const G4String &msg)
 
G4int ReceiveG4cout (const G4String &) override
 
G4int ReceiveG4cout_ (const G4String &msg)
 
virtual void ResetTransformers ()
 
G4UIsessionSessionStart () override
 
void SessionTerminate ()
 
 ~G4UIWin32 () override
 

Static Public Member Functions

static G4int InSession ()
 

Protected Member Functions

void ApplyShellCommand (const G4String &, G4bool &, G4bool &)
 
G4bool ChangeDirectory (const char *newDir)
 
void ChangeDirectoryCommand (const G4String &)
 
G4String Complete (const G4String &)
 
virtual void ExecuteCommand (const G4String &)
 
G4UIcommandFindCommand (const char *commandName) const
 
G4UIcommandTreeFindDirectory (const char *dirName) const
 
G4String FindMatchingPath (G4UIcommandTree *, const G4String &)
 
G4String GetCurrentWorkingDirectory () const
 
void ListDirectory (const G4String &) const
 
G4String ModifyToFullPathCommand (const char *aCommandLine) const
 
void ShowCurrent (const G4String &) const
 
void TerminalHelp (const G4String &)
 

Protected Attributes

G4int ifBatch = 0
 
G4int lastRC = 0
 
std::vector< TransformertransformersCerr
 
std::vector< TransformertransformersCout
 

Static Protected Attributes

static G4ICOMS_DLL G4int inSession = 0
 
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Private Types

typedef std::map< G4String, G4Interactor, std::less< G4String > > G4interactor_map
 

Private Member Functions

HTREEITEM AddItemToHelpTree (LPTSTR, HTREEITEM=TVI_ROOT)
 
void AddText (LPSTR)
 
G4bool CreateComponents (HWND)
 
void CreateHelpTree (HTREEITEM, G4UIcommandTree *)
 
void DoOpenMacro (HWND)
 
void DoSaveLog (HWND)
 
void DoSaveViewer (HWND)
 
void ExitHelp () const override
 
G4bool GetHelpChoice (G4int &) override
 
G4String GetHelpTreeToolTips (HTREEITEM)
 
LPSTR GetItemPath (HTREEITEM)
 
void HelpTreeDoubleClick (HTREEITEM)
 
G4bool InitHelpTreeItems ()
 
G4String ModifyPath (const G4String &tempPath) const
 
G4bool ProcessDefaultCommands (G4int)
 
void ProcessDownKey ()
 
void ProcessEnterKey ()
 
void ProcessEscKey ()
 
void ProcessTabKey ()
 
void ProcessUpKey ()
 
G4bool ResizeComponents (HWND)
 
G4bool SaveLogFile (LPCTSTR)
 
void SecondaryLoop (const G4String &)
 

Static Private Member Functions

static LRESULT CALLBACK ComboEditorWindowProc (HWND, UINT, WPARAM, LPARAM)
 
static G4String ConvertNewLines (G4String)
 
static G4String GetShortCommandPath (G4String)
 
static G4String GetToolTips (G4int)
 
static LRESULT CALLBACK MainWindowProc (HWND, UINT, WPARAM, LPARAM)
 

Private Attributes

std::map< G4int, G4String, std::less< G4int > > commands
 
G4String currentDirectory
 
G4bool fHelp
 
G4int fHelpChoice
 
std::vector< G4StringfHistory
 
G4int fHistoryPos
 
HWND fHWndComboBox
 
HWND fHWndComboEditor
 
HWND fHWndEditor
 
HWND fHWndHelpTree
 
HWND fHWndMainWindow
 
HWND fHWndStatus
 
HWND fHWndToolBar
 
G4VInteractorManagerinteractorManager
 
G4interactor_map interactors
 
HMENU menuBar
 
G4UImessengermessenger
 

Detailed Description

Definition at line 91 of file G4UIWin32.hh.

Member Typedef Documentation

◆ G4interactor_map

typedef std::map<G4String,G4Interactor, std::less<G4String> > G4VInteractiveSession::G4interactor_map
privateinherited

Definition at line 63 of file G4VInteractiveSession.hh.

◆ Transformer

Definition at line 61 of file G4coutDestination.hh.

Constructor & Destructor Documentation

◆ G4UIWin32()

G4UIWin32::G4UIWin32 ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 64 of file G4UIWin32.cc.

65 : fHWndMainWindow(nullptr), fHWndEditor(nullptr),
66 fHWndToolBar(nullptr), fHWndComboBox(nullptr),
67 fHWndComboEditor(nullptr), fHWndHelpTree(nullptr),
68 fHWndStatus(nullptr), menuBar(nullptr),
69 fHelp(false), fHelpChoice(0), fHistoryPos(-1) {
70
72 if (UI != nullptr) {
73 UI->SetSession(this);
74 UI->SetG4UIWindow(this);
75 }
76
77 // Ensure that the common control DLL is loaded
78 INITCOMMONCONTROLSEX commCtrls;
79 commCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
80 commCtrls.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES;
81 // this loads list-view and toolbar classes.
82 InitCommonControlsEx(&commCtrls);
83
85
86 static G4bool Done = false;
87 if (!Done) {
88 WNDCLASS wc;
89 wc.style = 0;
90 wc.lpfnWndProc = (WNDPROC) G4UIWin32::MainWindowProc;
91 wc.cbClsExtra = 0;
92 wc.cbWndExtra = 0;
93 wc.hInstance = ::GetModuleHandle(nullptr);
94 wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
95 wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
96 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
97 wc.lpszMenuName = mainClassName;
98 wc.lpszClassName = mainClassName;
99
100 if (!RegisterClass(&wc)) {
101 MessageBox(nullptr, "G4UIWin32: Win32 window registration failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
102 G4cout << "G4UIWin32: Win32 window registration failed!" << G4endl;
103 return;
104 }
105
106 Done = true;
107 }
108
109 menuBar = CreateMenu();
110
111 // Add some initial options to the menu
112 HMENU hMenu = CreatePopupMenu();
113 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&Geant4");
114 AddInteractor("Geant4", (G4Interactor) hMenu);
115
116 AppendMenu(hMenu, MF_STRING, ID_OPEN_MACRO, "&Open macro...");
117 AppendMenu(hMenu, MF_STRING, ID_SAVE_VIEWER_STATE, "&Save viewer state...");
118 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
119 AppendMenu(hMenu, MF_STRING, ID_RUN_BEAMON, "&Beam On");
120 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
121 AppendMenu(hMenu, MF_STRING, ID_EXIT_APP, "E&xit");
122
123 hMenu = CreatePopupMenu();
124 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&View");
125 AddInteractor("View", (G4Interactor) hMenu);
126
127 AppendMenu(hMenu, MF_STRING, ID_VIEW_SOLID, "S&olid");
128 AppendMenu(hMenu, MF_STRING, ID_VIEW_WIREFRAME, "&Wireframe");
129 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
130 AppendMenu(hMenu, MF_STRING, ID_PROJ_ORTHOGRAPHIC, "&Orthographic");
131 AppendMenu(hMenu, MF_STRING, ID_PROJ_PERSPECTIVE, "P&erspective");
132 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
133 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_XY, "&X-Y Plane");
134 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_XZ, "X-&Z Plane");
135 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_YZ, "&Y-Z Plane");
136 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_OBLIQUE, "&Oblique");
137
138 hMenu = CreatePopupMenu();
139 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&Zoom");
140 AddInteractor("Zoom", (G4Interactor) hMenu);
141
142 AppendMenu(hMenu, MF_STRING, ID_ZOOM_IN, "Zoom &In");
143 AppendMenu(hMenu, MF_STRING, ID_ZOOM_OUT, "Zoom &Out");
144
145 tmpSession = this;
146 fHWndMainWindow = ::CreateWindowEx(WS_EX_CLIENTEDGE, mainClassName, "Geant4",
147 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
148 CW_USEDEFAULT, CW_USEDEFAULT,
149 CW_USEDEFAULT, CW_USEDEFAULT,
150 nullptr, menuBar,
151 ::GetModuleHandle(nullptr), nullptr);
152
153 if (fHWndMainWindow == nullptr) {
154 MessageBox(nullptr, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
155 return;
156 }
157 tmpSession = nullptr;
158 ::SetWindowLongPtr(fHWndMainWindow, GWLP_USERDATA, (LONG_PTR) this);
159
160 ::SetForegroundWindow(fHWndMainWindow);
161 ::ShowWindow(fHWndMainWindow, SW_SHOWDEFAULT);
162 ::UpdateWindow(fHWndMainWindow);
163
164 if (UI != nullptr) UI->SetCoutDestination(this);
165
166// TODO: Manage multithreaded output
167//#ifdef G4MULTITHREADED
168 // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
169 //masterG4coutDestination = this;
170//#endif
171}
bool G4bool
Definition: G4Types.hh:86
static G4UIsession * tmpSession
Definition: G4UIWin32.cc:52
static char mainClassName[]
Definition: G4UIWin32.cc:48
#define ID_ORIENTATION_YZ
Definition: G4UIWin32.hh:65
#define ID_RUN_BEAMON
Definition: G4UIWin32.hh:55
#define ID_ORIENTATION_OBLIQUE
Definition: G4UIWin32.hh:66
#define ID_OPEN_MACRO
Definition: G4UIWin32.hh:53
#define ID_EXIT_APP
Definition: G4UIWin32.hh:52
#define ID_ZOOM_IN
Definition: G4UIWin32.hh:61
#define ID_VIEW_SOLID
Definition: G4UIWin32.hh:57
#define ID_SAVE_VIEWER_STATE
Definition: G4UIWin32.hh:54
#define ID_PROJ_ORTHOGRAPHIC
Definition: G4UIWin32.hh:59
#define ID_ZOOM_OUT
Definition: G4UIWin32.hh:62
#define ID_ORIENTATION_XY
Definition: G4UIWin32.hh:63
#define ID_PROJ_PERSPECTIVE
Definition: G4UIWin32.hh:60
#define ID_ORIENTATION_XZ
Definition: G4UIWin32.hh:64
#define ID_VIEW_WIREFRAME
Definition: G4UIWin32.hh:58
void * G4Interactor
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static LRESULT CALLBACK MainWindowProc(HWND, UINT, WPARAM, LPARAM)
Definition: G4UIWin32.cc:368
G4int fHistoryPos
Definition: G4UIWin32.hh:181
HWND fHWndComboEditor
Definition: G4UIWin32.hh:166
G4VInteractorManager * interactorManager
Definition: G4UIWin32.hh:170
HMENU menuBar
Definition: G4UIWin32.hh:171
HWND fHWndComboBox
Definition: G4UIWin32.hh:165
HWND fHWndToolBar
Definition: G4UIWin32.hh:164
HWND fHWndHelpTree
Definition: G4UIWin32.hh:167
HWND fHWndEditor
Definition: G4UIWin32.hh:163
G4int fHelpChoice
Definition: G4UIWin32.hh:179
HWND fHWndStatus
Definition: G4UIWin32.hh:168
G4bool fHelp
Definition: G4UIWin32.hh:178
HWND fHWndMainWindow
Definition: G4UIWin32.hh:162
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:727
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:190
void SetG4UIWindow(G4UIsession *const value)
Definition: G4UImanager.hh:191
void AddInteractor(G4String, G4Interactor)
static G4Win32 * getInstance()
Definition: G4Win32.cc:43

References G4VInteractiveSession::AddInteractor(), fHWndMainWindow, G4cout, G4endl, G4Win32::getInstance(), G4UImanager::GetUIpointer(), ID_EXIT_APP, ID_OPEN_MACRO, ID_ORIENTATION_OBLIQUE, ID_ORIENTATION_XY, ID_ORIENTATION_XZ, ID_ORIENTATION_YZ, ID_PROJ_ORTHOGRAPHIC, ID_PROJ_PERSPECTIVE, ID_RUN_BEAMON, ID_SAVE_VIEWER_STATE, ID_VIEW_SOLID, ID_VIEW_WIREFRAME, ID_ZOOM_IN, ID_ZOOM_OUT, interactorManager, mainClassName, MainWindowProc(), menuBar, G4UImanager::SetCoutDestination(), G4UImanager::SetG4UIWindow(), G4UImanager::SetSession(), and tmpSession.

◆ ~G4UIWin32()

G4UIWin32::~G4UIWin32 ( )
override

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 177 of file G4UIWin32.cc.

177 {
179 if (UI != nullptr) {
180 UI->SetSession(nullptr);
181 UI->SetG4UIWindow(nullptr);
182 UI->SetCoutDestination(nullptr);
183 }
184
185// TODO: Manage multithreaded output
186//#ifdef G4MULTITHREADED
187 //masterG4coutDestination = 0; // set to cout when UI is deleted
188//#endif
189
190 if (fHWndStatus != nullptr) ::SetWindowLongPtr(fHWndStatus, GWLP_USERDATA, LONG(NULL));
191 if (fHWndHelpTree != nullptr) ::SetWindowLongPtr(fHWndHelpTree, GWLP_USERDATA, LONG(NULL));
192 if (fHWndComboBox != nullptr) ::SetWindowLongPtr(fHWndComboBox, GWLP_USERDATA, LONG(NULL));
193 if (fHWndToolBar != nullptr) ::SetWindowLongPtr(fHWndToolBar, GWLP_USERDATA, LONG(NULL));
194 if (fHWndEditor != nullptr) ::SetWindowLongPtr(fHWndEditor, GWLP_USERDATA, LONG(NULL));
195 if (fHWndMainWindow != nullptr) {
196 ::SetWindowLongPtr(fHWndMainWindow, GWLP_USERDATA, LONG(NULL));
197 ::DestroyWindow(fHWndMainWindow);
198 }
199}

References fHWndComboBox, fHWndEditor, fHWndHelpTree, fHWndMainWindow, fHWndStatus, fHWndToolBar, G4UImanager::GetUIpointer(), G4UImanager::SetCoutDestination(), G4UImanager::SetG4UIWindow(), and G4UImanager::SetSession().

Member Function Documentation

◆ AddButton()

void G4UIWin32::AddButton ( const char *  a_menu,
const char *  a_label,
const char *  a_command 
)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 344 of file G4UIWin32.cc.

346 {
347
348 if ((a_menu != nullptr) && (a_label != nullptr) && (a_command != nullptr)) {
349 HMENU hMenu = (HMENU) GetInteractor(a_menu);
351 commands[actionIdentifier] = a_command;
352 AppendMenu(hMenu, MF_STRING, actionIdentifier, a_label);
353 }
354}
static G4int actionIdentifier
Definition: G4UIWin32.cc:59
std::map< G4int, G4String, std::less< G4int > > commands
Definition: G4UIWin32.hh:172
G4Interactor GetInteractor(G4String)

References actionIdentifier, commands, and G4VInteractiveSession::GetInteractor().

◆ AddCerrTransformer() [1/2]

void G4coutDestination::AddCerrTransformer ( const Transformer t)
inlineinherited

Definition at line 67 of file G4coutDestination.hh.

68 {
69 transformersCerr.push_back(t);
70 }
std::vector< Transformer > transformersCerr

References G4coutDestination::transformersCerr.

Referenced by G4MTcoutDestination::HandleFileCerr().

◆ AddCerrTransformer() [2/2]

void G4coutDestination::AddCerrTransformer ( Transformer &&  t)
inlineinherited

Definition at line 71 of file G4coutDestination.hh.

71{ transformersCerr.push_back(t); }

References G4coutDestination::transformersCerr.

◆ AddCoutTransformer() [1/2]

void G4coutDestination::AddCoutTransformer ( const Transformer t)
inlineinherited

◆ AddCoutTransformer() [2/2]

void G4coutDestination::AddCoutTransformer ( Transformer &&  t)
inlineinherited

Definition at line 66 of file G4coutDestination.hh.

66{ transformersCout.push_back(t); }

References G4coutDestination::transformersCout.

◆ AddIcon()

void G4VInteractiveSession::AddIcon ( const char *  ,
const char *  ,
const char *  ,
const char *   
)
virtualinherited

Reimplemented in G4UIQt.

Definition at line 60 of file G4VInteractiveSession.cc.

61{
62}

◆ AddInteractor()

void G4VInteractiveSession::AddInteractor ( G4String  a_name,
G4Interactor  a_interactor 
)
inherited

Definition at line 80 of file G4VInteractiveSession.cc.

82{
83 interactors[a_name] = a_interactor;
84}

References G4VInteractiveSession::interactors.

Referenced by G4UIQt::AddMenu(), G4UIXm::AddMenu(), AddMenu(), and G4UIWin32().

◆ AddItemToHelpTree()

HTREEITEM G4UIWin32::AddItemToHelpTree ( LPTSTR  lpszItem,
HTREEITEM  aParent = TVI_ROOT 
)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1222 of file G4UIWin32.cc.

1222 {
1223 TVITEM tvi;
1224 TVINSERTSTRUCT tvins;
1225 static auto hPrev = (HTREEITEM) TVI_FIRST;
1226
1227 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
1228
1229 // Set the text of the item.
1230 tvi.pszText = lpszItem;
1231 tvi.cchTextMax = sizeof(tvi.pszText)/sizeof(tvi.pszText[0]);
1232
1233 // Save the heading level in the item's application-defined
1234 // data area.
1235 tvi.lParam = (LPARAM) aParent;
1236 tvins.item = tvi;
1237 tvins.hInsertAfter = hPrev;
1238 // Set the parent item.
1239 tvins.hParent = aParent;
1240
1241 // Add the item to the tree-view control.
1242 hPrev = (HTREEITEM) SendMessage(fHWndHelpTree, TVM_INSERTITEM, (WPARAM) 0,
1243 (LPARAM) (LPTVINSERTSTRUCT) &tvins);
1244
1245 if (hPrev == nullptr)
1246 return nullptr;
1247 else
1248 return hPrev;
1249}

References fHWndHelpTree.

Referenced by CreateHelpTree(), and InitHelpTreeItems().

◆ AddMenu()

void G4UIWin32::AddMenu ( const char *  a_name,
const char *  a_label 
)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 331 of file G4UIWin32.cc.

331 {
332 if (a_name != nullptr) {
333 HMENU hMenu = CreatePopupMenu();
334 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, a_label);
335 AddInteractor(a_name, (G4Interactor) hMenu);
336 DrawMenuBar(fHWndMainWindow);
337 }
338}

References G4VInteractiveSession::AddInteractor(), fHWndMainWindow, and menuBar.

◆ AddText()

void G4UIWin32::AddText ( LPSTR  text)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1063 of file G4UIWin32.cc.

1063 {
1064 if ((fHWndEditor != nullptr) && (text != nullptr) && (text[0] != '\0')) {
1065 // Get current text length
1066 G4int ndx = GetWindowTextLength(fHWndEditor);
1067
1068 // Select the end of the text
1069 SendMessage(fHWndEditor, EM_SETSEL, (WPARAM) ndx, (LPARAM) ndx);
1070 //Add the new text
1071 SendMessage(fHWndEditor, EM_REPLACESEL, (WPARAM) 0, (LPARAM) text);
1072 // Scroll to the bottom
1073 SendMessage(fHWndEditor, WM_VSCROLL, SB_BOTTOM, NULL);
1074 }
1075}
int G4int
Definition: G4Types.hh:85

References fHWndEditor.

Referenced by ReceiveG4cerr(), and ReceiveG4cout().

◆ ApplyShellCommand()

void G4VBasicShell::ApplyShellCommand ( const G4String a_string,
G4bool exitSession,
G4bool exitPause 
)
protectedinherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 232 of file G4VBasicShell.cc.

237{
239 if(UI==NULL) return;
240
241 G4String command = G4StrUtil::lstrip_copy(a_string);
242
243 if( command[0] == '#' ) {
244
245 G4cout << command << G4endl;
246
247 } else if( command == "ls" || command.substr(0,3) == "ls " ) {
248
249 ListDirectory( command );
250
251 } else if( command == "pwd" ) {
252
253 G4cout << "Current Working Directory : "
255
256 } else if( command == "cd" || command.substr(0,3) == "cd ") {
257
258 ChangeDirectoryCommand ( command );
259
260 } else if( command == "help" || command.substr(0,5) == "help ") {
261
262 TerminalHelp( command );
263
264 } else if( command[0] == '?' ) {
265
266 ShowCurrent( command );
267
268 } else if( command == "hist" || command == "history") {
269
270 G4int nh = UI->GetNumberOfHistory();
271 for(G4int i=0;i<nh;i++) {
272 G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
273 }
274
275 } else if( command[0] == '!' ) {
276
277 G4String ss = command.substr(1,command.length()-1);
278 G4int vl;
279 const char* tt = ss;
280 std::istringstream is(tt);
281 is >> vl;
282 G4int nh = UI->GetNumberOfHistory();
283 if(vl>=0 && vl<nh) {
284 G4String prev = UI->GetPreviousCommand(vl);
285 G4cout << prev << G4endl;
287 } else {
288 G4cerr << "history " << vl << " is not found." << G4endl;
289 }
290
291 } else if( command == "exit" ) {
292
293 if( exitPause == false) { //In a secondary loop.
294 G4cout << "You are now processing RUN." << G4endl;
295 G4cout << "Please abort it using \"/run/abort\" command first" << G4endl;
296 G4cout << " and use \"continue\" command until the application" << G4endl;
297 G4cout << " becomes to Idle." << G4endl;
298 } else {
299 exitSession = true;
300 }
301
302 } else if( command == "cont" || command == "continue"){
303
304 exitPause = true;
305
306 } else {
307
309
310 }
311}
static G4bool exitSession
Definition: G4UIQt.cc:92
static G4bool exitPause
Definition: G4UIQt.cc:93
G4GLOB_DLL std::ostream G4cerr
G4int GetNumberOfHistory() const
Definition: G4UImanager.hh:201
G4String GetPreviousCommand(G4int i) const
Definition: G4UImanager.hh:202
G4String ModifyToFullPathCommand(const char *aCommandLine) const
void ShowCurrent(const G4String &) const
void TerminalHelp(const G4String &)
virtual void ExecuteCommand(const G4String &)
void ListDirectory(const G4String &) const
G4String GetCurrentWorkingDirectory() const
void ChangeDirectoryCommand(const G4String &)
G4String lstrip_copy(G4String str, char c=' ')
Return copy of string with leading characters removed.

References G4VBasicShell::ChangeDirectoryCommand(), G4VBasicShell::ExecuteCommand(), exitPause, exitSession, G4cerr, G4cout, G4endl, G4VBasicShell::GetCurrentWorkingDirectory(), G4UImanager::GetNumberOfHistory(), G4UImanager::GetPreviousCommand(), G4UImanager::GetUIpointer(), G4VBasicShell::ListDirectory(), G4StrUtil::lstrip_copy(), G4VBasicShell::ModifyToFullPathCommand(), G4VBasicShell::ShowCurrent(), and G4VBasicShell::TerminalHelp().

Referenced by G4UIQt::ButtonCallback(), G4UIXm::ButtonCallback(), G4UIQt::CommandEnteredCallback(), G4UIXm::CommandEnteredCallback(), DoOpenMacro(), DoSaveViewer(), ProcessDefaultCommands(), and ProcessEnterKey().

◆ ChangeDirectory()

G4bool G4VBasicShell::ChangeDirectory ( const char *  newDir)
protectedinherited

Definition at line 74 of file G4VBasicShell.cc.

75{
76 G4String newPrefix = G4StrUtil::strip_copy(newDir);
77
78 G4String newDirectory = ModifyPath( newPrefix );
79 if( newDirectory.back() != '/' )
80 { newDirectory += "/"; }
81 if( FindDirectory( newDirectory.c_str() ) == NULL )
82 { return false; }
83 currentDirectory = newDirectory;
84 return true;
85}
G4String ModifyPath(const G4String &tempPath) const
G4String currentDirectory
G4UIcommandTree * FindDirectory(const char *dirName) const
G4String strip_copy(G4String str, char c=' ')
Return copy of string with leading and trailing characters removed.

References G4VBasicShell::currentDirectory, G4VBasicShell::FindDirectory(), G4VBasicShell::ModifyPath(), and G4StrUtil::strip_copy().

Referenced by G4VBasicShell::ChangeDirectoryCommand().

◆ ChangeDirectoryCommand()

void G4VBasicShell::ChangeDirectoryCommand ( const G4String newCommand)
protectedinherited

Definition at line 325 of file G4VBasicShell.cc.

326{
328 if( newCommand.length() <= 3 ) {
329 prefix = "/";
330 } else {
331 G4String aNewPrefix = newCommand.substr(3, newCommand.length()-3);
332 prefix = G4StrUtil::strip_copy(aNewPrefix);
333 }
334 if(!ChangeDirectory(prefix)) {
335 G4cout << "directory <" << prefix << "> not found." << G4endl;
336 }
337}
G4bool ChangeDirectory(const char *newDir)

References G4VBasicShell::ChangeDirectory(), G4cout, G4endl, and G4StrUtil::strip_copy().

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIterminal::GetCommand(), and G4ZMQServer::GetCommand().

◆ ClearMenu()

void G4VInteractiveSession::ClearMenu ( )
virtualinherited

Reimplemented in G4UIQt.

Definition at line 75 of file G4VInteractiveSession.cc.

76{
77}

◆ ComboEditorWindowProc()

LRESULT CALLBACK G4UIWin32::ComboEditorWindowProc ( HWND  aWindow,
UINT  aMessage,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 471 of file G4UIWin32.cc.

471 {
472
473 // We need to go two steps up: Editor -> ComboBox -> Window
474 HWND parent = GetParent(GetParent(aWindow));
475 auto* This = (G4UIWin32*) ::GetWindowLongPtr(parent, GWLP_USERDATA);
476
477 switch (aMessage) {
478 case WM_KEYDOWN:
479 switch (wParam) {
480 case VK_TAB: {
481 if (This != nullptr) {
482 if (This->fHelp) break;
483
484 This->ProcessTabKey();
485 }
486 } return 0; //Do not jump into origComboEditorWindowProc.
487
488 case VK_ESCAPE: {
489 if (This != nullptr)
490 This->ProcessEscKey();
491 } return 0; //Do not jump into origComboEditorWindowProc.
492
493 case VK_RETURN: {
494 if (This != nullptr)
495 This->ProcessEnterKey();
496 } return 0; //Do not jump into origComboEditorWindowProc.
497
498 case VK_UP: {
499 if (This != nullptr)
500 This->ProcessUpKey();
501 } return 0; //Do not jump into origComboEditorWindowProc.
502
503 case VK_DOWN: {
504 if (This != nullptr)
505 This->ProcessDownKey();
506 } return 0; //Do not jump into origComboEditorWindowProc.
507 }
508 break;
509
510 case WM_KEYUP:
511 case WM_CHAR:
512 switch (wParam) {
513 case VK_TAB:
514 case VK_ESCAPE:
515 case VK_RETURN:
516 case VK_UP:
517 case VK_DOWN:
518 return 0; //Do not jump into origComboEditorWindowProc.
519 }
520 }
521
522 // Call the original window procedure for default processing.
523 return CallWindowProc(origComboEditorWindowProc, aWindow, aMessage, wParam, lParam);
524}
static WNDPROC origComboEditorWindowProc
Definition: G4UIWin32.cc:55

References origComboEditorWindowProc.

Referenced by CreateComponents().

◆ Complete()

G4String G4VBasicShell::Complete ( const G4String commandName)
protectedinherited

Definition at line 180 of file G4VBasicShell.cc.

181{
182 G4String rawCommandLine = commandName;
183 G4String commandLine = G4StrUtil::strip_copy(rawCommandLine);
184
185 size_t i = commandLine.find(" ");
186 if( i != std::string::npos ) return rawCommandLine; // Already entering parameters,
187 // assume command path is correct.
188 G4String commandString = commandLine;
189 G4String targetCom = ModifyPath(commandString);
191 G4String value = FindMatchingPath(tree,targetCom);
192 if(value=="") return rawCommandLine;
193 return value;
194}
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
G4String FindMatchingPath(G4UIcommandTree *, const G4String &)

References G4VBasicShell::FindMatchingPath(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), G4VBasicShell::ModifyPath(), and G4StrUtil::strip_copy().

Referenced by G4UIQt::eventFilter(), G4UIXm::keyHandler(), and ProcessTabKey().

◆ ConvertNewLines()

G4String G4UIWin32::ConvertNewLines ( G4String  a_string)
staticprivate

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 997 of file G4UIWin32.cc.

997 {
998
999 // Geant4 uses UNIX's style for new lines (\n)
1000 // we must convert them to Windows' style (\r\n)
1001 G4String str = std::move(a_string);
1002 size_t index = str.find("\n", 0);
1003 while (index < str.length()) {
1004 str.replace(index, 2, "\r\n");
1005 // Advance index forward so the next iteration doesn't pick it up as well.
1006 index = str.find("\n", index + 2);
1007 }
1008 return str;
1009}

Referenced by ReceiveG4cerr(), and ReceiveG4cout().

◆ CreateComponents()

G4bool G4UIWin32::CreateComponents ( HWND  aWindow)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 530 of file G4UIWin32.cc.

530 {
531 HFONT hfDefault;
532 TBBUTTON tbb[NUM_BUTTONS];
533 TBADDBITMAP tbab;
534 RECT rcClient; // dimensions of client area
535
536 G4int statwidths[] = {100, -1};
537
538 // Create Edit Control
539 fHWndEditor = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
540 WS_CHILD | WS_VISIBLE | WS_VSCROLL |
541 WS_HSCROLL | ES_MULTILINE |
542 ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY,
543 0, 0, 100, 100, aWindow, (HMENU) IDC_MAIN_EDIT,
544 GetModuleHandle(nullptr), nullptr);
545 if (fHWndEditor == nullptr)
546 MessageBox(aWindow, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
547
548 // Set editor font
549 //hfDefault = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
550 hfDefault = CreateFont(-10, -8, 0, 0, 0, false, 0, 0, OEM_CHARSET,
551 OUT_RASTER_PRECIS, CLIP_DEFAULT_PRECIS,
552 DEFAULT_QUALITY, FIXED_PITCH, "System");
553 SendMessage(fHWndEditor, WM_SETFONT, (WPARAM) hfDefault, MAKELPARAM(false, 0));
554
555 // Set editor's buffer size (the default value is too small)
556 SendMessage(fHWndEditor, EM_SETLIMITTEXT, (WPARAM) 500000, (LPARAM) 0);
557
558 // Create Toolbar
559 fHWndToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, nullptr,
560 WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT |
561 TBSTYLE_TOOLTIPS, 0, 0, 0, 0,
562 aWindow, (HMENU) IDC_MAIN_TOOL,
563 GetModuleHandle(nullptr), nullptr);
564 if (fHWndToolBar == nullptr)
565 MessageBox(aWindow, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
566
567 // Required for backward compatibility.
568 SendMessage(fHWndToolBar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), (LPARAM) 0);
569
570 // Load standard images
571 tbab.hInst = HINST_COMMCTRL;
572 tbab.nID = IDB_STD_SMALL_COLOR;
573 SendMessage(fHWndToolBar, TB_ADDBITMAP, (WPARAM) 0, (LPARAM) &tbab);
574
575 // Load history images
576 tbab.hInst = HINST_COMMCTRL;
577 tbab.nID = IDB_HIST_SMALL_COLOR;
578 SendMessage(fHWndToolBar, TB_ADDBITMAP, (WPARAM) 0, (LPARAM) &tbab);
579
580 G4int btnBMP[NUM_BUTTONS] = {STD_FILEOPEN, STD_FILESAVE, -1,
581 STD_FIND, STD_FIND, -1,
582 15 + HIST_FORWARD, -1,
583 STD_HELP, -1,
584 STD_FILENEW, STD_FILESAVE};
585 G4int btnSTL[NUM_BUTTONS] = {TBSTYLE_BUTTON, TBSTYLE_BUTTON, TBSTYLE_SEP,
586 TBSTYLE_BUTTON, TBSTYLE_BUTTON, TBSTYLE_SEP,
587 TBSTYLE_BUTTON, TBSTYLE_SEP,
588 TBSTYLE_BUTTON, TBSTYLE_SEP,
589 TBSTYLE_BUTTON, TBSTYLE_BUTTON};
592 ID_RUN_BEAMON, -1,
593 ID_HELP_ABOUT, -1,
595 ZeroMemory(tbb, sizeof(tbb));
596 for (G4int i = 0; i < NUM_BUTTONS; i++) {
597 tbb[i].iBitmap = btnBMP[i];
598 tbb[i].fsState = TBSTATE_ENABLED;
599 tbb[i].fsStyle = btnSTL[i];
600 tbb[i].idCommand = btnCMD[i];
601 }
602
603 SendMessage(fHWndToolBar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM) &tbb);
604
605 // Create the Combobox
606 fHWndComboBox = CreateWindowEx(0, WC_COMBOBOX, TEXT(""),
607 CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD |
608 WS_OVERLAPPED | WS_VISIBLE,
609 150, 0, 200, 200, aWindow, (HMENU) IDC_MAIN_COMBO,
610 GetModuleHandle(nullptr), nullptr);
611
612 // Display an initial item in the selection field
613 SendMessage(fHWndComboBox, CB_SETCURSEL, (WPARAM) 2, (LPARAM) 0);
614
615 //Get aWindow of edit control in combobox created earlier.
616 fHWndComboEditor = FindWindowEx(fHWndComboBox, nullptr, WC_EDIT, nullptr);
617
618 // Change the window procedure for the edit windows to the subclass procedure.
619 origComboEditorWindowProc = (WNDPROC) SetWindowLongPtr(fHWndComboEditor, GWLP_WNDPROC,
620 (LONG_PTR) ComboEditorWindowProc);
621
622 // Create TreeView
623
624 // Get the dimensions of the parent window's client area, and create
625 // the tree-view control.
626 GetClientRect(aWindow, &rcClient);
627 fHWndHelpTree = CreateWindowEx(0, WC_TREEVIEW,
628 TEXT("Tree View"),
629 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_INFOTIP |
630 TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT,
631 0, 0,
632 rcClient.right, rcClient.bottom,
633 aWindow, (HMENU) IDC_MAIN_TREE_VIEW,
634 GetModuleHandle(nullptr), nullptr);
635
636 // Initialize the Help Tree View.
637/* if (!InitHelpTreeItems()) {
638 DestroyWindow(fHWndHelpTree);
639 return false;
640 }*/
641
642 // Create Status bar
643 fHWndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr,
644 WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
645 100, 100, 200, 200,
646 aWindow, (HMENU) IDC_MAIN_STATUS,
647 GetModuleHandle(nullptr), nullptr);
648
649 SendMessage(fHWndStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM) statwidths);
650 //SendMessage(fHWndStatus, SB_SETTEXT, 0, (LPARAM) "Hi there :)");
651
652 return true;
653}
#define IDC_MAIN_EDIT
Definition: G4UIWin32.hh:74
#define ID_LOG_CLEAN
Definition: G4UIWin32.hh:68
#define NUM_BUTTONS
Definition: G4UIWin32.hh:71
#define IDC_MAIN_TREE_VIEW
Definition: G4UIWin32.hh:76
#define IDC_MAIN_COMBO
Definition: G4UIWin32.hh:77
#define ID_LOG_SAVE
Definition: G4UIWin32.hh:69
#define IDC_MAIN_STATUS
Definition: G4UIWin32.hh:78
#define ID_HELP_ABOUT
Definition: G4UIWin32.hh:67
#define IDC_MAIN_TOOL
Definition: G4UIWin32.hh:75
static LRESULT CALLBACK ComboEditorWindowProc(HWND, UINT, WPARAM, LPARAM)
Definition: G4UIWin32.cc:471

References ComboEditorWindowProc(), fHWndComboBox, fHWndComboEditor, fHWndEditor, fHWndHelpTree, fHWndStatus, fHWndToolBar, ID_HELP_ABOUT, ID_LOG_CLEAN, ID_LOG_SAVE, ID_OPEN_MACRO, ID_RUN_BEAMON, ID_SAVE_VIEWER_STATE, ID_ZOOM_IN, ID_ZOOM_OUT, IDC_MAIN_COMBO, IDC_MAIN_EDIT, IDC_MAIN_STATUS, IDC_MAIN_TOOL, IDC_MAIN_TREE_VIEW, NUM_BUTTONS, and origComboEditorWindowProc.

◆ CreateHelpTree()

void G4UIWin32::CreateHelpTree ( HTREEITEM  aParent,
G4UIcommandTree aCommandTree 
)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1191 of file G4UIWin32.cc.

1191 {
1192 if ((aParent != nullptr) && (aCommandTree != nullptr)) {
1193 // Creating new item
1194 HTREEITEM newItem;
1195
1196 G4String commandText;
1197 // Get the Sub directories
1198 for (G4int a = 0; a < aCommandTree->GetTreeEntry(); a++) {
1199 commandText = aCommandTree->GetTree(a + 1)->GetPathName().data();
1200
1201 // Add the item to the tree-view control.
1202 newItem = AddItemToHelpTree(const_cast<LPTSTR>(GetShortCommandPath(commandText).c_str()), aParent);
1203
1204 // Look for children
1205 CreateHelpTree(newItem, aCommandTree->GetTree(a + 1));
1206 }
1207
1208 // Get the Commands
1209 for (G4int a = 0; a < aCommandTree->GetCommandEntry(); a++) {
1210 commandText = aCommandTree->GetCommand(a + 1)->GetCommandPath().data();
1211
1212 // Add the item to the tree-view control.
1213 AddItemToHelpTree(const_cast<LPTSTR>(GetShortCommandPath(commandText).c_str()), aParent);
1214 }
1215 }
1216}
static G4String GetShortCommandPath(G4String)
Definition: G4UIWin32.cc:1255
HTREEITEM AddItemToHelpTree(LPTSTR, HTREEITEM=TVI_ROOT)
Definition: G4UIWin32.cc:1222
void CreateHelpTree(HTREEITEM, G4UIcommandTree *)
Definition: G4UIWin32.cc:1191
G4int GetCommandEntry() const
G4UIcommand * GetCommand(G4int i)
const G4String & GetPathName() const
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References AddItemToHelpTree(), CreateHelpTree(), G4UIcommandTree::GetCommand(), G4UIcommandTree::GetCommandEntry(), G4UIcommand::GetCommandPath(), G4UIcommandTree::GetPathName(), GetShortCommandPath(), G4UIcommandTree::GetTree(), and G4UIcommandTree::GetTreeEntry().

Referenced by CreateHelpTree(), and InitHelpTreeItems().

◆ DefaultIcons()

void G4VInteractiveSession::DefaultIcons ( bool  )
virtualinherited

Reimplemented in G4UIQt.

Definition at line 55 of file G4VInteractiveSession.cc.

56{
57}

◆ DoOpenMacro()

void G4UIWin32::DoOpenMacro ( HWND  aWindow)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1081 of file G4UIWin32.cc.

1081 {
1082 OPENFILENAME ofn;
1083 char szFileName[MAX_PATH] = "";
1084
1085 ZeroMemory(&ofn, sizeof(ofn));
1086
1087 ofn.lStructSize = sizeof(ofn);
1088 ofn.hwndOwner = aWindow;
1089 ofn.lpstrFilter = "Macro Files (*.mac)\0*.mac\0All Files (*.*)\0*.*\0";
1090 ofn.lpstrFile = szFileName;
1091 ofn.nMaxFile = MAX_PATH;
1092 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
1093 ofn.lpstrDefExt = "mac";
1094
1095 if (GetOpenFileName(&ofn)) {
1096 G4String command = "/control/execute " + G4String(szFileName);
1098
1099 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM) "Opened macro...");
1100 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM) szFileName);
1101 }
1102}
static G4bool exitSession
Definition: G4UIWin32.cc:49
static G4bool exitPause
Definition: G4UIWin32.cc:50
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)

References G4VBasicShell::ApplyShellCommand(), exitPause, exitSession, and IDC_MAIN_STATUS.

Referenced by ProcessDefaultCommands().

◆ DoSaveLog()

void G4UIWin32::DoSaveLog ( HWND  aWindow)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1135 of file G4UIWin32.cc.

1135 {
1136 OPENFILENAME ofn;
1137 char szFileName[MAX_PATH] = "";
1138
1139 ZeroMemory(&ofn, sizeof(ofn));
1140
1141 ofn.lStructSize = sizeof(ofn);
1142 ofn.hwndOwner = aWindow;
1143 ofn.lpstrFilter = "Log Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
1144 ofn.lpstrFile = szFileName;
1145 ofn.nMaxFile = MAX_PATH;
1146 ofn.lpstrDefExt = "txt";
1147 ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
1148
1149 if (GetSaveFileName(&ofn)) {
1150 if (SaveLogFile(szFileName)) {
1151 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM) "Saved log file...");
1152 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM) szFileName);
1153 }
1154 }
1155}
G4bool SaveLogFile(LPCTSTR)
Definition: G4UIWin32.cc:1028

References IDC_MAIN_STATUS, and SaveLogFile().

Referenced by ProcessDefaultCommands().

◆ DoSaveViewer()

void G4UIWin32::DoSaveViewer ( HWND  aWindow)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1108 of file G4UIWin32.cc.

1108 {
1109 OPENFILENAME ofn;
1110 char szFileName[MAX_PATH] = "";
1111
1112 ZeroMemory(&ofn, sizeof(ofn));
1113
1114 ofn.lStructSize = sizeof(ofn);
1115 ofn.hwndOwner = aWindow;
1116 ofn.lpstrFilter = "Macro Files (*.mac)\0*.mac\0All Files (*.*)\0*.*\0";
1117 ofn.lpstrFile = szFileName;
1118 ofn.nMaxFile = MAX_PATH;
1119 ofn.lpstrDefExt = "mac";
1120 ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
1121
1122 if (GetSaveFileName(&ofn)) {
1123 G4String command = "/vis/viewer/save " + G4String(szFileName);
1125
1126 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 0, (LPARAM) "State saved...");
1127 SendDlgItemMessage(aWindow, IDC_MAIN_STATUS, SB_SETTEXT, 1, (LPARAM) szFileName);
1128 }
1129}

References G4VBasicShell::ApplyShellCommand(), exitPause, exitSession, and IDC_MAIN_STATUS.

Referenced by ProcessDefaultCommands().

◆ ExecuteCommand()

void G4VBasicShell::ExecuteCommand ( const G4String aCommand)
protectedvirtualinherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented in G4UIterminal, and G4ZMQServer.

Definition at line 206 of file G4VBasicShell.cc.

210{
211 if(aCommand.length()<2) return;
213 if(UI==NULL) return;
214 G4int commandStatus = UI->ApplyCommand(aCommand);
215 switch(commandStatus) {
217 break;
218 case fCommandNotFound:
219 G4cerr << "command not found: " << "\"" << aCommand << "\"" << G4endl;
220 break;
222 G4cerr << "illegal application state -- command refused:" << "\"" << aCommand << "\"" << G4endl;
223 break;
227 default:
228 G4cerr << "command refused (" << commandStatus << "):" << "\"" << aCommand << "\"" << G4endl;
229 }
230}
@ fParameterOutOfCandidates
@ fCommandNotFound
@ fIllegalApplicationState
@ fParameterUnreadable
@ fCommandSucceeded
@ fParameterOutOfRange
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485

References G4UImanager::ApplyCommand(), fCommandNotFound, fCommandSucceeded, fIllegalApplicationState, fParameterOutOfCandidates, fParameterOutOfRange, fParameterUnreadable, G4cerr, G4endl, and G4UImanager::GetUIpointer().

Referenced by G4VBasicShell::ApplyShellCommand().

◆ ExitHelp()

void G4UIWin32::ExitHelp ( ) const
overrideprivatevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 325 of file G4UIWin32.cc.

325{}

◆ FindCommand()

G4UIcommand * G4VBasicShell::FindCommand ( const char *  commandName) const
protectedinherited

Definition at line 109 of file G4VBasicShell.cc.

110{
111 G4String commandLine = G4StrUtil::strip_copy(commandName);
112
113 G4String commandString;
114 size_t i = commandLine.find(" ");
115 if( i != std::string::npos )
116 { commandString = commandLine.substr(0,i); }
117 else
118 { commandString = commandLine; }
119
120 G4String targetCom = ModifyPath(commandString);
121 return G4UImanager::GetUIpointer()->GetTree()->FindPath(targetCom);
122}
G4UIcommand * FindPath(const char *commandPath) const

References G4UIcommandTree::FindPath(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), G4VBasicShell::ModifyPath(), and G4StrUtil::strip_copy().

Referenced by G4UIterminal::ExecuteCommand(), and G4ZMQServer::ExecuteCommand().

◆ FindDirectory()

G4UIcommandTree * G4VBasicShell::FindDirectory ( const char *  dirName) const
protectedinherited

Definition at line 87 of file G4VBasicShell.cc.

88{
89 G4String theDir = G4StrUtil::strip_copy(dirName);
90
91 G4String targetDir = ModifyPath( theDir );
92 if( targetDir.back() != '/' )
93 { targetDir += "/"; }
95 if( targetDir == "/" )
96 { return comTree; }
97 size_t idx = 1;
98 while( idx < targetDir.length()-1 )
99 {
100 size_t i = targetDir.find("/",idx);
101 comTree = comTree->GetTree(targetDir.substr(0,i+1).c_str());
102 if( comTree == NULL )
103 { return NULL; }
104 idx = i+1;
105 }
106 return comTree;
107}

References G4UImanager::GetTree(), G4UIcommandTree::GetTree(), G4UImanager::GetUIpointer(), G4VBasicShell::ModifyPath(), and G4StrUtil::strip_copy().

Referenced by G4VBasicShell::ChangeDirectory(), G4VBasicShell::ListDirectory(), and G4ZMQServer::SessionStart().

◆ FindMatchingPath()

G4String G4VBasicShell::FindMatchingPath ( G4UIcommandTree aTree,
const G4String aCommandPath 
)
protectedinherited

Definition at line 196 of file G4VBasicShell.cc.

198{
199 return aTree-> CompleteCommandPath(aCommandPath);
200}

Referenced by G4VBasicShell::Complete().

◆ GetCommand()

G4String G4UIWin32::GetCommand ( G4int  a_id)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 360 of file G4UIWin32.cc.

360 {
361 return commands[a_id];
362}

References commands.

◆ GetCurrentWorkingDirectory()

G4String G4VBasicShell::GetCurrentWorkingDirectory ( ) const
protectedinherited

◆ GetHelpChoice()

G4bool G4UIWin32::GetHelpChoice ( G4int aInt)
overrideprivatevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 301 of file G4UIWin32.cc.

301 {
302 fHelp = true;
303
304 if (interactorManager != nullptr) {
305 Prompt("Help");
306 exitHelp = false;
307 void* event;
308 while ((event = interactorManager->GetEvent()) != nullptr) {
310 if (exitHelp) break;
311 }
312 Prompt("session");
313 //
314 if (!fHelp) return false;
315 aInt = fHelpChoice;
316 fHelp = false;
317 return true;
318 } else return false;
319}
static G4bool exitHelp
Definition: G4UIWin32.cc:51
void Prompt(const G4String &)
Definition: G4UIWin32.cc:229
virtual void * GetEvent()=0

References G4VInteractorManager::DispatchEvent(), exitHelp, fHelp, fHelpChoice, G4VInteractorManager::GetEvent(), interactorManager, and Prompt().

◆ GetHelpTreeToolTips()

G4String G4UIWin32::GetHelpTreeToolTips ( HTREEITEM  item)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 967 of file G4UIWin32.cc.

967 {
968 // Tooltips for the help tree
970 if (UI == nullptr) return "";
971 G4UIcommandTree* treeTop = UI->GetTree();
972
973 G4String itemText = GetItemPath(item);
974
975 // Check if it is a command path
976 if (TreeView_GetChild(fHWndHelpTree, item) != nullptr)
977 itemText += "/";
978
979 G4UIcommand* command = treeTop->FindPath(itemText.c_str());
980
981 if (command) {
982 // This is a command, return the first line of help
983 return command->GetGuidanceLine(0).data();
984 } else {
985 // This is not a command, but a sub directory, return the title
986 G4UIcommandTree* path = treeTop->FindCommandTree(itemText.c_str());
987 if (path) return path->GetTitle().data();
988 }
989
990 return "";
991}
LPSTR GetItemPath(HTREEITEM)
Definition: G4UIWin32.cc:1270
G4UIcommandTree * FindCommandTree(const char *commandPath)
const G4String GetTitle() const
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:132

References fHWndHelpTree, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::FindPath(), G4UIcommand::GetGuidanceLine(), GetItemPath(), G4UIcommandTree::GetTitle(), G4UImanager::GetTree(), and G4UImanager::GetUIpointer().

◆ GetInteractor()

G4Interactor G4VInteractiveSession::GetInteractor ( G4String  a_name)
inherited

Definition at line 87 of file G4VInteractiveSession.cc.

88{
89 G4interactor_map::iterator it;
90 if((it=interactors.find(a_name))==interactors.end()) return NULL;
91 return (*it).second;
92}

References G4VInteractiveSession::interactors.

Referenced by G4UIQt::AddButton(), G4UIXm::AddButton(), and AddButton().

◆ GetItemPath()

LPSTR G4UIWin32::GetItemPath ( HTREEITEM  item)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1270 of file G4UIWin32.cc.

1270 {
1271 // Get the text for the item.
1272 TVITEM tvitem;
1273 tvitem.mask = TVIF_TEXT;
1274 tvitem.hItem = item;
1275 TCHAR infoTipBuf[1024];
1276 tvitem.pszText = infoTipBuf;
1277 tvitem.cchTextMax = sizeof(infoTipBuf)/sizeof(TCHAR);
1278
1279 std::string str = "";
1280 while (item != nullptr) {
1281 TreeView_GetItem(fHWndHelpTree, &tvitem);
1282 str = "/" + std::string(tvitem.pszText) + str;
1283
1284 item = TreeView_GetParent(fHWndHelpTree, item);
1285 tvitem.hItem = item;
1286 }
1287
1288 auto* result = new TCHAR[str.size() + 1];
1289 result[str.size()] = 0;
1290 std::copy(str.begin(), str.end(), result);
1291
1292 return result;
1293}
void copy(G4double dst[], const G4double src[], size_t size=G4FieldTrack::ncompSVEC)
Definition: G4FieldUtils.cc:98

References field_utils::copy(), and fHWndHelpTree.

Referenced by GetHelpTreeToolTips(), and HelpTreeDoubleClick().

◆ GetLastReturnCode()

G4int G4UIsession::GetLastReturnCode ( ) const
inlineinherited

Definition at line 63 of file G4UIsession.hh.

63{ return lastRC; }
G4int lastRC
Definition: G4UIsession.hh:69

References G4UIsession::lastRC.

◆ GetShortCommandPath()

G4String G4UIWin32::GetShortCommandPath ( G4String  commandPath)
staticprivate

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1255 of file G4UIWin32.cc.

1255 {
1256 G4String str = std::move(commandPath);
1257
1258 if (str.find_last_of("/") == (str.size() - 1))
1259 str = str.erase(str.size() - 1, 1);
1260
1261 str = str.erase(0, str.find_last_of("/") + 1);
1262
1263 return str;
1264}

Referenced by CreateHelpTree(), and InitHelpTreeItems().

◆ GetToolTips()

G4String G4UIWin32::GetToolTips ( G4int  idButton)
staticprivate

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 932 of file G4UIWin32.cc.

932 {
933 switch (idButton) {
934 case ID_OPEN_MACRO:
935 return "Open and execute macro file";
936
938 return "Save viewer state";
939
940 case ID_ZOOM_IN:
941 return "Zoom in";
942
943 case ID_ZOOM_OUT:
944 return "Zoom out";
945
946 case ID_RUN_BEAMON:
947 return "Beam on (one particle)";
948
949 case ID_HELP_ABOUT:
950 return "About G4UIWin32";
951
952 case ID_LOG_CLEAN:
953 return "Clean log";
954
955 case ID_LOG_SAVE:
956 return "Save log";
957
958 default:
959 return "";
960 }
961}

References ID_HELP_ABOUT, ID_LOG_CLEAN, ID_LOG_SAVE, ID_OPEN_MACRO, ID_RUN_BEAMON, ID_SAVE_VIEWER_STATE, ID_ZOOM_IN, and ID_ZOOM_OUT.

◆ HelpTreeDoubleClick()

void G4UIWin32::HelpTreeDoubleClick ( HTREEITEM  item)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1015 of file G4UIWin32.cc.

1015 {
1016 const char* item_path = GetItemPath(item);
1017 G4int l = strlen(item_path);
1018 Edit_SetText(fHWndComboEditor, item_path);
1019 Edit_SetSel(fHWndComboEditor, l, l);
1020
1021 SetFocus(fHWndComboEditor);
1022}

References fHWndComboEditor, and GetItemPath().

◆ InitHelpTreeItems()

G4bool G4UIWin32::InitHelpTreeItems ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1161 of file G4UIWin32.cc.

1161 {
1162 HTREEITEM newItem;
1163
1165 if (UI == nullptr) return false;
1166 G4UIcommandTree* treeTop = UI->GetTree();
1167
1168 G4int treeSize = treeTop->GetTreeEntry();
1169 G4String commandText;
1170 for (G4int a = 0; a < treeSize; a++) {
1171 // Creating new item
1172 commandText = treeTop->GetTree(a + 1)->GetPathName().data();
1173
1174 // Add the item to the tree-view control.
1175 newItem = AddItemToHelpTree(const_cast<LPTSTR>(GetShortCommandPath(commandText).c_str()));
1176
1177 if (newItem == nullptr)
1178 return false;
1179
1180 // Look for children
1181 CreateHelpTree(newItem, treeTop->GetTree(a + 1));
1182 }
1183
1184 return true;
1185}

References AddItemToHelpTree(), CreateHelpTree(), G4UIcommandTree::GetPathName(), GetShortCommandPath(), G4UImanager::GetTree(), G4UIcommandTree::GetTree(), G4UIcommandTree::GetTreeEntry(), and G4UImanager::GetUIpointer().

Referenced by SessionStart().

◆ InSession()

G4int G4UIsession::InSession ( )
staticinherited

Definition at line 68 of file G4UIsession.cc.

69{
70 return inSession;
71}
static G4ICOMS_DLL G4int inSession
Definition: G4UIsession.hh:67

References G4UIsession::inSession.

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ ListDirectory()

void G4VBasicShell::ListDirectory ( const G4String newCommand) const
protectedinherited

Definition at line 339 of file G4VBasicShell.cc.

340{
341 G4String targetDir;
342 if( newCommand.length() <= 3 ) {
343 targetDir = GetCurrentWorkingDirectory();
344 } else {
345 G4String newPrefix = newCommand.substr(3, newCommand.length()-3);
346 targetDir = G4StrUtil::strip_copy(newPrefix);
347 }
348 G4UIcommandTree* commandTree = FindDirectory( targetDir );
349 if( commandTree == NULL ) {
350 G4cout << "Directory <" << targetDir << "> is not found." << G4endl;
351 } else {
352 commandTree->ListCurrent();
353 }
354}
void ListCurrent() const

References G4VBasicShell::FindDirectory(), G4cout, G4endl, G4VBasicShell::GetCurrentWorkingDirectory(), G4UIcommandTree::ListCurrent(), and G4StrUtil::strip_copy().

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIterminal::GetCommand(), and G4ZMQServer::GetCommand().

◆ MainWindowProc()

LRESULT CALLBACK G4UIWin32::MainWindowProc ( HWND  aWindow,
UINT  aMessage,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 368 of file G4UIWin32.cc.

369 {
370 switch (aMessage) {
371 case WM_CREATE: {
372 auto* This = (G4UIWin32*) tmpSession;
373 if (This != nullptr) {
374 if (!This->CreateComponents(aWindow)) {
375 MessageBox(aWindow, "Could not create components.", "Error", MB_OK | MB_ICONERROR);
376 return false;
377 }
378 }
379 } return 0;
380
381 case WM_SIZE: {
382 auto* This = (G4UIWin32*) ::GetWindowLongPtr(aWindow, GWLP_USERDATA);
383 if (This != nullptr) {
384 if (!This->ResizeComponents(aWindow)) {
385 MessageBox(aWindow, "Could not resize components.", "Error", MB_OK | MB_ICONERROR);
386 return false;
387 }
388 }
389 } return 0;
390
391 case WM_CLOSE:
392 DestroyWindow(aWindow);
393 return 0;
394
395 case WM_DESTROY:
396 PostQuitMessage(0);
397 return 0;
398
399 case WM_SETFOCUS: {
400 auto* This = (G4UIWin32*) ::GetWindowLongPtr(aWindow, GWLP_USERDATA);
401 if (This != nullptr)
402 SetFocus(This->fHWndComboBox);
403 } return 0;
404
405 case WM_NOTIFY: {
406 auto* This = (G4UIWin32*) ::GetWindowLongPtr(aWindow, GWLP_USERDATA);
407 if (This != nullptr) {
408 switch (((LPNMHDR) lParam)->code) {
409 // Tooltip for Toolbar
410 case TTN_NEEDTEXT: {
411 auto lpttt = (LPTOOLTIPTEXT) lParam;
412 lpttt->hinst = nullptr;
413 UINT idButton = lpttt->hdr.idFrom;
414 lpttt->lpszText = (LPSTR) This->GetToolTips(idButton).c_str();
415 } break;
416
417 // Tooltip for TreeView
418 case TVN_GETINFOTIP: {
419 auto pTip = (LPNMTVGETINFOTIP) lParam;
420 pTip->pszText = (LPSTR) This->GetHelpTreeToolTips(pTip->hItem).c_str();
421 } break;
422
423 // Double click for TreeView
424 case NM_DBLCLK: {
425 auto lpnmh = (LPNMHDR) lParam;
426 auto item = TreeView_GetSelection(lpnmh->hwndFrom);
427 This->HelpTreeDoubleClick(item);
428 } break;
429 }
430 }
431 } return 0;
432
433 case WM_COMMAND: {
434 auto* This = (G4UIWin32*) ::GetWindowLongPtr(aWindow, GWLP_USERDATA);
435 if (This != nullptr)
436 if (!This->ProcessDefaultCommands(LOWORD(wParam)))
437 // If the command was not processed, do it now
438 switch (LOWORD(wParam)) {
439 case IDC_MAIN_EDIT: {
440 // We have to release some space when the buffer is full
441 if (HIWORD(wParam) == EN_ERRSPACE || HIWORD(wParam) == EN_MAXTEXT) {
442 G4int bufferSize = SendMessage(This->fHWndEditor, EM_GETLIMITTEXT,
443 (WPARAM) 0, (LPARAM) 0);
444
445 // Select the first third of the text
446 SendMessage(This->fHWndEditor, EM_SETSEL, (WPARAM) 0, (LPARAM) bufferSize/3);
447 // Delete it
448 SendMessage(This->fHWndEditor, EM_REPLACESEL, (WPARAM) 0, (LPARAM) "");
449 // Scroll to the bottom
450 SendMessage(This->fHWndEditor, WM_VSCROLL, SB_BOTTOM, NULL);
451 }
452 }
453 break;
454 default:
455 if (!This->fHelp) {
456 G4String command = This->GetCommand(wParam);
457 This->ApplyShellCommand(command, exitSession, exitPause);
458 }
459 }
460 } return 0;
461 default:
462 // For all the other cases, call the default window procedure.
463 return DefWindowProc(aWindow, aMessage, wParam, lParam);
464 }
465}

References exitPause, exitSession, IDC_MAIN_EDIT, and tmpSession.

Referenced by G4UIWin32().

◆ ModifyPath()

G4String G4VBasicShell::ModifyPath ( const G4String tempPath) const
privateinherited

Definition at line 124 of file G4VBasicShell.cc.

125{
126 if( tempPath.length() == 0 ) return tempPath;
127
128 G4String newPath = "";
129
130 // temporal full path
131 if( tempPath[0] == '/') newPath = tempPath;
132 else newPath = currentDirectory + tempPath;
133
134 // body of path...
135 while(1){
136 size_t idx = newPath.find("/./");
137 if( idx == G4String::npos) break;
138 newPath.erase(idx,2);
139 }
140
141 while(1) {
142 size_t idx = newPath.find("/../");
143 if( idx == G4String::npos) break;
144 if( idx == 0) {
145 newPath.erase(1,3);
146 continue;
147 }
148 size_t idx2 = newPath.find_last_of('/', idx-1);
149 if(idx2 != G4String::npos) newPath.erase(idx2, idx-idx2+3);
150 }
151
152 // end of path...
153 if ( newPath.size() >= 3 ) {
154 if(newPath.substr(newPath.size()-3,3) == "/..") {
155 if( newPath.size() == 3) {
156 newPath = "/";
157 } else {
158 size_t idx = newPath.find_last_of('/', newPath.size()-4);
159 if(idx != G4String::npos) newPath.erase(idx+1);
160 }
161 }
162 }
163
164 if ( newPath.size() >= 2 ) {
165 if(newPath.substr(newPath.size()-2,2) == "/.") newPath.erase(newPath.size()-1,1);
166 }
167
168 // truncate "/////" to "/"
169 while(1) {
170 size_t idx = newPath.find("//");
171 if( idx == G4String::npos) break;
172 newPath.erase(idx,1);
173 }
174
175 return newPath;
176}

References G4VBasicShell::currentDirectory.

Referenced by G4VBasicShell::ChangeDirectory(), G4VBasicShell::Complete(), G4VBasicShell::FindCommand(), G4VBasicShell::FindDirectory(), and G4VBasicShell::ModifyToFullPathCommand().

◆ ModifyToFullPathCommand()

G4String G4VBasicShell::ModifyToFullPathCommand ( const char *  aCommandLine) const
protectedinherited

Definition at line 47 of file G4VBasicShell.cc.

48{
49 G4String rawCommandLine = aCommandLine;
50 if(rawCommandLine.empty()||rawCommandLine[0]=='\0') return rawCommandLine;
51 G4String commandLine = G4StrUtil::strip_copy(rawCommandLine);
52 G4String commandString;
53 G4String parameterString;
54 size_t i = commandLine.find(" ");
55 if( i != std::string::npos )
56 {
57 commandString = commandLine.substr(0,i);
58 parameterString = " ";
59 parameterString += commandLine.substr(i+1,commandLine.length()-(i+1));
60 }
61 else
62 { commandString = commandLine; }
63
64 G4String fullPathCommandLine
65 = ModifyPath( commandString )+parameterString;
66 return fullPathCommandLine;
67}

References G4VBasicShell::ModifyPath(), and G4StrUtil::strip_copy().

Referenced by G4UIQt::ActivateCommand(), G4VBasicShell::ApplyShellCommand(), G4UIterminal::GetCommand(), G4ZMQServer::GetCommand(), G4VBasicShell::ShowCurrent(), and G4VBasicShell::TerminalHelp().

◆ NativeMenu()

void G4VInteractiveSession::NativeMenu ( bool  )
virtualinherited

Reimplemented in G4UIQt.

Definition at line 70 of file G4VInteractiveSession.cc.

71{
72}

◆ OutputStyle()

void G4VInteractiveSession::OutputStyle ( const char *  ,
const char *  ,
const char *   
)
virtualinherited

Reimplemented in G4UIQt.

Definition at line 65 of file G4VInteractiveSession.cc.

66{
67}

◆ PauseSessionStart()

void G4UIWin32::PauseSessionStart ( const G4String a_state)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 241 of file G4UIWin32.cc.

241 {
242 if (a_state == "G4_pause> ") {
243 SecondaryLoop("Pause, type continue to exit this state");
244 }
245
246 if (a_state == "EndOfEvent") {
247 // Picking with feed back in event data Done here !!!
248 SecondaryLoop("End of event, type continue to exit this state");
249 }
250}
void SecondaryLoop(const G4String &)
Definition: G4UIWin32.cc:256

References SecondaryLoop().

◆ ProcessDefaultCommands()

G4bool G4UIWin32::ProcessDefaultCommands ( G4int  idCommand)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 847 of file G4UIWin32.cc.

847 {
848 switch (idCommand) {
849 case ID_EXIT_APP:
850 PostMessage(fHWndMainWindow, WM_CLOSE, 0, 0);
851 return true;
852 case ID_OPEN_MACRO:
854 return true;
857 return true;
858 case ID_RUN_BEAMON:
859 if(!fHelp) {
860 G4String command = "/run/beamOn 1";
862 } return true;
863 case ID_RUN_CMD:
864 return true;
865 case ID_VIEW_SOLID:
866 if(!fHelp) {
867 G4String command = "/vis/viewer/set/style s";
869 } return true;
871 if(!fHelp) {
872 G4String command = "/vis/viewer/set/style w";
874 } return true;
876 if(!fHelp) {
877 G4String command = "/vis/viewer/set/projection o";
879 } return true;
881 if(!fHelp) {
882 G4String command = "/vis/viewer/set/projection p";
884 } return true;
885 case ID_ZOOM_IN:
886 if(!fHelp) {
887 G4String command = "/vis/viewer/zoom 1.2";
889 } return true;
890 case ID_ZOOM_OUT:
891 if(!fHelp) {
892 G4String command = "/vis/viewer/zoom 0.8";
894 } return true;
896 if(!fHelp) {
897 G4String command = "/vis/viewer/set/viewpointThetaPhi 0. 0.";
899 } return true;
901 if(!fHelp) {
902 G4String command = "/vis/viewer/set/viewpointThetaPhi 90. 0.";
904 } return true;
906 if(!fHelp) {
907 G4String command = "/vis/viewer/set/viewpointThetaPhi 0. 90.";
909 } return true;
911 if(!fHelp) {
912 G4String command = "/vis/viewer/set/viewpointThetaPhi 45. -45.";
914 } return true;
915 case ID_HELP_ABOUT:
916 return true;
917 case ID_LOG_CLEAN:
918 SetDlgItemText(fHWndMainWindow, IDC_MAIN_EDIT, "");
919 return true;
920 case ID_LOG_SAVE:
922 return true;
923 default:
924 return false;
925 }
926}
#define ID_RUN_CMD
Definition: G4UIWin32.hh:56
void DoSaveViewer(HWND)
Definition: G4UIWin32.cc:1108
void DoOpenMacro(HWND)
Definition: G4UIWin32.cc:1081
void DoSaveLog(HWND)
Definition: G4UIWin32.cc:1135

References G4VBasicShell::ApplyShellCommand(), DoOpenMacro(), DoSaveLog(), DoSaveViewer(), exitPause, exitSession, fHelp, fHWndMainWindow, ID_EXIT_APP, ID_HELP_ABOUT, ID_LOG_CLEAN, ID_LOG_SAVE, ID_OPEN_MACRO, ID_ORIENTATION_OBLIQUE, ID_ORIENTATION_XY, ID_ORIENTATION_XZ, ID_ORIENTATION_YZ, ID_PROJ_ORTHOGRAPHIC, ID_PROJ_PERSPECTIVE, ID_RUN_BEAMON, ID_RUN_CMD, ID_SAVE_VIEWER_STATE, ID_VIEW_SOLID, ID_VIEW_WIREFRAME, ID_ZOOM_IN, ID_ZOOM_OUT, and IDC_MAIN_EDIT.

◆ ProcessDownKey()

void G4UIWin32::ProcessDownKey ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 825 of file G4UIWin32.cc.

825 {
826 G4int pos = fHistoryPos + 1;
827 if ((pos >= 0) && (pos < (G4int) fHistory.size())) {
828 G4String command = fHistory[pos];
829 const char* d = command.data();
830 G4int l = strlen(d);
831 Edit_SetText(fHWndComboEditor, d);
832 Edit_SetSel(fHWndComboEditor, l, l);
833
835 } else if (pos >= (G4int) fHistory.size()) {
836 Edit_SetText(fHWndComboEditor, "");
837 Edit_SetSel(fHWndComboEditor, 0, 0);
838
839 fHistoryPos = -1;
840 }
841}
static const G4double pos
std::vector< G4String > fHistory
Definition: G4UIWin32.hh:180

References fHistory, fHistoryPos, fHWndComboEditor, and pos.

◆ ProcessEnterKey()

void G4UIWin32::ProcessEnterKey ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 758 of file G4UIWin32.cc.

758 {
759 char buffer[256];
760 DWORD dwIndex, numItems;
761
762 // Only process the command it the user has written something
763 if (SendMessage(fHWndComboBox, WM_GETTEXT, (WPARAM) sizeof(buffer), (LPARAM) buffer) != 0) {
764 SetFocus(fHWndComboBox);
765
766 // Read command
767 G4String command(buffer);
768
769 // Now clear the current selection.
770 SendMessage(fHWndComboBox, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
771
772 if (fHelp) {
773 exitHelp = true;
774 fHelp = ConvertStringToInt(command.data(), fHelpChoice);
775 } else {
776 fHistory.push_back(command);
777 fHistoryPos = -1;
779
780 // Now update the history in the ComboBox
781
782 // Check if this command exists in the ComboBox
783 dwIndex = SendMessage(fHWndComboBox, CB_FINDSTRINGEXACT, (WPARAM) (-1), (LPARAM) buffer);
784
785 // Add the string, if necessary
786 if (dwIndex == CB_ERR)
787 dwIndex = SendMessage(fHWndComboBox, CB_INSERTSTRING, (WPARAM) 0, (LPARAM) buffer);
788 // If the string exists, move it to the first position
789 if (dwIndex != CB_ERR) {
790 SendMessage(fHWndComboBox, CB_DELETESTRING, (WPARAM) dwIndex, (LPARAM) 0);
791 dwIndex = SendMessage(fHWndComboBox, CB_INSERTSTRING, (WPARAM) 0, (LPARAM) buffer);
792 }
793
794 numItems = SendMessage(fHWndComboBox, CB_GETCOUNT, (WPARAM) 0, (LPARAM) 0);
795 while (numItems > MAX_HISTORY_ITEMS) {
796 SendMessage(fHWndComboBox, CB_DELETESTRING, (WPARAM) (numItems - 1), (LPARAM) 0);
797 numItems = SendMessage(fHWndComboBox, CB_GETCOUNT, (WPARAM) 0, (LPARAM) 0);
798 }
799 }
800 }
801}
static G4bool ConvertStringToInt(const char *, G4int &)
Definition: G4UIWin32.cc:1299
#define MAX_HISTORY_ITEMS
Definition: G4UIWin32.hh:72
#define buffer
Definition: xmlparse.cc:628

References G4VBasicShell::ApplyShellCommand(), buffer, ConvertStringToInt(), exitHelp, exitPause, exitSession, fHelp, fHelpChoice, fHistory, fHistoryPos, fHWndComboBox, and MAX_HISTORY_ITEMS.

◆ ProcessEscKey()

void G4UIWin32::ProcessEscKey ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 747 of file G4UIWin32.cc.

747 {
748 // Clear the current selection.
749 SendMessage(fHWndComboBox, CB_SETCURSEL, (WPARAM) (-1), (LPARAM) 0);
750 // Set the focus to the Combo Box.
751 SetFocus(fHWndComboBox);
752}

References fHWndComboBox.

◆ ProcessTabKey()

void G4UIWin32::ProcessTabKey ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 721 of file G4UIWin32.cc.

721 {
722 char buffer[256];
723
724 // Only process the command it the user has written something
725 if (SendMessage(fHWndComboBox, WM_GETTEXT, (WPARAM) sizeof(buffer), (LPARAM) buffer) != 0) {
726 G4String command(buffer);
727
728 SetFocus(fHWndComboBox);
729
730 G4String cmd = Complete(command);
731 const char* d = cmd.data();
732 G4int l = strlen(d);
733 Edit_SetText(fHWndComboEditor, d);
734 Edit_SetSel(fHWndComboEditor, l, l);
735 } else {
736 if (GetFocus() == fHWndComboEditor)
737 SetFocus(fHWndHelpTree);
738 else
739 SetFocus(fHWndComboBox);
740 }
741}
G4String Complete(const G4String &)

References buffer, G4VBasicShell::Complete(), fHWndComboBox, fHWndComboEditor, and fHWndHelpTree.

◆ ProcessUpKey()

void G4UIWin32::ProcessUpKey ( )
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 807 of file G4UIWin32.cc.

807 {
808 G4int pos = fHistoryPos == -1 ?
809 fHistory.size() - 1: fHistoryPos - 1;
810 if ((pos >= 0) && (pos < (G4int) fHistory.size())) {
811 G4String command = fHistory[pos];
812 const char* d = command.data();
813 G4int l = strlen(d);
814 Edit_SetText(fHWndComboEditor, d);
815 Edit_SetSel(fHWndComboEditor, l, l);
816
818 }
819}

References fHistory, fHistoryPos, fHWndComboEditor, and pos.

◆ Prompt()

void G4UIWin32::Prompt ( const G4String a_prompt)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 229 of file G4UIWin32.cc.

229{}

Referenced by GetHelpChoice(), SecondaryLoop(), and SessionStart().

◆ ReceiveG4cerr()

G4int G4UIWin32::ReceiveG4cerr ( const G4String a_string)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 287 of file G4UIWin32.cc.

287 {
288 // Geant4 uses UNIX's style for new lines (\n)
289 // we must convert them to Windows' style (\r\n)
290 G4String str = ConvertNewLines(a_string);
291
292 AddText((LPSTR) str.data());
293
294 return 0;
295}
void AddText(LPSTR)
Definition: G4UIWin32.cc:1063
static G4String ConvertNewLines(G4String)
Definition: G4UIWin32.cc:997

References AddText(), and ConvertNewLines().

◆ ReceiveG4cerr_()

G4int G4coutDestination::ReceiveG4cerr_ ( const G4String msg)
inherited

Definition at line 84 of file G4coutDestination.cc.

85{
86 if(transformersCout.size() > 0)
87 {
88 G4String m = msg;
89 std::for_each(transformersCerr.begin(), transformersCerr.end(),
90 [&m](const Transformer& t) { t(m); }
91 // Call transforming function on message
92 );
93 return ReceiveG4cerr(m);
94 }
95 else
96 {
97 return ReceiveG4cerr(msg);
98 }
99}
static constexpr double m
Definition: G4SIunits.hh:109
virtual G4int ReceiveG4cerr(const G4String &msg)
std::function< G4bool(G4String &)> Transformer

References m, G4coutDestination::ReceiveG4cerr(), G4coutDestination::transformersCerr, and G4coutDestination::transformersCout.

Referenced by G4MasterForwardcoutDestination::ReceiveG4cerr().

◆ ReceiveG4cout()

G4int G4UIWin32::ReceiveG4cout ( const G4String a_string)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 273 of file G4UIWin32.cc.

273 {
274 // Geant4 uses UNIX's style for new lines (\n)
275 // we must convert them to Windows' style (\r\n)
276 G4String str = ConvertNewLines(a_string);
277
278 AddText((LPSTR) str.data());
279
280 return 0;
281}

References AddText(), and ConvertNewLines().

◆ ReceiveG4cout_()

G4int G4coutDestination::ReceiveG4cout_ ( const G4String msg)
inherited

Definition at line 62 of file G4coutDestination.cc.

63{
64 // Avoid copy of string if not necessary
65 if(transformersCout.size() > 0)
66 {
67 G4String m = msg;
68 G4bool result = true;
69 for(const auto& el : transformersCout)
70 {
71 result &= el(m);
72 if(!result)
73 break;
74 }
75 return (result ? ReceiveG4cout(m) : 0);
76 }
77 else
78 {
79 return ReceiveG4cout(msg);
80 }
81}
virtual G4int ReceiveG4cout(const G4String &msg)

References m, G4coutDestination::ReceiveG4cout(), and G4coutDestination::transformersCout.

Referenced by G4MasterForwardcoutDestination::ReceiveG4cout().

◆ ResetTransformers()

void G4coutDestination::ResetTransformers ( )
virtualinherited

Definition at line 41 of file G4coutDestination.cc.

42{
43 transformersCout.clear();
44 transformersCerr.clear();
45}

References G4coutDestination::transformersCerr, and G4coutDestination::transformersCout.

◆ ResizeComponents()

G4bool G4UIWin32::ResizeComponents ( HWND  aWindow)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 659 of file G4UIWin32.cc.

659 {
660 RECT rcTool;
661 G4int iToolHeight, iToolWidth;
662
663 RECT rcStatus;
664 G4int iStatusHeight;
665
666 RECT rcComboBox;
667 G4int iComboBoxHeight;
668
669 G4int iTreeViewHeight, iTreeViewWidth;
670 G4int iEditHeight, iEditWidth;
671
672 RECT rcClient;
673
674 // Size toolbar and get height and width
675 SendMessage(fHWndToolBar, TB_AUTOSIZE, 0, 0);
676
677 GetWindowRect(fHWndToolBar, &rcTool);
678 iToolHeight = rcTool.bottom - rcTool.top;
679 iToolWidth = rcTool.right - rcTool.left;
680
681 // Size status bar and get height
682 SendMessage(fHWndStatus, WM_SIZE, 0, 0);
683
684 GetWindowRect(fHWndStatus, &rcStatus);
685 iStatusHeight = rcStatus.bottom - rcStatus.top;
686
687 // Size status the Combo Box and get height
688 SendMessage(fHWndComboBox, WM_SIZE, 0, 0);
689
690 GetWindowRect(fHWndComboBox, &rcComboBox);
691 iComboBoxHeight = rcComboBox.bottom - rcComboBox.top;
692
693 // Calculate remaining height and size edit
694 GetClientRect(aWindow, &rcClient);
695
696 iTreeViewHeight = rcClient.bottom - iToolHeight - iStatusHeight;
697 iTreeViewWidth = iToolWidth/4;
698
699 iEditHeight = rcClient.bottom - iToolHeight - iComboBoxHeight - iStatusHeight;
700 iEditWidth = iToolWidth - iTreeViewWidth;
701
702 // TreeView location and size
703 SetWindowPos(fHWndHelpTree, nullptr, 0, iToolHeight,
704 iTreeViewWidth, iTreeViewHeight, SWP_NOZORDER);
705
706 // Editor location and size
707 SetWindowPos(fHWndEditor, nullptr, iTreeViewWidth, iToolHeight,
708 iEditWidth, iEditHeight, SWP_NOZORDER);
709
710 // ComboBox location and size
711 SetWindowPos(fHWndComboBox, nullptr, iTreeViewWidth, iToolHeight + iEditHeight,
712 iEditWidth, 200, 0);
713
714 return true;
715}

References fHWndComboBox, fHWndEditor, fHWndHelpTree, fHWndStatus, and fHWndToolBar.

◆ SaveLogFile()

G4bool G4UIWin32::SaveLogFile ( LPCTSTR  fileName)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 1028 of file G4UIWin32.cc.

1028 {
1029 HANDLE hFile;
1030 G4bool bSuccess = false;
1031
1032 hFile = CreateFile(fileName, GENERIC_WRITE, 0, nullptr,
1033 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
1034 if (hFile != INVALID_HANDLE_VALUE) {
1035 DWORD dwTextLength;
1036
1037 dwTextLength = GetWindowTextLength(fHWndEditor);
1038 // No need to bother if there's no text.
1039 if (dwTextLength > 0) {
1040 LPSTR text;
1041 DWORD dwBufferSize = dwTextLength + 1;
1042
1043 text = (LPSTR) GlobalAlloc(GPTR, dwBufferSize);
1044 if (text != nullptr) {
1045 if (GetWindowText(fHWndEditor, text, dwBufferSize)) {
1046 DWORD dwWritten;
1047
1048 if (WriteFile(hFile, text, dwTextLength, &dwWritten, nullptr))
1049 bSuccess = true;
1050 }
1051 GlobalFree(text);
1052 }
1053 }
1054 CloseHandle(hFile);
1055 }
1056 return bSuccess;
1057}

References fHWndEditor.

Referenced by DoSaveLog().

◆ SecondaryLoop()

void G4UIWin32::SecondaryLoop ( const G4String a_prompt)
private

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 256 of file G4UIWin32.cc.

256 {
257 if (interactorManager != nullptr) {
258 Prompt(a_prompt);
259 exitPause = false;
260 void* event;
261 while ((event = interactorManager->GetEvent()) != nullptr) {
263 if (exitPause) break;
264 }
265 Prompt("session");
266 }
267}

References G4VInteractorManager::DispatchEvent(), exitPause, G4VInteractorManager::GetEvent(), interactorManager, and Prompt().

Referenced by PauseSessionStart().

◆ SessionStart()

G4UIsession * G4UIWin32::SessionStart ( )
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 205 of file G4UIWin32.cc.

205 {
206 if (interactorManager != nullptr) {
207 Prompt("session");
208 exitSession = false;
209
210 // TODO: Ensure that the list of commands is updated
211 // Load commands into Help Tree View
213
215 void* event;
216 while ((event = interactorManager->GetEvent()) != nullptr) {
218 if (exitSession) break;
219 }
221 return this;
222 } else return this;
223}
G4bool InitHelpTreeItems()
Definition: G4UIWin32.cc:1161

References G4VInteractorManager::DisableSecondaryLoop(), G4VInteractorManager::DispatchEvent(), G4VInteractorManager::EnableSecondaryLoop(), exitSession, G4VInteractorManager::GetEvent(), InitHelpTreeItems(), interactorManager, and Prompt().

◆ SessionTerminate()

void G4UIWin32::SessionTerminate ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 235 of file G4UIWin32.cc.

235{}

◆ ShowCurrent()

void G4VBasicShell::ShowCurrent ( const G4String newCommand) const
protectedinherited

Definition at line 313 of file G4VBasicShell.cc.

314{
316 if(UI==NULL) return;
317 G4String comString = newCommand.substr(1,newCommand.length()-1);
318 G4String theCommand = ModifyToFullPathCommand(comString);
319 G4String curV = UI->GetCurrentValues(theCommand);
320 if( ! curV.empty() ) {
321 G4cout << "Current value(s) of the parameter(s) : " << curV << G4endl;
322 }
323}
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164

References G4cout, G4endl, G4UImanager::GetCurrentValues(), G4UImanager::GetUIpointer(), and G4VBasicShell::ModifyToFullPathCommand().

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIterminal::GetCommand(), and G4ZMQServer::GetCommand().

◆ TerminalHelp()

void G4VBasicShell::TerminalHelp ( const G4String newCommand)
protectedinherited

Definition at line 355 of file G4VBasicShell.cc.

356{
358 if(UI==NULL) return;
359 G4UIcommandTree * treeTop = UI->GetTree();
360 size_t i = newCommand.find(" ");
361 if( i != std::string::npos )
362 {
363 G4String newValue = newCommand.substr(i+1, newCommand.length()-(i+1));
364 G4StrUtil::strip(newValue);
365 G4String targetCom = ModifyToFullPathCommand(newValue);
366 G4UIcommand* theCommand = treeTop->FindPath(targetCom);
367 if( theCommand != NULL )
368 {
369 theCommand->List();
370 return;
371 }
372 else
373 {
374 G4cout << "Command <" << newValue << " is not found." << G4endl;
375 return;
376 }
377 }
378
379 G4UIcommandTree * floor[10];
380 floor[0] = treeTop;
381 size_t iFloor = 0;
382 size_t prefixIndex = 1;
384 while( prefixIndex < prefix.length()-1 )
385 {
386 size_t ii = prefix.find("/",prefixIndex);
387 floor[iFloor+1] =
388 floor[iFloor]->GetTree(G4String(prefix.substr(0,ii+1)));
389 prefixIndex = ii+1;
390 iFloor++;
391 }
392 floor[iFloor]->ListCurrentWithNum();
393 // 1998 Oct 2 non-number input
394 while(1){
395 //G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<std::flush;
396 G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<G4endl;
397 G4int j;
398 if(!GetHelpChoice(j)){
399 G4cout << G4endl << "Not a number, once more" << G4endl;
400 continue;
401 } else if( j < 0 ){
402 if( iFloor < (size_t)-j ) iFloor = 0;
403 else iFloor += j;
404 //iFloor += j;
405 //if( iFloor < 0 ) iFloor = 0;
406 floor[iFloor]->ListCurrentWithNum();
407 continue;
408 } else if(j == 0) {
409 break;
410 } else if( j > 0 ) {
411 G4int n_tree = floor[iFloor]->GetTreeEntry();
412 if( j > n_tree )
413 {
414 if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
415 {
416 floor[iFloor]->GetCommand(j-n_tree)->List();
417 }
418 }
419 else
420 {
421 floor[iFloor+1] = floor[iFloor]->GetTree(j);
422 iFloor++;
423 floor[iFloor]->ListCurrentWithNum();
424 }
425 }
426 }
427 G4cout << "Exit from HELP." << G4endl << G4endl;
428 //G4cout << G4endl;
429 ExitHelp();
430}
void ListCurrentWithNum() const
virtual void List()
Definition: G4UIcommand.cc:410
virtual void ExitHelp() const =0
virtual G4bool GetHelpChoice(G4int &)=0
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.

References G4VBasicShell::ExitHelp(), G4UIcommandTree::FindPath(), G4cout, G4endl, G4UIcommandTree::GetCommand(), G4VBasicShell::GetCurrentWorkingDirectory(), G4VBasicShell::GetHelpChoice(), G4UImanager::GetTree(), G4UIcommandTree::GetTree(), G4UIcommandTree::GetTreeEntry(), G4UImanager::GetUIpointer(), G4UIcommand::List(), G4UIcommandTree::ListCurrentWithNum(), G4VBasicShell::ModifyToFullPathCommand(), and G4StrUtil::strip().

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIterminal::GetCommand(), G4ZMQServer::GetCommand(), and G4UIQt::ShowHelpCallback().

Field Documentation

◆ commands

std::map<G4int, G4String, std::less<G4int> > G4UIWin32::commands
private

Definition at line 172 of file G4UIWin32.hh.

Referenced by AddButton(), and GetCommand().

◆ currentDirectory

G4String G4VBasicShell::currentDirectory
privateinherited

◆ fHelp

G4bool G4UIWin32::fHelp
private

Definition at line 178 of file G4UIWin32.hh.

Referenced by GetHelpChoice(), ProcessDefaultCommands(), and ProcessEnterKey().

◆ fHelpChoice

G4int G4UIWin32::fHelpChoice
private

Definition at line 179 of file G4UIWin32.hh.

Referenced by GetHelpChoice(), and ProcessEnterKey().

◆ fHistory

std::vector<G4String> G4UIWin32::fHistory
private

Definition at line 180 of file G4UIWin32.hh.

Referenced by ProcessDownKey(), ProcessEnterKey(), and ProcessUpKey().

◆ fHistoryPos

G4int G4UIWin32::fHistoryPos
private

Definition at line 181 of file G4UIWin32.hh.

Referenced by ProcessDownKey(), ProcessEnterKey(), and ProcessUpKey().

◆ fHWndComboBox

HWND G4UIWin32::fHWndComboBox
private

◆ fHWndComboEditor

HWND G4UIWin32::fHWndComboEditor
private

◆ fHWndEditor

HWND G4UIWin32::fHWndEditor
private

Definition at line 163 of file G4UIWin32.hh.

Referenced by AddText(), CreateComponents(), ResizeComponents(), SaveLogFile(), and ~G4UIWin32().

◆ fHWndHelpTree

HWND G4UIWin32::fHWndHelpTree
private

◆ fHWndMainWindow

HWND G4UIWin32::fHWndMainWindow
private

Definition at line 162 of file G4UIWin32.hh.

Referenced by AddMenu(), G4UIWin32(), ProcessDefaultCommands(), and ~G4UIWin32().

◆ fHWndStatus

HWND G4UIWin32::fHWndStatus
private

Definition at line 168 of file G4UIWin32.hh.

Referenced by CreateComponents(), ResizeComponents(), and ~G4UIWin32().

◆ fHWndToolBar

HWND G4UIWin32::fHWndToolBar
private

Definition at line 164 of file G4UIWin32.hh.

Referenced by CreateComponents(), ResizeComponents(), and ~G4UIWin32().

◆ ifBatch

G4int G4UIsession::ifBatch = 0
protectedinherited

Definition at line 68 of file G4UIsession.hh.

Referenced by G4UIsession::~G4UIsession().

◆ inSession

G4int G4UIsession::inSession = 0
staticprotectedinherited

◆ interactorManager

G4VInteractorManager* G4UIWin32::interactorManager
private

Definition at line 170 of file G4UIWin32.hh.

Referenced by G4UIWin32(), GetHelpChoice(), SecondaryLoop(), and SessionStart().

◆ interactors

G4interactor_map G4VInteractiveSession::interactors
privateinherited

◆ lastRC

G4int G4UIsession::lastRC = 0
protectedinherited

◆ masterG4coutDestination

G4coutDestination * G4coutDestination::masterG4coutDestination = nullptr
staticprotectedinherited

◆ menuBar

HMENU G4UIWin32::menuBar
private

Definition at line 171 of file G4UIWin32.hh.

Referenced by AddMenu(), and G4UIWin32().

◆ messenger

G4UImessenger* G4VInteractiveSession::messenger
privateinherited

◆ transformersCerr

std::vector<Transformer> G4coutDestination::transformersCerr
protectedinherited

◆ transformersCout

std::vector<Transformer> G4coutDestination::transformersCout
protectedinherited

The documentation for this class was generated from the following files: