This is a multi-part message in MIME format.
--------------F860D8BC0A0A9D2C7F4B09CC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello Danny.
Here is the source code.
I removed irrelevant parts and added comments for easy reading:
Michael
Danny G. Holstein wrote:
> I've experimented with colors a bit in xforms and have been able to
use decent
> work arounds to get the colors I want for applications. The problem
as I see
> it is that what I like for a color isn't necessarily what an end user
likes to
> see. Some end users are nearly color blind and some are color
sensitive, some
> have old eyes and need different fonts to see better.
--------------F860D8BC0A0A9D2C7F4B09CC
Content-Type: text/plain; charset=us-ascii; name="temp.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="temp.c"
static Colormap colour_map;
Display disp;
static XrmOptionDescRec xoptions[] =
{
{ "-bgcol", "*.colour.bg", XrmoptionSepArg, (XPointer)NULL },
{ "-topcol", "*.colour.topfg", XrmoptionSepArg, (XPointer)NULL },
{ "-btmcol", "*.colour.btmfg", XrmoptionSepArg, (XPointer)NULL },
};
static const short noptions = sizeof(xoptions)/sizeof(XrmOptionDescRec);
/* This small function will get a colour from resource data base,
check it and convert to RGB */
static Status get_resource_colour(const char *resname,
const char *default_colour, XColor *xcol_ptr)
{
char colour_name[256];
Status rc;
fl_get_resource(resname, ClassName, FL_STRING,
default_colour, colour_name, 255);
trim_line(colour_name); // My function for removing leading and trailing spaces
rc = XParseColor(disp, colour_map, colour_name, xcol_ptr);
if (!rc)
{ fprintf (stderr, "Invalid colour: '%s'. Default colour '%s' substituted.\n",
colour_name, default_colour);
rc = XParseColor(disp, colour_map, default_colour, xcol_ptr);
}
return rc;
}
int start_xformsing(int *argc, char *argv[])
{
int r, g, b;
FL_STATE *fls;
XColor xcol;
/* These are the only standard colours needed for the application
All the rest will be set to black */
const char used_cols[] = {FL_SPRINGGREEN, FL_INDIANRED, FL_DEEPPINK,
FL_GREEN, FL_RED, FL_DARKGOLD, 0 };
/* Clear the redundant colours */
for (r=0; r<FL_FREE_COL1; r++)
if (strchr(used_cols, (char)r) == NULL)
fl_set_icm_color(r, 0, 0, 0);
/* Now we are ready for fl_initialize */
fl_initialize(argc, argv, ClassName, xoptions, noptions);
/* The resources are ready. Go and collect them! */
/* Hold on! We need a small preamble */
disp = fl_get_display();
if (disp == NULL) return 0;
fls = fl_state + ScreenVC;
colour_map = fls->colormap;
/* Get the BG colour */
fl_get_resource("colour.bg", ClassName, FL_STRING, DEFAULT_XCOLOUR_BKGR, colourname, 255);
trim_line(colourname); /* my function to remove spaces at start and end */
/* Get the BG colour and make the border consistent */
if (get_resource_colour("colour.bg", DEFAULT_XCOLOUR_BKGR, &xcol))
{ r = xcol.red >> 8;
g = xcol.green >> 8;
b = xcol.blue >> 8;
/* Box border */
fl_mapcolor(FL_TOP_BCOL, r, g, b);
fl_mapcolor(FL_LEFT_BCOL, r, g, b);
fl_mapcolor(FL_BOTTOM_BCOL, r/2, g/2, b/2);
fl_mapcolor(FL_RIGHT_BCOL, r/2, g/2, b/2);
/* Box face */
fl_mapcolor(FL_COL1, r*2/3, g*2/3, b*2/3);
/* 'Light' for light/check buttons, and
current line for browsers */
fl_mapcolor(FL_YELLOW, r/2, g/2, b/2);
/* Button highlight colour (used on enter focus) */
r = r*4/3; g = g*4/3; b=b*4/3;
if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
fl_mapcolor(FL_MCOL, r, g, b);
/* Finita la comedia! */
}
/* Foreground (text) colour is taken easier */
if (get_resource_colour("colour.fg", DEFAULT_XCOLOUR_FKGR, &xcol))
fl_mapcolor(FL_BLACK, xcol.red >> 8, xcol.green >> 8, xcol.blue >> 8);
}
--------------F860D8BC0A0A9D2C7F4B09CC--
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/