static GdkCursor * create_cursor(GdkWindow *window, const gchar *data, int width, int height, const gchar *mask, int hot_x, int hot_y) { GdkBitmap *dbit, *mbit; GdkColor black, white; GdkCursor *cursor; g_return_val_if_fail(window != NULL, NULL); dbit = gdk_bitmap_create_from_data(window, data, width, height); mbit = gdk_bitmap_create_from_data(window, mask, width, height); g_assert(dbit != NULL && mbit != NULL); gdk_color_black(gdk_window_get_colormap(window), &black); gdk_color_white(gdk_window_get_colormap(window), &white); cursor = gdk_cursor_new_from_pixmap(dbit, mbit, &white,&black, hot_x,hot_y); g_assert(cursor != NULL); gdk_bitmap_unref(dbit); gdk_bitmap_unref(mbit); return cursor; }
static void gtk_plot_gdk_draw_pixmap (GtkPlotPC *pc, GdkPixmap *pixmap, GdkBitmap *mask, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height, gdouble scale_x, gdouble scale_y) { GdkGC *gc; GdkPixmap *new_pixmap; GdkBitmap *new_mask = NULL; if(!GTK_PLOT_GDK(pc)->drawable) return; if(!GTK_PLOT_GDK(pc)->window) return; if(!GTK_PLOT_GDK(pc)->gc) return; gc = GTK_PLOT_GDK(pc)->gc; if(!gc) return; new_pixmap = scale_pixmap(GTK_PLOT_GDK(pc)->window, pixmap, scale_x, scale_y); if(mask) new_mask = scale_bitmap(GTK_PLOT_GDK(pc)->window, mask, scale_x, scale_y); gtk_plot_pc_clip_mask(pc, xdest, ydest, new_mask); gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc, new_pixmap, xsrc, ysrc, xdest, ydest, width*scale_x, height*scale_y); gtk_plot_pc_clip_mask(pc, xdest, ydest, NULL); if(new_mask) gdk_bitmap_unref(new_mask); gdk_pixmap_unref(new_pixmap); }
/* * 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 thumbview_thumbs_do (ThumbLoader * tl) { GdkPixmap *pixmap = NULL; GdkBitmap *mask = NULL; gfloat status; if (tl == NULL) return; if (thumbview->thumbs_stop) return; thumb_loader_to_pixmap (tl, &pixmap, &mask); zalbum_set_pixmap (ZALBUM (thumbview->album), thumbview->thumbs_count, pixmap, mask); if (pixmap) gdk_pixmap_unref (pixmap); if (mask) gdk_bitmap_unref (mask); status = (gfloat) thumbview->thumbs_count / ZALBUM (thumbview->album)->len; thumbview_thumbs_progressbar (status); }
static void free_cached_pixmap (struct cached_pixmap *cp) { gdk_pixmap_unref (cp->pix); if (cp->mask) gdk_bitmap_unref (cp->mask); g_free (cp); }
wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) gdk_pixmap_unref( m_pixmap ); if (m_bitmap) gdk_bitmap_unref( m_bitmap ); delete m_mask; #if wxUSE_PALETTE delete m_palette; #endif // wxUSE_PALETTE }
wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) gdk_pixmap_unref( m_pixmap ); if (m_bitmap) gdk_bitmap_unref( m_bitmap ); #ifdef __WXGTK20__ if (m_pixbuf) gdk_pixbuf_unref( m_pixbuf ); #endif delete m_mask; delete m_palette; }
void free_pixmap (struct pixmap *pixmap) { if (!pixmap) return; if (pixmap->pix) { gdk_pixmap_unref (pixmap->pix); pixmap->pix = NULL; } if (pixmap->mask) { gdk_bitmap_unref (pixmap->mask); pixmap->mask = NULL; } }
/* This is an internally used function to create pixmaps. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename) { gchar *found_filename = NULL; GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; GList *elem; if (!filename || !filename[0]) return create_dummy_pixmap (widget); /* We first try any pixmaps directories set by the application. */ elem = pixmaps_directories; while (elem) { found_filename = check_file_exists ((gchar*)elem->data, filename); if (found_filename) break; elem = elem->next; } /* If we haven't found the pixmap, try the source directory. */ if (!found_filename) { found_filename = check_file_exists ("../pixmaps", filename); } if (!found_filename) { g_warning (_("Couldn't find pixmap file: %s"), filename); return create_dummy_pixmap (widget); } colormap = gtk_widget_get_colormap (widget); gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, NULL, found_filename); if (gdkpixmap == NULL) { g_warning (_("Error loading pixmap file: %s"), found_filename); g_free (found_filename); return create_dummy_pixmap (widget); } g_free (found_filename); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
void build_example1(GtkWidget *active_plot) { GdkColormap *colormap; GdkPixmap *pixmap; GdkBitmap *mask; static gdouble px1[]={0., 0.2, 0.4, 0.6, 0.8, 1.0}; static gdouble py1[]={.2, .4, .5, .35, .30, .40}; static gdouble px2[]={0., 0.2, 0.4, 0.6, 0.8, 1.0}; static gdouble py2[]={.12, .22, .27, .12, .52, .62}; colormap = gdk_colormap_get_system(); pixmap = gdk_pixmap_colormap_create_from_xpm(NULL, colormap, &mask, NULL, "cloud.xpm"); dataset[0] = GTK_PLOT_DATA(gtk_plot_pixmap_new(pixmap, mask)); gtk_plot_add_data(GTK_PLOT(active_plot), dataset[0]); gtk_widget_show(GTK_WIDGET(dataset[0])); gtk_plot_data_set_points(dataset[0], px1, py1, px2, py2, 6); gtk_plot_data_set_legend(dataset[0], "Pixmap 1"); gdk_pixmap_unref(pixmap); gdk_bitmap_unref(mask); pixmap = gdk_pixmap_colormap_create_from_xpm(NULL, colormap, &mask, NULL, "suncloud.xpm"); dataset[1] = GTK_PLOT_DATA(gtk_plot_pixmap_new(pixmap, mask)); gtk_plot_add_data(GTK_PLOT(active_plot), dataset[1]); gtk_widget_show(GTK_WIDGET(dataset[1])); gtk_plot_data_set_points(dataset[1], px2, py2, NULL, NULL, 6); gtk_plot_data_set_legend(dataset[1], "Pixmap 2"); gdk_pixmap_unref(pixmap); gdk_bitmap_unref(mask); }
static GtkWidget * create_pixmap (GtkWidget *w, const char **data) { GtkWidget *pixmap; GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; colormap = gtk_widget_get_colormap (w); gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, const_cast<gchar **>(data)); pixmap = gtk_image_new_from_pixmap (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
void build_example1(GtkWidget *active_plot) { GdkPixmap *pixmap; GdkBitmap *mask; GdkColormap *colormap; colormap = gdk_colormap_get_system(); pixmap = gdk_pixmap_colormap_create_from_xpm(NULL, colormap, &mask, NULL, "sat.xpm"); gtk_plot_set_background_pixmap(GTK_PLOT(active_plot), pixmap); gdk_pixmap_unref(pixmap); gdk_bitmap_unref(mask); }
void create_cursors(void) { static GdkColor color1={0,0xFFFF,0xFFFF,0xFFFF}; static GdkColor color2={0,0x0000,0x0000,0x0000}; GdkBitmap *curs_pix, *msk_pix; curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)point_bits, point_width, point_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pointmsk_bits, pointmsk_width, pointmsk_height); cpoint = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 3,0); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pour_bits, pour_width, pour_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)pourmsk_bits, pourmsk_width, pourmsk_height); cfill = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 14, 13); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)cross_bits, cross_width, cross_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)crossmsk_bits, crossmsk_width, crossmsk_height); ccross = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 8,8); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); curs_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)select_bits, select_width, select_height); msk_pix = gdk_bitmap_create_from_data(NULL, (const gchar *)selectmsk_bits, selectmsk_width, selectmsk_height); cselect = gdk_cursor_new_from_pixmap(curs_pix, msk_pix, &color2, &color1, 0,select_height); gdk_bitmap_unref(curs_pix); gdk_bitmap_unref(msk_pix); }
/* This is an internally used function to create pixmaps. */ static GtkWidget* create_dummy_pixmap (GtkWidget *widget) { GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; colormap = gtk_widget_get_colormap (widget); gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask, NULL, dummy_pixmap_xpm); if (gdkpixmap == NULL) g_error ("Couldn't create replacement pixmap."); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
GtkWidget * create_pixmap (GtkWidget * widget, const gchar * file) { GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; GtkWidget *pixmap; GtkStyle *style; colormap = gtk_widget_get_colormap (app.main_window); style = gtk_widget_get_style (app.main_window); gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, NULL, file); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
/* * This is an internally used function to create pixmaps. */ GtkWidget * create_pixmap (GtkWidget * widget, const gchar * filename, gboolean gnome_pixmap) { GtkWidget *pixmap; GdkColormap *colormap; GdkPixmap *gdkpixmap; GdkBitmap *mask; gchar *pathname; if (!filename || !filename[0]) return create_dummy_pixmap (widget, gnome_pixmap); pathname = gnome_pixmap_file (filename); if (!pathname) { g_warning (_("Couldn't find pixmap file: %s"), filename); return create_dummy_pixmap (widget, gnome_pixmap); } if (gnome_pixmap) { pixmap = gnome_pixmap_new_from_file (pathname); g_free (pathname); return pixmap; } colormap = gtk_widget_get_colormap (widget); gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask, NULL, pathname); if (gdkpixmap == NULL) { g_warning (_("Couldn't create pixmap from file: %s"), pathname); g_free (pathname); return create_dummy_pixmap (widget, gnome_pixmap); } g_free (pathname); pixmap = gtk_pixmap_new (gdkpixmap, mask); gdk_pixmap_unref (gdkpixmap); gdk_bitmap_unref (mask); return pixmap; }
bool wxMask::Create( const wxBitmap& bitmap ) { if (m_bitmap) { gdk_bitmap_unref( m_bitmap ); m_bitmap = (GdkBitmap*) NULL; } if (!bitmap.Ok()) return FALSE; wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 ); if (!m_bitmap) return FALSE; GdkGC *gc = gdk_gc_new( m_bitmap ); gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); gdk_gc_unref( gc ); return TRUE; }
void update_cursor(void) { GdkPixmap *source, *mask; GdkColor fg = {0, 0, 0, 0}, bg = {0, 65535, 65535, 65535}; ui.is_sel_cursor = FALSE; if (GTK_WIDGET(canvas)->window == NULL) return; if (ui.cursor!=NULL) { gdk_cursor_unref(ui.cursor); ui.cursor = NULL; } if (ui.cur_item_type == ITEM_MOVESEL_VERT) ui.cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); else if (ui.cur_item_type == ITEM_MOVESEL) ui.cursor = gdk_cursor_new(GDK_FLEUR); else if (ui.toolno[ui.cur_mapping] == TOOL_PEN) { fg.red = (ui.cur_brush->color_rgba >> 16) & 0xff00; fg.green = (ui.cur_brush->color_rgba >> 8) & 0xff00; fg.blue = (ui.cur_brush->color_rgba >> 0) & 0xff00; source = gdk_bitmap_create_from_data(NULL, cursor_pen_bits, 16, 16); ui.cursor = gdk_cursor_new_from_pixmap(source, source, &fg, &bg, 7, 7); gdk_bitmap_unref(source); }
void Cursor::updateCursor() { XOJ_CHECK_TYPE(Cursor); MainWindow* win = control->getWindow(); if (!win) { return; } XournalView* xournal = win->getXournal(); if (!xournal) { return; } GdkCursor* cursor = NULL; if (this->busy) { cursor = gdk_cursor_new(GDK_WATCH); } else { ToolHandler* handler = control->getToolHandler(); ToolType type = handler->getToolType(); if (type == TOOL_HAND) { if (this->mouseDown) { cursor = gdk_cursor_new(GDK_FLEUR); } else { cursor = gdk_cursor_new(GDK_HAND1); } } else if(!this->insidePage) { // not inside page: so use default cursor } else if (this->selectionType) { switch (this->selectionType) { case CURSOR_SELECTION_MOVE: cursor = gdk_cursor_new(GDK_FLEUR); break; case CURSOR_SELECTION_TOP_LEFT: cursor = gdk_cursor_new(GDK_TOP_LEFT_CORNER); break; case CURSOR_SELECTION_TOP_RIGHT: cursor = gdk_cursor_new(GDK_TOP_RIGHT_CORNER); break; case CURSOR_SELECTION_BOTTOM_LEFT: cursor = gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER); break; case CURSOR_SELECTION_BOTTOM_RIGHT: cursor = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER); break; case CURSOR_SELECTION_LEFT: case CURSOR_SELECTION_RIGHT: cursor = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW); break; case CURSOR_SELECTION_TOP: case CURSOR_SELECTION_BOTTOM: cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); break; } } else if (type == TOOL_PEN) { cursor = getPenCursor(); } else if (type == TOOL_ERASER) { GdkColor bg = { 0, 65535, 65535, 65535 }; GdkColor fg = { 0, 0, 0, 0 }; GdkPixmap* source = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HIGLIGHTER_BITS, 16, 16); GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HILIGHTER_MASK, 16, 16); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 7, 7); gdk_bitmap_unref(source); gdk_bitmap_unref(mask); } else if (type == TOOL_HILIGHTER) { GdkColor fg = { 0, 0, 0, 0 }; GdkColor bg = handler->getGdkColor(); GdkPixmap* source = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HIGLIGHTER_BITS, 16, 16); GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, (gchar*) CURSOR_HILIGHTER_MASK, 16, 16); cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, 7, 7); gdk_bitmap_unref(source); gdk_bitmap_unref(mask); } else if (type == TOOL_TEXT) { if (this->invisible) { cursor = gdk_cursor_new(GDK_BLANK_CURSOR); } else { cursor = gdk_cursor_new(GDK_XTERM); } } else if (type == TOOL_IMAGE) { // No special cursor needed } else if (type == TOOL_VERTICAL_SPACE) { if (this->mouseDown) { cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); } } else if (type != TOOL_SELECT_OBJECT) // other selections are handled before anyway, because you can move a selection with every tool { cursor = gdk_cursor_new(GDK_TCROSS); } } if (gtk_widget_get_window(xournal->getWidget())) { gdk_window_set_cursor(gtk_widget_get_window(xournal->getWidget()), cursor); gtk_widget_set_sensitive(xournal->getWidget(), !this->busy); } gdk_display_sync(gdk_display_get_default()); if (cursor) { gdk_cursor_unref(cursor); } }
GtkWidget * gw_window_box_about_create ( GtkWindow *window) { /* This window must be single, this property shouldn't be changed */ static GtkWidget *w = NULL; GdkColor transparent = {0}; GtkWidget *vbox_about = NULL; GtkWidget *label = NULL; GtkWidget *event_box = NULL; GtkWidget *logo = NULL; GdkPixmap *pix_gw_logo = NULL; GdkBitmap *msk_gw_logo = NULL; gchar * text = NULL; gchar * text_utf8 = NULL; GdkCursor *cursor = NULL; gchar * os_version = NULL; #ifdef GW_DEBUG_GUI_COMPONENT g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); #endif if ( !w ) { /* GWhere logo loading */ pix_gw_logo = gdk_pixmap_create_from_xpm_d ( GTK_WIDGET ( window)->window, &msk_gw_logo, &transparent, GWhere_logo_xpm); w = gtk_window_new ( GTK_WINDOW_TOPLEVEL); gtk_window_set_modal ( GTK_WINDOW ( w), TRUE); gtk_window_set_transient_for ( GTK_WINDOW ( w), window); gtk_window_set_position ( GTK_WINDOW ( w), GTK_WIN_POS_CENTER); g_strdup_to_gtk_text ( _( "About"), text_utf8); gtk_window_set_title ( GTK_WINDOW ( w), text_utf8); g_free ( text_utf8); gtk_signal_connect ( GTK_OBJECT ( w), "destroy", GTK_SIGNAL_FUNC ( gw_window_box_about_destroy), &w); gtk_signal_connect ( GTK_OBJECT ( w), "delete-event", GTK_SIGNAL_FUNC ( gtk_widget_destroy), NULL); /* See more bottom the call of gdk_pixmap_unref() and gdk_bitmap_unref(). gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_WINDOW_ABOUT_LOGO_PIX, pix_gw_logo, ( GtkDestroyNotify)gdk_pixmap_unref); gtk_object_set_data_full ( GTK_OBJECT ( w), GW_REF_WINDOW_ABOUT_LOGO_BIT, msk_gw_logo, ( GtkDestroyNotify)gdk_bitmap_unref); */ gtk_container_set_border_width ( GTK_CONTAINER ( w), 5); gtk_widget_set_usize ( w, 360, 340); event_box = gtk_event_box_new ( ); gtk_container_add ( GTK_CONTAINER ( w), event_box); vbox_about = gtk_vbox_new ( FALSE, 0); gtk_container_add ( GTK_CONTAINER ( event_box), vbox_about); logo = gtk_pixmap_new ( pix_gw_logo, msk_gw_logo); gdk_pixmap_unref ( pix_gw_logo); gdk_bitmap_unref ( msk_gw_logo); gtk_container_add ( GTK_CONTAINER ( vbox_about), logo); /* Doesn't encode to UTF-8 substring because the result string will be encoded. */ gw_os_get_version_str ( &os_version); text = g_strconcat ( PROJECT_NAME, "-", VERSION, _( "\nRemovable media catalog management\nBy Sebastien LECACHEUR\n\[email protected]\nhttp://www.gwhere.org\n"), _( "GWhere allows you to manage a database of your CDs and other removable media (hard disks, floppy drive, Zip drive, CD- ROM, etc...). With GWhere it's easy to browse your CDs or to make a quick search without needing to insert all of your CDs in the drive and search them one by one."), _( "\n\nRuns under "), os_version, NULL); if ( os_version != NULL ) { g_free ( os_version); } g_strdup_to_gtk_text ( text, text_utf8); g_free ( text); label = gtk_label_new ( text_utf8); g_free ( text_utf8); gtk_label_set_justify ( GTK_LABEL ( label), GTK_JUSTIFY_FILL); gtk_label_set_line_wrap ( GTK_LABEL ( label), TRUE); gtk_container_add ( GTK_CONTAINER ( vbox_about), label); /* Should it be mandatory? Yes, in order to get the good window size to displaying all informations. */ gtk_widget_set_usize ( label, 330, 280); gtk_widget_set_events ( event_box, GDK_BUTTON_PRESS_MASK); gtk_signal_connect_object ( GTK_OBJECT ( event_box), "button_press_event", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w)); if ( (cursor = gdk_cursor_new ( GDK_HAND2)) != NULL) { /* Fix bug : event_box->window is NULL with GTK-2.0. */ if ( GTK_WIDGET ( event_box)->window != NULL ) { gdk_window_set_cursor ( GTK_WIDGET ( event_box)->window, cursor); #ifdef HAVE_GTK20 gdk_cursor_unref ( cursor); #endif } else { #ifdef GW_DEBUG_GUI_COMPONENT g_warning ( "gtk_event_box->window is NULL!!"); #endif gdk_cursor_destroy ( cursor); } } } if ( !GTK_WIDGET_VISIBLE ( w) ) { #ifdef GW_DEBUG_GUI_COMPONENT g_print ( "*** GW - %s (%d) :: %s() : show the window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); #endif gtk_widget_show_all ( w); } else { #ifdef GW_DEBUG_GUI_COMPONENT g_print ( "*** GW - %s (%d) :: %s() : destroy the window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); #endif g_warning ( "gw_window_box_about is already displayed!! Destroying it..."); gtk_widget_destroy ( w); } return w; }
bool wxMask::Create( const wxBitmap& bitmap, const wxColour& colour ) { if (m_bitmap) { gdk_bitmap_unref( m_bitmap ); m_bitmap = (GdkBitmap*) NULL; } wxImage image = bitmap.ConvertToImage(); if (!image.Ok()) return FALSE; m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 ); GdkGC *gc = gdk_gc_new( m_bitmap ); GdkColor color; color.red = 65000; color.green = 65000; color.blue = 65000; color.pixel = 1; gdk_gc_set_foreground( gc, &color ); gdk_gc_set_fill( gc, GDK_SOLID ); gdk_draw_rectangle( m_bitmap, gc, TRUE, 0, 0, image.GetWidth(), image.GetHeight() ); unsigned char *data = image.GetData(); int index = 0; unsigned char red = colour.Red(); unsigned char green = colour.Green(); unsigned char blue = colour.Blue(); GdkVisual *visual = wxTheApp->GetGdkVisual(); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if (bpp == 15) { red = red & 0xf8; green = green & 0xf8; blue = blue & 0xf8; } else if (bpp == 16) { red = red & 0xf8; green = green & 0xfc; blue = blue & 0xf8; } else if (bpp == 12) { red = red & 0xf0; green = green & 0xf0; blue = blue & 0xf0; } color.red = 0; color.green = 0; color.blue = 0; color.pixel = 0; gdk_gc_set_foreground( gc, &color ); for (int j = 0; j < image.GetHeight(); j++) { int start_x = -1; int i; for (i = 0; i < image.GetWidth(); i++) { if ((data[index] == red) && (data[index+1] == green) && (data[index+2] == blue)) { if (start_x == -1) start_x = i; } else { if (start_x != -1) { gdk_draw_line( m_bitmap, gc, start_x, j, i-1, j ); start_x = -1; } } index += 3; } if (start_x != -1) gdk_draw_line( m_bitmap, gc, start_x, j, i, j ); } gdk_gc_unref( gc ); return TRUE; }
wxMask::~wxMask() { if (m_bitmap) gdk_bitmap_unref( m_bitmap ); }
static gint thumbview_thumbs_next (void) { ZAlbumCell *cell; thumbview->thumbs_count++; if (thumbview->thumbs_stop) { thumbview_thumbs_cleanup (); return FALSE; } if (thumbview->thumbs_count < ZALBUM (thumbview->album)->len) { gchar *path; cell = ZLIST_CELL_FROM_INDEX (ZLIST (thumbview->album), thumbview->thumbs_count); path = g_strdup (cell->name); if (file_type_is_movie (cell->name)) { GdkPixbuf *pixbuf = NULL; GdkPixmap *pixmap; GdkBitmap *mask; gchar *cache_dir; mode_t mode = 0755; gfloat status; cache_dir = cache_get_location (CACHE_THUMBS, path, FALSE, NULL, &mode); if (cache_ensure_dir_exists (cache_dir, mode)) { gchar *cache_path; cache_path = g_strconcat (cache_dir, "/", g_basename (cell->name), PORNVIEW_CACHE_THUMB_EXT, NULL); #ifdef USE_GTK2 pixbuf = gdk_pixbuf_new_from_file (cache_path, NULL); #else pixbuf = gdk_pixbuf_new_from_file (cache_path); #endif if (pixbuf) { gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); zalbum_set_pixmap (ZALBUM (thumbview->album), thumbview->thumbs_count, pixmap, mask); if (pixmap) gdk_pixmap_unref (pixmap); if (mask) gdk_bitmap_unref (mask); gdk_pixbuf_unref (pixbuf); } else { pixbuf = image_get_video_pixbuf (); gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); zalbum_set_pixmap (ZALBUM (thumbview->album), thumbview->thumbs_count, pixmap, mask); if (pixmap) gdk_pixmap_unref (pixmap); if (mask) gdk_bitmap_unref (mask); gdk_pixbuf_unref (pixbuf); } g_free (cache_path); } g_free (cache_dir); g_free (path); status = (gfloat) thumbview->thumbs_count / ZALBUM (thumbview->album)->len; thumbview_thumbs_progressbar (status); while (gtk_events_pending ()) gtk_main_iteration (); thumbview_thumbs_do (NULL); return TRUE; } else { thumb_loader_free (thumbview->thumbs_loader); thumbview->thumbs_loader = thumb_loader_new (path, 100, 100); g_free (path); thumb_loader_set_error_func (thumbview->thumbs_loader, cb_thumbview_thumbs_error, NULL); if (!thumb_loader_start (thumbview->thumbs_loader, cb_thumbview_thumbs_done, NULL)) { thumbview_thumbs_do (NULL); return TRUE; } } return FALSE; } else { thumbview_thumbs_cleanup (); return FALSE; } return TRUE; }
bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { style = style | wxCAPTION; if ((style & wxCAPTION) || (style & wxTINY_CAPTION)) m_miniTitle = 13; m_miniEdge = 3; m_isDragging = false; m_oldX = -1; m_oldY = -1; m_diffX = 0; m_diffY = 0; wxFrame::Create( parent, id, title, pos, size, style, name ); if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); } if ((style & wxSYSTEM_MENU) && ((style & wxCAPTION) || (style & wxTINY_CAPTION))) { GdkBitmap *mask = NULL; GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d ( wxGetRootWindow()->window, &mask, NULL, (char **)cross_xpm ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); gdk_bitmap_unref( mask ); gdk_pixmap_unref( pixmap ); gtk_widget_show( pw ); GtkWidget *close_button = gtk_button_new(); gtk_container_add( GTK_CONTAINER(close_button), pw ); gtk_pizza_put( GTK_PIZZA(m_mainWidget), close_button, size.x-16, 4, 11, 11 ); gtk_widget_show( close_button ); gtk_signal_connect( GTK_OBJECT(close_button), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); } /* these are called when the borders are drawn */ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); /* these are required for dragging the mini frame around */ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_release_event", GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_mainWidget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); return true; }
static void gtk_plot_gdk_draw_string (GtkPlotPC *pc, gint tx, gint ty, gint angle, const GdkColor *fg, const GdkColor *bg, gboolean transparent, gint border, gint border_space, gint border_width, gint shadow_width, const gchar *font_name, gint font_height, GtkJustification just, const gchar *text) { GdkBitmap *text_bitmap; GdkPixmap *text_pixmap; GdkBitmap *text_mask; GdkImage *image; GdkGC *gc, *bitmap_gc; GdkColormap *colormap; GdkColor white, black, mask_color; GList *family = NULL; gint y0; gint old_width, old_height; gboolean bold, italic; gint fontsize; gint ascent, descent; gint numf; gint xp = 0, yp = 0; gint width, height; gint x, y; gint i; GdkFont *font, *latin_font, *dfont; GtkPSFont *psfont, *base_psfont, *latin_psfont; gchar subs[2], insert_char; GdkWChar *aux, *wtext, *lastchar = NULL, *xaux; gchar num[4]; if(!GTK_PLOT_GDK(pc)->drawable) return; if(!GTK_PLOT_GDK(pc)->window) return; if(!GTK_PLOT_GDK(pc)->gc) return; if(!text || strlen(text) == 0) return; colormap = gdk_colormap_get_system (); gc = GTK_PLOT_GDK(pc)->gc; if(!gc) return; gtk_plot_text_get_size(text, angle, font_name, font_height, &width, &height, &ascent, &descent); if(height == 0 || width == 0) return; old_width = width; old_height = height; if(angle == 90 || angle == 270) { old_width = height; old_height = width; } gtk_psfont_get_families(&family, &numf); font = gtk_psfont_get_gdkfont(font_name, font_height); base_psfont = psfont = gtk_psfont_get_font(font_name); italic = psfont->italic; bold = psfont->bold; fontsize = font_height; x = 0; y0 = y = ascent; if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } else { latin_psfont = NULL; latin_font = NULL; } i = strlen(text) + 2; aux = wtext = g_malloc0(sizeof(GdkWChar) * i); gdk_mbstowcs(wtext, text, i - 1); /* initializing text bitmap - ajd */ text_bitmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, old_width, old_height, 1); bitmap_gc = gdk_gc_new(text_bitmap); gdk_color_white (colormap, &white); gdk_gc_set_foreground(bitmap_gc, &white); gdk_draw_rectangle(text_bitmap, bitmap_gc, TRUE, 0, 0, -1, -1); gdk_color_black (colormap, &black); gdk_gc_set_foreground(bitmap_gc, &black); while(aux && *aux != '\0' && *aux != '\n'){ if(*aux == '\\'){ aux++; switch(*aux){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '9': psfont = gtk_psfont_find_by_family((gchar *)g_list_nth_data(family, *aux-'0'), italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } aux++; break; case '8': case 'g': psfont = gtk_psfont_find_by_family("Symbol", italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } aux++; break; case 'B': bold = TRUE; psfont = gtk_psfont_find_by_family(psfont->family, italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'x': xaux = aux + 1; for (i=0; i<3; i++){ if (xaux[i] >= '0' && xaux[i] <= '9') num[i] = xaux[i]; else break; } if (i < 3){ aux++; break; } num[3] = '\0'; insert_char = (gchar)atoi(num); subs[0] = insert_char; subs[1] = '\0'; /* \xNNN is always outputted with latin fonts. */ dfont = (psfont->i18n_latinfamily != NULL) ? latin_font : font; gdk_draw_string (text_bitmap, dfont, bitmap_gc, x, y, subs); x += gdk_char_width(font, insert_char); aux += 4; lastchar = aux - 1; break; case 'i': italic = TRUE; psfont = gtk_psfont_find_by_family(psfont->family, italic, bold); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'S': case '^': fontsize = (int)((gdouble)fontsize * 0.6 + 0.5); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y -= font->ascent; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 's': case '_': fontsize = (int)((gdouble)fontsize * 0.6 + 0.5); gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y += font->descent; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case '+': fontsize += 3; gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case '-': fontsize -= 3; gdk_font_unref(font); font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'N': psfont = base_psfont; gdk_font_unref(font); fontsize = font_height; font = gtk_psfont_get_gdkfont(psfont->psname, fontsize); y = y0; italic = psfont->italic; bold = psfont->bold; if (latin_font) { gdk_font_unref(latin_font); latin_font = NULL; } if (psfont->i18n_latinfamily) { latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic, bold); latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize); } aux++; break; case 'b': if (lastchar) { gtk_psfont_get_char_size(psfont, font, latin_font, *lastchar, &i, NULL, NULL); x -= i; if (lastchar == wtext) lastchar = NULL; else lastchar--; } else { gtk_psfont_get_char_size(psfont, font, latin_font, 'X', &i, NULL, NULL); x -= i; } aux++; break; default: if(aux && *aux != '\0' && *aux !='\n'){ x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y, psfont, font, latin_font, *aux); lastchar = aux; aux++; } break; } } else { if(aux && *aux != '\0' && *aux !='\n'){ x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y, psfont, font, latin_font, *aux); lastchar = aux; aux++; } } } g_free(wtext); /* initializing clip mask bitmap - ajd */ text_mask = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, 1); mask_color = white; mask_color.pixel = 0; gdk_gc_set_foreground(bitmap_gc, &mask_color); gdk_draw_rectangle(text_mask, bitmap_gc, TRUE, 0, 0, -1, -1); mask_color = black; mask_color.pixel = 1; gdk_gc_set_foreground(bitmap_gc, &mask_color); /* performing text rotation and saving it onto clip mask bitmap - ajd */ image = gdk_image_get(text_bitmap, 0, 0, old_width, old_height); for(y = 0; y < old_height; y++) for(x = 0; x < old_width; x++) { if( black.pixel == gdk_image_get_pixel(image, x, y) ){ switch(angle){ case 0: xp = x; yp = y; break; case 90: xp = y; yp = old_width - x; break; case 180: xp = old_width - x; yp = old_height - y; break; case 270: xp = old_height - y; yp = x; break; } gdk_draw_point(text_mask, bitmap_gc, xp, yp); } } gdk_image_destroy(image); /* initializing text pixmap - ajd */ text_pixmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, -1); gdk_gc_set_foreground(gc, (GdkColor *) bg); gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1); gdk_gc_set_foreground(gc, (GdkColor *) fg); /* copying clip mask bitmap onto text pixmap - ajd */ gdk_gc_set_clip_mask(gc, text_mask); gdk_gc_set_clip_origin(gc, 0, 0); gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1); gdk_gc_set_clip_mask(gc, NULL); gtk_plot_text_get_area(text, angle, just, font_name, font_height, &x, &y, &width, &height); tx += x; ty += y; if(transparent){ gdk_gc_set_clip_mask (gc, text_mask); gdk_gc_set_clip_origin (gc, tx, ty); } else { gdk_gc_set_foreground(gc, (GdkColor *) bg); gtk_plot_pc_draw_rectangle(pc, TRUE, tx - border_space, ty - border_space, width + 2*border_space, height + 2*border_space); } gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc, text_pixmap, 0, 0, tx, ty, -1, -1); gdk_gc_set_clip_mask(gc, NULL); gdk_pixmap_unref(text_pixmap); gdk_bitmap_unref(text_mask); gdk_font_unref(font); if (latin_font) gdk_font_unref(latin_font); gdk_gc_unref(bitmap_gc); gdk_pixmap_unref(text_bitmap); /* border */ gdk_gc_set_foreground(gc, (GdkColor *) fg); gtk_plot_pc_set_dash(pc, 0, NULL, 0); gtk_plot_pc_set_lineattr(pc, border_width, 0, 0, 0); switch(border){ case GTK_PLOT_BORDER_SHADOW: gtk_plot_pc_draw_rectangle(pc, TRUE, tx - border_space + shadow_width, ty + height + border_space, width + 2 * border_space, shadow_width); gtk_plot_pc_draw_rectangle(pc, TRUE, tx + width + border_space, ty - border_space + shadow_width, shadow_width, height + 2 * border_space); case GTK_PLOT_BORDER_LINE: gtk_plot_pc_draw_rectangle(pc, FALSE, tx - border_space, ty - border_space, width + 2*border_space, height + 2*border_space); case GTK_PLOT_BORDER_NONE: default: break; } return; }