Ejemplo n.º 1
0
void MusikFXDialog::OnRightClick( wxContextMenuEvent& event )
{
	if ( event.GetId() == SLD_PITCH )
	{
		slPitch->SetValue( 50 );
		g_FX.SetFrequency( 44100 );
	}
}
Ejemplo n.º 2
0
void MainFrame::OnContextMenu(wxContextMenuEvent& evt)
{
	if (evt.GetId()==ID_LIST)
	{
		wxPoint pt = m_pList->ScreenToClient(evt.GetPosition());

		int flags = 0;
		long list_id = m_pList->HitTest(pt,flags);

		pt = evt.GetPosition();

		if (list_id == wxNOT_FOUND && pt.x==-1 && pt.y==-1 && m_pList->GetSelectedItemCount()>0)
		{
			list_id = m_pList->GetNextItem(-1,wxLIST_NEXT_ALL,wxLIST_STATE_FOCUSED);

			m_pList->GetItemPosition(list_id,pt);
			wxRect rc;
			m_pList->GetItemRect(list_id,rc,wxLIST_RECT_LABEL);

			pt.x += rc.GetWidth()/2;
			pt.y += rc.GetHeight()/2;

			pt = m_pList->ClientToScreen(pt);
		}
		else if (pt.x==-1 && pt.y==-1)
		{
			pt = m_pList->ClientToScreen(pt);
		}

		pt = ScreenToClient(pt);

		wxMenu menu;

		if (list_id != wxNOT_FOUND)
		{
			menu.Append(ID_MODIFY, _("&Modify"), _("Modifies the value's data"));
			menu.AppendSeparator();
			menu.Append(wxID_DELETE, _("&Delete"), _("Deletes the selection."));
			menu.Append(ID_RENAME, _("&Rename"), _("Renames the selection."));
		}
		else
		{
			wxMenu* pNewMenu = new wxMenu;
			pNewMenu->Append(ID_NEW_KEY, _("&Key"), _("Adds a new key."));
			pNewMenu->AppendSeparator();
			pNewMenu->Append(ID_NEW_STRING_VALUE, _("&String Value"), _("Adds a new string value."));
			pNewMenu->Append(ID_NEW_BINARY_VALUE, _("&Binary Value"), _("Adds a new binary value."));
			pNewMenu->Append(ID_NEW_UINT32_VALUE, _("&Integer Value"), _("Adds a new integer value."));
			menu.Append(ID_NEW, _("&New"), pNewMenu, _("Contains commands for creating new keys or values."));
		}

		PopupMenu(&menu,pt);
	}
	else if (evt.GetId()==ID_TREE)
	{
		wxPoint pt = m_pTree->ScreenToClient(evt.GetPosition());

		int flags = 0;
		wxTreeItemId tree_id = m_pTree->HitTest(pt,flags);

		pt = evt.GetPosition();

		if (!tree_id)
		{
			tree_id = m_pTree->GetSelection();
			if (!tree_id)
				return;

			wxRect rc;
			m_pTree->GetBoundingRect(tree_id,rc,true);

			pt.x  = rc.GetLeft() + rc.GetWidth()/2;
			pt.y  = rc.GetTop() + rc.GetHeight()/2;

			pt = m_pTree->ClientToScreen(pt);
		}

		m_pTree->SetFocus();

		pt = ScreenToClient(pt);

		wxMenu* pNewMenu = new wxMenu;
		pNewMenu->Append(ID_NEW_KEY, _("&Key"), _("Adds a new key."));
		pNewMenu->AppendSeparator();
		pNewMenu->Append(ID_NEW_STRING_VALUE, _("&String Value"), _("Adds a new string value."));
		pNewMenu->Append(ID_NEW_BINARY_VALUE, _("&Binary Value"), _("Adds a new binary value."));
		pNewMenu->Append(ID_NEW_UINT32_VALUE, _("&Integer Value"), _("Adds a new integer value."));

		wxMenu menu;
		menu.Append(ID_NEW, _("&New"), pNewMenu, _("Contains commands for creating new keys or values."));
		menu.Append(ID_FIND, _("&Find..."), _("Finds a text string in a key, value, or data."));
		menu.AppendSeparator();
		menu.Append(wxID_DELETE, _("&Delete"), _("Deletes the selection."));
		menu.Append(ID_RENAME, _("&Rename"), _("Renames the selection."));
		menu.AppendSeparator();
		menu.Append(ID_COPY_NAME, _("&Copy Key Name"), _("Copies the name of the selected key to the Clipboard."));

		PopupMenu(&menu,pt);
	}
}