/***************************************************************************
                            QTimeEdit.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_QTimeEdit.h>
#include <qtobjc/QTimeEdit.h>

@implementation  QTimeEdit


- initWithWidget: (QWidget *)parent name: (NSString *)name
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTimeEdit((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_QTimeEdit(0, 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDate: (NSDate *)time parent: (QWidget *)parent name: (NSString *)name
{
static qt_QTime * _qdate_time = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTimeEdit1((qt_QTime *) [time toQTime: (qt_QTime **)&_qdate_time], (qt_QWidget *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDate: (NSDate *)time 
{
static qt_QTime * _qdate_time = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTimeEdit1((qt_QTime *) [time toQTime: (qt_QTime **)&_qdate_time], 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_QTimeEdit((qt_QTimeEdit *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

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

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

- setTime: (NSDate *)time
{
static qt_QTime * _qdate_time = 0L;
	qt_QTimeEdit_setTime((qt_QTimeEdit *)[self qt], (qt_QTime *) [time toQTime: (qt_QTime **)&_qdate_time]);
	return self;
}

- (NSDate *) time
{
static qt_QTime * _qdate = 0L;
	_qdate = qt_QTimeEdit_time((qt_QTimeEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQTime: _qdate];
}

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

- (BOOL) autoAdvance
{
	return (BOOL) qt_QTimeEdit_autoAdvance((qt_QTimeEdit *)[self qt]);
}

- setMinValue: (NSDate *)d
{
static qt_QTime * _qdate_d = 0L;
	qt_QTimeEdit_setMinValue((qt_QTimeEdit *)[self qt], (qt_QTime *) [d toQTime: (qt_QTime **)&_qdate_d]);
	return self;
}

- (NSDate *) minValue
{
static qt_QTime * _qdate = 0L;
	_qdate = qt_QTimeEdit_minValue((qt_QTimeEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQTime: _qdate];
}

- setMaxValue: (NSDate *)d
{
static qt_QTime * _qdate_d = 0L;
	qt_QTimeEdit_setMaxValue((qt_QTimeEdit *)[self qt], (qt_QTime *) [d toQTime: (qt_QTime **)&_qdate_d]);
	return self;
}

- (NSDate *) maxValue
{
static qt_QTime * _qdate = 0L;
	_qdate = qt_QTimeEdit_maxValue((qt_QTimeEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQTime: _qdate];
}

- setRange: (NSDate *)min max: (NSDate *)max
{
static qt_QTime * _qdate_max = 0L;
static qt_QTime * _qdate_min = 0L;
	qt_QTimeEdit_setRange((qt_QTimeEdit *)[self qt], (qt_QTime *) [min toQTime: (qt_QTime **)&_qdate_min], (qt_QTime *) [max toQTime: (qt_QTime **)&_qdate_max]);
	return self;
}

- (NSString *) separator
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTimeEdit_separator((qt_QTimeEdit *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setSeparator: (NSString *)s
{
static qt_QString * _qstring_s = 0L;
	qt_QTimeEdit_setSeparator((qt_QTimeEdit *)[self qt], (qt_QString *) [s toQString: &_qstring_s]);
	return self;
}

- (BOOL) event: (QEvent *)e
{
	return (BOOL) qt_QTimeEdit_event((qt_QTimeEdit *)[self qt], (qt_QEvent *) [e qt]);
}

- stepUp
{
	qt_QTimeEdit_stepUp((qt_QTimeEdit *)[self qt]);
	return self;
}

- stepDown
{
	qt_QTimeEdit_stepDown((qt_QTimeEdit *)[self qt]);
	return self;
}

- (NSString *) sectionFormattedText: (int)sec
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTimeEdit_sectionFormattedText((qt_QTimeEdit *)[self qt], (int)sec);
	return [NSString fromQString: _qstring];
}

- addNumber: (int)sec num: (int)num
{
	qt_QTimeEdit_addNumber((qt_QTimeEdit *)[self qt], (int)sec, (int)num);
	return self;
}

- removeLastNumber: (int)sec
{
	qt_QTimeEdit_removeLastNumber((qt_QTimeEdit *)[self qt], (int)sec);
	return self;
}

- (BOOL) setFocusSection: (int)s
{
	return (BOOL) qt_QTimeEdit_setFocusSection((qt_QTimeEdit *)[self qt], (int)s);
}

- (BOOL) outOfRange: (int)h m: (int)m s: (int)s
{
	return (BOOL) qt_QTimeEdit_outOfRange((qt_QTimeEdit *)[self qt], (int)h, (int)m, (int)s);
}

- setHour: (int)h
{
	qt_QTimeEdit_setHour((qt_QTimeEdit *)[self qt], (int)h);
	return self;
}

- setMinute: (int)m
{
	qt_QTimeEdit_setMinute((qt_QTimeEdit *)[self qt], (int)m);
	return self;
}

- setSecond: (int)s
{
	qt_QTimeEdit_setSecond((qt_QTimeEdit *)[self qt], (int)s);
	return self;
}

- updateButtons
{
	qt_QTimeEdit_updateButtons((qt_QTimeEdit *)[self qt]);
	return self;
}

@end
