@ -58,7 +58,7 @@
# define StatusElHeight (StatusHeight - 2 * StatusFrame)
# define StatusElHeight (StatusHeight - 2 * StatusFrame)
# define SourceLength 500 / / Platz fuer Source File Name
# define SourceLength 500 / / Platz fuer Source File Name
# define AnalyseLength 100 / / Platz fuer Analyse
# define AnalyseLength 100 / / Platz fuer Analyse
# define QuitButtonLength 8 0
# define QuitButtonLength 6 0
/* Define the macro below to create a larger main window that is useful
/* Define the macro below to create a larger main window that is useful
* for seeing debug output that is generated before the window can be
* for seeing debug output that is generated before the window can be
@ -69,6 +69,7 @@
# define NG_IGNORE(x) (void)x
# define NG_IGNORE(x) (void)x
# define QUIT_BUTTON_ID 2
# define QUIT_BUTTON_ID 2
# define STOP_BUTTON_ID 3
/* Types */
/* Types */
typedef char SBufLine [ SBufSize + 1 ] ; / / Eingabezeile
typedef char SBufLine [ SBufSize + 1 ] ; / / Eingabezeile
@ -82,7 +83,8 @@ HWND swString; /* input string */
HWND hwStatus ; /* status bar */
HWND hwStatus ; /* status bar */
HWND hwSource ; /* display of source name */
HWND hwSource ; /* display of source name */
HWND hwAnalyse ; /* analysis window */
HWND hwAnalyse ; /* analysis window */
HWND hwQuitButton ; /* Pause button */
HWND hwQuitButton ; /* End button */
HWND hwStopButton ; /* Pause button */
static int nReturnCode = 0 ; /* WinMain return value */
static int nReturnCode = 0 ; /* WinMain return value */
static int nShowState ; /* Display mode of main window */
static int nShowState ; /* Display mode of main window */
# ifdef EXT_ASC
# ifdef EXT_ASC
@ -134,6 +136,7 @@ extern bool ft_batchmode;
extern FILE * flogp ; /* definition see xmain.c, stdout redirected to file */
extern FILE * flogp ; /* definition see xmain.c, stdout redirected to file */
extern void cp_doquit ( void ) ;
extern void cp_doquit ( void ) ;
extern void cp_evloop ( char * ) ;
static struct History_info * init_history ( void ) ;
static struct History_info * init_history ( void ) ;
@ -506,11 +509,13 @@ Main_OnSize(HWND hwnd, UINT state, int cx, int cy)
/* Expand Status Elements */
/* Expand Status Elements */
h = cy - LineHeight + StatusFrame - 2 ;
h = cy - LineHeight + StatusFrame - 2 ;
int statbegin = 3 * StatusFrame + QuitButtonLength + AnalyseLength + 4 ;
int statbegin = 3 * StatusFrame + 2 * QuitButtonLength + AnalyseLength + 5 ;
MoveWindow ( hwSource , StatusFrame , h , cx - statbegin - BorderSize , StatusElHeight , TRUE ) ;
MoveWindow ( hwSource , StatusFrame , h , cx - statbegin - BorderSize , StatusElHeight , TRUE ) ;
MoveWindow ( hwAnalyse , cx - statbegin , h , AnalyseLength , StatusElHeight , TRUE ) ;
MoveWindow ( hwAnalyse , cx - statbegin , h , AnalyseLength , StatusElHeight , TRUE ) ;
MoveWindow ( hwQuitButton , cx - StatusFrame - QuitButtonLength - 1 ,
MoveWindow ( hwQuitButton , cx - StatusFrame - QuitButtonLength - 1 ,
h + 1 , QuitButtonLength , StatusElHeight , TRUE ) ;
h + 1 , QuitButtonLength , StatusElHeight , TRUE ) ;
MoveWindow ( hwStopButton , cx - StatusFrame - QuitButtonLength - QuitButtonLength - 3 ,
h + 1 , QuitButtonLength , StatusElHeight , TRUE ) ;
}
}
@ -531,12 +536,18 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* command issued by pushing the "Quit" button */
/* command issued by pushing the "Quit" button */
case WM_COMMAND :
case WM_COMMAND :
if ( HIWORD ( wParam ) = = BN_CLICKED )
if ( ft_batchmode & &
if ( HIWORD ( wParam ) = = BN_CLICKED ) {
if ( ft_batchmode & & LOWORD ( wParam ) = = QUIT_BUTTON_ID & &
( MessageBox ( NULL , " Do you want to quit ngspice? " , " Quit " , MB_OKCANCEL | MB_ICONERROR ) = = IDCANCEL ) )
( MessageBox ( NULL , " Do you want to quit ngspice? " , " Quit " , MB_OKCANCEL | MB_ICONERROR ) = = IDCANCEL ) )
goto DEFAULT_AFTER ;
goto DEFAULT_AFTER ;
if ( ft_batchmode & & LOWORD ( wParam ) = = STOP_BUTTON_ID & &
( MessageBox ( NULL , " Stop in Batch Mode is not available! " , " Stop " , MB_OK ) = = IDOK ) )
goto DEFAULT_AFTER ;
}
if ( LOWORD ( wParam ) = = QUIT_BUTTON_ID )
if ( LOWORD ( wParam ) = = QUIT_BUTTON_ID )
SendMessage ( GetParent ( ( HWND ) lParam ) , WM_CLOSE , 0 , 0 ) ;
SendMessage ( GetParent ( ( HWND ) lParam ) , WM_CLOSE , 0 , 0 ) ;
if ( LOWORD ( wParam ) = = STOP_BUTTON_ID )
SendMessage ( GetParent ( ( HWND ) lParam ) , WM_USER , 0 , 0 ) ;
/* write all achieved so far to log file */
/* write all achieved so far to log file */
if ( flogp )
if ( flogp )
win_x_fflush ( flogp ) ;
win_x_fflush ( flogp ) ;
@ -547,6 +558,10 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* continue if the user declined the 'quit' command */
/* continue if the user declined the 'quit' command */
return 0 ;
return 0 ;
case WM_USER :
cp_evloop ( NULL ) ;
goto DEFAULT_AFTER ;
case WM_SIZE :
case WM_SIZE :
HANDLE_WM_SIZE ( hwnd , wParam , lParam , Main_OnSize ) ;
HANDLE_WM_SIZE ( hwnd , wParam , lParam , Main_OnSize ) ;
goto DEFAULT_AFTER ;
goto DEFAULT_AFTER ;
@ -1288,15 +1303,18 @@ wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR
# else
# else
hwQuitButton = CreateWindowW ( L " BUTTON " , L " Quit " , WS_CHILD | BS_PUSHBUTTON , 0 , 0 , QuitButtonLength ,
hwQuitButton = CreateWindowW ( L " BUTTON " , L " Quit " , WS_CHILD | BS_PUSHBUTTON , 0 , 0 , QuitButtonLength ,
StatusElHeight , hwMain , ( HMENU ) ( UINT_PTR ) QUIT_BUTTON_ID , hInst , NULL ) ;
StatusElHeight , hwMain , ( HMENU ) ( UINT_PTR ) QUIT_BUTTON_ID , hInst , NULL ) ;
hwStopButton = CreateWindowW ( L " BUTTON " , L " Stop " , WS_CHILD | BS_PUSHBUTTON , 0 , 0 , QuitButtonLength ,
StatusElHeight , hwMain , ( HMENU ) ( UINT_PTR ) STOP_BUTTON_ID , hInst , NULL ) ;
# endif
# endif
if ( ! hwQuitButton )
if ( ! hwQuitButton )
goto THE_END ;
goto THE_END ;
SetWindowFont ( hwQuitButton , efont , FALSE ) ;
SetWindowFont ( hwQuitButton , efont , FALSE ) ;
SetWindowFont ( hwStopButton , efont , FALSE ) ;
/* Define a minimum width */
/* Define a minimum width */
int MinWidth = AnalyseLength + SourceLength + QuitButtonLength + 48 ;
int MinWidth = AnalyseLength + SourceLength + QuitButtonLength + QuitButtonLength + 48 ;
if ( WinLineWidth < MinWidth )
if ( WinLineWidth < MinWidth )
WinLineWidth = MinWidth ;
WinLineWidth = MinWidth ;
@ -1314,6 +1332,7 @@ wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR
ShowWindow ( hwSource , SW_SHOWNORMAL ) ;
ShowWindow ( hwSource , SW_SHOWNORMAL ) ;
ShowWindow ( hwAnalyse , SW_SHOWNORMAL ) ;
ShowWindow ( hwAnalyse , SW_SHOWNORMAL ) ;
ShowWindow ( hwQuitButton , SW_SHOWNORMAL ) ;
ShowWindow ( hwQuitButton , SW_SHOWNORMAL ) ;
ShowWindow ( hwStopButton , SW_SHOWNORMAL ) ;
ClearInput ( ) ;
ClearInput ( ) ;
DisplayText ( ) ;
DisplayText ( ) ;
SetSource ( " " ) ;
SetSource ( " " ) ;