Standard GUI framework inspired by Qt

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 7 01:27:42 PST 2015


On Fri, 06 Mar 2015 18:55:31 +0000, Ola Fosheim Grøstad wrote:

> On Friday, 6 March 2015 at 17:03:51 UTC, ketmar wrote:
>> but i like it's core simplicity (oh, no, full xorg is a beast,
>> especially with
> 
> Opening a simple window with nothing on it in a portable and compliant
> manner using xlib is at least 800 lines of code...
> Simple!

ahem...

  //import iv.x11.X, iv.x11.Xlib;
  import iv.x11;
  import iv.writer;


  int main () {
    Display *dpy = XOpenDisplay();
    if (!dpy) {
      errwriteln("FATAL: XOpenDisplay failed!");
      return 1;
    }

    int screen = DefaultScreen(dpy);

    Window window = XCreateSimpleWindow(
      dpy,
      DefaultRootWindow(dpy),  //parent window
      0, 0, 323, 200, 0,           //x, y, width, height, border_width
      BlackPixel(dpy, screen), //border_color
      WhitePixel(dpy,screen)   //back_color
    );

    writefln!"dpy=%s; wid=%s"(dpy, window);

    XStoreName(dpy, window, "Example window");
    XSelectInput(dpy, window, ExposureMask);
    XMapWindow(dpy, window);

    Atom wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
    XSetWMProtocols(dpy, window, &wmDeleteMessage, 1);

    GC gc = DefaultGC(dpy, screen);

    bool running = true;
    while (running) {
      XEvent event;
      KeySym keySym;
      while (running && XPending(dpy)) {
        XNextEvent(dpy, &event);
        switch (event.type) {
          case ClientMessage:
            if (cast(Atom)event.xclient.data.l[0] == wmDeleteMessage) {
              writeln("delete message");
              running = false;
            }
            break;
          case Expose:
            auto ee = cast(XExposeEvent*)&event;
            writefln!"expose event(dpy=%s, wid=%s); serial=%s; send=%s; x=
%s; y=%s; count=%s"
               (ee.display, ee.window, ee.serial, ee.send_event, ee.x, 
ee.y, ee.count);
            XDrawString(dpy, cast(Drawable)window, gc, 10, 16, "Hello 
world!", 12);
            break;
          default:
        }
      }
    }

    XUnmapWindow(dpy, window);
    XDestroyWindow(dpy, window);
    XCloseDisplay(dpy);

    return 0;
  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150307/8bb34706/attachment.sig>


More information about the Digitalmars-d mailing list