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 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
# include "appFrameConfig.h"
# include <stdlib.h>
# include <stdio.h>
# include "appFrame.h"
# include "appSystem.h"
# include <appGeoString.h>
# ifdef USE_MOTIF
# include <Xm/Label.h>
# include <appDebugon.h>
/************************************************************************/
/* */
/* Make a row with a label and a text widget. */
/* */
/************************************************************************/
void appMakeLabelInRow( APP_WIDGET * pLabel,
APP_WIDGET row,
int column,
int colspan,
const char * labelText )
{
Widget label;
XmString labelString;
Arg al[20];
int ac= 0;
labelString= XmStringCreateLocalized( (char *)labelText );
ac= 0;
XtSetArg( al[ac], XmNtopAttachment, XmATTACH_FORM ); ac++;
XtSetArg( al[ac], XmNtopOffset, 0 ); ac++;
XtSetArg( al[ac], XmNleftAttachment, XmATTACH_POSITION ); ac++;
XtSetArg( al[ac], XmNleftPosition, column ); ac++;
XtSetArg( al[ac], XmNrightAttachment, XmATTACH_POSITION ); ac++;
XtSetArg( al[ac], XmNrightPosition, column+ colspan ); ac++;
XtSetArg( al[ac], XmNrecomputeSize, True ); ac++;
XtSetArg( al[ac], XmNalignment, XmALIGNMENT_BEGINNING ); ac++;
XtSetArg( al[ac], XmNlabelString, labelString ); ac++;
XtSetArg( al[ac], XmNmarginTop, 6 ); ac++;
label= XmCreateLabel( row, WIDGET_NAME, al, ac );
XmStringFree( labelString );
XtManageChild( label );
*pLabel= label;
}
void appMakeLabelInColumn( APP_WIDGET * pLabel,
APP_WIDGET column,
const char * labelText )
{
Widget label;
XmString labelString;
Arg al[20];
int ac= 0;
labelString= XmStringCreateLocalized( (char *)labelText );
ac= 0;
XtSetArg( al[ac], XmNskipAdjust, True ); ac++;
XtSetArg( al[ac], XmNrecomputeSize, True ); ac++;
XtSetArg( al[ac], XmNalignment, XmALIGNMENT_BEGINNING ); ac++;
XtSetArg( al[ac], XmNlabelString, labelString ); ac++;
XtSetArg( al[ac], XmNallowResize, True ); ac++;
label= XmCreateLabel( column, WIDGET_NAME, al, ac );
XmStringFree( labelString );
XtManageChild( label );
appMotifTurnOfSashTraversal( column );
*pLabel= label; return;
}
void appGuiChangeLabelText( APP_WIDGET labelWidget,
const char * label )
{
XmString labelString;
labelString= XmStringCreateLocalized( (char *)label );
XtVaSetValues( labelWidget,
XmNlabelString, labelString,
NULL );
XmStringFree( labelString );
return;
}
/************************************************************************/
/* */
/* Get the font of a label widget. */
/* */
/************************************************************************/
APP_FONT * appGuiGetLabelFont( APP_WIDGET w )
{
APP_FONT * rval= (APP_FONT *)0;
XmFontList fontList= (XmFontList)0;
# if 1
XtVaGetValues( w, XmNfontList, &fontList,
NULL );
# else
/*# include <Xm/XmP.h>*/
fontList= _XmGetDefaultFontList( w, XmLABEL_FONTLIST );
# endif
if ( ! fontList )
{ XDEB(fontList); }
else{
XmFontContext context;
XmFontListEntry entry;
XmFontListInitFontContext( &context, fontList );
entry= XmFontListNextEntry( context );
if ( ! entry )
{ XDEB(entry); }
else{
XtPointer fontPtr;
XmFontType fontType;
fontPtr= XmFontListEntryGetFont( entry, &fontType );
if ( fontType == XmFONT_IS_FONT )
{ rval= (XFontStruct *)fontPtr; }
else{
int fontCount;
char ** fontNameList;
XFontStruct ** fontList;
fontCount = XFontsOfFontSet( (XFontSet)fontPtr,
&fontList, &fontNameList );
if ( fontCount == 0 )
{ LDEB(fontCount); }
else{ rval= fontList[0]; }
}
/* NO! Pointer into the belly of the font list.
XmFontListEntryFree( &entry );
*/
}
XmFontListFreeFontContext( context );
/* NO! Pointer into the belly of the label widget.
XmFontListFree( fontList );
*/
}
if ( ! rval )
{ XDEB(rval); }
return rval;
}
# endif
|