public Hello(String [] args) : base(args) { about ("0.1", "hello world", "Stephen Tse <*****@*****.**>", "http://escher.sourceforge.net/", "\nTo quit, press 'q', 'Q', ESCAPE, or any button."); if (help_option) return; Window.Attributes win_attr = new Window.Attributes (); win_attr.set_background (display.default_white); win_attr.set_border (display.default_black); win_attr.set_event_mask (Event.BUTTON_PRESS_MASK | Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK); Window window = new Window (display.default_root, 10, 10, 100, 50, 5, win_attr); window.set_wm (this, "main"); window.set_wm_delete_window (); window.map (); while (!exit_now) { Event evt = display.next_event (); switch (evt.code ()) { case gnu.x11.xevent.ButtonPress.CODE: exit (); break; case ClientMessage.CODE: if (((ClientMessage) evt).delete_window ()) exit (); break; case Expose.CODE: if (((Expose) evt).count () == 0) window.text (display.default_gc, 20, 30, "Hello World!"); break; case KeyPress.CODE: { KeyPress e = (KeyPress) evt; int keycode = e.detail (); int keystate = e.state (); int keysym = display.input.keycode_to_keysym (keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) exit (); break; } } } display.close (); }
//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 (); }