
#include "WINGs.h"

#include <stdio.h>

void
wAbort()
{
    exit(1);
}

char *ProgName= "test";

Display *dpy;

void
testOpenFilePanel(WMScreen *scr)
{
    WMOpenPanel *panel;
    panel = WMCreateOpenPanel(scr);
    
    WMRunModalOpenPanelForDirectory(panel, "/usr/local", NULL, NULL);
    
    WMDestroyFilePanel(panel);
}


void
testColorWell(WMScreen *scr)
{
    WMWindow *win;
    WMColorWell *well1, *well2;

    win = WMCreateWindow(scr);
    WMResizeWidget(win, 300, 300);

    well1 = WMCreateColorWell(win);
    WMResizeWidget(well1, 40, 30);
    WMMoveWidget(well1, 100, 100);
    WMSetColorWellColor(well1, WMCreateRGBColor(scr, 0x8888, 0, 0x1111, True));
    well2 = WMCreateColorWell(win);
    WMResizeWidget(well2, 40, 30);
    WMMoveWidget(well2, 200, 100);
    WMSetColorWellColor(well2, WMCreateRGBColor(scr, 0, 0, 0x8888, True));
    
    WMRealizeWidget(win);
    WMMapSubwidgets(win);
    WMMapWidget(win);
}

void
testTextField(WMScreen *scr)
{
    WMWindow *win;
    WMTextField *field, *field2;

    win = WMCreateWindow(scr);
    WMResizeWidget(win, 400, 300);

    field = WMCreateTextField(win);
    WMResizeWidget(field, 200, 20);
    WMMoveWidget(field, 20, 20);

    field2 = WMCreateTextField(win);
    WMResizeWidget(field2, 200, 20);
    WMMoveWidget(field2, 20, 50);
    WMSetTextFieldAlignment(field2, WARight);

    WMRealizeWidget(win);
    WMMapSubwidgets(win);
    WMMapWidget(win);
    
}


int main(int argc, char **argv)
{
    WMScreen *scr;
    WMPixmap *pixmap;

    dpy = XOpenDisplay("");
    
    if (!dpy) {
	puts("could not open display");
	exit(1);
    }
    
    XSynchronize(dpy, True);
    
    scr = WMCreateScreen(dpy, DefaultScreen(dpy));

    pixmap = WMCreatePixmapFromFile(scr, "logo.xpm");
    
    WMSetApplicationIcon(scr, pixmap); WMReleasePixmap(pixmap);
    testColorWell(scr);
    
    while (1) {
	XEvent event;
	
	WMNextEvent(dpy, &event);
	WMHandleEvent(&event);
    }
    return 0;
}
