diff options
Diffstat (limited to 'engines/sci/gfx/sci_widgets.cpp')
-rw-r--r-- | engines/sci/gfx/sci_widgets.cpp | 285 |
1 files changed, 132 insertions, 153 deletions
diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index d840962503..8f47e4a97f 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -36,8 +36,7 @@ static void -clear_titlebar(gfxw_port_t *titlebar) -{ +clear_titlebar(gfxw_port_t *titlebar) { if (titlebar->contents) { titlebar->contents->widfree(titlebar->contents); titlebar->contents = NULL; @@ -46,8 +45,7 @@ clear_titlebar(gfxw_port_t *titlebar) } static gfxw_list_t * -make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) -{ +make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) { gfx_color_t color = status_bar->bgcolor; gfxw_list_t *list; gfxw_box_t *bgbox; @@ -55,7 +53,7 @@ make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) list = gfxw_new_list(status_bar->bounds, 0); bgbox = gfxw_new_box(s->gfx_state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl - 1), - color, color, GFX_BOX_SHADE_FLAT); + color, color, GFX_BOX_SHADE_FLAT); list->add((gfxw_container_t *) list, (gfxw_widget_t *) bgbox); @@ -63,22 +61,20 @@ make_titlebar_list(state_t *s, rect_t bounds, gfxw_port_t *status_bar) } static gfxw_list_t * -finish_titlebar_list(state_t *s, gfxw_list_t *list, gfxw_port_t *status_bar) -{ +finish_titlebar_list(state_t *s, gfxw_list_t *list, gfxw_port_t *status_bar) { gfx_color_t black = s->ega_colors[0]; gfxw_primitive_t *line; line = gfxw_new_line(gfx_point(0, status_bar->bounds.yl - 1), - gfx_point(status_bar->bounds.xl, status_bar->bounds.yl - 1), - black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL); + gfx_point(status_bar->bounds.xl, status_bar->bounds.yl - 1), + black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL); list->add((gfxw_container_t *) list, (gfxw_widget_t *) line); return list; } void -sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor, int bgcolor) -{ +sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor, int bgcolor) { gfx_state_t *state; gfxw_list_t *list; gfx_color_t bg = status_bar->bgcolor; @@ -101,8 +97,8 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor if (text) { gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl), - status_bar->font_nr, text, ALIGN_LEFT, ALIGN_CENTER, - fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES); + status_bar->font_nr, text, ALIGN_LEFT, ALIGN_CENTER, + fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES); list = make_titlebar_list(s, status_bar->bounds, status_bar); @@ -110,7 +106,7 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor } else { gfxw_box_t *bgbox = gfxw_new_box(state, gfx_rect(0, 0, status_bar->bounds.xl, status_bar->bounds.yl - 1), - black, black, GFX_BOX_SHADE_FLAT); + black, black, GFX_BOX_SHADE_FLAT); list = gfxw_new_list(status_bar->bounds, 0); @@ -125,23 +121,21 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor } static void -sciw_make_window_fit(rect_t *rect, gfxw_port_t *parent) -{ - /* This window is meant to cover the whole screen, so we allow it to go through. */ - if (rect->xl == 319 && rect->yl == 189) return; +sciw_make_window_fit(rect_t *rect, gfxw_port_t *parent) { + /* This window is meant to cover the whole screen, so we allow it to go through. */ + if (rect->xl == 319 && rect->yl == 189) return; - if (rect->x + rect->xl > parent->bounds.x + parent->bounds.xl) - rect->x -= (rect->x + rect->xl) - (parent->bounds.x + parent->bounds.xl) + 2; + if (rect->x + rect->xl > parent->bounds.x + parent->bounds.xl) + rect->x -= (rect->x + rect->xl) - (parent->bounds.x + parent->bounds.xl) + 2; - if (rect->y + rect->yl > parent->bounds.y + parent->bounds.yl) - rect->y -= (rect->y + rect->yl) - (parent->bounds.y + parent->bounds.yl) + 2; + if (rect->y + rect->yl > parent->bounds.y + parent->bounds.yl) + rect->y -= (rect->y + rect->yl) - (parent->bounds.y + parent->bounds.yl) + 2; } gfxw_port_t * sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_t bgcolor, - int title_font, gfx_color_t title_color, gfx_color_t title_bgcolor, - const char *title, int flags) -{ + int title_font, gfx_color_t title_color, gfx_color_t title_bgcolor, + const char *title, int flags) { gfxw_visual_t *visual = s->visual; gfx_state_t *state = s->gfx_state; int shadow_offset = 2; @@ -152,8 +146,7 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ // int xextra = !(flags & WINDOW_FLAG_NOFRAME) ? 1 : 0; // int yextra = !(flags & WINDOW_FLAG_NOFRAME) ? 2 : 0; - if (area.xl == 319 && area.yl == 189) - { + if (area.xl == 319 && area.yl == 189) { flags |= WINDOW_FLAG_NOFRAME; /* The below line makes the points bar in QfG2 work, but breaks the one in QfG1. Hm. */ @@ -195,22 +188,22 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ return win; /* Fully transparent window */ if (flags & WINDOW_FLAG_TITLE) - frame = gfx_rect(area.x-1, area.y-10, area.xl + 2, area.yl + 11); + frame = gfx_rect(area.x - 1, area.y - 10, area.xl + 2, area.yl + 11); else - frame = gfx_rect(area.x-1, area.y-1, area.xl + 2, area.yl + 2); + frame = gfx_rect(area.x - 1, area.y - 1, area.xl + 2, area.yl + 2); /* Set visible window boundaries */ win->bounds = gfx_rect(frame.x, frame.y, frame.xl + shadow_offset, frame.yl + shadow_offset); decorations = gfxw_new_list(gfx_rect(frame.x, frame.y, - frame.xl + 1 + shadow_offset, frame.yl + 1 + shadow_offset), 0); + frame.xl + 1 + shadow_offset, frame.yl + 1 + shadow_offset), 0); if (!(flags & WINDOW_FLAG_TRANSPARENT)) { /* Draw window background */ - win->port_bg = (gfxw_widget_t *) gfxw_new_box (state, - gfx_rect(1, (flags & WINDOW_FLAG_TITLE)? 10 : 1, - area.xl, area.yl), - bgcolor, bgcolor, GFX_BOX_SHADE_FLAT); + win->port_bg = (gfxw_widget_t *) gfxw_new_box(state, + gfx_rect(1, (flags & WINDOW_FLAG_TITLE) ? 10 : 1, + area.xl, area.yl), + bgcolor, bgcolor, GFX_BOX_SHADE_FLAT); decorations->add((gfxw_container_t *) decorations, win->port_bg); win->flags |= GFXW_FLAG_OPAQUE; } @@ -220,12 +213,12 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ rect_t title_rect = gfx_rect(1, 1, area.xl, 8); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, title_rect, title_bgcolor, title_bgcolor, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, title_rect, title_bgcolor, title_bgcolor, GFX_BOX_SHADE_FLAT)); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_text(state, title_rect, title_font, title, - ALIGN_CENTER, ALIGN_CENTER, title_color, title_color, - title_bgcolor, GFXR_FONT_FLAG_NO_NEWLINES)); + gfxw_new_text(state, title_rect, title_font, title, + ALIGN_CENTER, ALIGN_CENTER, title_color, title_color, + title_bgcolor, GFXR_FONT_FLAG_NO_NEWLINES)); } if (!(flags & WINDOW_FLAG_NOFRAME)) { @@ -238,14 +231,14 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ } decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, gfx_rect(shadow_offset + 1, frame.yl - 1, - frame.xl - 4, shadow_offset), - black, black, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, gfx_rect(shadow_offset + 1, frame.yl - 1, + frame.xl - 4, shadow_offset), + black, black, GFX_BOX_SHADE_FLAT)); decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_box(state, gfx_rect(frame.xl - 1, shadow_offset + 1, - shadow_offset, frame.yl - 2), - black, black, GFX_BOX_SHADE_FLAT)); + gfxw_new_box(state, gfx_rect(frame.xl - 1, shadow_offset + 1, + shadow_offset, frame.yl - 2), + black, black, GFX_BOX_SHADE_FLAT)); } /* Draw frame */ @@ -258,18 +251,18 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ if (!(flags & WINDOW_FLAG_NO_DROP_SHADOW)) { decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_rect(gfx_rect(0, 0, frame.xl-1, frame.yl-1), - black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); + gfxw_new_rect(gfx_rect(0, 0, frame.xl - 1, frame.yl - 1), + black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); if (flags & WINDOW_FLAG_TITLE) decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_line(gfx_point(1, 9), - gfx_point(frame.xl - 2, 9), - black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)); + gfxw_new_line(gfx_point(1, 9), + gfx_point(frame.xl - 2, 9), + black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)); } else { decorations->add((gfxw_container_t *) decorations, (gfxw_widget_t *) - gfxw_new_rect(gfx_rect(0, 0, frame.xl, frame.yl), - black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); + gfxw_new_rect(gfx_rect(0, 0, frame.xl, frame.yl), + black, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL)); } } @@ -286,17 +279,15 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ /**** Controls ****/ /*----------------*/ static inline rect_t -_move_and_extend_rect(rect_t rect, point_t point, int yplus) -{ +_move_and_extend_rect(rect_t rect, point_t point, int yplus) { return gfx_rect(rect.x + point.x, rect.y + point.y, rect.xl + 1, rect.yl + yplus); } gfxw_list_t * _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char *text, - int font, gfx_alignment_t align, char framed, char inverse, int flags, - char gray_text) -{ + int font, gfx_alignment_t align, char framed, char inverse, int flags, + char gray_text) { gfx_color_t *color1, *color2, *bgcolor; if (inverse) { @@ -311,8 +302,8 @@ _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char * } list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, zone, - font, text, align, ALIGN_TOP, - *color1, *color2, *bgcolor, flags))); + font, text, align, ALIGN_TOP, + *color1, *color2, *bgcolor, flags))); zone.xl--; @@ -320,17 +311,16 @@ _sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t zone, char * if (framed) { list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, *color2, GFX_LINE_MODE_CORRECT, - GFX_LINE_STYLE_STIPPLED))); + GFXW(gfxw_new_rect(zone, *color2, GFX_LINE_MODE_CORRECT, + GFX_LINE_STYLE_STIPPLED))); } return list; } gfxw_list_t * -sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, char selected, char inverse, char grayed_out) -{ - gfx_color_t *frame_col = (inverse)? &(port->bgcolor) : &(port->color); +sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, char selected, char inverse, char grayed_out) { + gfx_color_t *frame_col = (inverse) ? &(port->bgcolor) : &(port->color); gfxw_list_t *list; zone.x--; @@ -346,25 +336,25 @@ sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, in zone.y = 0; if (inverse) - list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.xl + 1, zone.yl + 1), - port->color, port->color, GFX_BOX_SHADE_FLAT))); + list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.xl + 1, zone.yl + 1), + port->color, port->color, GFX_BOX_SHADE_FLAT))); if (!inverse) list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.xl - 1, zone.yl), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); if (!inverse) list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); if (inverse) list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.xl - 1, zone.yl), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); - if (selected) - list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x + 1, zone.y + 1, zone.xl - 2, zone.yl - 2), - *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + if (selected) + list->add(GFXWC(list), + GFXW(gfxw_new_rect(gfx_rect(zone.x + 1, zone.y + 1, zone.xl - 2, zone.yl - 2), + *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); return list; } @@ -372,8 +362,7 @@ sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, in gfxw_list_t * sciw_new_text_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, - gfx_alignment_t align, char framed, char inverse) -{ + gfx_alignment_t align, char framed, char inverse) { gfxw_list_t *list = gfxw_new_list(_move_and_extend_rect(zone, gfx_point(port->zone.x, port->zone.y), 2), 0); gfxw_set_id(GFXW(list), ID.segment, ID.offset); @@ -387,8 +376,7 @@ sciw_new_text_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int gfxw_list_t * sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, unsigned int cursor, - char inverse) -{ + char inverse) { gfxw_text_t *text_handle; long draw_cursor; long foo; @@ -411,8 +399,8 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int if (!draw_cursor) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, text, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, text, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); } else { @@ -425,8 +413,8 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int if (cursor > 0) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, textdup, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; @@ -436,32 +424,32 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int textdup[0] = text[cursor]; textdup[1] = 0; text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES); + font, textdup, ALIGN_LEFT, ALIGN_TOP, + port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; - if (cursor+1 < strlen(text)) { + if (cursor + 1 < strlen(text)) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, - font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; if (cursor == strlen(text)) list->add(GFXWC(list), GFXW(gfxw_new_line(gfx_point(zone.x, zone.y), - gfx_point(zone.x, zone.y + cursor_height - 1), - port->color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); + gfx_point(zone.x, zone.y + cursor_height - 1), + port->color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); free(textdup); } zone.x = zone.y = 0; - list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + list->add(GFXWC(list), + GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); return list; } @@ -469,8 +457,7 @@ sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int gfxw_list_t * sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int loop, int cel, - char frame, char inverse) -{ + char frame, char inverse) { gfxw_list_t *list = gfxw_new_list(_move_and_extend_rect(zone, gfx_point(port->zone.x, port->zone.y), 1), 0); gfxw_widget_t *icon; gfxw_set_id(GFXW(list), ID.segment, ID.offset); @@ -484,7 +471,7 @@ sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int lo zone.y = 0; icon = GFXW(gfxw_new_view(port->visual->gfx_state, gfx_point(zone.x, zone.y), view, loop, cel, 0, -1, -1, - ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET)); + ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET)); if (!icon) { GFXERROR("Attempt to create icon control with cel %d/%d/%d (invalid)\n", view, loop, cel); @@ -501,8 +488,7 @@ sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int lo gfxw_list_t * sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, char **entries_list, - int entries_nr, int list_top, int selection, char inverse) -{ + int entries_nr, int list_top, int selection, char inverse) { gfxw_list_t *list; char arr_up[2], arr_down[2]; @@ -544,16 +530,16 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha if (i != selection) list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), - font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), + font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, + port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); else { list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 1, font_height), - port->color, port->color, GFX_BOX_SHADE_FLAT))); + port->color, port->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), - font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.xl - 2, font_height), + font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, + port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES))); } zone.y += font_height; @@ -566,33 +552,33 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha /* Add up arrow */ list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, 0, zone.xl-2, 8), - port->font_nr, arr_up, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, 0, zone.xl - 2, 8), + port->font_nr, arr_up, ALIGN_CENTER, ALIGN_CENTER, + port->color, port->color, port->bgcolor, 0))); /* Add down arrow */ list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, zone.yl-9, zone.xl-2, 8), - port->font_nr, arr_down, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, zone.yl - 9, zone.xl - 2, 8), + port->font_nr, arr_down, ALIGN_CENTER, ALIGN_CENTER, + port->color, port->color, port->bgcolor, 0))); if (list_top & 1) { /* Hack to work around aggressive caching */ list->add(GFXWC(list), - GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 20), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 20), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } else { list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y, zone.xl, zone.yl - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y, zone.xl, zone.yl - 10), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), - GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.xl, zone.yl - 10), + port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } return list; @@ -600,8 +586,7 @@ sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int font_nr, cha void -sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) -{ +sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) { gfxw_list_t *list = make_titlebar_list(s, status_bar->bounds, status_bar); int offset = MENU_LEFT_BORDER; int i; @@ -614,16 +599,16 @@ sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int se if (i == selection) { list->add(GFXWC(list), GFXW(gfxw_new_box(status_bar->visual->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); + status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), - GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, - status_bar->bgcolor, status_bar->bgcolor, status_bar->color, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), + status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, + status_bar->bgcolor, status_bar->bgcolor, status_bar->color, GFXR_FONT_FLAG_NO_NEWLINES))); } else list->add(GFXWC(list), - GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, - status_bar->color, status_bar->color, status_bar->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), + status_bar->font_nr, menu->title, ALIGN_CENTER, ALIGN_CENTER, + status_bar->color, status_bar->color, status_bar->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); offset += width; } @@ -633,8 +618,7 @@ sciw_set_menubar(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int se } gfxw_port_t * -sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) -{ +sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selection) { gfxw_port_t *retval; menu_t *menu = menubar->menus + selection; rect_t area = gfx_rect(MENU_LEFT_BORDER, 10, 0, 0); @@ -655,8 +639,8 @@ sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selec area.yl = menu->items_nr * 10; retval = sciw_new_window(s, area, status_bar->font_nr, status_bar->color, status_bar->bgcolor, - 0, status_bar->color, status_bar->bgcolor, - NULL, WINDOW_FLAG_NO_DROP_SHADOW | WINDOW_FLAG_TRANSPARENT); + 0, status_bar->color, status_bar->bgcolor, + NULL, WINDOW_FLAG_NO_DROP_SHADOW | WINDOW_FLAG_TRANSPARENT); retval->set_visual(GFXW(retval), s->visual); @@ -669,8 +653,7 @@ sciw_new_menu(state_t *s, gfxw_port_t *status_bar, menubar_t *menubar, int selec #define MAGIC_ID_OFFSET 0x2000 static inline gfx_color_t -un_prioritize(gfx_color_t col) -{ +un_prioritize(gfx_color_t col) { col.priority = -1; col.mask &= ~GFX_MASK_PRIORITY; @@ -678,8 +661,7 @@ un_prioritize(gfx_color_t col) } gfxw_widget_t * -_make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID, int gray) -{ +_make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID, int gray) { rect_t area = gfx_rect(MENU_BOX_LEFT_PADDING, 0, width - MENU_BOX_LEFT_PADDING, 10); rect_t list_area = gfx_rect(port->zone.x, area.y + offset + port->zone.y, width, area.yl); gfxw_list_t *list = (gfxw_list_t *) gfxw_set_id(GFXW(gfxw_new_list(list_area, 0)), ID, GFXW_NO_ID); @@ -688,24 +670,23 @@ _make_menu_entry(menu_item_t *item, int offset, int width, gfxw_port_t *port, gf color = un_prioritize(color); bgcolor = un_prioritize(bgcolor); - xcolor = gray? color : bgcolor; + xcolor = gray ? color : bgcolor; list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->text, ALIGN_LEFT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); if (item->keytext) { area.xl -= MENU_BOX_RIGHT_PADDING; list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->keytext, ALIGN_RIGHT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); } return GFXW(list); } gfxw_widget_t * -_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID) -{ +_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx_color_t bgcolor, int ID) { rect_t area = gfx_rect(0, 0, width, 10); rect_t list_area = gfx_rect(area.x + port->zone.x, area.y + offset + port->zone.y, area.xl, area.yl); gfxw_list_t *list = (gfxw_list_t *) gfxw_set_id(GFXW(gfxw_new_list(list_area, 0)), ID, GFXW_NO_ID); @@ -715,16 +696,15 @@ _make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_color_t color, gfx list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_line(gfx_point(0, 5), - gfx_point(width, 5), - color, - GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED))); + gfx_point(width, 5), + color, + GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED))); return GFXW(list); } gfxw_port_t * -sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) -{ +sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) { menu_item_t *item = menu->items + selection; if (selection < 0 || selection >= menu->items_nr) @@ -732,20 +712,19 @@ sciw_unselect_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selecti if (item->type == MENU_TYPE_NORMAL) menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->color, - menu_port->bgcolor, selection + MAGIC_ID_OFFSET, - item->enabled))); + menu_port, menu_port->color, + menu_port->bgcolor, selection + MAGIC_ID_OFFSET, + item->enabled))); else menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->color, - menu_port->bgcolor, selection + MAGIC_ID_OFFSET))); + menu_port, menu_port->color, + menu_port->bgcolor, selection + MAGIC_ID_OFFSET))); return menu_port; } gfxw_port_t * -sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) -{ +sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection) { menu_item_t *item = menu->items + selection; if (selection < 0 || selection >= menu->items_nr) @@ -753,13 +732,13 @@ sciw_select_item(state_t *s, gfxw_port_t *menu_port, menu_t *menu, int selection if (item->type == MENU_TYPE_NORMAL) menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->bgcolor, - menu_port->color, selection + MAGIC_ID_OFFSET, - item->enabled))); + menu_port, menu_port->bgcolor, + menu_port->color, selection + MAGIC_ID_OFFSET, + item->enabled))); else menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.xl + 1, - menu_port, menu_port->bgcolor, - menu_port->color, selection + MAGIC_ID_OFFSET))); + menu_port, menu_port->bgcolor, + menu_port->color, selection + MAGIC_ID_OFFSET))); return menu_port; } |