void ui_mouse_init() { int i, w,h; //mouse_init(); w = grd_curscreen->sc_w; h = grd_curscreen->sc_h; mouse_set_limits( 0,0, w-1, h-1 ); Mouse.x = w/2; Mouse.y = h/2; //mouse_set_pos( w/2, h/2 ); for (i=0; i < PTR_W*PTR_H; i++ ) { switch (ui_mouse_pointer[i]) { case '0': ui_converted_mouse_pointer[i]=255; break; case '1': ui_converted_mouse_pointer[i]=CBLACK; break; case '2': ui_converted_mouse_pointer[i]=CGREY; break; case '3': ui_converted_mouse_pointer[i]=CWHITE; break; case '4': ui_converted_mouse_pointer[i]=CBRIGHT; break; case '5': ui_converted_mouse_pointer[i]=CRED; break; } } default_pointer = gr_create_bitmap_raw( PTR_W, PTR_H, ui_converted_mouse_pointer ); Mouse.x = Mouse.y = 0; Mouse.backwards = 0; Mouse.hidden = 1; Mouse.b1_status = Mouse.b1_last_status = BUTTON_RELEASED; Mouse.b2_status = Mouse.b2_last_status = BUTTON_RELEASED; Mouse.b3_status = Mouse.b3_last_status = BUTTON_RELEASED; Mouse.bg_x = Mouse.bg_y = 0; Mouse.bg_saved = 0; Mouse.pointer = default_pointer; Mouse.background = gr_create_bitmap( Mouse.pointer->bm_w, Mouse.pointer->bm_h ); Mouse.time_lastpressed = 0; Mouse.moved = 0; }
UI_WINDOW * ui_open_window( short x, short y, short w, short h, int flags ) { UI_WINDOW * wnd; int sw, sh, req_w, req_h; wnd = (UI_WINDOW *)malloc(sizeof(UI_WINDOW)); if (wnd==NULL) exit(1); W_NEXT = NULL; W_PREV = NULL; add_window_to_end( wnd ); sw = grd_curscreen->sc_w; sh = grd_curscreen->sc_h; mouse_set_limits( 0,0, sw-1, sh-1 ); req_w = w; req_h = h; if (flags & WIN_BORDER) { x -= BORDER_WIDTH; y -= BORDER_WIDTH; w += 2*BORDER_WIDTH; h += 2*BORDER_WIDTH; } if ( x < 0 ) x = 0; if ( (x+w-1) >= sw ) x = sw - w; if ( y < 0 ) y = 0; if ( (y+h-1) >= sh ) y = sh - h; W_X = x; W_Y = y; W_WIDTH = w; W_HEIGHT = h; W_OLDCANVAS = grd_curcanv; W_GADGET = NULL; wnd->keyboard_focus_gadget = NULL; ui_mouse_hide(); if (flags & WIN_SAVE_BG) { W_BACKGROUND = gr_create_bitmap( w, h ); gr_bm_ubitblt(w, h, 0, 0, x, y, &(grd_curscreen->sc_canvas.cv_bitmap), W_BACKGROUND ); } else W_BACKGROUND = NULL; if (flags & WIN_BORDER) { W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x+BORDER_WIDTH, y+BORDER_WIDTH, req_w, req_h ); gr_set_current_canvas( NULL ); ui_draw_frame( x, y, x+w-1, y+h-1 ); } else W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x, y, req_w, req_h ); gr_set_current_canvas( W_CANVAS ); if (flags & WIN_FILLED) ui_draw_box_out( 0, 0, req_w-1, req_h-1 ); gr_set_fontcolor( CBLACK, CWHITE ); selected_gadget = NULL; W_TEXT_X = 0; W_TEXT_Y = 0; return wnd; }