#include "globals.h" #include "TextFieldState_v8_wrapper.h" #include #include "TextFieldState.h" #include using namespace v8; #ifdef UNICODE # define V8_TCHAR uint16_t #else # define V8_TCHAR char #endif static Handle Get_TextFieldState_text(Local property, const AccessorInfo &info) { Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); TextFieldState *tmp = (TextFieldState *) wrap->Value(); return String::New((const V8_TCHAR *) tmp->getText()); } static void Set_TextFieldState_text(Local property, Local value, const AccessorInfo& info) { Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); TextFieldState *tmp = (TextFieldState *) wrap->Value(); String::Utf8Value utf8_value(value); tmp->setText(Utf8ToTchar(*utf8_value)); } static Handle Get_TextFieldState_hAlign(Local property, const AccessorInfo &info) { Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); TextFieldState *tmp = (TextFieldState *) wrap->Value(); switch(tmp->getHAlign()) { case LEFT: return String::New((const V8_TCHAR *) _T("LEFT")); case CENTER: return String::New((const V8_TCHAR *) _T("CENTER")); case RIGHT: return String::New((const V8_TCHAR *) _T("RIGHT")); } return Undefined(); } static void Set_TextFieldState_hAlign(Local property, Local value, const AccessorInfo& info) { Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); TextFieldState *tmp = (TextFieldState *) wrap->Value(); String::Utf8Value utf8_value(value); Utf8ToTchar tval(*utf8_value); if ( lstrcmpi(_T("LEFT"), tval) == 0) tmp->setHAlign(LEFT); else if ( lstrcmpi(_T("CENTER"), tval) == 0) tmp->setHAlign(CENTER); else if ( lstrcmpi(_T("RIGHT"), tval) == 0) tmp->setHAlign(RIGHT); } void AddTextFieldStateAcessors(Handle &templ) { templ->SetAccessor(String::New("text"), Get_TextFieldState_text, Set_TextFieldState_text); templ->SetAccessor(String::New("hAlign"), Get_TextFieldState_hAlign, Set_TextFieldState_hAlign); }