Commit 01f28e3f authored by Paolo Molaro's avatar Paolo Molaro
Browse files

Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>


Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>

	* gdk/Makefile.am: added poly.h to EXTRA_DIST.
	* gdk/gdkgc.c: support dashes in GdkGCPrivate
	* gdk/gdkprivate.h: move here GdkPsDrawable definition
	* gdk/gdkdrawable.c: gdk_drawable_register returns an int
	* gdk/gdkps.c: beginning support for pixmaps, better
	guessing of postscript font name, beginning of downloading
	function, better emulation of dashed lines,
	* gtk/testps.c: better example to show pixmaps, dashes,
	font size and a4 page size.

There is some bug in the pixmap code: try to enable it in testps.c
and enjoy a badmatch from XInternAtom:-):-)
Anyone care to look into this? Thanks.
parent 68d9165f
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
Fri, 13 Nov 1998 18:54:13 +0100 Paolo Molaro <lupus@debian.org>
* gdk/Makefile.am: added poly.h to EXTRA_DIST.
* gdk/gdkgc.c: support dashes in GdkGCPrivate
* gdk/gdkprivate.h: move here GdkPsDrawable definition
* gdk/gdkdrawable.c: gdk_drawable_register returns an int
* gdk/gdkps.c: beginning support for pixmaps, better
guessing of postscript font name, beginning of downloading
function, better emulation of dashed lines,
* gtk/testps.c: better example to show pixmaps, dashes,
font size and a4 page size.
Wed, 21 Oct 1998 19:29:03 +0200 Paolo Molaro <lupus@debian.org>
* gdk/gdkps.c: fixed silly error.
......
......@@ -72,7 +72,7 @@ gxid_LDADD = \
BUILT_SOURCES = gdkcursors.h gdkkeysyms.h
EXTRA_DIST = makecursors.awk makekeysyms.awk PolyReg.c Region.c region.c region.h
EXTRA_DIST = makecursors.awk makekeysyms.awk PolyReg.c Region.c region.h poly.h
gdkcursors.h:
awk -f $(srcdir)/makecursors.awk @x_includes@/X11/cursorfont.h > $@
......
......@@ -907,7 +907,7 @@ guint gdk_keyval_to_lower (guint keyval);
gboolean gdk_keyval_is_upper (guint keyval);
gboolean gdk_keyval_is_lower (guint keyval);
void gdk_drawable_register (GdkDrawableClass* draw_class);
gint gdk_drawable_register (GdkDrawableClass* draw_class);
#include <gdk/gdkps.h>
#include <gdk/gdkrgb.h>
......
......@@ -23,17 +23,18 @@
static GList* engines = NULL;
void
gint
gdk_drawable_register(GdkDrawableClass* d_engine)
{
gint type = 0;
g_return_if_fail(d_engine != NULL);
g_return_val_if_fail(d_engine != NULL, 0);
if ( d_engine->type )
return;
return d_engine->type;
type = g_list_length(engines)+1;
d_engine->type = type;
engines = g_list_append(engines, d_engine);
return type;
}
......@@ -21,6 +21,21 @@
#include "gdk.h"
#include "gdkprivate.h"
static void
gc_set_dashes(GdkGCPrivate* gc, gint offset, gchar* dashes, gint n)
{
if ( gc->dash_list)
g_free(gc->dash_list);
if ( n ) {
gc->dash_num = n;
gc->dash_offset = offset;
gc->dash_list = g_new(gchar, n);
memcpy(gc->dash_list, dashes, n);
} else {
gc->dash_list = NULL;
gc->dash_num = gc->dash_offset = 0;
}
}
GdkGC*
gdk_gc_new (GdkWindow *window)
......@@ -213,12 +228,15 @@ gdk_gc_new_with_values (GdkWindow *window,
{
case GDK_LINE_SOLID:
xvalues.line_style = LineSolid;
gc_set_dashes(private, 0, NULL, 0);
break;
case GDK_LINE_ON_OFF_DASH:
xvalues.line_style = LineOnOffDash;
gc_set_dashes(private, 0, "\1\1", 2);
break;
case GDK_LINE_DOUBLE_DASH:
xvalues.line_style = LineDoubleDash;
gc_set_dashes(private, 0, "\2\1", 2); /* FIXME: is this right? */
break;
}
xvalues_mask |= GCLineStyle;
......@@ -792,12 +810,15 @@ gdk_gc_set_line_attributes (GdkGC *gc,
{
case GDK_LINE_SOLID:
xline_style = LineSolid;
gc_set_dashes(private, 0, NULL, 0);
break;
case GDK_LINE_ON_OFF_DASH:
xline_style = LineOnOffDash;
gc_set_dashes(private, 0, "\1\1", 2);
break;
case GDK_LINE_DOUBLE_DASH:
xline_style = LineDoubleDash;
gc_set_dashes(private, 0, "\2\1", 2);
break;
default:
xline_style = None;
......@@ -855,14 +876,7 @@ gdk_gc_set_dashes (GdkGC *gc,
XSetDashes (private->xdisplay, private->xgc, dash_offset, dash_list, n);
g_free(private->dash_list);
private->dash_list = NULL;
private->dash_num = n;
private->dash_offset = dash_offset;
if ( n ) {
private->dash_list = g_new(gchar, n);
memcpy(private->dash_list, dash_list, n);
}
gc_set_dashes(private, dash_offset, dash_list, n);
}
void
......@@ -885,13 +899,6 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
dst_private->fg = src_private->fg;
dst_private->bg = src_private->bg;
g_free(dst_private->dash_list);
dst_private->dash_list = NULL;
dst_private->dash_num = src_private->dash_num;
dst_private->dash_offset = src_private->dash_offset;
if ( src_private->dash_num ) {
dst_private->dash_list = g_new(gchar, src_private->dash_num);
memcpy(dst_private->dash_list, src_private->dash_list, src_private->dash_num);
}
gc_set_dashes(dst_private, src_private->dash_offset, src_private->dash_list, src_private->dash_num);
}
......@@ -49,6 +49,7 @@ typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkClientFilter GdkClientFilter;
typedef struct _GdkColorContextPrivate GdkColorContextPrivate;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
typedef struct _GdkPsDrawable GdkPsDrawable;
struct _GdkWindowPrivate
......@@ -114,7 +115,6 @@ struct _GdkGCPrivate
guint ref_count;
guint nrects;
GdkRectangle* rects;
/* FIXME: need to store here the dashes as well */
GdkColor fg;
GdkColor bg;
gint dash_offset;
......@@ -234,6 +234,33 @@ struct _GdkRegionPrivate
Region xregion;
};
struct _GdkPsDrawable {
gint page;
gint fd;
gint width;
gint height;
GString *sbuf;
gint xoff;
gint yoff;
gint intile;
gint inframe;
GdkFont* font;
GdkColor fg;
GdkColor bg;
GdkCapStyle cap_style;
GdkJoinStyle join_style;
gint line_width;
gint valid;
gint valid_fg;
gint valid_bg;
gint nrects;
GdkRectangle *rects;
gint clipped;
gint dash_offset;
gint dash_num;
gchar* dash_list;
};
typedef enum {
GDK_DEBUG_MISC = 1 << 0,
GDK_DEBUG_EVENTS = 1 << 1,
......
This diff is collapsed.
......@@ -25,34 +25,30 @@ extern "C" {
/*typedef struct _GdkPsDrawable GdkPsDrawable;*/
typedef struct {
gint page;
gint fd;
gint width;
gint height;
GString *sbuf;
gint xoff;
gint yoff;
gint intile;
gint inframe;
GdkFont* font;
GdkColor fg;
GdkColor bg;
GdkCapStyle cap_style;
GdkJoinStyle join_style;
gint line_width;
gint valid;
gint valid_fg;
gint nrects;
GdkRectangle *rects;
gint clipped;
} GdkPsDrawable;
typedef struct
{
gchar* name;
gchar* face;
gchar* family;
gint download;
gchar* afm;
gchar* pfa;
} GdkPsFontInfo;
void gdk_ps_drawable_add_font_info(GdkPsFontInfo *info);
GdkDrawable* gdk_ps_drawable_new (gint fd,
gchar *title,
gchar *author);
void gdk_ps_drawable_draw_rgb (GdkDrawable *d,
GdkGC *gc,
gchar *data,
gint bpp,
gint x,
gint y,
gint width,
gint height);
void gdk_ps_drawable_put_data (GdkDrawable *d,
gchar *data,
guint len);
......
......@@ -4,6 +4,8 @@
#include <unistd.h>
#include <time.h>
gint a4w = 595;
gint a4h = 842;
GdkColor red;
GdkColor blue;
......@@ -20,11 +22,16 @@ GtkWidget *vb;
GtkWidget *sw;
GtkWidget *pix;
GdkPixmap* bp;
GdkPixmap* xpm;
GdkBitmap* bitmap;
gint xpm_w, xpm_h;
gint depth;
gchar dashes[] = {1,2,3,4,5};
gint ndashes=5;
void page1(GdkDrawable* d, int print) {
if (print)
gdk_ps_drawable_page_start(d, 0, 1, 0, 300, 600, 1200);
gdk_ps_drawable_page_start(d, 0, 1, 0, 72, a4w, a4h);
else {
d = gdk_pixmap_new(win->window, 300, 300, depth);
gdk_gc_set_foreground(gc, &white);
......@@ -49,6 +56,9 @@ void page1(GdkDrawable* d, int print) {
gdk_gc_set_line_attributes(gc, 16, -1, GDK_CAP_NOT_LAST, -1);
gdk_draw_line(d, gc, 20, 100, 100, 100);
gdk_draw_text(d, font, gc, 120, 100, "(not last)", 10);
/*gdk_draw_pixmap(d, gc, xpm, 0, 0, 160, 100, xpm_w, xpm_h);
gdk_draw_pixmap(d, gc, bitmap, 0, 0, 160, 140, xpm_w, xpm_h);
*/
if (print)
gdk_ps_drawable_page_end(d);
else {
......@@ -62,7 +72,7 @@ void page1(GdkDrawable* d, int print) {
void page2(GdkDrawable* d, int print) {
GdkRectangle clip = {30, 30, 320, 350};
if (print)
gdk_ps_drawable_page_start(d, 0, 1, 0, 300, 600, 1200);
gdk_ps_drawable_page_start(d, 0, 1, 0, 72, a4w, a4h);
else {
d = gdk_pixmap_new(win->window, 350, 350, depth);
gdk_gc_set_foreground(gc, &white);
......@@ -100,7 +110,7 @@ void page3(GdkDrawable* d, int print) {
gdk_region_destroy(region2);
gdk_gc_set_clip_rectangle(gc, NULL);
if (print)
gdk_ps_drawable_page_start(d, 0, 1, 0, 300, 600, 1200);
gdk_ps_drawable_page_start(d, 0, 1, 0, 72, a4w, a4h);
else {
d = gdk_pixmap_new(win->window, 300, 300, depth);
gdk_gc_set_foreground(gc, &white);
......@@ -118,6 +128,12 @@ void page3(GdkDrawable* d, int print) {
gdk_draw_string(d, font, gc, 50, fsize*5, "Fifth line");
len = gdk_string_width(font, "Fifth line");
gdk_draw_string(d, font, gc, 50+len, fsize*5, "This continues right after line");
gdk_gc_set_foreground(gc, &black);
gdk_draw_rectangle(d, gc, 0, 50, fsize*5-font->ascent, len, font->ascent+font->descent);
gdk_gc_set_line_attributes(gc, 1, GDK_LINE_DOUBLE_DASH, GDK_CAP_BUTT, -1);
gdk_draw_rectangle(d, gc, 0, 50, 10+fsize*6, len, font->ascent+font->descent);
gdk_gc_set_dashes(gc, 0, dashes, ndashes);
gdk_draw_rectangle(d, gc, 0, 50+10+len, 10+fsize*6, len, font->ascent+font->descent);
if (print)
gdk_ps_drawable_page_end(d);
else {
......@@ -139,7 +155,7 @@ int main(int argc, char* argv[]) {
vb = gtk_vbox_new(5, 5);
gtk_container_add(GTK_CONTAINER(sw), vb);
gc = gdk_gc_new(win->window);
font = gdk_font_load(argc>1?argv[1]:"fixed");
font = gdk_font_load(argc>1?argv[1]:"-adobe-helvetica-medium-r-*");
gdk_window_get_geometry(win->window, NULL, NULL, NULL, NULL, &depth);
gtk_signal_connect(GTK_OBJECT(win), "delete_event",
(GtkSignalFunc)gtk_main_quit, NULL);
......@@ -159,6 +175,9 @@ int main(int argc, char* argv[]) {
gdk_color_alloc(cmap, &black);
fsize = font->ascent+font->descent;
xpm = gdk_pixmap_create_from_xpm(win->window, &bitmap, &white, "test.xpm");
gdk_window_get_size(xpm, &xpm_w, &xpm_h);
d = gdk_ps_drawable_new(1, "Test for GdkPs", "lupus");
page1(d, 1);
......@@ -170,6 +189,7 @@ int main(int argc, char* argv[]) {
gdk_ps_drawable_end(d);
gtk_widget_show_all(win);
gtk_main();
gdk_window_destroy(d);
return 0;
}
Supports Markdown
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