hello, i got some questions!:
(im planning to make a Console application into a well designed GUI based application,as the console application is coded on the basis of standard C++ concepts ( and it should run on all platforms), im trying to make the Gui based version of the program that again can be said is cross platform , and thats why i chose Wxwidgets , again i gave it search and i found a powerful gui creation tool called WxSmith , so now after playing with it i have some question that is not answered it , and i realy appreciate if anybody answers any of my questions!
so here they are :
first : what are dialogs and what are frames ? whats the difference?
and how to add a dialog to a frame (or interact with dialogs, ex pressing on a button results in opening a new dialog ,and you know stuff like that) ?
second : where can i find more tutorials on wxsmith rather than the wikki page you specified earlier in this forum( by BYO, i think ( many tanx to you for the frame based tuts!))
and third : i have a console application (thats a simple emulator coded in standard C++) is it possible that i make it have a GUI using wxsmith?
all i need is a way of inputting and outputting the data, is it possible or i should rewrite the whole program from sketch using wxwidgets !? ( please run the sample code for familiarizing with the specific output and input stuff )
( if you need the code , i can give you that , Please , i need your help !
sample code "
//In the name of god
//http://www.cs.uaf.edu/~cs202/deitel/
// Exercise 8.19 Solution
#include <iostream.h>
#include <iomanip.h>
using namespace std;
const int SIZE = 100, MAX_WORD = 9999, MIN_WORD = -9999;
const long SENTINEL = -99999;
enum Commands { READ = 10, WRITE, LOAD = 20, STORE, ADD = 30, SUBTRACT,
DIVIDE, MULTIPLY, BRANCH = 40, BRANCHNEG, BRANCHZERO, HALT };
void load( int * const );
void execute( int * const, int * const, int * const, int * const,
int * const, int * const);
void dump( const int * const, int, int, int, int, int );
bool validWord( int );
int main()
{
int memory[ SIZE ] = { 0 }, accumulator = 0, instructionCounter = 0,
opCode = 0, operand = 0, instructionRegister = 0;
load( memory );
execute( memory, &accumulator, &instructionCounter, &instructionRegister,
&opCode, &operand );
dump( memory, accumulator, instructionCounter, instructionRegister,
opCode, operand );
return 0;
}
void load( int * const loadMemory )
{
long instruction;
int i = 0;
cout << "*** Welcome to Simpletron ***\n"
<< "*** Please enter your program one instruction ***\n"
<< "*** (or data word) at a time. I will type the ***\n"
<< "*** location number and a question mark (?). ***\n"
<< "*** You then type the word for that location. ***\n"
<< "*** Type the sentinel -99999 to stop entering ***\n"
<< "*** your program. ***\n" << "00 ? ";
cin >> instruction;
while ( instruction != SENTINEL ) {
if ( !validWord( instruction ) )
cout << "Number out of range. Please enter again.\n";
else
loadMemory[ i++ ] = instruction;
// function setfill sets the padding character for unused
// field widths.
cout << setw( 2 ) << setfill( '0' ) << i << " ? ";
cin >> instruction;
}
}
void execute( int * const memory, int * const acPtr, int * const icPtr,
int * const irPtr, int * const opCodePtr, int * const opPtr )
{
bool fatal = false;
int temp;
const char *messages[] = { "Accumulator overflow ***",
"Attempt to divide by zero ***",
"Invalid opcode detected ***" },
*termString = "\n*** Simpletron execution abnormally terminated ***",
*fatalString = "*** FATAL ERROR: ";
cout << "\n************START SIMPLETRON EXECUTION************\n\n";
do {
*irPtr = memory[ *icPtr ];
*opCodePtr = *irPtr / 100;
*opPtr = *irPtr % 100;
switch ( *opCodePtr ) {
case READ:
cout << "Enter an integer: ";
cin >> temp;
while ( !validWord( temp ) ) {
cout << "Number out of range. Please enter again: ";
cin >> temp;
}
memory[ *opPtr ] = temp;
++( *icPtr );
break;
case WRITE:
cout << "Contents of " << setw( 2 ) << setfill( '0' ) << *opPtr
<< ": " << memory[ *opPtr ] << '\n';
++( *icPtr );
break;
case LOAD:
*acPtr = memory[ *opPtr ];
++( *icPtr );
break;
case STORE:
memory[ *opPtr ] = *acPtr;
++( *icPtr );
break;
case ADD:
temp = *acPtr + memory[ *opPtr ];
if ( !validWord( temp ) ) {
cout << fatalString << messages[ 0 ] << termString << '\n';
fatal = true;
}
else {
*acPtr = temp;
++( *icPtr );
}
break;
case SUBTRACT:
temp = *acPtr - memory[ *opPtr ];
if ( !validWord( temp ) ) {
cout << fatalString << messages[ 0 ] << termString << '\n';
fatal = true;
}
else {
*acPtr = temp;
++( *icPtr );
}
break;
case DIVIDE:
if ( memory[ *opPtr ] == 0 ) {
cout << fatalString << messages[ 1 ] << termString << '\n';
fatal = true;
}
else {
*acPtr /= memory[ *opPtr ];
++( *icPtr );
}
break;
case MULTIPLY:
temp = *acPtr * memory[ *opPtr ];
if ( !validWord( temp ) ) {
cout << fatalString << messages[ 0 ] << termString << '\n';
fatal = true;
}
else {
*acPtr = temp;
++( *icPtr );
}
break;
case BRANCH:
*icPtr = *opPtr;
break;
case BRANCHNEG:
*acPtr < 0 ? *icPtr = *opPtr : ++( *icPtr );
break;
case BRANCHZERO:
*acPtr == 0 ? *icPtr = *opPtr : ++( *icPtr );
break;
case HALT:
cout << "*** Simpletron execution terminated ***\n";
break;
default:
cout << fatalString << messages[ 2 ] << termString << '\n';
fatal = true;
break;
}
} while ( *opCodePtr != HALT && !fatal );
cout << "\n*************END SIMPLETRON EXECUTION*************\n";
}
void dump( const int * const memory, int accumulator, int instructionCounter,
int instructionRegister, int operationCode, int operand )
{
void output( const char * const, int, int, bool ); // prototype
cout << "\nREGISTERS:\n";
output( "accumulator", 5, accumulator, true );
output( "instructionCounter", 2, instructionCounter, false );
output( "instructionRegister", 5, instructionRegister, true );
output( "operationCode", 2, operationCode, false );
output( "operand", 2, operand, false );
cout << "\n\nMEMORY:\n";
int i = 0;
cout << setfill( ' ' ) << setw( 3 ) << ' ';
// print header
for ( ; i <= 9; ++i )
cout << setw( 5 ) << i << ' ';
for ( i = 0; i < SIZE; ++i ) {
if ( i % 10 == 0 )
cout << '\n' << setw( 2 ) << i << ' ';
cout << setiosflags( ios::internal | ios::showpos )
<< setw( 5 ) << setfill( '0' ) << memory[ i ] << ' '
<< resetiosflags( ios::internal | ios::showpos );
}
cout << endl;
}
bool validWord( int word )
{
return word >= MIN_WORD && word <= MAX_WORD;
}
void output( const char * const sPtr, int width, int value, bool sign )
{
// format of "accumulator", etc.
cout << setfill( ' ' ) << setiosflags( ios::left ) << setw( 20 )
<< sPtr << ' ';
// is a +/- sign needed?
if ( sign )
cout << setiosflags( ios::showpos | ios::internal );
// setup for displaying accumulator value, etc.
cout << resetiosflags( ios::left ) << setfill( '0' );
// determine the field widths and display value
if ( width == 5 )
cout << setw( width ) << value << '\n';
else // width is 2
cout << setfill( ' ' ) << setw( 3 ) << ' ' << setw( width )
<< setfill( '0' ) << value << '\n';
// disable sign if it was set
if ( sign )
cout << resetiosflags( ios::showpos | ios::internal );
}
tanx