dflplot/Plot2Kill, Most Mature *nix GUI For D2

dsimcha dsimcha at yahoo.com
Fri Jul 16 22:03:25 PDT 2010


== Quote from dsimcha (dsimcha at yahoo.com)'s article
> 1.  Doesn't Window mean that the plot would have to exist in its own window?  I'd
> like to be able to make a plot go to one section of a larger window.
> 2.  When I do:
> drawable = (new DrawingArea(800, 600)).getWindow();
> drawable somehow ends up null.

Never mind, I figured this stuff out, though the documentation is rather obtuse
and in serious need of examples of how to accomplish simple things.  However, I
can't get the DrawingArea to actually show up on the screen.  I just get a blank
window.  Here's a reduced test case.  Can someone tell me what's wrong w/ it
and/or provide minimal example code to get stuff drawn via DrawingArea to show up
on screen?

import gtk.DrawingArea, gtk.Main, gtk.MainWindow, gdk.GC, gdk.Drawable,
    gdk.Color;

void main(string[] args) {
    Main.init(args);

    auto win = new MainWindow("Hello, world");
    win.setDefaultSize(800, 600);
    auto drawingArea = new DrawingArea(800, 600);
    win.add(drawingArea);
    drawingArea.realize();

    auto drawable = drawingArea.getWindow();
    auto gc = new GC(drawable);
    gc.setForeground(new Color(255, 0, 0));
    gc.setBackground(new Color(255, 255, 255));
    drawable.drawLine(gc, 0, 0, 100, 100);

    drawingArea.showAll();
    drawingArea.queueDraw();
    win.showAll();

    Main.run();
}


More information about the Digitalmars-d mailing list