// draw a box directly to display memory int _near Drawbox_Cmd( LPTSTR pszCmdLine ) { register TCHAR *pszArg, *pszLine; int nTop, nLeft, nBottom, nRight, nStyle, nAttribute = -1, nFill = -1, n, nFlags = 0, nShade; if (( pszCmdLine == NULL ) || ( *pszCmdLine == _TEXT('\0') )) return ( Usage( DRAWBOX_USAGE )); // get the arguments & colors if ( sscanf( pszCmdLine, _TEXT("%d%d%d%d%d%n"), &nTop, &nLeft, &nBottom, &nRight, &nStyle, &n ) == 6 ) { pszLine = pszCmdLine + n; nAttribute = GetColors( pszLine, 0 ); // check for a FILL color if (( *pszLine ) && ( _strnicmp( first_arg( pszLine ), BOX_FILL, 3 ) == 0 ) && (( pszArg = first_arg( next_arg( pszLine, 1 ))) != NULL )) { if ( _strnicmp( pszArg, BRIGHT, 3 ) == 0 ) { // set intensity bit nFill = 0x80; if (( pszArg = first_arg( next_arg( pszLine, 1 ))) == NULL ) return ( Usage( DRAWBOX_USAGE )); } else nFill = 0; if (( nShade = color_shade( pszArg )) <= 15 ) { nFill |= ( nShade << 4 ); next_arg( pszLine, 1 ); } } // check for a SHADOW or ZOOM while ( *pszLine ) { if ( _strnicmp( pszLine, BOX_SHADOW, 3 ) == 0 ) nFlags |= BOX_SHADOWED; else if ( _strnicmp( pszLine, BOX_ZOOM, 3 ) == 0 ) nFlags |= BOX_ZOOMED; next_arg( pszLine, 1 ); } } if (( nAttribute == -1 ) || ( verify_row_col( nTop, nLeft )) || ( verify_row_col( nBottom, nRight ))) return ( Usage( DRAWBOX_USAGE )); if ( nLeft == 999 ) { if (( nLeft = (( GetScrCols() - nRight ) / 2 )) < 0 ) nLeft = 0; nRight += nLeft; } if ( nTop == 999 ) { if (( nTop = (( GetScrRows() - nBottom ) / 2 )) < 0 ) nTop = 0; nBottom += nTop; } _box( nTop, nLeft, nBottom, nRight, nStyle, nAttribute, nFill, nFlags, 1 ); return 0; }
void gtk_css_image_builtin_draw_handle (GtkCssImage *image, cairo_t *cr, double width, double height) { GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image); GdkRGBA lighter, darker; gint xx, yy; cairo_set_line_width (cr, 1.0); color_shade (&builtin->bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 1.3, &lighter); for (yy = 0; yy < height; yy += 3) for (xx = 0; xx < width; xx += 6) { render_dot (cr, &lighter, &darker, xx, yy, 2); render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2); } }
void gtk_css_image_builtin_draw_pane_separator (GtkCssImage *image, cairo_t *cr, double width, double height) { GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image); GdkRGBA lighter, darker; gint xx, yy; cairo_set_line_width (cr, 1.0); color_shade (&builtin->bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 1.3, &lighter); if (width > height) for (xx = width / 2 - 15; xx <= width / 2 + 15; xx += 5) render_dot (cr, &lighter, &darker, xx, height / 2 - 1, 3); else for (yy = height / 2 - 15; yy <= height / 2 + 15; yy += 5) render_dot (cr, &lighter, &darker, width / 2 - 1, yy, 3); }
// draw a box directly to display memory int drawbox_cmd(int argc, char **argv) { char *arg, *pszLine; int top, left, bottom, right, style, attribute = -1, fill = -1; int box_flags = 0; // get the arguments & colors if ((argc >= 7) && (sscanf(argv[1],"%d%d%d%d%d",&top,&left,&bottom,&right,&style) == 5)) { pszLine = argv[6]; attribute = GetColors(pszLine,0); // check for a FILL color if ((*pszLine) && (_strnicmp(first_arg(pszLine),BOX_FILL,3) == 0) && ((arg = first_arg(next_arg(pszLine,1))) != NULL)) { if (_strnicmp(arg,BRIGHT,3) == 0) { // set intensity bit fill = 0x80; if ((arg = first_arg(next_arg(pszLine,1))) == NULL) return (usage(DRAWBOX_USAGE)); } else fill = 0; if ((argc = color_shade(arg)) <= 15) { fill |= (argc << 4); (void)next_arg(pszLine,1); } } // check for a SHADOW or ZOOM while (*pszLine) { if (_strnicmp(pszLine,BOX_SHADOW,3) == 0) box_flags |= BOX_SHADOWED; else if (_strnicmp(pszLine,BOX_ZOOM,3) == 0) box_flags |= BOX_ZOOMED; (void)next_arg(pszLine,1); } } if ((attribute == -1) || (verify_row_col(top,left)) || (verify_row_col(bottom,right))) return (usage(DRAWBOX_USAGE)); _box(top,left,bottom,right,style,attribute,fill,box_flags,1); return 0; }
static void render_border (cairo_t *cr, GtkRoundedBox *border_box, const double border_width[4], guint hidden_side, GdkRGBA colors[4], GtkBorderStyle border_style[4]) { guint i, j; cairo_save (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); for (i = 0; i < 4; i++) { if (hidden_side & (1 << i)) continue; /* NB: code below divides by this value */ /* a border smaller than this will not noticably modify * pixels on screen, and since we don't compare with 0, * we'll use this value */ if (border_width[i] < 1.0 / 1024) continue; switch (border_style[i]) { case GTK_BORDER_STYLE_NONE: case GTK_BORDER_STYLE_HIDDEN: case GTK_BORDER_STYLE_SOLID: break; case GTK_BORDER_STYLE_INSET: if (i == 1 || i == 2) color_shade (&colors[i], 1.8, &colors[i]); break; case GTK_BORDER_STYLE_OUTSET: if (i == 0 || i == 3) color_shade (&colors[i], 1.8, &colors[i]); break; case GTK_BORDER_STYLE_DOTTED: case GTK_BORDER_STYLE_DASHED: { guint dont_draw = hidden_side; for (j = 0; j < 4; j++) { if (border_style[j] == border_style[i]) hidden_side |= (1 << j); else dont_draw |= (1 << j); } render_frame_stroke (cr, border_box, border_width, colors, dont_draw, border_style[i]); } break; case GTK_BORDER_STYLE_DOUBLE: { GtkRoundedBox other_box; double other_border[4]; guint dont_draw = hidden_side; for (j = 0; j < 4; j++) { if (border_style[j] == GTK_BORDER_STYLE_DOUBLE) hidden_side |= (1 << j); else dont_draw |= (1 << j); other_border[j] = border_width[j] / 3; } render_frame_fill (cr, border_box, other_border, colors, dont_draw); other_box = *border_box; _gtk_rounded_box_shrink (&other_box, 2 * other_border[GTK_CSS_TOP], 2 * other_border[GTK_CSS_RIGHT], 2 * other_border[GTK_CSS_BOTTOM], 2 * other_border[GTK_CSS_LEFT]); render_frame_fill (cr, &other_box, other_border, colors, dont_draw); } break; case GTK_BORDER_STYLE_GROOVE: case GTK_BORDER_STYLE_RIDGE: { GtkRoundedBox other_box; GdkRGBA other_colors[4]; guint dont_draw = hidden_side; double other_border[4]; for (j = 0; j < 4; j++) { other_colors[j] = colors[j]; if ((j == 0 || j == 3) ^ (border_style[j] == GTK_BORDER_STYLE_RIDGE)) color_shade (&other_colors[j], 1.8, &other_colors[j]); else color_shade (&colors[j], 1.8, &colors[j]); if (border_style[j] == GTK_BORDER_STYLE_GROOVE || border_style[j] == GTK_BORDER_STYLE_RIDGE) hidden_side |= (1 << j); else dont_draw |= (1 << j); other_border[j] = border_width[j] / 2; } render_frame_fill (cr, border_box, other_border, colors, dont_draw); other_box = *border_box; _gtk_rounded_box_shrink (&other_box, other_border[GTK_CSS_TOP], other_border[GTK_CSS_RIGHT], other_border[GTK_CSS_BOTTOM], other_border[GTK_CSS_LEFT]); render_frame_fill (cr, &other_box, other_border, other_colors, dont_draw); } break; default: g_assert_not_reached (); break; } } render_frame_fill (cr, border_box, border_width, colors, hidden_side); cairo_restore (cr); }
void gtk_css_image_builtin_draw_grip (GtkCssImage *image, cairo_t *cr, double width, double height, GtkCssImageBuiltinType image_type) { GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image); GdkRGBA lighter, darker; cairo_set_line_width (cr, 1.0); color_shade (&builtin->bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 1.3, &lighter); /* align drawing area to the connected side */ if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT) { if (height < width) width = height; } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT) { if (width < height) height = width; else if (height < width) width = height; } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMLEFT) { /* make it square, aligning to bottom left */ if (width < height) { cairo_translate (cr, 0, height - width); height = width; } else if (height < width) width = height; } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_RIGHT) { /* aligning to right */ if (height < width) { cairo_translate (cr, width - height, 0); width = height; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOPRIGHT) { if (width < height) height = width; else if (height < width) { cairo_translate (cr, width - height, 0); width = height; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMRIGHT) { /* make it square, aligning to bottom right */ if (width < height) { cairo_translate (cr, 0, height - width); height = width; } else if (height < width) { cairo_translate (cr, width - height, 0); width = height; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOP) { if (width < height) height = width; } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOM) { /* align to bottom */ if (width < height) { cairo_translate (cr, 0, height - width); height = width; } } else g_assert_not_reached (); if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT || image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_RIGHT) { gint xi; xi = 0; while (xi < width) { gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, 0, 0, 0, height); cairo_stroke (cr); xi++; gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, xi, 0, xi, height); cairo_stroke (cr); xi += 2; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOP || image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOM) { gint yi; yi = 0; while (yi < height) { gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, 0, yi, width, yi); cairo_stroke (cr); yi++; gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, 0, yi, width, yi); cairo_stroke (cr); yi += 2; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT) { gint xi, yi; xi = width; yi = height; while (xi > 3) { gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, xi, 0, 0, yi); cairo_stroke (cr); --xi; --yi; add_path_line (cr, xi, 0, 0, yi); cairo_stroke (cr); --xi; --yi; gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, xi, 0, 0, yi); cairo_stroke (cr); xi -= 3; yi -= 3; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_TOPRIGHT) { gint xi, yi; xi = 0; yi = height; while (xi < (width - 3)) { gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, xi, 0, width, yi); cairo_stroke (cr); ++xi; --yi; gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, xi, 0, width, yi); cairo_stroke (cr); ++xi; --yi; add_path_line (cr, xi, 0, width, yi); cairo_stroke (cr); xi += 3; yi -= 3; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMLEFT) { gint xi, yi; xi = width; yi = 0; while (xi > 3) { gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, 0, yi, xi, height); cairo_stroke (cr); --xi; ++yi; add_path_line (cr, 0, yi, xi, height); cairo_stroke (cr); --xi; ++yi; gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, 0, yi, xi, height); cairo_stroke (cr); xi -= 3; yi += 3; } } else if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMRIGHT) { gint xi, yi; xi = 0; yi = 0; while (xi < (width - 3)) { gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, xi, height, width, yi); cairo_stroke (cr); ++xi; ++yi; gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, xi, height, width, yi); cairo_stroke (cr); ++xi; ++yi; add_path_line (cr, xi, height, width, yi); cairo_stroke (cr); xi += 3; yi += 3; } } }