void make_background() { if( background ) g_object_unref( background ); if( ! (*bg_filename && (background = gdk_pixmap_create_from_xpm( window->window, NULL, NULL, bg_filename ))) ) { int i, j; background = gdk_pixmap_new( window->window, ws_width, ws_height, -1 ); gdk_draw_rectangle( background, gc[bg], TRUE, 1, 1, ws_width, ws_height ); /* draw the boundaries of the different viewports */ if( vp_width < ws_width-1 || vp_height < ws_height-1 ) for( i=1; i<ws_width; i+=vp_width ) for( j=1; j<ws_height; j+=vp_height ) gdk_draw_rectangle( background, gc[vp_divider], FALSE, i+1, j+1, vp_width-3, vp_height-3 ); /* draw the workspace-boundary (repeated by tiling) */ gdk_draw_line( background, gc[ws_divider], 0, 0, 0, ws_height ); gdk_draw_line( background, gc[ws_divider], 1, 0, ws_width, 0 ); } gdk_gc_set_fill( gc[bg], GDK_TILED ); gdk_gc_set_tile( gc[bg], background ); }
imgcard_t *load_imgcard(gchar *file, card_t *card,ihm_trick_t *ihm_setup,position_t position) { imgcard_t *imgcard = (imgcard_t *) g_malloc(sizeof(imgcard_t) ); if(imgcard != NULL) { imgcard->couleur = card->clcard; imgcard->valeur = card->nocard; imgcard->position = position; imgcard->dim.x = 0; imgcard->dim.y = 0; imgcard->draw = TRUE; imgcard->draw_face = TRUE; imgcard->moveable = FALSE; imgcard->blink = FALSE; imgcard->status = AVAILABLE; imgcard->img = gdk_pixmap_create_from_xpm( ihm_setup->Drawing_area->window, NULL, NULL, file); gdk_drawable_get_size(imgcard->img, &(imgcard->dim.w), &(imgcard->dim.h)); } return(imgcard); }
/* ----------------------------------------------------------------------------- * Initialize the drawing structures */ void viewInitialize(GtkWidget* parent) { g_message("in viewInitialize"); GdkWindow* window = gtk_widget_get_root_window(parent); int j, k; for (j=0; j<13; j++) { for (k=0; k<3; k++) { gc[j][k] = gdk_gc_new(window); gdk_gc_set_rgb_fg_color(gc[j][k], &color[j][k]); } } lightGreyGC = gdk_gc_new(window); gdk_gc_set_rgb_fg_color(lightGreyGC, &lightGrey); gdk_gc_set_line_attributes(lightGreyGC, 2, /* line_width, */ GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); darkGreyGC = gdk_gc_new(window); gdk_gc_set_rgb_fg_color(darkGreyGC, &darkGrey); gdk_gc_set_line_attributes(darkGreyGC, 1, /* line_width, */ GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); backgrounds = gdk_pixmap_create_from_xpm(window, NULL, NULL, "screens.xpm"); }
void SetUpStatusBarStuff (GtkWidget* aWindow) { _String fName = baseDirectory & "GTKResources/striped.xpm"; statusBarLayout = pango_layout_new (screenPContext); statusBarFontDesc = pango_font_description_new (); stripedFill = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData); stripedFillGC = gdk_gc_new (GDK_DRAWABLE(aWindow->window)); if (stripedFill) { gdk_gc_set_fill (stripedFillGC,GDK_TILED); gdk_gc_set_tile (stripedFillGC,stripedFill); } else { printf ("Failed to load a status bar .xpm from %s\n", fName.sData); } gdk_gc_set_line_attributes (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); GdkColor saveFG = {0,0,0,0}; gdk_gc_set_foreground (stripedFillGC, &saveFG); pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData); pango_font_description_set_style (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_size (statusBarFontDesc, statusBarFont.size*PANGO_SCALE); pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ? pango_layout_set_width (statusBarLayout, -1); redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000); yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001); greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002); orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003); }
/* Create a pixmap widget from an xpm file */ GtkWidget *c_gtk_pixmap_create_from_xpm (GtkWidget *widget, char *fname) { GdkBitmap *mask; GdkPixmap *pixmap; /* Widget must be realized before we can attach a pixmap to it */ if (widget->window == NULL) gtk_widget_realize (widget); pixmap = gdk_pixmap_create_from_xpm (widget->window, &mask, &widget->style->bg[GTK_STATE_NORMAL], fname); return (gtk_pixmap_new (pixmap, mask)); }
static VALUE gdkpmap_create_from_xpm(VALUE self, VALUE win, VALUE color, VALUE fname) { GdkPixmap *result; GdkBitmap *mask; result = gdk_pixmap_create_from_xpm(GDK_WINDOW(RVAL2GOBJ(win)), &mask, RVAL2GDKCOLOR(color), RVAL2CSTR(fname)); if (result == NULL) rb_raise(rb_eArgError, "Pixmap not created from %s", RVAL2CSTR(fname)); return rb_assoc_new(GOBJ2RVAL(result), GOBJ2RVAL(mask)); }
GtkWidget * build_dockapp(char *configfile) { static GtkWidget *mainwin; static GtkWidget *mainbox; static GtkWidget *box; static GtkWidget *pixmap; static GdkBitmap *mask; static GtkWidget *pixmap_widget; static struct wmtrash *wmtrash; wmtrash = malloc(sizeof(struct wmtrash)); memset(wmtrash, 0, sizeof(struct wmtrash)); char *image_path_file; strncpy (wmtrash->param_img, "trashicon", MEDIUM_STRING); strncpy (wmtrash->param_fm, "filemanager", MEDIUM_STRING); strncpy (wmtrash->param_path, "trashpath", MEDIUM_STRING); strncpy (wmtrash->configfile, configfile, MEDIUM_STRING); image_path_file = malloc(LONG_STRING); parse_from_config(wmtrash->configfile, wmtrash->param_img, wmtrash->imagefile); sprintf(image_path_file, "%s/%s", __ICONPATH, wmtrash->imagefile); parse_from_config(wmtrash->configfile, wmtrash->param_fm, wmtrash->fm); parse_from_config(wmtrash->configfile, wmtrash->param_path, wmtrash->path); // GTK stuff ******************************************************************* gtk_widget_destroy(mainwin); mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(mainwin); mainbox = create_main_dockapp_icon_window(mainwin, 52); box = gtk_event_box_new(); pixmap = (gpointer) gdk_pixmap_create_from_xpm (mainwin->window, &mask, NULL, image_path_file); pixmap_widget = gtk_pixmap_new((gpointer) pixmap, mask); gtk_container_add(GTK_CONTAINER(box), pixmap_widget); gtk_container_add (GTK_CONTAINER (mainbox), box); gtk_signal_connect (GTK_OBJECT(box), "button_press_event", GTK_SIGNAL_FUNC(launchonclick), wmtrash); free(image_path_file); return mainwin; }
/* charge un pixmap, si necessaire desalloue et/ou (re)alloue la couleur */ gboolean tansetpixmapmode(GtkWidget *widget, char *aname, int gcnbr){ GdkPixmap *pixmap; GdkGC *gc; char *pname; gboolean ret; pixmap=tabpxpx[gcnbr]; pname=tabpxnam[gcnbr]; gc=tabgc[gcnbr]; if (tabcolalloc[gcnbr]){ gdk_colormap_free_colors (gdk_colormap_get_system(), &colortab[gcnbr], 1); tabcolalloc[gcnbr] = FALSE; } if (pixmap!=NULL) gdk_pixmap_unref(pixmap); ret=FALSE; if ( (pixmap=gdk_pixmap_create_from_xpm (widget->window, NULL, NULL, aname))!=NULL ){ tanallocname(&pname,aname); gdk_gc_set_fill (gc, GDK_TILED); gdk_gc_set_tile (gc, pixmap); ret=TRUE; } if (pname==NULL) tanallocname(&pname,"LoadPixmapFailed"); tabpxpx[gcnbr] = pixmap; tabpxnam[gcnbr] = pname; tabpxpixmode[gcnbr] = ret; if (!ret) tansetcolormode(&colortab[gcnbr],gcnbr); return (ret); }
/*! \brief Creates a new GtkImage displaying a GTK stock icon if available. * * If a stock GTK icon with the requested name was not found, this function * falls back to the bitmap icons provided in the distribution. * * \param stock Name of the stock icon ("new", "open", etc.) * \param w_current Schematic top level * \return Pointer to the new GtkImage object. */ static GtkWidget *x_window_stock_pixmap(const char *stock, GSCHEM_TOPLEVEL *w_current) { GtkWidget *wpixmap = NULL; GdkPixmap *pixmap; GdkBitmap *mask; GtkStockItem item; GdkWindow *window=w_current->main_window->window; GdkColor *background=&w_current->main_window->style->bg[GTK_STATE_NORMAL]; gchar *filename=g_strconcat(w_current->toplevel->bitmap_directory, G_DIR_SEPARATOR_S, "gschem-", stock, ".xpm", NULL); gchar *stockid=g_strconcat("gtk-", stock, NULL); /* First check if GTK knows this stock icon */ if(gtk_stock_lookup(stockid, &item)) { wpixmap = gtk_image_new_from_stock(stockid, GTK_ICON_SIZE_SMALL_TOOLBAR); } else { /* Fallback to the original custom icon */ pixmap = gdk_pixmap_create_from_xpm (window, &mask, background, filename); if (pixmap != NULL) { wpixmap = gtk_image_new_from_pixmap (pixmap, mask); } else { s_log_message("Could not find image at file: %s.\n", filename); wpixmap = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE , GTK_ICON_SIZE_SMALL_TOOLBAR); } } g_free(filename); g_free(stockid); return wpixmap; }
static void gtk_ui_load_picture(const char *name, int trans, Picture **pictp) { Picture *pict; char file[255]; GdkBitmap *mask; UNUSED(trans); pict = xalloc(sizeof *pict); sprintf(file, "%s/pixmaps/%s.xpm", pictdir, name); pict->pix = gdk_pixmap_create_from_xpm(toplevel->window, &mask, NULL, file); if (pict->pix == NULL) fatal("error reading %s", file); pict->mask = mask; pict->gc = gdk_gc_new(toplevel->window); gdk_gc_set_exposures(pict->gc, FALSE); gdk_gc_set_clip_mask(pict->gc, mask); gdk_window_get_size(pict->pix, &pict->width, &pict->height); *pictp = pict; }
static GtkWidget * create_sheet_page(GtkWidget *parent, Sheet *sheet) { GSList *list; SheetObject *sheet_obj; GtkWidget *table; GtkWidget *button; GtkWidget *pixmapwidget; GdkPixmap *pixmap; GdkBitmap *mask; ToolButtonData *data; GtkStyle *style; GtkWidget *scrolled_window; int i; int rows; scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); rows = (g_slist_length(sheet->objects) - 1) / COLUMNS + 1; if (rows<1) rows = 1; table = gtk_table_new (rows, COLUMNS, TRUE); style = gtk_widget_get_style(parent); i = 0; list = sheet->objects; while (list != NULL) { sheet_obj = (SheetObject *) list->data; if (sheet_obj->pixmap != NULL) { pixmap = gdk_pixmap_create_from_xpm_d(parent->window, &mask, &style->bg[GTK_STATE_NORMAL], sheet_obj->pixmap); } else if (sheet_obj->pixmap_file != NULL) { pixmap = gdk_pixmap_create_from_xpm(parent->window, &mask, &style->bg[GTK_STATE_NORMAL], sheet_obj->pixmap_file); } else { ObjectType *type; type = object_get_type(sheet_obj->object_type); pixmap = gdk_pixmap_create_from_xpm_d(parent->window, &mask, &style->bg[GTK_STATE_NORMAL], type->pixmap); } pixmapwidget = gtk_pixmap_new(pixmap, mask); button = gtk_radio_button_new (tool_group); gtk_container_set_border_width (GTK_CONTAINER (button), 0); tool_group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); gtk_container_add (GTK_CONTAINER (button), pixmapwidget); gtk_table_attach (GTK_TABLE (table), button, (i % COLUMNS), (i % COLUMNS) + 1, (i / COLUMNS), (i / COLUMNS) + 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0); /* This is a Memory leak, these can't be freed. Doesn't matter much anyway... */ data = g_new(ToolButtonData, 1); data->type = CREATE_OBJECT_TOOL; data->extra_data = sheet_obj->object_type; data->user_data = sheet_obj->user_data; gtk_signal_connect (GTK_OBJECT (button), "toggled", GTK_SIGNAL_FUNC (tool_select_update), data); gtk_signal_connect (GTK_OBJECT (button), "button_press_event", GTK_SIGNAL_FUNC (tool_button_press), data); gtk_tooltips_set_tip (tool_tips, button, gettext(sheet_obj->description), NULL); list = g_slist_next(list); i++; } gtk_widget_show(table); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), table); return scrolled_window; }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *image; GtkWidget *fixed; // GtkWidget *item; GtkWidget *mainWindow; GdkScreen* scr; GdkBitmap *window_mask; GdkPixmap *pixmap; GdkBitmap *pixmap_mask; int lang = get_lang(); switch(lang) { case 0: item_labels[0] = g_strdup_printf("重启"); item_labels[1] = g_strdup_printf("待机"); item_labels[2] = g_strdup_printf("关机"); item_labels[3] = g_strdup_printf("取消"); break; case 1: item_labels[0] = g_strdup_printf("Restart"); item_labels[1] = g_strdup_printf("Stand By"); item_labels[2] = g_strdup_printf("Turn off"); item_labels[3] = g_strdup_printf("Cancel"); break; case 2: item_labels[0] = g_strdup_printf("再起動"); item_labels[1] = g_strdup_printf("スタンバイ"); item_labels[2] = g_strdup_printf("電源を切る"); item_labels[3] = g_strdup_printf("キャンセル"); break; } gtk_init(&argc, &argv); //---------------------------------------------- mainWindow = gtk_window_new( GTK_WINDOW_POPUP); scr = gtk_window_get_screen( GTK_WINDOW( mainWindow)); GdkColor white; gdk_color_parse("#9c9c9c",&white); gtk_widget_modify_bg(mainWindow,GTK_STATE_NORMAL,&white); gtk_window_set_default_size( GTK_WINDOW( mainWindow), gdk_screen_get_width( scr), gdk_screen_get_height( scr)); //gtk_widget_set_size_request(mainWindow, window_width, window_height); gtk_window_fullscreen( GTK_WINDOW( mainWindow)); gtk_widget_show_all( mainWindow); gtk_widget_realize(GTK_WIDGET(mainWindow)); Display *xdpy = XOpenDisplay(getenv("DISPLAY")); GdkWindow *gdkwin = GTK_WIDGET(mainWindow)->window; Window xwin = GDK_WINDOW_XID(gdkwin); unsigned int opacity = (unsigned int) (0.70 * OPAQUE); XChangeProperty(xdpy, xwin, XInternAtom(xdpy, OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); // XSync(xdpy, False); //---------------------------------------------- window = gtk_window_new(GTK_WINDOW_POPUP); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); gtk_window_set_default_size(GTK_WINDOW(window), window_width, window_height); //gtk_widget_set_size_request(window, window_width, window_height); //gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_move(GTK_WINDOW(window), 249,163); gtk_window_set_modal(window,FALSE); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_set_title (GTK_WINDOW (window),"CloseWindow"); /*gdk_pointer_grab (window->window, FALSE, (GdkEventMask)EVENT_MASKS, 0, NULL, GDK_CURRENT_TIME);*/ gdk_pixmap_create_from_xpm(window->window, &window_mask, NULL, background_png); gtk_widget_shape_combine_mask (window, window_mask, 0, 0); gtk_widget_realize(GTK_WIDGET(window)); Display *xdpy2 = XOpenDisplay(getenv("DISPLAY")); GdkWindow *gdkwin2 = GTK_WIDGET(window)->window; Window xwin2 = GDK_WINDOW_XID(gdkwin2); unsigned int opacity2 = (unsigned int) (0.80 * OPAQUE); XChangeProperty(xdpy2, xwin2, XInternAtom(xdpy2, OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity2, 1L); gtk_widget_show_all(window); fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed); gtk_widget_show(fixed); pixmap = gdk_pixmap_create_from_xpm(window->window, &pixmap_mask, NULL, background_png); image = gtk_image_new_from_pixmap(pixmap, pixmap_mask); gtk_fixed_put(GTK_FIXED(fixed), image, 0, 0); gtk_widget_show(image); make_icon_area(fixed); //make_cancel_button(fixed); XSync(xdpy, False);XSync(xdpy2, False); gtk_main(); return 0; }