/*
*
* (c) Copyright 1991-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Author: Adobe Systems Incorporated
*/
/* $XFree86$ */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
/* There are no words to describe how I feel about having to do this */
#if XmVersion > 1001
#include <Xm/ManagerP.h>
#else
#endif
#include <Xm/SeparatoG.h>
#include <Xm/RowColumn.h>
#include <Xm/DrawingA.h>
#include <Xm/ScrolledW.h>
#include <Xm/ToggleBG.h>
#include <Xm/RowColumn.h>
#include <DPS/dpsXclient.h>
#include <DPS/dpsXcommon.h>
#include <DPS/dpsXshare.h>
#include "FSBwraps.h"
#include "FontSBI.h"
#include <DPS/FontSamplP.h>
#if 0
/* This is not in Xos.h for some reason */
char *strstr();
#endif
#define MAX(x,y) ((x) > (y) ? (x) : (y))
static float defaultSizeList[] = {
#ifndef SAMPLER_DEFAULT_SIZE_LIST
8, 10, 12, 14, 16, 18, 24, 36, 48, 72
#else
#endif /* DEFAULT_SIZE_LIST */
};
#ifndef SAMPLER_DEFAULT_SIZE_LIST_COUNT
#endif /* DEFAULT_SIZE_LIST_COUNT */
#ifndef SAMPLER_DEFAULT_SIZE
#endif /* SAMPLER_DEFAULT_SIZE */
"Current size is too large or panel is too small"},
"There are no fonts!"},
"No font is currently selected"},
"No family is currently selected"},
"Selected family has no fonts!"},
"No fonts match filters"},
};
/* Forward declarations */
static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed);
static void ChangeManaged(Widget w);
static void ClassInitialize(void);
{"FSBClickAction", ClickAction}
};
/* Core class part */
{
/* class_name */ "FontSampler",
/* widget_size */ sizeof(FontSamplerRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize */ ClassPartInitialize,
/* class_inited */ False,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ actions,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ True,
/* compress_exposure */ XtExposeCompressMultiple,
/* compress_enterleave */ True,
/* visible_interest */ False,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ NULL,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback offsets */ NULL,
/* tm_table */ NULL,
/* query_geometry */ XtInheritQueryGeometry,
/* display_accelerator */ NULL,
/* extension */ NULL,
},
/* Composite class part */
{
/* geometry_manager */ GeometryManager,
/* change_managed */ ChangeManaged,
/* insert_child */ XtInheritInsertChild,
/* delete_child */ XtInheritDeleteChild,
/* extension */ NULL,
},
/* Constraint class part */
{
/* resources */ NULL,
/* num_resources */ 0,
/* constraint_size */ 0,
/* initialize */ NULL,
/* destroy */ NULL,
/* set_values */ NULL,
/* extension */ NULL,
},
/* Manager class part */
{
/* translations */ XtInheritTranslations,
/* syn_resources */ NULL,
/* num_syn_resources */ 0,
/* syn_constraint_resources */ NULL,
/* num_syn_constraint_resources */ 0,
/* parent_process */ XmInheritParentProcess,
/* extension */ NULL,
},
/* FontSampler class part */
{
/* cancel */ Cancel,
/* extension */ NULL,
}
};
struct _FilterRec;
typedef struct _FilterRec {
char *name;
} FilterRec;
{"symbol", {"Pi", "Symbol", "Logo", "Math", "Ornaments",
{"oldstyle", {"Oldstyle Figures", "Old Style Figures",
"Expert", NULL}},
{"separator1", { NULL}},
{"separator2", { NULL}},
{"medium", {"Medium", "Normal", "Regular",
{"black", {"Black", "Heavy", "Poster", "Scal",
{"separator3", { NULL}},
};
#define TYPE_FILTERS 0
{
}
{
d->l-1, d->t-1);
}
{
int bogusFont;
}
/* ARGSUSED */
static void ClickAction(
{
DisplayedFontRec *f;
while (f != NULL &&
(b->x < f->l || b->y < f->t || b->x > f->r || b->y > f->b)) {
f = f->next;
}
if (f != NULL) {
if (s->sampler.highlighted_font == f) return;
s->sampler.highlighted_font = f;
HighlightFont(s);
else {
}
} else {
}
}
}
static void UpdateDisplayedFontRecs(
{
float h, w;
DisplayedFontRec *f;
h = newHeight;
w = newWidth;
}
}
/* ARGSUSED */
static void ResizeEventHandler(
{
int depth;
Pixmap p;
/* Trying to make it fit exactly causes looooping... */
}
}
(XDPSStandardColormap *) NULL,
(XDPSStandardColormap *) NULL,
s->sampler.pixmap_gstate);
p, new_height,
(XDPSStandardColormap *) NULL,
(XDPSStandardColormap *) NULL,
s->sampler.pixmap_gstate);
/* La di dah */
}
}
}
static void ClassInitialize(void)
{
}
{
}
}
{
DisplayedFontRec *f;
DisplayedTextRec *t;
XtFree((char *) f);
}
XtFree((char *) t);
}
}
{
return XmToggleButtonGadgetGetState(widget);
}
/* ARGSUSED */
{
float h, w;
float *m;
char *value;
DisplayedTextRec *t;
}
NULL);
(XDPSStandardColormap *) NULL,
(XDPSStandardColormap *) NULL,
(XDPSStandardColormap *) NULL,
(XDPSStandardColormap *) NULL,
&s->sampler.pixmap_gstate);
}
h = info->window_height;
info->column_width = 0;
info->x = 5;
else {
}
s->sampler.pixmap_gstate);
}
}
{
}
/* ARGSUSED */
{
}
/* ARGSUSED */
{
DisplayedTextRec *t;
char *value;
if (!s->sampler.displaying) return;
t = XtNew(DisplayedTextRec);
}
/* ARGSUSED */
{
}
/* ARGSUSED */
{
}
}
/* ARGSUSED */
{
}
}
/* ARGSUSED */
{
}
/* ARGSUSED */
{
int j;
}
}
}
/* ARGSUSED */
{
char *ch;
DisplayedTextRec *t;
else {
}
if (!s->sampler.displaying) return;
t = XtNew(DisplayedTextRec);
else {
}
}
/* There's a problem; sometimes the change has already been made in the field,
and sometimes it hasn't. The times when it has seem to correspond to
making changes with the size option menu, so we use this disgusting
global flag to notice when this happens. */
/* ARGSUSED */
{
int i;
int decimalPoints = 0;
if (changingSize) return; /* We know what we're doing; allow it */
/* Should probably look at format field, but seems to contain garbage */
return;
}
}
if (decimalPoints > 1) {
return;
}
}
}
/* ARGSUSED */
{
changingSize = True;
}
{
int i, j;
char *ch;
if (destroyOldChildren) {
/* Don't destroy first child ("other") */
sizeof(Widget));
} else {
i = 0;
sizeof(Widget));
}
for (j = 0; j < s->sampler.size_count; j++) {
i = 0;
sizes[j+1] =
}
}
{
FilterRec *f;
int i;
s->sampler.filter_widgets =
s->sampler.filter_flags =
f = filters+i;
s->sampler.filter_widgets[i] =
} else {
s->sampler.filter_widgets[i] =
FilterCallback, (XtPointer) s);
}
}
}
{
int i;
int depth;
i = 0;
DisplayCallback, (XtPointer) s);
i = 0;
s->sampler.stop_button_child =
StopCallback, (XtPointer) s);
i = 0;
DismissCallback, (XtPointer) s);
i = 0;
s->sampler.size_label_child =
i = 0;
XtCreateManagedWidget("sizeTextField",
SizeSelect, (XtPointer) s);
i = 0;
CreateSizeMenu(s, False);
i = 0;
i = 0;
i = 0;
s->sampler.radio_frame_child =
i = 0;
"radioBox", args, i);
i = 0;
s->sampler.all_toggle_child =
i = 0;
i = 0;
XtCreateManagedWidget("selectedFamilyToggle",
i = 0;
XtCreateManagedWidget("filterToggle",
i = 0;
i = 0;
s->sampler.filter_box_child =
CreateFilters(s);
i = 0;
s->sampler.filter_text_child =
FilterCallback, (XtPointer) s);
i = 0;
ClearCallback, (XtPointer) s);
i = 0;
s->sampler.text_child =
TextCallback, (XtPointer) s);
i = 0;
s->sampler.font_label_child =
i = 0;
XtCreateManagedWidget("scrolledWindow",
i = 0;
s->sampler.area_child =
ExposeCallback, (XtPointer) s);
NULL);
/* I would like to use translations for this, but Motif overwrites the
clip window's translation. Grr... */
ResizeEventHandler, (XtPointer) s);
NULL);
}
NULL);
}
/* ARGSUSED */
static void Initialize(
{
/* Must have a fsb */
"initializeFontSampler", "noFontSelectionBox",
"FontSelectionBoxError",
"No font selection box given to font sampler",
}
/* Verify size list */
"initializeFontSampler", "sizeMismatch",
"FontSelectionBoxError",
"Size count specified but no sizes present",
}
"initializeFontSampler", "negativeSize",
"FontSelectionBoxError",
"Size count should not be negative",
}
/* Initialize non-resource fields */
}
{
}
}
}
}
{
DisplayedFontRec *d;
float *m;
int bogusFont;
if (info->y < 0) {
info->column_width = 0;
}
return True;
}
/* Do ...AndGetDimensions on the pixmap to make sure that it's synced.
That way we can reliably do an XCopyArea without first doing a
WaitContext. */
if (bogusFont) {
if (info->current_font == f) {
/* Must be the same font, different blend */
}
}
}
return True;
}
s->sampler.pixmap_gstate);
d = XtNew(DisplayedFontRec);
d->x = info->x;
d->y = info->y;
d->font = f;
d->blend = b;
info->shown_fonts = d;
return True;
}
{
}
return True;
}
return True;
}
return False;
}
{
return True;
}
{
} else {
return True;
}
}
return True;
}
return True;
}
return False;
}
/* ARGSUSED */
{
FilterRec *f;
int len;
/* Roman means not italic and not symbol */
do {
}
}
}
return True;
}
{
FilterRec *f;
int len;
do {
}
}
/* Also match anything that has none of the other weight particles */
if (f == filter) continue;
do {
}
}
}
return True;
}
{
int len;
do {
/* Only match "Ultra" if not followed by "Compressed" or
"Light". We'd also like to add "Condensed" to this
list, but some fonts use "Ultra Condensed" to mean
"Ultra & Condensed" while others use it to mean "Very
much Condensed". Sigh... */
}
}
}
return False;
}
{
int i;
}
}
s->sampler.filter_text =
}
{
int *cl, i;
FilterRec *f;
int len;
char *name;
for (i = *cl;
f = filters+i;
if (!s->sampler.filter_flags[i]) continue;
goto NEXT_CLASS;
}
continue;
}
do {
goto NEXT_CLASS;
}
}
}
}
NEXT_CLASS: ;
/* If there were any filters set in this class, but we didn't match,
return False */
}
/* Now check against the text field */
return allmatch;
}
}
{
}
return True;
}
} else AdvanceInfoToNextFont(info);
return True;
}
return False;
}
{
s->sampler.pixmap_gstate);
}
}
}
}
{
}
/* ARGSUSED */
Widget w,
{
if (WANTS(CWBorderWidth)) {
}
return XtGeometryYes;
}
{
FontSamplerWidget s = (FontSamplerWidget) w;
}
/* ARGSUSED */
{
"setValuesFontSampler", "sizeMismatch",
"FontSelectionBoxError",
"Size count specified but no sizes present",
}
"setValuesFontSampler", "negativeSize",
"FontSelectionBoxError",
"Size count should not be negative",
}
return False;
}
{
FontSamplerWidget s = (FontSamplerWidget) w;
}
}
{
}
#ifdef NO_STRSTR_AVAILABLE
{
}
len1--;
s1++;
}
}
#endif /* NO_STRSTR_AVAILABLE */