mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Check in locale independent form select/button handling change Approvaled by XFE owner
This commit is contained in:
parent
00e5e615d4
commit
8dd7624bd3
254
cmd/xfe/fonts.c
254
cmd/xfe/fonts.c
@ -180,6 +180,9 @@ static GenericFontFamily fe_generics[] = {
|
||||
|
||||
static XP_Bool fe_AreNormalFontsAvail(int16 win_csid);
|
||||
|
||||
static XmFontList fe_GetFontListNormal(int16 charset, fe_Font font, int numOfFont);
|
||||
static XmString fe_ToXmStringNormal(int16 charset, fe_Font font, char * string, int len);
|
||||
|
||||
static fe_Font
|
||||
fe_LoadNormalFont(MWContext *context, char *familyName,
|
||||
int points, int sizeNum,
|
||||
@ -211,6 +214,10 @@ static char * fe_FindGenericFamily(int charsetID, char *familyName);
|
||||
|
||||
static XP_Bool fe_AreEUCCNFontsAvail(int16 /* win_csid */);
|
||||
|
||||
static XmFontList fe_FontGroupGetFontList(int16 charset, fe_Font font, int numOfFonts);
|
||||
static XmString fe_EUCToXmString(int16 charset, fe_Font fontGroup, char * string, int len,
|
||||
fe_StringProcessTable *table);
|
||||
|
||||
static fe_Font
|
||||
fe_LoadEUCCNFont(MWContext *context, char *familyName, int points,
|
||||
int sizeNum, int fontmask, int charset, int pitch,
|
||||
@ -225,6 +232,7 @@ static void
|
||||
fe_DrawEUCCNImageString(Display *dpy, Drawable d, fe_Font font, GC gc, GC gc2,
|
||||
int x, int y, char *string, int len);
|
||||
|
||||
static XmString fe_EUCCNToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
static XP_Bool fe_AreEUCJPFontsAvail(int16 /* win_csid */);
|
||||
|
||||
static fe_Font
|
||||
@ -240,6 +248,7 @@ fe_DrawEUCJPString(Display *dpy, Drawable d, fe_Font font, GC gc, int x,
|
||||
static void
|
||||
fe_DrawEUCJPImageString(Display *dpy, Drawable d, fe_Font font, GC gc, GC gc2,
|
||||
int x, int y, char *string, int len);
|
||||
static XmString fe_EUCJPToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
|
||||
static XP_Bool fe_AreEUCKRFontsAvail(int16 /* win_csid */);
|
||||
|
||||
@ -256,6 +265,7 @@ fe_DrawEUCKRString(Display *dpy, Drawable d, fe_Font font, GC gc, int x,
|
||||
static void
|
||||
fe_DrawEUCKRImageString(Display *dpy, Drawable d, fe_Font font, GC gc, GC gc2,
|
||||
int x, int y, char *string, int len);
|
||||
static XmString fe_EUCKRToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
|
||||
static XP_Bool fe_AreEUCTWFontsAvail(int16 /* win_csid */);
|
||||
|
||||
@ -272,6 +282,7 @@ fe_DrawEUCTWString(Display *dpy, Drawable d, fe_Font font, GC gc, int x,
|
||||
static void
|
||||
fe_DrawEUCTWImageString(Display *dpy, Drawable d, fe_Font font, GC gc, GC gc2,
|
||||
int x, int y, char *string, int len);
|
||||
static XmString fe_EUCTWToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
|
||||
static XP_Bool fe_AreBIG5FontsAvail(int16 /* win_csid */);
|
||||
|
||||
@ -288,6 +299,7 @@ fe_DrawBIG5String(Display *dpy, Drawable d, fe_Font font, GC gc, int x,
|
||||
static void
|
||||
fe_DrawBIG5ImageString(Display *dpy, Drawable d, fe_Font font, GC gc, GC gc2,
|
||||
int x, int y, char *string, int len);
|
||||
static XmString fe_BIG5ToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
|
||||
/* Unicode support */
|
||||
static XP_Bool fe_AreUnicodeFontsAvail(int16 /* win_csid */);
|
||||
@ -298,6 +310,10 @@ static XFontStruct *
|
||||
fe_UnicodeInitXfont(fe_UnicodePseudoFont *ufont, uint16 encoding);
|
||||
static int16 *INTL_GetXCharSetIDs(Display *dpy);
|
||||
|
||||
|
||||
static XmFontList fe_UTF8GetFontList(int16 charset, fe_Font font, int numOfFont);
|
||||
static XmString fe_UTF8ToXmString(int16 charset, fe_Font fontGroup, char * string, int len);
|
||||
|
||||
enum
|
||||
{
|
||||
FE_FONT_INFO_X8 = 0,
|
||||
@ -319,7 +335,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadNormalFont,
|
||||
(fe_TextExtentsFunc) XTextExtents,
|
||||
(fe_DrawStringFunc) XDrawString,
|
||||
(fe_DrawImageStringFunc) XDrawImageString
|
||||
(fe_DrawImageStringFunc) XDrawImageString,
|
||||
(fe_GetFontList) fe_GetFontListNormal,
|
||||
(fe_ToXmString) fe_ToXmStringNormal
|
||||
},
|
||||
{
|
||||
1,
|
||||
@ -327,7 +345,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadNormalFont,
|
||||
(fe_TextExtentsFunc) XTextExtents16,
|
||||
(fe_DrawStringFunc) XDrawString16,
|
||||
(fe_DrawImageStringFunc) XDrawImageString16
|
||||
(fe_DrawImageStringFunc) XDrawImageString16,
|
||||
(fe_GetFontList) fe_GetFontListNormal,
|
||||
(fe_ToXmString) fe_ToXmStringNormal
|
||||
},
|
||||
{
|
||||
2,
|
||||
@ -335,7 +355,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadEUCCNFont,
|
||||
(fe_TextExtentsFunc) fe_EUCCNTextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawEUCCNString,
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCCNImageString
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCCNImageString,
|
||||
(fe_GetFontList) fe_FontGroupGetFontList,
|
||||
(fe_ToXmString) fe_EUCCNToXmString
|
||||
},
|
||||
{
|
||||
4,
|
||||
@ -343,7 +365,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadEUCJPFont,
|
||||
(fe_TextExtentsFunc) fe_EUCJPTextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawEUCJPString,
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCJPImageString
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCJPImageString,
|
||||
(fe_GetFontList) fe_FontGroupGetFontList,
|
||||
(fe_ToXmString) fe_EUCJPToXmString
|
||||
},
|
||||
{
|
||||
2,
|
||||
@ -351,7 +375,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadEUCKRFont,
|
||||
(fe_TextExtentsFunc) fe_EUCKRTextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawEUCKRString,
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCKRImageString
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCKRImageString,
|
||||
(fe_GetFontList) fe_FontGroupGetFontList,
|
||||
(fe_ToXmString) fe_EUCKRToXmString
|
||||
},
|
||||
{
|
||||
3,
|
||||
@ -359,7 +385,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadEUCTWFont,
|
||||
(fe_TextExtentsFunc) fe_EUCTWTextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawEUCTWString,
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCTWImageString
|
||||
(fe_DrawImageStringFunc) fe_DrawEUCTWImageString,
|
||||
(fe_GetFontList) fe_FontGroupGetFontList,
|
||||
(fe_ToXmString) fe_EUCTWToXmString
|
||||
},
|
||||
{
|
||||
2,
|
||||
@ -367,7 +395,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadBIG5Font,
|
||||
(fe_TextExtentsFunc) fe_BIG5TextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawBIG5String,
|
||||
(fe_DrawImageStringFunc) fe_DrawBIG5ImageString
|
||||
(fe_DrawImageStringFunc) fe_DrawBIG5ImageString,
|
||||
(fe_GetFontList) fe_FontGroupGetFontList,
|
||||
(fe_ToXmString) fe_BIG5ToXmString
|
||||
},
|
||||
{
|
||||
4,
|
||||
@ -375,7 +405,9 @@ fe_CharSetFuncs fe_CharSetFuncsArray[] =
|
||||
(fe_LoadFontFunc) fe_LoadUnicodeFont,
|
||||
(fe_TextExtentsFunc) fe_UTF8TextExtents,
|
||||
(fe_DrawStringFunc) fe_DrawUTF8String,
|
||||
(fe_DrawImageStringFunc) fe_DrawUTF8StringImage
|
||||
(fe_DrawImageStringFunc) fe_DrawUTF8StringImage,
|
||||
(fe_GetFontList) fe_UTF8GetFontList,
|
||||
(fe_ToXmString) fe_UTF8ToXmString
|
||||
},
|
||||
};
|
||||
|
||||
@ -4607,6 +4639,24 @@ fe_LoadNormalFont(MWContext *context, char *familyName,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static XmFontList
|
||||
fe_GetFontListNormal(int16 charset, fe_Font font, int numOfFonts)
|
||||
{
|
||||
XmFontList fl;
|
||||
XmFontListEntry e;
|
||||
e = XmFontListEntryCreate("f0", XmFONT_IS_FONT, (XFontStruct*) font);
|
||||
XP_ASSERT(NULL != e);
|
||||
|
||||
fl = XmFontListAppendEntry(NULL, e);
|
||||
XP_ASSERT(NULL != fl);
|
||||
|
||||
XmFontListEntryFree(&e);
|
||||
return fl;
|
||||
}
|
||||
static XmString fe_ToXmStringNormal(int16 charset, fe_Font font, char * string, int len)
|
||||
{
|
||||
return XmStringCreate(string, "f0");
|
||||
}
|
||||
|
||||
void
|
||||
fe_GenericFontExtents(int charset, fe_Font font,
|
||||
@ -4687,7 +4737,6 @@ fe_GenericFontExtents(int charset, fe_Font font,
|
||||
|
||||
#define FE_PROCESS_STRING_BUFFER_SIZE 1024
|
||||
|
||||
|
||||
static void
|
||||
fe_ProcessEUCString(int charset, fe_StringProcessTable *table,
|
||||
fe_XDrawStringFunc draw1,
|
||||
@ -4865,6 +4914,100 @@ fe_ProcessEUCString(int charset, fe_StringProcessTable *table,
|
||||
}
|
||||
}
|
||||
|
||||
static XmString fe_create_and_concatnate_XmString(
|
||||
XmString list, char* str, int len, char* flabel)
|
||||
{
|
||||
XmString ret;
|
||||
XmString seg = NULL;
|
||||
|
||||
str[len++] = '\0';
|
||||
|
||||
if(NULL == list)
|
||||
return XmStringCreate(str, flabel);
|
||||
|
||||
seg = XmStringCreate(str, flabel);
|
||||
XP_ASSERT(NULL != seg);
|
||||
|
||||
ret = XmStringConcat(list, seg);
|
||||
XP_ASSERT(NULL != list);
|
||||
|
||||
XmStringFree(list);
|
||||
XmStringFree(seg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static XmString fe_EUCToXmString(int16 charset, fe_Font fontGroup, char * string, int len,
|
||||
fe_StringProcessTable *table)
|
||||
{
|
||||
int begin, cur, out;
|
||||
unsigned char curFI;
|
||||
char flabel[4];
|
||||
XmString xms = NULL;
|
||||
unsigned char buf[FE_PROCESS_STRING_BUFFER_SIZE];
|
||||
fe_StringProcessTable *entry = &table[(unsigned char)string[0]];
|
||||
unsigned char lastFI = entry->fontIndex;
|
||||
unsigned char mask1 = 0xff;
|
||||
unsigned char mask2 = 0xff;
|
||||
fe_FontGroupFont *fonts;
|
||||
fonts = (fe_FontGroupFont *) fontGroup;
|
||||
|
||||
if(FALSE == fe_AreFontsAvail(charset))
|
||||
{ /* The font is not available, it does not matter what we do, fall back to a simple string */
|
||||
return XmStringCreateLocalized(string);
|
||||
}
|
||||
|
||||
XP_STRCPY(flabel, "f0");
|
||||
|
||||
if(entry->len > 1)
|
||||
{
|
||||
mask1 = fonts[lastFI].mask1;
|
||||
mask2 = fonts[lastFI].mask2;
|
||||
}
|
||||
|
||||
for(out=cur=begin=0; cur < len; )
|
||||
{
|
||||
entry = &table[(unsigned char)string[cur]];
|
||||
curFI = entry->fontIndex;
|
||||
|
||||
/* Need to switch font, generate a new segment */
|
||||
if((lastFI != curFI) || (out >= (FE_PROCESS_STRING_BUFFER_SIZE - 4)))
|
||||
{
|
||||
(void)PR_snprintf(flabel, sizeof(flabel), "f%d", lastFI);
|
||||
|
||||
xms = fe_create_and_concatnate_XmString( xms, buf, out, flabel);
|
||||
|
||||
/* Now we should save the state somewhere */
|
||||
out = 0;
|
||||
begin = cur;
|
||||
lastFI = curFI;
|
||||
if(entry->len > 1)
|
||||
{
|
||||
mask1 = fonts[lastFI].mask1;
|
||||
mask2 = fonts[lastFI].mask2;
|
||||
}
|
||||
}
|
||||
|
||||
cur += entry->skip;
|
||||
if(1 == entry->len)
|
||||
{
|
||||
if(cur < len) buf[out++] = string[cur++];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cur < len) buf[out++] = (string[cur++] & mask1);
|
||||
if(cur < len) buf[out++] = (string[cur++] & mask2);
|
||||
}
|
||||
|
||||
}
|
||||
if(begin != len)
|
||||
{
|
||||
(void)PR_snprintf(flabel, sizeof(flabel), "f%d", lastFI);
|
||||
xms = fe_create_and_concatnate_XmString( xms, buf, out, flabel);
|
||||
}
|
||||
return xms;
|
||||
}
|
||||
|
||||
|
||||
/* fontIndex skip len */
|
||||
#define EUCCN_LATIN1 { 0, 0, 1 }
|
||||
@ -5198,6 +5341,61 @@ fe_LoadEUCCNFont(MWContext *context, char *familyName, int points,
|
||||
return (fe_Font) ret;
|
||||
}
|
||||
|
||||
static XmFontList
|
||||
fe_FontGroupGetFontList(int16 charset, fe_Font fontGroup, int numOfFonts)
|
||||
{
|
||||
fe_FontGroupFont *fonts;
|
||||
int i;
|
||||
char flabel[4];
|
||||
XmFontListEntry e;
|
||||
XmFontList fl;
|
||||
|
||||
if(FALSE == fe_AreFontsAvail(charset))
|
||||
return NULL;
|
||||
|
||||
XP_STRCPY(flabel, "f0");
|
||||
fonts = (fe_FontGroupFont *) fontGroup;
|
||||
|
||||
e = XmFontListEntryCreate(flabel,
|
||||
XmFONT_IS_FONT,
|
||||
(XFontStruct*) fonts[0].xFont);
|
||||
flabel[1] = flabel[1] + 1;
|
||||
XP_ASSERT(NULL != e);
|
||||
|
||||
fl = XmFontListAppendEntry(NULL, e);
|
||||
XP_ASSERT(NULL != fl);
|
||||
|
||||
XmFontListEntryFree(&e);
|
||||
|
||||
for(i=1; i < numOfFonts; i++, flabel[1] = flabel[1] + 1)
|
||||
{
|
||||
XFontStruct* f;
|
||||
|
||||
XP_ASSERT(fonts[i].xFont);
|
||||
|
||||
if(NULL != fonts[i].xFont)
|
||||
f = (XFontStruct*) fonts[i].xFont;
|
||||
else
|
||||
f = (XFontStruct*) fonts[0].xFont; /* somehow it will crash in Xt if we do not create it, fall back to latin1 */
|
||||
|
||||
e = XmFontListEntryCreate(flabel,
|
||||
XmFONT_IS_FONT,
|
||||
f);
|
||||
XP_ASSERT(NULL != e);
|
||||
|
||||
fl = XmFontListAppendEntry(fl, e);
|
||||
XP_ASSERT(NULL != fl);
|
||||
|
||||
XmFontListEntryFree(&e);
|
||||
}
|
||||
return fl;
|
||||
}
|
||||
|
||||
static XmString
|
||||
fe_EUCCNToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
return fe_EUCToXmString(charset, fontGroup, string, len, EUCCNTable);
|
||||
}
|
||||
|
||||
static void
|
||||
fe_EUCCNTextExtents(fe_Font font, char *string, int len, int *direction,
|
||||
@ -5593,7 +5791,11 @@ fe_LoadEUCJPFont(MWContext *context, char *familyName, int points,
|
||||
return (fe_Font) ret;
|
||||
}
|
||||
|
||||
|
||||
static XmString
|
||||
fe_EUCJPToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
return fe_EUCToXmString(charset, fontGroup, string, len, EUCJPTable);
|
||||
}
|
||||
static void
|
||||
fe_EUCJPTextExtents(fe_Font font, char *string, int len, int *direction,
|
||||
int *fontAscent, int *fontDescent, XCharStruct *overall)
|
||||
@ -5965,7 +6167,11 @@ fe_LoadEUCKRFont(MWContext *context, char *familyName, int points,
|
||||
return (fe_Font) ret;
|
||||
}
|
||||
|
||||
|
||||
static XmString
|
||||
fe_EUCKRToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
return fe_EUCToXmString(charset, fontGroup, string, len, EUCKRTable);
|
||||
}
|
||||
static void
|
||||
fe_EUCKRTextExtents(fe_Font font, char *string, int len, int *direction,
|
||||
int *fontAscent, int *fontDescent, XCharStruct *overall)
|
||||
@ -6361,6 +6567,12 @@ fe_LoadEUCTWFont(MWContext *context, char *familyName, int points,
|
||||
return (fe_Font) ret;
|
||||
}
|
||||
|
||||
static XmString
|
||||
fe_EUCTWToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
return fe_EUCToXmString(charset, fontGroup, string, len, EUCTWTable);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fe_EUCTWTextExtents(fe_Font font, char *string, int len, int *direction,
|
||||
@ -6720,6 +6932,11 @@ fe_LoadBIG5Font(MWContext *context, char *familyName, int points,
|
||||
return (fe_Font) ret;
|
||||
}
|
||||
|
||||
static XmString
|
||||
fe_BIG5ToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
return fe_EUCToXmString(charset, fontGroup, string, len, BIG5Table);
|
||||
}
|
||||
|
||||
static void
|
||||
fe_BIG5TextExtents(fe_Font font, char *string, int len, int *direction,
|
||||
@ -6875,6 +7092,21 @@ fe_LoadUnicodeFontByPixelSize(void *not_used, char *familyName, int pixelSize,
|
||||
return ufont;
|
||||
}
|
||||
|
||||
static XmFontList
|
||||
fe_UTF8GetFontList(int16 charset, fe_Font font, int numOfFonts)
|
||||
{
|
||||
fe_UnicodePseudoFont *ufont = (fe_UnicodePseudoFont *)font;
|
||||
XP_ASSERT( NULL != ufont);
|
||||
XP_ASSERT( NULL != ufont->xmfontlist);
|
||||
return XmFontListCopy(ufont->xmfontlist);
|
||||
}
|
||||
|
||||
static XmString fe_UTF8ToXmString(int16 charset, fe_Font fontGroup, char * string, int len)
|
||||
{
|
||||
XP_ASSERT(0);
|
||||
return NULL; /* to make compiler happen */
|
||||
}
|
||||
|
||||
void
|
||||
fe_freeUnicodePseudoFont(fe_Font font)
|
||||
{
|
||||
|
@ -345,6 +345,52 @@ do \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef NO_WEB_FONTS
|
||||
#define FE_NONEDIT_FONTLIST(charset, font, fontlist) \
|
||||
do \
|
||||
{ \
|
||||
fe_Font platform_font; \
|
||||
\
|
||||
fe_CharSetFuncs entry = \
|
||||
fe_CharSetFuncsArray[fe_CharSetInfoArray[(charset) & 0xff].info]; \
|
||||
\
|
||||
platform_font = ((fe_FontWrap *) font)->platform_font; \
|
||||
\
|
||||
(fontlist) = \
|
||||
(* (entry.nonEditGetFontList))(charset, platform_font, \
|
||||
(int)entry.numberOfFonts); \
|
||||
} while(0)
|
||||
#else
|
||||
#define FE_NONEDIT_FONTLIST(charset, font, fontlist) \
|
||||
do \
|
||||
{ \
|
||||
fe_CharSetFuncs entry = \
|
||||
fe_CharSetFuncsArray[fe_CharSetInfoArray[(charset) & 0xff].info]; \
|
||||
\
|
||||
(fontlist) = \
|
||||
(* (entry.nonEditGetFontList))( charset, font, \
|
||||
(int) entry.numberOfFonts); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_WEB_FONTS
|
||||
#define FE_NONEDIT_TO_XMSTRING(charset, font, string, len) \
|
||||
(*fe_CharSetFuncsArray[fe_CharSetInfoArray[(charset) & 0xff]. \
|
||||
info].nonEditToXmString)( (charset), \
|
||||
(fe_Font) (((fe_FontWrap *) font)->platform_font), \
|
||||
(string), \
|
||||
(len) \
|
||||
)
|
||||
#else
|
||||
#define FE_NONEDIT_TO_XMSTRING(charset, font, string, len) \
|
||||
(*fe_CharSetFuncsArray[fe_CharSetInfoArray[(charset) & 0xff]. \
|
||||
info].nonEditToXmString)((charset), \
|
||||
(fe_Font)(font), \
|
||||
(string), \
|
||||
(len) \
|
||||
)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* typedefs and structs
|
||||
@ -500,15 +546,19 @@ typedef void (*fe_DrawStringFunc)(Display *dpy, Drawable d, fe_Font font,
|
||||
GC gc, int x, int y, char *string, int len);
|
||||
typedef void (*fe_DrawImageStringFunc)(Display *dpy, Drawable d, fe_Font font,
|
||||
GC gc, GC gc2, int x, int y, char *string, int len);
|
||||
typedef XmFontList (*fe_GetFontList)(int16 charset, fe_Font font, int numOfFont);
|
||||
typedef XmString (*fe_ToXmString)(int16 charset, fe_Font font, char* string, int len );
|
||||
|
||||
typedef struct fe_CharSetFuncs
|
||||
{
|
||||
unsigned char numberOfFonts;
|
||||
fe_AreFontsAvailFunc areFontsAvail;
|
||||
fe_AreFontsAvailFunc areFontsAvail;
|
||||
fe_LoadFontFunc loadFont;
|
||||
fe_TextExtentsFunc textExtents;
|
||||
fe_DrawStringFunc drawString;
|
||||
fe_DrawImageStringFunc drawImageString;
|
||||
fe_DrawImageStringFunc drawImageString;
|
||||
fe_GetFontList nonEditGetFontList;
|
||||
fe_ToXmString nonEditToXmString;
|
||||
} fe_CharSetFuncs;
|
||||
|
||||
|
||||
|
328
cmd/xfe/forms.c
328
cmd/xfe/forms.c
@ -336,6 +336,184 @@ fe_font_list_metrics(MWContext *context, LO_FormElementStruct *form,
|
||||
FE_FONT_EXTENTS(text->charset, font, ascentp, descentp);
|
||||
}
|
||||
|
||||
static fe_Font fe_LoadFontForWidgetUnicodePseudoFont (MWContext *context,
|
||||
Widget parent,
|
||||
LO_TextAttr *text_attr,
|
||||
XmFontList *fontlist,
|
||||
XmFontType *type,
|
||||
int mask
|
||||
)
|
||||
{
|
||||
fe_Font fe_font;
|
||||
|
||||
fe_font = fe_LoadUnicodeFont(NULL, "", 0, text_attr->size, mask,
|
||||
0, 0, 0, XtDisplay(parent));
|
||||
|
||||
/*
|
||||
This looks very weired ,
|
||||
but it looks like this before I split the code
|
||||
*/
|
||||
|
||||
*fontlist = NULL;
|
||||
return fe_font;
|
||||
}
|
||||
|
||||
static fe_Font fe_LoadFontForWidgetLocale (MWContext *context,
|
||||
Widget parent,
|
||||
LO_TextAttr *text_attr,
|
||||
XmFontList *fontlist,
|
||||
XmFontType *type,
|
||||
int mask
|
||||
)
|
||||
{
|
||||
fe_Font fe_font;
|
||||
XmFontListEntry flentry;
|
||||
XmFontList locale_font_list = NULL;
|
||||
|
||||
fe_font = fe_GetFontOrFontSetFromFace(context, NULL,
|
||||
text_attr->font_face,
|
||||
text_attr->size,
|
||||
mask, type);
|
||||
XP_ASSERT(NULL != fe_font);
|
||||
if (!fe_font)
|
||||
return NULL;
|
||||
|
||||
flentry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, *type, fe_font);
|
||||
XP_ASSERT(NULL != flentry);
|
||||
if (!flentry)
|
||||
return NULL;
|
||||
|
||||
locale_font_list = XmFontListAppendEntry(NULL, flentry);
|
||||
|
||||
XP_ASSERT(NULL != locale_font_list);
|
||||
if (!locale_font_list)
|
||||
return NULL;
|
||||
|
||||
XmFontListEntryFree(&flentry);
|
||||
|
||||
*fontlist = locale_font_list;
|
||||
return fe_font;
|
||||
}
|
||||
|
||||
static void
|
||||
fe_FontlistAndXmStringForOptions( MWContext *context,
|
||||
LO_TextAttr *text_attr,
|
||||
LO_FormElementData *form_data,
|
||||
int nitems,
|
||||
XmString *xmstrings,
|
||||
XmFontList *fontlist)
|
||||
{
|
||||
Widget parent = CONTEXT_DATA(context)->drawing_area;
|
||||
XP_Bool use_UnicodePseudoFont = IS_UNICODE_CSID(text_attr->charset);
|
||||
fe_Font fe_font;
|
||||
XmFontType type = 0; /* keep purify happy */
|
||||
|
||||
if(use_UnicodePseudoFont)
|
||||
{
|
||||
fe_font = fe_LoadFontForWidgetUnicodePseudoFont(context, parent, text_attr, fontlist, &type,
|
||||
text_attr->fontmask);
|
||||
if(*fontlist)
|
||||
*fontlist = XmFontListCopy(*fontlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
fe_font = fe_LoadFontFromFace(
|
||||
context, text_attr,
|
||||
&text_attr->charset,
|
||||
text_attr->font_face,
|
||||
text_attr->size,
|
||||
text_attr->fontmask
|
||||
);
|
||||
FE_NONEDIT_FONTLIST(text_attr->charset, fe_font, *fontlist);
|
||||
}
|
||||
|
||||
if (xmstrings)
|
||||
{
|
||||
int i;
|
||||
for(i = 0 ; i < nitems; i++)
|
||||
{
|
||||
unsigned char* text = (unsigned char*)
|
||||
XP_FormSelectGetOption(form_data, i)->text_value;
|
||||
|
||||
if(NULL == text)
|
||||
text = (unsigned char*) "---\?\?\?---";
|
||||
|
||||
if(use_UnicodePseudoFont)
|
||||
{
|
||||
xmstrings[i] = fe_ConvertToXmString(
|
||||
text,
|
||||
text_attr->charset,
|
||||
fe_font,
|
||||
type,
|
||||
fontlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmstrings[i] = FE_NONEDIT_TO_XMSTRING(text_attr->charset,
|
||||
fe_font,
|
||||
text,
|
||||
XP_STRLEN(text)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void
|
||||
fe_FontlistAndXmStringForButton(MWContext *context,
|
||||
int32 form_type,
|
||||
char *string,
|
||||
LO_TextAttr *text_attr,
|
||||
XmString *xmstring,
|
||||
XmFontList *fontlist)
|
||||
{
|
||||
Widget parent = CONTEXT_DATA(context)->drawing_area;
|
||||
XP_Bool use_UnicodePseudoFont;
|
||||
fe_Font fe_font;
|
||||
XmFontType type = 0; /* keep purify happy */
|
||||
|
||||
use_UnicodePseudoFont = IS_UNICODE_CSID(text_attr->charset);
|
||||
|
||||
if (xmstring)
|
||||
*xmstring = NULL;
|
||||
|
||||
if( use_UnicodePseudoFont )
|
||||
{
|
||||
fe_font = fe_LoadFontForWidgetUnicodePseudoFont(context, parent,
|
||||
text_attr, fontlist, &type,
|
||||
text_attr->fontmask);
|
||||
|
||||
XP_ASSERT(NULL != fe_font);
|
||||
|
||||
if (string && xmstring)
|
||||
*xmstring = fe_ConvertToXmString((unsigned char*)string,
|
||||
text_attr->charset,
|
||||
fe_font,
|
||||
type,
|
||||
fontlist);
|
||||
if(*fontlist)
|
||||
*fontlist = XmFontListCopy(*fontlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
fe_font = fe_LoadFontFromFace(
|
||||
context, text_attr,
|
||||
&text_attr->charset,
|
||||
text_attr->font_face,
|
||||
text_attr->size,
|
||||
text_attr->fontmask
|
||||
);
|
||||
FE_NONEDIT_FONTLIST(text_attr->charset, fe_font, *fontlist);
|
||||
|
||||
if (string && xmstring)
|
||||
{
|
||||
*xmstring = FE_NONEDIT_TO_XMSTRING(text_attr->charset,
|
||||
fe_font,
|
||||
string,
|
||||
XP_STRLEN(string)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void
|
||||
fe_FontlistAndXmStringForFormElement(MWContext *context,
|
||||
int32 form_type,
|
||||
@ -348,10 +526,7 @@ fe_FontlistAndXmStringForFormElement(MWContext *context,
|
||||
XP_Bool use_UnicodePseudoFont;
|
||||
fe_Font fe_font;
|
||||
XmFontType type = 0; /* keep purify happy */
|
||||
XmFontListEntry flentry;
|
||||
int mask = text_attr->fontmask;
|
||||
XmFontList unicodePseudo_font_list = NULL;
|
||||
XmFontList locale_font_list = NULL;
|
||||
|
||||
use_UnicodePseudoFont = IS_UNICODE_CSID(text_attr->charset);
|
||||
|
||||
@ -375,37 +550,15 @@ fe_FontlistAndXmStringForFormElement(MWContext *context,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the font info
|
||||
*/
|
||||
if (use_UnicodePseudoFont)
|
||||
{
|
||||
fe_font = fe_LoadUnicodeFont(NULL, "", 0, text_attr->size, mask,
|
||||
0, 0, 0, XtDisplay(parent));
|
||||
|
||||
*fontlist = unicodePseudo_font_list;
|
||||
}
|
||||
else
|
||||
{
|
||||
fe_font = fe_GetFontOrFontSetFromFace(context, NULL,
|
||||
text_attr->font_face,
|
||||
text_attr->size,
|
||||
mask, &type);
|
||||
if (!fe_font)
|
||||
return;
|
||||
flentry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, type, fe_font);
|
||||
if (!flentry)
|
||||
return;
|
||||
locale_font_list = XmFontListAppendEntry(NULL, flentry);
|
||||
if (!locale_font_list)
|
||||
return;
|
||||
XmFontListEntryFree(&flentry);
|
||||
|
||||
if (xmstring)
|
||||
if (xmstring)
|
||||
*xmstring = NULL;
|
||||
|
||||
*fontlist = locale_font_list;
|
||||
}
|
||||
if(use_UnicodePseudoFont)
|
||||
fe_font = fe_LoadFontForWidgetUnicodePseudoFont(context, parent, text_attr, fontlist, &type, mask);
|
||||
else
|
||||
fe_font = fe_LoadFontForWidgetLocale(context, parent, text_attr, fontlist, &type, mask);
|
||||
|
||||
XP_ASSERT(NULL != fe_font);
|
||||
|
||||
if (string && xmstring)
|
||||
*xmstring = fe_ConvertToXmString((unsigned char*)string,
|
||||
@ -414,7 +567,6 @@ fe_FontlistAndXmStringForFormElement(MWContext *context,
|
||||
type,
|
||||
fontlist);
|
||||
}
|
||||
|
||||
static void
|
||||
set_form_colors(FEFormData *fed,
|
||||
LO_Color *lo_fg,
|
||||
@ -1398,7 +1550,7 @@ button_create_widget(FEFormData *fed,
|
||||
? "formResetButton"
|
||||
: "formButton"));
|
||||
|
||||
fe_FontlistAndXmStringForFormElement(context,
|
||||
fe_FontlistAndXmStringForButton(context,
|
||||
form_type,
|
||||
(char*)string,
|
||||
text_attr,
|
||||
@ -1489,6 +1641,8 @@ button_create_widget(FEFormData *fed,
|
||||
XmNactivateCallback, fe_button_form_cb, fed);
|
||||
break;
|
||||
}
|
||||
if (font_list)
|
||||
XmFontListFree(font_list);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1635,26 +1789,30 @@ select_create_widget(FEFormData *fed,
|
||||
}
|
||||
|
||||
for (i = 0; i < nitems; i++)
|
||||
{
|
||||
{
|
||||
lo_FormElementOptionData *d2 =
|
||||
XP_FormSelectGetOption(form_data, i);
|
||||
|
||||
fe_FontlistAndXmStringForFormElement(context,
|
||||
form_type,
|
||||
(d2->text_value
|
||||
? (char *) d2->text_value
|
||||
: "---\?\?\?---"),
|
||||
text_attr,
|
||||
&items[i],
|
||||
&font_list);
|
||||
|
||||
selected_p [i] = !!d2->def_selected;
|
||||
d2->selected = d2->def_selected;
|
||||
}
|
||||
}
|
||||
fe_FontlistAndXmStringForOptions(context,
|
||||
text_attr,
|
||||
form_data,
|
||||
nitems,
|
||||
items,
|
||||
&font_list);
|
||||
|
||||
ac = 0;
|
||||
/* #ifdef FORMS_ARE_FONTIFIED */
|
||||
XtSetArg (av [ac], XmNfontList, font_list); ac++;
|
||||
if(NULL != font_list)
|
||||
{
|
||||
XtSetArg (av [ac], XmNfontList, font_list); ac++;
|
||||
if (form_type == FORM_TYPE_SELECT_ONE)
|
||||
{
|
||||
/* Need to do this untill Ramiro implement fe_ComboBoxSetFontLists */
|
||||
XtSetArg (av [ac], XmNlistFontList, font_list); ac++;
|
||||
}
|
||||
}
|
||||
/* #endif */
|
||||
XtSetArg (av [ac], XmNspacing, 0); ac++;
|
||||
|
||||
@ -1704,22 +1862,29 @@ select_create_widget(FEFormData *fed,
|
||||
}
|
||||
else /* FORM_TYPE_SELECT_ONE */
|
||||
{
|
||||
/* we also need to set the fontlist explicitly on the label, for
|
||||
some reason... */
|
||||
Widget label;
|
||||
|
||||
fed->widget = DtCreateComboBox(parent, "list", av, ac);
|
||||
XtVaGetValues(fed->widget,
|
||||
XmNlist, &sel_fed->list_widget,
|
||||
NULL);
|
||||
|
||||
label = ((DtComboBoxWidget)fed->widget)->combo_box.label;
|
||||
/* we also need to set the fontlist explicitly on the label, for
|
||||
some reason... */
|
||||
if((NULL != font_list) &&
|
||||
(NULL != fed->widget)
|
||||
)
|
||||
{
|
||||
|
||||
ac = 0;
|
||||
/* #ifdef FORMS_ARE_FONTIFIED */
|
||||
XtSetArg (av [ac], XmNfontList, font_list); ac++;
|
||||
XtSetValues(label, av, ac);
|
||||
ac = 0;
|
||||
XtSetArg (av [ac], XmNfontList, font_list); ac++;
|
||||
|
||||
/* Still need to do this untill Ramiro implement fe_ComboBoxSetFontLists */
|
||||
if(NULL != ((DtComboBoxWidget)(fed->widget))->combo_box.label)
|
||||
XtSetValues((Widget)((DtComboBoxWidget)(fed->widget))->combo_box.label , av, ac);
|
||||
|
||||
}
|
||||
}
|
||||
if(NULL != font_list)
|
||||
XmFontListFree(font_list);
|
||||
|
||||
#ifdef FORMS_ARE_COLORED
|
||||
set_form_colors(fed, &text_attr->fg, &text_attr->bg);
|
||||
@ -1872,22 +2037,39 @@ select_change(FEFormData *fed,
|
||||
int32 form_type = XP_FormGetType(form_data);
|
||||
fe_Font fe_font;
|
||||
LO_TextAttr *text_attr;
|
||||
uint16 mask;
|
||||
XmString *new_items;
|
||||
char* new_selected_p;
|
||||
int nitems;
|
||||
int i;
|
||||
int16 charset;
|
||||
XmFontList unicodePseudo_font_list = NULL;
|
||||
XmFontList fontlist = NULL;
|
||||
XP_Bool item_selected = FALSE;
|
||||
XmFontType type;
|
||||
XP_Bool use_UnicodePseudoFont;
|
||||
MWContext *context = fed->context;
|
||||
|
||||
nitems = XP_FormSelectGetOptionsCount(form_data);
|
||||
text_attr = XP_GetFormTextAttr(form);
|
||||
mask = text_attr->fontmask;
|
||||
charset = text_attr->charset;
|
||||
use_UnicodePseudoFont = IS_UNICODE_CSID(text_attr->charset);
|
||||
|
||||
fe_font = fe_LoadUnicodeFont(NULL, "", 0, text_attr->size, mask, 0, 0, 0,
|
||||
XtDisplay(CONTEXT_WIDGET(fed->context)));
|
||||
if(use_UnicodePseudoFont)
|
||||
{
|
||||
Widget parent = CONTEXT_DATA(context)->drawing_area;
|
||||
fe_font = fe_LoadFontForWidgetUnicodePseudoFont(context, parent, text_attr, &fontlist, &type,
|
||||
text_attr->fontmask);
|
||||
if(fontlist)
|
||||
fontlist = XmFontListCopy(fontlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
fe_font = fe_LoadFontFromFace(
|
||||
context, text_attr,
|
||||
&text_attr->charset,
|
||||
text_attr->font_face,
|
||||
text_attr->size,
|
||||
text_attr->fontmask
|
||||
);
|
||||
FE_NONEDIT_FONTLIST(text_attr->charset, fe_font, fontlist);
|
||||
}
|
||||
|
||||
if (nitems > 0)
|
||||
{
|
||||
@ -1911,9 +2093,23 @@ select_change(FEFormData *fed,
|
||||
: " ")
|
||||
: "---\?\?\?---");
|
||||
|
||||
new_items [i] = fe_ConvertToXmString(str, charset, fe_font,
|
||||
XmFONT_IS_FONT,
|
||||
&unicodePseudo_font_list);
|
||||
if(use_UnicodePseudoFont)
|
||||
{
|
||||
new_items[i] = fe_ConvertToXmString(
|
||||
str,
|
||||
text_attr->charset,
|
||||
fe_font,
|
||||
type,
|
||||
fontlist);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_items[i] = FE_NONEDIT_TO_XMSTRING(text_attr->charset,
|
||||
fe_font,
|
||||
str,
|
||||
XP_STRLEN(str)
|
||||
);
|
||||
}
|
||||
new_selected_p [i] = !!XP_FormOptionGetSelected(option_data);
|
||||
|
||||
#ifdef DEBUG_username
|
||||
|
Loading…
Reference in New Issue
Block a user