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 46 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/************************************************************************/
/* */
/* Manage a menu to contol the font encoding in a font selection tool. */
/* */
/************************************************************************/
# include <appEncodingMenu.h>
# include <appFrame.h>
# include <appDebugon.h>
/************************************************************************/
/* */
/* Adapt to a font, encoding combination. */
/* */
/************************************************************************/
void appEncodingMenuSetOptionmenu( AppEncodingMenu * aem,
const SupportedCharset * sc,
int enc )
{
int i;
if ( enc < 0 || enc >= ENCODINGps_COUNT )
{ LLDEB(enc,ENCODINGps_COUNT); }
else{
if ( aem->aemFontEncodingChosen != enc )
{
aem->aemFontEncodingChosen= enc;
appSetOptionmenu( &(aem->aemEncodingOptionmenu), enc );
}
}
for ( i= 0; i < ENCODINGps_COUNT; i++ )
{
appGuiEnableWidget( aem->aemFontEncodingOptions[i],
sc[i].scSupported != 0 );
}
return;
}
/************************************************************************/
/* */
/* Adapt to the encodings of a font family. */
/* */
/************************************************************************/
void appEncodingMenuAdaptToFamilyEncodings(
AppEncodingMenu * aem,
const AppFontFamily * aff )
{
int enc= -1;
enc= aff->affDefaultEncoding;
if ( aem->aemFontEncodingSet >= 0 &&
aem->aemFontEncodingSet < ENCODINGps_COUNT &&
aff->affSupportedCharsets[
aem->aemFontEncodingSet].scSupported )
{
enc= aem->aemFontEncodingSet;
}
if ( aem->aemFontEncodingChosen >= 0 &&
aem->aemFontEncodingChosen < ENCODINGps_COUNT &&
aff->affSupportedCharsets[
aem->aemFontEncodingChosen].scSupported )
{
enc= aem->aemFontEncodingChosen;
}
appEncodingMenuSetOptionmenu( aem, aff->affSupportedCharsets, enc );
return;
}
/************************************************************************/
/* */
/* Retrieve the encoding from an option menu option event. */
/* */
/************************************************************************/
int appEncodingMenuEncodingFromWidget( int * pEnc,
const AppEncodingMenu * aem,
APP_WIDGET w )
{
int enc;
for ( enc= 0; enc < ENCODINGps_COUNT; enc++ )
{
if ( w == aem->aemFontEncodingOptions[enc] )
{ break; }
}
if ( enc < 0 || enc >= ENCODINGps_COUNT )
{ LLDEB(enc,ENCODINGps_COUNT); return -1; }
*pEnc= enc; return 0;
}
/************************************************************************/
/* */
/* Fill the option menu of an encoding menu. */
/* */
/************************************************************************/
void appEncodingMenuFillOptionmenu( char ** opts,
APP_BUTTON_CALLBACK callBack,
void * through,
AppEncodingMenu * aem )
{
int i;
appEmptyOptionmenu( &(aem->aemEncodingOptionmenu) );
for ( i= 0; i < ENCODINGps_COUNT; i++ )
{
aem->aemFontEncodingOptions[i]= appAddItemToOptionmenu(
&(aem->aemEncodingOptionmenu),
opts[i], callBack, through );
}
appSetOptionmenu( &(aem->aemEncodingOptionmenu), 0 );
aem->aemFontEncodingSet= 0;
aem->aemFontEncodingChosen= 0;
appOptionmenuRefreshWidth( &(aem->aemEncodingOptionmenu) );
return;
}
/************************************************************************/
/* */
/* Retrieve the textual representation of the encoding names. */
/* */
/************************************************************************/
void appEncodingMenuGetOptionTexts( char ** opts,
EditApplication * ea )
{
int i;
AppConfigurableResource acr[ENCODINGps_COUNT];
AppConfigurableResource * acri;
const FontCharset * fc;
fc= PS_Encodings;
acri= acr;
for ( i= 0; i < ENCODINGps_COUNT; fc++, acri++, i++ )
{
APP_SET_RESOURCE( acri, fc->fcId,
/*
offsetof(AppSymbolPickerResources,asprEncodings[i]),
*/
i* sizeof(char *),
fc->fcLabel );
}
appGuiGetResourceValues( ea, opts, acr, ENCODINGps_COUNT );
return;
}
|