/***************************************************************************
                            PartManager.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_PartManager.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/PartManager.h>
#include <kdeobjc/KInstance.h>
#include <kdeobjc/Part.h>
#include <qtobjc/QWidget.h>


@implementation  PartManager


- initWithWidget: (QWidget *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_PartManager((qt_QWidget *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithWidget: (QWidget *)topLevel parent: (QObject *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_PartManager1((qt_QWidget *) [topLevel qt], (qt_QObject *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithWidget: (QWidget *)topLevel parent: (QObject *)parent 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_PartManager1((qt_QWidget *) [topLevel qt], (qt_QObject *) [parent qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parent] == nil) {
			kde_del_PartManager((kde_PartManager *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- setSelectionPolicy: (int)policy
{
	kde_PartManager_setSelectionPolicy((kde_PartManager *)[self qt], (int)policy);
	return self;
}

- (int) selectionPolicy
{
	return (int) kde_PartManager_selectionPolicy((kde_PartManager *)[self qt]);
}

- setAllowNestedParts: (BOOL)allow
{
	kde_PartManager_setAllowNestedParts((kde_PartManager *)[self qt], (int)allow);
	return self;
}

- (BOOL) allowNestedParts
{
	return (BOOL) kde_PartManager_allowNestedParts((kde_PartManager *)[self qt]);
}

- setIgnoreScrollBars: (BOOL)ignore
{
	kde_PartManager_setIgnoreScrollBars((kde_PartManager *)[self qt], (int)ignore);
	return self;
}

- (BOOL) ignoreScrollBars
{
	return (BOOL) kde_PartManager_ignoreScrollBars((kde_PartManager *)[self qt]);
}

- (BOOL) eventFilter: (QObject *)obj ev: (QEvent *)ev
{
	return (BOOL) kde_PartManager_eventFilter((kde_PartManager *)[self qt], (qt_QObject *) [obj qt], (qt_QEvent *) [ev qt]);
}

- addPart: (Part*)part setActive: (BOOL)setActive
{
	kde_PartManager_addPart((kde_PartManager *)[self qt], (kde_Part*) [part qt], (int)setActive);
	return self;
}

- addPart: (Part*)part 
{
	kde_PartManager_addPart((kde_PartManager *)[self qt], (kde_Part*) [part qt], 1);
	return self;
}

- removePart: (Part*)part
{
	kde_PartManager_removePart((kde_PartManager *)[self qt], (kde_Part*) [part qt]);
	return self;
}

- replacePart: (Part*)oldPart newPart: (Part*)newPart setActive: (BOOL)setActive
{
	kde_PartManager_replacePart((kde_PartManager *)[self qt], (kde_Part*) [oldPart qt], (kde_Part*) [newPart qt], (int)setActive);
	return self;
}

- replacePart: (Part*)oldPart newPart: (Part*)newPart 
{
	kde_PartManager_replacePart((kde_PartManager *)[self qt], (kde_Part*) [oldPart qt], (kde_Part*) [newPart qt], 1);
	return self;
}

- setActivePart: (Part*)part widget: (QWidget *)widget
{
	kde_PartManager_setActivePart((kde_PartManager *)[self qt], (kde_Part*) [part qt], (qt_QWidget *) [widget qt]);
	return self;
}

- setActivePart: (Part*)part 
{
	kde_PartManager_setActivePart((kde_PartManager *)[self qt], (kde_Part*) [part qt], 0L);
	return self;
}

- (Part*) activePart
{
	return (Part*) [QtSupport objectForQtKey: kde_PartManager_activePart((kde_PartManager *)[self qt]) withClass: [Part class] allocatedInObjcWorld: YES];
}

- (QWidget*) activeWidget
{
	return (QWidget*) [QtSupport objectForQtKey: kde_PartManager_activeWidget((kde_PartManager *)[self qt]) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

- setSelectedPart: (Part*)part widget: (QWidget *)widget
{
	kde_PartManager_setSelectedPart((kde_PartManager *)[self qt], (kde_Part*) [part qt], (qt_QWidget *) [widget qt]);
	return self;
}

- setSelectedPart: (Part*)part 
{
	kde_PartManager_setSelectedPart((kde_PartManager *)[self qt], (kde_Part*) [part qt], 0L);
	return self;
}

- (Part*) selectedPart
{
	return (Part*) [QtSupport objectForQtKey: kde_PartManager_selectedPart((kde_PartManager *)[self qt]) withClass: [Part class] allocatedInObjcWorld: YES];
}

- (QWidget*) selectedWidget
{
	return (QWidget*) [QtSupport objectForQtKey: kde_PartManager_selectedWidget((kde_PartManager *)[self qt]) withClass: [QWidget class] allocatedInObjcWorld: YES];
}

- addManagedTopLevelWidget: (QWidget *)topLevel
{
	kde_PartManager_addManagedTopLevelWidget((kde_PartManager *)[self qt], (qt_QWidget *) [topLevel qt]);
	return self;
}

- removeManagedTopLevelWidget: (QWidget *)topLevel
{
	kde_PartManager_removeManagedTopLevelWidget((kde_PartManager *)[self qt], (qt_QWidget *) [topLevel qt]);
	return self;
}

- setActiveInstance: (KInstance*)instance
{
	kde_PartManager_setActiveInstance((kde_PartManager *)[self qt], (kde_KInstance*) [instance qt]);
	return self;
}

- slotObjectDestroyed
{
	kde_PartManager_slotObjectDestroyed((kde_PartManager *)[self qt]);
	return self;
}

- slotWidgetDestroyed
{
	kde_PartManager_slotWidgetDestroyed((kde_PartManager *)[self qt]);
	return self;
}

- slotManagedTopLevelWidgetDestroyed
{
	kde_PartManager_slotManagedTopLevelWidgetDestroyed((kde_PartManager *)[self qt]);
	return self;
}

+ (int) Direct
{
	return (int) PARTMANAGER_Direct;
}

+ (int) TriState
{
	return (int) PARTMANAGER_TriState;
}

@end
