/* 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 (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_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 (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 (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_show (hrule); gtk_widget_show (vrule); gtk_widget_show (table); gtk_widget_show (window); gtk_main (); return 0; }
/* main ルーチン */ int main( int argc, char *argv[] ) { GtkWidget *window, *table, *area, *hrule, *vrule; /* gtk を初期化、メインウィンドウを作成する */ gtk_init( &argc, &argv ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( close_application ), NULL); gtk_container_border_width (GTK_CONTAINER (window), 10); /* ルーラとドローイングエリアを配置するテーブルを作成 */ table = gtk_table_new( 3, 2, FALSE ); gtk_container_add( GTK_CONTAINER(window), table ); area = gtk_drawing_area_new(); gtk_drawing_area_size( (GtkDrawingArea *)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 ); /* 水平ルーラは上に置かれる。マウスがドローイングエリアを横切って * 移動すると、motion_notify_event がこのルーラの対応するイベント * ハンドラに渡される。*/ hrule = gtk_hruler_new(); gtk_ruler_set_metric( GTK_RULER(hrule), GTK_PIXELS ); gtk_ruler_set_range( GTK_RULER(hrule), 7, 13, 0, 20 ); gtk_signal_connect_object( GTK_OBJECT(area), "motion_notify_event", (GtkSignalFunc)EVENT_METHOD(hrule, motion_notify_event), GTK_OBJECT(hrule) ); /* GTK_WIDGET_CLASS(GTK_OBJECT(hrule)->klass)->motion_notify_event, */ gtk_table_attach( GTK_TABLE(table), hrule, 1, 2, 0, 1, GTK_EXPAND|GTK_SHRINK|GTK_FILL, GTK_FILL, 0, 0 ); /* 垂直ルーラは左に置かれる。マウスがドローイングエリアを横切って * 移動すると、motion_notify_event がこのルーラの対応するイベント * ハンドラに渡される。*/ vrule = gtk_vruler_new(); gtk_ruler_set_metric( GTK_RULER(vrule), GTK_PIXELS ); gtk_ruler_set_range( GTK_RULER(vrule), 0, YSIZE, 10, YSIZE ); gtk_signal_connect_object( GTK_OBJECT(area), "motion_notify_event", (GtkSignalFunc) GTK_WIDGET_CLASS(GTK_OBJECT(vrule)->klass)->motion_notify_event, GTK_OBJECT(vrule) ); gtk_table_attach( GTK_TABLE(table), vrule, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0 ); /* では全てを表示しよう */ gtk_widget_show( area ); gtk_widget_show( hrule ); gtk_widget_show( vrule ); gtk_widget_show( table ); gtk_widget_show( window ); gtk_main(); return 0; }
void canvas(link q) { GtkWidget *window, *draw_area, *table, *tool_bar; GtkWidget *export, *save, *zoom_in, *zoom_out, *restore; gchar stmp[MAXLEN] = "Node "; strc *r; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (GTK_WIDGET(window), 620, 480); gtk_window_set_title (GTK_WINDOW(window), strcat(stmp, p->nodename[q->i])); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_transient_for(GTK_WINDOW (window), GTK_WINDOW (main_window)); gtk_window_set_destroy_with_parent(GTK_WINDOW (window), TRUE); table = gtk_table_new(4, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 0); gtk_table_set_col_spacings(GTK_TABLE(table), 0); gtk_container_add(GTK_CONTAINER(window), table); draw_area = gtk_drawing_area_new(); gtk_widget_set_size_request (GTK_WIDGET(draw_area), 400, 400); gtk_signal_connect(GTK_OBJECT(draw_area), "expose_event", G_CALLBACK(expose_event), q); gtk_signal_connect (GTK_OBJECT(window), "destroy", G_CALLBACK(child_window_quit), NULL); gtk_widget_set_events(draw_area, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); hruler[q->i] = gtk_hruler_new (); g_signal_connect_swapped(G_OBJECT (draw_area), "motion_notify_event", G_CALLBACK (EVENT_METHOD (hruler[q->i], motion_notify_event)), G_OBJECT (hruler[q->i])); vruler[q->i] = gtk_vruler_new (); g_signal_connect_swapped(G_OBJECT (draw_area), "motion_notify_event", G_CALLBACK (EVENT_METHOD (vruler[q->i], motion_notify_event)), G_OBJECT (vruler[q->i])); g_signal_connect(G_OBJECT (draw_area), "motion_notify_event", G_CALLBACK (put_status), q); tool_bar = gtk_toolbar_new(); gtk_toolbar_set_orientation (GTK_TOOLBAR (tool_bar), GTK_ORIENTATION_HORIZONTAL); gtk_toolbar_set_style (GTK_TOOLBAR (tool_bar), GTK_TOOLBAR_BOTH); r = malloc(sizeof(strc)); r->widget = draw_area; r->p = q; status_bar[q->i] = gtk_statusbar_new (); export = gtk_toolbar_append_item(GTK_TOOLBAR(tool_bar),"Export",
int clip_GTK_VRULERNEW(ClipMachine * cm) { ClipVar * cv = _clip_spar(cm, 1); GtkWidget *wid = NULL; C_widget *cwid; CHECKOPT(1,MAP_t); wid = gtk_vruler_new(); if (!wid) goto err; cwid = _register_widget(cm, wid, cv); _clip_mclone(cm,RETPTR(cm),&cwid->obj); return 0; err: return 1; }
void AP_UnixLeftRuler::setView(AV_View * pView) { AP_LeftRuler::setView(pView); UT_ASSERT(gtk_widget_get_realized(m_wLeftRuler)); m_pG->setZoomPercentage(pView->getGraphics()->getZoomPercentage()); #if GTK_CHECK_VERSION(3,0,0) GtkWidget * w = gtk_label_new(""); ((GR_UnixCairoGraphics*)m_pG)->init3dColors(w); gtk_widget_destroy(w); #else GtkWidget * ruler = gtk_vruler_new (); ((GR_UnixCairoGraphics*)m_pG)->init3dColors(get_ensured_style(ruler)); #endif }
void AP_UnixLeftRuler::setView(AV_View * pView) { AP_LeftRuler::setView(pView); // We really should allocate m_pG in createWidget(), but // unfortunately, the actual window (m_wLeftRuler->window) // is not created until the frame's top-level window is // shown. DELETEP(m_pG); GR_UnixCairoAllocInfo ai(m_wLeftRuler->window); m_pG = XAP_App::getApp()->newGraphics(ai); UT_ASSERT(m_pG); m_pG->setZoomPercentage(pView->getGraphics()->getZoomPercentage()); GtkWidget * ruler = gtk_vruler_new (); ((GR_UnixCairoGraphics*)m_pG)->init3dColors(get_ensured_style (ruler)); }
int clip_GTK_VRULERNEW(ClipMachine * ClipMachineMemory) { ClipVar *cv = _clip_spar(ClipMachineMemory, 1); GtkWidget *wid = NULL; C_widget *cwid; CHECKOPT(1, MAP_type_of_ClipVarType); wid = gtk_vruler_new(); if (!wid) goto err; cwid = _register_widget(ClipMachineMemory, wid, cv); _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cwid->obj); return 0; err: return 1; }
static VALUE vruler_initialize(VALUE self) { RBGTK_INITIALIZE(self, gtk_vruler_new()); return Qnil; }
GtkWidget* create_wspec (void) { GtkWidget *wspec; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *label1; GtkWidget *specfreqpointer; GtkWidget *label2; GtkWidget *specfreqmark; GtkWidget *label3; GtkWidget *specfreqspace; GtkWidget *frame1; GtkWidget *hbox2; GSList *hbox2_group = NULL; GtkWidget *shift170; GtkWidget *shift200; GtkWidget *shift425; GtkWidget *shift800; GtkWidget *shiftother; GtkWidget *frame4; GtkWidget *table9; GtkWidget *spec; GtkWidget *hruler1; GtkWidget *squelch_vruler; GtkAccelGroup *spec_accels; wspec = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_name (wspec, "wspec"); gtk_object_set_data (GTK_OBJECT (wspec), "wspec", wspec); gtk_window_set_title (GTK_WINDOW (wspec), _("Frequency Spectrum")); gtk_window_set_policy (GTK_WINDOW (wspec), FALSE, FALSE, FALSE); gtk_window_set_wmclass (GTK_WINDOW (wspec), "hfterm", "hfterm"); spec_accels = gtk_accel_group_new (); gtk_accel_group_attach(spec_accels, GTK_OBJECT(wspec)); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_set_name (vbox1, "vbox1"); gtk_widget_ref (vbox1); gtk_object_set_data_full (GTK_OBJECT (wspec), "vbox1", vbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (wspec), vbox1); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_set_name (hbox1, "hbox1"); gtk_widget_ref (hbox1); gtk_object_set_data_full (GTK_OBJECT (wspec), "hbox1", hbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 3); gtk_container_set_border_width (GTK_CONTAINER (hbox1), 1); label1 = gtk_label_new (_("Pointer")); gtk_widget_set_name (label1, "label1"); gtk_widget_ref (label1); gtk_object_set_data_full (GTK_OBJECT (wspec), "label1", label1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); specfreqpointer = gtk_entry_new (); gtk_widget_set_name (specfreqpointer, "specfreqpointer"); gtk_widget_ref (specfreqpointer); gtk_object_set_data_full (GTK_OBJECT (wspec), "specfreqpointer", specfreqpointer, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (specfreqpointer); gtk_box_pack_start (GTK_BOX (hbox1), specfreqpointer, FALSE, TRUE, 4); gtk_widget_set_usize (specfreqpointer, 60, -2); GTK_WIDGET_UNSET_FLAGS (specfreqpointer, GTK_CAN_FOCUS); gtk_entry_set_editable (GTK_ENTRY (specfreqpointer), FALSE); label2 = gtk_label_new (_("Mark")); gtk_widget_set_name (label2, "label2"); gtk_widget_ref (label2); gtk_object_set_data_full (GTK_OBJECT (wspec), "label2", label2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label2); gtk_box_pack_start (GTK_BOX (hbox1), label2, FALSE, FALSE, 0); specfreqmark = gtk_entry_new (); gtk_widget_set_name (specfreqmark, "specfreqmark"); gtk_widget_ref (specfreqmark); gtk_object_set_data_full (GTK_OBJECT (wspec), "specfreqmark", specfreqmark, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (specfreqmark); gtk_box_pack_start (GTK_BOX (hbox1), specfreqmark, FALSE, TRUE, 4); gtk_widget_set_usize (specfreqmark, 60, -2); GTK_WIDGET_UNSET_FLAGS (specfreqmark, GTK_CAN_FOCUS); gtk_entry_set_editable (GTK_ENTRY (specfreqmark), FALSE); label3 = gtk_label_new (_("Space")); gtk_widget_set_name (label3, "label3"); gtk_widget_ref (label3); gtk_object_set_data_full (GTK_OBJECT (wspec), "label3", label3, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label3); gtk_box_pack_start (GTK_BOX (hbox1), label3, FALSE, FALSE, 0); specfreqspace = gtk_entry_new (); gtk_widget_set_name (specfreqspace, "specfreqspace"); gtk_widget_ref (specfreqspace); gtk_object_set_data_full (GTK_OBJECT (wspec), "specfreqspace", specfreqspace, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (specfreqspace); gtk_box_pack_start (GTK_BOX (hbox1), specfreqspace, FALSE, TRUE, 4); gtk_widget_set_usize (specfreqspace, 60, -2); GTK_WIDGET_UNSET_FLAGS (specfreqspace, GTK_CAN_FOCUS); gtk_entry_set_editable (GTK_ENTRY (specfreqspace), FALSE); frame1 = gtk_frame_new (_("Shift")); gtk_widget_set_name (frame1, "frame1"); gtk_widget_ref (frame1); gtk_object_set_data_full (GTK_OBJECT (wspec), "frame1", frame1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (frame1); gtk_box_pack_end (GTK_BOX (hbox1), frame1, FALSE, TRUE, 0); hbox2 = gtk_hbox_new (FALSE, 0); gtk_widget_set_name (hbox2, "hbox2"); gtk_widget_ref (hbox2); gtk_object_set_data_full (GTK_OBJECT (wspec), "hbox2", hbox2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hbox2); gtk_container_add (GTK_CONTAINER (frame1), hbox2); shift170 = gtk_radio_button_new_with_label (hbox2_group, _("170")); hbox2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shift170)); gtk_widget_set_name (shift170, "shift170"); gtk_widget_ref (shift170); gtk_object_set_data_full (GTK_OBJECT (wspec), "shift170", shift170, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (shift170); gtk_box_pack_start (GTK_BOX (hbox2), shift170, FALSE, FALSE, 0); shift200 = gtk_radio_button_new_with_label (hbox2_group, _("200")); hbox2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shift200)); gtk_widget_set_name (shift200, "shift200"); gtk_widget_ref (shift200); gtk_object_set_data_full (GTK_OBJECT (wspec), "shift200", shift200, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (shift200); gtk_box_pack_start (GTK_BOX (hbox2), shift200, FALSE, FALSE, 0); shift425 = gtk_radio_button_new_with_label (hbox2_group, _("425")); hbox2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shift425)); gtk_widget_set_name (shift425, "shift425"); gtk_widget_ref (shift425); gtk_object_set_data_full (GTK_OBJECT (wspec), "shift425", shift425, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (shift425); gtk_box_pack_start (GTK_BOX (hbox2), shift425, FALSE, FALSE, 0); shift800 = gtk_radio_button_new_with_label (hbox2_group, _("800")); hbox2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shift800)); gtk_widget_set_name (shift800, "shift800"); gtk_widget_ref (shift800); gtk_object_set_data_full (GTK_OBJECT (wspec), "shift800", shift800, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (shift800); gtk_box_pack_start (GTK_BOX (hbox2), shift800, FALSE, FALSE, 0); shiftother = gtk_radio_button_new_with_label (hbox2_group, _("other")); hbox2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shiftother)); gtk_widget_set_name (shiftother, "shiftother"); gtk_widget_ref (shiftother); gtk_object_set_data_full (GTK_OBJECT (wspec), "shiftother", shiftother, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (shiftother); gtk_box_pack_start (GTK_BOX (hbox2), shiftother, FALSE, FALSE, 0); frame4 = gtk_frame_new (_("Spectrum")); gtk_widget_set_name (frame4, "frame4"); gtk_widget_ref (frame4); gtk_object_set_data_full (GTK_OBJECT (wspec), "frame4", frame4, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (frame4); gtk_box_pack_start (GTK_BOX (vbox1), frame4, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame4), 1); table9 = gtk_table_new (2, 2, FALSE); gtk_widget_set_name (table9, "table9"); gtk_widget_ref (table9); gtk_object_set_data_full (GTK_OBJECT (wspec), "table9", table9, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table9); gtk_container_add (GTK_CONTAINER (frame4), table9); spec = spectrum_new ("spec", NULL, NULL, 0, 0); gtk_widget_set_name (spec, "spec"); gtk_widget_ref (spec); gtk_object_set_data_full (GTK_OBJECT (wspec), "spec", spec, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (spec); gtk_table_attach (GTK_TABLE (table9), spec, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_widget_set_usize (spec, 512, 384); GTK_WIDGET_SET_FLAGS (spec, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (spec, GTK_CAN_DEFAULT); gtk_widget_set_events (spec, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); hruler1 = gtk_hruler_new (); gtk_widget_set_name (hruler1, "hruler1"); gtk_widget_ref (hruler1); gtk_object_set_data_full (GTK_OBJECT (wspec), "hruler1", hruler1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hruler1); gtk_table_attach (GTK_TABLE (table9), hruler1, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_ruler_set_range (GTK_RULER (hruler1), 0, 4000, 5.91797, 10); squelch_vruler = gtk_vruler_new (); gtk_widget_set_name (squelch_vruler, "squelch_vruler"); gtk_widget_ref (squelch_vruler); gtk_object_set_data_full (GTK_OBJECT (wspec), "squelch_vruler", squelch_vruler, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (squelch_vruler); gtk_table_attach (GTK_TABLE (table9), squelch_vruler, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_ruler_set_range (GTK_RULER (squelch_vruler), 0, 10, 4.24479, 10); gtk_signal_connect (GTK_OBJECT (wspec), "delete_event", GTK_SIGNAL_FUNC (on_wspec_delete_event), NULL); gtk_widget_add_accelerator(wspec, "hide", spec_accels, GDK_f, GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); gtk_widget_add_accelerator(wspec, "hide", spec_accels, GDK_Escape, 0, GTK_ACCEL_VISIBLE); gtk_signal_connect (GTK_OBJECT (spec), "button_press_event", GTK_SIGNAL_FUNC (on_spec_button_press_event), NULL); gtk_signal_connect (GTK_OBJECT (spec), "motion_notify_event", GTK_SIGNAL_FUNC (on_spec_motion_event), NULL); return wspec; }
void create_display_shell(DDisplay *ddisp, int width, int height, char *title) { GtkWidget *table; GtkWidget *status_hbox; int s_width, s_height; s_width = gdk_screen_width (); s_height = gdk_screen_height (); if (width > s_width) width = s_width; if (height > s_height) width = s_width; /* The adjustment datums */ ddisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width-1)); ddisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height-1)); /* The toplevel shell */ ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (ddisp->shell), title); gtk_window_set_wmclass (GTK_WINDOW (ddisp->shell), "diagram_window", "Dia"); gtk_window_set_policy (GTK_WINDOW (ddisp->shell), TRUE, TRUE, TRUE); gtk_object_set_user_data (GTK_OBJECT (ddisp->shell), (gpointer) ddisp); gtk_widget_set_events (ddisp->shell, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_FOCUS_CHANGE_MASK); /* GDK_ALL_EVENTS_MASK */ gtk_signal_connect (GTK_OBJECT (ddisp->shell), "delete_event", GTK_SIGNAL_FUNC (ddisplay_delete), ddisp); gtk_signal_connect (GTK_OBJECT (ddisp->shell), "destroy", GTK_SIGNAL_FUNC (ddisplay_destroy), ddisp); /* the table containing all widgets */ table = gtk_table_new (4, 3, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2); gtk_container_set_border_width (GTK_CONTAINER (table), 2); gtk_container_add (GTK_CONTAINER (ddisp->shell), table); /* scrollbars, rulers, canvas, menu popup button */ ddisp->origin = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT); ddisp->hrule = gtk_hruler_new (); gtk_signal_connect_object (GTK_OBJECT (ddisp->shell), "motion_notify_event", (GtkSignalFunc) GTK_WIDGET_CLASS (GTK_OBJECT (ddisp->hrule)->klass)->motion_notify_event, GTK_OBJECT (ddisp->hrule)); ddisp->vrule = gtk_vruler_new (); gtk_signal_connect_object (GTK_OBJECT (ddisp->shell), "motion_notify_event", (GtkSignalFunc) GTK_WIDGET_CLASS (GTK_OBJECT (ddisp->vrule)->klass)->motion_notify_event, GTK_OBJECT (ddisp->vrule)); ddisp->hsb = gtk_hscrollbar_new (ddisp->hsbdata); GTK_WIDGET_UNSET_FLAGS (ddisp->hsb, GTK_CAN_FOCUS); ddisp->vsb = gtk_vscrollbar_new (ddisp->vsbdata); GTK_WIDGET_UNSET_FLAGS (ddisp->vsb, GTK_CAN_FOCUS); /* set up the scrollbar observers */ gtk_signal_connect (GTK_OBJECT (ddisp->hsbdata), "value_changed", (GtkSignalFunc) ddisplay_hsb_update, ddisp); gtk_signal_connect (GTK_OBJECT (ddisp->vsbdata), "value_changed", (GtkSignalFunc) ddisplay_vsb_update, ddisp); ddisp->canvas = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (ddisp->canvas), width, height); gtk_widget_set_events (ddisp->canvas, CANVAS_EVENT_MASK); GTK_WIDGET_SET_FLAGS (ddisp->canvas, GTK_CAN_FOCUS); gtk_signal_connect (GTK_OBJECT (ddisp->canvas), "event", (GtkSignalFunc) ddisplay_canvas_events, ddisp); gtk_object_set_user_data (GTK_OBJECT (ddisp->canvas), (gpointer) ddisp); /* pack all the widgets */ gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->hrule, 1, 2, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->vrule, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->hsb, 0, 2, 2, 3, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->vsb, 2, 3, 0, 2, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); /* the popup menu */ #ifdef GNOME ddisp->popup = gnome_display_menus_create (); ddisp->accel_group = gnome_popup_menu_get_accel_group(GTK_MENU(ddisp->popup)); #else menus_get_image_menu (&ddisp->popup, &ddisp->accel_group); #endif /* the accelerator table/group for the popup */ gtk_window_add_accel_group (GTK_WINDOW(ddisp->shell), ddisp->accel_group); /* the statusbars */ status_hbox = gtk_hbox_new (FALSE, 2); ddisp->zoom_status = gtk_statusbar_new (); ddisp->modified_status = gtk_statusbar_new (); gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->zoom_status, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->modified_status, TRUE, TRUE, 0); gtk_table_attach (GTK_TABLE (table), status_hbox, 0, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (ddisp->hsb); gtk_widget_show (ddisp->vsb); gtk_widget_show (ddisp->origin); gtk_widget_show (ddisp->hrule); gtk_widget_show (ddisp->vrule); gtk_widget_show (ddisp->canvas); gtk_widget_show (ddisp->zoom_status); gtk_widget_show (ddisp->modified_status); gtk_widget_show (status_hbox); gtk_widget_show (table); gtk_widget_show (ddisp->shell); /* set the focus to the canvas area */ gtk_widget_grab_focus (ddisp->canvas); }