Properties.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "UnitTest.h"
  2. #include "Gwen/Controls/Properties.h"
  3. #include "Gwen/Controls/PropertyTree.h"
  4. using namespace Gwen;
  5. class Properties2 : public GUnit
  6. {
  7. public:
  8. GWEN_CONTROL_INLINE( Properties2, GUnit )
  9. {
  10. {
  11. Gwen::Controls::Properties* props = new Gwen::Controls::Properties( this );
  12. props->SetBounds( 10, 10, 150, 300 );
  13. {
  14. {
  15. Gwen::Controls::PropertyRow* pRow = props->Add( L"First Name" );
  16. pRow->onChange.Add( this, &Properties2::OnFirstNameChanged );
  17. }
  18. props->Add( L"Middle Name" );
  19. props->Add( L"Last Name" );
  20. }
  21. }
  22. {
  23. Gwen::Controls::PropertyTree* ptree = new Gwen::Controls::PropertyTree( this );
  24. ptree->SetBounds( 200, 10, 200, 200 );
  25. {
  26. Gwen::Controls::Properties* props = ptree->Add( L"Item One" );
  27. props->Add( L"Middle Name" );
  28. props->Add( L"Last Name" );
  29. props->Add( L"Four" );
  30. }
  31. {
  32. Gwen::Controls::Properties* props = ptree->Add( L"Item Two" );
  33. props->Add( L"More Items" );
  34. props->Add( L"To Fill" );
  35. props->Add( L"Out Here" );
  36. }
  37. ptree->ExpandAll();
  38. }
  39. }
  40. void OnFirstNameChanged( Controls::Base* pControl )
  41. {
  42. Gwen::Controls::PropertyRow* pRow = (Gwen::Controls::PropertyRow*) pControl;
  43. UnitPrint( Utility::Format( L"First Name Changed: %s", pRow->GetProperty()->GetPropertyValue().c_str() ) );
  44. }
  45. };
  46. DEFINE_UNIT_TEST( Properties2, L"Properties" );