--- a/XGraphicsContext.st Fri Dec 26 22:46:49 2014 +0100
+++ b/XGraphicsContext.st Fri Dec 26 22:52:58 2014 +0100
@@ -1,7 +1,7 @@
"{ Package: 'stx:libview' }"
DeviceGraphicsContext subclass:#XGraphicsContext
- instanceVariableNames:'xftDrawId'
+ instanceVariableNames:'xftDrawId cairoSurfaceId'
classVariableNames:''
poolDictionaries:''
category:'Interface-Graphics'
@@ -20,133 +20,6 @@
"Modified (format): / 23-06-2014 / 21:28:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!XGraphicsContext methodsFor:'displaying'!
-
-displayString:aString x:x y:y opaque:opaque
- "draw a string - if opaque is false, draw foreground only; otherwise, draw both
- foreground and background characters.
- If the coordinates are not integers, an error is triggered."
-
- <context: #return>
-
- |displayId|
-
- device flushIfAppropriate.
- displayId := device displayIdOrErrorIfBroken.
-
-%{
-#if 0
- GC gc;
- Window win;
- char *cp;
- int n;
- OBJ cls;
-# define NLOCALBUFFER 200
- XChar2b xlatebuffer[NLOCALBUFFER];
- int nInstBytes;
-
- if (displayId != nil
- && __isExternalAddress(__INST(gcId))
- && __isExternalAddress(__INST(drawableId))
- && __isNonNilObject(aString)
- && __bothSmallInteger(x, y)) {
- int lMax = __intVal(@global(XWorkstation:MaxStringLength));
- Display *dpy = __DisplayVal(displayId);
- gc = __GCVal(__INST(gcId));
- win = __WindowVal(__INST(drawableId));
-
- cp = (char *) __stringVal(aString);
-
- if (__isStringLike(aString)) {
- n = __stringSize(aString);
- if (n > lMax) n = lMax;
- ENTER_XLIB();
- if (opaque == true)
- XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
- else
- XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
- LEAVE_XLIB();
- RETURN ( self );
- }
-
- cls = __qClass(aString);
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- cp += nInstBytes;
-
- if (__isBytes(aString)) {
- n = __byteArraySize(aString) - nInstBytes - 1;
-
- if (n > lMax) n = lMax;
- ENTER_XLIB();
- if (opaque == true)
- XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
- else
- XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
- LEAVE_XLIB();
- RETURN ( self );
- }
-
- /* TWOBYTESTRINGS */
- if (__isWords(aString)) {
- union {
- char b[2];
- unsigned short s;
- } u;
- int i;
- XChar2b *cp2;
- int mustFree = 0;
-
- n = (__byteArraySize(aString) - nInstBytes) / 2;
- if (n > lMax) n = lMax;
-
-#if defined(MSBFIRST) || defined(__MSBFIRST)
- /*
- * chars already in correct order
- */
-#else
-# if ! (defined(LSBFIRST) || defined(__LSBFIRST))
- /*
- * ST/X TwoByteStrings store the asciiValue in native byteOrder;
- * X expects them MSB first
- * convert as required
- */
- u.s = 0x1234;
- if (u.b[0] != 0x12)
-# endif
- {
- if (n <= NLOCALBUFFER) {
- cp2 = xlatebuffer;
- } else {
- cp2 = (XChar2b *)(malloc(n * 2));
- mustFree = 1;
- }
-
- for (i=0; i<n; i++) {
- cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
- cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
- }
- cp = (char *) cp2;
- }
-#endif
- ENTER_XLIB();
- if (opaque == true)
- XDrawImageString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
- else
- XDrawString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
- LEAVE_XLIB();
-
- if (mustFree) {
- free(cp2);
- }
-
- RETURN ( self );
- }
- }
-#undef NLOCALBUFFER
-#endif
-%}.
- ^ super displayString:aString x:x y:y opaque:opaque
-! !
!XGraphicsContext methodsFor:'initialization & release'!
@@ -156,8 +29,10 @@
super prepareForReinit.
xftDrawId := nil.
+ cairoSurfaceId := nil.
"Created: / 09-10-2014 / 00:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 26-12-2014 / 22:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!XGraphicsContext class methodsFor:'documentation'!