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