From 1aea76630f8466d0df3ea99edc7df634ac921787 Mon Sep 17 00:00:00 2001 From: David Brown <dbrown@gitlab.riscosopen.org> Date: Tue, 7 Oct 1997 13:18:29 +0000 Subject: [PATCH] Added runtime detection of editable colours for fake page display. --- c/Choices | 81 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/c/Choices b/c/Choices index 679dfce..8e5a727 100644 --- a/c/Choices +++ b/c/Choices @@ -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 */ -- GitLab