static int cdhatch(cdCtxCanvas *ctxcanvas, int hatch_style) { GdkColor fg, bg; if (ctxcanvas->last_hatch) g_object_unref(ctxcanvas->last_hatch); fg.pixel = 1; bg.pixel = 0; ctxcanvas->last_hatch = gdk_pixmap_create_from_data(ctxcanvas->wnd, hatches[hatch_style], HATCH_WIDTH, HATCH_HEIGHT, 1, &fg, &bg); cdinteriorstyle(ctxcanvas, CD_HATCH); return hatch_style; }
static VALUE gdkpmap_create_from_data(int argc, VALUE *argv, VALUE self) { VALUE win, data, w, h, depth, fg, bg, ret; rb_scan_args(argc, argv, "43", &win, &data, &w, &h, &depth, &fg, &bg); Check_Type(data, T_STRING); if (NIL_P(depth)){ ret = GOBJ2RVAL(gdk_bitmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), RVAL2CSTR(data), NUM2INT(w), NUM2INT(h))); } else { ret = GOBJ2RVAL(gdk_pixmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)), RVAL2CSTR(data), NUM2INT(w), NUM2INT(h), NUM2INT(depth), RVAL2GDKCOLOR(fg), RVAL2GDKCOLOR(bg))); } return ret; }
int mousemng_initialize(void) { static gchar hide_cursor[16*16/8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ms = ms_default; ms.cursor_pixmap = gdk_pixmap_create_from_data(main_window->window, hide_cursor, 16, 16, 1, &main_window->style->black, &main_window->style->black); ms.cursor = gdk_cursor_new_from_pixmap(ms.cursor_pixmap, ms.cursor_pixmap, &main_window->style->black, &main_window->style->black, 0, 0); return SUCCESS; }
void ZLGtkPaintContext::setFillColor(ZLColor color, FillStyle style) { if (style == SOLID_FILL) { ::setColor(myFillGC, color); gdk_gc_set_fill(myFillGC, GDK_SOLID); } else { gdk_gc_set_fill(myFillGC, GDK_TILED); if (myPixmap != 0) { if (myTilePixmap != 0) { gdk_pixmap_unref(myTilePixmap); } static GdkColor fgColor; ::setColor(fgColor, color); static GdkColor bgColor; ::setColor(bgColor, myBackColor); static char data[] = { 0x0C, 0x0C, 0x03, 0x03 }; myTilePixmap = gdk_pixmap_create_from_data( myPixmap, data, 4, 4, gdk_drawable_get_depth(myPixmap), &fgColor, &bgColor ); gdk_gc_set_tile(myFillGC, myTilePixmap); } } }
void InitCursors(void) { GdkPixmap *image, *mask; static GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff }, black = { 0xffffffff, 0 , 0 , 0 }, red = { 0xffffffff, 0xffff, 0 , 0 }; image = gdk_pixmap_create_from_data(NULL,(guchar *)magplus_bits,magplus_width,magplus_height, 1, &black, &white); ct_magplus = gdk_cursor_new_from_pixmap( image,image,&black,&white,magplus_x_hot, magplus_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)magminus_bits,magminus_width,magminus_height, 1, &black, &white); ct_magminus = gdk_cursor_new_from_pixmap( image,image,&black,&white,magminus_x_hot, magminus_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointercur_bits,pointercur_width,pointercur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointercurmask_bits,pointercurmask_width,pointercurmask_height, 1, &black, &white); ct_mypointer = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointercur_x_hot, pointercur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointercirc_bits,pointercirc_width,pointercirc_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointercircmask_bits,pointercircmask_width,pointercircmask_height, 1, &black, &white); ct_circle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointercirc_x_hot, pointercirc_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointertri_bits,pointertri_width,pointertri_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointertrimask_bits,pointertrimask_width,pointertrimask_height, 1, &black, &white); ct_triangle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointertri_x_hot, pointertri_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointersqr_bits,pointersqr_width,pointersqr_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointersqrmask_bits,pointersqrmask_width,pointersqrmask_height, 1, &black, &white); ct_square = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointersqr_x_hot, pointersqr_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pencur_bits,pencur_width,pencur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pencurmask_bits,pencurmask_width,pencurmask_height, 1, &black, &white); ct_pen = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pencur_x_hot, pencur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)setwidthcur_bits,setwidthcur_width,setwidthcur_height, 1, &black, &white); /* mask = gdk_pixmap_create_from_data(NULL,(guchar *)setwidthcurmask_bits,setwidthcurmask_width,setwidthcurmask_height, 1, &black, &white);*/ ct_setwidth = gdk_cursor_new_from_pixmap( image,image,&black,&white,setwidthcur_x_hot, setwidthcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerhvcirc_bits,pointerhvcirc_width,pointerhvcirc_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerhvcircmask_bits,pointerhvcircmask_width,pointerhvcircmask_height, 1, &black, &white); ct_hvcircle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerhvcirc_x_hot, pointerhvcirc_y_hot); #if _CursorsMustBe16x16 ct_g2circle = ct_hvcircle; #else image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerg2circ_bits,pointerg2circ_width,pointerg2circ_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerg2circmask_bits,pointerg2circmask_width,pointerg2circmask_height, 1, &black, &white); ct_g2circle = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerg2circ_x_hot, pointerg2circ_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerright_bits,pointerright_width,pointerright_height, 1, &black, &white); #endif mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerrightmask_bits,pointerrightmask_width,pointerrightmask_height, 1, &black, &white); ct_spiroright = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerright_x_hot, pointerright_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pointerleft_bits,pointerleft_width,pointerleft_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pointerleftmask_bits,pointerleftmask_width,pointerleftmask_height, 1, &black, &white); ct_spiroleft = gdk_cursor_new_from_pixmap( image,mask,&black,&white,pointerleft_x_hot, pointerleft_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rulercur_bits,rulercur_width,rulercur_height, 1, &black, &white); ct_ruler = gdk_cursor_new_from_pixmap( image,image,&black,&white,rulercur_x_hot, rulercur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)knifecur_bits,knifecur_width,knifecur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)knifecurmask_bits,knifecurmask_width,knifecurmask_height, 1, &black, &white); ct_knife = gdk_cursor_new_from_pixmap( image,mask,&black,&white,knifecur_x_hot, knifecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)flipcur_bits,flipcur_width,flipcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)flipcurmask_bits,flipcurmask_width,flipcurmask_height, 1, &black, &white); ct_flip = gdk_cursor_new_from_pixmap( image,mask,&red,&white,flipcur_x_hot, flipcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rotatecur_bits,rotatecur_width,rotatecur_height, 1, &black, &white); ct_rotate = gdk_cursor_new_from_pixmap( image,image,&red,&white,rotatecur_x_hot, rotatecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)scalecur_bits,scalecur_width,scalecur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)scalecurmask_bits,scalecur_width,scalecur_height, 1, &black, &white); ct_scale = gdk_cursor_new_from_pixmap( image,mask,&red,&white,scalecur_x_hot, scalecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)skewcur_bits,skewcur_width,skewcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)skewcurmask_bits,skewcur_width,skewcur_height, 1, &black, &white); ct_skew = gdk_cursor_new_from_pixmap( image,mask,&red,&white,skewcur_x_hot, skewcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rotate3dcur_bits,rotate3dcur_width,rotate3dcur_height, 1, &black, &white); ct_3drotate = gdk_cursor_new_from_pixmap( image,image,&red,&white,rotate3dcur_x_hot, rotate3dcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)perspectivecur_bits,perspectivecur_width,perspectivecur_height, 1, &black, &white); ct_perspective = gdk_cursor_new_from_pixmap( image,image,&red,&white,perspectivecur_x_hot, perspectivecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rectcur_bits,rectcur_width,rectcur_height, 1, &black, &white); ct_rect = gdk_cursor_new_from_pixmap( image,image,&red,&white,rectcur_x_hot, rectcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)elipsecur_bits,elipsecur_width,elipsecur_height, 1, &black, &white); ct_elipse = gdk_cursor_new_from_pixmap( image,image,&red,&white,elipsecur_x_hot, elipsecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)polycur_bits,polycur_width,polycur_height, 1, &black, &white); ct_poly = gdk_cursor_new_from_pixmap( image,image,&red,&white,polycur_x_hot, polycur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)starcur_bits,starcur_width,starcur_height, 1, &black, &white); ct_star = gdk_cursor_new_from_pixmap( image,image,&red,&white,starcur_x_hot, starcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)nwse_bits,nwse_width,nwse_height, 1, &black, &white); ct_nwse = gdk_cursor_new_from_pixmap( image,image,&red,&white,nwse_x_hot, nwse_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)nesw_bits,nesw_width,nesw_height, 1, &black, &white); ct_nesw = gdk_cursor_new_from_pixmap( image,image,&red,&white,nesw_x_hot, nesw_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)leftright_bits,leftright_width,leftright_height, 1, &black, &white); ct_leftright = gdk_cursor_new_from_pixmap( image,image,&red,&white,leftright_x_hot, leftright_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)updown_bits,updown_width,updown_height, 1, &black, &white); ct_updown = gdk_cursor_new_from_pixmap( image,image,&red,&white,updown_x_hot, updown_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)pencil_bits,pencil_width,pencil_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)pencilmask_bits,pencil_width,pencil_height, 1, &black, &white); ct_pencil = gdk_cursor_new_from_pixmap( image,mask,&red,&white,pencil_x_hot, pencil_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)eyedropper_bits,eyedropper_width,eyedropper_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)eyedroppermask_bits,eyedropper_width,eyedropper_height, 1, &black, &white); ct_eyedropper = gdk_cursor_new_from_pixmap( image,mask,&red,&white,eyedropper_x_hot, eyedropper_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)shift_bits,shift_width,shift_height, 1, &black, &white); ct_shift = gdk_cursor_new_from_pixmap( image,image,&red,&white,shift_x_hot, shift_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)linecur_bits,linecur_width,linecur_height, 1, &black, &white); ct_line = gdk_cursor_new_from_pixmap( image,image,&red,&white,linecur_x_hot, linecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)hand_bits,hand_width,hand_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)handmask_bits,hand_width,hand_height, 1, &black, &white); ct_myhand = gdk_cursor_new_from_pixmap( image,mask,&red,&white,hand_x_hot, hand_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)filledrectcur_bits,filledrectcur_width,filledrectcur_height, 1, &black, &white); ct_filledrect = gdk_cursor_new_from_pixmap( image,image,&red,&white,filledrectcur_x_hot, filledrectcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)filledelipsecur_bits,filledelipsecur_width,filledelipsecur_height, 1, &black, &white); ct_filledelipse = gdk_cursor_new_from_pixmap( image,image,&red,&white,filledelipsecur_x_hot, filledelipsecur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)kerncur_bits,kerncur_width,kerncur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)rbearmask_bits,kerncur_width,kerncur_height, 1, &black, &white); ct_kerning = gdk_cursor_new_from_pixmap( image,mask,&red,&white,kerncur_x_hot, kerncur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)rbearcur_bits,rbearcur_width,rbearcur_height, 1, &black, &white); ct_rbearing = gdk_cursor_new_from_pixmap( image,mask,&red,&white,rbearcur_x_hot, rbearcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)lbearcur_bits,lbearcur_width,lbearcur_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)lbearmask_bits,lbearcur_width,lbearcur_height, 1, &black, &white); ct_lbearing = gdk_cursor_new_from_pixmap( image,mask,&red,&white,lbearcur_x_hot, lbearcur_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)prohibition_bits,prohibition_width,prohibition_height, 1, &black, &white); mask = gdk_pixmap_create_from_data(NULL,(guchar *)prohibitionmask_bits,prohibition_width,prohibition_height, 1, &black, &white); ct_prohibition = gdk_cursor_new_from_pixmap( image,mask,&red,&white,prohibition_x_hot, prohibition_y_hot); image = gdk_pixmap_create_from_data(NULL,(guchar *)ddcursor_bits,ddcursor_width,ddcursor_height, 1, &black, &white); ct_ddcursor = gdk_cursor_new_from_pixmap( image,image,&red,&white,ddcursor_x_hot, ddcursor_y_hot); ct_pointer = gdk_cursor_new(GDK_LEFT_PTR); ct_4way = gdk_cursor_new(GDK_FLEUR); ct_watch = gdk_cursor_new(GDK_WATCH); ct_draganddrop = gdk_cursor_new(GDK_RIGHT_PTR); image = gdk_pixmap_create_from_data(NULL,(guchar *)zeroes,16,16, 1, &black, &white); ct_invisible = gdk_cursor_new_from_pixmap( image,image,&red,&white,0,0); /*ct_backpointer = gdk_cursor_new(GDK_RIGHT_PTR);*/ /*ct_hand = gdk_cursor_new(GDK_HAND2);*/ /*ct_question = gdk_cursor_new(GDK_QUESTION_ARROW);*/ /*ct_cross = gdk_cursor_new(GDK_TCROSS);*/ /*ct_text = gdk_cursor_new(GDK_XTERM);*/ }
int main(int argc, char *argv[]) { gnome_init(VERSION, VERSION, argc, argv); /* Set up to draw from card class */ GtkWidget *vbox, *vbox1, *vbox2, *vbox3; GtkWidget *tbar; GtkWidget *setbutton, *nosetbutton; GdkColor white, black, blue; /* Done setting up */ window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Set Game"); gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); gtk_container_border_width(GTK_CONTAINER(window), 0); vbox= gtk_vbox_new(FALSE, 0); vbox1 = gtk_vbox_new(FALSE, 0); vbox2 = gtk_vbox_new(FALSE, 0); vbox3 = gtk_vbox_new(FALSE, 0); drawing_area = gtk_drawing_area_new(); gtk_widget_set_events(drawing_area, GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK); gtk_widget_set_events(window, GDK_KEY_PRESS_MASK); gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event", GTK_SIGNAL_FUNC(expose_event), 0); gtk_signal_connect(GTK_OBJECT(drawing_area), "button_press_event", GTK_SIGNAL_FUNC(button_event), 0); GnomeUIInfo toolbar[ ] = { GNOMEUIINFO_ITEM_STOCK ("New Game", "Start new Game", newgame, GNOME_STOCK_PIXMAP_NEW), GNOMEUIINFO_ITEM_STOCK ("High Scores", "Shows High scores", gtk_main_quit, GNOME_STOCK_PIXMAP_SCORES), GNOMEUIINFO_ITEM_STOCK ("End Game", "Ends Current Game", gtk_main_quit, GNOME_STOCK_PIXMAP_STOP), GNOMEUIINFO_ITEM_STOCK ("Exit", "Exit the application", gtk_main_quit, GNOME_STOCK_PIXMAP_EXIT), GNOMEUIINFO_END }; tbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); gnome_app_fill_toolbar(GTK_TOOLBAR(tbar), toolbar, gtk_accel_group_new()); gtk_box_pack_start(GTK_BOX(vbox1), tbar, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), vbox3, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox2), drawing_area, TRUE, TRUE, 5); gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), SPACE_INTER+CARD_WS*4, SPACE_INTER+CARD_HS*3); gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Player"), TRUE, TRUE, 1); playerscore = gtk_label_new("0"); gtk_box_pack_start(GTK_BOX(vbox3), playerscore, TRUE, TRUE, 1); gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Computer"), TRUE, TRUE, 1); computerscore = gtk_label_new("0"); gtk_box_pack_start(GTK_BOX(vbox3), computerscore, TRUE, TRUE, 1); gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Cards Remaining"), TRUE, TRUE, 1); cards_remain = gtk_label_new("81"); gtk_box_pack_start(GTK_BOX(vbox3), cards_remain, TRUE, TRUE, 1); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show_all(window); gtk_idle_add( myidle, NULL); /************************ Start Deck Setup *************************/ unsigned char *pixmap_data[] = { bean_e_bits, bean_s_bits, bean_f_bits, blob_e_bits, blob_s_bits, blob_f_bits, diamond_e_bits, diamond_s_bits, diamond_f_bits }; int i, j; GdkWindow *wn = window->window; GdkColor col[4]; GdkColormap *cmap = gdk_window_get_colormap(wn); GdkGC *gc; GtkStyle *style = gtk_widget_get_style(window); col[0].red = 54000; col[0].green = col[0].blue = 0; col[1].green = 40000; col[1].red = col[1].blue = 0; col[2].red = col[2].blue = 32000; col[2].green = 0; gdk_color_white(cmap, &white); gdk_color_black(cmap, &black); blue.red = blue.green = 0; blue.blue = 48000; gdk_color_alloc(cmap, &blue); for (i=0; i<3; i++) gdk_color_alloc(cmap, &col[i]); for (i=0; i<9; i++) for (j=0; j<3; j++) card_pixmap[i*3+j] = gdk_pixmap_create_from_data(wn, (gchar*) pixmap_data[i], SHAPE_W, SHAPE_H, -1, &col[j], &white); /* free colors? !! */ gc = gdk_gc_new(wn); /*** cards in normal state ***/ card_bkg = gdk_pixmap_new(wn, CARD_WIDTH, CARD_HEIGHT, -1); /* clear the card */ gdk_gc_set_foreground(gc, &style->bg[GTK_STATE_NORMAL]); gdk_draw_rectangle(card_bkg, gc, 1, 0, 0, CARD_WIDTH, CARD_HEIGHT); /* draw corner arcs */ gdk_gc_set_foreground(gc, &white); gdk_draw_arc(card_bkg, gc, 1, 0, 0, 2*ARC_SIZE, 2*ARC_SIZE, 90*64, 90*64); gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE, 0, 2*ARC_SIZE, 2*ARC_SIZE, 0, 90*64); gdk_draw_arc(card_bkg, gc, 1, 0, CARD_HEIGHT-2*ARC_SIZE, 2*ARC_SIZE, 2*ARC_SIZE, 180*64, 90*64); gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE, CARD_HEIGHT-2*ARC_SIZE, 2*ARC_SIZE, 2*ARC_SIZE, 270*64, 90*64); /* draw the rest */ gdk_draw_rectangle(card_bkg, gc, 1, ARC_SIZE, 0, CARD_WIDTH-2*ARC_SIZE, CARD_HEIGHT); gdk_draw_rectangle(card_bkg, gc, 1, 0, ARC_SIZE, CARD_WIDTH, CARD_HEIGHT-2*ARC_SIZE); gdk_gc_destroy(gc); /************************ End Deck Setup *************************/ /* done setting up for once to draw wn = drawing_area->window; gc-gdk_gc_new(wn); card1.draw(); .............draw(); gdk_gc_destroy(); Card(int colr, int shp, int num, int shdng); */ mytable.Draw(); gtk_main(); return 0; }
int main(int argc, char *argv[]) { // GtkWidget *window; GtkWidget *fixed; GtkWidget *area; // gtk_init(&argc, &argv); // Window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "gui"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 0); gtk_window_set_default_size(GTK_WINDOW(window), width, height); printf("window ok\n"); // layout fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed); printf("fixed ok\n"); // Image GList *visuals = gdk_list_visuals(); void tst(gpointer data, gpointer udata) { if (((GdkVisual*)data)->depth == 32) printf("visual :\n\ttype = %d\n\ttype = %d\n\tdepth = %d\n\tbits/rgb = %d\n\torder = %d\n\tred = %08X\n\tgreen = %08X\n\tblue = %08X\n" , ((GdkVisual*)data)->type , ((GdkVisual*)data)->colormap_size , ((GdkVisual*)data)->depth , ((GdkVisual*)data)->bits_per_rgb , ((GdkVisual*)data)->byte_order , ((GdkVisual*)data)->red_mask , ((GdkVisual*)data)->green_mask , ((GdkVisual*)data)->blue_mask ); } g_list_foreach(visuals, &tst, NULL); GdkVisual *visu = gdk_visual_get_best_with_depth(32); ximg = gdk_image_new(GDK_IMAGE_SHARED, visu, width, height); printf("GdkImage : bytes/pix = %d, linesize = %d, bits/pix = %d ; type %d (mem = %p)\n" , ximg->bpp, ximg->bpl, ximg->bits_per_pixel , ximg->type, ximg->mem ); // GdkPixbufAnimation //gtk_image_set_from_pixbuf // GdkColormap *dcm = gdk_colormap_new(visu, FALSE); // drawing area area = gtk_drawing_area_new(); gdk_drawable_set_colormap(window, dcm); gdk_drawable_set_colormap(area, dcm); gtk_drawing_area_size(GTK_DRAWING_AREA(area), width, height); printf("area ok\n"); // gtk_fixed_put(GTK_FIXED(fixed), area, 0, 0); printf("fixed ok\n"); // bgra_alloc650(&bgra, width, height); bgra_origin650(&bgra, +width/2, +height/2); bgra_scale650(&bgra, 1, -1); printf("bgra alloc ok\n"); maj(); printf("bgra maj done, still (%p <- %p)\n", ximg->mem, bgra.data); // // Ximg // memcpy(ximg->mem, bgra.data, bgra.size); // printf("mcpy done\n"); // Pixmap GdkColor bg; GdkColor fg; fg.pixel = 0xff000000; fg.red = 0; fg.green = 0; fg.blue = 0; bg.pixel = 0xff000000; bg.red = 0; bg.green = 0; bg.blue = 0; pixmap = gdk_pixmap_create_from_data( GTK_WINDOW(window) , bgra.data , width , height , 32 , &fg , &bg ); // img = gdk_pixbuf_new_from_data( // (guchar*)bgra.data // , GDK_COLORSPACE_RGB // , TRUE // , 8 // , width // , height // , width << 2 // , &pbd, NULL // ); // printf("PixBuf new ok\n"); // // Image // frame = gtk_image_new_from_pixbuf(img); //// frame = gtimg; // gtk_fixed_put(GTK_FIXED(fixed), frame, 0, 0); // printf("fixed ok\n"); // Events g_signal_connect(area, "expose-event", G_CALLBACK (on_expose_event), NULL); // g_signal_connect(frame, "expose-event", G_CALLBACK (on_expose_event), NULL); g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL); g_signal_connect(window, "destroy", G_CALLBACK (destroy), NULL); printf("signals ok\n"); // Show // gtk_widget_show(area); gtk_widget_show(fixed); gtk_widget_show_all(window); printf("show ok\n"); // Timer g_timeout_add(500, (GSourceFunc)time_handler, (gpointer)area); printf("timer ok\n"); gtk_main(); return 0; }
int config_dialog(char* title, int argc, char** argv) { GtkWidget *box1, *but_quit, *but_start; GdkBitmap *mask; GdkPixmap *background; GdkColormap* colormap; GdkColor white, black; if (gtk_init_check(&argc, &argv) == FALSE) return -1; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE); gtk_window_set_title(GTK_WINDOW(window), title); gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); gtk_widget_set_usize(GTK_WIDGET(window), 120, 400); gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); box1 = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), box1); ch_windowed = gtk_check_button_new_with_label("Windowed"); gtk_box_pack_start(GTK_BOX(box1), ch_windowed, FALSE, FALSE, 0); gtk_widget_show(ch_windowed); ch_oldskool = gtk_check_button_new_with_label("Oldskool"); gtk_box_pack_start(GTK_BOX(box1), ch_oldskool, FALSE, FALSE, 0); gtk_widget_show(ch_oldskool); but_quit = gtk_button_new_with_label("Quit"); gtk_box_pack_end(GTK_BOX(box1), but_quit, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(but_quit), "clicked", GTK_SIGNAL_FUNC(quit_event), NULL); gtk_widget_show(but_quit); but_start = gtk_button_new_with_label("Start"); gtk_box_pack_end(GTK_BOX(box1), but_start, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(but_start), "clicked", GTK_SIGNAL_FUNC(start_event), NULL); gtk_widget_show(but_start); gtk_widget_show(box1); gtk_widget_realize(GTK_WIDGET(window)); gdk_window_set_decorations(GTK_WIDGET(window)->window, 0); colormap = gdk_colormap_get_system(); gdk_color_white(colormap, &white); gdk_color_black(colormap, &black); background = gdk_pixmap_create_from_data(GTK_WIDGET(window)->window, fznback2_bits, fznback2_width, fznback2_height, -1, &black, &white); gdk_window_set_back_pixmap(GTK_WIDGET(window)->window, background, FALSE); gdk_window_clear(GTK_WIDGET(window)->window); gtk_widget_show(window); gtk_main(); return result; }