/***************************************************************************
                            QSpinBox.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_QSpinBox.h>
#include <qtc/qt_QRangeControl.h>
#include <qtobjc/QSpinBox.h>
#include <qtobjc/QStyle.h>
#include <qtobjc/QValidator.h>
#include <qtobjc/QLineEdit.h>

@implementation  QSpinBox


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

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

- initWithInt: (int)minValue maxValue: (int)maxValue 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QSpinBox1((int)minValue, (int)maxValue, 1, 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_QSpinBox((qt_QSpinBox *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) text
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_text((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) prefix
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_prefix((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) suffix
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_suffix((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) cleanText
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_cleanText((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setSpecialValueText: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	qt_QSpinBox_setSpecialValueText((qt_QSpinBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- (NSString *) specialValueText
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_specialValueText((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setWrapping: (BOOL)on
{
	qt_QSpinBox_setWrapping((qt_QSpinBox *)[self qt], (int)on);
	return self;
}

- (BOOL) wrapping
{
	return (BOOL) qt_QSpinBox_wrapping((qt_QSpinBox *)[self qt]);
}

- setButtonSymbols: (int)arg1
{
	qt_QSpinBox_setButtonSymbols((qt_QSpinBox *)[self qt], (int)arg1);
	return self;
}

- (int) buttonSymbols
{
	return (int) qt_QSpinBox_buttonSymbols((qt_QSpinBox *)[self qt]);
}

- setValidator: (QValidator *)v
{
	qt_QSpinBox_setValidator((qt_QSpinBox *)[self qt], (qt_QValidator *) [v qt]);
	return self;
}

- (QValidator*) validator
{
	return (QValidator*) [QtSupport objectForQtKey: qt_QSpinBox_validator((qt_QSpinBox *)[self qt]) withClass: [QValidator class] allocatedInObjcWorld: YES];
}

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

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

- (int) minValue
{
	return (int) qt_QSpinBox_minValue((qt_QSpinBox *)[self qt]);
}

- (int) maxValue
{
	return (int) qt_QSpinBox_maxValue((qt_QSpinBox *)[self qt]);
}

- setMinValue: (int)arg1
{
	qt_QSpinBox_setMinValue((qt_QSpinBox *)[self qt], (int)arg1);
	return self;
}

- setMaxValue: (int)arg1
{
	qt_QSpinBox_setMaxValue((qt_QSpinBox *)[self qt], (int)arg1);
	return self;
}

- (int) lineStep
{
	return (int) qt_QSpinBox_lineStep((qt_QSpinBox *)[self qt]);
}

- setLineStep: (int)arg1
{
	qt_QSpinBox_setLineStep((qt_QSpinBox *)[self qt], (int)arg1);
	return self;
}

- (int) value
{
	return (int) qt_QSpinBox_value((qt_QSpinBox *)[self qt]);
}

- (QRect*) upRect
{
	return (QRect*) [QtSupport objectForQtKey: qt_QSpinBox_upRect((qt_QSpinBox *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- (QRect*) downRect
{
	return (QRect*) [QtSupport objectForQtKey: qt_QSpinBox_downRect((qt_QSpinBox *)[self qt]) withClass: [QRect class] allocatedInObjcWorld: YES];
}

- setValue: (int)value
{
	qt_QSpinBox_setValue((qt_QSpinBox *)[self qt], (int)value);
	return self;
}

- setPrefix: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	qt_QSpinBox_setPrefix((qt_QSpinBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- setSuffix: (NSString *)text
{
static qt_QString * _qstring_text = 0L;
	qt_QSpinBox_setSuffix((qt_QSpinBox *)[self qt], (qt_QString *) [text toQString: &_qstring_text]);
	return self;
}

- stepUp
{
	qt_QSpinBox_stepUp((qt_QSpinBox *)[self qt]);
	return self;
}

- stepDown
{
	qt_QSpinBox_stepDown((qt_QSpinBox *)[self qt]);
	return self;
}

- setEnabled: (BOOL)enabled
{
	qt_QSpinBox_setEnabled((qt_QSpinBox *)[self qt], (int)enabled);
	return self;
}

- selectAll
{
	qt_QSpinBox_selectAll((qt_QSpinBox *)[self qt]);
	return self;
}

- (NSString *) mapValueToText: (int)value
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_mapValueToText((qt_QSpinBox *)[self qt], (int)value);
	return [NSString fromQString: _qstring];
}

- (int) mapTextToValue: (int*)ok
{
	return (int) qt_QSpinBox_mapTextToValue((qt_QSpinBox *)[self qt], (int*)ok);
}

- (NSString *) currentValueText
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSpinBox_currentValueText((qt_QSpinBox *)[self qt]);
	return [NSString fromQString: _qstring];
}

- updateDisplay
{
	qt_QSpinBox_updateDisplay((qt_QSpinBox *)[self qt]);
	return self;
}

- interpretText
{
	qt_QSpinBox_interpretText((qt_QSpinBox *)[self qt]);
	return self;
}

- (QLineEdit*) editor
{
	return (QLineEdit*) [QtSupport objectForQtKey: qt_QSpinBox_editor((qt_QSpinBox *)[self qt]) withClass: [QLineEdit class] allocatedInObjcWorld: YES];
}

- valueChange
{
	qt_QSpinBox_valueChange((qt_QSpinBox *)[self qt]);
	return self;
}

- rangeChange
{
	qt_QSpinBox_rangeChange((qt_QSpinBox *)[self qt]);
	return self;
}

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

- styleChange: (QStyle*)arg1
{
	qt_QSpinBox_styleChange((qt_QSpinBox *)[self qt], (qt_QStyle*) [arg1 qt]);
	return self;
}

- textChanged
{
	qt_QSpinBox_textChanged((qt_QSpinBox *)[self qt]);
	return self;
}

+ (int) UpDownArrows
{
	return (int) QSPINBOX_UpDownArrows;
}

+ (int) PlusMinus
{
	return (int) QSPINBOX_PlusMinus;
}

@end

@implementation QSpinBox (QRangeControlImplementation)
- (int) value
{
	return (int) qt_QRangeControl_value(qt_QSpinBox_QRangeControl([self qt]));
}

- setValue: (int)arg1
{
	qt_QRangeControl_setValue(qt_QSpinBox_QRangeControl([self qt]), (int)arg1);
	return self;
}

- addPage
{
	qt_QRangeControl_addPage(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- subtractPage
{
	qt_QRangeControl_subtractPage(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- addLine
{
	qt_QRangeControl_addLine(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- subtractLine
{
	qt_QRangeControl_subtractLine(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- (int) minValue
{
	return (int) qt_QRangeControl_minValue(qt_QSpinBox_QRangeControl([self qt]));
}

- (int) maxValue
{
	return (int) qt_QRangeControl_maxValue(qt_QSpinBox_QRangeControl([self qt]));
}

- setRange: (int)minValue maxValue: (int)maxValue
{
	qt_QRangeControl_setRange(qt_QSpinBox_QRangeControl([self qt]), (int)minValue, (int)maxValue);
	return self;
}

- setMinValue: (int)minVal
{
	qt_QRangeControl_setMinValue(qt_QSpinBox_QRangeControl([self qt]), (int)minVal);
	return self;
}

- setMaxValue: (int)minVal
{
	qt_QRangeControl_setMaxValue(qt_QSpinBox_QRangeControl([self qt]), (int)minVal);
	return self;
}

- (int) lineStep
{
	return (int) qt_QRangeControl_lineStep(qt_QSpinBox_QRangeControl([self qt]));
}

- (int) pageStep
{
	return (int) qt_QRangeControl_pageStep(qt_QSpinBox_QRangeControl([self qt]));
}

- setSteps: (int)line page: (int)page
{
	qt_QRangeControl_setSteps(qt_QSpinBox_QRangeControl([self qt]), (int)line, (int)page);
	return self;
}

- (int) bound: (int)arg1
{
	return (int) qt_QRangeControl_bound(qt_QSpinBox_QRangeControl([self qt]), (int)arg1);
}

- (int) positionFromValue: (int)val space: (int)space
{
	return (int) qt_QRangeControl_positionFromValue(qt_QSpinBox_QRangeControl([self qt]), (int)val, (int)space);
}

- (int) valueFromPosition: (int)pos space: (int)space
{
	return (int) qt_QRangeControl_valueFromPosition(qt_QSpinBox_QRangeControl([self qt]), (int)pos, (int)space);
}

- directSetValue: (int)val
{
	qt_QRangeControl_directSetValue(qt_QSpinBox_QRangeControl([self qt]), (int)val);
	return self;
}

- (int) prevValue
{
	return (int) qt_QRangeControl_prevValue(qt_QSpinBox_QRangeControl([self qt]));
}

- valueChange
{
	qt_QRangeControl_valueChange(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- rangeChange
{
	qt_QRangeControl_rangeChange(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

- stepChange
{
	qt_QRangeControl_stepChange(qt_QSpinBox_QRangeControl([self qt]));
	return self;
}

@end
