/***************************************************************************
                            KToolBarPopupAction.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_KToolBarPopupAction.h>
#include <kdec/kde_KShortcut.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KToolBarPopupAction.h>
#include <kdeobjc/KActionCollection.h>
#include <kdeobjc/KGuiItem.h>
#include <kdeobjc/KShortcut.h>

#include <qtobjc/QKeySequence.h>

#include <qtobjc/QWidget.h>


@implementation  KToolBarPopupAction


- initWithText: (NSString *)text icon: (NSString *)icon cut: (KShortcut*)cut parent: (QObject *)parent name: (NSString *)name
{
static qt_QString * _qstring_icon = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KToolBarPopupAction((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [icon toQString: &_qstring_icon], (kde_KShortcut*) [cut qt], (qt_QObject *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text icon: (NSString *)icon
{
static qt_QString * _qstring_icon = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KToolBarPopupAction((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [icon toQString: &_qstring_icon], kde_new_KShortcut(), 0, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text icon: (NSString *)icon cut: (KShortcut*)cut receiver: (QObject *)receiver slot: (NSString *)slot parent: (QObject *)parent name: (NSString *)name
{
static qt_QString * _qstring_icon = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KToolBarPopupAction1((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [icon toQString: &_qstring_icon], (kde_KShortcut*) [cut qt], (qt_QObject *) [receiver qt], (char*) [slot cString], (qt_QObject *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)text icon: (NSString *)icon cut: (KShortcut*)cut receiver: (QObject *)receiver slot: (NSString *)slot 
{
static qt_QString * _qstring_icon = 0L;
static qt_QString * _qstring_text = 0L;
	if ([self qt] == 0L) {
		[self setQt: kde_new_KToolBarPopupAction1((qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [icon toQString: &_qstring_icon], (kde_KShortcut*) [cut qt], (qt_QObject *) [receiver qt], (char*) [slot cString], 0, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithGuiItem: (KGuiItem*)item cut: (KShortcut*)cut receiver: (QObject *)receiver slot: (NSString *)slot parent: (KActionCollection*)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KToolBarPopupAction2((kde_KGuiItem*) [item qt], (kde_KShortcut*) [cut qt], (qt_QObject *) [receiver qt], (char*) [slot cString], (kde_KActionCollection*) [parent qt], (char*) [name cString])];
		[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_KToolBarPopupAction((kde_KToolBarPopupAction *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (int) plug: (QWidget *)widget index: (int)index
{
	return (int) kde_KToolBarPopupAction_plug((kde_KToolBarPopupAction *)[self qt], (qt_QWidget *) [widget qt], (int)index);
}

- (int) plug: (QWidget *)widget 
{
	return (int) kde_KToolBarPopupAction_plug((kde_KToolBarPopupAction *)[self qt], (qt_QWidget *) [widget qt], -1);
}

- unplug: (QWidget *)widget
{
	kde_KToolBarPopupAction_unplug((kde_KToolBarPopupAction *)[self qt], (qt_QWidget *) [widget qt]);
	return self;
}

- (KPopupMenu*) popupMenu
{
	return (KPopupMenu*) [QtSupport objectForQtKey: kde_KToolBarPopupAction_popupMenu((kde_KToolBarPopupAction *)[self qt]) withClass: [KPopupMenu class] allocatedInObjcWorld: YES];
}

- (BOOL) delayed
{
	return (BOOL) kde_KToolBarPopupAction_delayed((kde_KToolBarPopupAction *)[self qt]);
}

- setDelayed: (BOOL)delayed
{
	kde_KToolBarPopupAction_setDelayed((kde_KToolBarPopupAction *)[self qt], (int)delayed);
	return self;
}

- (BOOL) stickyMenu
{
	return (BOOL) kde_KToolBarPopupAction_stickyMenu((kde_KToolBarPopupAction *)[self qt]);
}

- setStickyMenu: (BOOL)sticky
{
	kde_KToolBarPopupAction_setStickyMenu((kde_KToolBarPopupAction *)[self qt], (int)sticky);
	return self;
}

@end
