bool ruiSlider::OnPointerMove(const rPoint& position){ if (handleGrabbed){ HandleDrag(position); return true; } else{ return false; } }
void WindowManager::Handle() { if (!Controller::Handled) { HandleFocus(); if (!Controller::Handled) HandleDrag(); if (!Controller::Handled) HandleController(); } }
int gResizerBar::handle(int e) { int ret = 0; int this_y = Fl::event_y_root(); switch (e) { case FL_FOCUS: ret = 1; break; case FL_ENTER: ret = 1; fl_cursor(FL_CURSOR_NS); break; case FL_LEAVE: ret = 1; fl_cursor(FL_CURSOR_DEFAULT); break; case FL_PUSH: ret = 1; last_y = this_y; break; case FL_DRAG: HandleDrag(this_y-last_y); last_y = this_y; ret = 1; break; default: break; } return(Fl_Box::handle(e) | ret); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc, hmem; static HDC offscreen; PAINTSTRUCT ps; RECT rect, rect2; BITMAP bm; POINT point; static POINT start; static int dragging = 0; HDC desktop; HBITMAP hbitmap; HANDLE hdrop; HFONT dfltFont; int dfltBGMode; double percomp; switch (message) { case WM_CREATE: menu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1)); menu = GetSubMenu(menu, 0); offscreen = CreateCompatibleDC(NULL); desktop = GetDC(GetDesktopWindow()); hbitmap = CreateCompatibleBitmap(desktop, 200, 200); ReleaseDC(GetDesktopWindow(), desktop); SelectObject(offscreen, hbitmap); // Start the engines decthread_init(); // We accept drag&drop DragAcceptFiles(hwnd, TRUE); return 0; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); width = rect.right + 1; height = rect.bottom + 1; FillRect(offscreen, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); DrawText(offscreen, "Drop Files Here", -1, &rect, DT_SINGLELINE | DT_CENTER); SetRect(&rect2, 0, height - 110, width, height - 25); DrawText(offscreen, "For Decoding", -1, &rect2, DT_SINGLELINE | DT_CENTER); hmem = CreateCompatibleDC(offscreen); SelectObject(hmem, hbm[frame]); GetObject(hbm[frame], sizeof(BITMAP), &bm); BitBlt(offscreen, width / 2 - 33, height / 2 - 31, bm.bmWidth, bm.bmHeight, hmem, 0, 0, SRCCOPY); DeleteDC(hmem); percomp = ((double)(totalfiles - numfiles) + 1 - (1 - file_complete)) / (double)totalfiles; SetRect(&vbrBR, 0, height - 35, width, height - 19); dfltBGMode = SetBkMode(offscreen, TRANSPARENT); dfltFont = SelectObject(offscreen, font2); SetRect(&bar1, 0, height - 23, (int)(file_complete * width), height - 13); SetRect(&bar2, 0, height - 12, (int)(percomp * width), height - 2); FillRect(offscreen, &bar1, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); FillRect(offscreen, &bar2, (HBRUSH)GetStockObject(DKGRAY_BRUSH)); if (fileName) { char* sep; char fileCaption[80]; if ((sep = strrchr(fileName, '\\')) != 0) fileName = sep+1; (void) strcpy(fileCaption, " "); (void) strcat(fileCaption, fileName); DrawText(offscreen, fileCaption, -1, &bar1, DT_SINGLELINE | DT_LEFT); } SelectObject(offscreen, dfltFont); SetBkMode(offscreen, dfltBGMode); BitBlt(hdc, 0, 0, width, height, offscreen, 0, 0, SRCCOPY); EndPaint(hwnd, &ps); return DefWindowProc(hwnd, message, wParam, lParam); //return 0; case WM_TIMER: if (animate || frame) { frame++; if (frame > 7) frame -= 8; } else { frame = 0; } GetClientRect(hwnd, &rect); InvalidateRect(hwnd, &rect, FALSE); return 0; case WM_LBUTTONDOWN: start.x = LOWORD(lParam); start.y = HIWORD(lParam); ClientToScreen(hwnd, &start); GetWindowRect(hwnd, &rect); start.x -= rect.left; start.y -= rect.top; dragging = 1; SetCapture(hwnd); return 0; case WM_LBUTTONUP: if (dragging) { dragging = 0; ReleaseCapture(); } return 0; case WM_MOUSEMOVE: if (dragging) { point.x = LOSHORT(lParam); point.y = HISHORT(lParam); /* lParam can contain negative coordinates ! * point.x = LOWORD(lParam); * point.y = HIWORD(lParam); */ ClientToScreen(hwnd, &point); SetWindowPos(hwnd, 0, point.x - start.x, point.y - start.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); iniSettings.window_x = point.x - start.x; iniSettings.window_y = point.y - start.y; } return 0; case WM_CAPTURECHANGED: if (dragging) { dragging = 0; ReleaseCapture(); } return 0; case WM_RBUTTONUP: point.x = LOWORD(lParam); point.y = HIWORD(lParam); ClientToScreen(hwnd, &point); TrackPopupMenu(menu, TPM_RIGHTBUTTON, point.x, point.y, 0, hwnd, NULL); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_QUIT: WriteIniFile(INI_FILE); decoding_done = 1; PostQuitMessage(0); break; case IDM_ONTOP: set_always_on_top(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); break; case IDM_LOGERR: set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); break; case IDM_STOP_DEC: { int v = ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED; if(v == 8) stop_decoding = 1; break; } case IDM_VOLUME: { int value = DialogBox( hinst, MAKEINTRESOURCE(IDD_VOLUME), hwnd, QCProc); if (value == -2) break; break; } case IDM_ABOUT: { int value = DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, QCProc); if (value == -7) break; break; } } // LOWORD(wParam) return 0; case WM_DROPFILES: hdrop = (HANDLE)wParam; HandleDrag(hwnd, hdrop); return 0; case WM_DESTROY: decoding_done = 1; PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }
void VSliderControl::Transition(ControlTransitionEnum eTrans, Pos *pPos) { Rect oRect; if (m_eCurrentState == CS_Dragging && eTrans == CT_SetValue) return; switch(eTrans) { case CT_MouseEnter: m_pParent->SendControlMessage(this, CM_MouseEnter); break; case CT_MouseLeave: m_pParent->SendControlMessage(this, CM_MouseLeave); break; case CT_SetValue: { int iNewPos; if (m_iValue < 0 || m_iValue > 100) return; m_oMutex.Acquire(); if (m_bInUpdate) { m_oMutex.Release(); return; } m_bInUpdate = true; iNewPos = ((100 - m_iValue) * m_iRange) / 100; if (iNewPos == m_iCurrentPos) { m_bInUpdate = false; m_oMutex.Release(); return; } m_iCurrentPos = iNewPos; m_bInUpdate = false; m_oMutex.Release(); if (!m_pPanel->IsHidden()) MoveThumb(iNewPos); return; } default: break; } if (m_pPanel->IsHidden()) return; oRect.x1 = m_oRect.x1; oRect.x2 = m_oRect.x2; oRect.y1 = m_oRect.y1 + m_iCurrentPos; oRect.y2 = oRect.y1 + m_iThumbHeight; m_oMutex.Acquire(); if (m_eCurrentState != CS_Dragging && m_eLastState == CS_Dragging) { if (m_oOrigin.y != -1) { Rect oRect; m_oMutex.Release(); m_pParent->GetWindowPosition(oRect); m_oMutex.Acquire(); m_oOrigin.y = m_oRect.y1 + m_iCurrentPos + (m_iThumbHeight / 2); m_oOrigin.y += oRect.y1; m_oOrigin.x += oRect.x1; m_oMutex.Release(); m_pParent->EndMouseCapture(); m_pParent->HideMouse(false); m_oMutex.Acquire(); m_oOrigin.y = -1; } m_iValue = 100 - ((m_iCurrentPos * 100) / m_iRange); m_oMutex.Release(); m_pParent->SendControlMessage(this, CM_ValueChanged); m_oMutex.Acquire(); } if (m_eCurrentState == CS_Dragging && m_eLastState != CS_Dragging) m_bIsDrag = oRect.IsPosInRect(*pPos); m_oMutex.Release(); int iThumbNumber = m_iNumThumbStates * (1 - m_iCurrentPos / m_iRange); iThumbNumber = min(m_iNumThumbStates - 1, iThumbNumber); if (m_eCurrentState != CS_MouseOver && m_eCurrentState != CS_DisabledMO) BlitTrough(m_iCurrentPos); switch(m_eCurrentState) { case CS_Normal: BlitFrame(CS_Normal, iThumbNumber, &oRect); break; case CS_MouseOver: BlitFrame(CS_MouseOver, iThumbNumber, &oRect); break; case CS_Dragging: m_oMutex.Acquire(); if (m_bInUpdate) { m_oMutex.Release(); return; } m_bInUpdate = true; m_oMutex.Release(); if (m_bIsDrag) HandleDrag(eTrans, pPos); else HandleJump(eTrans, pPos); m_oMutex.Acquire(); m_bInUpdate = false; m_oMutex.Release(); break; case CS_Disabled: BlitFrame(CS_Disabled, iThumbNumber, &oRect); break; default: break; } }