/* copy the native state of the peer (GtkWidget *) to the native state of the graphics object */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject obj, jobject peer) { struct graphics *g = (struct graphics *) malloc (sizeof (struct graphics)); void *ptr; GtkWidget *widget; GdkColor color; ptr = NSA_GET_PTR (env, peer); g->x_offset = g->y_offset = 0; gdk_threads_enter (); widget = GTK_WIDGET (ptr); g->drawable = (GdkDrawable *) widget->window; gdk_window_ref (g->drawable); g->cm = gtk_widget_get_colormap (widget); gdk_colormap_ref (g->cm); g->gc = gdk_gc_new (g->drawable); gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]); color = widget->style->fg[GTK_STATE_NORMAL]; gdk_threads_leave (); NSA_SET_PTR (env, obj, g); }
static void cvImageWidget_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask; //printf("cvImageWidget_realize\n"); g_return_if_fail (widget != NULL); g_return_if_fail (CV_IS_IMAGE_WIDGET (widget)); gtk_widget_set_realized(widget, TRUE); attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); widget->style = gtk_style_attach (widget->style, widget->window); gdk_window_set_user_data (widget->window, widget); gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE); }
static void pp_layout_nup_pageview_realize (GtkWidget *widget) { pp_Layout_NUp_PageView *pageview; GdkWindowAttr attributes; gint attributes_mask; g_return_if_fail (widget != NULL); g_return_if_fail (PP_IS_PAGEVIEW (widget)); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); pageview = PP_LAYOUT_NUP_PAGEVIEW (widget); attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); widget->style = gtk_style_attach (widget->style, widget->window); gdk_window_set_user_data (widget->window, widget); gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE); }
/* * CreateWidgetFromXpm * * Using the window information and the string with the icon color/data, * create a widget that represents the data. Once done, this widget can * be added to buttons or other container widgets. */ GtkWidget *CreateWidgetFromXpm (GtkWidget *window, gchar **xpm_data) { // got this code from Xmps GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; colormap = gtk_widget_get_colormap(window); gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, xpm_data); if (gdkpixmap == NULL) { printf("Error\n"); return (NULL); } #ifdef HAVE_GTK_2_0 pixmap = gtk_image_new_from_pixmap(gdkpixmap, mask); #else pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); #endif gtk_widget_show(pixmap); return pixmap; }
static void uni_image_view_realize (GtkWidget * widget) { UniImageView *view = UNI_IMAGE_VIEW (widget); gtk_widget_set_realized(widget, TRUE); GdkWindowAttr attrs; attrs.window_type = GDK_WINDOW_CHILD; attrs.x = widget->allocation.x; attrs.y = widget->allocation.y; attrs.width = widget->allocation.width; attrs.height = widget->allocation.height; attrs.wclass = GDK_INPUT_OUTPUT; attrs.visual = gtk_widget_get_visual (widget); attrs.colormap = gtk_widget_get_colormap (widget); attrs.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); int attr_mask = (GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); GdkWindow *parent = gtk_widget_get_parent_window (widget); widget->window = gdk_window_new (parent, &attrs, attr_mask); gdk_window_set_user_data (widget->window, view); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); view->void_cursor = gdk_cursor_new (GDK_ARROW); }
void gtk_codegraph_realize(GtkWidget *widget){ GdkWindowAttr attributes; guint attributes_mask; g_return_if_fail(widget != NULL); g_return_if_fail(GTK_IS_CODEGRAPH(widget)); GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new( gtk_widget_get_parent_window (widget), & attributes, attributes_mask); gdk_window_set_user_data(widget->window, widget ); widget->style = gtk_style_attach(widget->style, widget->window); gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); gtk_codegraph_create_backing_pixmap(GTK_CODEGRAPH(widget)); }
int clip_GTK_WIDGETGETCOLORMAP(ClipMachine * cm) { C_widget *cwid = _fetch_cw_arg(cm); GdkColormap *colormap; C_object *ccmap; CHECKCWID(cwid,GTK_IS_WIDGET); colormap = gtk_widget_get_colormap(cwid->widget); if (colormap) { ccmap = _register_object(cm,colormap,GDK_TYPE_COLORMAP,NULL, (coDestructor)gdk_object_colormap_destructor); if (ccmap) { ccmap->ref_count = 1; //ccmap->ref_count ++; //gdk_colormap_ref(colormap); _clip_mclone(cm,RETPTR(cm),&ccmap->obj); } else gdk_colormap_unref(colormap); } return 0; err: return 1; }
void vkb_button_set_bg(GtkWidget *widget, GtkStateType state, const GdkColor *color) { GtkVkbButton *button; GdkColormap *colormap; g_return_if_fail(GTK_IS_VKB_BUTTON(widget)); g_return_if_fail(state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE); button = GTK_VKB_BUTTON(widget); colormap = gtk_widget_get_colormap(GTK_WIDGET(button)); if (button->bgcolor[state].pixel != 0) { if (gdk_color_equal(&button->bgcolor[state], color)) goto done; gdk_colormap_free_colors(colormap, &button->bgcolor[state], 1); } button->bgcolor[state] = *color; button->bgcolor[state].pixel = 0; gdk_colormap_alloc_color(colormap, &button->bgcolor[state], FALSE, TRUE); done: return; }
static void gtk_mng_view_realize (GtkWidget * widget) { FUNCTION_ENTRY(); GdkWindowAttr attributes; gint attributes_mask; g_return_if_fail (IS_GTK_MNG_VIEW (widget)); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); }
static void hildon_color_chooser_realize (GtkWidget *widget) { HildonColorChooserPrivate *priv = HILDON_COLOR_CHOOSER_GET_PRIVATE (widget); g_assert (priv); GdkWindowAttr attributes; gint attributes_mask; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_WMCLASS; priv->event_window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); gdk_window_set_user_data (priv->event_window, widget); GTK_WIDGET_CLASS (parent_class)->realize (widget); }
/********************************************************************\ * gnc_set_label_color * * sets the color of the label given the value * * * * Args: label - gtk label widget * * value - value to use to set color * * Returns: none * \*******************************************************************/ void gnc_set_label_color(GtkWidget *label, gnc_numeric value) { gboolean deficit; GdkColormap *cm; GtkStyle *style; if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED)) return; cm = gtk_widget_get_colormap(GTK_WIDGET(label)); gtk_widget_ensure_style(GTK_WIDGET(label)); style = gtk_widget_get_style(GTK_WIDGET(label)); style = gtk_style_copy(style); deficit = gnc_numeric_negative_p (value); if (deficit) { gnc_get_deficit_color(&style->fg[GTK_STATE_NORMAL]); gdk_colormap_alloc_color(cm, &style->fg[GTK_STATE_NORMAL], FALSE, TRUE); } else style->fg[GTK_STATE_NORMAL] = style->black; gtk_widget_set_style(label, style); g_object_unref(style); }
static void plot_area_set_channel_colors(PlotArea* self, const gchar* colorstr) { GdkColormap* colormap = NULL; gchar** splitstr; unsigned int i; GdkColor default_color = {0, 0, 0, 0xFFFF}; // blue if (GTK_WIDGET_REALIZED(self)) { colormap = gtk_widget_get_colormap(GTK_WIDGET(self)); gdk_colormap_free_colors(colormap, self->colors, self->nColors); } g_free(self->colors); splitstr = g_strsplit(colorstr, ";", 0); self->nColors = g_strv_length(splitstr); self->colors = g_malloc0(self->nColors*sizeof(*(self->colors))); for (i=0; i<self->nColors; i++) { if (!gdk_color_parse(splitstr[i], self->colors+i)) self->colors[i] = default_color; } g_strfreev(splitstr); if (GTK_WIDGET_REALIZED(self)) { for (i=0; i<self->nColors; i++) gdk_colormap_alloc_color(colormap, self->colors+i, FALSE, TRUE); } }
static GtkWidget * zenity_create_monk (void) { GtkWidget *canvas_board; GnomeCanvasItem *canvas_item; GdkPixbuf *pixbuf; GdkColor color = { 0, 0xffff, 0xffff, 0xffff }; canvas_board = gnome_canvas_new (); gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0, ZENITY_CANVAS_X, ZENITY_CANVAS_Y); gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y); gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)), &color, FALSE, TRUE); gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color); pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL); canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), GNOME_TYPE_CANVAS_PIXBUF, "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0, "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0, "pixbuf", pixbuf, "anchor", GTK_ANCHOR_NW, NULL); zenity_create_clothes (canvas_board); return canvas_board; }
static gboolean colorlabel_drawing_area_expose_event_cb (GtkWidget *widget, GdkEventExpose *expose, gpointer data) { cairo_t *cr; GdkWindow *drawable = gtk_widget_get_window(widget); GtkAllocation allocation; gulong c = (gulong) GPOINTER_TO_INT(data); GdkColor color; INTCOLOR_TO_GDKCOLOR(c, color) gdk_colormap_alloc_color(gtk_widget_get_colormap(widget), &color, FALSE, TRUE); cr = gdk_cairo_create(drawable); gtk_widget_get_allocation(widget, &allocation); cairo_set_source_rgb(cr, 0., 0., 0.); cairo_rectangle(cr, 0, 0, allocation.width - 1, allocation.height - 1); cairo_stroke(cr); gdk_cairo_set_source_color(cr, &color); cairo_rectangle(cr, 1, 1, allocation.width - 2, allocation.height - 2); cairo_fill(cr); cairo_destroy(cr); return FALSE; }
void gmdb_form_add_icon(gchar *text) { GList *glist = NULL; GtkWidget *li; GtkWidget *label; GtkWidget *box; GtkWidget *pixmapwid; GdkPixmap *pixmap; GdkBitmap *mask; li = gtk_list_item_new (); box = gtk_hbox_new (FALSE,5); pixmap = gdk_pixmap_colormap_create_from_xpm( NULL, gtk_widget_get_colormap(app), &mask, NULL, "table.xpm"); /* a pixmap widget to contain the pixmap */ pixmapwid = gtk_pixmap_new( pixmap, mask ); gtk_widget_show( pixmapwid ); gtk_box_pack_start (GTK_BOX (box), pixmapwid, FALSE, TRUE, 0); label = gtk_label_new (text); gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(li), box); glist = g_list_append (glist, li); gtk_widget_show (label); gtk_widget_show_all (li); gtk_hlist_append_items(GTK_HLIST(form_hlist), glist); }
static void polygon_view_realize (GtkWidget *widget) { GdkWindowAttr attributes; GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_EXPOSURE_MASK; widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); }
/* INPUT * red, green, blue : 0-255 * OUTPUT * gc : */ void get_color (GtkWidget * widget, gint red, gint green, gint blue, GdkGC * gc) { GdkColor color; /* red, green, and blue are passed values, indicating the RGB triple * of the color we want to draw. Note that the values of the RGB components * within the GdkColor are taken from 0 to 65535, not 0 to 255. */ color.red = red * (65535 / 255); color.green = green * (65535 / 255); color.blue = blue * (65535 / 255); /* the pixel value indicates the index in the colormap of the color. * it is simply a combination of the RGB values we set earlier */ color.pixel = (gulong)(red * 65536 + green * 256 + blue); /* However, the pixel valule is only truly valid on 24-bit (TrueColor) * displays. Therefore, this call is required so that GDK and X can * give us the closest color available in the colormap */ gdk_color_alloc (gtk_widget_get_colormap (widget), &color); /* set the foreground to our color */ gdk_gc_set_foreground (gc, &color); }
static void browwidgetgtk_realize( GtkWidget *widget) { GdkWindowAttr attr; gint attr_mask; BrowWidgetGtk *brow; g_return_if_fail (widget != NULL); g_return_if_fail (IS_BROWWIDGETGTK( widget)); GTK_WIDGET_SET_FLAGS( widget, GTK_REALIZED); brow = BROWWIDGETGTK( widget); attr.x = widget->allocation.x; attr.y = widget->allocation.y; attr.width = widget->allocation.width; attr.height = widget->allocation.height; attr.wclass = GDK_INPUT_OUTPUT; attr.window_type = GDK_WINDOW_CHILD; attr.event_mask = gtk_widget_get_events( widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_SCROLL_MASK; attr.visual = gtk_widget_get_visual( widget); attr.colormap = gtk_widget_get_colormap( widget); attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new( widget->parent->window, &attr, attr_mask); widget->style = gtk_style_attach( widget->style, widget->window); gdk_window_set_user_data( widget->window, widget); gtk_style_set_background( widget->style, widget->window, GTK_STATE_ACTIVE); GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_FOCUS); if ( brow->is_navigator) { if ( !brow->brow_ctx) { BrowWidgetGtk *main_brow = (BrowWidgetGtk *) brow->main_brow_widget; brow->brow_ctx = main_brow->brow_ctx; brow->draw_ctx = main_brow->draw_ctx; ((FlowDrawGtk *)brow->draw_ctx)->init_nav( widget, brow->brow_ctx); } } else { if ( !brow->brow_ctx) { brow->draw_ctx = new FlowDrawGtk( widget, &brow->brow_ctx, brow_init_proc, brow->client_data, flow_eCtxType_Brow); } } }
void create_about_dialog(void) { char work[256]; GtkWidget *about_dialog; GtkWidget *main_widget; GtkWidget *ver_label; GtkWidget *ok_button; GtkWidget *neko_image; GdkColormap *colormap; GdkPixmap *neko_pixmap; GdkBitmap *mask; uninstall_idle_process(); about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(about_dialog), "About Neko Project II"); gtk_window_set_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(about_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(about_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 10); g_signal_connect(GTK_OBJECT(about_dialog), "destroy", GTK_SIGNAL_FUNC(about_destroy), NULL); main_widget = gtk_hbox_new(FALSE, 3); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(about_dialog), main_widget); colormap = gtk_widget_get_colormap(about_dialog); neko_pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &mask, NULL, (gchar **)np2_icon); if (neko_pixmap == NULL) g_error("Couldn't create replacement pixmap."); neko_image = gtk_image_new_from_pixmap(neko_pixmap, mask); g_object_unref(neko_pixmap); g_object_unref(mask); gtk_widget_show(neko_image); gtk_box_pack_start(GTK_BOX(main_widget), neko_image, FALSE, FALSE, 10); milstr_ncpy(work, "Neko Project II\n", sizeof(work)); milstr_ncat(work, NP2VER_CORE, sizeof(work)); #if defined(NP2VER_X11) milstr_ncat(work, NP2VER_X11, sizeof(work)); #endif ver_label = gtk_label_new(work); gtk_widget_show(ver_label); gtk_box_pack_start(GTK_BOX(main_widget), ver_label, FALSE, FALSE, 10); ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_box_pack_end(GTK_BOX(main_widget), ok_button, FALSE, TRUE, 0); g_signal_connect_swapped(GTK_OBJECT(ok_button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(about_dialog)); GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT); gtk_widget_grab_default(ok_button); gtk_widget_show_all(about_dialog); }
static void gtk_text_render_state_set_color (GtkTextRenderState *state, GdkGC *gc, GdkColor *color) { gdk_colormap_alloc_color (gtk_widget_get_colormap (state->widget), color, FALSE, TRUE); gdk_gc_set_foreground (gc, color); }
static void bytes_view_realize(GtkWidget *widget) { BytesView *bv; GdkWindowAttr attributes; GtkAllocation allocation; GdkWindow *win; #if GTK_CHECK_VERSION(3, 0, 0) GtkStyleContext *context; #endif _gtk_widget_set_realized_true(widget); bv = BYTES_VIEW(widget); gtk_widget_get_allocation(widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; #if !GTK_CHECK_VERSION(3, 0, 0) attributes.colormap = gtk_widget_get_colormap(widget); win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); #else win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL); #endif gtk_widget_set_window(widget, win); #if GTK_CHECK_VERSION(3, 8, 0) gtk_widget_register_window(widget, win); #else gdk_window_set_user_data(win, widget); #endif #if !GTK_CHECK_VERSION(3, 0, 0) /* XXX, check */ gdk_window_set_back_pixmap(win, NULL, FALSE); #endif #if GTK_CHECK_VERSION(3, 0, 0) context = gtk_widget_get_style_context(widget); gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW); /* gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY); */ #elif GTK_CHECK_VERSION(2, 20, 0) gtk_widget_style_attach(widget); #else widget->style = gtk_style_attach(widget->style, win); #endif bytes_view_ensure_layout(bv); }
void moz_container_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask = 0; MozContainer *container; GtkAllocation allocation; g_return_if_fail(IS_MOZ_CONTAINER(widget)); container = MOZ_CONTAINER(widget); gtk_widget_set_realized(widget, TRUE); /* create the shell window */ attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | #ifdef MOZ_PLATFORM_MAEMO GDK_POINTER_MOTION_HINT_MASK | #endif GDK_POINTER_MOTION_MASK); gtk_widget_get_allocation(widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); #if defined(MOZ_WIDGET_GTK2) attributes.colormap = gtk_widget_get_colormap (widget); #endif attributes.window_type = GDK_WINDOW_CHILD; attributes_mask |= GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y; #if defined(MOZ_WIDGET_GTK2) attributes_mask |= GDK_WA_COLORMAP; #endif gtk_widget_set_window(widget, gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask)); /* printf("widget->window is %p\n", (void *)widget->window); */ gdk_window_set_user_data (gtk_widget_get_window(widget), container); #if defined(MOZ_WIDGET_GTK2) widget->style = gtk_style_attach (widget->style, widget->window); #endif /* TODO GTK3? */ #if defined(MOZ_WIDGET_GTK2) /* set the back pixmap to None so that you don't end up with the gtk default which is BlackPixel */ gdk_window_set_back_pixmap (widget->window, NULL, FALSE); #endif }
int clip_GTK_EXTEXTSETLINEPIXMAPFROMXPM(ClipMachine * cm) { C_widget *extext = _fetch_cw_arg(cm); gint line = _clip_parni(cm, 2); ClipVar *cxpmd = _clip_par(cm, 3); GdkBitmap *mask; GdkPixmap *pixmap; GdkWindow *win = NULL; GdkColormap *colormap = NULL; char * * xpm_data = NULL; unsigned short i; CHECKCWID(extext, GTK_IS_EXTEXT); CHECKOPT(2, NUMERIC_t); CHECKOPT(3, ARRAY_t); if (_clip_parinfo(cm, 2) != NUMERIC_t) line = GTK_EXTEXT(extext->widget)->line_number; else line --; //printf("\nextext %d\n extext->widget %d\n extext->widget->window %d\n" , (extext->parent ), (extext->parent->widget), (extext->parent->widget->window)); //if (extext && extext->widget && extext->widget->window) //{ win = extext->widget->window; colormap = gtk_widget_get_colormap(extext->widget); // printf("\n win & colormap\n"); //} //else // colormap = gdk_colormap_get_system(); if (cxpmd->a.count > 0) { ClipVar *item; xpm_data = (char * *)calloc(sizeof(char*),cxpmd->a.count); for (i = 0; i < cxpmd->a.count; i++) { item = cxpmd->a.items + i; if (item->t.type == CHARACTER_t) { xpm_data[i] = (char*)calloc(1,item->s.str.len+1); strcpy(xpm_data[i], item->s.str.buf); //printf("xpm_data[i]=%s\n", xpm_data[i]); } } } pixmap = gdk_pixmap_colormap_create_from_xpm_d(win, colormap, &mask, NULL, xpm_data); gtk_extext_set_line_pixmap(GTK_EXTEXT(extext->widget), line, pixmap, mask); return 0; err: return 1; }
static void gtk_form_realize(GtkWidget *widget) { GList *tmp_list; GtkForm *form; GdkWindowAttr attributes; gint attributes_mask; g_return_if_fail(GTK_IS_FORM(widget)); form = GTK_FORM(widget); GTK_WIDGET_SET_FLAGS(form, GTK_REALIZED); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); gdk_window_set_user_data(widget->window, widget); attributes.x = 0; attributes.y = 0; attributes.event_mask = gtk_widget_get_events(widget); form->bin_window = gdk_window_new(widget->window, &attributes, attributes_mask); gdk_window_set_user_data(form->bin_window, widget); gtk_form_set_static_gravity(form->bin_window, TRUE); widget->style = gtk_style_attach(widget->style, widget->window); gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL); gdk_window_add_filter(widget->window, gtk_form_main_filter, form); gdk_window_add_filter(form->bin_window, gtk_form_filter, form); for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { GtkFormChild *child = tmp_list->data; gtk_form_attach_child_window(form, child); if (GTK_WIDGET_VISIBLE(child->widget)) gtk_form_realize_child(form, child); } }
void message_dialog (gchar *message) { GtkWidget *dialog; GtkWidget *vbox; GtkWidget *hbox; GdkColormap *colormap; GtkStyle *style; GdkBitmap *mask; GdkPixmap *pixmap; GtkWidget *image; GtkWidget *label; GtkWidget *button; dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); #if GTK_MAJOR_VERSION == 2 gtk_window_set_decorated (GTK_WINDOW(dialog), FALSE); #endif gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_container_set_border_width (GTK_CONTAINER(dialog), 12); vbox = gtk_vbox_new (FALSE, 10); gtk_container_add (GTK_CONTAINER(dialog), vbox); hbox = gtk_hbox_new (FALSE, 10); gtk_box_pack_start_defaults (GTK_BOX(vbox), hbox); style = gtk_widget_get_style (dialog); colormap = gtk_widget_get_colormap(dialog); pixmap = gdk_pixmap_colormap_create_from_xpm (dialog->window, colormap, &mask, NULL, "/etc/icons/error.xpm"); image = gtk_pixmap_new (pixmap, mask); gtk_box_pack_start_defaults (GTK_BOX(hbox), image); label = gtk_label_new (message); gtk_box_pack_start_defaults (GTK_BOX(hbox), label); button = gtk_button_new_with_label ("Fechar"); gtk_signal_connect (GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_box_pack_start_defaults (GTK_BOX(vbox), button); gtk_widget_show_all (dialog); gtk_widget_grab_focus (button); gtk_main (); gtk_widget_destroy (dialog); while (gtk_events_pending ()) gtk_main_iteration (); }
static void ddb_tabstrip_realize (GtkWidget *widget) { DdbTabStrip *darea = DDB_TABSTRIP (widget); GdkWindowAttr attributes; gint attributes_mask; if (!gtk_widget_get_has_window (widget)) { GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget); } else { gtk_widget_set_realized (widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; GtkAllocation a; gtk_widget_get_allocation (widget, &a); attributes.x = a.x; attributes.y = a.y; attributes.width = a.width; attributes.height = a.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); #if !GTK_CHECK_VERSION(3,0,0) attributes.colormap = gtk_widget_get_colormap (widget); #endif attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; #if !GTK_CHECK_VERSION(3,0,0) attributes_mask |= GDK_WA_COLORMAP; #endif GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window(widget, window); gdk_window_set_user_data (gtk_widget_get_window(widget), darea); #if !GTK_CHECK_VERSION(3,0,0) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); #else gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); #endif } ddb_tabstrip_send_configure (DDB_TABSTRIP (widget)); GtkTargetEntry entry = { .target = TARGET_PLAYITEMS, .flags = GTK_TARGET_SAME_APP, .info = TARGET_SAMEWIDGET }; gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); gtk_drag_dest_add_uri_targets (widget); gtk_drag_dest_set_track_motion (widget, TRUE); }
static void gwy_color_axis_realize(GtkWidget *widget) { GwyColorAxis *axis; GdkWindowAttr attributes; gint attributes_mask; GtkStyle *s; gwy_debug(""); g_return_if_fail(widget != NULL); g_return_if_fail(GWY_IS_COLOR_AXIS(widget)); GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); axis = GWY_COLOR_AXIS(widget); attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; attributes.visual = gtk_widget_get_visual(widget); attributes.colormap = gtk_widget_get_colormap(widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); gdk_window_set_user_data(widget->window, widget); widget->style = gtk_style_attach(widget->style, widget->window); /*set backgroun for white forever*/ s = gtk_style_copy(widget->style); s->bg_gc[0] = s->bg_gc[1] = s->bg_gc[2] = s->bg_gc[3] = s->bg_gc[4] = widget->style->white_gc; s->bg[0] = s->bg[1] = s->bg[2] = s->bg[3] = s->bg[4] = widget->style->white; gtk_style_set_background(s, widget->window, GTK_STATE_NORMAL); /*compute axis*/ gwy_color_axis_update(axis); }
static void plot_area_unrealize_callback(PlotArea* self) { GdkColormap* colormap = gtk_widget_get_colormap(GTK_WIDGET(self)); gdk_colormap_free_colors( colormap, self->colors, self->nColors); gdk_colormap_free_colors( colormap, &(self->grid_color), 1); g_object_unref( G_OBJECT(self->plotgc) ); }
/* compute a gdkcolor */ void setcolor(GtkWidget *widget, GdkColor *color, gint red,gint green,gint blue) { /* colors in GdkColor are taken from 0 to 65535, not 0 to 255. */ color->red = red * (65535/255); color->green = green * (65535/255); color->blue = blue * (65535/255); color->pixel = (gulong)(color->red*65536 + color->green*256 + color->blue); /* find closest in colormap, if needed */ gdk_color_alloc(gtk_widget_get_colormap(widget),color); }
void moz_drawingarea_create_windows (MozDrawingarea *drawingarea, GdkWindow *parent, GtkWidget *widget, GdkVisual *visual) { GdkWindowAttr attributes; gint attributes_mask = 0; /* create the clipping window */ attributes.event_mask = 0; attributes.x = 0; attributes.y = 0; attributes.width = 1; attributes.height = 1; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; if (!visual) { attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); } else { attributes.visual = visual; attributes.colormap = gdk_colormap_new(visual, 0); } attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_X | GDK_WA_Y; drawingarea->clip_window = gdk_window_new (parent, &attributes, attributes_mask); gdk_window_set_user_data(drawingarea->clip_window, widget); /* set the default pixmap to None so that you don't end up with the gtk default which is BlackPixel. */ gdk_window_set_back_pixmap(drawingarea->clip_window, NULL, FALSE); attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); /* create the inner window */ drawingarea->inner_window = gdk_window_new (drawingarea->clip_window, &attributes, attributes_mask); gdk_window_set_user_data(drawingarea->inner_window, widget); g_object_weak_ref(G_OBJECT(widget), nullify_widget_pointers, drawingarea); /* set the default pixmap to None so that you don't end up with the gtk default which is BlackPixel. */ gdk_window_set_back_pixmap(drawingarea->inner_window, NULL, FALSE); if (visual) { g_object_unref(attributes.colormap); } }