edamenu.cpp 2.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/************************************************************************/
/*				MODULE edamenu.cpp										*/
/************************************************************************/

/****************************/
/*  INCLUDES SYSTEMES		*/
/****************************/

#include "fctsys.h"

#include "wxstruct.h"
#include "gr_basic.h"
#include "macros.h"
#include "common.h"

#include "worksheet.h"

/* Pour imprimer / lire en unites utilisateur ( INCHES / MM ) */

/* Retourne la valeur en inch ou mm de la valeur val en units internes
*/
double To_User_Unit(bool is_metric, int val,int internal_unit_value)
{
double value;

	if (is_metric)
		value = (double) (val) * 25.4 / internal_unit_value;
	else value = (double) (val) / internal_unit_value;

	return value;
}

/* Retourne la valeur en units internes de la valeur val exprime en inch ou mm
*/
int From_User_Unit(bool is_metric, double val,int internal_unit_value)
{
double value;

	if (is_metric) value = val * internal_unit_value / 25.4 ;
	else value = val * internal_unit_value;

	return (int) round(value);
}

/**********************/
46
wxString GenDate()
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
/**********************/
/* Retourne la chaine de caractere donnant la date */
{
static char * mois[12] =
	{
	"jan", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"
	};
time_t buftime;
struct tm * Date;
wxString string_date;
char Line[1024];

	time(&buftime);
	Date = gmtime(&buftime);
	sprintf(Line,"%d %s %d", Date->tm_mday,
							mois[Date->tm_mon],
							Date->tm_year + 1900);
	string_date = Line;
	return(string_date);
}

/***********************************/
void * MyMalloc (size_t nb_octets)
/***********************************/
/* Routine d'allocation memoire */
{
void * pt_mem;
char txt[60];

	if (nb_octets == 0)
		{
		DisplayError(NULL, "Allocate 0 bytes !!");
		return(NULL);
		}
	pt_mem = malloc(nb_octets);
	if (pt_mem == NULL)
		{
		sprintf(txt,"Out of memory: allocation %d bytes", nb_octets);
		DisplayError(NULL, txt);
		}
	return(pt_mem);
}

/************************************/
void * MyZMalloc (size_t nb_octets)
/************************************/
/* Routine d'allocation memoire, avec remise a zero de la zone allouee */
{
	void * pt_mem = MyMalloc (nb_octets);
	if ( pt_mem) memset(pt_mem, 0, nb_octets);
	return(pt_mem);
}

/*******************************/
void MyFree (void * pt_mem)
/*******************************/
{
	if( pt_mem ) free(pt_mem);
}