Re: ruler doesn't work well with myline.c
- From: Gustavo Carneiro <gjc inescporto pt>
- To: Donggyoo Lee <doogie78 hanmir com>
- Cc: GTK+ App Devel Mail List <gtk-app-devel-list gnome org>
- Subject: Re: ruler doesn't work well with myline.c
- Date: 23 May 2002 15:54:08 +0100
On Mon, 2002-05-20 at 15:48, Donggyoo Lee wrote:
Hello. This is GTK+ beginner speaking.
I add myline.c to ruler.c. example source called ruler.c works well.
But, ruler on ruler_line.c doesn't work well. ruler Widget don't move
dynamically.
I don't know what is problum. I'm very stupid.
Please, tell me what is problum on ruler_line.c.
I think your main problem is your english. :) No offense intended!
Your program compiles and runs. I see no problem. What do you mean by
"ruler Widget don't move dynamically"? Because I see the rulers
stretching to adjust to the size of the window. Is there anything else
you wanted to do?
Thank you,
Donggyoo Lee
--
It is understood on the middle which you proceed, and appreciated on the
middle which you execute. -- Moolmoolja (1900 to 1994 A.D.)
undergraduate Computer Engineering major, Korea Maritime Univ.
Fingerprint: 46B3 D652 7ADA A68D 482C DB63 60EB 5CDF 14BF 16C8 pub 0x14BF16C8
Kongzi (551 to 479 B.C)
----
#include <gtk/gtk.h>
#define EVENT_METHOD(i, x) GTK_WIDGET_GET_CLASS(i)->x
#define XSIZE 600
#define YSIZE 400
/* This routine gets control when the close button is clicked */
gint close_application( GtkWidget *widget,
GdkEvent *event,
gpointer data )
{
gtk_main_quit ();
return FALSE;
}
/* Redraw the screen from the backing pixmap */
static gint
expose_event (GtkWidget *widget, GdkEventExpose *event)
{
gdk_draw_line(widget->window, widget->style->black_gc, 0, 0, 300, 300);
return FALSE;
}
/* The main routine */
int main( int argc,
char *argv[] ) {
GtkWidget *window, *table, *area, *hrule, *vrule;
/* Initialize GTK and create the main window */
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (close_application), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/* Create a table for placing the ruler and the drawing area */
table = gtk_table_new (3, 2, FALSE);
gtk_container_add (GTK_CONTAINER (window), table);
area = gtk_drawing_area_new ();
gtk_signal_connect (GTK_OBJECT (area), "expose_event",
GTK_SIGNAL_FUNC (expose_event), NULL);
gtk_widget_set_size_request (GTK_WIDGET (area), XSIZE, YSIZE);
gtk_table_attach (GTK_TABLE (table), area, 1, 2, 1, 2,
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_set_events (area, GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
/* The horizontal ruler goes on top. As the mouse moves across the
* drawing area, a motion_notify_event is passed to the
* appropriate event handler for the ruler. */
hrule = gtk_hruler_new ();
gtk_ruler_set_metric (GTK_RULER (hrule), GTK_PIXELS);
gtk_ruler_set_range (GTK_RULER (hrule), 7, 13, 0, 20);
g_signal_connect_swapped (G_OBJECT (area), "motion_notify_event",
G_CALLBACK (EVENT_METHOD (hrule, motion_notify_event)),
hrule);
gtk_table_attach (GTK_TABLE (table), hrule, 1, 2, 0, 1,
GTK_EXPAND|GTK_SHRINK|GTK_FILL, GTK_FILL, 0, 0);
/* The vertical ruler goes on the left. As the mouse moves across
* the drawing area, a motion_notify_event is passed to the
* appropriate event handler for the ruler. */
vrule = gtk_vruler_new ();
gtk_ruler_set_metric (GTK_RULER (vrule), GTK_PIXELS);
gtk_ruler_set_range (GTK_RULER (vrule), 0, YSIZE, 10, YSIZE );
g_signal_connect_swapped (G_OBJECT (area), "motion_notify_event",
G_CALLBACK (EVENT_METHOD (vrule, motion_notify_event)),
vrule);
gtk_table_attach (GTK_TABLE (table), vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0);
/* Now show everything */
gtk_widget_show (area);
gtk_widget_set_events (area, GDK_EXPOSURE_MASK);
gtk_widget_show (hrule);
gtk_widget_show (vrule);
gtk_widget_show (table);
gtk_widget_show (window);
gtk_main ();
return 0;
}
--
Gustavo João Alves Marques Carneiro
<gjc inescporto pt> <gustavo users sourceforge net>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]