Exemplo n.º 1
0
wxAcceleratorEntry *wxMenuItem::GetAccel() const
{
    if ( !GetHotKey() )
    {
        // nothing
        return NULL;
    }

    // accelerator parsing code looks for them after a TAB, so insert a dummy
    // one here
    wxString label;
    label << wxT('\t') << GetHotKey();

    return wxAcceleratorEntry::Create(label);
}
Exemplo n.º 2
0
void CSHCTHotKey::OnKillFocus(CWnd *)
{
  if (m_pParent != NULL) {
    WORD wVirtualKeyCode, wHKModifiers;
    GetHotKey(wVirtualKeyCode, wHKModifiers);
    m_pParent->OnMenuShortcutKillFocus(wVirtualKeyCode, wHKModifiers);
  }
}
Exemplo n.º 3
0
void CSHCTHotKey::OnKillFocus(CWnd *pWnd)
{
  UNREFERENCED_PARAMETER(pWnd);
  if (m_pParent != NULL) {
    WORD wVK, wMod;
    GetHotKey(wVK, wMod);
    m_pParent->OnHotKeyKillFocus(wVK, wMod);
  }
}
Exemplo n.º 4
0
BOOL CSHCTHotKey::PreTranslateMessage(MSG* pMsg)
{
  // This is all to allow user to add special characters like ENTER, DELETE into
  // their assigned Hotkey
  if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
    const UINT_PTR nChar = pMsg->wParam;
    if ((nChar == VK_RETURN && 
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_TAB &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_NUMLOCK &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_SCROLL &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_CANCEL &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_DELETE) ||
        (nChar == VK_SPACE)  ||
        (nChar == VK_BACK)) {
      if (pMsg->message == WM_KEYUP)
        return TRUE;

      WORD wVirtualKeyCode, wHKModifiers;
      GetHotKey(wVirtualKeyCode, wHKModifiers);

      // Enter sets the Hotkey unless user did Ctrl+Enter, or
      // Alt+Enter or Ctrl+Alt+Enter, in which is taken as a HotKey
      if (nChar == VK_RETURN && 
          ((wHKModifiers & HOTKEYF_CONTROL) != HOTKEYF_CONTROL &&
           (wHKModifiers & HOTKEYF_ALT    ) != HOTKEYF_ALT    )) {
        CHotKeyCtrl::PreTranslateMessage(pMsg);
      }

      // No current key means don't want to use the current modifiers.
      if (wVirtualKeyCode != 0)
        wHKModifiers = 0;

      // Set extended to make sure we get DEL and not NUM DECIMAL
      if (nChar == VK_DELETE)
        wHKModifiers |= HOTKEYF_EXT;

      wVirtualKeyCode = (WORD)nChar;
      SetHotKey(wVirtualKeyCode, wHKModifiers);

      // Just in case parent requires notification of a change
      m_pParent->SendMessage(WM_COMMAND, MAKEWPARAM(IDC_SHORTCUTHOTKEY, EN_CHANGE), 0);
      return TRUE;
    }
  }
  return CHotKeyCtrl::PreTranslateMessage(pMsg);
}
Exemplo n.º 5
0
	LRESULT CHotKeyWnd::OnEditChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		if( !m_bInit ) return 0;
		if( m_pOwner == NULL ) return 0;
		GetHotKey(m_pOwner->m_wVirtualKeyCode, m_pOwner->m_wModifiers);
		if (m_pOwner->m_wVirtualKeyCode == 0) {
			m_pOwner->m_sText = _T("нч");
			m_pOwner->m_wModifiers = 0;
		}
		else {
			m_pOwner->m_sText = GetHotKeyName();
		}
		m_pOwner->GetManager()->SendNotify(m_pOwner, _T("textchanged"));
		return 0;
	}
Exemplo n.º 6
0
BOOL CSHCTHotKey::PreTranslateMessage(MSG* pMsg)
{
  if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
    const UINT_PTR nChar = pMsg->wParam;
    if ((nChar == VK_RETURN && 
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_TAB &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_NUMLOCK &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_SCROLL &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_CANCEL &&
            (GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_MENU) < 0)) ||
        (nChar == VK_DELETE) ||
        (nChar == VK_SPACE)  ||
        (nChar == VK_BACK)) {
    if (pMsg->message == WM_KEYUP)
      return TRUE;

      WORD wVK, wMod;
      GetHotKey(wVK, wMod);

      // Enter sets the Hotkey unless user did Ctrl+Enter, or
      // Alt+Enter or Ctrl+Alt+Enter, in which is taken as a HotKey
      if (nChar == VK_RETURN && 
          ((wMod & HOTKEYF_CONTROL) != HOTKEYF_CONTROL &&
           (wMod & HOTKEYF_ALT    ) != HOTKEYF_ALT    )) {
        CHotKeyCtrl::PreTranslateMessage(pMsg);
      }

      // No current key means don't want to use the current modifiers.
      if (wVK != 0)
        wMod = 0;

      // Set extended to make sure we get DEL and not NUM DECIMAL
      if (nChar == VK_DELETE)
        wMod |= HOTKEYF_EXT;

      wVK = (WORD)nChar;
      SetHotKey(wVK, wMod);

      m_pParent->SendMessage(WM_COMMAND, MAKEWPARAM(IDC_SHORTCUTHOTKEY, EN_CHANGE), 0);
      return TRUE;
    }
  }
  return CHotKeyCtrl::PreTranslateMessage(pMsg);
}
Exemplo n.º 7
0
	CDuiString CHotKeyWnd::GetHotKeyName()
	{
		ASSERT(::IsWindow(m_hWnd));

		CDuiString strKeyName;
		WORD wCode = 0;
		WORD wModifiers = 0;
		const TCHAR szPlus[] = _T(" + ");

		GetHotKey(wCode, wModifiers);
		if (wCode != 0 || wModifiers != 0)
		{
			if (wModifiers & HOTKEYF_CONTROL)
			{
				strKeyName += GetKeyName(VK_CONTROL, FALSE);
				strKeyName += szPlus;
			}


			if (wModifiers & HOTKEYF_SHIFT)
			{
				strKeyName += GetKeyName(VK_SHIFT, FALSE);
				strKeyName += szPlus;
			}


			if (wModifiers & HOTKEYF_ALT)
			{
				strKeyName += GetKeyName(VK_MENU, FALSE);
				strKeyName += szPlus;
			}


			strKeyName += GetKeyName(wCode, wModifiers & HOTKEYF_EXT);
		}

		return strKeyName;
	}
Exemplo n.º 8
0
void wxMenuItem::SetItemLabel( const wxString& string )
{
    wxString str = string;
    if ( str.empty() && !IsSeparator() )
    {
        wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
        str = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR |
                                       wxSTOCK_WITH_MNEMONIC);
    }

    // Some optimization to avoid flicker
    wxString oldLabel = m_text;
    oldLabel = wxStripMenuCodes(oldLabel);
    oldLabel.Replace(wxT("_"), wxEmptyString);
    wxString label1 = wxStripMenuCodes(str);
    wxString oldhotkey = GetHotKey();    // Store the old hotkey in Ctrl-foo format
    wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) );  // and as <control>foo

    DoSetText(str);

    if (oldLabel == label1 &&
             oldhotkey == GetHotKey())    // Make sure we can change a hotkey even if the label is unaltered
        return;

    if (m_menuItem)
    {
        GtkLabel *label;
        if (m_labelWidget)
            label = (GtkLabel*) m_labelWidget;
        else
            label = GTK_LABEL( GTK_BIN(m_menuItem)->child );

        // set new text
        gtk_label_set( label, wxGTK_CONV( m_text ) );

        // reparse key accel
        (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
        gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
    }

    guint accel_key;
    GdkModifierType accel_mods;
    gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods);
    if (accel_key != 0)
    {
        gtk_widget_remove_accelerator( GTK_WIDGET(m_menuItem),
                                       m_parentMenu->m_accel,
                                       accel_key,
                                       accel_mods );
    }

    wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*this) );
    gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
    if (accel_key != 0)
    {
        gtk_widget_add_accelerator( GTK_WIDGET(m_menuItem),
                                    "activate",
                                    m_parentMenu->m_accel,
                                    accel_key,
                                    accel_mods,
                                    GTK_ACCEL_VISIBLE);
    }
}
Exemplo n.º 9
0
	void CHotKeyWnd::GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const
	{
		DWORD dw = GetHotKey();
		wVirtualKeyCode = LOBYTE(LOWORD(dw));
		wModifiers = HIBYTE(LOWORD(dw));
	}