/*
 * NeXFontSel
 *
 * YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
 */

/* $Id: nexfontsel.h,v 1.2 2000/07/10 13:42:21 elca Exp $ */

#ifndef _NEXFONTSEL_H
#define _NEXFONTSEL_H

#define DEFAULTPATTERN "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"

#define MIN_APP_DEFAULTS_VERSION 1
#define FIELD_COUNT 14
#define DELIM '-'

/* number of font names to parse in each background iteration */
#ifndef PARSE_QUANTUM
#define PARSE_QUANTUM 25
#endif

#define NZ NULL,ZERO
#define BACKGROUND 10

/* from X11/IntrinsicP.h */
typedef void (*XtProc)(/*void*/);

typedef enum {ValidateCurrentField, SkipCurrentField} ValidateAction;

typedef struct _FieldValue {
    int field;
    String string;
    Widget menu_item;
    int count;			/* of fonts */
    int allocated;
    int *font;
    Boolean enable;
} FieldValue;


typedef struct _FieldValueList {
    int count;			/* of values */
    int allocated;
    Boolean show_unselectable;
    FieldValue value[1];	/* really [allocated] */
} FieldValueList;


typedef struct _FontValues {
    int value_index[FIELD_COUNT];
} FontValues;


typedef struct _FieldMenu {
    int field;
    Widget button;
} FieldMenuRec;


typedef struct _Choice {
    struct _Choice *prev;
    FieldValue *value;
} Choice;

typedef struct _Parse {
    char **fontNames;
    int num_fonts;
    int start, end;
    FontValues *fonts;
    FieldValueList **fieldValues;
} ParseRec;

typedef struct _WorkPiece {
    struct _WorkPiece *next;
    int priority;
    XtProc proc;
    XtPointer closure;
} WorkPieceRec, *WorkPiecePtr;

struct _appRes {
    int app_defaults_version;
    Cursor cursor;
    String pattern;
    String pixelSizeList;
    String pointSizeList;
    Boolean print_on_quit;
    String sample_text;
    String sample_text16;
    String sample_textUCS;
    Boolean scaled_fonts;
};

static Boolean IsISO10646(Display *dpy, XFontStruct *font);
static void ScheduleWork(XtProc proc, XtPointer closure, int priority);
static void SetNoFonts(void);
static void SetParsingFontCount(int count);
static void SetCurrentFontCount(void);
static void EnableRemainingItems(ValidateAction current_field_action);
static void EnableAllItems(int field);
static void FlushXqueue(Display *dpy);
static void MarkInvalidFonts(Boolean *set, FieldValue *val);
static void AllAnyValue(Widget w, XtPointer closure, XtPointer callData);
static void Syntax(char *call);
static void SelectAction(Widget w, XtPointer closure, XtPointer callData);


static void GetFontNames(XtPointer closure);
static Boolean Matches(register String pattern, register String fontName,
		       Boolean fields[/*FIELD_COUNT*/], int *maxField);
static Boolean DoWorkPiece(XtPointer closure);
static void Quit(Widget w, XtPointer closure, XtPointer callData);
static void OwnSelection(Widget w, XtPointer closure, XtPointer callData);
static void SelectField(Widget w, XtPointer closure, XtPointer callData);
static void ParseFontNames(XtPointer closure);
static void SortFields(XtPointer closure);
static void FixScalables(XtPointer closure);
static void MakeFieldMenu(XtPointer closure);
static void SelectValue(Widget w, XtPointer closure, XtPointer callData);
static void AnyValue(Widget w, XtPointer closure, XtPointer callData);
static void EnableOtherValues(Widget w, XtPointer closure, XtPointer callData);
static void EnableMenu(XtPointer closure);
static void SetCurrentFont(XtPointer closure);
static Boolean IsXLFDFontName(String fontName);

#endif
/* end */
