Пример #1
0
void HandleKey(EventRecord *event)
{
    BOOLEAN appleKeyPressed = ((event->modifiers & appleKey) != 0);
    char key = (event->message & 0xff);

    if (!appleKeyPressed)
        return;

    switch (key) {
    case 'C':
    case 'c':
        DoCopy();
        break;

    case 'X':
    case 'x':
        DoCut();
        break;

    case 'V':
    case 'v':
        DoPaste();
        break;
    }
}
Пример #2
0
void HandleMenu(int menuItem)
{
    SetPort(gCalcWinPtr);

    switch (menuItem) {
    case cutAction:
        DoCut();
        break;

    case copyAction:
        DoCopy();
        break;

    case pasteAction:
        DoPaste();
        break;

    case clearAction:
        DoClear();
        break;

    default:
        break;
    }
}
Пример #3
0
void MainWindow::OnEditPasteSpecial(void)
{
    PasteSpecialDialog dlg;
    bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);

    // invert the meaning, so non-default mode is default in dialog
    if (pasteJunkPaths)
        dlg.fPasteHow = PasteSpecialDialog::kPastePaths;
    else
        dlg.fPasteHow = PasteSpecialDialog::kPasteNoPaths;
    if (dlg.DoModal() != IDOK)
        return;

    switch (dlg.fPasteHow) {
    case PasteSpecialDialog::kPastePaths:
        pasteJunkPaths = false;
        break;
    case PasteSpecialDialog::kPasteNoPaths:
        pasteJunkPaths = true;
        break;
    default:
        assert(false);
        break;
    }

    DoPaste(pasteJunkPaths);
}
Пример #4
0
void PyConsole::OnContextMenu(wxCommandEvent& event)
{
    int id = event.GetId();

    if( id == idCut )
        DoCut();
    else if( id == idCopy )
        DoCopy();
    else if( id == idPaste )
        DoPaste();
    else if( id == idDelete )
        DoDelete();
    else if( id == idSelectAll )
        DoSelectAll();
}
Пример #5
0
BOOL CEditBar::PreTranslateMessage(MSG* pMsg) 
{
    CWnd* pWnd;
    CEdit* pEdit;
	if ( pMsg->message == WM_KEYDOWN ) {
        if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) )
            return TRUE;
        switch ( pMsg->wParam ) {
			case VK_RETURN:
			{
				tokenSetup=0;
	 	        if(GetKeyState(VK_SHIFT)&0x1000)  {tokenSetup = 2;}
	 	        if(GetKeyState(VK_CONTROL)&0x1000){tokenSetup = 1;}
     
	            pWnd = ((CMainFrame*)AfxGetMainWnd())->GetActiveView();
		        if ( pWnd ) 
			        pWnd->PostMessage(WM_USER+100 , 0 , 0 );
	            return TRUE;
			}
        case VK_TAB:
            {
                // Check we are in extending mode 
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                if ( m_bExtending ) {
                    // substitute word by new value
                    if ( !m_posCurPos ) 
                        m_posCurPos= m_lstTabWords.GetHeadPosition ();

                    CString strWord = m_lstTabWords.GetNext(m_posCurPos);
                    CString str = m_strStartLine;
                    str += strWord;
                    str+= m_strEndLine;
                    m_bExtendingChange = TRUE;
                    pEdit->SetWindowText (str);
                    pEdit->SetSel (m_strStartLine.GetLength () + strWord.GetLength (), 
                            m_strStartLine.GetLength () + strWord.GetLength ());
                    m_bExtendingChange = FALSE;
                    return TRUE;
                }
                
                // ok, get current line, word etc 
                CString strText;
                pEdit->GetWindowText (strText);

                if ( !strText.GetLength () ) 
                    return TRUE;

                int start, end;
                pEdit->GetSel (start, end);

                if ( end <= 0  || strText[end-1] == ' ') 
                    return TRUE;

                m_strEndLine = strText.Right(strText.GetLength() - end);

                strText = strText.Left(end);

                int cpos = strText.ReverseFind(' ');

                CString strWord;
                if ( cpos < 0 ) {
                    strWord =  strText;
                    m_strStartLine.Empty ();
                } else {
                    strWord = strText.Right(strText.GetLength () - cpos-1);
                    m_strStartLine = strText.Left (cpos +1);
                }
                m_lstTabWords.RemoveAll ();
                // now find all words same as this one 
                CSmcDoc* pDoc = (CSmcDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument ();
                if ( !pDoc ) 
                    return TRUE;

                m_lstTabWords.AddHead(strWord );
                POSITION pos = pDoc->m_lstTabWords.GetHeadPosition ();
                while ( pos ) {
                    CString str = pDoc->m_lstTabWords.GetNext(pos);
                    if ( !strnicmp(str, strWord, strWord.GetLength()) ) {
                        m_lstTabWords.AddTail (str);
                    }
                }

                if ( m_lstTabWords.GetCount () < 2 ) {
                    m_lstTabWords.RemoveAll ();
                    return TRUE;
                }
                m_bExtending = TRUE;
                m_posCurPos = m_lstTabWords.GetHeadPosition();
                m_lstTabWords.GetNext (m_posCurPos);
                strWord = m_lstTabWords.GetNext (m_posCurPos);
                strText = m_strStartLine + strWord + m_strEndLine;
                m_bExtendingChange = TRUE;
                pEdit ->SetWindowText (strText);
                int selpos = m_strStartLine.GetLength () + strWord.GetLength ();
                pEdit->SetSel (selpos, selpos);
                m_bExtendingChange = FALSE;
                return TRUE;

            }
            break;
        case VK_UP:
            if ( GetKeyState(VK_CONTROL) >= 0 ) {
                PrevLine();
                return TRUE;
            } else 
                return FALSE;
        case VK_DOWN:
            if ( GetKeyState(VK_CONTROL) >= 0 ) {
                NextLine();
                return TRUE;
            } else 
                return FALSE;
        case 'C':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Copy();
                return TRUE;
            }
            break;
		case VK_DELETE:
            if ( GetKeyState(VK_SHIFT)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Cut();
                return TRUE;
            }
            break;
        case 'X':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Cut();
                return TRUE;
            }
            break;
		case VK_INSERT:
            if ( GetKeyState(VK_CONTROL)&0x1000){
                pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Copy();
                return TRUE;
            }
            if ( GetKeyState(VK_SHIFT)&0x1000){
                /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Paste();*/
                DoPaste();
                return TRUE;
            }
            break;
        case 'V':
            if ( GetKeyState(VK_CONTROL)&0x1000){
                /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
                pEdit->Paste();*/
                DoPaste();
                return TRUE;
            }
            break;
        default:
            break;
        };
    }
	if ( pMsg->message == WM_SYSKEYDOWN ) {
        if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) )
            return TRUE;

    }
    
	return CDialogBar::PreTranslateMessage(pMsg);
}
Пример #6
0
/// <summary>
/// Handles window messages.
/// </summary>
LRESULT WINAPI TileGroup::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam, LPVOID) {
  if (message == mChangeNotifyMsg) {
    return HandleChangeNotify(HANDLE(wParam), DWORD(lParam));
  }

  if (mContextMenu3) {
    LRESULT result;
    if (SUCCEEDED(mContextMenu3->HandleMenuMsg2(message, wParam, lParam, &result))) {
      return result;
    }
  }

  if (mContextMenu2) {
    if (SUCCEEDED(mContextMenu2->HandleMenuMsg(message, wParam, lParam))) {
      return 0;
    }
  }

  switch (message) {
  case WM_KEYDOWN:
    switch (wParam) {
    case 'A':
      if (GetKeyState(VK_CONTROL) < 0) {
        SelectAll();
      }
      break;

    case 'C':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoCopy(false);
      }
      break;

    case 'V':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoPaste();
      }
      break;

    case 'X':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoCopy(true);
      }
      break;

    case 'Z':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoUndo();
      }
      break;

    case VK_DELETE:
      DeleteSelectedFiles();
      break;

    case VK_RETURN:
      OpenSelectedFiles();
      break;

    case VK_F2:
      RenameSelectedFiles();
      break;

    case VK_F5:
      UpdateAllIcons();
      break;

    case VK_UP:
    case VK_DOWN:
    case VK_LEFT:
    case VK_RIGHT:
      break;
    }
    break;

  case WM_LBUTTONDOWN:
  case WM_RBUTTONDOWN:
    if (!mInRectangleSelection) {
      StartRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    } else {
      EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    }
    break;

  case WM_MOUSEMOVE:
    if (mInRectangleSelection) {
      MoveRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    }
    break;

  case WM_LBUTTONUP:
  case WM_RBUTTONUP:
    if (mInRectangleSelection) {
      EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    } else if (GetKeyState(VK_CONTROL) >= 0) {
      DeselectAll();
    }
    break;

  case Window::WM_TOPPARENTLOST:
    mChangeNotifyMsg = 0;
    if (mChangeNotifyUID != 0) {
      SHChangeNotifyDeregister(mChangeNotifyUID);
      mChangeNotifyUID = 0;
    }
    break;

  case Window::WM_NEWTOPPARENT:
    {
      // TODO(Erik): This is unacceptable. We have to pick up change notifications while we don't
      // have a top parent.
      IPersistFolder2 *ipsf2;
      LPITEMIDLIST curFolder;
      HRESULT hr;

      mChangeNotifyMsg = mWindow->RegisterUserMessage(this);

      if (SUCCEEDED(hr = mWorkingFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&ipsf2))) {
        if (SUCCEEDED(hr = ipsf2->GetCurFolder(&curFolder))) {
          // (Re)Register for change notifications
          SHChangeNotifyEntry watchEntries[] = { curFolder, FALSE };
          mChangeNotifyUID = SHChangeNotifyRegister(
            window,
            CHANGE_SOURCES,
            CHANGE_EVENTS,
            mChangeNotifyMsg,
            1,
            watchEntries);

          // Let go fo the PIDLists
          CoTaskMemFree(curFolder);
        }
        ipsf2->Release();
      }
    }
    break;
  }

  mEventHandler->HandleMessage(window, message, wParam, lParam);
  return DefWindowProc(window, message, wParam, lParam);
}
Пример #7
0
/**************************************************************************************************
	This function handles events.
**************************************************************************************************/
void CGroup::HandleEvent(UINT uEvent)
{
	if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_NONE) == 0)
	{
		return;
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RENAME) == 0)
	{
		ListView_EditLabel(m_hwndListView, ListView_GetNextItem(m_hwndListView, -1, LVNI_FOCUSED));
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_EXECUTE) == 0)
	{
		if (ListView_GetSelectedCount(m_hwndListView) == 1)
		{
			int iItem = ListView_GetNextItem(m_hwndListView, -1, LVNI_SELECTED);
			char szFileName[MAX_PATH];
			if (GetNameFromId(iItem, szFileName, sizeof(szFileName)))
			{
				if (utils::Is_Directory(szFileName))
				{
					if (m_bInlineBrowsing)
					{
						return ChangeDir(".selected");
					}
					else if (m_bExplicitCalls)
					{
						LSExecuteEx(NULL, "open", "explorer.exe", szFileName, NULL, SW_SHOWNORMAL);
						return;
					}
				}
			}
		}
		CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RETURN, NULL);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DELETE) == 0)
	{
		DeleteFiles();
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_PASTE) == 0)
	{
		DoPaste();
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UNDO) == 0)
	{
		// TODO::Add support for this
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_COPY) == 0)
	{
		CopyFiles(false);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CUT) == 0)
	{
		CopyFiles(true);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_SELECTALL) == 0)
	{
		ListView_SetItemState(m_hwndListView, -1, LVIS_SELECTED, LVIS_SELECTED);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_REFRESH) == 0)
	{
		SaveState();
		m_pView2->Refresh();
		RestoreState();
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UP) == 0)
	{
		ChangeDir(".up");
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CHANGEDIR) == 0)
	{
		ChangeDir(".selected");
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DOWNKEY) == 0)
	{
		CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_DOWN, NULL);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UPKEY) == 0)
	{
		CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_UP, NULL);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_LEFTKEY) == 0)
	{
		CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_LEFT, NULL);
	}
	else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RIGHTKEY) == 0)
	{
		CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RIGHT, NULL);
	}
	else
	{
		LSExecute(m_hwndListView, m_szEventCommand[uEvent], SW_SHOWNORMAL);
	}
}
Пример #8
0
static HRESULT WINAPI BackgroundMenu_InvokeCommand(
	IContextMenu3 *iface,
	LPCMINVOKECOMMANDINFO lpcmi)
{
    ContextMenu *This = impl_from_IContextMenu3(iface);
    IShellBrowser *browser;
    IShellView *view = NULL;
    HWND hWnd = NULL;

    TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", This, lpcmi, lpcmi->lpVerb, lpcmi->hwnd);

    /* get the active IShellView */
    if ((browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0)))
    {
        if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
	    IShellView_GetWindow(view, &hWnd);
    }

    if(HIWORD(lpcmi->lpVerb))
    {
        TRACE("%s\n", debugstr_a(lpcmi->lpVerb));

        if (!strcmp(lpcmi->lpVerb, CMDSTR_NEWFOLDERA))
        {
            DoNewFolder(This, view);
        }
        else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWLISTA))
        {
            if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW, 0), 0);
        }
        else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWDETAILSA))
        {
	    if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW, 0), 0);
        }
        else
        {
            FIXME("please report: unknown verb %s\n", debugstr_a(lpcmi->lpVerb));
        }
    }
    else
    {
        switch (LOWORD(lpcmi->lpVerb))
        {
	    case FCIDM_SHVIEW_REFRESH:
	        if (view) IShellView_Refresh(view);
                break;

            case FCIDM_SHVIEW_NEWFOLDER:
                DoNewFolder(This, view);
                break;

            case FCIDM_SHVIEW_INSERT:
                DoPaste(This);
                break;

            case FCIDM_SHVIEW_PROPERTIES:
                if (This->desktop) {
		    ShellExecuteA(lpcmi->hwnd, "open", "rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL);
		} else {
		    FIXME("launch item properties dialog\n");
		}
		break;

            default:
                /* if it's an id just pass it to the parent shv */
                if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0), 0);
                break;
         }
    }

    if (view)
        IShellView_Release(view);

    return S_OK;
}
Пример #9
0
void MainWindow::OnEditPaste(void)
{
    bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);

    DoPaste(pasteJunkPaths);
}