1 /*!
2 	@file
3 	@author		Albert Semenov
4 	@date		08/2008
5 */
6 #include "Precompiled.h"
7 #include "PanelDynamic.h"
8 
9 namespace demo
10 {
11 
PanelDynamic()12 	PanelDynamic::PanelDynamic() : BasePanelViewItem("")
13 	{
14 	}
15 
initialise()16 	void PanelDynamic::initialise()
17 	{
18 		mPanelCell->setCaption("Dynamic panel");
19 
20 		const int height = 24;
21 		const int height_step = 26;
22 		const int width = 55;
23 		const int width_step = 3;
24 		int height_current = 0;
25 		for (size_t pos = 0; pos < 16; ++pos)
26 		{
27 			MyGUI::TextBox* text = mWidgetClient->createWidget<MyGUI::TextBox>("TextBox", MyGUI::IntCoord(width_step, height_current, width, height), MyGUI::Align::Left | MyGUI::Align::Top);
28 			text->setTextAlign(MyGUI::Align::Right | MyGUI::Align::VCenter);
29 			text->setCaption(MyGUI::utility::toString("line ", pos + 1, " : "));
30 			mItemsText.push_back(text);
31 
32 			MyGUI::EditBox* edit = mWidgetClient->createWidget<MyGUI::EditBox>("Edit", MyGUI::IntCoord(width_step + width_step + width, height_current, mWidgetClient->getWidth() - (width_step + width_step + width_step + width), height), MyGUI::Align::HStretch | MyGUI::Align::Top);
33 			mItemsEdit.push_back(edit);
34 
35 			height_current += height_step;
36 		}
37 
38 		mPanelCell->setClientHeight(height_current, false);
39 	}
40 
shutdown()41 	void PanelDynamic::shutdown()
42 	{
43 		mItemsText.clear();
44 		mItemsEdit.clear();
45 	}
46 
setVisibleCount(size_t _count)47 	void PanelDynamic::setVisibleCount(size_t _count)
48 	{
49 		const int height_step = 26;
50 		int height_current = 0;
51 		for (size_t pos = 0; pos < 16; ++pos)
52 		{
53 			if (pos < _count)
54 			{
55 				mItemsText[pos]->setVisible(true);
56 				mItemsEdit[pos]->setVisible(true);
57 				height_current += height_step;
58 			}
59 			else
60 			{
61 				mItemsText[pos]->setVisible(false);
62 				mItemsEdit[pos]->setVisible(false);
63 			}
64 		}
65 		mPanelCell->setClientHeight(height_current, true);
66 	}
67 
68 } // namespace demo
69