bool CEditTreeCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam) {
	bool bCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
	bool bShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
	HTREEITEM hCur = GetSelectedItem();

	if(GetEditControl() == 0) {
		method fnc = m_Keymap[int(wParam)][bCtrl][bShift];
		if(fnc)
			return (this->*fnc)(hCur);
	}

	// under some circumstances we need to check some more keys
	switch(int(wParam)) {
		case VK_ESCAPE:
			if(m_pDragData) {
				DragStop();
				return true;
			}
			/*FALLTHRU*/

		case VK_RETURN:
			if(GetEditControl() != 0) {
				GetEditControl()->SendMessage(WM_KEYDOWN, wParam, lParam);
				return true;
			}
			break;

		default:
			break;
	}

	return false;
}
void EXTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
    TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
    *pResult = FALSE;

    char buf[1024];
    CString str;

    GetEditControl()->GetLine(0,buf,1024);
    str = buf;

    HTREEITEM hItem = GetSelectedItem();
    /*	EBaseItem * pItem = (EBaseItem *)GetItemData(hItem);
    	if(pItem && pItem->m_pITreeMember)
    	{
    		if(pItem->m_pITreeMember->CanEditLabel())
    		{
    			pItem->m_pITreeMember->SetLabel(str);
    			*pResult = TRUE;
    		}
    	}*/
    IXTreeItem *pItem = (IXTreeItem *)GetItemData(hItem);
    if(pItem)
    {
        if(pItem->CanEditLabel())
        {
            pItem->SetLabel(str);
            *pResult = TRUE;
        }
    }
}
void CFileBrowserListCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
	CEdit	*pEdit = GetEditControl();
	if (m_LabelEdit && pEdit != NULL) {	// if label edit wasn't canceled
		CString	NewName;
		pEdit->GetWindowText(NewName);	// label is new item name
		int	ItemIdx = pDispInfo->item.iItem;
		CDirItem&	item = m_DirList.GetItem(ItemIdx);
		if (NewName != item.GetName()) {	// if name is different
			CPathStr	NewPath(GetFolder());
			NewPath.Append(NewName);	// make new item path
			CString	OldPath(GetItemPath(ItemIdx));
			if (RenameFile(m_hWnd, OldPath, NewPath)) {
				item.SetName(NewName);	// update item name
				NMFBRENAMEITEM	nmri;
				nmri.pszOldPath = OldPath;
				nmri.pszNewPath = NewPath;
				Notify(FBLCN_RENAMEITEM, &nmri);
			}
		}
	}
	m_LabelEdit = FALSE;
	*pResult = 0;
}
void CTDLFindTaskExpressionListCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	int nItem, nCol;
	GetCurSel(nItem, nCol);
	
	if (GetRuleCount() > 0 || nCol == ATTRIB)
	{
		// if the user typed an alphanumeric char then begin editing automatically
		// numeric keys only work for value column
		if (isalpha(nChar) || (nCol == VALUE && isdigit(nChar)))
		{
			EditCell(nItem, nCol);

			// forward key down on to edit control
			CWnd* pEdit = GetEditControl(nItem, nCol);

			if (pEdit)
			{
				pEdit->PostMessage(WM_CHAR, nChar, MAKELPARAM(nRepCnt, nFlags));
				return; // eat it
			}
		}
	}
	
	CInputListCtrl::OnChar(nChar, nRepCnt, nFlags);
}
예제 #5
0
BOOL CGroupEditTree::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN)
	{
		if (GetEditControl() 
			&& (pMsg->wParam == VK_RETURN
			||  pMsg->wParam == VK_ESCAPE))
		{
			::TranslateMessage(pMsg);
			::DispatchMessage(pMsg);
			return TRUE;	// DO NOT process further
		}

		if (pMsg->wParam == VK_ESCAPE 
			&& m_bDragging)
		{
			m_bDragging = 0;
			CImageList::DragLeave(NULL);
			CImageList::EndDrag();
			ReleaseCapture();
			SelectDropTarget(NULL);
			delete m_pDragImage;
			return TRUE;	// DO NOT process further
		}
	}

	return CTreeCtrl::PreTranslateMessage(pMsg);
}
예제 #6
0
void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
{
    if (GetEditControl() == NULL)
    {
        wxPoint point = event.GetPosition();
        // If from keyboard
        if ( (point.x == -1) && (point.y == -1) )
        {
            wxSize size = GetSize();
            point.x = size.x / 2;
            point.y = size.y / 2;
        }
        else
        {
            point = ScreenToClient(point);
        }
        ShowContextMenu(point);
    }
    else
    {
        // the user is editing:
        // allow the text control to display its context menu
        // if it has one (it has on Windows) rather than display our one
        event.Skip();
    }
}
예제 #7
0
void CListCtrlEx::UpdateEditor()
{
	CEditCell* edit = dynamic_cast<CEditCell*>(GetEditControl());
	if (edit) {
		CString txt = GetItemText(edit->m_Item, edit->m_SubItem);
		edit->SetWindowText(txt);
	}
}
예제 #8
0
void CListCtrlEx::CancelEdit(BOOL cancel)
{
	CEditCell* edit = dynamic_cast<CEditCell*>(GetEditControl());
	if (edit != NULL) {
		if (!cancel)
			edit->SetListText();
		SetFocus();
	}
}
예제 #9
0
void CListCtrlEx::OnSetFocus(CWnd* pOldWnd) 
{
	CEdit* editor = GetEditControl();
	if (editor)
		editor->SetFocus();
	else
		CListCtrl::OnSetFocus(pOldWnd);
		
}
예제 #10
0
void EXTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
    TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;

    // Limit text to 127 characters
    GetEditControl()->LimitText(127);

    *pResult = 0;
}
예제 #11
0
BOOL CListCtrlEx::GetEditPos(int &iItem, int &iSubItem)
{
	CEditCell* edit = dynamic_cast<CEditCell*>(GetEditControl());
	if (edit) {
		iItem = edit->m_Item;
		iSubItem = edit->m_SubItem;
		return TRUE;
	} else
		return FALSE;
}
예제 #12
0
void MyListCtrl::OnBeginLabelEdit(wxListEvent& event)
{
    wxLogMessage( wxT("OnBeginLabelEdit: %s"), event.m_item.m_text.c_str());

    wxTextCtrl * const text = GetEditControl();
    if ( !text )
    {
        wxLogMessage("BUG: started to edit but no edit control");
    }
    else
    {
        wxLogMessage("Edit control value: \"%s\"", text->GetValue());
    }
}
/////////////////////////////////////
// @mfunc Display the Search/Replace dialog for some views which use the Scintilla edit control
// @rvalue void | not used
//
void CScintillamfcView::OnEditReplace() 
{
    m_pReplaceDlg = new CReplaceDlg(this);
    if (m_pReplaceDlg != NULL)
    {
		m_pReplaceDlg->Create(CReplaceDlg::IDD);
		m_pReplaceDlg->m_pEdit = GetEditControl();
		m_pReplaceDlg->ShowWindow(SW_SHOW);
		m_pReplaceDlg->InitDialog();
    }

	m_pReplaceDlg->SetReplaceString(m_wndScintilla.GetSelectedText());
	ShowDialogInCenter(m_pReplaceDlg);
}
예제 #14
0
BOOL CSiteGroupsTree::PreTranslateMessage(MSG *msg)
{
    if (msg->message == WM_KEYDOWN) {
		// When an item is being edited make sure the edit control
		// receives certain important key strokes
		if (GetEditControl() && (msg->wParam == VK_RETURN || msg->wParam == VK_DELETE || msg->wParam == VK_ESCAPE || GetKeyState(VK_CONTROL))) {
			::TranslateMessage(msg);
			::DispatchMessage(msg);
			return TRUE; // Do NOT process further
		}
    }

    return CTreeCtrl::PreTranslateMessage(msg);
}
예제 #15
0
void CSiteGroupsTree::OnBeginLabelEdit(NMHDR *header, LRESULT *result)
{
    NMTVDISPINFO *info = reinterpret_cast<NMTVDISPINFO *>(header);

    CEdit *edit = GetEditControl();
    if (edit) {
        WebWatch::SiteItemGroup & group = GetGroupFromItem(info->item.hItem);
        const std::string & name = group.GetName();
        edit->SetWindowText(name.c_str());
        *result = 0;
    } else {
        // Cancel editing
        *result = TRUE;
    }
}
void CTDLFindTaskExpressionListCtrl::EditCell(int nItem, int nCol)
{
	// handle new rules
	if (nItem == GetRuleCount() && nCol == ATTRIB)
		AddRule();

	CWnd* pEdit = GetEditControl(nItem, nCol);
	ASSERT (pEdit);

	if (!pEdit)
		return;

	const SEARCHPARAM& sp = m_aSearchParams[nItem];

	switch (nCol)
	{
	case ATTRIB:
	case OPERATOR:
	case ANDOR:
		ShowControl(*pEdit, nItem, nCol);
		break;

	case VALUE:
		if (sp.GetOperator() != FOP_SET && sp.GetOperator() != FOP_NOT_SET)
		{
			switch (sp.GetAttribType())
			{
			case FT_DATE:
			case FT_TIME:
				ShowControl(*pEdit, nItem, nCol);
				break;

			default:
				PrepareEdit(nItem, nCol);

				if (pEdit == &m_editBox)
					CInputListCtrl::EditCell(nItem, nCol);
				else
					ShowControl(*pEdit, nItem, nCol);
			}
		}
		break;
	}
}
예제 #17
0
void wxTreeCtrlBase::OnCharHook(wxKeyEvent& event)
{
    if ( GetEditControl() )
    {
        bool discardChanges = false;
        switch ( event.GetKeyCode() )
        {
            case WXK_ESCAPE:
                discardChanges = true;
                wxFALLTHROUGH;

            case WXK_RETURN:
                EndEditLabel(GetFocusedItem(), discardChanges);

                // Do not call Skip() below.
                return;
        }
    }

    event.Skip();
}
예제 #18
0
BOOL CNZProjectTreeCtrl::PreTranslateMessage(MSG* pMsg) 
{
	// When editing labels, make sure the edit control receives important messages
	if( pMsg->message == WM_KEYDOWN && GetEditControl() )
	{
    	CWnd* pParent;
		if (pMsg->wParam == VK_RETURN)
		{
			pParent = GetParent();
			ASSERT(pParent);
			if(pParent)
				pParent->PostMessage(TVM_ENDEDITLABELNOW, FALSE, 0);
		}
		else if (pMsg->wParam == VK_ESCAPE)
		{
			pParent = GetParent();
			ASSERT(pParent);
			if(pParent)
				pParent->PostMessage(TVM_ENDEDITLABELNOW, TRUE, 0);
		}
		else
		{
			return CTreeCtrl::PreTranslateMessage(pMsg);
		}
		
        ::TranslateMessage(pMsg);
        ::DispatchMessage(pMsg);
        return TRUE;                            // DO NOT process further
    }

	if (pMsg->message == WM_KEYDOWN)
	{
		// allow handling of key down events for project tree
        ::TranslateMessage(pMsg);
        ::DispatchMessage(pMsg);
		return TRUE;
	}

	return CTreeCtrl::PreTranslateMessage(pMsg);
}
예제 #19
0
파일: LineList.cpp 프로젝트: joshlong/libcd
BOOL LListCtrl::PreTranslateMessage(MSG* pMsg)
{
    // If edit control is visible in tree view control, sending a
    // WM_KEYDOWN message to the edit control will dismiss the edit
    // control.  When ENTER key was sent to the edit control, the parent
    // window of the tree view control is responsible for updating the
    // item's label in TVN_ENDLABELEDIT notification code.
    if ( pMsg->message == WM_KEYDOWN )
    {
        CHAR ckey=toupper( pMsg->wParam &0xFF );

        if ( VK_RETURN == pMsg->wParam )
            m_bEditNext = TRUE;
        if ( VK_ESCAPE == pMsg->wParam )
            m_bEditNext = FALSE;


        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'A') )
        {
            SelectAll();
            return TRUE;
        }
        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'N') )
        {
            SelectNone();
            return TRUE;
        }


        CEdit* edit = GetEditControl();
        if (edit)
        {
            //			LTRACE("Control key status = %d %d\n",LOBYTE(GetKeyState( VK_CONTROL )),HIWORD(GetKeyState( VK_CONTROL )));

            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'C' ) ) )
            {
                edit->Copy();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'V' ) ) )
            {
                edit->Paste();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'X' ) ) )
            {
                edit->Cut();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'Z' ) ) )
            {
                edit->Undo();
                return TRUE;
            }
            if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_INSERT || pMsg->wParam == VK_SHIFT )
            {
                edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
                return TRUE;
            }
        }
    }
    return CListCtrl::PreTranslateMessage(pMsg);
}
예제 #20
0
void CGroupEditTree::OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
	GetEditControl()->LimitText(80);
	*pResult = 0;
}
예제 #21
0
void CLocalListView::OnContextMenu(wxContextMenuEvent& event)
{
	if (GetEditControl())
	{
		event.Skip();
		return;
	}

	wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_LOCALFILELIST"));
	if (!pMenu)
		return;

	const bool connected = m_pState->IsRemoteConnected();
	if (!connected)
	{
		pMenu->Enable(XRCID("ID_EDIT"), COptions::Get()->GetOptionVal(OPTION_EDIT_TRACK_LOCAL) == 0);
		pMenu->Enable(XRCID("ID_UPLOAD"), false);
		pMenu->Enable(XRCID("ID_ADDTOQUEUE"), false);
	}

	int index = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	int count = 0;
	int fillCount = 0;
	bool selectedDir = false;
	while (index != -1)
	{
		count++;
		const CLocalFileData* const data = GetData(index);
		if (!data || (!index && m_hasParent))
		{
			pMenu->Enable(XRCID("ID_OPEN"), false);
			pMenu->Enable(XRCID("ID_RENAME"), false);
			pMenu->Enable(XRCID("ID_EDIT"), false);
		}
		if ((data && data->flags == fill) || (!index && m_hasParent))
			fillCount++;
		if (data && data->dir)
			selectedDir = true;
		index = GetNextItem(index, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	}
	if (!count || fillCount == count)
	{
		pMenu->Delete(XRCID("ID_ENTER"));
		pMenu->Enable(XRCID("ID_UPLOAD"), false);
		pMenu->Enable(XRCID("ID_ADDTOQUEUE"), false);
		pMenu->Enable(XRCID("ID_DELETE"), false);
		pMenu->Enable(XRCID("ID_RENAME"), false);
		pMenu->Enable(XRCID("ID_EDIT"), false);
	}
	else if (count > 1)
	{
		pMenu->Delete(XRCID("ID_ENTER"));
		pMenu->Enable(XRCID("ID_RENAME"), false);
	}
	else
	{
		// Exactly one item selected
		if (!selectedDir)
			pMenu->Delete(XRCID("ID_ENTER"));
	}
	if (selectedDir)
		pMenu->Enable(XRCID("ID_EDIT"), false);

	PopupMenu(pMenu);
	delete pMenu;
}
예제 #22
0
void CListCtrlEx::ApplyEditText()
{
	CEditCell* edit = dynamic_cast<CEditCell*>(GetEditControl());
	if (edit)
		edit->SetListText();
}
예제 #23
0
BOOL CTreeFileCtrl::PreTranslateMessage(MSG* pMsg) 
{
  // When an item is being edited make sure the edit control
  // receives certain important key strokes
  if (GetEditControl())
  {
    ::TranslateMessage(pMsg);
    ::DispatchMessage(pMsg);
    return TRUE; // DO NOT process further
  }

  //Context menu via the keyboard
	if ((((pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && // If we hit a key and
    	(pMsg->wParam == VK_F10) && (GetKeyState(VK_SHIFT) & ~1)) != 0) ||   // it's Shift+F10 OR
		  (pMsg->message == WM_CONTEXTMENU))						                   	   // Natural keyboard key
	{
		CRect rect;
		GetItemRect(GetSelectedItem(), rect, TRUE);
		ClientToScreen(rect);
		OnContextMenu(NULL, rect.CenterPoint());
		return TRUE;
	}
  //Hitting the Escape key, Cancelling drag & drop
	else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE && IsDragging())
  {
    EndDragging(TRUE);
    return TRUE;
  }
  //Hitting the Alt-Enter key combination, show the properties sheet 
	else if (pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == VK_RETURN)
  {
    OnFileProperties();
    return TRUE;
  }
  //Hitting the Enter key, open the item
	else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
  {
    OnFileOpen();
    return TRUE;
  }
  //Hitting the delete key, delete the item
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE)
  {
    OnFileDelete();
    return TRUE;
  }
  //hitting the backspace key, go to the parent folder
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_BACK)
  {
    UpOneLevel();
    return TRUE;
  }
  //hitting the F2 key, being in-place editing of an item
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F2)
  {
    OnFileRename();
    return TRUE;
  }
  //hitting the F5 key, force a refresh of the whole tree
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5)
  {
    OnViewRefresh();
    return TRUE;
  }

  //Let the parent class do its thing
	return CTreeCtrl::PreTranslateMessage(pMsg);
}