From 3abd781670e4cd7a82d5ab2966ef9f8131535b54 Mon Sep 17 00:00:00 2001 From: pescuma Date: Tue, 6 Jan 2009 05:45:37 +0000 Subject: skins: Added border to fields State is now got through interface It works! git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@124 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Plugins/skins/SkinLib/V8Script.cpp | 40 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'Plugins/skins/SkinLib/V8Script.cpp') diff --git a/Plugins/skins/SkinLib/V8Script.cpp b/Plugins/skins/SkinLib/V8Script.cpp index 2df8cad..0d0fc85 100644 --- a/Plugins/skins/SkinLib/V8Script.cpp +++ b/Plugins/skins/SkinLib/V8Script.cpp @@ -31,10 +31,17 @@ static Handle IsEmptyCallback(const Arguments& args) { return Boolean::New(true); } - else if (arg->IsExternal()) + else if (arg->IsObject()) { - Local wrap = Local::Cast(arg); + Local self = Local::Cast(arg); + if (self->InternalFieldCount() < 1) + continue; + + Local wrap = Local::Cast(self->GetInternalField(0)); FieldState *field = (FieldState *) wrap->Value(); + if (field == NULL) + continue; + if (field->isEmpty()) return Boolean::New(true); } @@ -58,6 +65,34 @@ static Handle RGBCallback(const Arguments& args) return Int32::New(color); } +static Handle AlertCallback(const Arguments& args) +{ + Local wrap = Local::Cast(args.Data()); + if (wrap.IsEmpty()) + return Int32::New(-1); + + Dialog *dialog = (Dialog *) wrap->Value(); + if (dialog == NULL) + return Int32::New(-1); + + if (args.Length() < 1) + return Int32::New(-1); + + Local arg = args[0]; + if (!arg->IsString()) + return Int32::New(-1); + + Local str = Local::Cast(arg); + String::Utf8Value utf8_value(str); + + std::tstring title; + title = CharToTchar(dialog->getName()); + title += _T(" - Skin alert"); + MessageBox(NULL, Utf8ToTchar(*utf8_value), title.c_str(), MB_OK); + + return Int32::New(0); +} + bool V8Script::compile(const TCHAR *source, Dialog *dlg) { dispose(); @@ -68,6 +103,7 @@ bool V8Script::compile(const TCHAR *source, Dialog *dlg) global->Set(String::New("IsEmpty"), FunctionTemplate::New(&IsEmptyCallback)); global->Set(String::New("RGB"), FunctionTemplate::New(&RGBCallback)); + global->Set(String::New("alert"), FunctionTemplate::New(&AlertCallback, External::New(dlg))); global->Set(String::New("NUMBER"), String::New("NUMBER")); global->Set(String::New("CHECKBOX"), String::New("CHECKBOX")); -- cgit v1.2.3