wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction ) { /// ID numbers for tool actions need to have a value higher than ACTION_ID const BITMAP_OPAQUE* icon = aAction.GetIcon(); wxMenuItem* item = new wxMenuItem( this, getMenuId( aAction ), aAction.GetMenuItem(), aAction.GetDescription(), wxITEM_NORMAL ); if( icon ) item->SetBitmap( KiBitmap( icon ) ); m_toolActions[getMenuId( aAction )] = &aAction; return Append( item ); }
void update() { SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>(); // lines like this make me really think about a better name for SELECTION_CONDITIONS class bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) && /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/ SELECTION_CONDITIONS::SameNet( true ) && SELECTION_CONDITIONS::SameLayer() )( selTool->GetSelection() ); Enable( getMenuId( COMMON_ACTIONS::zoneMerge ), mergeEnabled ); }
LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (!_instance) return 0; switch (uMsg) { case WM_SYSCOMMAND: case WM_COMMAND: { if (HIWORD(wParam) == 0) { // menu WORD menuId = LOWORD(wParam); auto menuService = dynamic_cast<player::PlayerMenuServiceWin*> (player::PlayerProtocol::getInstance()->getMenuService()); auto menuItem = menuService->getItemByCommandId(menuId); if (menuItem) { AppEvent event("APP.EVENT", APP_EVENT_MENU); std::stringstream buf; buf << "{\"data\":\"" << menuItem->getMenuId().c_str() << "\""; buf << ",\"name\":" << "\"menuClicked\"" << "}"; event.setDataString(buf.str()); event.setUserData(menuItem); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } if (menuId == ID_HELP_ABOUT) { onHelpAbout(); } } break; } case WM_KEYDOWN: { #if (SIMULATOR_WITH_CONSOLE_AND_MENU > 0) if (wParam == VK_F5) { _instance->relaunch(); } #endif break; } case WM_COPYDATA: { PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam; if (pMyCDS->dwData == 1) { const char *szBuf = (const char*)(pMyCDS->lpData); SimulatorWin::getInstance()->writeDebugLog(szBuf); break; } } case WM_DESTROY: { DragAcceptFiles(hWnd, FALSE); break; } case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0); if (count > 0) { int fileIndex = 0; const UINT length = DragQueryFileW(hDrop, fileIndex, NULL, 0); WCHAR* buffer = (WCHAR*)calloc(length + 1, sizeof(WCHAR)); DragQueryFileW(hDrop, fileIndex, buffer, length + 1); char *utf8 = SimulatorWin::convertTCharToUtf8(buffer); std::string firstFile(utf8); CC_SAFE_FREE(utf8); DragFinish(hDrop); // broadcast drop event AppEvent forwardEvent("APP.EVENT.DROP", APP_EVENT_DROP); forwardEvent.setDataString(firstFile); Director::getInstance()->getEventDispatcher()->dispatchEvent(&forwardEvent); } } // WM_DROPFILES } return g_oldWindowProc(hWnd, uMsg, wParam, lParam); }