Advertisement
Guest User

Untitled

a guest
Dec 21st, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1.  
  2. using namespace std;
  3.  
  4.  
  5. namespace Original{
  6.  
  7. namespace WindowLibTest{
  8. // To check the message
  9. namespace {
  10. void MsgBox( const std::string msg ){
  11. MessageBox( NULL, msg.c_str(), "Debug", MB_OK );
  12. }
  13. void MsgBox( const std::wstring msg ){
  14. MessageBoxW( NULL, msg.c_str(), L"Debug", MB_OK );
  15. }
  16. }
  17. // This
  18. void ThrowingException()throw(int){
  19. throw (int)-1;
  20. }
  21. // This
  22. void CatchingException(){
  23. try{
  24. ThrowingException();
  25. }catch( int e ){
  26.  
  27. }
  28. }
  29.  
  30. class CMain{
  31. public:
  32. CMain( int argc, char *argv[] ){
  33. arg.size = argc;
  34. arg.text = argv;
  35. this->init();
  36. }
  37.  
  38. ~CMain(){
  39. this->uninit();
  40. }
  41.  
  42. int operator()(){
  43. return Main();
  44. }
  45. public:
  46. virtual bool closed( int id ){
  47. MsgBox( "Window::closed" );
  48. return true;
  49. }
  50.  
  51. virtual bool clicked( int id, bool state ){
  52.  
  53. return true;
  54. }
  55.  
  56. virtual bool textChanged( int id, const std::string text ){
  57.  
  58. return false;
  59. }
  60.  
  61. virtual bool menuChecked( int id, bool state ){
  62. string msg;
  63. if( id == 1 ) msg = "C++ > std::string";
  64. if( id == 2 ) msg = "C++ > std::vector";
  65. if( id == 3 ) msg = "C++ > std::string > length()";
  66. MsgBox( msg );
  67.  
  68. if( menu1->items().at(0)->isCheckable() ){
  69. menu1->items().at(0)->setCheckable( true );
  70. }else{
  71. MsgBox( "menu1 has something wrong" );
  72. }
  73. }
  74.  
  75. protected:
  76. bool CmdlineExec( void ){
  77.  
  78. return false;
  79. }
  80.  
  81. void init( void ){
  82. app = new QtUse::QtWorker::CApplication( arg.size, arg.text );
  83. window = new QtUse::QtWindow::MainWindow( 101, nullptr, this );
  84. button1 = new QtUse::QtWindow::Button( 102, window, this );
  85. combo1 = new QtUse::QtWindow::FontComboBox( 105, window, this );
  86. status1 = new QtUse::QtWindow::StatusBar( 106, nullptr, this );
  87. return;
  88. }
  89.  
  90. void uninit( void ){
  91. delete window;
  92. delete app;
  93. return;
  94. }
  95.  
  96. void setup( void ){
  97. window->show();
  98. window->resize( 500, 500 );
  99. window->setText( "test!" );
  100.  
  101. button1->move( 10, 10 );
  102. button1->resize( 20, 100 );
  103. button1->setText( "button" );
  104. button1->setChecked(false);
  105.  
  106. combo1->move( 10, 32 );
  107. combo1->resize( 50, 222 );
  108.  
  109. status1->setText( "hello" );
  110.  
  111. window->setStatusBar( status1 );
  112.  
  113. menu1 = new QtUse::QtMenu::Menu( "C++", window );
  114. QtUse::QtMenu::Menu* menu2 = new QtUse::QtMenu::Menu( "Java", window );
  115. QtUse::QtMenu::MenuItem* item1 = new QtUse::QtMenu::MenuItem( "std::string", 1, window, this );
  116. QtUse::QtMenu::MenuItem* item2 = new QtUse::QtMenu::MenuItem( "std::vector", 2, window, this );
  117. menu1->addItem( item1 );
  118. menu1->addItem( item2 );
  119. item1->setCheckable( true );
  120.  
  121. CatchingException(); // <- Crash!
  122. return;
  123. }
  124.  
  125. int returnValue( void ){ app->exec(); }
  126. private:
  127. QtUse::QtWindow::MainWindow* window;
  128. QtUse::QtWindow::Button* button1;
  129. QtUse::QtWindow::FontComboBox* combo1;
  130. QtUse::QtWindow::StatusBar* status1;
  131. QtUse::QtWorker::CApplication* app;
  132. QtUse::QtMenu::Menu* menu1;
  133. };
  134.  
  135. int check( int argc, char *argv[] ){
  136. CMain Main( argc, argv );
  137. return Main();
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement