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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
/* ************************************************************************
Module: attributes.c
Author: Matt Simpson
Arlington, TX
matthewsimpson@home.com
Date: August, 2000
Description:
Allocates and sets styles for colors & fonts and
sets pixmaps.
Changes:
****************************************************************************
COPYRIGHT (C) 1999, 2000 Matt Simpson
GNU General Public License
See lexgui.c for full notice.
**************************************************************************** */
#include <stdio.h>
#include <gtk/gtk.h>
#include "lexgui.h"
#include "icons.h"
#include "logo.h"
#include "pbkgnd.h"
/* -------------------------------------------------------------------------
get_color() Returns a color.
------------------------------------------------------------------------- */
GdkColor get_color(int color)
{
static int init = 0;
GdkColor pick;
static GdkColor white = {0, 0xffff, 0xffff, 0xffff};
static GdkColor black = {0, 0x0000, 0x0000, 0x0000};
static GdkColor red = {0, 0xc8c8, 0x0000, 0x0000};
static GdkColor green = {0, 0x0000, 0x5a5a, 0x0000};
static GdkColor yellow = {0, 0xffff, 0xffff, 0x0000};
static GdkColor beige = {0, 0xffff, 0xf8f8, 0xf2f2};
static GdkColor brown1 = {0, 0xcccc, 0xc1c1, 0xb2b2};
static GdkColor brown2 = {0, 0xb5b5, 0xa7a7, 0x9999};
static GdkColor brown3 = {0, 0xf7f7, 0xe9e9, 0xdcdc};
static GdkColor brown4 = {0, 0xadad, 0xa0a0, 0x9393};
static GdkColor grey = {0, 0xcccc, 0xcccc, 0xcccc};
if(!init)
{
init = 1;
gdk_color_alloc(gdk_colormap_get_system(), &white);
gdk_color_alloc(gdk_colormap_get_system(), &black);
gdk_color_alloc(gdk_colormap_get_system(), &red);
gdk_color_alloc(gdk_colormap_get_system(), &green);
gdk_color_alloc(gdk_colormap_get_system(), &yellow);
gdk_color_alloc(gdk_colormap_get_system(), &brown1);
gdk_color_alloc(gdk_colormap_get_system(), &brown2);
gdk_color_alloc(gdk_colormap_get_system(), &brown3);
gdk_color_alloc(gdk_colormap_get_system(), &brown4);
gdk_color_alloc(gdk_colormap_get_system(), &grey);
}
switch (color)
{
case WHITE:
pick = white;
break;
case BLACK:
pick = black;
break;
case RED:
pick = red;
break;
case GREEN:
pick = green;
break;
case YELLOW:
pick = yellow;
break;
case BEIGE:
pick = beige;
break;
case BROWN1:
pick = brown1;
break;
case BROWN2:
pick = brown2;
break;
case BROWN3:
pick = brown3;
break;
case BROWN4:
pick = brown4;
break;
case GREY:
pick = grey;
break;
default:
pick = black;
}
return(pick);
}
/* -------------------------------------------------------------------------
set_color() Sets color of specified part in widget. Note the
default colors are set in main().
------------------------------------------------------------------------- */
void set_color(GtkWidget **w, int color, int section, int mode)
{
GtkStyle *newstyle;
newstyle = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(*w)));
switch (section)
{
case FG:
newstyle->fg[mode] = get_color(color);
break;
case BG:
newstyle->bg[mode] = get_color(color);
break;
case LIGHT:
newstyle->light[mode] = get_color(color);
break;
case DARK:
newstyle->dark[mode] = get_color(color);
break;
case MID:
newstyle->mid[mode] = get_color(color);
break;
case TEXT:
newstyle->text[mode] = get_color(color);
break;
case BASE:
newstyle->base[mode] = get_color(color);
break;
}
gtk_widget_set_style(GTK_WIDGET(*w), newstyle);
}
/* -------------------------------------------------------------------------
set_font() Sets font in widget. See below for predefined
fonts, selected by passing in the assigned int.
------------------------------------------------------------------------- */
void set_font(GtkWidget **w, int font_num)
{
GtkStyle *newstyle;
GdkFont *font;
gchar *szFont;
static gchar *font0 =
"-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1";
static gchar *font1 =
"-adobe-helvetica-medium-r-normal--8-80-75-75-p-46-iso8859-1";
static gchar *font2 =
"-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1";
static gchar *font3 =
"-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1";
static gchar *font4 =
"-adobe-helvetica-medium-r-normal--14-100-100-100-p-76-iso8859-1";
static gchar *font5 =
"-adobe-courier-medium-r-normal--17-120-100-100-m-100-iso8859-1";
static gchar *font6 =
"-adobe-courier-bold-r-normal--18-180-75-75-m-110-iso8859-1";
static gchar *font7 =
"-adobe-courier-medium-r-normal--14-100-100-100-m-90-iso8859-1";
static gchar *font8 =
"-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1";
switch(font_num)
{
case 1:
szFont = font1;
break;
case 2:
szFont = font2;
break;
case 3:
szFont = font3;
break;
case 4:
szFont = font4;
break;
case 5:
szFont = font5;
break;
case 6:
szFont = font6;
break;
case 7:
szFont = font7;
break;
case 8:
szFont = font8;
break;
default:
szFont = font0;
}
font = gdk_font_load(szFont);
newstyle = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(*w)));
newstyle->font = font;
gtk_widget_set_style(*w, newstyle);
}
/* -------------------------------------------------------------------------
create_nbpix() For creating pixmap widgets for the notebook pages
and popup windows the notebook buttons bring up.
------------------------------------------------------------------------- */
GtkWidget *create_nbpix(GtkWidget **topwin, int p)
{
GtkWidget *pixmapwidget = NULL;
gchar **xpm_ptr;
switch(p)
{
case 0:
xpm_ptr = (gchar **)printink_xpm; /* Install cartridges window */
break;
case 1:
xpm_ptr = (gchar **)car_xpm; /* Park cartridges */
break;
case 2:
xpm_ptr = (gchar **)drafting_xpm; /* Align window */
break;
case 3:
xpm_ptr = (gchar **)thermometer_xpm; /* Reset gauges window */
break;
case 4:
xpm_ptr = (gchar **)info_xpm; /* Print info */
break;
case 5:
xpm_ptr = (gchar **)paperoll_xpm; /* Clean cartridges */
break;
case 6:
xpm_ptr = (gchar **)info2_xpm; /* Query printer settings. */
break;
case 7:
xpm_ptr = (gchar **)qd_xpm; /* Set printer defaults -- dynamic. */
break;
case 8:
xpm_ptr = (gchar **)qf_xpm; /* Set printer defaults -- fixed. */
break;
case 9:
xpm_ptr = (gchar **)check_xpm; /* Printer Status. */
break;
case 10:
xpm_ptr = (gchar **)tp_xpm; /* Print test page. */
break;
case 11:
xpm_ptr = (gchar **)ps_xpm; /* Print Postscript font listing. */
break;
case 12:
xpm_ptr = (gchar **)pcl_xpm; /* Print PCL font listing. */
break;
case 13:
xpm_ptr = (gchar **)info_xpm; /* Print the settings page. */
break;
case 14:
xpm_ptr = (gchar **)pdemo_xpm; /* Print demo page. */
break;
case 15:
xpm_ptr = (gchar **)ttf_xpm; /* Print TTF test page. */
break;
default:
xpm_ptr = NULL;
}
if(xpm_ptr)
pixmapwidget = CreateWidgetFromXpm(*topwin, xpm_ptr);
return(pixmapwidget);
}
/* -------------------------------------------------------------------------
create_pix() For creating some other pixmap widgets.
------------------------------------------------------------------------- */
GtkWidget *create_pix(GtkWidget **topwin, int p)
{
GtkWidget *pixmapwidget = NULL;
gchar **xpm_ptr;
switch(p)
{
case 0:
xpm_ptr = (gchar **)hand_xpm;
break;
case 1:
xpm_ptr = (gchar **)t_xpm;
break;
case 2:
xpm_ptr = (gchar **)logo_xpm;
break;
case 3:
xpm_ptr = (gchar **)output_xpm;
break;
case 4:
xpm_ptr = (gchar **)printer_xpm;
break;
case 5:
xpm_ptr = (gchar **)disks_xpm;
break;
case 6:
xpm_ptr = (gchar **)pbkgnd_xpm;
break;
default:
xpm_ptr = NULL;
}
if(xpm_ptr)
pixmapwidget = CreateWidgetFromXpm(*topwin, xpm_ptr);
return(pixmapwidget);
}
|