/***************************************************************************
                            QDateTimeEdit.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, 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 <qtc/qt_QDateTimeEdit.h>
#include <qtobjc/QDateTimeEdit.h>

@implementation  QDateTimeEdit


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

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

- initWithDate: (NSDate *)datetime parent: (QWidget *)parent name: (NSString *)name
{
static qt_QDateTime * _qdate_datetime = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDateTimeEdit1((qt_QDateTime *) [datetime toQDateTime: (qt_QDateTime **)&_qdate_datetime], (qt_QWidget *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDate: (NSDate *)datetime 
{
static qt_QDateTime * _qdate_datetime = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDateTimeEdit1((qt_QDateTime *) [datetime toQDateTime: (qt_QDateTime **)&_qdate_datetime], 0, 0)];
		[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) {
			qt_del_QDateTimeEdit((qt_QDateTimeEdit *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (QSize*) sizeHint
{
	return (QSize*) [QtSupport objectForQtKey: qt_QDateTimeEdit_sizeHint((qt_QDateTimeEdit *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- (QSize*) minimumSizeHint
{
	return (QSize*) [QtSupport objectForQtKey: qt_QDateTimeEdit_minimumSizeHint((qt_QDateTimeEdit *)[self qt]) withClass: [QSize class] allocatedInObjcWorld: YES];
}

- setDateTime: (NSDate *)dt
{
static qt_QDateTime * _qdate_dt = 0L;
	qt_QDateTimeEdit_setDateTime((qt_QDateTimeEdit *)[self qt], (qt_QDateTime *) [dt toQDateTime: (qt_QDateTime **)&_qdate_dt]);
	return self;
}

- (NSDate *) dateTime
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QDateTimeEdit_dateTime((qt_QDateTimeEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDateTime: _qdate];
}

- (QDateEdit*) dateEdit
{
	return (QDateEdit*) [QtSupport objectForQtKey: qt_QDateTimeEdit_dateEdit((qt_QDateTimeEdit *)[self qt]) withClass: [QDateEdit class] allocatedInObjcWorld: YES];
}

- (QTimeEdit*) timeEdit
{
	return (QTimeEdit*) [QtSupport objectForQtKey: qt_QDateTimeEdit_timeEdit((qt_QDateTimeEdit *)[self qt]) withClass: [QTimeEdit class] allocatedInObjcWorld: YES];
}

- setAutoAdvance: (BOOL)advance
{
	qt_QDateTimeEdit_setAutoAdvance((qt_QDateTimeEdit *)[self qt], (int)advance);
	return self;
}

- (BOOL) autoAdvance
{
	return (BOOL) qt_QDateTimeEdit_autoAdvance((qt_QDateTimeEdit *)[self qt]);
}

//- init
//{
//	qt_QDateTimeEdit_init((qt_QDateTimeEdit *)[self qt]);
//	return self;
//}

- layoutEditors
{
	qt_QDateTimeEdit_layoutEditors((qt_QDateTimeEdit *)[self qt]);
	return self;
}

- newValue: (NSDate *)d
{
static qt_QDate * _qdate_d = 0L;
	qt_QDateTimeEdit_newValue((qt_QDateTimeEdit *)[self qt], (qt_QDate *) [d toQDate: (qt_QDate **)&_qdate_d]);
	return self;
}

//- newValue: (NSDate *)t
//{
//static qt_QTime * _qdate_t = 0L;
//	qt_QDateTimeEdit_newValue1((qt_QDateTimeEdit *)[self qt], (qt_QTime *) [t toQTime: (qt_QTime **)&_qdate_t]);
//	return self;
//}

@end
