//绘制从父节点往子节点绘制 bool XWidget::responseEvent(X_Event *event) { if(!visible) { return false; } #ifdef USE_MOUSE if(event->type >= X_MOUSEMOTION && event->type <= X_MOUSEBUTTONUP ) { //如果鼠标或者点击在矩形内 if(devEvent(event)){ return true; }else { switch(event->type) { case SDL_MOUSEMOTION: { mouseLeaveEvent(event); } break; } } } #endif else if(event->type >= X_PAINT) { onPaint(event->type); } return false; // 处理本组件消息................. }
LRESULT Window::wndProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: { if (onCreate()) break; return 0; } case WM_DESTROY: { if (onDestroy()) break; return 0; } case WM_CLOSE: { if (onClose()) break; return 0; } case WM_MOUSEMOVE: { if (onMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) break; return 0; } case WM_LBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0)) break; return 0; } case WM_RBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 1)) break; return 0; } case WM_MBUTTONDOWN: { if (onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 2)) break; return 0; } case WM_LBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0)) break; return 0; } case WM_RBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 1)) break; return 0; } case WM_MBUTTONUP: { if (onMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 2)) break; return 0; } case WM_PAINT: { if (onPaint()) break; return 0; } case WM_SIZE: { if (onSizeChanged()) break; return 0; } case WM_KEYDOWN: { if (onKeyDown((UINT)wParam)) break; return 0; } case WM_KEYUP: { if (onKeyUp((UINT)wParam)) break; return 0; } case WM_COMMAND: { if (SendMessage(reinterpret_cast<HWND>(lParam), WM_COMMAND_REFLECT, wParam, lParam)) break; return 0; } } if (mBaseWndProc != sGlobalWndProc) { LRESULT r = CallWindowProc(mBaseWndProc, mHWND, uMsg, wParam, lParam); return r; } else { LRESULT r = DefWindowProc(mHWND, uMsg, wParam, lParam); return r; } }
LRESULT basic_window::WndProc(HWND hWnd, INT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: onCreate(uMsg, wParam, lParam); break; case WM_COMMAND: onCommand(uMsg, wParam, lParam); break; case WM_NOTIFY: onNotify(uMsg, wParam, lParam); break; case WM_PAINT: onPaint(uMsg, wParam, lParam); break; case WM_LBUTTONDOWN: onClick(uMsg, wParam, lParam); break; case WM_RBUTTONDOWN: onRClick(uMsg, wParam, lParam); break; case WM_MOUSEMOVE: onMouse(uMsg, wParam, lParam); break; case WM_DESTROY: onDestroy(uMsg, wParam, lParam); break; case WM_CLOSE: { PostQuitMessage(0); // send quit message return 0; // jump back } default: onOther(uMsg, wParam, lParam); break; } return DefProc(hWnd, uMsg, wParam, lParam); }
/*! Mouse move eventhandler forwards the events to slMouseMove or slTouch2Move. */ static void onMouseMove(GLFWwindow* window, double x, double y) { // x & y are in screen coords. // We need to scale them to framebuffer coords x *= scr2fbX; y *= scr2fbY; mouseX = (int)x; mouseY = (int)y; // Offset of 2nd. finger for two finger simulation // Simulate double finger touches if (modifiers & KeyAlt) { // Do parallel double finger move if (modifiers & KeyShift) { slTouch2Move(svIndex, (int)x, (int)y, (int)x - touchDeltaX, (int)y - touchDeltaY); } else // Do concentric double finger pinch { int scrW2 = lastWidth / 2; int scrH2 = lastHeight / 2; touchX2 = scrW2 - ((int)x - scrW2); touchY2 = scrH2 - ((int)y - scrH2); touchDeltaX = (int)x - touchX2; touchDeltaY = (int)y - touchY2; slTouch2Move(svIndex, (int)x, (int)y, touchX2, touchY2); } } else // Do normal mouse move if (slMouseMove(svIndex, (int)x, (int)y)) onPaint(); }
void Window_android::paintIfNeeded() { if (fWindowContext) { // Check if initDisplay has already been called onPaint(); } else { markInvalProcessed(); } }
LRESULT BSPanel::handlePaint(UINT uMsg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps = { 0 }; ::BeginPaint(hwnd_, &ps); onPaint(ps.hdc, ps.rcPaint); ::EndPaint(hwnd_, &ps); return 0; }
/*! Mouse wheel eventhandler that moves the camera foreward or backwards */ void onMouseWheel(GLFWwindow* window, double xscroll, double yscroll) { if (_modifiers == NONE) { _camZ += (SLfloat)SL_sign(yscroll)*0.1f; onPaint(); } }
/*! Mouse wheel eventhandler forwards the events to slMouseWheel */ static void onMouseWheel(GLFWwindow* window, double xscroll, double yscroll) { // make sure the delta is at least one integer int dY = (int)yscroll; if (dY==0) dY = (int)(SL_sign(yscroll)); if (slMouseWheel(svIndex, dY, modifiers)) onPaint(); }
void PaintBox::Paint( Draw &w ) { /*ImageDraw dw(GetSize()); onPaint(dw); w.DrawImage(0, 0, dw); */ w.DrawRect(0,0,this->GetSize().cx,this->GetSize().cy, White); onPaint(w); }
/*-------------------------------------------------------------------------*/ LRESULT CALLBACK NHCommandWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PNHCmdWindow data; int i; switch (message) { case WM_CREATE: onCreate( hWnd, wParam, lParam ); break; case WM_PAINT: onPaint(hWnd); break; case WM_SIZE: LayoutCmdWindow(hWnd); break; case WM_LBUTTONDOWN: onMouseDown(hWnd, wParam, lParam); return 0; case WM_MOUSEMOVE: /* proceed only if if have mouse focus (set in onMouseDown() - left mouse button is pressed) */ if( GetCapture()==hWnd ) { onMouseMove(hWnd, wParam, lParam); return 0; } else { return 1; } break; case WM_LBUTTONUP: /* proceed only if if have mouse focus (set in onMouseDown()) */ if( GetCapture()==hWnd ) { onMouseUp(hWnd, wParam, lParam); return 0; } else { return 1; } break; case WM_DESTROY: data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA); for(i=0; i<=NH_CMDPAD_FONT_MAX; i++ ) if( data->font[i] ) DeleteObject(data->font[i]); free(data); SetWindowLong(hWnd, GWL_USERDATA, (LONG)0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return FALSE; }
void XEditBox::keydownEvent(X_Event *event) { switch(event->key->keysym.sym) { case SDLK_LEFT: CursorLeftMove(); break; case SDLK_RIGHT: CursorRightMove(); break; case SDLK_BACKSPACE: { deleteFont(); onPaint(X_UPDATE); } break; } if(event->key->keysym.sym <=126 && event->key->keysym.sym>=32) { char ch[2]="\n"; *ch=event->key->keysym.sym; text.insert(cursor_addr,1,event->key->keysym.sym); cursor_addr++; cursor_postion+=font->getFontWidth(ch); if(cursor_postion> widget_rect.w-3) { cursor_postion = widget_rect.w-4; } static_cursor.resume(); static_cursor.setLocation(text_rect.x+cursor_postion,widget_rect.y+5); static_cursor.paint(); onPaint(X_UPDATE); } }
void PBModule::ProcessPaint (int appid, HDC hdc) { PPBINSTSTRUCT pInstStruct; // Notify specified instance for (pInstStruct = m_pInstHead; pInstStruct; pInstStruct = pInstStruct->pNext) { if (pInstStruct->instID == appid) onPaint (hdc, pInstStruct->pWrappedObj); } }
void ASSDrawEngine::OnPaint(wxPaintEvent& event) { draw(); onPaint(event); if (setfitviewpoint) { FitToViewPoint( fitviewpoint_hmargin, fitviewpoint_vmargin ); setfitviewpoint = false; RefreshDisplay(); } }
/*! Mouse move eventhandler tracks the mouse delta since touch down (_deltaX/_deltaY) */ void onMouseMove(GLFWwindow* window, double x, double y) { _mouseX = (int)x; _mouseY = (int)y; if (_mouseLeftDown) { _deltaY = (int)x - _startX; _deltaX = (int)y - _startY; onPaint(); } }
LRESULT Dispatcher::onPaint( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { Rect rcPaint; if( !::GetUpdateRect(m_hWnd, &rcPaint, FALSE) ) return 1; PAINTSTRUCT ps; ::BeginPaint(m_hWnd, &ps); onPaint(ps.rcPaint); ::EndPaint(m_hWnd, &ps); return 1; }
/*! onResize: Event handler called on the resize event of the window. This event should called once before the onPaint event. Do everything that is dependent on the size and ratio of the window. */ void onResize(GLFWwindow* window, int width, int height) { double w = (double)width; double h = (double)height; // define the projection matrix _projectionMatrix.perspective(45, w/h, 0.01f, 10.0f); // define the viewport glViewport(0, 0, width, height); onPaint(); }
bool mxWindow::handleMessage( LRESULT *lRes, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch (uMsg) { case MM_MCINOTIFY: return onMciNotify(wParam, lParam); case WM_CLOSE: return onClose(); case WM_COMMAND: return onCommand( LOWORD(wParam), reinterpret_cast<HWND>(lParam), HIWORD(wParam)); case WM_CREATE: return onCreate(lRes, reinterpret_cast<CREATESTRUCT*>(lParam)); case WM_DESTROY: return onDestroy(); case WM_ERASEBKGND: return onEraseBkgnd(lRes, reinterpret_cast<HDC>(wParam)); case WM_LBUTTONDBLCLK: return onLButtonDown(TRUE, mxPoint(lParam), wParam); case WM_LBUTTONDOWN: return onLButtonDown(FALSE, mxPoint(lParam), wParam); case WM_MOUSEMOVE: return onMouseMove(mxPoint(lParam), wParam); case WM_PAINT: { mxPaintDC dc(this); return onPaint(&dc); } case WM_SIZE: return onSize(wParam, mxSize(lParam)); case WM_TIMER: return onTimer(wParam); } return false; }
virtual void onChannelDataReady(Ipc::ChannelRef channel, Ipc::MessageRef message) { switch(Ipc::CommandId cmd = message->get_cmd()) { default: { logger->error() << "Tab: received unknown command '" << cmd << "'" << std::endl; break; } case Ipc::CommandId::onReady: { onReady(); break; } case Ipc::CommandId::onPaint: { onPaint(); break; } } }
LRESULT WebPopupMenuProxyWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lResult = 0; bool handled = true; switch (message) { case WM_MOUSEACTIVATE: lResult = onMouseActivate(hWnd, message, wParam, lParam, handled); break; case WM_SIZE: lResult = onSize(hWnd, message, wParam, lParam, handled); break; case WM_KEYDOWN: lResult = onKeyDown(hWnd, message, wParam, lParam, handled); break; case WM_CHAR: lResult = onChar(hWnd, message, wParam, lParam, handled); break; case WM_MOUSEMOVE: lResult = onMouseMove(hWnd, message, wParam, lParam, handled); break; case WM_LBUTTONDOWN: lResult = onLButtonDown(hWnd, message, wParam, lParam, handled); break; case WM_LBUTTONUP: lResult = onLButtonUp(hWnd, message, wParam, lParam, handled); break; case WM_MOUSEWHEEL: lResult = onMouseWheel(hWnd, message, wParam, lParam, handled); break; case WM_PAINT: lResult = onPaint(hWnd, message, wParam, lParam, handled); break; case WM_PRINTCLIENT: lResult = onPrintClient(hWnd, message, wParam, lParam, handled); break; default: handled = false; break; } if (!handled) lResult = ::DefWindowProc(hWnd, message, wParam, lParam); return lResult; }
void QtOpenGLWindowBase::paint() { if (!m_initialized) { initialize(); } if (!isExposed()) { return; } m_updatePending = false; m_context->makeCurrent(this); onPaint(); m_context->swapBuffers(this); m_context->doneCurrent(); }
LRESULT Tooltip::wndProc(UINT msg, WPARAM wp, LPARAM lp) { switch(msg) { case WM_PAINT: { PAINTSTRUCT ps; BeginPaint( hwnd, &ps ); onPaint(ps); EndPaint(hwnd, &ps); } break; case WM_TIMER: hideTip(); break; case WM_MOUSEACTIVATE: return MA_NOACTIVATE; default: return DefWindowProc(hwnd, msg, wp, lp); } return 0; }
bool HippoCanvas::processMessage(UINT message, WPARAM wParam, LPARAM lParam) { if (HippoAbstractControl::processMessage(message, wParam, lParam)) return true; switch (message) { case WM_PAINT: onPaint(wParam, lParam); // do NOT call DefWindowProc, it clears the update region return true; case WM_HSCROLL: if (hscrollNeeded_) { int newX = hscroll_->handleScrollMessage(message, wParam, lParam); scrollTo(newX, canvasY_); } return true; case WM_VSCROLL: case WM_MOUSEWHEEL: // running DefWindowProc for this one forwards it to parent window if (vscrollNeeded_) { int newY = vscroll_->handleScrollMessage(message, wParam, lParam); scrollTo(canvasX_, newY); } return true; case WM_SETCURSOR: // kill DefWindowProc setting the cursor, so we are the only // ones that do (in the mouse move handler) return true; case WM_LBUTTONDOWN: onMouseDown(1, wParam, lParam); return true; case WM_LBUTTONUP: onMouseUp(1, wParam, lParam); return true; case WM_LBUTTONDBLCLK: onMouseDoubleClick(1, wParam, lParam); return true; case WM_MBUTTONDOWN: onMouseDown(2, wParam, lParam); return true; case WM_MBUTTONUP: onMouseUp(2, wParam, lParam); return true; case WM_RBUTTONDOWN: onMouseDown(3, wParam, lParam); return true; case WM_RBUTTONUP: onMouseUp(3, wParam, lParam); return true; case WM_MOUSEMOVE: onMouseMove(wParam, lParam); return true; case WM_MOUSELEAVE: onMouseLeave(wParam, lParam); return true; case WM_MOUSEHOVER: onHover(wParam, lParam); return true; case WM_SETFOCUS: // forward focus on to some control inside the canvas, if any hippo_canvas_context_win_focus_controls(context_); return true; case WM_COMMAND: return onCommand(wParam, lParam); } return false; }
void SDLWindow::tick() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_ACTIVEEVENT: { if(event.active.state & SDL_APPINPUTFOCUS) { // ignored } if(event.active.state & SDL_APPACTIVE) { if(event.active.gain) { onRestore(); } else { onMinimize(); } } if(input != NULL && (event.active.state & SDL_APPMOUSEFOCUS)) { input->onInputEvent(event); } break; } case SDL_KEYDOWN: // For some reason, release notes from SDL 1.2.12 says a SDL_QUIT message // should be sent when Command+Q is pressed on Mac OS or ALT-F4 on other platforms // but it doesn't look like it's working as expected... #if ARX_PLATFORM == ARX_PLATFORM_MACOSX if(event.key.keysym.sym == SDLK_q && (event.key.keysym.mod & KMOD_META) != KMOD_NONE) { #else if(event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) { #endif onDestroy(); break; } #if ARX_PLATFORM != ARX_PLATFORM_WIN32 // The SDL X11 backend always grabs all keys when in fullscreen mode, // ufortunately breaking window manager shortcuts. // At least provide users with a way to switch to other windows. if(event.key.keysym.sym == SDLK_TAB && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) { SDL_WM_IconifyWindow(); } #endif case SDL_KEYUP: case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_JOYAXISMOTION: case SDL_JOYBALLMOTION: case SDL_JOYHATMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: { if(input) { input->onInputEvent(event); } break; } case SDL_QUIT: { onDestroy(); break; } case SDL_VIDEORESIZE: { Vec2i newSize(event.resize.w, event.resize.h); if(newSize != size_ && !isFullscreen_) { setMode(DisplayMode(newSize, depth_), false); updateSize(false); } break; } case SDL_VIDEOEXPOSE: { onPaint(); break; } } } } Vec2i SDLWindow::getCursorPosition() const { int cursorPosX, cursorPosY; SDL_GetMouseState(&cursorPosX, &cursorPosY); return Vec2i(cursorPosX, cursorPosY); }
void Events::paint() { onPaintBegin(); onPaint(); onPaintEnd(); }
LRESULT Window::msgproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_ACTIVATE: { boolean newActive = LOWORD( wParam ) == WA_ACTIVE; if( active != newActive ) { onActive( newActive ); active = newActive; } } break; case WM_ERASEBKGND: { } break; case WM_PAINT: { onPaint(); } break; case WM_ENTERSIZEMOVE: { updateFlag = false; onEnterSizeMove(); } break; case WM_SIZE: { boolean newActive = ( wParam != SIZE_MAXHIDE ) && ( wParam != SIZE_MINIMIZED ); if( active != newActive ) { onActive( newActive ); active = newActive; } onSize(); } break; case WM_EXITSIZEMOVE: { onExitSizeMove(); updateFlag = true; } break; case WM_SETCURSOR: { onSetCursor(); } break; case WM_CHAR: { onChar( static_cast<wchar>( wParam ) ); } break; case WM_INPUT: { onRawInput( reinterpret_cast<HRAWINPUT>( lParam ) ); } break; case WM_CLOSE: { onClose(); } break; case WM_DESTROY: { onDestroy(); } break; default: { } } return DefWindowProcA( hWnd, msg, wParam, lParam ); }
void XWidget::update() { onPaint(X_UPDATE); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; HACCEL hAccelTable; // グローバル文字列を初期化しています。 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_TETRIS, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // アプリケーションの初期化を実行します: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TETRIS)); // メイン メッセージ ループ: ::timeBeginPeriod(1); double host_timescale = 1; double view_max_fps = VIEW_SPEED_FPS; // 描画のFPS制限 // 上のがいわゆるnet_graphのFPSだと思う double game_max_fps = GAME_SPEED_FPS * host_timescale; // ゲームスピードのFPS制限 // こっちが一般的にはtick?? DWORD dwTime = ::timeGetTime(); DWORD fps_after = dwTime; DWORD fps_before = fps_after; DWORD frame = 0; DWORD currentTime = dwTime; double gameSpeedWaitTime = (1.0 / game_max_fps * 1000.0); double gameSpeedNextTime = dwTime + gameSpeedWaitTime; double viewSpeedWaitTime = (1.0 / view_max_fps * 1000.0); double viewSpeedNextTime = dwTime + gameSpeedWaitTime; Game_init(); while(true){ if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){ if(!GetMessage(&msg, NULL, 0, 0)) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); }else{ // FPS測定(1000ms秒あたりのframe数を計測) currentTime = ::timeGetTime(); if(currentTime - fps_before >= 1000){ // 前回から1秒間(1000ms)経過していた場合 fps_before = currentTime; g_frameRate = g_frame; g_frame = 0; // フレーム数を次秒の計測のためにリセット } // FPS制限(1/60おきにコードが実行されるようにする) if(currentTime >= gameSpeedNextTime ){ // 次回の予定実行時を過ぎていた場合 gameSpeedNextTime += gameSpeedWaitTime; // メイン処理 if( GameMain(msg.hwnd) == false ){ break; // 終了処理へ } }else{ // 表示上のFPS描画しなければならないかチェックする if(currentTime >= viewSpeedNextTime ){ viewSpeedNextTime += viewSpeedWaitTime; onPaint(g_hWnd, g_mDC); ::InvalidateRect(g_hWnd, NULL, FALSE); g_frame++; }else{ Sleep(1); } } } } // いろいろ後片付けを書く trace(L"終了処理\n"); GameMain_quit(); ::timeEndPeriod(1); return (int) msg.wParam; }
void SDL2Window::tick() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: { switch(event.window.event) { case SDL_WINDOWEVENT_SHOWN: onShow(true); break; case SDL_WINDOWEVENT_HIDDEN: onShow(false); break; case SDL_WINDOWEVENT_EXPOSED: onPaint(); break; case SDL_WINDOWEVENT_MINIMIZED: onMinimize(); break; case SDL_WINDOWEVENT_MAXIMIZED: onMaximize(); break; case SDL_WINDOWEVENT_RESTORED: onRestore(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: onFocus(true); break; case SDL_WINDOWEVENT_FOCUS_LOST: onFocus(false); break; case SDL_WINDOWEVENT_MOVED: { onMove(event.window.data1, event.window.data2); break; } case SDL_WINDOWEVENT_SIZE_CHANGED: { Vec2i newSize(event.window.data1, event.window.data2); if(newSize != m_size && !m_fullscreen) { m_renderer->beforeResize(false); updateSize(); } else { // SDL regrettably sends resize events when a fullscreen window // is minimized - we'll have none of that! } break; } case SDL_WINDOWEVENT_CLOSE: { // The user has requested to close a single window // TODO we only support one main window for now break; } } break; } case SDL_QUIT: { // The user has requested to close the whole program // TODO onDestroy() fits SDL_WINDOWEVENT_CLOSE better, but SDL captures Ctrl+C // evenst and *only* sends the SDL_QUIT event for them while normal close // generates *both* SDL_WINDOWEVENT_CLOSE and SDL_QUIT onDestroy(); return; // abort event loop! } } if(m_input) { m_input->onEvent(event); } } if(!m_renderer->isInitialized()) { updateSize(); m_renderer->afterResize(); m_renderer->SetViewport(Rect(m_size.x, m_size.y)); } }
/* map window procedure */ LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PNHMapWindow data; int x, y; data = (PNHMapWindow) GetWindowLong(hWnd, GWL_USERDATA); switch (message) { case WM_CREATE: onCreate(hWnd, wParam, lParam); break; case WM_MSNH_COMMAND: onMSNHCommand(hWnd, wParam, lParam); break; case WM_PAINT: onPaint(hWnd); break; case WM_SETFOCUS: /* transfer focus back to the main window */ SetFocus(GetNHApp()->hMainWnd); break; case WM_HSCROLL: onMSNH_HScroll(hWnd, wParam, lParam); break; case WM_VSCROLL: onMSNH_VScroll(hWnd, wParam, lParam); break; case WM_SIZE: { SIZE size; if (data->bFitToScreenMode) { size.cx = LOWORD(lParam); size.cy = HIWORD(lParam); } else { /* mapping factor is unchaged we just need to adjust scroll bars */ size.cx = data->xScrTile * COLNO; size.cy = data->yScrTile * ROWNO; } mswin_map_stretch(hWnd, &size, TRUE); } break; case WM_LBUTTONDOWN: x = max(0, min(COLNO, data->xPos + (LOWORD(lParam) - data->map_orig.x) / data->xScrTile)); y = max(0, min(ROWNO, data->yPos + (HIWORD(lParam) - data->map_orig.y) / data->yScrTile)); NHEVENT_MS(CLICK_1, x, y); data->xLastMouseClick = x; data->yLastMouseClick = y; return 0; case WM_LBUTTONDBLCLK: x = max(0, min(COLNO, data->xPos + (LOWORD(lParam) - data->map_orig.x) / data->xScrTile)); y = max(0, min(ROWNO, data->yPos + (HIWORD(lParam) - data->map_orig.y) / data->yScrTile)); /* if map has scrolled since the last mouse click - ignore * double-click message */ if (data->xLastMouseClick == x && data->yLastMouseClick == y) { NHEVENT_MS(CLICK_1, x, y); } return 0; case WM_DESTROY: if (data->hMapFont) DeleteObject(data->hMapFont); free(data); SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void XWidget::reLayout() { computeLayout(); onPaint(X_PAINT); showWidget(); }