void CPlainTextEditor::SelectLeft(void) { BeginSelection(); miEditPos = FindLeft(miEditPos); EndSelection(); ResetUpDown(); }
// KillFocus problem fix suggested by Paul Wilkerson. void CColourPopup::OnActivateApp(BOOL bActive, DWORD dwTask) { CWnd::OnActivateApp(bActive, dwTask); // If Deactivating App, cancel this selection if (!bActive) EndSelection(CPN_SELENDCANCEL); }
void COptionTreeColorPopUp::OnActivateApp(BOOL bActive, DWORD hTask) { // If Deactivating App, cancel this selection if (!bActive) { EndSelection(OT_COLOR_SELENDCANCEL); } CWnd::OnActivateApp(bActive, hTask); }
void DisassemblyView::mouseMoveEvent(QMouseEvent * evt) { if (evt->buttons() & Qt::LeftButton) { medusa::u32 x = evt->x() / _wChar; medusa::u32 y = evt->y() / _hChar; EndSelection(x, y); _needRepaint = true; // TODO: selectionChanged emit viewUpdated(); } }
LOCAL void ZoomBox_OnKeyUp(HWND hWnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) /***********************************************************************/ { if ( vk != VK_ESCAPE ) return; if ( !fCapture ) return; ReleaseCapture(); fCapture = FALSE; if (fSelection) EndSelection( hWnd, NULL, &SelectRect, SL_BOX | SL_NOLIMIT, YES ); SetFocus(hOldFocus); EnableMarquee(fMarquee); }
LOCAL void ZoomBox_OnLButtonUp(HWND hWnd, int x, int y, UINT keyFlags) /***********************************************************************/ { BOOL fGotaRect; LPDISPLAY lpMyDisplay; RECT ClientRect; HWND hOwner; if ( !fCapture ) return; ReleaseCapture(); fCapture = FALSE; if (fSelection) { EndSelection( hWnd, NULL, &SelectRect, SL_BOX|SL_NOLIMIT, YES ); if (abs(SelectRect.right-SelectRect.left) <= SMALL_MOVEMENT && abs(SelectRect.bottom-SelectRect.top) <= SMALL_MOVEMENT) fGotaRect = NO; else fGotaRect = YES; } else { fGotaRect = NO; SelectRect.left = SelectRect.right = StartPoint.x; SelectRect.top = SelectRect.bottom = StartPoint.y; Display2File( hWnd, (LPINT)&SelectRect.left, (LPINT)&SelectRect.top ); Display2File( hWnd, (LPINT)&SelectRect.right, (LPINT)&SelectRect.bottom ); } // clip to file rect lpMyDisplay = GetDisplayPtr(hWnd); ClientRect = lpMyDisplay->FileRect; AstralIntersectRect( &SelectRect, &SelectRect, &ClientRect ); SetFocus(hOldFocus); EnableMarquee(fMarquee); hOwner = GetZoomOwner(hWnd); if (!hOwner) return; if (IsIconic(hOwner)) return; SaveLastView(hOwner); if ( fGotaRect ) ViewRect(hOwner, &SelectRect, NO); else { Zoom( hOwner, SelectRect.left, SelectRect.top, ( SHIFT ? -100 : ( CONTROL ? +100 : 0 ) ), YES,NO); } }
void COptionTreeColorPopUp::OnLButtonUp(UINT nFlags, CPoint point) { // Declare variables DWORD dwPos; // Get osition dwPos = GetMessagePos(); point = CPoint(LOWORD(dwPos), HIWORD(dwPos)); if (m_rcWindowRect.PtInRect(point)) { EndSelection(OT_COLOR_SELENDOK); } else { EndSelection(OT_COLOR_SELENDCANCEL); } // Handle left click if (::IsWindow(GetSafeHwnd())) { CWnd::OnLButtonUp(nFlags, point); } }
/*---------------------------------------------------------------------------------------------- End selection on LButtonUp ----------------------------------------------------------------------------------------------*/ bool IconComboPopup::OnLButtonUp(UINT nFlags, POINT pt) { m_fMouseDown = false; if (m_fIgnoreButtonUp) { m_fIgnoreButtonUp = false; return true; } ::ClientToScreen(m_hwnd, &pt); RECT rc; ::GetWindowRect(m_hwnd, &rc); EndSelection(PtInRect(&rc, pt) ? CBN_SELENDOK : CBN_SELENDCANCEL); return false; }
// If an arrow key is pressed, then move the selection void CColourPopup::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { int row = GetRow(m_nCurrentSel), col = GetColumn(m_nCurrentSel); if (nChar == VK_DOWN) { if (row == DEFAULT_BOX_VALUE) row = col = 0; else if (row == CUSTOM_BOX_VALUE) { if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else row = col = 0; } else { row++; if (GetIndex(row,col) < 0) { if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else row = col = 0; } } ChangeSelection(GetIndex(row, col)); } if (nChar == VK_UP) { if (row == DEFAULT_BOX_VALUE) { if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } else if (row == CUSTOM_BOX_VALUE) { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } else if (row > 0) row--; else /* row == 0 */ { if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } ChangeSelection(GetIndex(row, col)); } if (nChar == VK_RIGHT) { if (row == DEFAULT_BOX_VALUE) row = col = 0; else if (row == CUSTOM_BOX_VALUE) { if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else row = col = 0; } else if (col < m_nNumColumns-1) col++; else { col = 0; row++; } if (GetIndex(row,col) == INVALID_COLOUR) { if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else row = col = 0; } ChangeSelection(GetIndex(row, col)); } if (nChar == VK_LEFT) { if (row == DEFAULT_BOX_VALUE) { if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } else if (row == CUSTOM_BOX_VALUE) { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } else if (col > 0) col--; else /* col == 0 */ { if (row > 0) { row--; col = m_nNumColumns-1; } else { if (m_strDefaultText.GetLength()) row = col = DEFAULT_BOX_VALUE; else if (m_strCustomText.GetLength()) row = col = CUSTOM_BOX_VALUE; else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } } ChangeSelection(GetIndex(row, col)); } if (nChar == VK_ESCAPE) { m_crColour = m_crInitialColour; EndSelection(CPN_SELENDCANCEL); return; } if (nChar == VK_RETURN || nChar == VK_SPACE) { EndSelection(CPN_SELENDOK); return; } CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }
void COptionTreeColorPopUp::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // Declare variable int nRow, nCol; // Get row nRow = GetRow(m_nCurrentSel); // Get column nCol = GetColumn(m_nCurrentSel); // Down if (nChar == VK_DOWN) { if (nRow == OT_COLOR_DEFAULTBOXVALUE) { nRow = nCol = 0; } else if (nRow == OT_COLOR_CUSTOMBOXVALUE) { if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else { nRow = nCol = 0; } } else { nRow++; if (GetIndex(nRow, nCol) < 0) { if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else { nRow = nCol = 0; } } } ChangeSelection(GetIndex(nRow, nCol)); } // Up if (nChar == VK_UP) { if (nRow == OT_COLOR_DEFAULTBOXVALUE) { if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else { nRow = GetRow(m_nNumColors-1); nCol = GetColumn(m_nNumColors-1); } } else if (nRow == OT_COLOR_CUSTOMBOXVALUE) { nRow = GetRow(m_nNumColors-1); nCol = GetColumn(m_nNumColors-1); } else if (nRow > 0) { nRow--; } else { if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else { nRow = GetRow(m_nNumColors-1); nCol = GetColumn(m_nNumColors-1); } } ChangeSelection(GetIndex(nRow, nCol)); } // Right if (nChar == VK_RIGHT) { if (nRow == OT_COLOR_DEFAULTBOXVALUE) { nRow = nCol = 0; } else if (nRow == OT_COLOR_CUSTOMBOXVALUE) { if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else { nRow = nCol = 0; } } else if (nCol < m_nNumColumns - 1) { nCol++; } else { nCol = 0; nRow++; } if (GetIndex(nRow,nCol) == OT_COLOR_INVALIDCOLOR) { if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else { nRow = nCol = 0; } } ChangeSelection(GetIndex(nRow, nCol)); } // Left if (nChar == VK_LEFT) { if (nRow == OT_COLOR_DEFAULTBOXVALUE) { if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else { nRow = GetRow(m_nNumColors-1); nCol = GetColumn(m_nNumColors-1); } } else if (nRow == OT_COLOR_CUSTOMBOXVALUE) { nRow = GetRow(m_nNumColors-1); nCol = GetColumn(m_nNumColors-1); } else if (nCol > 0) { nCol--; } else { if (nRow > 0) { nRow--; nCol = m_nNumColumns - 1; } else { if (m_strDefaultText.GetLength()) { nRow = nCol = OT_COLOR_DEFAULTBOXVALUE; } else if (m_strCustomText.GetLength()) { nRow = nCol = OT_COLOR_CUSTOMBOXVALUE; } else { nRow = GetRow(m_nNumColors - 1); nCol = GetColumn(m_nNumColors - 1); } } } ChangeSelection(GetIndex(nRow, nCol)); } // Escape if (nChar == VK_ESCAPE) { m_crColor = m_crInitialColor; EndSelection(OT_COLOR_SELENDCANCEL); return; } // Return or space if (nChar == VK_RETURN || nChar == VK_SPACE) { EndSelection(OT_COLOR_SELENDOK); return; } CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }
/*---------------------------------------------------------------------------------------------- If an arrow key is pressed, then move the selection. ----------------------------------------------------------------------------------------------*/ bool IconComboPopup::OnKeyDown(int vk, int cact) { switch (vk) { case VK_DOWN: case VK_UP: case VK_RIGHT: case VK_LEFT: if (m_ivalHot < 0) { ChangeSelection(0); return true; } break; case VK_ESCAPE: *m_pival = m_ivalOld; EndSelection(CBN_SELENDCANCEL); return false; case VK_RETURN: case VK_SPACE: EndSelection(CBN_SELENDOK); return false; default: return true; } int row = GetRowFromColor(m_ivalHot); int col = GetColFromColor(m_ivalHot); switch (vk) { case VK_DOWN: if (++row >= m_cRows) row = 0; break; case VK_UP: if (--row < 0) row = m_cRows - 1; if (row == 0) col = 0; break; case VK_RIGHT: if (row == 0) return true; if (++col >= m_cColumns) col = 0; break; case VK_LEFT: if (row == 0) return true; if (--col < 0) col = m_cColumns - 1; break; } ChangeSelection(GetTableIndexFromRowCol(row, col)); return true; }
/******************************************************************************* Function Name : OnKeyDown Input(s) : nChar - Key Code, nRepCnt - Repeat Count, nFlags - Ctrl and Alt key status Output : - Functionality : This function moves the selection if arrow keys are pressed Member of : CColourPopup Author(s) : Raja N Date Created : 09/12/2004 Modifications : *******************************************************************************/ void CColourPopup::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { int row = GetRow(m_nCurrentSel), col = GetColumn(m_nCurrentSel); // Move Selection if (nChar == VK_DOWN) { // Wrap to top if (row == DEFAULT_BOX_VALUE) { row = col = 0; } else if (row == CUSTOM_BOX_VALUE) { if ( m_strDefaultText.GetLength() > 0 ) { row = col = DEFAULT_BOX_VALUE; } else { row = col = 0; } } else { // Increment row count row++; if ( GetIndex(row,col) < 0) { if (m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else if (m_strDefaultText.GetLength() > 0) { row = col = DEFAULT_BOX_VALUE; } else { row = col = 0; } } } // Update Selection ChangeSelection(GetIndex(row, col)); } // Move One cell Up if (nChar == VK_UP) { if (row == DEFAULT_BOX_VALUE) { if (m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } else if (row == CUSTOM_BOX_VALUE) { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } else if (row > 0) { row--; } else { if (m_strDefaultText.GetLength() > 0) { row = col = DEFAULT_BOX_VALUE; } else if( m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } // Update Selection ChangeSelection(GetIndex(row, col)); } // Move One Cell Right if (nChar == VK_RIGHT) { if (row == DEFAULT_BOX_VALUE) { row = col = 0; } else if (row == CUSTOM_BOX_VALUE) { if (m_strDefaultText.GetLength()) { row = col = DEFAULT_BOX_VALUE; } else { row = col = 0; } } else if (col < m_nNumColumns - 1) { col++; } else { // Move to Col 0 of next row col = 0; row++; } if (GetIndex(row,col) == INVALID_COLOUR) { if (m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else if ( m_strDefaultText.GetLength() > 0) { row = col = DEFAULT_BOX_VALUE; } else { row = col = 0; } } // Update Selection ChangeSelection(GetIndex(row, col)); } // Move one cell left if (nChar == VK_LEFT) { if (row == DEFAULT_BOX_VALUE) { if (m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } else if (row == CUSTOM_BOX_VALUE) { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } else if (col > 0) { col--; } else // col == 0 { if (row > 0) { row--; col = m_nNumColumns - 1; } else { if (m_strDefaultText.GetLength() > 0) { row = col = DEFAULT_BOX_VALUE; } else if (m_strCustomText.GetLength() > 0) { row = col = CUSTOM_BOX_VALUE; } else { row = GetRow(m_nNumColours-1); col = GetColumn(m_nNumColours-1); } } } // Update Selection ChangeSelection(GetIndex(row, col)); } // Hide This dialog on press of escape key if (nChar == VK_ESCAPE) { // Restore initial color m_crColour = m_crInitialColour; // Close the session EndSelection(WM_CPN_SELENDCANCEL); return; } // On Press of enter or space select the selection and close this // dialog if (nChar == VK_RETURN || nChar == VK_SPACE) { EndSelection(WM_CPN_SELENDOK); return; } // Else call default procedure CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { RECT Rect; BOOL fShift; POINT pt; static int Type, Style; static BOOL fConstrain; static RECT SelectRect; int res; FRMDATATYPE type; LPIMAGE lpImage; STRING szString; GRADIENT_PARMS parms; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type); if (type == FDT_LINEART) { AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) ); Message(IDS_NOTWITHLINEART, (LPSTR)szString); break; } AstralUpdateWindow(hWindow); Tool.bActive = YES; // SetMaskingState( x, y ); break; case WM_LBUTTONDOWN: Type = Vignette.Gradient; fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE ); AstralSetRectEmpty( &SelectRect ); if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE ) Style = SL_ELLIPSE; else if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR ) Style = SL_LINE; else Style = SL_BOX; pt.x = x; pt.y = y; StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL, pt, 0L ); break; case WM_LBUTTONUP: Tool.bActive = NO; Rect = SelectRect; // make a copy before it gets ordered EndSelection( hWindow, NULL, &SelectRect, Style, YES ); lpImage = (LPIMAGE)GetImagePtr ( hWindow ); res = FrameResolution(ImgGetBaseEditFrame(lpImage)); type = FrameType(ImgGetBaseEditFrame(lpImage)); parms.VigOpacity = Vignette.VigOpacity; parms.VigMergeMode = Vignette.VigMergeMode; parms.iBaseRes = res; parms.x1 = Rect.left; parms.y1 = Rect.top; parms.x2 = Rect.right; parms.y2 = Rect.bottom; GetActiveColorFromType(type, &parms.StartColor); GetAlternateColorFromType(type, &parms.EndColor); parms.Gradient = Vignette.Gradient; parms.RepeatCount = Vignette.RepeatCount; parms.SoftTransition = Vignette.SoftTransition; parms.Midpoint = Vignette.Midpoint; parms.VigColorModel = Vignette.VigColorModel; ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms); break; case WM_MOUSEMOVE: // sent when ToolActive is on fShift = SHIFT; pt.x = x; pt.y = y; UpdateSelection( hWindow, NULL, &SelectRect, Style, pt, fConstrain^CONSTRAINASPECT, 1L, 1L, MOVEKEY||Window.fRButtonDown, FROMCENTER); break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message if (!Tool.bActive) break; Tool.bActive = NO; EndSelection( hWindow, NULL, &SelectRect, Style, YES ); break; } }