bool TabMenuDisplay::OnMouseUp(PixelScalar x, PixelScalar y) { RasterPoint Pos; Pos.x = x; Pos.y = y; if (dragging) { DragEnd(); const MenuTabIndex di = IsPointOverButton(Pos, GetPageMainIndex(cursor)); if (di == down_index) { // sub menu click if (di.IsSub()) pager.ClickPage(PAGE_OFFSET + GetPageNum(di)); // main menu click else if (di.IsMain()) { /* move cursor to first item in this menu */ cursor = main_menu_buttons[di.main_index].first_page_index; Invalidate(); } else { InvalidateButton(down_index); } } down_index = MenuTabIndex::None(); return true; } else { return PaintWindow::OnMouseUp(x, y); } }
void CFlatToolbar::OnLButtonDown(UINT nFlags, CPoint point) { if ((m_iButtonCapture = HitTest(point)) < 0) // nothing hit { CControlBar::OnLButtonDown(nFlags, point); return; } AFX_TBBUTTON* pTBB = _GetButtonPtr(m_iButtonCapture); ASSERT(!(pTBB->nStyle & TBBS_SEPARATOR)); // update the button before checking for disabled status UpdateButton(m_iButtonCapture); if (pTBB->nStyle & TBBS_DISABLED) { m_iButtonCapture = -1; return; // don't press it } // TONYCL: START: // Kill the UPSTATE style so that the button is drawn in the downstate pTBB->nStyle &= ~TBBS_UPSTATE; // TONYCL: END: pTBB->nStyle |= TBBS_PRESSED; InvalidateButton(m_iButtonCapture); UpdateWindow(); // immediate feedback SetCapture(); GetOwner()->SendMessage(WM_SETMESSAGESTRING, (WPARAM)pTBB->nID); }
void CFlatToolbar::SetButtonInfo(int nIndex, UINT nID, UINT nStyle, int iImage) { ASSERT_VALID(this); AFX_TBBUTTON* pTBB = _GetButtonPtr(nIndex); pTBB->nID = nID; pTBB->iImage = iImage; pTBB->nStyle = nStyle; InvalidateButton(nIndex); }
void CFlatToolbar::SetButtonStyle(int nIndex, UINT nStyle) { AFX_TBBUTTON* pTBB = _GetButtonPtr(nIndex); UINT nOldStyle = pTBB->nStyle; if (nOldStyle != nStyle) { // update the style and invalidate pTBB->nStyle = nStyle; // invalidate the button only if both styles not "pressed" if (!(nOldStyle & nStyle & TBBS_PRESSED)) InvalidateButton(nIndex); } }
// NOTE: Host / CPU Thread void TASInputDlg::SetButtonValue(Button* button, bool CurrentState) { if (CurrentState) { button->set_by_keyboard = true; } else if (button->set_by_keyboard) { button->set_by_keyboard = false; } else { return; } button->value = CurrentState; InvalidateButton(button); }
bool TabMenuDisplay::OnMouseDown(PixelScalar x, PixelScalar y) { DragEnd(); RasterPoint Pos; Pos.x = x; Pos.y = y; // If possible -> Give focus to the Control SetFocus(); down_index = IsPointOverButton(Pos, GetPageMainIndex(cursor)); if (!down_index.IsNone()) { dragging = true; SetCapture(); InvalidateButton(down_index); return true; } return PaintWindow::OnMouseDown(x, y); }
// NOTE: Host / CPU Thread void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key) { u8* const coreData = rptf.core ? (data + rptf.core) : nullptr; u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr; // u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr; u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr; if (coreData) { for (size_t i = 0; i < s_wii_buttons_bitmask.size(); ++i) { if (m_buttons[i] != nullptr) SetButtonValue(m_buttons[i], (((wm_buttons*)coreData)->hex & s_wii_buttons_bitmask[i]) != 0); } } if (accelData) { wm_accel* dt = (wm_accel*)accelData; SetSliderValue(&m_x_cont, dt->x << 2 | ((wm_buttons*)coreData)->acc_x_lsb); SetSliderValue(&m_y_cont, dt->y << 2 | ((wm_buttons*)coreData)->acc_y_lsb << 1); SetSliderValue(&m_z_cont, dt->z << 2 | ((wm_buttons*)coreData)->acc_z_lsb << 1); } // I don't think this can be made to work in a sane manner. // if (irData) //{ // u16 x = 1023 - (irData[0] | ((irData[2] >> 4 & 0x3) << 8)); // u16 y = irData[1] | ((irData[2] >> 6 & 0x3) << 8); // SetStickValue(&m_main_stick.x_cont.set_by_keyboard, &m_main_stick.x_cont.value, // m_main_stick.x_cont.text, x, 561); // SetStickValue(&m_main_stick.y_cont.set_by_keyboard, &m_main_stick.y_cont.value, // m_main_stick.y_cont.text, y, 486); //} if (extData && ext == 1) { wm_nc& nunchuk = *(wm_nc*)extData; WiimoteDecrypt(&key, (u8*)&nunchuk, 0, sizeof(wm_nc)); nunchuk.bt.hex = nunchuk.bt.hex ^ 0x3; SetButtonValue(m_buttons[11], nunchuk.bt.c != 0); SetButtonValue(m_buttons[12], nunchuk.bt.z != 0); } if (extData && ext == 2) { wm_classic_extension& cc = *(wm_classic_extension*)extData; WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension)); cc.bt.hex = cc.bt.hex ^ 0xFFFF; for (size_t i = 0; i < m_cc_buttons.size(); ++i) { SetButtonValue(&m_cc_buttons[i], ((cc.bt.hex & s_cc_buttons_bitmask[i]) != 0)); } if (m_cc_l.value == 31) { m_cc_buttons[10].value = true; InvalidateButton(&m_cc_buttons[10]); } if (m_cc_r.value == 31) { m_cc_buttons[11].value = true; InvalidateButton(&m_cc_buttons[11]); } SetSliderValue(&m_cc_l_stick.x_cont, cc.regular_data.lx); SetSliderValue(&m_cc_l_stick.y_cont, cc.regular_data.ly); SetSliderValue(&m_cc_r_stick.x_cont, cc.rx1 | (cc.rx2 << 1) | (cc.rx3 << 3)); SetSliderValue(&m_cc_r_stick.y_cont, cc.ry); } }
void CBCGPDropDownToolBar::OnMouseMove(UINT /*nFlags*/, CPoint point) { if (m_ptLastMouse != CPoint (-1, -1) && abs (m_ptLastMouse.x - point.x) < 1 && abs (m_ptLastMouse.y - point.y) < 1) { m_ptLastMouse = point; return; } m_ptLastMouse = point; int iPrevHighlighted = m_iHighlighted; m_iHighlighted = HitTest (point); CBCGPToolbarButton* pButton = m_iHighlighted == -1 ? NULL : GetButton (m_iHighlighted); if (pButton != NULL && (pButton->m_nStyle & TBBS_SEPARATOR || (pButton->m_nStyle & TBBS_DISABLED && !AllowSelectDisabled ()))) { m_iHighlighted = -1; } if (!m_bTracked) { m_bTracked = TRUE; TRACKMOUSEEVENT trackmouseevent; trackmouseevent.cbSize = sizeof(trackmouseevent); trackmouseevent.dwFlags = TME_LEAVE; trackmouseevent.hwndTrack = GetSafeHwnd(); trackmouseevent.dwHoverTime = HOVER_DEFAULT; BCGPTrackMouse (&trackmouseevent); } if (iPrevHighlighted != m_iHighlighted) { BOOL bNeedUpdate = FALSE; m_iButtonCapture = m_iHighlighted; if (iPrevHighlighted != -1) { CBCGPToolbarButton* pTBBCapt = GetButton (iPrevHighlighted); ASSERT (pTBBCapt != NULL); ASSERT (!(pTBBCapt->m_nStyle & TBBS_SEPARATOR)); UINT nNewStyle = (pTBBCapt->m_nStyle & ~TBBS_PRESSED); if (nNewStyle != pTBBCapt->m_nStyle) { SetButtonStyle (iPrevHighlighted, nNewStyle); } } if (m_iButtonCapture != -1) { CBCGPToolbarButton* pTBBCapt = GetButton (m_iButtonCapture); ASSERT (pTBBCapt != NULL); ASSERT (!(pTBBCapt->m_nStyle & TBBS_SEPARATOR)); UINT nNewStyle = (pTBBCapt->m_nStyle & ~TBBS_PRESSED); if (m_iHighlighted == m_iButtonCapture) { nNewStyle |= TBBS_PRESSED; } if (nNewStyle != pTBBCapt->m_nStyle) { SetButtonStyle (m_iButtonCapture, nNewStyle); bNeedUpdate = TRUE; } } if ((m_iButtonCapture == -1 || iPrevHighlighted == m_iButtonCapture) && iPrevHighlighted != -1) { InvalidateButton (iPrevHighlighted); bNeedUpdate = TRUE; } if ((m_iButtonCapture == -1 || m_iHighlighted == m_iButtonCapture) && m_iHighlighted != -1) { InvalidateButton (m_iHighlighted); bNeedUpdate = TRUE; } if (bNeedUpdate) { UpdateWindow (); } if (m_iHighlighted != -1 && (m_iHighlighted == m_iButtonCapture || m_iButtonCapture == -1)) { ASSERT (pButton != NULL); ShowCommandMessageString (pButton->m_nID); } else if (m_iButtonCapture == -1 && m_hookMouseHelp == NULL) { GetOwner()->SendMessage (WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE); } OnChangeHot (m_iHighlighted); } }
void CFlatToolbar::OnMouseMove(UINT /*nFlags*/, CPoint point) { if (m_iButtonCapture >= 0) { AFX_TBBUTTON* pTBB = _GetButtonPtr(m_iButtonCapture); ASSERT(!(pTBB->nStyle & TBBS_SEPARATOR)); UINT nNewStyle = (pTBB->nStyle & ~TBBS_PRESSED); int iButtonCapture = m_iButtonCapture; if (GetCapture() != this) { m_iButtonCapture = -1; // lost capture GetOwner()->SendMessage(WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE); } else { // should be pressed if still hitting the captured button if (HitTest(point) == m_iButtonCapture) nNewStyle |= TBBS_PRESSED; } SetButtonStyle(iButtonCapture, nNewStyle); UpdateWindow(); // immediate feedback } // TONYCL: START: OFFICE97 LOOK AND FEEL else { // We have to be the active application if (GetForegroundWindow()->GetSafeHwnd() == AfxGetMainWnd()->GetSafeHwnd()) { // Hit test the button, and then draw the button in the up state int nButtonID = HitTest(point); // Which button are we over? if (nButtonID == -1) { ReleaseCapture(); } else { SetCapture(); } // Are we over the same button as we were last time? if (m_nUpButtonIndex == nButtonID) { return; } // Is the new button -1, and were we over a button? else if ((nButtonID == -1) && (m_nUpButtonIndex != -1)) { // Reset the button state so it's flat UINT nStyle = GetButtonStyle(m_nUpButtonIndex); nStyle &= ~TBBS_UPSTATE; SetButtonStyle(m_nUpButtonIndex, nStyle); InvalidateButton(m_nUpButtonIndex); m_nUpButtonIndex = -1; UpdateWindow(); // immediate feedback } // We are over a button else if (nButtonID != -1 && (!(GetButtonStyle(nButtonID) & TBBS_DISABLED))) { // Put the button into the upstate UINT nStyle = GetButtonStyle(nButtonID); nStyle |= TBBS_UPSTATE; SetButtonStyle(nButtonID, nStyle); InvalidateButton(nButtonID); // If we were over a different button to the one before, flatten it if (m_nUpButtonIndex != -1) { UINT nStyle = GetButtonStyle(m_nUpButtonIndex); nStyle &= ~TBBS_UPSTATE; SetButtonStyle(m_nUpButtonIndex, nStyle); InvalidateButton(m_nUpButtonIndex); } m_nUpButtonIndex = nButtonID; UpdateWindow(); // immediate feedback } } } // TONYCL: END: OFFICE97 LOOK AND FEEL }