コード例 #1
0
ファイル: pinhole.c プロジェクト: dpithon/cg
/**
 * init_mapping - compute constants to map pixel on "sensor" surface.
 *
 */
static void init_mapping(void)
{
	if (pixmap_width() < pixmap_height())
		fatal("pixmap_width < pixmap_height");

	sqr_edge = 1. / pixmap_width();
	fac_xy   = - sqr_edge;
	off_x    = 0.5 - sqr_edge;
	off_y    = pixmap_height() / (2. * pixmap_width()) - sqr_edge;
}
コード例 #2
0
ファイル: flt-player.c プロジェクト: svn2github/xqf
void player_filter_page (GtkWidget *notebook) {
  GtkWidget *page_hbox;
  GtkWidget *scrollwin;
  GtkWidget *label;
  GtkWidget *vbox;
  GtkWidget *vbox2;
  GtkWidget *alignment;
  GtkWidget *pixmap;
  GtkWidget *button;
  GtkWidget *peditor;
  char *titles[5] = { "", "", "", _("Mode"), _("Pattern") };
  int i;

  page_hbox = gtk_hbox_new (FALSE, 8);
  gtk_container_set_border_width (GTK_CONTAINER (page_hbox), 8);

  label = gtk_label_new (_("Player Filter"));
  gtk_widget_show (label);

  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_hbox, label);

  /* Pattern CList */

  scrollwin = gtk_scrolled_window_new (NULL, NULL);
  gtk_box_pack_start (GTK_BOX (page_hbox), scrollwin, FALSE, FALSE, 0);

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin), 
				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  pattern_clist = gtk_clist_new_with_titles (5, titles);
  gtk_widget_set_usize (pattern_clist, 260, 200);
  gtk_clist_set_selection_mode (GTK_CLIST (pattern_clist),
                                                        GTK_SELECTION_BROWSE);
  gtk_clist_set_reorderable (GTK_CLIST (pattern_clist), TRUE);

  gtk_signal_connect (GTK_OBJECT (pattern_clist), "event",
                        GTK_SIGNAL_FUNC (pattern_clist_event_callback), NULL);
  gtk_signal_connect (GTK_OBJECT (pattern_clist), "select_row",
                   GTK_SIGNAL_FUNC (pattern_clist_select_row_callback), NULL);
  gtk_signal_connect (GTK_OBJECT (pattern_clist), "row_move",
                     GTK_SIGNAL_FUNC (pattern_clist_row_move_callback), NULL);

  for (i = 0; i < 3; i++) {
    pixmap = aligned_pixmap (group_pix[i].pix, group_pix[i].mask);
    gtk_clist_set_column_width (GTK_CLIST (pattern_clist), i, 
                                             pixmap_width (group_pix[i].pix));
    gtk_clist_set_column_widget (GTK_CLIST (pattern_clist), i, pixmap);
    gtk_widget_show (pixmap);

    gtk_clist_set_column_resizeable (GTK_CLIST (pattern_clist), i, FALSE);
  }

  gtk_clist_set_column_width (GTK_CLIST (pattern_clist), 3, 45);

  gtk_container_add (GTK_CONTAINER (scrollwin), pattern_clist); 
  gtk_clist_column_titles_passive (GTK_CLIST (pattern_clist));

  gtk_widget_show (pattern_clist);

  gtk_widget_show (scrollwin);

  gtk_widget_ensure_style (pattern_clist);

/*FIXME_GTK2: style->font not working with gtk2*/
#ifndef USE_GTK2
  i = MAX (pixmap_height (group_pix[0].pix), 
	      pattern_clist->style->font->ascent + 
	      pattern_clist->style->font->descent + 1);

  gtk_clist_set_row_height (GTK_CLIST (pattern_clist), i);
#endif

  /* Buttons */

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_box_pack_start (GTK_BOX (page_hbox), vbox, FALSE, FALSE, 0);

  button = gtk_button_new_with_label (_("New"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
                                GTK_SIGNAL_FUNC (new_pattern_callback), NULL);
  gtk_widget_show (button);

  delete_button = gtk_button_new_with_label (_("Delete"));
  gtk_box_pack_start (GTK_BOX (vbox), delete_button, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (delete_button), "clicked",
                             GTK_SIGNAL_FUNC (delete_pattern_callback), NULL);
  gtk_widget_show (delete_button);

  alignment = gtk_alignment_new (0, 0.5, 1, 0);
  gtk_box_pack_end (GTK_BOX (vbox), alignment, TRUE, TRUE, 0);

  vbox2 = gtk_vbox_new (FALSE, 4);
  gtk_container_add (GTK_CONTAINER (alignment), vbox2);

  up_button = gtk_button_new_with_label (_("Up"));
  gtk_box_pack_start (GTK_BOX (vbox2), up_button, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (up_button), "clicked",
                GTK_SIGNAL_FUNC (move_up_down_pattern_callback), (void *) -1);
  gtk_widget_show (up_button);

  down_button = gtk_button_new_with_label (_("Down"));
  gtk_box_pack_start (GTK_BOX (vbox2), down_button, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (down_button), "clicked",
                 GTK_SIGNAL_FUNC (move_up_down_pattern_callback), (void *) 1);
  gtk_widget_show (down_button);

  gtk_widget_show (vbox2);
  gtk_widget_show (alignment);
  gtk_widget_show (vbox);

  /* Pattern Editor */

  peditor = player_filter_pattern_editor ();
  gtk_box_pack_end (GTK_BOX (page_hbox), peditor, TRUE, TRUE, 0);

  gtk_widget_show (page_hbox);

  player_filter_page_init ();
}