aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects/class_xmlreader.h
blob: ea2d9cafc0d34b3ed792f3c50b4ccd4723547605 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _CLASS_XMLREADER_H_
#define _CLASS_XMLREADER_H_
//=============================================================================
//
//   File : class_xmlreader.h
//   Created on Tue 27 Dec 2005 00:14:09 by Szymon Stefanek
//
//   This file is part of the KVIrc IRC Client distribution
//   Copyright (C) 2005-2008 Szymon Stefanek <pragma at kvirc dot net>
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#include "kvi_settings.h"
#include "kvi_qstring.h"

#include "object_macros.h"

class KviKvsObject_xmlreader : public KviKvsObject
{
public:
	KVSO_DECLARE_OBJECT(KviKvsObject_xmlreader)
public:
	bool parse(KviKvsObjectFunctionCall *c);
	bool lastError(KviKvsObjectFunctionCall *c);

	void fatalError(const QString &szError);
protected:
	QString m_szLastError;
};

#endif //!_CLASS_XMLREADER_H_
ackground-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
//=============================================================================
//
//   File : class_hbox.cpp
//   Creation date : Wed Mar 01 2005 23:00:01 by Alessandro Carbone & Tonino Imbesi
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2005-2009 Alessandro Carbone (elfonol at gmail dot com)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#define _KVI_DEBUG_CHECK_RANGE_
#include "kvi_debug.h"
#include "kvi_locale.h"
#include "class_hbox.h"
#include "kvi_tal_hbox.h"

const char * const align_tbl[] = {
	"Left",
	"Right",
	"HCenter",
	"VCenter",
	"Center",
	"Top",
	"Bottom",
	"WordBreak"
};



const int align_cod[] = {
	Qt::AlignLeft,
	Qt::AlignRight,
	Qt::AlignHCenter,
	Qt::AlignVCenter,
	Qt::AlignCenter,
	Qt::AlignTop,
	Qt::AlignBottom,
	Qt::AlignJustify,
};

#define align_num	(sizeof(align_tbl) / sizeof(align_tbl[0]))

/*
	@doc: hbox
	@keyterms:
		hbox object class, child widgets
	@title:
		hbox class
	@type:
		class
	@short:
		Manages child widget horizontal geometry
	@inherits:
		[class]object[/class]
	@description:
		The hbox class widget provides horizontal geometry management for its child widgets.
	@functions:
		!fn: $setSpacing(<spacing:uint>)
		Sets the default spacing of the widgets in pixels
		!fn: $setMargin(<margin:uint>)
		Sets the dimension of the layout margin : the distance from the border to the outermost child widget edges.
		!fn: $setStretchFactor(<widget:hobject>,<stretch:uint>)
		Sets the stretch factor of widget to stretch.
		!fn: $addStretch(<stretch:integer>)
		Adds a stretchable space with zero minimum size and stretch factor stretch to the end of this box layout.
		!fn: $setAlignment(<flag1:string>, <flag2:string>, ...)
		Sets the alignment for widget w to  flags, given as parameters.
		Valid flags are:Right,Left,Top,Bottom,HCenter,VCenter,Center
*/


KVSO_BEGIN_REGISTERCLASS(KviKvsObject_hbox,"hbox","widget")
	KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_hbox,setMargin)
	KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_hbox,setSpacing)
	KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_hbox,setStretchFactor )
	KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_hbox,addStretch )
	KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_hbox,setAlignment )
KVSO_END_REGISTERCLASS(KviKvsObject_hbox)

KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_hbox,KviKvsObject_widget)

KVSO_END_CONSTRUCTOR(KviKvsObject_hbox)


KVSO_BEGIN_DESTRUCTOR(KviKvsObject_hbox)

KVSO_END_CONSTRUCTOR(KviKvsObject_hbox)

bool KviKvsObject_hbox::init(KviKvsRunTimeContext *,KviKvsVariantList *)
{

	setObject(new KviTalHBox(parentScriptWidget()), true);
	return true;
}

KVSO_CLASS_FUNCTION(hbox,setMargin)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_uint_t uMargin;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->setMargin(uMargin);
	return true;
}

KVSO_CLASS_FUNCTION(hbox,setSpacing)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_uint_t uSpacing;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->setSpacing(uSpacing);
	return true;
}

KVSO_CLASS_FUNCTION(hbox,setStretchFactor)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	kvs_uint_t uStretch;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
	KVSO_PARAMETERS_END(c)
	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	if(((KviKvsObject_widget *)pObject)->widget()->parentWidget() != widget())
	{
		c->warning(__tr2qs_ctx("The widget must be a child of this hbox","objects"));
		return true;
	}
	((KviTalHBox *)widget())->setStretchFactor(((QWidget *)(pObject->object())),uStretch);
	return true;
}

KVSO_CLASS_FUNCTION(hbox,addStretch)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_int_t iStretch;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("stretch",KVS_PT_INT,0,iStretch)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->addStretch(iStretch);
	return true;
}

KVSO_CLASS_FUNCTION(hbox,setAlignment)
{
	CHECK_INTERNAL_POINTER(widget())
	QStringList alignment;
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("alignment",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,alignment)
	KVSO_PARAMETERS_END(c)
	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	if(((KviKvsObject_widget *)pObject)->widget()->parentWidget() != widget())
	{
		c->warning(__tr2qs_ctx("The widget must be a child of this hbox","objects"));
		return true;
	}
	int align,sum=0;
	for ( QStringList::Iterator it = alignment.begin(); it != alignment.end(); ++it )
		{

			align = 0;
			for(unsigned int j = 0; j < align_num; j++)
			{
				if(KviQString::equalCI((*it), align_tbl[j]))
				{
					align=align_cod[j];
					break;
				}
			}
			if(align)
				sum = sum | align;
			else
				c->warning(__tr2qs_ctx("Unknown alignment '%Q'","objects"),&(*it));

		}
	((KviTalHBox *)widget())->setAlignment(((QWidget *)(pObject->object())),(Qt::Alignment)sum);
	return true;
}