/***************************************************************************
                            Element.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_Element.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/Element.h>
#include <kdeobjc/Attr.h>


@implementation  Element


- init
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_Element()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDOMNode: (DOMNode*)other
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_Element1((kde_DOMNode*) [other qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	Element * aCopy;
	aCopy = [[(Element *)[[self class] allocWithZone: zone] setQt: kde_new_Element2([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_Element((kde_Element *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) tagName
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_Element_tagName((kde_Element *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) getAttribute: (NSString *)name
{
static kde_DOMString * _domstring = 0L;
static kde_DOMString * _domstring_name = 0L;
	_domstring = kde_Element_getAttribute((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]);
	return [NSString fromDOMString: _domstring];
}

- setAttribute: (NSString *)name value: (NSString *)value
{
static kde_DOMString * _domstring_value = 0L;
static kde_DOMString * _domstring_name = 0L;
	kde_Element_setAttribute((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name], (kde_DOMString*) [value toDOMString: &_domstring_value]);
	return self;
}

- removeAttribute: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	kde_Element_removeAttribute((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]);
	return self;
}

- (Attr*) getAttributeNode: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (Attr*) [QtSupport objectForQtKey: kde_Element_getAttributeNode((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (Attr*) setAttributeNode: (Attr*)newAttr
{
	return (Attr*) [QtSupport objectForQtKey: kde_Element_setAttributeNode((kde_Element *)[self qt], (kde_Attr*) [newAttr qt]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (Attr*) removeAttributeNode: (Attr*)oldAttr
{
	return (Attr*) [QtSupport objectForQtKey: kde_Element_removeAttributeNode((kde_Element *)[self qt], (kde_Attr*) [oldAttr qt]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (NSArray *) getElementsByTagName: (NSString *)name
{
static kde_DOMNodeList * _qlist = 0L;
static kde_DOMString * _domstring_name = 0L;
	_qlist = kde_Element_getElementsByTagName((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]);
	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
}

- (NSArray *) getElementsByTagNameNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMNodeList * _qlist = 0L;
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	_qlist = kde_Element_getElementsByTagNameNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]);
	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
}

- (NSString *) getAttributeNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMString * _domstring = 0L;
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	_domstring = kde_Element_getAttributeNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]);
	return [NSString fromDOMString: _domstring];
}

- setAttributeNS: (NSString *)namespaceURI qualifiedName: (NSString *)qualifiedName value: (NSString *)value
{
static kde_DOMString * _domstring_value = 0L;
static kde_DOMString * _domstring_qualifiedName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	kde_Element_setAttributeNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [qualifiedName toDOMString: &_domstring_qualifiedName], (kde_DOMString*) [value toDOMString: &_domstring_value]);
	return self;
}

- removeAttributeNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	kde_Element_removeAttributeNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]);
	return self;
}

- (Attr*) getAttributeNodeNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	return (Attr*) [QtSupport objectForQtKey: kde_Element_getAttributeNodeNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (Attr*) setAttributeNodeNS: (Attr*)newAttr
{
	return (Attr*) [QtSupport objectForQtKey: kde_Element_setAttributeNodeNS((kde_Element *)[self qt], (kde_Attr*) [newAttr qt]) withClass: [Attr class] allocatedInObjcWorld: YES];
}

- (BOOL) hasAttribute: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_hasAttribute((kde_Element *)[self qt], (kde_DOMString*) [name toDOMString: &_domstring_name]);
}

- (BOOL) hasAttributeNS: (NSString *)namespaceURI localName: (NSString *)localName
{
static kde_DOMString * _domstring_localName = 0L;
static kde_DOMString * _domstring_namespaceURI = 0L;
	return (BOOL) kde_Element_hasAttributeNS((kde_Element *)[self qt], (kde_DOMString*) [namespaceURI toDOMString: &_domstring_namespaceURI], (kde_DOMString*) [localName toDOMString: &_domstring_localName]);
}

- (CSSStyleDeclaration*) style
{
	return (CSSStyleDeclaration*) [QtSupport objectForQtKey: kde_Element_style((kde_Element *)[self qt]) withClass: [CSSStyleDeclaration class] allocatedInObjcWorld: YES];
}

- (BOOL) isHTMLElement
{
	return (BOOL) kde_Element_isHTMLElement((kde_Element *)[self qt]);
}

+ (BOOL) khtmlValidAttrName: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_khtmlValidAttrName((kde_DOMString*) [name toDOMString: &_domstring_name]);
}

+ (BOOL) khtmlValidPrefix: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_khtmlValidPrefix((kde_DOMString*) [name toDOMString: &_domstring_name]);
}

+ (BOOL) khtmlValidQualifiedName: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_khtmlValidQualifiedName((kde_DOMString*) [name toDOMString: &_domstring_name]);
}

+ (BOOL) khtmlMalformedQualifiedName: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_khtmlMalformedQualifiedName((kde_DOMString*) [name toDOMString: &_domstring_name]);
}

+ (BOOL) khtmlMalformedPrefix: (NSString *)name
{
static kde_DOMString * _domstring_name = 0L;
	return (BOOL) kde_Element_khtmlMalformedPrefix((kde_DOMString*) [name toDOMString: &_domstring_name]);
}

@end
