vbutton * buttonmenu_no_backdrop(button * buttons, Sint32 numbuttons, Sint32 redraw) { Sint32 i; for (i=1; i < MAX_BUTTONS; i++) // skip # 0! { if (allbuttons[i]) delete allbuttons[i]; allbuttons[i] = NULL; } for (i=0; i < numbuttons; i++) { allbuttons[i] = new vbutton(buttons[i].x,buttons[i].y, buttons[i].sizex, buttons[i].sizey, buttons[i].myfun, buttons[i].arg1, buttons[i].label, buttons[i].hotkey); myscreen->draw_box(allbuttons[i]->xloc-1, allbuttons[i]->yloc-1, allbuttons[i]->xend, allbuttons[i]->yend, 0, 0, 1); } release_mouse(); //if (redraw) // myscreen->buffer_to_screen(0, 0, 320, 200); grab_mouse(); return allbuttons[0]; }
// ------------------------------------------------------------------------ // window to display an adventure map // ------------------------------------------------------------------------ void t_adventure_map_window::left_button_up( t_mouse_event const& event ) { assert( m_frame ); if (m_dragging) { drag( event.screen_point ); release_mouse(); m_dragging = false; } if (m_object_mover != 0) { halt_movement(); return; } if ( m_spell_targeter != 0 ) { m_spell_targeter->cast_spell( *this, event.client_point ); clear_spell_targeter(); return; } t_army* army = m_frame->get_selected_army(); if (army == 0) return; // otherwise, move the temporary hero. t_adventure_path_point path_point; t_adventure_path path; // abort if this is not a valid location. if (!get_path_point( event.client_point, path_point )) return; if (!(show_move_path())) { m_frame->get_path_finder()->get_path( path_point, path ); army->set_path( path ); } // check if the army has a valid path, and the path matches this point. if (army->get_destination() == path_point) { // start army moving. m_frame->start_army_moving( army ); return; } if (!m_frame->get_path_finder()->get_path( path_point, path )) { army->set_path( path ); return; } army->set_path( path ); m_map->display_path( path, army->get_movement() ); m_frame->update_buttons(); }
void Slider::on_mouse_up (const CL_InputEvent& event) { if (event.id == CL_MOUSE_LEFT) { pressed = false; release_mouse(); update_mouse(event); } }
void Root_widget::drop_child(Widget *child) { if (contains_widget( mouse_holder() )) { release_mouse(); } remove_child(child); invalidate(); }
void vbutton::vdisplay(Sint32 status) { if(hidden || no_draw) return; if (!status) // do normal { vdisplay(); return; } text& mytext = myscreen->text_normal; if (mypixie) // then use the graphic { mypixie->draw(xloc, yloc, myscreen->viewob[0]); if (label.size()) mytext.write_xy( (short) ( ((xloc+xend)/2) - (((label.size()-1)* (mytext.letters.w+1) )/2)) , (short) (yloc + (height-(mytext.letters.h))/2), label.c_str(), (unsigned char) DARK_BLUE, 1); } else { if (status == 1) { myscreen->draw_box(xloc,yloc,xend-1,yend-1,BUTTON_FACING-3,1,1); // front myscreen->draw_box(xloc,yloc,xend-2,yloc,BUTTON_BOTTOM,1,1); // top edge myscreen->draw_box(xloc,yloc+1,xloc,yend-2,BUTTON_RIGHT,1,1); // left myscreen->draw_box(xend-1,yloc+1,xend-1,yend-2,BUTTON_LEFT,1,1); // right myscreen->draw_box(xloc+1,yend-1,xend-1,yend-1,BUTTON_TOP,1,1); // bottom if (label.size()) mytext.write_xy( (short) ( ((xloc+xend)/2) - (((label.size()-1)* (mytext.letters.w+1) )/2)) , (short) (yloc + (height-(mytext.letters.h))/2), label.c_str(), (unsigned char) DARK_BLUE, 1); myscreen->buffer_to_screen(xloc,yloc,xend-xloc,yend-yloc); } else if (status == 2) // special (red) button.. { myscreen->draw_box(xloc,yloc,xend-1,yend-1,BUTTON_FACING+32,1,1); // front myscreen->draw_box(xloc,yloc,xend-2,yloc,BUTTON_TOP+32,1,1); // top edge myscreen->draw_box(xloc,yloc+1,xloc,yend-2,BUTTON_LEFT+32,1,1); // left myscreen->draw_box(xend-1,yloc+1,xend-1,yend-2,BUTTON_RIGHT+32,1,1); // right myscreen->draw_box(xloc+1,yend-1,xend-1,yend-1,BUTTON_BOTTOM+32,1,1); // bottom if (label.size()) mytext.write_xy( (short) ( ((xloc+xend)/2) - (((label.size()-1)* (mytext.letters.w+1) )/2)) , (short) (yloc + (height-(mytext.letters.h))/2), label.c_str(), (unsigned char) DARK_BLUE, 1); } } release_mouse(); //buffers: myscreen->buffer_to_screen(0, 0, 320, 200); // Zardus: following isn't really needed and it messes up the fading //myscreen->buffer_to_screen(xloc,yloc,xend-xloc,yend-yloc); grab_mouse(); }
//after this point old code void clearmenu(button *buttons, short numbuttons) { short i; // First remove the mouse .. release_mouse(); for (i=0; i < numbuttons; i++) { myscreen->fastbox(buttons[i].x-1, buttons[i].y-1, buttons[i].sizex+3, buttons[i].sizey+3, 0, 1); } // Clear the WHOLE screen //myscreen->clearbuffer(); //commented out temporarily to see if ok // DARK_BLUEisplay the mouse grab_mouse(); }
// ------------------------------------------------------------------------ // window to display an adventure map // ------------------------------------------------------------------------ void t_adventure_map_window::mouse_move( t_mouse_event const& event ) { if (!m_dragging) { if ( get_mouse_position( this ) != event.client_point ) return; update_cursor( event.client_point ); return; } if (!event.left_button) { release_mouse(); m_dragging = false; return; } // check event message against current mouse position. if ( get_mouse_position( this ) != event.client_point ) return; drag( event.screen_point ); }
LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) { GF_Event evt; DDContext *ctx; GF_VideoOutput *vout = (GF_VideoOutput *) GetWindowLong(hWnd, GWL_USERDATA); if (!vout) return DefWindowProc (hWnd, msg, wParam, lParam); ctx = (DDContext *)vout->opaque; switch (msg) { case WM_SIZE: /*always notify GPAC since we're not sure the owner of the window is listening to these events*/ evt.type = GF_EVENT_SIZE; evt.size.width = LOWORD(lParam); evt.size.height = HIWORD(lParam); vout->on_event(vout->evt_cbk_hdl, &evt); break; case WM_CLOSE: if (hWnd==ctx->os_hwnd) { evt.type = GF_EVENT_QUIT; vout->on_event(vout->evt_cbk_hdl, &evt); } return 1; case WM_DESTROY: if (ctx->owns_hwnd || (hWnd==ctx->fs_hwnd)) { PostQuitMessage (0); } else if (ctx->orig_wnd_proc) { /*restore window proc*/ SetWindowLong(ctx->os_hwnd, GWL_WNDPROC, ctx->orig_wnd_proc); ctx->orig_wnd_proc = 0L; } break; case WM_ACTIVATE: #if 1 if (ctx->fullscreen && (LOWORD(wParam)==WA_INACTIVE) && (hWnd==ctx->fs_hwnd)) { evt.type = GF_EVENT_SHOWHIDE; vout->on_event(vout->evt_cbk_hdl, &evt); } #endif break; case WM_SETCURSOR: if (ctx->cur_hwnd==hWnd) DD_SetCursor(vout, ctx->cursor_type); return 1; case WM_ERASEBKGND: //InvalidateRect(ctx->cur_hwnd, NULL, TRUE); //break; case WM_PAINT: if (ctx->cur_hwnd==hWnd) { evt.type = GF_EVENT_REFRESH; vout->on_event(vout->evt_cbk_hdl, &evt); } break; case WM_KILLFOCUS: if (hWnd==ctx->os_hwnd) ctx->has_focus = 0; break; case WM_MOUSEMOVE: if (ctx->cur_hwnd!=hWnd) break; if (ctx->last_mouse_pos != lParam) { ctx->last_mouse_pos = lParam; DD_SetCursor(vout, (ctx->cursor_type==GF_CURSOR_HIDE) ? ctx->cursor_type_backup : ctx->cursor_type); evt.type = GF_EVENT_MOUSEMOVE; DD_GetCoordinates(lParam, &evt); vout->on_event(vout->evt_cbk_hdl, &evt); mouse_start_timer(ctx, hWnd, vout); } break; case WM_TIMER: if (wParam==10) { if (ctx->fullscreen && (ctx->cursor_type!=GF_CURSOR_HIDE)) { if (gf_sys_clock() > MOUSE_HIDE_TIMEOUT + ctx->last_mouse_move) { ctx->cursor_type_backup = ctx->cursor_type; DD_SetCursor(vout, GF_CURSOR_HIDE); KillTimer(hWnd, ctx->timer); ctx->timer = 0; } } } break; case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: grab_mouse(ctx, vout); evt.type = GF_EVENT_MOUSEDOWN; DD_GetCoordinates(lParam, &evt); evt.mouse.button = GF_MOUSE_LEFT; vout->on_event(vout->evt_cbk_hdl, &evt); if (!ctx->has_focus && (hWnd==ctx->os_hwnd)) { ctx->has_focus = 1; SetFocus(ctx->os_hwnd); } break; case WM_LBUTTONUP: release_mouse(ctx, hWnd, vout); evt.type = GF_EVENT_MOUSEUP; DD_GetCoordinates(lParam, &evt); evt.mouse.button = GF_MOUSE_LEFT; vout->on_event(vout->evt_cbk_hdl, &evt); break; case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: grab_mouse(ctx, vout); evt.type = GF_EVENT_MOUSEDOWN; DD_GetCoordinates(lParam, &evt); evt.mouse.button = GF_MOUSE_RIGHT; vout->on_event(vout->evt_cbk_hdl, &evt); if (!ctx->has_focus && (hWnd==ctx->os_hwnd)) { ctx->has_focus = 1; SetFocus(ctx->os_hwnd); } break; case WM_RBUTTONUP: release_mouse(ctx, hWnd, vout); evt.type = GF_EVENT_MOUSEUP; DD_GetCoordinates(lParam, &evt); evt.mouse.button = GF_MOUSE_RIGHT; vout->on_event(vout->evt_cbk_hdl, &evt); mouse_start_timer(ctx, hWnd, vout); break; case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: grab_mouse(ctx, vout); evt.type = GF_EVENT_MOUSEDOWN; evt.mouse.button = GF_MOUSE_MIDDLE; DD_GetCoordinates(lParam, &evt); vout->on_event(vout->evt_cbk_hdl, &evt); if (!ctx->has_focus && (hWnd==ctx->os_hwnd)) { ctx->has_focus = 1; SetFocus(ctx->os_hwnd); } break; case WM_MBUTTONUP: release_mouse(ctx, hWnd, vout); evt.type = GF_EVENT_MOUSEUP; DD_GetCoordinates(lParam, &evt); evt.mouse.button = GF_MOUSE_MIDDLE; vout->on_event(vout->evt_cbk_hdl, &evt); mouse_start_timer(ctx, hWnd, vout); break; case WM_MOUSEWHEEL: if (ctx->cur_hwnd==hWnd) { DD_SetCursor(vout, (ctx->cursor_type==GF_CURSOR_HIDE) ? ctx->cursor_type_backup : ctx->cursor_type); evt.type = GF_EVENT_MOUSEWHEEL; DD_GetCoordinates(lParam, &evt); evt.mouse.wheel_pos = FLT2FIX( ((Float) (s16) HIWORD(wParam)) / WHEEL_DELTA ); vout->on_event(vout->evt_cbk_hdl, &evt); mouse_start_timer(ctx, hWnd, vout); } return 1; /*there's a bug on alt state (we miss one event)*/ case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: case WM_KEYDOWN: w32_translate_key(wParam, lParam, &evt.key); evt.type = ((msg==WM_SYSKEYDOWN) || (msg==WM_KEYDOWN)) ? GF_EVENT_KEYDOWN : GF_EVENT_KEYUP; vout->on_event(vout->evt_cbk_hdl, &evt); break; case WM_CHAR: evt.type = GF_EVENT_TEXTINPUT; evt.character.unicode_char = wParam; vout->on_event(vout->evt_cbk_hdl, &evt); break; } return DefWindowProc (hWnd, msg, wParam, lParam); }