GwenTextureWindow.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "GwenTextureWindow.h"
  2. #include "gwenUserInterface.h"
  3. #include "gwenInternalData.h"
  4. #include "Gwen/Controls/ImagePanel.h"
  5. class MyGraphWindow : public Gwen::Controls::WindowControl
  6. {
  7. Gwen::Controls::ImagePanel* m_imgPanel;
  8. public:
  9. class MyMenuItems2* m_menuItems;
  10. MyGraphWindow ( const MyGraphInput& input)
  11. : Gwen::Controls::WindowControl( input.m_data->pCanvas ),
  12. m_menuItems(0)
  13. {
  14. Gwen::UnicodeString str = Gwen::Utility::StringToUnicode(input.m_name);
  15. SetTitle( str );
  16. SetPos(input.m_xPos,input.m_yPos);
  17. SetSize( 12+input.m_width+2*input.m_borderWidth, 30+input.m_height+2*input.m_borderWidth );
  18. m_imgPanel = new Gwen::Controls::ImagePanel( this );
  19. if (input.m_texName)
  20. {
  21. Gwen::UnicodeString texName = Gwen::Utility::StringToUnicode(input.m_texName);
  22. m_imgPanel->SetImage( texName );
  23. }
  24. m_imgPanel->SetBounds( input.m_borderWidth, input.m_borderWidth,
  25. input.m_width,
  26. input.m_height );
  27. // this->Dock( Gwen::Pos::Bottom);
  28. }
  29. virtual ~MyGraphWindow()
  30. {
  31. delete m_imgPanel;
  32. }
  33. };
  34. class MyMenuItems2 : public Gwen::Controls::Base
  35. {
  36. MyGraphWindow* m_graphWindow;
  37. public:
  38. Gwen::Controls::MenuItem* m_item;
  39. MyMenuItems2(MyGraphWindow* graphWindow)
  40. :Gwen::Controls::Base(0),
  41. m_graphWindow(graphWindow),
  42. m_item(0)
  43. {
  44. }
  45. void MenuItemSelect(Gwen::Controls::Base* pControl)
  46. {
  47. if (m_graphWindow->Hidden())
  48. {
  49. m_graphWindow->SetHidden(false);
  50. //@TODO(erwincoumans) setCheck/SetCheckable drawing is broken, need to see what's wrong
  51. // if (m_item)
  52. // m_item->SetCheck(false);
  53. } else
  54. {
  55. m_graphWindow->SetHidden(true);
  56. // if (m_item)
  57. // m_item->SetCheck(true);
  58. }
  59. }
  60. };
  61. MyGraphWindow* setupTextureWindow(const MyGraphInput& input)
  62. {
  63. MyGraphWindow* graphWindow = new MyGraphWindow(input);
  64. MyMenuItems2* menuItems = new MyMenuItems2(graphWindow);
  65. graphWindow->m_menuItems = menuItems;
  66. Gwen::UnicodeString str = Gwen::Utility::StringToUnicode(input.m_name);
  67. menuItems->m_item = input.m_data->m_viewMenu->GetMenu()->AddItem( str, menuItems,(Gwen::Event::Handler::Function)&MyMenuItems2::MenuItemSelect);
  68. // menuItems->m_item->SetCheckable(true);
  69. return graphWindow;
  70. }
  71. void destroyTextureWindow(MyGraphWindow* window)
  72. {
  73. delete window->m_menuItems->m_item;
  74. delete window->m_menuItems;
  75. delete window;
  76. }