public Graphics(String [] args, int width, int height) : base(args) { 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 = new Window(display.default_root, 10, 10, width, height, 5, win_attr); window.set_wm(this, "main"); window.set_wm_delete_window(); }
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); }
public DisplayHack(String [] args, bool clear, bool erase, bool rainbow_color, int default_color_count, int default_delay) : base(args) { this.thread = new Thread(new ThreadStart(this.run)); this.clear = clear; this.erase_ = erase; int color_count = option.intt("color-count", "total number of random colors", default_color_count); delay = option.longg("delay", "delay between screens in ms", default_delay); if (erase) { eraser_delay = option.longg("eraser-delay", "delay between iterations of eraser in ms", 10); eraser_delta = option.intt("eraser-delta", "granularity of eraser", 5, 1, 10); eraser_mode = option.Enum("eraser-mode", "which eraser", Eraser.ALL_STRINGS, Eraser.RANDOM_ERASER_INDEX); } Rectangle geometry = option.rectangle("geometry", "initial geometry of main window", new Rectangle(10, 10, 600, 480)); if (help_option) { return; } gc = gnu.x11.GC.build(display); if (erase_) { eraser_gc = gnu.x11.GC.build(display); } colors = new Color [color_count]; if (rainbow_color) { for (int i = 0; i < color_count; i++) { colors [i] = display.default_colormap. alloc_random_rainbow_color(random); } } else { for (int i = 0; i < color_count; i++) { colors [i] = display.default_colormap.alloc_random_color(random); } } Window.Attributes win_attr = new Window.Attributes(); win_attr.set_background(display.default_black); win_attr.set_event_mask(Event.BUTTON_PRESS_MASK | Event.STRUCTURE_NOTIFY_MASK | Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK); window = new Window(display.default_root, geometry, 0, win_attr); window.set_wm(this, "main"); window.set_wm_delete_window(); }
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(); }