/***************************************************************************
                            QDateEdit.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_QDateEdit.h>
#include <qtobjc/QDateEdit.h>

@implementation  QDateEdit


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

- initWithDate: (NSDate *)date parent: (QWidget *)parent name: (NSString *)name
{
static qt_QDate * _qdate_date = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDateEdit1((qt_QDate *) [date toQDate: (qt_QDate **)&_qdate_date], (qt_QWidget *) [parent qt], (char*) [name cString])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDate: (NSDate *)date 
{
static qt_QDate * _qdate_date = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDateEdit1((qt_QDate *) [date toQDate: (qt_QDate **)&_qdate_date], 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_QDateEdit((qt_QDateEdit *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

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

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

- setDate: (NSDate *)date
{
static qt_QDate * _qdate_date = 0L;
	qt_QDateEdit_setDate((qt_QDateEdit *)[self qt], (qt_QDate *) [date toQDate: (qt_QDate **)&_qdate_date]);
	return self;
}

- (NSDate *) date
{
static qt_QDate * _qdate = 0L;
	_qdate = qt_QDateEdit_date((qt_QDateEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDate: _qdate];
}

- setOrder: (int)order
{
	qt_QDateEdit_setOrder((qt_QDateEdit *)[self qt], (int)order);
	return self;
}

- (int) order
{
	return (int) qt_QDateEdit_order((qt_QDateEdit *)[self qt]);
}

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

- (BOOL) autoAdvance
{
	return (BOOL) qt_QDateEdit_autoAdvance((qt_QDateEdit *)[self qt]);
}

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

- (NSDate *) minValue
{
static qt_QDate * _qdate = 0L;
	_qdate = qt_QDateEdit_minValue((qt_QDateEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDate: _qdate];
}

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

- (NSDate *) maxValue
{
static qt_QDate * _qdate = 0L;
	_qdate = qt_QDateEdit_maxValue((qt_QDateEdit *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDate: _qdate];
}

- setRange: (NSDate *)min max: (NSDate *)max
{
static qt_QDate * _qdate_max = 0L;
static qt_QDate * _qdate_min = 0L;
	qt_QDateEdit_setRange((qt_QDateEdit *)[self qt], (qt_QDate *) [min toQDate: (qt_QDate **)&_qdate_min], (qt_QDate *) [max toQDate: (qt_QDate **)&_qdate_max]);
	return self;
}

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

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

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

- stepUp
{
	qt_QDateEdit_stepUp((qt_QDateEdit *)[self qt]);
	return self;
}

- stepDown
{
	qt_QDateEdit_stepDown((qt_QDateEdit *)[self qt]);
	return self;
}

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

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

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

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

- setYear: (int)year
{
	qt_QDateEdit_setYear((qt_QDateEdit *)[self qt], (int)year);
	return self;
}

- setMonth: (int)month
{
	qt_QDateEdit_setMonth((qt_QDateEdit *)[self qt], (int)month);
	return self;
}

- setDay: (int)day
{
	qt_QDateEdit_setDay((qt_QDateEdit *)[self qt], (int)day);
	return self;
}

- fix
{
	qt_QDateEdit_fix((qt_QDateEdit *)[self qt]);
	return self;
}

- (BOOL) outOfRange: (int)y m: (int)m d: (int)d
{
	return (BOOL) qt_QDateEdit_outOfRange((qt_QDateEdit *)[self qt], (int)y, (int)m, (int)d);
}

- updateButtons
{
	qt_QDateEdit_updateButtons((qt_QDateEdit *)[self qt]);
	return self;
}

+ (int) DMY
{
	return (int) QDATEEDIT_DMY;
}

+ (int) MDY
{
	return (int) QDATEEDIT_MDY;
}

+ (int) YMD
{
	return (int) QDATEEDIT_YMD;
}

+ (int) YDM
{
	return (int) QDATEEDIT_YDM;
}

@end
