diff options
Diffstat (limited to 'app/wlib/gtklib/tooltip.c')
-rw-r--r-- | app/wlib/gtklib/tooltip.c | 237 |
1 files changed, 121 insertions, 116 deletions
diff --git a/app/wlib/gtklib/tooltip.c b/app/wlib/gtklib/tooltip.c index cd12d0a..75c8870 100644 --- a/app/wlib/gtklib/tooltip.c +++ b/app/wlib/gtklib/tooltip.c @@ -17,7 +17,7 @@ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
@@ -54,11 +54,11 @@ static wBool_t balloonVisible = FALSE; /**
* Hide the currently displayed Balloon Help.
*/
-
+
void
wlibHelpHideBalloon()
{
- wControlSetBalloon( balloonB, 0, 0, NULL );
+ wControlSetBalloon( balloonB, 0, 0, NULL );
}
/**
@@ -70,7 +70,7 @@ wlibHelpHideBalloon() void wSetBalloonHelp( wBalloonHelp_t * bh )
{
- balloonHelpStrings = bh;
+ balloonHelpStrings = bh;
}
/**
@@ -82,7 +82,7 @@ void wSetBalloonHelp( wBalloonHelp_t * bh ) void wEnableBalloonHelp( int enable )
{
- enableBalloonHelp = enable;
+ enableBalloonHelp = enable;
}
/**
@@ -93,10 +93,10 @@ void wEnableBalloonHelp( int enable ) */
void wControlSetHelp(
- wControl_p b,
- const char * help )
+ wControl_p b,
+ const char * help )
{
- wControlSetBalloonText( b, help );
+ wControlSetBalloonText( b, help );
}
/**
@@ -107,13 +107,13 @@ void wControlSetHelp( */
void wControlSetBalloonText(
- wControl_p b,
- const char * label )
+ wControl_p b,
+ const char * label )
{
- assert(b->widget != NULL);
+ assert(b->widget != NULL);
- gtk_widget_set_tooltip_text( b->widget, label );
+ gtk_widget_set_tooltip_text( b->widget, label );
}
/**
@@ -128,93 +128,93 @@ void wControlSetBalloonText( * \return
*/
-void wControlSetBalloon( wControl_p b, wWinPix_t dx, wWinPix_t dy, const char * msg )
+void wControlSetBalloon( wControl_p b, wWinPix_t dx, wWinPix_t dy,
+ const char * msg )
{
- PangoLayout * layout;
-
- gint x, y;
- gint w, h;
- wWinPix_t xx, yy;
- const char * msgConverted;
- GtkRequisition size;
-
- /* return if there is nothing to do */
- if (balloonVisible && balloonB == b &&
- balloonDx == dx && balloonDy == dy && msg != NULL && !balloonMsg[0])
- if (strcmp(msg,balloonMsg)==0)
- return;
-
- /* hide the tooltip */
- if ( msg == NULL ) {
- if ( balloonF != NULL && balloonVisible) {
- gtk_widget_hide( balloonF );
- balloonVisible = FALSE;
- }
- balloonMsg[0] = '\0';
- return;
- }
- msgConverted = wlibConvertInput(msg);
-
- if ( balloonF == NULL ) {
+ gint x, y;
+ gint w, h;
+ wWinPix_t xx, yy;
+ const char * msgConverted;
+ GtkRequisition size;
+
+ /* return if there is nothing to do */
+ if (balloonVisible && balloonB == b &&
+ balloonDx == dx && balloonDy == dy && msg != NULL && !balloonMsg[0])
+ if (strcmp(msg,balloonMsg)==0) {
+ return;
+ }
+
+ /* hide the tooltip */
+ if ( msg == NULL ) {
+ if ( balloonF != NULL && balloonVisible) {
+ gtk_widget_hide( balloonF );
+ balloonVisible = FALSE;
+ }
+ balloonMsg[0] = '\0';
+ return;
+ }
+ msgConverted = wlibConvertInput(msg);
+
+ if ( balloonF == NULL ) {
//GtkWidget *alignment;
- GdkColor color;
- color.red = 0x00C5 * 65536/255;
- color.green = 0x006F * 65536/255;
- color.blue = 0x0078 * 65536/255;
-
- balloonF = gtk_window_new( GTK_WINDOW_POPUP );
- gtk_window_set_type_hint( GTK_WINDOW( balloonF), GDK_WINDOW_TYPE_HINT_TOOLTIP );
- gtk_window_set_decorated (GTK_WINDOW (balloonF), FALSE );
- gtk_window_set_resizable( GTK_WINDOW (balloonF), FALSE );
- gtk_window_set_accept_focus(GTK_WINDOW( balloonF), FALSE);
- gtk_widget_modify_bg(GTK_WIDGET(balloonF), GTK_STATE_NORMAL, &color);
-
+ GdkColor color;
+ color.red = 0x00C5 * 65536/255;
+ color.green = 0x006F * 65536/255;
+ color.blue = 0x0078 * 65536/255;
+
+ balloonF = gtk_window_new( GTK_WINDOW_POPUP );
+ gtk_window_set_type_hint( GTK_WINDOW( balloonF), GDK_WINDOW_TYPE_HINT_TOOLTIP );
+ gtk_window_set_decorated (GTK_WINDOW (balloonF), FALSE );
+ gtk_window_set_resizable( GTK_WINDOW (balloonF), FALSE );
+ gtk_window_set_accept_focus(GTK_WINDOW( balloonF), FALSE);
+ gtk_widget_modify_bg(GTK_WIDGET(balloonF), GTK_STATE_NORMAL, &color);
+
GtkWidget * alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_alignment_set_padding( GTK_ALIGNMENT(alignment), 6, 6, 6, 6 );
gtk_container_add (GTK_CONTAINER (balloonF), alignment);
-
+
gtk_widget_show (alignment);
-
- balloonPI = gtk_label_new(msgConverted);
- gtk_container_add( GTK_CONTAINER(alignment), balloonPI );
- gtk_widget_show_all( balloonPI );
- }
- gtk_label_set_text( GTK_LABEL(balloonPI), msgConverted );
-
- balloonDx = dx;
- balloonDy = dy;
- balloonB = b;
- snprintf(balloonMsg, sizeof(balloonMsg), "%s", msg);
- gtk_widget_get_requisition(balloonPI, &size );
- w = size.width;
- h = size.height;
-
- gtk_window_get_position( GTK_WINDOW(b->parent->gtkwin), &x, &y);
-
- x += b->realX + dx;
- y += b->realY + b->h - dy;
+
+ balloonPI = gtk_label_new(msgConverted);
+ gtk_container_add( GTK_CONTAINER(alignment), balloonPI );
+ gtk_widget_show_all( balloonPI );
+ }
+ gtk_label_set_text( GTK_LABEL(balloonPI), msgConverted );
+
+ balloonDx = dx;
+ balloonDy = dy;
+ balloonB = b;
+ snprintf(balloonMsg, sizeof(balloonMsg), "%s", msg);
+ gtk_widget_get_requisition(balloonPI, &size );
+ w = size.width;
+ h = size.height;
+
+ gtk_window_get_position( GTK_WINDOW(b->parent->gtkwin), &x, &y);
+
+ x += b->realX + dx;
+ y += b->realY + b->h - dy;
#ifdef __linux__
- y += 7; // balloon popup overlaps the control
+ y += 7; // balloon popup overlaps the control
#endif
- xx = gdk_screen_width();
- yy = gdk_screen_height();
- if ( x < 0 ) {
- x = 0;
- } else if ( x+w > xx ) {
- x = xx - w;
- }
- if ( y < 0 ) {
- y = 0;
- } else if ( y+h > yy ) {
- y = yy - h ;
- }
- gtk_window_move( GTK_WINDOW( balloonF ), x, y );
- gtk_widget_show_all( balloonF );
- gtk_widget_show( balloonPI );
-
- balloonVisible = TRUE;
+ xx = gdk_screen_width();
+ yy = gdk_screen_height();
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x+w > xx ) {
+ x = xx - w;
+ }
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y+h > yy ) {
+ y = yy - h ;
+ }
+ gtk_window_move( GTK_WINDOW( balloonF ), x, y );
+ gtk_widget_show_all( balloonF );
+ gtk_widget_show( balloonPI );
+
+ balloonVisible = TRUE;
}
/**
@@ -232,36 +232,41 @@ void wBalloonHelpUpdate( void ) */
void wlibAddHelpString(
- GtkWidget * widget,
- const char * helpStr )
+ GtkWidget * widget,
+ const char * helpStr )
{
- char *string;
- char *wAppName = wlibGetAppName();
- wBalloonHelp_t * bhp;
-
- if (helpStr==NULL || *helpStr==0)
- return;
- if ( balloonHelpStrings == NULL )
- return;
-
- // search for the helpStr, bhp points to the entry when found
- for ( bhp = balloonHelpStrings; bhp->name && strcmp(bhp->name,helpStr) != 0; bhp++ )
- ;
-
- if (listMissingHelpStrings && !bhp->name) {
- printf( "Missing Help String: %s\n", helpStr );
- return;
- }
-
- string = malloc( strlen(wAppName) + 5 + strlen(helpStr) + 1 );
- sprintf( string, "%sHelp/%s", wAppName, helpStr );
-
- if(bhp->value)
+ char *string;
+ char *wAppName = wlibGetAppName();
+ wBalloonHelp_t * bhp;
+
+ if (helpStr==NULL || *helpStr==0) {
+ return;
+ }
+ if ( balloonHelpStrings == NULL ) {
+ return;
+ }
+
+ // search for the helpStr, bhp points to the entry when found
+ for ( bhp = balloonHelpStrings; bhp->name
+ && strcmp(bhp->name,helpStr) != 0; bhp++ )
+ ;
+
+ if (listMissingHelpStrings && !bhp->name) {
+ printf( "Missing Help String: %s\n", helpStr );
+ return;
+ }
+
+ string = malloc( strlen(wAppName) + 5 + strlen(helpStr) + 1 );
+ sprintf( string, "%sHelp/%s", wAppName, helpStr );
+
+ if(bhp->value) {
gtk_widget_set_tooltip_text( widget, wlibConvertInput(_(bhp->value)) );
+ }
- g_object_set_data( G_OBJECT( widget ), HELPDATAKEY, string );
+ g_object_set_data( G_OBJECT( widget ), HELPDATAKEY, string );
- if (listHelpStrings)
- printf( "HELPSTR - %s\n", string );
+ if (listHelpStrings) {
+ printf( "HELPSTR - %s\n", string );
+ }
}
|