use oos::def::*; use oos::wn::gdi::*; use oos::wn::ui::*; const BALL_NUMBER: usize = 8; const YSPACE: INT = 5; static mut RECT: [rc::RCT;BALL_NUMBER] = [rc::NULL;BALL_NUMBER]; static mut DC: HAND = NULL; static mut WIN_SIZE: rc::RCT = rc::NULL; static mut PIECE: INT = 0; static mut YPIECE: INT = 0; static mut HALF: INT = 0; unsafe extern "stdcall" fn proc( wnd: HAND, msg: UINT, wparam: WPARAM, lparam: LPARAM ) -> LRESULT{ if msg == mg::message::CREATE{ DC = dc::get(wnd); rc::get(wnd, std::ptr::addr_of_mut!(WIN_SIZE)); PIECE = WIN_SIZE.width / BALL_NUMBER as INT; YPIECE = WIN_SIZE.height / YSPACE; HALF = WIN_SIZE.height / 2; for i in 0..BALL_NUMBER{ RECT[i].left = PIECE * i as INT; RECT[i].top = HALF; RECT[i].width = PIECE; RECT[i].height = YPIECE; } }else if msg == mg::message::PAINT{ draw::rect(wnd, WIN_SIZE.left, WIN_SIZE.top, WIN_SIZE.width, WIN_SIZE.height); for i in 0..BALL_NUMBER{ draw::rect(DC, RECT[i].left, RECT[i].top, RECT[i].width, RECT[i].height); RECT[i].top -= 1; } } mg::default(wnd, msg, wparam, lparam) } static mut HWND: HAND = NULL; static mut MSG: mg::MSG = mg::NULL; static mut CLS: rg::CLS = rg::CLS{ style: rg::style::OWNDC, proc: proc, cls_extra: 0, win_extra: 0, inst: NULL, icon: NULL, cursor: NULL, bkg: NULL, menu_name: SCNULL, cls_name: "OrangeTestWindow\0".as_ptr() }; #[test] fn tests() {unsafe{ CLS.inst = oos::wn::lb::get(SNULL); rg::reg(std::ptr::addr_of_mut!(CLS)); HWND = wn::new( 0, CLS.cls_name, "There!->->->->->->->->->->->->\0".as_ptr(), wn::style::WINDOW | wn::style::VISIT, -1, -1, 1000, 500, NULL, 0, CLS.inst, NULL ); while mg::get(std::ptr::addr_of_mut!(MSG), HWND, 0, 0) != 0{ mg::translate(std::ptr::addr_of_mut!(MSG)); mg::dispatch(std::ptr::addr_of_mut!(MSG)); mg::post(HWND, mg::message::PAINT, 0, 0); } }}