[teklib-general] changeset in /hg/teklib/current: initial import

Franciska Schulze fschulze at neoscientists.org
Mon Nov 26 16:22:11 CET 2007


changeset e4b380b14aec in /hg/teklib/current
details: http://teklib.org:8001/hg/teklib/current?cmd=changeset;node=e4b380b14aec
description:
	initial import

diffs (272 lines):

diff -r 1daea84640d3 -r e4b380b14aec src/visual/posix/visual_host.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/visual/posix/visual_host.h	Sat Sep 01 16:50:39 2007 +0200
@@ -0,0 +1,88 @@
+#ifndef _VISUAL_HOST_H
+#define _VISUAL_HOST_H
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+
+struct FontMan
+{
+	struct TList openfonts;		/* list of opened fonts */
+	TAPTR deffont;				/* pointer to default font */
+	TINT defref;				/* count of references to default font */
+	TAPTR curfont;				/* current active font */
+};
+ 
+typedef struct
+{
+	TINT winwidth, winheight;
+	TINT fontwidth, fontheight;
+	TINT textwidth, textheight;
+	TSTRPTR title;
+
+	TUINT flags;
+	TUINT pixfmt;
+	TINT depth, bpp;
+
+	TAPTR HalBase;
+	THALO lock;
+	TINT sigPending;
+
+	Display *display;
+	int screen;
+	Visual *visual;
+	Window window;
+
+	struct FontMan fm;
+	
+	XTextProperty title_prop;
+	Colormap colormap;
+	GC gc;
+
+	TINT shm, shmevent;
+	XShmSegmentInfo shminfo;
+	TBOOL shmpending;
+
+	Atom atom_wm_delete_win;
+
+	TINT keyqual;
+	TINT mousex, mousey;
+	TUINT base_mask;
+	TUINT eventmask;
+
+	struct TList imsgpool;
+
+	TVPEN bgpen, fgpen;
+
+	int fd_display;
+	int fd_sigpipe_read;
+	int fd_sigpipe_write;
+	int fd_max;
+
+	XImage *image;
+	char *tempbuf;
+	int imw, imh;
+
+	XSizeHints *sizehints;
+
+} VISUAL;
+
+#define DEFFONTNAME			"-misc-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*"
+
+#define PIXFMT_UNDEFINED	0
+#define PIXFMT_RGB			1
+#define PIXFMT_RBG			2
+#define PIXFMT_BRG			3
+#define PIXFMT_BGR			4
+#define PIXFMT_GRB			5
+#define PIXFMT_GBR			6
+
+#define TVISF_SWAPBYTEORDER	0x00000001
+
+
+#endif /* VISUAL_HOST_H */
diff -r 1daea84640d3 -r e4b380b14aec src/visual/tests/fonts.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/visual/tests/fonts.c	Sat Sep 01 16:50:39 2007 +0200
@@ -0,0 +1,176 @@
+
+/*
+**	$Id: bashing.c,v 1.3 2006/09/10 01:06:45 tmueller Exp $
+**	teklib/src/visual/tests/bashing.c - Visual module unit test
+**
+**	Written by Timm S. Mueller <tmueller at neoscientists.org>
+**	See copyright notice in teklib/COPYRIGHT
+*/
+
+#include <math.h>
+#include <stdio.h>
+#include <tek/teklib.h>
+#include <tek/debug.h>
+#include <tek/inline/exec.h>
+#include <tek/inline/util.h>
+#include <tek/inline/time.h>
+#include <tek/proto/visual.h>
+
+TAPTR TExecBase;
+TAPTR TTimeBase;
+TAPTR TUtilBase;
+TAPTR vismod;
+
+/*****************************************************************************/
+
+#define NUMPENS		4
+
+/*****************************************************************************/
+
+#define TVisualOpenFont(visual,tags) \
+	(*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(vismod))[-30]))(visual,tags)
+#define TVisualCloseFont(visual,font) \
+	(*(((TMODCALL TVOID(**)(TAPTR,TAPTR))(vismod))[-31]))(visual,font)
+#define TVisualSetFont(visual,font) \
+	(*(((TMODCALL TVOID(**)(TAPTR,TAPTR))(vismod))[-32]))(visual,font)
+#define TVisualTextSize(visual,font,text) \
+	(*(((TMODCALL TINT(**)(TAPTR,TAPTR,TSTRPTR))(vismod))[-33]))(visual,font,text)
+#define TVisualGetFAttrs(visual,font,text) \
+	(*(((TMODCALL TINT(**)(TAPTR,TAPTR,TTAGITEM *))(vismod))[-34]))(visual,font,tags)
+
+
+TVOID fonttest(TAPTR v, TVPEN *pentab)
+{
+	TINT fh = 0;
+	TAPTR font = TNULL;
+	TSTRPTR buf = "hallo";
+	TTAGITEM ftags[5];
+	static TBOOL init_done = TFALSE;
+
+	if (!init_done)
+	{
+		ftags[0].tti_Tag = TVisual_FontName;
+		ftags[0].tti_Value = (TTAG) "utopia";
+		ftags[1].tti_Tag = TVisual_FontPxSize;
+		ftags[1].tti_Value = (TTAG) 24;
+		ftags[2].tti_Tag = TVisual_FontItalic;
+		ftags[2].tti_Value = (TTAG) TTRUE;
+		ftags[3].tti_Tag = TVisual_FontBold;
+		ftags[3].tti_Value = (TTAG) TTRUE;
+		ftags[4].tti_Tag = TTAG_DONE;
+
+		font = TVisualOpenFont(v, ftags);
+		if (font)
+		{
+			TTAGITEM tags[2];
+
+			tags[0].tti_Tag = TVisual_FontHeight;
+			tags[0].tti_Value = (TTAG) &fh;
+			tags[1].tti_Tag = TTAG_DONE;
+
+			TVisualGetFAttrs(v, font, tags);
+			
+			TVisualSetFont(v, font);
+			TVisualText(v, 10, 10, buf, TStrLen(buf), pentab[0], TVPEN_UNDEFINED);
+			printf("size of text: %d\n", TVisualTextSize(v, font, buf));
+			TVisualCloseFont(v, font);
+		}
+
+		init_done = TTRUE;
+	}
+
+	TVisualText(v, 10, 10+fh, buf, TStrLen(buf), pentab[0], TVPEN_UNDEFINED);
+}
+
+/*****************************************************************************/
+/*
+**	Main Program
+*/
+
+TTASKENTRY TVOID TEKMain(TAPTR task)
+{
+	TExecBase = TGetExecBase(task);
+	TUtilBase = TOpenModule("util", 0, TNULL);
+	TTimeBase = TOpenModule("time", 0, TNULL);
+
+	if (TUtilBase && TTimeBase)
+	{
+		vismod = TOpenModule("visual", 0, TNULL);
+		if (vismod)
+		{
+			TAPTR v;
+			TTAGITEM vistags[4];
+
+			vistags[0].tti_Tag = TVisual_PixWidth;
+			vistags[0].tti_Value = (TTAG) 680;
+			vistags[1].tti_Tag = TVisual_PixHeight;
+			vistags[1].tti_Value = (TTAG) 460;
+			vistags[2].tti_Tag = TVisual_Title;
+			vistags[2].tti_Value = (TTAG) "Font Test";
+			vistags[3].tti_Tag = TTAG_DONE;
+
+			v = TVisualOpen(vismod, vistags);
+
+			if (v)
+			{
+				TIMSG *imsg;
+				TBOOL abort = TFALSE;
+				TAPTR iport;
+				TINT i = 0;
+				TVPEN pentab[NUMPENS];
+				
+				pentab[0] = TVisualAllocPen(v, 0xffffff);
+				pentab[1] = TVisualAllocPen(v, 0x000000);
+				pentab[2] = TVisualAllocPen(v, 0xff00ff);
+				pentab[3] = TVisualAllocPen(v, 0xff0000);
+
+				TVisualClear(v, pentab[1]);
+
+				fonttest(v, pentab);
+
+				TVisualSetInput(v, TITYPE_NONE, TITYPE_CLOSE |
+					TITYPE_COOKEDKEY | TITYPE_NEWSIZE | TITYPE_REFRESH);
+
+				iport = TVisualGetPort(v);
+
+				do
+				{
+					TWait(TGetPortSignal(iport));
+
+					while ((imsg = (TIMSG *) TGetMsg(iport)))
+					{
+						switch (imsg->timsg_Type)
+						{
+							case TITYPE_REFRESH:
+							case TITYPE_NEWSIZE:
+								TVisualClear(v, pentab[1]);
+								fonttest(v, pentab);
+								break;
+
+							case TITYPE_CLOSE:
+								abort = TTRUE;
+								break;
+
+							case TITYPE_COOKEDKEY:
+								if (imsg->timsg_Code == TKEYC_ESC)
+									abort = TTRUE;
+								break;
+						}
+						TAckMsg(imsg);
+					}
+
+				} while (!abort);
+
+				for (i = 0; i < NUMPENS; ++i)
+					TVisualFreePen(v, pentab[i]);
+
+				TVisualClose(vismod, v);
+			}
+
+			TCloseModule(vismod);
+		}
+	}
+
+	TCloseModule(TTimeBase);
+	TCloseModule(TUtilBase);
+}


More information about the teklib-general mailing list