Commit 1aea7663 authored by David Brown's avatar David Brown
Browse files

Added runtime detection of editable colours for fake page display.

parent f8a39c01
......@@ -1448,11 +1448,13 @@ static int choices_redraw_fakepage_handler(int eventcode, WimpPollBlock * event,
_kernel_oserror * e = NULL;
WimpRedrawWindowBlock block;
WimpGetWindowStateBlock state;
int more, ypos, xtarget, ptsize, gadsize, xstart;
int more, ypos, xtarget, ptsize, gadsize, xstart, nolines;
unsigned int flags;
int fontheight = 0;
int gotfont = 0;
BBox icon_coords, fbox;
fm_face h = 0;
char display_this[4];
block.window_handle = event->redraw_window_request.window_handle;
state.window_handle = event->redraw_window_request.window_handle;
......@@ -1478,6 +1480,33 @@ static int choices_redraw_fakepage_handler(int eventcode, WimpPollBlock * event,
coords_box_toscreen(&icon_coords, (WimpRedrawWindowBlock *) &state);
/* Find out which lines to draw */
for(nolines = 0; nolines < sizeof(display_this); nolines++) display_this[nolines] = 0;
nolines = 1; /* Start with one line (half at top, half at bottom) */
if (!gadget_get_flags(0, idb->self_id, CD_LinkColourBt, &flags))
{
nolines ++;
display_this[0] = 1;
}
if (!gadget_get_flags(0, idb->self_id, CD_UsedColourBt, &flags))
{
nolines ++;
display_this[1] = 1;
}
if (!gadget_get_flags(0, idb->self_id, CD_FolwColourBt, &flags))
{
nolines ++;
display_this[2] = 1;
}
if (!gadget_get_flags(0, idb->self_id, CD_SlctColourBt, &flags))
{
nolines ++;
display_this[3] = 1;
}
/* Start the redraw loop */
ChkError(wimp_redraw_window(&block, &more));
......@@ -1506,11 +1535,7 @@ static int choices_redraw_fakepage_handler(int eventcode, WimpPollBlock * event,
/* point size which will allow an appropriate number */
/* of lines in the fake page display. */
#ifdef ChoiceUseSelected
ptsize = ((gadsize * 1000 / 5) / fontheight);
#else
ptsize = ((gadsize * 1000 / 4) / fontheight);
#endif
ptsize = ((gadsize * 1000 / nolines) / fontheight);
h = fm_find_font(NULL, "serif", ptsize, ptsize, 0, 0);
ChkError(fm_font_box(h, &fbox));
......@@ -1537,40 +1562,50 @@ static int choices_redraw_fakepage_handler(int eventcode, WimpPollBlock * event,
/* Display the new link line of the fake page display */
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 2));
ChkError(choices_draw_string(h, "new", xtarget, ypos, new_choices->underline_links, new_choices->link_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 3));
if (display_this[0])
{
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 2));
ChkError(choices_draw_string(h, "new", xtarget, ypos, new_choices->underline_links, new_choices->link_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 3));
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
}
/* Display the new followed line of the fake page display */
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 4));
ChkError(choices_draw_string(h, "followed", xtarget, ypos, new_choices->underline_links, new_choices->used_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 5));
if (display_this[1])
{
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 4));
ChkError(choices_draw_string(h, "followed", xtarget, ypos, new_choices->underline_links, new_choices->used_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 5));
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
}
/* Display the highlighted link line of the fake page display */
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 6));
ChkError(choices_draw_string(h, "highlighted", xtarget, ypos, new_choices->underline_links, new_choices->followed_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 7));
if (display_this[2])
{
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 6));
ChkError(choices_draw_string(h, "highlighted", xtarget, ypos, new_choices->underline_links, new_choices->followed_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 7));
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
}
/* Display the selected link line of the fake page display */
#ifdef ChoiceUseSelected
if (display_this[3])
{
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmin+xstart, new_choices->text_colour, new_choices->background_colour, &xtarget, 12));
ChkError(choices_draw_string(h, "selected", xtarget, ypos, new_choices->underline_links, new_choices->selected_colour, new_choices->background_colour, &xtarget));
ChkError(choices_write_crap(h, xtarget, ypos, icon_coords.xmax, new_choices->text_colour, new_choices->background_colour, &xtarget, 9));
ypos -= fontheight;
xtarget = icon_coords.xmin - 32;
#endif
}
/* Display the bottom line of the fake page display */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment