ultimatepp/bazaar/TabBarCtrlTest/main.cpp
micio efbad2ccc6 Bazaar/TabBarCtrl - corrected a Bug - Updated demo
git-svn-id: svn://ultimatepp.org/upp/trunk@1903 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2010-01-17 19:19:46 +00:00

85 lines
1.6 KiB
C++

#include "TabBarCtrlTest.h"
class TabBarTest : public WithTabBarTestLayout<TopWindow>
{
private:
TabBarCtrl tabCtrl;
WithFirstLayout<ParentCtrl> first;
WithSecondLayout<ParentCtrl> second;
WithBaseLayout<ParentCtrl> base;
void actionCb(void);
bool cancelCloseCb(Vector<int>tabs);
void closeCb(Vector<int>tabs);
public:
typedef TabBarTest CLASSNAME;
TabBarTest();
};
TabBarTest::TabBarTest()
{
CtrlLayout(*this, "Window title");
CtrlLayout(first);
CtrlLayout(second);
CtrlLayout(base);
Add(tabCtrl.SizePos());
Sizeable().Zoomable();
// add a fixed control to TabBarCtrl
tabCtrl.Add(base);
// setup actions
tabCtrl.WhenSet = THISBACK(actionCb);
tabCtrl.WhenClose = THISBACK(closeCb);
tabCtrl.CancelClose = THISBACK(cancelCloseCb);
tabCtrl.Add(first, "First");
tabCtrl.Add(second, "Second");
tabCtrl.Remove(1);
tabCtrl.Remove(0);
tabCtrl.Add(first, "First");
tabCtrl.Add(second, "Second");
tabCtrl.Add("Third");
for(int i = 3; i < 7; i++)
tabCtrl.Add("Item#" + FormatInt(i));
}
void TabBarTest::actionCb(void)
{
int i = tabCtrl.Get();
base.txt.SetText(base.txt.GetText() + Format("Pressed tab %d\n", i));
}
bool TabBarTest::cancelCloseCb(Vector<int>tabs)
{
String s = "Close item(s) ";
for(int i = 0; i < tabs.GetCount(); i++)
s += FormatInt(tabs[i]) + ", ";
s = s.Left(s.GetCount() - 2) + " ?";
if(PromptYesNo(s))
return false;
return true;
}
void TabBarTest::closeCb(Vector<int>tabs)
{
String s = "Closing item(s) ";
for(int i = 0; i < tabs.GetCount(); i++)
s += FormatInt(tabs[i]) + ", ";
s = s.Left(s.GetCount() - 2);
PromptOK(s);
}
GUI_APP_MAIN
{
TabBarTest tabBarTest;
tabBarTest.Run();
}