Blame view

GUI/SW2/SRC/src/main/NbkTxtCtls.cpp 9.3 KB
886c558b   Steve Greedy   SACAMOS Public Re...
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
//**************************************************************************************************
//                                         NbkTxtCtls.cpp                                          *
//                                        ----------------                                         *
// Started     : 2005-06-14                                                                        *
// Last Update : 2015-04-01                                                                        *
// Copyright   : (C) 2005-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 "NbkTxtCtls.hpp"

//**************************************************************************************************
// Constructor.

NbkTxtCtls::NbkTxtCtls( void ) : wxNotebook( )
{
}

//**************************************************************************************************
// Destructor.

NbkTxtCtls::~NbkTxtCtls( )
{
}

//**************************************************************************************************
// Create an instantance of this object.
//
// Argument List :
//   poWin  - The parent window
//   oWinID - The window identifier
//   roPosn - The position
//   roSize - The size
//
// Return Values :
//   true  - Success
//   false - Failure

bool  NbkTxtCtls::bCreate( wxWindow * poWin, wxWindowID oWinID )
{
  bool      bRtn=true;
  wxString  os1;

  // Check if the object has already been created
  if( bIsCreated( ) )             return( true );

  // Create the notebook object to hold the text controls
  if( ! Create( poWin, oWinID ) ) return( false );

  // Allocate memory for the text controls
  TextCtrl * poTxcConsole = new TextCtrl;
  TextCtrl * poTxcNetList = new TextCtrl;
  TextCtrl * poTxcSimultn = new TextCtrl;
  TextCtrl * poTxcNgSpice = new TextCtrl;
  TextCtrl * poTxcGnuCap  = new TextCtrl;

  // Create the text controls
  if( ! poTxcConsole->bCreate( this ) ) bRtn = false;
  if( ! poTxcNetList->bCreate( this ) ) bRtn = false;
  if( ! poTxcSimultn->bCreate( this ) ) bRtn = false;
  if( ! poTxcNgSpice->bCreate( this ) ) bRtn = false;
  if( ! poTxcGnuCap ->bCreate( this ) ) bRtn = false;

  // Initialize the text controls
  os1 = wxT("No console I/O to display");
  if( ! poTxcConsole->bSetInitMsg( os1 ) ) bRtn = false;
  os1 = wxT("No netlist currently loaded");
  if( ! poTxcNetList->bSetInitMsg( os1 ) ) bRtn = false;
  os1 = wxT("No simulation currently defined");
  if( ! poTxcSimultn->bSetInitMsg( os1 ) ) bRtn = false;
  os1 = wxT("No NG-Spice simulation results to display");
  if( ! poTxcNgSpice->bSetInitMsg( os1 ) ) bRtn = false;
  os1 = wxT("No GNU-Cap simulation results to display");
  if( ! poTxcGnuCap ->bSetInitMsg( os1 ) ) bRtn = false;

  // Define tool tips for the wxNotebook and each page
  poTxcConsole->SetToolTip( wxT("Console I/O (non-editable)") );
  poTxcNetList->SetToolTip( wxT("Netlist file (non-editable)") );
  poTxcSimultn->SetToolTip( wxT("Simulation file (editable)") );
  poTxcNgSpice->SetToolTip( wxT("NG-Spice simulation results (non-editable)") );
  poTxcGnuCap ->SetToolTip( wxT("GNU-Cap simulation results (non-editable)") );

  // Add the display objects to the wxNotebook (wxNotebook will delete them)
  AddPage( poTxcConsole, wxT("   Console   ")  );
  AddPage( poTxcNetList, wxT("   NetList    ") );
  AddPage( poTxcSimultn, wxT(" Simulation ")   );
  AddPage( poTxcNgSpice, wxT("  NG-Spice   ")  );
  AddPage( poTxcGnuCap , wxT("  GNU-Cap   ")   );

  bInitialize( );

  return( bRtn );
}

//**************************************************************************************************
// Clear one or all text controls associated with the notebook.
//
// Argument List :
//   ePage - The enumerated page identifier
//
// Return Values :
//   true  - Success
//   false - Failure

bool  NbkTxtCtls::bClear( ePageType ePage )
{
  size_t  szt1;

  // Check that the object has been created
  if( ! bIsCreated( ) ) return( false );

  // Attempt the clear operation
  switch( ePage )
  {
    case ePAGE_CONSOLE :  // Clear a particular page
    case ePAGE_NETLIST :
    case ePAGE_SIMULTN :
    case ePAGE_NGSPICE :
    case ePAGE_GNUCAP  :
    case ePAGE_CURRENT :
      if( ! poGetPage( ePage )->bClear( ) )
        return( false );
      break;

    case ePAGE_ALL :      // Clear all pages
      for( szt1=0; szt1<GetPageCount( ); szt1++ )
        if( ! poGetPage( (ePageType) szt1 )->bClear( ) )
          return( false );
      break;

     default :            // Invalid page identifier
       return( false );
  }

  return( true );
}

//**************************************************************************************************
// Initialize one or all text controls associated with the notebook.
//
// Argument List :
//   ePage - The enumerated page identifier
//
// Return Values :
//   true  - Success
//   false - Failure

bool  NbkTxtCtls::bInitialize( ePageType ePage )
{
  size_t  szt1;

  // Check that the object has been created
  if( ! bIsCreated( ) ) return( false );

  // Attempt the initialize operation
  switch( ePage )
  {
    case ePAGE_CONSOLE :  // Initialize a particular page
    case ePAGE_NETLIST :
    case ePAGE_SIMULTN :
    case ePAGE_NGSPICE :
    case ePAGE_GNUCAP  :
    case ePAGE_CURRENT :
      if( ! poGetPage( ePage )->bInitialize( ) )
        return( false );
      break;

    case ePAGE_ALL :      // Initialize all pages
      for( szt1=0; szt1<GetPageCount( ); szt1++ )
        if( ! poGetPage( (ePageType) szt1 )->bInitialize( ) )
          return( false );
      break;

     default :            // Invalid page identifier
       return( false );
  }

  return( true );
}

//**************************************************************************************************
// Set the page to be displayed.
//
// Argument List :
//   ePage - The enumerated page identifier
//
// Return Values :
//   true  - Success
//   false - Failure

bool  NbkTxtCtls::bSetPage( NbkTxtCtls::ePageType ePage )
{
  // Check if the object has already been created
  if( ! bIsCreated( ) )                        return( false );

  // Check that the page identifier is valid
  if( GetPageCount( ) < ((size_t) ePage + 1) ) return( false );

  SetSelection( (size_t) ePage );

  return( true );
}

//**************************************************************************************************
// Set the insert and show positions in the currently displayed page.
//
// Argument List :
//   liPosn - The position
//
// Return Values :
//   true  - Success
//   false - Failure

bool  NbkTxtCtls::bSetPosn( long liPosn )
{
  TextCtrl * poTxtCtl;

  // Check if the object has already been created
  if( ! bIsCreated( ) )  return( false );

  // Get a pointer to the currently displayed page
  poTxtCtl = (TextCtrl *) GetCurrentPage( );

  if( poTxtCtl == NULL ) return( false );

  // Set the position
  if( liPosn >= 0 ) poTxtCtl->SetInsertionPoint( liPosn );
  else              poTxtCtl->SetInsertionPointEnd( );

  return( true );
}

//**************************************************************************************************
// Get the enumerated identifier for the currently displayed notebook page.
//
// Return Values :
//   Success - The enumerated page identifier
//   Failure - ePAGE_NONE

NbkTxtCtls::ePageType  NbkTxtCtls::eGetPage( void )
{
  ePageType  ePage;

  // Check if the object has already been created
  if( ! bIsCreated( ) ) return( ePAGE_NONE );

  // Get the enumerated identifier for the currently displayed page
  switch( GetSelection( ) )
  {
    case 0  : ePage = ePAGE_CONSOLE; break;
    case 1  : ePage = ePAGE_NETLIST; break;
    case 2  : ePage = ePAGE_SIMULTN; break;
    case 3  : ePage = ePAGE_NGSPICE; break;
    case 4  : ePage = ePAGE_GNUCAP;  break;
    default : ePage = ePAGE_NONE;
  }

  return( ePage );
}

//**************************************************************************************************
// Get a pointer to the text control currently being displayed.
//
// Argument List :
//   ePage - The enumerated page identifier
//
// Return Values :
//   Success - A pointer to the TextCtrl object
//   Failure - NULL

TextCtrl * NbkTxtCtls::poGetPage( NbkTxtCtls::ePageType ePage )
{
  // Check if the object has already been created
  if( ! bIsCreated( ) )                        return( NULL );

  // Check that the page identifier is valid
  if( ePage == ePAGE_CURRENT ) ePage = eGetPage( );
  if( GetPageCount( ) < ((size_t) ePage + 1) ) return( NULL );

  // Return a pointer to the requested page
  return( (TextCtrl *) GetPage( (size_t) ePage ) );
}

//**************************************************************************************************