/***************************************************************************
                            KEditToolbarWidget.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_KEditToolbarWidget.h>
#include <kdec/kde_KXMLGUIClient.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KEditToolbarWidget.h>
#include <kdeobjc/KActionCollection.h>
#include <kdeobjc/KXMLGUIBuilder.h>
#include <kdeobjc/KXMLGUIFactory.h>
#include <kdeobjc/KInstance.h>
#include <qtobjc/QDomDocument.h>
#include <qtobjc/QDomElement.h>
#include <qtobjc/QListViewItem.h>


@implementation  KEditToolbarWidget


- initWithActionCollection: (KActionCollection*)collection file: (NSString *)file global: (BOOL)global parent: (QWidget *)parent
{
static qt_QString * _qstring_file = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KEditToolbarWidget((kde_KActionCollection*) [collection qt], (qt_QString *) [file toQString: &_qstring_file], (int)global, (qt_QWidget *) [parent qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithActionCollection: (KActionCollection*)collection 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KEditToolbarWidget((kde_KActionCollection*) [collection qt], qt_QString_null(), 1, 0L)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithXMLGUIFactory: (KXMLGUIFactory*)factory parent: (QWidget *)parent
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KEditToolbarWidget1((kde_KXMLGUIFactory*) [factory qt], (qt_QWidget *) [parent qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithXMLGUIFactory: (KXMLGUIFactory*)factory 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KEditToolbarWidget1((kde_KXMLGUIFactory*) [factory qt], 0L)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parentWidget: YES] == nil) {
			kde_del_KEditToolbarWidget((kde_KEditToolbarWidget *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (BOOL) save
{
	return (BOOL) kde_KEditToolbarWidget_save((kde_KEditToolbarWidget *)[self qt]);
}

- setupLayout
{
	kde_KEditToolbarWidget_setupLayout((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

- loadToolbarCombo
{
	kde_KEditToolbarWidget_loadToolbarCombo((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

- loadActionList: (QDomElement*)elem
{
	kde_KEditToolbarWidget_loadActionList((kde_KEditToolbarWidget *)[self qt], (qt_QDomElement*) [elem qt]);
	return self;
}

- updateLocal: (QDomElement*)elem
{
	kde_KEditToolbarWidget_updateLocal((kde_KEditToolbarWidget *)[self qt], (qt_QDomElement*) [elem qt]);
	return self;
}

- slotToolbarSelected: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	kde_KEditToolbarWidget_slotToolbarSelected((kde_KEditToolbarWidget *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- slotInactiveSelected: (QListViewItem *)item
{
	kde_KEditToolbarWidget_slotInactiveSelected((kde_KEditToolbarWidget *)[self qt], (qt_QListViewItem *) [item qt]);
	return self;
}

- slotActiveSelected: (QListViewItem *)item
{
	kde_KEditToolbarWidget_slotActiveSelected((kde_KEditToolbarWidget *)[self qt], (qt_QListViewItem *) [item qt]);
	return self;
}

- slotInsertButton
{
	kde_KEditToolbarWidget_slotInsertButton((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

- slotRemoveButton
{
	kde_KEditToolbarWidget_slotRemoveButton((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

- slotUpButton
{
	kde_KEditToolbarWidget_slotUpButton((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

- slotDownButton
{
	kde_KEditToolbarWidget_slotDownButton((kde_KEditToolbarWidget *)[self qt]);
	return self;
}

@end

@implementation KEditToolbarWidget (KXMLGUIClientImplementation)

- (KAction*) action: (NSString *)name
{
	return (KAction*) [QtSupport objectForQtKey: kde_KXMLGUIClient_action(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (char*) [name cString]) withClass: [KAction class] allocatedInObjcWorld: YES];
}

- (KAction*) actionForDomElement: (QDomElement*)element
{
	return (KAction*) [QtSupport objectForQtKey: kde_KXMLGUIClient_action1(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QDomElement*) [element qt]) withClass: [KAction class] allocatedInObjcWorld: YES];
}

- (KActionCollection*) actionCollection
{
	return (KActionCollection*) [QtSupport objectForQtKey: kde_KXMLGUIClient_actionCollection(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [KActionCollection class] allocatedInObjcWorld: YES];
}

- (KInstance*) instance
{
	return (KInstance*) [QtSupport objectForQtKey: kde_KXMLGUIClient_instance(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [KInstance class] allocatedInObjcWorld: YES];
}

- (QDomDocument*) domDocument
{
	return (QDomDocument*) [QtSupport objectForQtKey: kde_KXMLGUIClient_domDocument(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [QDomDocument class] allocatedInObjcWorld: YES];
}

- (NSString *) xmlFile
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KXMLGUIClient_xmlFile(kde_KEditToolbarWidget_KXMLGUIClient([self qt]));
	return [NSString fromQString: _qstring];
}

- (NSString *) localXMLFile
{
static qt_QString * _qstring = 0L;
	_qstring = kde_KXMLGUIClient_localXMLFile(kde_KEditToolbarWidget_KXMLGUIClient([self qt]));
	return [NSString fromQString: _qstring];
}

- setXMLGUIBuildDocument: (QDomDocument*)doc
{
	kde_KXMLGUIClient_setXMLGUIBuildDocument(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QDomDocument*) [doc qt]);
	return self;
}

- (QDomDocument*) xmlguiBuildDocument
{
	return (QDomDocument*) [QtSupport objectForQtKey: kde_KXMLGUIClient_xmlguiBuildDocument(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [QDomDocument class] allocatedInObjcWorld: YES];
}

- setFactory: (KXMLGUIFactory*)factory
{
	kde_KXMLGUIClient_setFactory(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (kde_KXMLGUIFactory*) [factory qt]);
	return self;
}

- (KXMLGUIFactory*) factory
{
	return (KXMLGUIFactory*) [QtSupport objectForQtKey: kde_KXMLGUIClient_factory(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [KXMLGUIFactory class] allocatedInObjcWorld: YES];
}

- (KXMLGUIClient*) parentClient
{
	return (KXMLGUIClient*) [QtSupport objectForQtKey: kde_KXMLGUIClient_parentClient(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [KXMLGUIClient class] allocatedInObjcWorld: YES];
}

- insertChildClient: (KXMLGUIClient*)child
{
	kde_KXMLGUIClient_insertChildClient(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (kde_KXMLGUIClient*) [child qt]);
	return self;
}

- removeChildClient: (KXMLGUIClient*)child
{
	kde_KXMLGUIClient_removeChildClient(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (kde_KXMLGUIClient*) [child qt]);
	return self;
}

- setClientBuilder: (KXMLGUIBuilder*)builder
{
	kde_KXMLGUIClient_setClientBuilder(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (kde_KXMLGUIBuilder*) [builder qt]);
	return self;
}

- (KXMLGUIBuilder*) clientBuilder
{
	return (KXMLGUIBuilder*) [QtSupport objectForQtKey: kde_KXMLGUIClient_clientBuilder(kde_KEditToolbarWidget_KXMLGUIClient([self qt])) withClass: [KXMLGUIBuilder class] allocatedInObjcWorld: YES];
}

- reloadXML
{
	kde_KXMLGUIClient_reloadXML(kde_KEditToolbarWidget_KXMLGUIClient([self qt]));
	return self;
}

- unplugActionList: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	kde_KXMLGUIClient_unplugActionList(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

- addStateActionEnabled: (NSString *)state action: (NSString *)action
{
static qt_QString * _qstring_action = 0L;
static qt_QString * _qstring_state = 0L;
	kde_KXMLGUIClient_addStateActionEnabled(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [state toQString: &_qstring_state], (qt_QString *) [action toQString: &_qstring_action]);
	return self;
}

- addStateActionDisabled: (NSString *)state action: (NSString *)action
{
static qt_QString * _qstring_action = 0L;
static qt_QString * _qstring_state = 0L;
	kde_KXMLGUIClient_addStateActionDisabled(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [state toQString: &_qstring_state], (qt_QString *) [action toQString: &_qstring_action]);
	return self;
}

//- (StateChange) getActionsToChangeForState: (NSString *)state
//{
//static qt_QString * _qstring_state = 0L;
//	return (StateChange) kde_KXMLGUIClient_getActionsToChangeForState(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [state toQString: &_qstring_state]);
//}

+ (NSString *) findMostRecentXMLFile: (NSArray *)files doc: (NSString *)doc
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_doc = 0L;
static qt_QStringList * _qlist_files = 0L;
	_qstring = kde_KXMLGUIClient_findMostRecentXMLFile((qt_QStringList*) [files toQStringList: (void *)&_qlist_files], (qt_QString *) [doc toQString: &_qstring_doc]);
	return [NSString fromQString: _qstring];
}

- setInstance: (KInstance*)instance
{
	kde_KXMLGUIClient_setInstance(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (kde_KInstance*) [instance qt]);
	return self;
}

- setXMLFile: (NSString *)file merge: (BOOL)merge setXMLDoc: (BOOL)setXMLDoc
{
static qt_QString * _qstring_file = 0L;
	kde_KXMLGUIClient_setXMLFile(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [file toQString: &_qstring_file], (int)merge, (int)setXMLDoc);
	return self;
}

- setXMLFile: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	kde_KXMLGUIClient_setXMLFile(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [file toQString: &_qstring_file], 0, 1);
	return self;
}

- setLocalXMLFile: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	kde_KXMLGUIClient_setLocalXMLFile(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [file toQString: &_qstring_file]);
	return self;
}

- setXML: (NSString *)document merge: (BOOL)merge
{
static qt_QString * _qstring_document = 0L;
	kde_KXMLGUIClient_setXML(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [document toQString: &_qstring_document], (int)merge);
	return self;
}

- setXML: (NSString *)document
{
static qt_QString * _qstring_document = 0L;
	kde_KXMLGUIClient_setXML(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [document toQString: &_qstring_document], 0);
	return self;
}

- setDOMDocument: (QDomDocument*)document merge: (BOOL)merge
{
	kde_KXMLGUIClient_setDOMDocument(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QDomDocument*) [document qt], (int)merge);
	return self;
}

- setDOMDocument: (QDomDocument*)document
{
	kde_KXMLGUIClient_setDOMDocument(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QDomDocument*) [document qt], 0);
	return self;
}

- conserveMemory
{
	kde_KXMLGUIClient_conserveMemory(kde_KEditToolbarWidget_KXMLGUIClient([self qt]));
	return self;
}

- stateChanged: (NSString *)newstate
{
static qt_QString * _qstring_newstate = 0L;
	kde_KXMLGUIClient_stateChanged(kde_KEditToolbarWidget_KXMLGUIClient([self qt]), (qt_QString *) [newstate toQString: &_qstring_newstate]);
	return self;
}

@end
