#pragma +
// Name:						Auswert-Basis-Klassen
// Programmtyp:			Hilfsroutine für
//								Fakturierprogramm
//	Programmiersprache:	C++ (AT&T Standard 3.0)
// Computersystem:		Commodore AMIGA
// Betriebssystem:		AMIGA OS3.0 oder höher
// Autor:					Manfred Tremmel
// © Copyright:			1998-2000 by MT Graphic & Design
// Version:					V1.08
//
//    Copyright (C) 1997-2000 Manfred Tremmel
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA


// Includes:
#include "MTScreen.h"
#include "MTLocale.h"
#include "MTWindow.h"
#include "MTAuswert.h"

extern OpenLocaleClass	*MyLocalePTR;

// MTAuswert Klasse
// Konstruktor
MTAuswert::MTAuswert( MTWindow* Win )
{
	Switch = FALSE;
 	NextAusw = NULL;
	PrevAusw = NULL;
	ThisWindow = Win;
};

BOOL MTAuswert::TextAuswert( STRPTR DBText )
{
	BOOL Update = FALSE;
	if( GetAttr(WSTRINGA_String, ThisWindow->gads[IconNummer], (ULONG *)&TextPTR ) )
	{
		if( strcmp( (const char *)TextPTR, (const char*)DBText) != 0 )
		{
			strcpy( (char *)DBText, (const char *)TextPTR);
			Update = TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::TextFeldAuswert( STRPTR DBText )
{
	BOOL Update = FALSE;
	if( GetAttr(WSTRINGFIELDA_Text, ThisWindow->gads[IconNummer], (ULONG *)&TextPTR ) )
	{
		if( strcmp( (const char *)TextPTR, (const char*)DBText) != 0 )
		{
			strcpy( (char *)DBText, (const char *)TextPTR);
			Update = TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::DoubleAuswert( DOUBLE *DBDouble, UBYTE NKStellen )
{
	BOOL Update = FALSE;
	if( GetAttr(WSTRINGA_String, ThisWindow->gads[IconNummer], (ULONG *)&TextPTR ) )
	{
		DoubleWert = MyLocalePTR->ParseNumber( (STRPTR)TextPTR );
		if( DoubleWert != *DBDouble )
		{
			*DBDouble = DoubleWert;
			Update = TRUE;
		}
		MyLocalePTR->FormatNumber( Buffer, DoubleWert, NKStellen);
		SetGadgetAttrs( ThisWindow->gads[IconNummer], ThisWindow->Win, NULL, WSTRINGA_String, (STRPTR)Buffer, TAG_DONE );
	}
	return Update;
};

BOOL MTAuswert::MoneyAuswert( DOUBLE *DBDouble, STRPTR Waehrung )
{
	BOOL Update = FALSE;
	if( GetAttr(WSTRINGA_String, ThisWindow->gads[IconNummer], (ULONG *)&TextPTR ) )
	{
		DoubleWert = MyLocalePTR->ParseMoney( (STRPTR)TextPTR );
		if( DoubleWert != *DBDouble )
		{
			*DBDouble = DoubleWert;
			Update = TRUE;
		}
		MyLocalePTR->FormatMoney( Buffer, DoubleWert, Waehrung );
		SetGadgetAttrs( ThisWindow->gads[IconNummer], ThisWindow->Win, NULL, WSTRINGA_String, (STRPTR)Buffer, TAG_DONE );
	}
	return Update;
};

BOOL MTAuswert::DatumAuswert( struct DateStamp* DBDatum )
{
	BOOL Update = FALSE;
	if( GetAttr(WSTRINGA_String, ThisWindow->gads[IconNummer], (ULONG *)&TextPTR ) )
	{
		struct DateStamp MyDatestamp = MyLocalePTR->ParseDateC( (STRPTR)TextPTR );
		if( MyDatestamp.ds_Days	!= DBDatum->ds_Days )
		{
			DBDatum->ds_Days		= MyDatestamp.ds_Days;
			DBDatum->ds_Minute	= MyDatestamp.ds_Minute;
			DBDatum->ds_Tick		= MyDatestamp.ds_Tick;
			Update = TRUE;
		}
		MyLocalePTR->FormatDateC( Buffer, DBDatum );
		SetGadgetAttrs( ThisWindow->gads[IconNummer], ThisWindow->Win, NULL, WSTRINGA_String, (STRPTR)Buffer, TAG_DONE );
	}
	return Update;
};

BOOL MTAuswert::CycleAuswert( UBYTE *DBCycle )
{
	BOOL Update = FALSE;
	if( GetAttr(WCYCLEA_Active, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert	!= *DBCycle )
		{
			*DBCycle		= LongWert;
			Update		= TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::CycleAuswert( UWORD *DBCycle )
{
	BOOL Update = FALSE;
	if( GetAttr(WCYCLEA_Active, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert	!= *DBCycle )
		{
			*DBCycle		= LongWert;
			Update		= TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::CycleAuswert( ULONG *DBCycle )
{
	BOOL Update = FALSE;
	if( GetAttr(WCYCLEA_Active, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert	!= *DBCycle )
		{
			*DBCycle		= LongWert;
			Update		= TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::LongAuswert( ULONG *DBLong )
{
	BOOL Update = FALSE;
	if( GetAttr(WINTEGERA_Long, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert != *DBLong )
		{
			*DBLong = LongWert;
			Update = TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::LongAuswert( LONG *DBLong )
{
	BOOL Update = FALSE;
	if( GetAttr(WINTEGERA_Long, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert != *DBLong )
		{
			*DBLong = LongWert;
			Update = TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::LongAuswert( UWORD *DBLong )
{
	BOOL Update = FALSE;
	if( GetAttr(WINTEGERA_Long, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert != *DBLong )
		{
			*DBLong = LongWert;
			Update = TRUE;
		}
	}
	return Update;
};

BOOL MTAuswert::LongAuswert( UBYTE *DBLong )
{
	BOOL Update = FALSE;
	if( GetAttr(WINTEGERA_Long, ThisWindow->gads[IconNummer], (ULONG *)&LongWert ) )
	{
		if( LongWert != *DBLong )
		{
			*DBLong = LongWert;
			Update = TRUE;
		}
	}
	return Update;
};

UWORD MTAuswert::GetHotKey( STRPTR Label, ULONG Position )
{
	BOOL Weiter = TRUE;

	for(; *Label && Weiter; Label++)
	{
		if( *Label == '\n' )
			Position--;
		if( Position == 0 )
		{
			for(; *Label && *Label != '_'; Label++);
			Weiter = FALSE;
		}
	}

	return (UWORD)MyLocalePTR->ConvToUpperC((ULONG)*Label);
};

