Example::Example() { #ifdef WIN32 clan::D3DTarget::set_current(); #else clan::OpenGLTarget::set_current(); #endif // Set the window 1 description clan::DisplayWindowDescription desc_window_1; desc_window_1.set_title("MultiWindow Example - Window 1"); desc_window_1.set_allow_resize(true); desc_window_1.set_position(clan::Rect(50, 50, clan::Size(350, 350)), false); // Set the window 2 description clan::DisplayWindowDescription desc_window_2; desc_window_2.set_title("MultiWindow Example - Window 2"); desc_window_2.set_allow_resize(true); desc_window_2.set_position(clan::Rect(50 + 350, 50, clan::Size(350, 350)), false); // Open the windows window_1 = clan::DisplayWindow(desc_window_1); window_2 = clan::DisplayWindow(desc_window_2); // Connect the Window close event - to both windows sc.connect(window_1.sig_window_close(), [&](){on_window_close(&window_1); }); sc.connect(window_2.sig_window_close(), [&](){on_window_close(&window_2); }); // Connect a keyboard handler to on_key_up() - to both windows sc.connect(window_1.get_keyboard().sig_key_up(), [=](const clan::InputEvent &input_event){on_input_up(input_event, 1); }); sc.connect(window_2.get_keyboard().sig_key_up(), [=](const clan::InputEvent &input_event){on_input_up(input_event, 2); }); // Get the canvas - for both windows canvas_1 = clan::Canvas(window_1); canvas_2 = clan::Canvas(window_2); // Load the example text - Note, any window can create the font font = clan::Font("tahoma", 64); game_time.reset(); }
int createconsole(int argc, char *argv[]) { if (win != NULL) return 1; if (app != NULL) /* delete existing partial data structures */ deleteconsole(); lines = malloc(NUM_LINES*NUM_COLUMNS*sizeof(TCHAR)); if (lines == NULL) return 0; memset(lines, __T(' '), NUM_LINES * NUM_COLUMNS); app = new_app(argc, argv); if (app == NULL) { deleteconsole(); return 0; } /* if */ font = new_font(app, "unifont", PLAIN | PORTABLE_FONT, 16); if (font == NULL) font = new_font(app, "courier", PLAIN | NATIVE_FONT, 16); if (font == NULL) font = find_default_font(app); if (font == NULL) { deleteconsole(); return 0; } /* if */ win = new_window(app, rect(0,0, NUM_COLUMNS*font_width(font,"x",1), NUM_LINES*font_height(font)), "Pawn console", TITLEBAR|CLOSEBOX|MAXIMIZE|MINIMIZE|CENTRED); on_window_redraw(win, window_redraw); on_window_close (win, window_close); on_window_key_down(win, window_key_action); /* normal keys (including CR) */ show_window(win); /* handle any pending events */ while (do_event(app)) /* nothing */; csrx = 0; csry = 0; autowrap = 0; attrib = 0x07; return 1; }
App::App() { // We support all display targets, in order listed here clan::OpenGLTarget::set_current(); // Set the window description clan::DisplayWindowDescription desc_window; desc_window.set_title("Layered Window Example"); desc_window.set_popup_window(); desc_window.set_allow_resize(false); desc_window.set_layered(true); desc_window.show_caption(false); desc_window.set_size(clan::Size(600, 600), false); // Open the windows window = clan::DisplayWindow(desc_window); sc.connect(window.sig_window_close(), [=](){on_window_close(); }); sc.connect(window.get_mouse().sig_key_down(), clan::bind_member(this, &App::on_mouse_down)); sc.connect(window.get_mouse().sig_key_dblclk(), clan::bind_member(this, &App::on_mouse_down)); sc.connect(window.get_mouse().sig_key_up(), clan::bind_member(this, &App::on_mouse_up)); sc.connect(window.get_mouse().sig_pointer_move(), [&](const clan::InputEvent &input){on_mouse_move(input, window); }); sc.connect(window.sig_lost_focus(), clan::bind_member(this, &App::on_lost_focus)); sc.connect(window.get_keyboard().sig_key_up(), clan::bind_member(this, &App::on_input_up)); canvas = clan::Canvas(window); // Get the graphics clan::FontDescription font_desc; font_desc.set_height(48); font_desc.set_subpixel(false); font_large = clan::Font("tahoma", font_desc); font_desc.set_height(30); font_small = clan::Font("tahoma", font_desc); tux = clan::Sprite(canvas, "round_tux.png"); tux_radius = tux.get_width() / 2; rock = clan::Image(canvas, "rock.png"); clan::BlendStateDescription blend_desc; blend_desc.enable_blending(false); blend_state_off = clan::BlendState(canvas, blend_desc); game_time.reset(); }