MenuStrip.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #include "UnitTest.h"
  2. #include "Gwen/Controls/MenuStrip.h"
  3. using namespace Gwen;
  4. class MenuStrip : public GUnit
  5. {
  6. public:
  7. GWEN_CONTROL_INLINE( MenuStrip, GUnit )
  8. {
  9. Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip( this );
  10. {
  11. Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"File" );
  12. pRoot->GetMenu()->AddItem( L"New", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  13. pRoot->GetMenu()->AddItem( L"Load", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  14. pRoot->GetMenu()->AddItem( L"Save", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  15. pRoot->GetMenu()->AddItem( L"Save As..", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  16. pRoot->GetMenu()->AddItem( L"Quit", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  17. }
  18. {
  19. Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E" );
  20. pRoot->GetMenu()->AddItem( L"\u5355\u5143\u6D4B\u8BD5", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  21. pRoot->GetMenu()->AddItem( L"\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
  22. }
  23. {
  24. Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"Submenu" );
  25. pRoot->GetMenu()->AddItem( "One" )->SetCheckable( true );
  26. {
  27. Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem( "Two" );
  28. pRootB->GetMenu()->AddItem( "Two.One" );
  29. pRootB->GetMenu()->AddItem( "Two.Two" );
  30. pRootB->GetMenu()->AddItem( "Two.Three" );
  31. pRootB->GetMenu()->AddItem( "Two.Four" );
  32. pRootB->GetMenu()->AddItem( "Two.Five" );
  33. pRootB->GetMenu()->AddItem( "Two.Six" );
  34. pRootB->GetMenu()->AddItem( "Two.Seven" );
  35. pRootB->GetMenu()->AddItem( "Two.Eight" );
  36. pRootB->GetMenu()->AddItem( "Two.Nine", "test16.png" );
  37. }
  38. pRoot->GetMenu()->AddItem( "Three" );
  39. pRoot->GetMenu()->AddItem( "Four" );
  40. pRoot->GetMenu()->AddItem( "Five" );
  41. {
  42. Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem( "Six" );
  43. pRootB->GetMenu()->AddItem( "Six.One" );
  44. pRootB->GetMenu()->AddItem( "Six.Two" );
  45. pRootB->GetMenu()->AddItem( "Six.Three" );
  46. pRootB->GetMenu()->AddItem( "Six.Four" );
  47. pRootB->GetMenu()->AddItem( "Six.Five", "test16.png" );
  48. {
  49. Gwen::Controls::MenuItem* pRootC = pRootB->GetMenu()->AddItem( "Six.Six" );
  50. pRootC->GetMenu()->AddItem( "Sheep" );
  51. pRootC->GetMenu()->AddItem( "Goose" );
  52. {
  53. Gwen::Controls::MenuItem* pRootD = pRootC->GetMenu()->AddItem( "Camel" );
  54. pRootD->GetMenu()->AddItem( "Eyes" );
  55. pRootD->GetMenu()->AddItem( "Nose" );
  56. {
  57. Gwen::Controls::MenuItem* pRootE = pRootD->GetMenu()->AddItem( "Hair" );
  58. pRootE->GetMenu()->AddItem( "Blonde" );
  59. pRootE->GetMenu()->AddItem( "Black" );
  60. {
  61. Gwen::Controls::MenuItem* pRootF = pRootE->GetMenu()->AddItem( "Red" );
  62. pRootF->GetMenu()->AddItem( "Light" );
  63. pRootF->GetMenu()->AddItem( "Medium" );
  64. pRootF->GetMenu()->AddItem( "Dark" );
  65. }
  66. pRootE->GetMenu()->AddItem( "Brown" );
  67. }
  68. pRootD->GetMenu()->AddItem( "Ears" );
  69. }
  70. pRootC->GetMenu()->AddItem( "Duck" );
  71. }
  72. pRootB->GetMenu()->AddItem( "Six.Seven" );
  73. pRootB->GetMenu()->AddItem( "Six.Eight" );
  74. pRootB->GetMenu()->AddItem( "Six.Nine" );
  75. }
  76. pRoot->GetMenu()->AddItem( "Seven" );
  77. }
  78. }
  79. void MenuItemSelect( Base* pControl )
  80. {
  81. Gwen::Controls::MenuItem* pMenuItem = (Gwen::Controls::MenuItem*)pControl;
  82. UnitPrint( Utility::Format( L"Menu Selected: %s", pMenuItem->GetText().c_str() ) );
  83. }
  84. };
  85. DEFINE_UNIT_TEST( MenuStrip, L"MenuStrip" );