/***************************************************************************
                            Node.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_DOMNode.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/DOMNode.h>



@implementation  DOMNode

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


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

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

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

- (NSString *) nodeName
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_DOMNode_nodeName((kde_DOMNode *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) nodeValue
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_DOMNode_nodeValue((kde_DOMNode *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- setNodeValue: (NSString *)arg1
{
static kde_DOMString * _domstring_arg1 = 0L;
	kde_DOMNode_setNodeValue((kde_DOMNode *)[self qt], (kde_DOMString*) [arg1 toDOMString: &_domstring_arg1]);
	return self;
}

- (unsigned short) nodeType
{
	return (unsigned short) kde_DOMNode_nodeType((kde_DOMNode *)[self qt]);
}

- (DOMNode*) parentNode
{
	return (DOMNode*) kde_DOMNode_parentNode((kde_DOMNode *)[self qt]);
}

- (NSArray *) childNodes
{
static kde_DOMNodeList * _qlist = 0L;
	_qlist = kde_DOMNode_childNodes((kde_DOMNode *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
}

- (DOMNode*) firstChild
{
	return (DOMNode*) kde_DOMNode_firstChild((kde_DOMNode *)[self qt]);
}

- (DOMNode*) lastChild
{
	return (DOMNode*) kde_DOMNode_lastChild((kde_DOMNode *)[self qt]);
}

- (DOMNode*) previousSibling
{
	return (DOMNode*) kde_DOMNode_previousSibling((kde_DOMNode *)[self qt]);
}

- (DOMNode*) nextSibling
{
	return (DOMNode*) kde_DOMNode_nextSibling((kde_DOMNode *)[self qt]);
}

//- (NamedNodeMap*) attributes
//{
//	return (NamedNodeMap*) [QtSupport objectForQtKey: kde_DOMNode_attributes((kde_DOMNode *)[self qt]) withClass: [NamedNodeMap class] allocatedInObjcWorld: YES];
//}

- (DOMDocument*) ownerDocument
{
	return (DOMDocument*) [QtSupport objectForQtKey: kde_DOMNode_ownerDocument((kde_DOMNode *)[self qt]) withClass: [DOMDocument class] allocatedInObjcWorld: YES];
}

- (DOMNode*) insertBefore: (DOMNode*)newChild refChild: (DOMNode*)refChild
{
	return (DOMNode*) kde_DOMNode_insertBefore((kde_DOMNode *)[self qt], (kde_DOMNode*) [newChild qt], (kde_DOMNode*) [refChild qt]);
}

- (DOMNode*) replaceChild: (DOMNode*)newChild oldChild: (DOMNode*)oldChild
{
	return (DOMNode*) kde_DOMNode_replaceChild((kde_DOMNode *)[self qt], (kde_DOMNode*) [newChild qt], (kde_DOMNode*) [oldChild qt]);
}

- (DOMNode*) removeChild: (DOMNode*)oldChild
{
	return (DOMNode*) kde_DOMNode_removeChild((kde_DOMNode *)[self qt], (kde_DOMNode*) [oldChild qt]);
}

- (DOMNode*) appendChild: (DOMNode*)newChild
{
	return (DOMNode*) kde_DOMNode_appendChild((kde_DOMNode *)[self qt], (kde_DOMNode*) [newChild qt]);
}

- (BOOL) hasChildNodes
{
	return (BOOL) kde_DOMNode_hasChildNodes((kde_DOMNode *)[self qt]);
}

- (DOMNode*) cloneNode: (BOOL)deep
{
	return (DOMNode*) kde_DOMNode_cloneNode((kde_DOMNode *)[self qt], (int)deep);
}

- normalize
{
	kde_DOMNode_normalize((kde_DOMNode *)[self qt]);
	return self;
}

- (BOOL) isSupported: (NSString *)feature version: (NSString *)version
{
static kde_DOMString * _domstring_version = 0L;
static kde_DOMString * _domstring_feature = 0L;
	return (BOOL) kde_DOMNode_isSupported((kde_DOMNode *)[self qt], (kde_DOMString*) [feature toDOMString: &_domstring_feature], (kde_DOMString*) [version toDOMString: &_domstring_version]);
}

- (NSString *) namespaceURI
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_DOMNode_namespaceURI((kde_DOMNode *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) prefix
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_DOMNode_prefix((kde_DOMNode *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- setPrefix: (NSString *)prefix
{
static kde_DOMString * _domstring_prefix = 0L;
	kde_DOMNode_setPrefix((kde_DOMNode *)[self qt], (kde_DOMString*) [prefix toDOMString: &_domstring_prefix]);
	return self;
}

- (NSString *) localName
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_DOMNode_localName((kde_DOMNode *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (BOOL) hasAttributes
{
	return (BOOL) kde_DOMNode_hasAttributes((kde_DOMNode *)[self qt]);
}

//- addEventListener: (NSString *)type listener: (EventListener*)listener useCapture: (BOOL)useCapture
//{
//static kde_DOMString * _domstring_type = 0L;
//	kde_DOMNode_addEventListener((kde_DOMNode *)[self qt], (kde_DOMString*) [type toDOMString: &_domstring_type], (kde_EventListener*) [listener qt], (int)useCapture);
//	return self;
//}

//- removeEventListener: (NSString *)type listener: (EventListener*)listener useCapture: (BOOL)useCapture
//{
//static kde_DOMString * _domstring_type = 0L;
//	kde_DOMNode_removeEventListener((kde_DOMNode *)[self qt], (kde_DOMString*) [type toDOMString: &_domstring_type], (kde_EventListener*) [listener qt], (int)useCapture);
//	return self;
//}

//- (BOOL) dispatchEvent: (Event*)evt
//{
//	return (BOOL) kde_DOMNode_dispatchEvent((kde_DOMNode *)[self qt], (Event) evt);
//}

- (unsigned int) elementId
{
	return (unsigned int) kde_DOMNode_elementId((kde_DOMNode *)[self qt]);
}

- (BOOL) isNull
{
	return (BOOL) kde_DOMNode_isNull((kde_DOMNode *)[self qt]);
}

- (unsigned long) index
{
	return (unsigned long) kde_DOMNode_index((kde_DOMNode *)[self qt]);
}

- (NSString *) toHTML
{
static qt_QString * _qstring = 0L;
	_qstring = kde_DOMNode_toHTML((kde_DOMNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- applyChanges
{
	kde_DOMNode_applyChanges((kde_DOMNode *)[self qt]);
	return self;
}

- getCursor: (int)offset _x: (int)_x _y: (int)_y height: (int)height
{
	kde_DOMNode_getCursor((kde_DOMNode *)[self qt], (int)offset, (int)_x, (int)_y, (int)height);
	return self;
}

- (QRect*) getRect
{
	return (QRect*) [QtSupport objectForQtKey: kde_DOMNode_getRect((kde_DOMNode *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

+ (int) ELEMENT_NODE
{
	return (int) NODE_ELEMENT_NODE;
}

+ (int) ATTRIBUTE_NODE
{
	return (int) NODE_ATTRIBUTE_NODE;
}

+ (int) TEXT_NODE
{
	return (int) NODE_TEXT_NODE;
}

+ (int) CDATA_SECTION_NODE
{
	return (int) NODE_CDATA_SECTION_NODE;
}

+ (int) ENTITY_REFERENCE_NODE
{
	return (int) NODE_ENTITY_REFERENCE_NODE;
}

+ (int) ENTITY_NODE
{
	return (int) NODE_ENTITY_NODE;
}

+ (int) PROCESSING_INSTRUCTION_NODE
{
	return (int) NODE_PROCESSING_INSTRUCTION_NODE;
}

+ (int) COMMENT_NODE
{
	return (int) NODE_COMMENT_NODE;
}

+ (int) DOCUMENT_NODE
{
	return (int) NODE_DOCUMENT_NODE;
}

+ (int) DOCUMENT_TYPE_NODE
{
	return (int) NODE_DOCUMENT_TYPE_NODE;
}

+ (int) DOCUMENT_FRAGMENT_NODE
{
	return (int) NODE_DOCUMENT_FRAGMENT_NODE;
}

+ (int) NOTATION_NODE
{
	return (int) NODE_NOTATION_NODE;
}

@end
