App_gSpiceUI.cpp
6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//**************************************************************************************************
// App_gSpiceUI.hpp *
// ------------------ *
// Started : 2003-08-15 *
// Last Update : 2016-10-25 *
// Copyright : (C) 2003-2016 MSWaters *
//**************************************************************************************************
//**************************************************************************************************
// *
// This program is free software; you can redistribute it and/or modify it under the *
// terms of the GNU General Public License as published by the Free Software Foundation; *
// either version 3 of the License, or (at your option) any later version. *
// *
//**************************************************************************************************
#include "App_gSpiceUI.hpp"
//**************************************************************************************************
// All programs must have a "main" function. Under wxWidgets main( ) is implemented using the
// following macro which creates an application instance and starts program execution.
wxIMPLEMENT_APP( App_gSpiceUI );
//**************************************************************************************************
// Implement an event table in which the events are routed to their respective
// handler functions in the class. If -1 is given as the ID, the given handler
// will be invoked for any event of the specified type.
//wxBEGIN_EVENT_TABLE( App_gSpiceUI, wxApp )
//wxEND_EVENT_TABLE( )
//**************************************************************************************************
// Constructor.
App_gSpiceUI::App_gSpiceUI( void )
{
g_bDebug = false;
m_poFrmMain = NULL;
}
//**************************************************************************************************
// Destructor.
App_gSpiceUI::~App_gSpiceUI( )
{
}
//**************************************************************************************************
// Set the configuration file name and update its contents based on the command line arguments.
void App_gSpiceUI::UpdateCfg( void )
{
// Set the simulation engine type
if( m_oCmdLn.m_eSimEng != eSIMR_NONE ) g_oConfig.bSetSimEng( m_oCmdLn.m_eSimEng );
// Set the schematic capture / editor program
// if( ! m_oCmdLn.m_osSchemEdit.IsEmpty( ) ) g_oConfig.bSetSchemEdit( m_oCmdLn.m_osSchemEdit );
// Set the waveform data viewer utility
if( m_oCmdLn.m_eDataViewer != eVIEW_NONE ) g_oConfig.bSetDataViewer( m_oCmdLn.m_eDataViewer );
// Set the analysis type
if( m_oCmdLn.m_eAnalysis != eCMD_NONE ) g_oConfig.bSetAnalysis( m_oCmdLn.m_eAnalysis );
// Set the Guile procedure to be used by GNetList
if( ! m_oCmdLn.m_osGuileProc.IsEmpty( ) ) g_oConfig.bSetGuileProc( m_oCmdLn.m_osGuileProc );
// Set the netlist and/or the schematics file name/s
if( ! m_oCmdLn.m_osNetLstFile.IsEmpty( ) || ! m_oCmdLn.m_osaSchemFiles.IsEmpty( ) )
{
g_oConfig.bSetNetLstFile( m_oCmdLn.m_osNetLstFile );
g_oConfig.bSetSchemFiles( m_oCmdLn.m_osaSchemFiles );
}
// Write any changes to file
g_oConfig.bFlush( );
}
//**************************************************************************************************
// Event Handlers *
//**************************************************************************************************
// wxWidgets calls wxApp::OnInit( ) at startup.
//
// This method is used to initialize the application.
//
// Return Values :
// true - Success (continue application execution)
// false - Failure (terminate application execution)
bool App_gSpiceUI::OnInit( void )
{
// The following lines magically makes locale stuff work, don't touch!
m_oLocale.Init( wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT );
setlocale( LC_NUMERIC, "C" );
// Process the command line
if( ! m_oCmdLn.bSetCmdLn( argc, argv ) ) return( false );
if( ! m_oCmdLn.bProcArgs( ) ) return( false );
// Open the global configuration object
if( ! m_oCmdLn.m_osConfigFile.IsEmpty( ) )
g_oConfig.bSetFileName( m_oCmdLn.m_osConfigFile );
else g_oConfig.bSetFileName( wxString( wxT('.') ) + GetAppName( ) + wxT(".conf") );
g_oConfig.bOpen( );
// Update the configuration with command line argument values (if any)
UpdateCfg( );
// Rebuild/clean the configuration file if requested
if( m_oCmdLn.m_bCleanCfgFile ) g_oConfig.bClean( );
// Create the GUI
m_poFrmMain = new FrmMain( this );
m_poFrmMain->Show( true );
SetTopWindow( m_poFrmMain );
// Display error message held over during startup
m_poFrmMain->DlgErrMsg( );
return( true );
}
//**************************************************************************************************
// wxWidgets calls wxApp::OnRun( ) to start execution of the application.
//
// This function is where the execution of a program written in wxWidgets starts. The default
// implementation just enters the main loop and starts handling the events until it terminates. The
// return value of this function becomes the exit code of the application.
//
// Return Values :
// EXIT_SUCCESS - application exit code on success
// EXIT_FAILURE - application exit code on failure
/*
int App_gSpiceUI::OnRun( void )
{
return( EXIT_SUCCESS );
}
*/
//**************************************************************************************************
// wxWidgets calls wxApp::OnExit( ) on application termination.
//
// This method does any processing which needs to be done as the application is about to exit. Note
// that it is not called at all if OnInit( ) failed.
//
// Return Values :
// 0 - the return value is not used
int App_gSpiceUI::OnExit( void )
{
g_oConfig.bFlush( );
g_oConfig.bClose( );
return( 0 );
}
//**************************************************************************************************