Status bar again
- From: "Billy N. Patton" <bpatton dal asp ti com>
- To: Gtk users <gtk-list gnome org>
- Subject: Status bar again
- Date: Thu, 7 Dec 2000 09:24:09 -0600 (CST)
I've tried what I think should work but nothing happens. Here is my code
and some comments where I think may be wrong.
#include "extern.h"
static gint motion_notify_event(GtkWidget*,GdkEventMotion*);
static gint context_id;
void canvas(void)
{
GtkWidget *mw
,*vbox
,*draw
,*status_bar
;
GtkStyle *style;
GdkColor newbg;
if (fcellp EQ NULL) return;
mw = gtk_window_new(GTK_WINDOW_DIALOG);
gtk_container_set_border_width(GTK_CONTAINER(mw), 5);
gtk_window_set_title (GTK_WINDOW (mw), focus_cell);
gtk_window_set_position(GTK_WINDOW (mw),GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (mw), "destroy",
(GtkSignalFunc) destroy, &mw);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
gtk_container_add(GTK_CONTAINER(mw), vbox);
gtk_widget_show(vbox);
draw = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(vbox), draw);
gtk_drawing_area_size(GTK_DRAWING_AREA(draw),400,200);
gtk_widget_show(draw);
newbg.red = 0x0;
newbg.green = 0x0;
newbg.blue = 0x0;
style = gtk_style_copy(gtk_widget_get_style(draw));
style->bg[GTK_STATE_NORMAL] = newbg;
gtk_widget_set_style(draw,style);
status_bar = gtk_statusbar_new();
gtk_container_add(GTK_CONTAINER(vbox), status_bar);
gtk_widget_set_usize(status_bar,400,30);
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar),"MyId");
/***
NOT SURE ABOUT THIS, Am I connecting the motion over the draw
to the status bar?
***/
gtk_signal_connect_object(GTK_OBJECT(status_bar)
,"motion_notify_event"
,(GtkSignalFunc) motion_notify_event
,GTK_OBJECT(draw));
gtk_widget_show(status_bar);
gtk_widget_show(mw);
}
static gint motion_notify_event( GtkWidget *widget,
GdkEventMotion *event )
{
int x, y;
GdkModifierType state;
gchar buffer[64];
if (event->is_hint)
gdk_window_get_pointer (event->window, &x, &y, &state);
else
{
x = event->x;
y = event->y;
state = event->state;
}
gtk_statusbar_pop(GTK_STATUSBAR(widget),context_id);
sprintf(buffer,"XY : %d,%d",x,y);
gtk_statusbar_push(GTK_STATUSBAR(widget),context_id,buffer);
return TRUE;
}
=========+=========+=========+=========+=========+=========+=========+
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methology Group
Dallas, Texas
214-480-4455
bpatton dal asp ti com
=========+=========+=========+=========+=========+=========+=========+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]