summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/wlib/gtklib/bitmap.c')
-rw-r--r--app/wlib/gtklib/bitmap.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/app/wlib/gtklib/bitmap.c b/app/wlib/gtklib/bitmap.c
index 7562e33..b1ff2ed 100644
--- a/app/wlib/gtklib/bitmap.c
+++ b/app/wlib/gtklib/bitmap.c
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
@@ -46,54 +46,57 @@ struct wBitmap_t {
*/
wControl_p
-wBitmapCreate( wWin_p parent, wWinPix_t x, wWinPix_t y, long options, const struct wIcon_t * iconP )
+wBitmapCreate( wWin_p parent, wWinPix_t x, wWinPix_t y, long options,
+ const struct wIcon_t * iconP )
{
wBitmap_p bt;
GdkPixbuf *pixbuf;
GtkWidget *image;
-
+
bt = wlibAlloc( parent, B_BITMAP, x, y, NULL, sizeof *bt, NULL );
bt->w = iconP->w;
bt->h = iconP->h;
bt->option = options;
-
+
/*
- * Depending on the platform, parent->widget->window might still be null
+ * Depending on the platform, parent->widget->window might still be null
* at this point. The window allocation should be forced before creating
* the pixmap.
*/
- if ( gtk_widget_get_window( parent->widget ) == NULL )
- gtk_widget_realize( parent->widget ); /* force allocation, if pending */
-
+ if ( gtk_widget_get_window( parent->widget ) == NULL ) {
+ gtk_widget_realize( parent->widget ); /* force allocation, if pending */
+ }
+
/* create the bitmap from supplied xpm data */
pixbuf = gdk_pixbuf_new_from_xpm_data( (const char **)iconP->bits );
g_object_ref_sink(pixbuf);
image = gtk_image_new_from_pixbuf( pixbuf );
gtk_widget_show( image );
g_object_unref( (gpointer)pixbuf );
-
+
bt->widget = gtk_fixed_new();
gtk_widget_show( bt->widget );
gtk_container_add( GTK_CONTAINER(bt->widget), image );
-
+
wlibComputePos( (wControl_p)bt );
wlibControlGetSize( (wControl_p)bt );
gtk_fixed_put( GTK_FIXED( parent->widget ), bt->widget, bt->realX, bt->realY );
-
+
return( (wControl_p)bt );
}
/**
* Create a two-tone icon
- *
+ *
* \param w IN width of icon
* \param h IN height of icon
* \param bits IN bitmap
- * \param color IN color
+ * \param color IN color
* \returns icon handle
*/
-wIcon_p wIconCreateBitMap( wWinPix_t w, wWinPix_t h, const char * bits, wDrawColor color )
+wIcon_p wIconCreateBitMap( wWinPix_t w, wWinPix_t h, const char * bits,
+ wDrawColor color )
{
wIcon_p ip;
ip = (wIcon_p)malloc( sizeof *ip );
@@ -101,7 +104,10 @@ wIcon_p wIconCreateBitMap( wWinPix_t w, wWinPix_t h, const char * bits, wDrawCol
ip->w = w;
ip->h = h;
ip->color = color;
- ip->bits = bits;
+ // Copy bits
+ int nBytes = ( ( w + 7 ) / 8 ) * h;
+ ip->bits = (char*)malloc( nBytes );
+ memcpy( (void*)ip->bits, bits, nBytes );
return ip;
}
@@ -125,7 +131,7 @@ wIcon_p wIconCreatePixMap( char *pm[] )
/**
* Set the color a two-tone icon
- *
+ *
* \param ip IN icon handle
* \param color IN color to use
*/