to be applied on the cairo branch
>From 6f7caeda688f07a71fa8e14ef328025853582984 Mon Sep 17 00:00:00 2001
From: Johann Haarhoff <[email protected]>
Date: Thu, 25 Mar 2010 22:31:47 +0200
Subject: [PATCH] Merge WM2 WINGs Examples and Tests

This completes the merging of the WM2 branch onto next. The tests
and examples don't compile yet, but the merge is complete
---
 WINGs/Examples/Makefile.am |    9 +++----
 WINGs/Tests/Makefile.am    |    7 ++---
 WINGs/Tests/wmquery.c      |   17 +++++++------
 WINGs/Tests/wtest.c        |   55 ++++++++++++++++++++++++++++++++++++++-----
 WINGs/wballoon.c           |   21 ++++++++--------
 WINGs/wcolor.c             |   14 +++++++----
 WINGs/wview.c              |   42 ++++++++++++++++-----------------
 7 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/WINGs/Examples/Makefile.am b/WINGs/Examples/Makefile.am
index 437dc10..e5dcb1d 100644
--- a/WINGs/Examples/Makefile.am
+++ b/WINGs/Examples/Makefile.am
@@ -3,12 +3,11 @@
 AUTOMAKE_OPTIONS = no-dependencies
 
 
-noinst_PROGRAMS = connect server fontl puzzle colorpick
+noinst_PROGRAMS = connect server fontl
 
-
-LDADD= $(top_builddir)/WINGs/libWINGs.la $(top_builddir)/wrlib/libwraster.la \
-       $(top_builddir)/WINGs/libWUtil.la \
-       @XFTLIBS@ @INTLIBS@
+LDADD= $(top_builddir)/WINGs/.libs/libWINGs.a \
+               $(top_builddir)/WINGs/.libs/libWUtil.a \
+               @XLIBS@ @XFTLIBS@ @INTLIBS@ @GLIB_LIBS@ @CAIRO_LIBS@
 
 colorpick_DEPENDENCIES = $(top_builddir)/WINGs/libWINGs.la
 
diff --git a/WINGs/Tests/Makefile.am b/WINGs/Tests/Makefile.am
index 977ac31..ed6463e 100644
--- a/WINGs/Tests/Makefile.am
+++ b/WINGs/Tests/Makefile.am
@@ -4,10 +4,9 @@ AUTOMAKE_OPTIONS = no-dependencies
 
 noinst_PROGRAMS = wtest wmquery wmfile testmywidget 
 
-LDADD= $(top_builddir)/WINGs/libWINGs.la $(top_builddir)/wrlib/libwraster.la \
-       $(top_builddir)/WINGs/libWUtil.la \
-       @XFTLIBS@ @INTLIBS@
-
+LDADD= $(top_builddir)/WINGs/.libs/libWINGs.a \
+               $(top_builddir)/WINGs/.libs/libWUtil.a \
+               @XLIBS@ @XFTLIBS@ @INTLIBS@ @CAIRO_LIBS@ @GLIB_LIBS@
 
 testmywidget_SOURCES = testmywidget.c mywidget.c mywidget.h 
 
diff --git a/WINGs/Tests/wmquery.c b/WINGs/Tests/wmquery.c
index dac7031..57a6388 100644
--- a/WINGs/Tests/wmquery.c
+++ b/WINGs/Tests/wmquery.c
@@ -79,12 +79,13 @@ int main(int argc, char **argv)
 
        pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
 
-       WMSetApplicationIconPixmap(scr, pixmap);
-       WMReleasePixmap(pixmap);
-
-       if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", 
"Cancel")) != NULL)
-               printf("%s\n", result);
-       else
-               printf("\n");
-       return 0;
+       //XXXWMSetApplicationIconPixmap(scr, pixmap);
+       //XXXWMReleasePixmap(pixmap);
+
+       //XXXif ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, 
"OK", "Cancel")) != NULL)
+       //XXX   printf("%s\n", result);
+       //XXXelse
+       //XXX   printf("\n");
+       //XXXreturn 0;
+    return 0;
 }
diff --git a/WINGs/Tests/wtest.c b/WINGs/Tests/wtest.c
index 565b526..b1ba52b 100644
--- a/WINGs/Tests/wtest.c
+++ b/WINGs/Tests/wtest.c
@@ -32,12 +32,12 @@ void closeAction(WMWidget * self, void *data)
                exit(0);
 }
 
+#if 0
 void testOpenFilePanel(WMScreen * scr)
 {
        WMOpenPanel *panel;
 
        /* windowCount++; */
-#if 0
        /* get the shared Open File panel */
        panel = WMGetOpenPanel(scr);
 
@@ -289,7 +289,9 @@ void testButton(WMScreen * scr)
        WMMapSubwidgets(win);
        WMMapWidget(win);
 }
+#endif
 
+#ifdef obsolete
 void testGradientButtons(WMScreen * scr)
 {
        WMWindow *win;
@@ -380,7 +382,9 @@ void testGradientButtons(WMScreen * scr)
        WMMapSubwidgets(win);
        WMMapWidget(win);
 }
+#endif
 
+#if 0
 void testScrollView(WMScreen * scr)
 {
        WMWindow *win;
@@ -512,7 +516,44 @@ void testSlider(WMScreen * scr)
        WMMapSubwidgets(win);
        WMMapWidget(win);
 }
+#endif
+
+void testStuff(WMScreen *scr)
+{
+       WMWindow *win;
+       WMLabel *label;
+       WMButton *button;
+
+       windowCount++;
+
+       win = WMCreateWindow(scr, "testTextField");
+       WMResizeWidget(win, 400, 300);
+
+       WMSetWindowCloseAction(win, closeAction, NULL);
+
+
+       label= WMCreateLabel(win);
+       WMSetLabelText(label, "HELLO");
+       WMResizeWidget(label, 100, 20);
+       WMMoveWidget(label, 10, 100);
+
+       button= WMCreateCommandButton(win);
+       WMSetButtonText(button, "OK");
+       WMResizeWidget(button, 80, 24);
+       WMMoveWidget(button, 400-80-12, 300-24-12);
+
+       button= WMCreateCommandButton(win);
+       WMSetButtonText(button, "Cancel");
+       WMResizeWidget(button, 80, 24);
+       WMMoveWidget(button, 400-80-12-80-12, 300-24-12);
+
+
+       WMRealizeWidget(win);
+       WMMapSubwidgets(win);
+       WMMapWidget(win);
+}
 
+#if 0
 void testTextField(WMScreen * scr)
 {
        WMWindow *win;
@@ -914,6 +955,7 @@ void testUD()
        WMSetUDStringForKey(defs, str, "testKey");
        puts(str);
 }
+#endif
 
 int main(int argc, char **argv)
 {
@@ -923,7 +965,7 @@ int main(int argc, char **argv)
        /* Initialize the application */
        WMInitializeApplication("t...@eqweq_ewq$eqw", &argc, argv);
 
-       testUD();
+       //XXXtestUD();
 
        /*
         * Open connection to the X display.
@@ -956,8 +998,8 @@ int main(int argc, char **argv)
         * Makes the logo be used in standard dialog panels.
         */
        if (pixmap) {
-               WMSetApplicationIconPixmap(scr, pixmap);
-               WMReleasePixmap(pixmap);
+               //XXXWMSetApplicationIconPixmap(scr, pixmap);
+               //XXXWMReleasePixmap(pixmap);
        }
 
        /*
@@ -965,7 +1007,9 @@ int main(int argc, char **argv)
         *
         * Put the testSomething() function you want to test here.
         */
+       testStuff(scr);
 
+#if 0
        testText(scr);
        testFontPanel(scr);
 
@@ -973,8 +1017,6 @@ int main(int argc, char **argv)
 
        testTextField(scr);
 
-#if 0
-
        testBox(scr);
        testButton(scr);
        testColorPanel(scr);
@@ -997,6 +1039,5 @@ int main(int argc, char **argv)
         *
         */
        WMScreenMainLoop(scr);
-#endif
        return 0;
 }
diff --git a/WINGs/wballoon.c b/WINGs/wballoon.c
index 0c52fd6..ee045e0 100644
--- a/WINGs/wballoon.c
+++ b/WINGs/wballoon.c
@@ -240,10 +240,11 @@ void W_BalloonHandleEnterView(WMView * view)
 static void drawBalloon(WMScreen * scr, Pixmap bitmap, Pixmap pix, int x, int 
y, int w, int h, int side)
 {
        Display *dpy = scr->display;
-       WMColor *white = WMWhiteColor(scr);
-       WMColor *black = WMBlackColor(scr);
+       //XXXWMColor *white = WMWhiteColor(scr);
+       //XXXWMColor *black = WMBlackColor(scr);
        GC bgc = scr->monoGC;
-       GC gc = WMColorGC(white);
+       //XXXGC gc = WMColorGC(white);
+       GC gc = scr->monoGC;
        int rad = h * 3 / 10;
        XPoint pt[3], ipt[3];
        int w1;
@@ -315,7 +316,7 @@ static void drawBalloon(WMScreen * scr, Pixmap bitmap, 
Pixmap pix, int x, int y,
        XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
 
        /* fix outline */
-       XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
+       //XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
        if (side & RIGHT) {
                pt[0].x++;
                pt[2].x--;
@@ -323,10 +324,10 @@ static void drawBalloon(WMScreen * scr, Pixmap bitmap, 
Pixmap pix, int x, int y,
                pt[0].x--;
                pt[2].x++;
        }
-       XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
+       //XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
 
-       WMReleaseColor(white);
-       WMReleaseColor(black);
+       //WMReleaseColor(white);
+       //WMReleaseColor(black);
 }
 
 static Pixmap makePixmap(WMScreen * scr, int width, int height, int side, 
Pixmap * mask)
@@ -335,7 +336,7 @@ static Pixmap makePixmap(WMScreen * scr, int width, int 
height, int side, Pixmap
        Pixmap bitmap;
        Pixmap pixmap;
        int x, y;
-       WMColor *black = WMBlackColor(scr);
+       //WMColor *black = WMBlackColor(scr);
 
        bitmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + 
SPACE, 1);
 
@@ -344,7 +345,7 @@ static Pixmap makePixmap(WMScreen * scr, int width, int 
height, int side, Pixmap
 
        pixmap = XCreatePixmap(dpy, scr->rootWin, width + SPACE, height + 
SPACE, scr->depth);
 
-       XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, width + SPACE, 
height + SPACE);
+       //XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, width + SPACE, 
height + SPACE);
 
        if (side & BOTTOM) {
                y = 0;
@@ -357,7 +358,7 @@ static Pixmap makePixmap(WMScreen * scr, int width, int 
height, int side, Pixmap
 
        *mask = bitmap;
 
-       WMReleaseColor(black);
+       //WMReleaseColor(black);
 
        return pixmap;
 }
diff --git a/WINGs/wcolor.c b/WINGs/wcolor.c
index 69b4164..8d0ac7a 100644
--- a/WINGs/wcolor.c
+++ b/WINGs/wcolor.c
@@ -57,6 +57,7 @@ static WMColor *createRGBAColor(WMScreen * scr, unsigned 
short red, unsigned sho
        return color;
 }
 
+#ifdef obsolete
 WMColor *WMCreateRGBColor(WMScreen * scr, unsigned short red, unsigned short 
green,
                          unsigned short blue, Bool exact)
 {
@@ -70,6 +71,7 @@ WMColor *WMCreateRGBColor(WMScreen * scr, unsigned short red, 
unsigned short gre
 
        return color;
 }
+#endif
 
 WMColor* WMCreateColorWithSpec(WMScreen *scr, WMColorSpec *spec)
 {
@@ -79,7 +81,7 @@ WMColor* WMCreateColorWithSpec(WMScreen *scr, WMColorSpec 
*spec)
                color = findCloseColor(scr, spec->red<<8, spec->green<<8, 
spec->blue<<8, 0xffff);
 
        if (!color)
-               color = WMBlackColor(scr);
+               createRGBAColor(scr, spec->red<<8, spec->green<<8, 
spec->blue<<8, 0xffff);
 
        return color;
 }
@@ -102,7 +104,7 @@ WMColor *WMCreateRGBAColor(WMScreen * scr, unsigned short 
red, unsigned short gr
                color = findCloseColor(scr, red, green, blue, alpha);
        }
        if (!color)
-               color = WMBlackColor(scr);
+               color = createRGBAColor(scr, 0,0,0,0);
 
        return color;
 }
@@ -184,6 +186,8 @@ void WMSetColorInGC(WMColor * color, GC gc)
 }
 
 /* "system" colors */
+#ifdef obsolete
+
 WMColor *WMWhiteColor(WMScreen * scr)
 {
        if (!scr->white) {
@@ -193,7 +197,6 @@ WMColor *WMWhiteColor(WMScreen * scr)
        }
        return WMRetainColor(scr->white);
 }
-#ifdef obsolete
 
 WMColor *WMBlackColor(WMScreen * scr)
 {
@@ -204,7 +207,7 @@ WMColor *WMBlackColor(WMScreen * scr)
        }
        return WMRetainColor(scr->black);
 }
-#endif
+
 WMColor *WMGrayColor(WMScreen * scr)
 {
        if (!scr->gray) {
@@ -213,7 +216,7 @@ WMColor *WMGrayColor(WMScreen * scr)
                if (scr->depth == 1) {
                        Pixmap stipple;
                        WMColor *white = WMWhiteColor(scr);
-                       WMColor *black = WMBlackColor(scr);
+                       WMColor *black = WMBlackColorSpec(scr);
                        XGCValues gcv;
 
                        stipple = XCreateBitmapFromData(scr->display, 
W_DRAWABLE(scr),
@@ -242,6 +245,7 @@ WMColor *WMGrayColor(WMScreen * scr)
        }
        return WMRetainColor(scr->gray);
 }
+#endif
 
 WMColor *WMDarkGrayColor(WMScreen * scr)
 {
diff --git a/WINGs/wview.c b/WINGs/wview.c
index 94d0b89..d0893ea 100644
--- a/WINGs/wview.c
+++ b/WINGs/wview.c
@@ -102,19 +102,17 @@ static W_View *createView(W_Screen * screen, W_View * 
parent)
        view->backColor= WMWhiteColorSpec();
 
        if (parent!=NULL) {
-               WMColor *xcolor= WMCreateColorWithSpec(screen, 
&view->backColor);
+               //XXXWMColor *xcolor= WMCreateColorWithSpec(screen, 
&view->backColor);
 
                /* attributes are not valid for root window */
                view->attribFlags = CWEventMask|CWBitGravity;
                view->attribs = defAtts;
 
                view->attribFlags |= CWBackPixel|CWColormap|CWBorderPixel;
-               view->attribs.background_pixel = W_PIXEL(xcolor);
+               view->attribs.background_pixel = 
WMCreateRGBAColor(screen,0,0,0,0,0);
                view->attribs.border_pixel = 0;
                view->attribs.colormap = screen->colormap;
 
-               WMReleaseColor(xcolor);
-
                adoptChildView(parent, view);
        }
 
@@ -374,24 +372,6 @@ static void destroyView(W_View * view)
                if (ptr == view->childrenList) {
                        view->childrenList = ptr->nextSister;
                        ptr->parent = NULL;
-cairo_t*
-W_CreateCairoForView(W_View *view)
-{
-    cairo_surface_t *surface;
-    cairo_t *cairo;
-
-    surface= cairo_xlib_surface_create(W_VIEW_DISPLAY(view),
-                                       W_VIEW_DRAWABLE(view),
-                                       W_VIEW_SCREEN(view)->visual,
-                                       W_VIEW_WIDTH(view),
-                                       W_VIEW_HEIGHT(view));
-    cairo= cairo_create(surface);
-    cairo_surface_destroy(surface);
-    cairo_translate(cairo, 0.5, 0.5);
-    cairo_set_line_width(cairo, 1.0);
-
-    return cairo;
-}
 
                }
        }
@@ -420,6 +400,24 @@ W_CreateCairoForView(W_View *view)
        wfree(view);
 }
 
+cairo_t* W_CreateCairoForView(W_View *view)
+{
+       cairo_surface_t *surface;
+       cairo_t *cairo;
+
+       surface= cairo_xlib_surface_create(W_VIEW_DISPLAY(view),
+                       W_VIEW_DRAWABLE(view),
+                       W_VIEW_SCREEN(view)->visual,
+                       W_VIEW_WIDTH(view),
+                       W_VIEW_HEIGHT(view));
+       cairo= cairo_create(surface);
+       cairo_surface_destroy(surface);
+       cairo_translate(cairo, 0.5, 0.5);
+       cairo_set_line_width(cairo, 1.0);
+
+       return cairo;
+}
+
 void W_DestroyView(W_View * view)
 {
        view->refCount--;
-- 
1.6.0.3

Reply via email to