Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- namespace Original{
- namespace WindowLibTest{
- // To check the message
- namespace {
- void MsgBox( const std::string msg ){
- MessageBox( NULL, msg.c_str(), "Debug", MB_OK );
- }
- void MsgBox( const std::wstring msg ){
- MessageBoxW( NULL, msg.c_str(), L"Debug", MB_OK );
- }
- }
- // This
- void ThrowingException()throw(int){
- throw (int)-1;
- }
- // This
- void CatchingException(){
- try{
- ThrowingException();
- }catch( int e ){
- }
- }
- class CMain{
- public:
- CMain( int argc, char *argv[] ){
- arg.size = argc;
- arg.text = argv;
- this->init();
- }
- ~CMain(){
- this->uninit();
- }
- int operator()(){
- return Main();
- }
- public:
- virtual bool closed( int id ){
- MsgBox( "Window::closed" );
- return true;
- }
- virtual bool clicked( int id, bool state ){
- return true;
- }
- virtual bool textChanged( int id, const std::string text ){
- return false;
- }
- virtual bool menuChecked( int id, bool state ){
- string msg;
- if( id == 1 ) msg = "C++ > std::string";
- if( id == 2 ) msg = "C++ > std::vector";
- if( id == 3 ) msg = "C++ > std::string > length()";
- MsgBox( msg );
- if( menu1->items().at(0)->isCheckable() ){
- menu1->items().at(0)->setCheckable( true );
- }else{
- MsgBox( "menu1 has something wrong" );
- }
- }
- protected:
- bool CmdlineExec( void ){
- return false;
- }
- void init( void ){
- app = new QtUse::QtWorker::CApplication( arg.size, arg.text );
- window = new QtUse::QtWindow::MainWindow( 101, nullptr, this );
- button1 = new QtUse::QtWindow::Button( 102, window, this );
- combo1 = new QtUse::QtWindow::FontComboBox( 105, window, this );
- status1 = new QtUse::QtWindow::StatusBar( 106, nullptr, this );
- return;
- }
- void uninit( void ){
- delete window;
- delete app;
- return;
- }
- void setup( void ){
- window->show();
- window->resize( 500, 500 );
- window->setText( "test!" );
- button1->move( 10, 10 );
- button1->resize( 20, 100 );
- button1->setText( "button" );
- button1->setChecked(false);
- combo1->move( 10, 32 );
- combo1->resize( 50, 222 );
- status1->setText( "hello" );
- window->setStatusBar( status1 );
- menu1 = new QtUse::QtMenu::Menu( "C++", window );
- QtUse::QtMenu::Menu* menu2 = new QtUse::QtMenu::Menu( "Java", window );
- QtUse::QtMenu::MenuItem* item1 = new QtUse::QtMenu::MenuItem( "std::string", 1, window, this );
- QtUse::QtMenu::MenuItem* item2 = new QtUse::QtMenu::MenuItem( "std::vector", 2, window, this );
- menu1->addItem( item1 );
- menu1->addItem( item2 );
- item1->setCheckable( true );
- CatchingException(); // <- Crash!
- return;
- }
- int returnValue( void ){ app->exec(); }
- private:
- QtUse::QtWindow::MainWindow* window;
- QtUse::QtWindow::Button* button1;
- QtUse::QtWindow::FontComboBox* combo1;
- QtUse::QtWindow::StatusBar* status1;
- QtUse::QtWorker::CApplication* app;
- QtUse::QtMenu::Menu* menu1;
- };
- int check( int argc, char *argv[] ){
- CMain Main( argc, argv );
- return Main();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement