1 #include "CheckBoxControl.h"
2 
3 namespace ADM_qtScript
4 {
CheckBoxControl(const QString & title,bool value)5 	CheckBoxControl::CheckBoxControl(const QString& title, bool value)
6 	{
7 		this->_title = title;
8 		this->_value = value;
9 	}
10 
constructor(QScriptContext * context,QScriptEngine * engine)11 	QScriptValue CheckBoxControl::constructor(QScriptContext *context, QScriptEngine *engine)
12 	{
13 		if (context->isCalledAsConstructor())
14 		{
15 			if (context->argumentCount() == 1 && context->argument(0).isString())
16 			{
17 				return engine->newQObject(new CheckBoxControl(context->argument(0).toString()), QScriptEngine::ScriptOwnership);
18 			}
19 			else if (context->argumentCount() == 2 && context->argument(0).isString() && context->argument(1).isBool())
20 			{
21 				return engine->newQObject(
22 					new CheckBoxControl(context->argument(0).toString(), context->argument(1).toBool()), QScriptEngine::ScriptOwnership);
23 			}
24 			else
25 			{
26 				return context->throwError("Invalid arguments passed to constructor");
27 			}
28 		}
29 
30 		return engine->undefinedValue();
31 	}
32 
createControl(void)33 	diaElem* CheckBoxControl::createControl(void)
34 	{
35 		return new diaElemToggle(&this->_value, this->_title.toUtf8().constData(), NULL);
36 	}
37 
getTitle()38 	const QString& CheckBoxControl::getTitle()
39 	{
40 		return this->_title;
41 	}
42 
getValue()43 	bool CheckBoxControl::getValue()
44 	{
45 		return this->_value;
46 	}
47 
setTitle(const QString & title)48 	void CheckBoxControl::setTitle(const QString& title)
49 	{
50 		this->_title = title;
51 	}
52 
setValue(bool value)53 	void CheckBoxControl::setValue(bool value)
54 	{
55 		this->_value = value;
56 	}
57 }