/***************************************************************************
                            HTMLDocument.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_HTMLDocument.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/HTMLDocument.h>
#include <kdeobjc/DOMNode.h>
#include <kdeobjc/HTMLElement.h>
#include <kdeobjc/KHTMLView.h>


@implementation  HTMLDocument


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

- initWithHTMLView: (KHTMLView*)parent
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_HTMLDocument1((kde_KHTMLView*) [parent qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithDOMNode: (DOMNode*)other
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_HTMLDocument3((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_HTMLDocument((kde_HTMLDocument *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) title
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_title((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

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

- (NSString *) referrer
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_referrer((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) domain
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_domain((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) URL
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_URL((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (HTMLElement*) body
{
	return (HTMLElement*) [QtSupport objectForQtKey: kde_HTMLDocument_body((kde_HTMLDocument *)[self qt]) withClass: [HTMLElement class] allocatedInObjcWorld: YES];
}

- setBody: (HTMLElement*)arg1
{
	kde_HTMLDocument_setBody((kde_HTMLDocument *)[self qt], (kde_HTMLElement*) [arg1 qt]);
	return self;
}

- (HTMLCollection*) images
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_images((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

- (HTMLCollection*) applets
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_applets((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

- (HTMLCollection*) links
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_links((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

- (HTMLCollection*) forms
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_forms((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

- (HTMLCollection*) anchors
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_anchors((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

- (NSString *) cookie
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_cookie((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

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

- open
{
	kde_HTMLDocument_open((kde_HTMLDocument *)[self qt]);
	return self;
}

- close
{
	kde_HTMLDocument_close((kde_HTMLDocument *)[self qt]);
	return self;
}

- writeString: (NSString *)text
{
static kde_DOMString * _domstring_text = 0L;
	kde_HTMLDocument_write((kde_HTMLDocument *)[self qt], (kde_DOMString*) [text toDOMString: &_domstring_text]);
	return self;
}

- writeln: (NSString *)text
{
static kde_DOMString * _domstring_text = 0L;
	kde_HTMLDocument_writeln((kde_HTMLDocument *)[self qt], (kde_DOMString*) [text toDOMString: &_domstring_text]);
	return self;
}

//- (NSArray *) getElementsByName: (NSString *)elementName
//{
//static kde_DOMNodeList * _qlist = 0L;
//static kde_DOMString * _domstring_elementName = 0L;
//	_qlist = kde_HTMLDocument_getElementsByName((kde_HTMLDocument *)[self qt], (kde_DOMString*) [elementName toDOMString: &_domstring_elementName]);
//	return (NSArray *) [NSMutableArray arrayWithNodeList: _qlist];
//}

- (NSString *) completeURL: (NSString *)url
{
static kde_DOMString * _domstring = 0L;
static kde_DOMString * _domstring_url = 0L;
	_domstring = kde_HTMLDocument_completeURL((kde_HTMLDocument *)[self qt], (kde_DOMString*) [url toDOMString: &_domstring_url]);
	return [NSString fromDOMString: _domstring];
}

- (NSString *) lastModified
{
static kde_DOMString * _domstring = 0L;
	_domstring = kde_HTMLDocument_lastModified((kde_HTMLDocument *)[self qt]);
	return [NSString fromDOMString: _domstring];
}

- (HTMLCollection*) all
{
	return (HTMLCollection*) [QtSupport objectForQtKey: kde_HTMLDocument_all((kde_HTMLDocument *)[self qt]) withClass: [HTMLCollection class] allocatedInObjcWorld: YES];
}

@end
