1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/* Xsynth DSSI software synthesizer GUI
*
* Copyright (C) 2004, 2009 Sean Bolton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "gui_images.h"
#include "bitmap_about.xbm"
#include "bitmap_logo.xbm"
#include "bitmap_waveform0.xpm"
#include "bitmap_waveform1.xpm"
#include "bitmap_waveform2.xpm"
#include "bitmap_waveform3.xpm"
#include "bitmap_waveform4.xpm"
#include "bitmap_waveform5.xpm"
#include "bitmap_waveform6.xpm"
static char **waveform_xpms[7] = {
waveform0_xpm,
waveform1_xpm,
waveform2_xpm,
waveform3_xpm,
waveform4_xpm,
waveform5_xpm,
waveform6_xpm
};
static GdkPixmap *waveform_pixmaps[7];
/* This is a dummy pixmap we use when a pixmap can't be found. */
static char *dummy_pixmap_xpm[] = {
/* columns rows colors chars-per-pixel */
"1 1 1 1",
" c None",
/* pixels */
" "
};
/* 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;
}
/* window must be realized before you call this */
static GtkWidget *
create_halloween_colored_pixmap_from_data(GtkWidget *window,
const gchar *bitmap_data,
gint bitmap_width,
gint bitmap_height)
{
GdkColormap *colormap;
GdkColor fg_color;
GdkColor bg_color;
GdkPixmap *gdkpixmap;
GtkWidget *pixmap;
colormap = gtk_widget_get_colormap (window);
fg_color.red = 0;
fg_color.green = 0;
fg_color.blue = 0;
if (!gdk_color_alloc(colormap, &fg_color)) {
g_warning("couldn't allocate fg color");
}
bg_color.red = 0xfcfc;
bg_color.green = 0xa4a4;
bg_color.blue = 0;
if (!gdk_color_alloc(colormap, &bg_color)) {
g_warning("couldn't allocate bg color");
}
gdkpixmap = gdk_pixmap_create_from_data ((GdkWindow *)(window->window),
bitmap_data,
bitmap_width,
bitmap_height,
-1,
&fg_color,
&bg_color);
if (gdkpixmap == NULL) {
g_warning("error creating pixmap");
return create_dummy_pixmap (window);
}
pixmap = gtk_pixmap_new (gdkpixmap, NULL);
gdk_pixmap_unref (gdkpixmap);
return pixmap;
}
GtkWidget *
create_about_pixmap(GtkWidget *window)
{
return create_halloween_colored_pixmap_from_data(window,
bitmap_about_bits,
bitmap_about_width,
bitmap_about_height);
}
GtkWidget *
create_logo_pixmap(GtkWidget *window)
{
return create_halloween_colored_pixmap_from_data(window,
bitmap_logo_bits,
bitmap_logo_width,
bitmap_logo_height);
}
void
create_waveform_gdk_pixmaps(GtkWidget *widget)
{
GdkColormap *colormap;
GdkPixmap *gdkpixmap;
int i;
colormap = gtk_widget_get_colormap (widget);
for (i = 0; i <= 6; i++)
waveform_pixmaps[i] = NULL;
for (i = 0; i <= 6; i++) {
gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, NULL,
NULL, waveform_xpms[i]);
if (gdkpixmap == NULL) {
g_warning ("Error creating waveform pixmap %d", i);
gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, NULL,
NULL, dummy_pixmap_xpm);
}
if (gdkpixmap == NULL) {
g_error ("Couldn't create replacement pixmap.");
}
waveform_pixmaps[i] = gdkpixmap;
}
}
void
free_waveform_gdk_pixmaps(void)
{
int i;
for (i = 0; i <= 6; i++) {
if (waveform_pixmaps[i] != NULL)
gdk_pixmap_unref (waveform_pixmaps[i]);
waveform_pixmaps[i] = NULL;
}
}
GtkWidget *
create_waveform_pixmap(GtkWidget *widget)
{
GtkWidget *pixmap;
pixmap = gtk_pixmap_new (waveform_pixmaps[0], NULL);
return pixmap;
}
void
set_waveform_pixmap(GtkWidget *widget, int waveform)
{
if (waveform >=0 && waveform <= 6)
gtk_pixmap_set(GTK_PIXMAP(widget), waveform_pixmaps[waveform], NULL);
}
|