gint configure_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { int i; if( pixmap ) { g_object_unref( pixmap ); for( i = bg; i <= vp_frame; i++ ) gdk_gc_unref( gc[i] ); } pixmap = gdk_pixmap_new( widget->window, width, height, -1 ); for( i = bg; i <= ws_divider; i++ ) gdk_gc_set_foreground( gc[i] = gdk_gc_new( pixmap ), &colors[i] ); /* wishing for a nicer line style, like 3 on, 5 off, making this alternate for neighbouring VPs */ gdk_gc_set_line_attributes( gc[vp_divider], 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND ); gdk_gc_set_foreground( gc[vp_frame] = gdk_gc_new( pixmap ), &colors[vp_divider] ); gdk_gc_set_line_attributes( gc[vp_frame], 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND ); /* wishing for Gimp-style functions -- GDK is just too primitive */ /* gdk_gc_set_function( gc[vp_frame], GDK_XOR ); */ make_background(); draw_pager( widget ); return TRUE; }
World::World(){ SDL_Surface *tmp; srand (time(NULL)); width = 1080; height = 720; tmp = SDL_CreateRGBSurface(0,width, height, 32,0,0,0,0); world_surf = SDL_DisplayFormat(tmp); SDL_FreeSurface(tmp); SDL_SetAlpha(world_surf, 0, 0); background = make_background(); last_mutate_time = time(NULL); mutate_time = 60; }
box pager_rep::pages_make_page (pagelet pg) { box sb= pages_format (pg); box lb= move_box (ip, sb, 0, 0); int nr= N(pages) + 1 + page_offset; SI left= (nr&1)==0? even: odd; env->write (PAGE_NR, as_string (nr)); env->write (PAGE_THE_PAGE, style[PAGE_THE_PAGE]); tree page_t= env->exec (compound (PAGE_THE_PAGE)); bool empty= N (pg->ins) == 0; box header= make_header (empty); box footer= make_footer (empty); brush bgc = make_background (empty); adjust_margins (empty); return page_box (ip, lb, page_t, nr, bgc, width, height, left, top + dtop, top + dtop + text_height, header, footer, head_sep, foot_sep); }
G_MODULE_EXPORT int test_bin_layout_main (int argc, char *argv[]) { ClutterActor *stage, *box, *rect; ClutterLayoutManager *layout; ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterColor bg_color = { 0xcc, 0xcc, 0xcc, 0x99 }; ClutterColor *color; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 640, 480); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); rect = make_background (&bg_color, 200, 200); /* first method: use clutter_box_pack() */ clutter_box_pack (CLUTTER_BOX (box), rect, "x-align", CLUTTER_BIN_ALIGNMENT_FILL, "y-align", CLUTTER_BIN_ALIGNMENT_FILL, NULL); clutter_actor_lower_bottom (rect); clutter_actor_set_name (rect, "background"); { ClutterActor *tex; GError *error; gchar *file; error = NULL; file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); tex = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to create texture: %s", error->message); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE); /* second method: use clutter_bin_layout_add() */ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_raise (tex, rect); clutter_actor_set_width (tex, 175); clutter_actor_set_name (tex, "texture"); g_free (file); } color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); rect = clutter_rectangle_new_with_color (color); /* third method: container_add() and set_alignment() */ clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect, CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_opacity (rect, 0); clutter_actor_raise_top (rect); clutter_actor_set_name (rect, "emblem"); g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), rect); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), rect); clutter_actor_show_all (stage); clutter_main (); clutter_color_free (color); return EXIT_SUCCESS; }