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
|
# include "appFrameConfig.h"
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <appDebugon.h>
# include "appFrame.h"
# include "appSystem.h"
# include <appGeoString.h>
# ifdef USE_GTK
void appMakeTextInRow( APP_WIDGET * pText,
APP_WIDGET row,
int column,
int colspan,
int textColumns,
int textEnabled )
{
APP_WIDGET text;
text= gtk_entry_new();
if ( textColumns > 0 )
{
GtkStyle * gs= gtk_widget_get_style( text );
GdkFont * gf;
# if GTK_MAJOR_VERSION < 2
gf= gs->font;
# else
gf= gtk_style_get_font( gs );
# endif
gtk_widget_set_usize( text, ( 55* textColumns*
( gf->ascent+ gf->descent ) )/ 100, -1 );
}
gtk_table_attach( GTK_TABLE( row ),
text,
column, column+ colspan,
0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
ROW_XPADDING_GTK, ROW_YPADDING_GTK );
gtk_widget_show( text );
gtk_entry_set_editable( GTK_ENTRY( text ), textEnabled != 0 );
*pText= text;
}
/************************************************************************/
/* */
/* Make a text widget that is contained in a column of widgets */
/* */
/************************************************************************/
void appMakeTextInColumn( APP_WIDGET * pText,
APP_WIDGET column,
int textColumns,
int textEnabled )
{
APP_WIDGET text;
if ( textColumns > 0 )
{ text= gtk_entry_new_with_max_length( textColumns ); }
else{ text= gtk_entry_new(); }
gtk_box_pack_start( GTK_BOX( column ), text, FALSE, TRUE, 0 );
gtk_entry_set_editable( GTK_ENTRY( text ), textEnabled != 0 );
gtk_widget_show( text );
*pText= text;
}
void appRefuseTextValue( APP_WIDGET text )
{
gtk_entry_select_region( GTK_ENTRY( text ), 0,
strlen( gtk_entry_get_text( GTK_ENTRY( text ) ) ) );
return;
}
/************************************************************************/
/* */
/* Insert an integer in a text widget. */
/* */
/************************************************************************/
void appStringToTextWidget( APP_WIDGET text,
const char * s )
{
gtk_entry_set_text( GTK_ENTRY( text ), s );
return;
}
/************************************************************************/
/* */
/* Turn a text widget on or off. */
/* */
/************************************************************************/
void appEnableText( APP_WIDGET text,
int enabled )
{
gtk_entry_set_editable( GTK_ENTRY( text ), enabled != 0 );
}
/************************************************************************/
/* */
/* 1) Retrieve strings from text widgets. */
/* 2) Free the result obtained in this way. */
/* */
/************************************************************************/
/* 1 */
char * appGetStringFromTextWidget( APP_WIDGET text )
{
return strdup( gtk_entry_get_text( GTK_ENTRY( text ) ) );
}
/* 2 */
void appFreeStringFromTextWidget( char * s )
{
free( s );
}
void appGuiSetTypingCallbackForText( APP_WIDGET text,
APP_TXTYPING_CALLBACK_T callBack,
void * through )
{
gtk_signal_connect( GTK_OBJECT( text ), "changed",
(GtkSignalFunc)callBack, through );
return;
}
void appGuiSetGotValueCallbackForText(
APP_WIDGET text,
APP_TXACTIVATE_CALLBACK_T callBack,
void * through )
{
gtk_signal_connect( GTK_OBJECT( text ), "activate",
(GtkSignalFunc)callBack, through );
return;
}
# endif
|