teapot-spreadsheet/src/common/cell.h

71 lines
1.7 KiB
C

#ifndef CELL_H
#define CELL_H
#include "scanner.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { LEFT=0, RIGHT=1, CENTER=2, AUTOADJUST=3 } Adjust;
typedef enum
{ BASE_CONT=0, ITER_CONT, ATTR_REF, MAX_PERSIST_TV = ATTR_REF,
CURR_VAL, RES_VAL,
CONTINGENT /* Must be last, marks end of many loops */
} TokVariety;
extern const char *TokVariety_Name[];
typedef unsigned char ColorNum;
#define MAX_MAX_COLORS UCHAR_MAX;
typedef enum { FOREGROUND = 0, BACKGROUND, NUM_COLOR_ASPECTS } ColorAspect;
extern const char *ColorAspect_Name[];
extern const ColorNum DefaultCN[];
typedef struct
{
Token tok[CONTINGENT];
char *label;
int precision;
Adjust adjust;
ColorNum aspect[NUM_COLOR_ASPECTS];
unsigned int updated:1;
unsigned int shadowed:1;
unsigned int scientific:1;
unsigned int locked:1;
unsigned int transparent:1;
unsigned int ignored:1;
unsigned int clock_t0:1;
unsigned int clock_t1:1;
unsigned int clock_t2:1;
unsigned int bold:1;
unsigned int underline:1;
} Cell;
#define NULLCELL ((Cell*)0)
typedef enum {ALTER_LABEL, PRESERVE_LABEL} LabelHandling;
Token gettok(const Cell *cell, TokVariety v);
Adjust getadjust(const Cell *cell);
bool shadowed(const Cell *cell);
bool isbold(const Cell *cell);
bool underlined(const Cell *cell);
ColorNum getcolor(const Cell *cell, ColorAspect aspect);
bool locked(const Cell *cell);
bool transparent(const Cell *cell);
bool ignored(const Cell *cell);
bool getscientific(const Cell *cell);
int getprecision(const Cell* cell);
const char *getlabel(const Cell *cell);
void initcellcontents(Cell *cell);
void freecellcontents(Cell *cell);
void copycell(Cell *to, const Cell *from, LabelHandling lh);
#ifdef __cplusplus
}
#endif
#endif