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
|
/************************************************************************/
/* */
/* 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 appEncodingMenuSetEncoding( AppEncodingMenu * aem,
const DocumentFontFamily * dff,
int enc )
{
int i;
if ( enc < 0 || enc >= ENCODINGps_COUNT )
{ appEncodingMenuUnsetEncoding( aem ); }
else{
if ( aem->aemFontEncoding != enc )
{
aem->aemFontEncoding= enc;
appSetOptionmenu( &(aem->aemEncodingOptionmenu), enc );
}
}
for ( i= 0; i < ENCODINGps_COUNT; i++ )
{
appGuiEnableWidget( aem->aemFontEncodingOptions[i],
dff->dffFontForEncoding[i] >= 0 );
}
return;
}
void appEncodingMenuSetDocEncoding( AppEncodingMenu * aem,
const int * fontForEncoding,
int enc )
{
int i;
if ( enc < 0 || enc >= ENCODINGps_COUNT )
{ LLDEB(enc,ENCODINGps_COUNT); }
else{
if ( fontForEncoding[enc] < 0 )
{ LLDEB(enc,fontForEncoding[enc]); }
if ( aem->aemFontEncoding != enc )
{
aem->aemFontEncoding= enc;
appSetOptionmenu( &(aem->aemEncodingOptionmenu), enc );
}
}
for ( i= 0; i < ENCODINGps_COUNT; i++ )
{
appGuiEnableWidget( aem->aemFontEncodingOptions[i],
fontForEncoding[i] >= 0 );
}
return;
}
void appEncodingMenuUnsetEncoding( AppEncodingMenu * aem )
{
aem->aemFontEncoding= -1;
appSetOptionmenu( &(aem->aemEncodingOptionmenu), -1 );
return;
}
/************************************************************************/
/* */
/* Adapt to the encodings of a font family. */
/* */
/************************************************************************/
void appEncodingMenuAdaptToFamilyEncodings(
AppEncodingMenu * aem,
const DocumentFontFamily * dff )
{
int enc= -1;
if ( aem->aemFontEncoding >= 0 &&
aem->aemFontEncoding < ENCODINGps_COUNT &&
dff->dffFontForEncoding[aem->aemFontEncoding] >= 0 )
{ enc= aem->aemFontEncoding; }
appEncodingMenuSetEncoding( aem, dff, enc );
return;
}
/************************************************************************/
/* */
/* Fill the option menu of an encoding menu. */
/* */
/************************************************************************/
void appEncodingMenuFillOptionmenu( char * const * opts,
APP_OITEM_CALLBACK_T 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->aemFontEncoding= 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, i* sizeof(char *), fc->fcLabel );
}
appGuiGetResourceValues( ea, opts, acr, ENCODINGps_COUNT );
return;
}
|