summaryrefslogtreecommitdiff
path: root/src/test/w32dtst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/w32dtst.cpp')
-rw-r--r--src/test/w32dtst.cpp68
1 files changed, 54 insertions, 14 deletions
diff --git a/src/test/w32dtst.cpp b/src/test/w32dtst.cpp
index 75b5b44..838c9f5 100644
--- a/src/test/w32dtst.cpp
+++ b/src/test/w32dtst.cpp
@@ -24,19 +24,24 @@
#include "dialog.h"
+#define DATAX_TEST
+
class Test : public W32DLib::Dialog
{
public:
- Test() : m_static(this,IDSTATIC1)
- , m_text(this,IDTEXT)
- , m_check(this,IDCHECK)
- , m_button(this,IDBUTTON)
- , m_quit(this,IDQUIT)
- , m_load(this,IDLOADTXT)
- , m_loadbut(this,IDLOADBUT)
- , m_save(this,IDSAVETXT)
- , m_savebut(this,IDSAVEBUT)
- , m_combo(this,IDCOMBO)
+ Test() : m_check_data(W32DLib::DataX::eBool)
+ , m_combo_data(W32DLib::DataX::eInt)
+ , m_text_data(W32DLib::DataX::eString)
+ , m_static(this,IDSTATIC1)
+ , m_text(this,IDTEXT,&m_text_data)
+ , m_check(this,IDCHECK,&m_check_data)
+ , m_button(this,IDBUTTON)
+ , m_quit(this,IDQUIT)
+ , m_load(this,IDLOADTXT)
+ , m_loadbut(this,IDLOADBUT)
+ , m_save(this,IDSAVETXT)
+ , m_savebut(this,IDSAVEBUT)
+ , m_combo(this,IDCOMBO,&m_combo_data)
{
m_button.OnPress
(this,static_cast<W32DLib::W32DLibCallback>(&Test::OnButton));
@@ -76,8 +81,9 @@ public:
virtual void OnInit()
{
std::cout << "OnInit()" << std::endl;
- m_text.SetText("Hello");
- m_check.SetState(W32DLib::AutoCheck::eChecked);
+ std::cout << "Can be used from a thread:"
+ << (HasMutex() ? "Yes":"No") << std::endl;
+
m_quit.Enable(true);
m_combo.Reset();
@@ -88,10 +94,23 @@ public:
std::cout << "count=" << m_combo.Count() << std::endl;
std::cout << "HWND=" << m_combo.GetHWND() << std::endl;
+#ifdef DATAX_TEST
+ m_text_data.Set("Hello");
+ m_check_data.Set(true);
+ m_combo_data.Set(2);
+ SetData();
+#else
+ m_text.SetText("Hello");
+ m_check.SetState(W32DLib::AutoCheck::eChecked);
m_combo.SelectedIndex(2);
+#endif
}
private:
+ W32DLib::DataX m_check_data;
+ W32DLib::DataX m_combo_data;
+ W32DLib::DataX m_text_data;
+
W32DLib::StaticText m_static;
W32DLib::Text m_text;
W32DLib::AutoCheck m_check;
@@ -118,11 +137,18 @@ private:
BOOL OnButton(UINT msg, WPARAM wp, LPARAM lp)
{
+#ifdef DATAX_TEST
+ GetData();
+ bool check=m_check_data.Bool();
+ std::string txt=m_text_data.Str();
+#else
+ bool check=m_check.GetState();
std::string txt=m_text.GetText();
+#endif
std::cout << "Called OnButton()" << std::endl;
std::cout << "text=" << txt << std::endl;
- std::cout << "check=" << m_check.GetState() << std::endl;
+ std::cout << "check=" << check << std::endl;
m_static.SetText(txt);
SetText(txt+" [Title]");
m_combo.AddString(m_combo.GetText());
@@ -132,7 +158,12 @@ private:
BOOL OnCheck(UINT msg, WPARAM wp, LPARAM lp)
{
+#ifdef DATAX_TEST
+ GetData();
+ bool checked=m_check_data.Bool();
+#else
bool checked=m_check.GetState();
+#endif
std::cout << "Called OnCheck() - state " << checked << std::endl;
@@ -182,7 +213,12 @@ private:
BOOL OnComboDbl(UINT msg, WPARAM wp, LPARAM lp)
{
+#ifdef DATAX_TEST
+ GetData();
+ int sel=m_combo_data.Int();
+#else
int sel=m_combo.SelectedIndex();
+#endif
std::string str=m_combo.GetString(sel);
std::cout << "Called OnComboDbl()" << std::endl;
@@ -201,7 +237,7 @@ private:
BOOL OnText(UINT msg, WPARAM wp, LPARAM lp)
{
std::cout << "Called OnText()" << std::endl;
- std::cout << ":GetText=" << m_text.GetText() << std::endl;
+ std::cout << "OnText::GetText=" << m_text.GetText() << std::endl;
return TRUE;
}
@@ -233,6 +269,10 @@ int WINAPI WinMain (HINSTANCE hInstance,
Test t;
INT_PTR i;
+#ifdef DATAX_TEST
+ std::cout << "DATAX_TEST enabled" << std::endl;
+#endif
+
i=t.ShowModal(hInstance,NULL);
if (i==IDOK)