Example #1
0
        //throws gnu.x11.extension.NotFoundException {
        public PrintHello(String [] args)
            : base(args)
        {
            String printer_name = option.option ("printer");

            about ("0.1", "print hello world",
              "Stephen Tse <*****@*****.**>",
              "http://escher.sourceforge.net/");

            if (help_option) return;

            Print print = new Print (display);
            Print.Context context = print.create_context (printer_name);

            Console.WriteLine (print);
            Console.WriteLine (context);

            context.set_attributes (Print.Context.JOB_ATTRIBUTE_POOL,
              Print.Context.ATTRIBUTE_MERGE,
              "*job-name: Hello world for Xprint");
            context.set ();
            print.start_job (Print.SPOOL);

            Window root = context.screen ();
            GC gc = root.screen ().default_gc ();
            gc.set_font (new gnu.x11.Font (display, FONT));
            Window window = new Window (root, 100, 100, 100, 100);
            window.create ();

            print.start_page (window);
            window.map ();
            window.text (gc, 20, 30, "Hello World!");
            print.end_page ();

            print.end_job ();
            context.destroy ();
            display.close ();
        }
Example #2
0
        protected void init_window(int width, int height)
        {
            visual_config = glx.visual_config (visual_config);
            int vid = visual_config.visual_id ();
            gl = glx.create_context (vid, display.default_screen_no, GL.NONE0);

            // FIXME share colormap
            Colormap colormap = new Colormap (display.default_root, vid, false);

            Window.Attributes attr = new Window.Attributes ();
            attr.set_colormap (colormap);

            // TODO use depth of x visual config instead of
            // `visual_config.buffer_size'?
            int depth = visual_config.buffer_size ();

            int more = Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK; // compulsory

            /* Bugs? Whenever button motion events are selected, it is required to
             * select button press event as well.
             */
             if ((event_mask & ANY_BUTTON_MOTION_BITS) != 0)
               more |= Event.BUTTON_PRESS_MASK;
             attr.set_event_mask (event_mask | more);

            window = new Window (display.default_root, 10, 10, width, height);
            window.create (5, depth, Window.INPUT_OUTPUT, vid, attr);

            window.set_wm (this, "main");
            window.set_wm_delete_window ();

            gl.make_current (window);
            glu = new GLU (gl);
            glut = new GLUT (glu);
        }