// Loads the default shortcuts from the registry void EventManager::loadAccelerators() { if (_debugMode) { std::cout << "EventManager: Loading accelerators...\n"; } xml::NodeList shortcutSets = GlobalRegistry().findXPath("user/ui/input//shortcuts"); if (_debugMode) { std::cout << "Found " << shortcutSets.size() << " sets.\n"; } // If we have two sets of shortcuts, delete the default ones if (shortcutSets.size() > 1) { GlobalRegistry().deleteXPath("user/ui/input//shortcuts[@name='default']"); } // Find all accelerators xml::NodeList shortcutList = GlobalRegistry().findXPath("user/ui/input/shortcuts//shortcut"); if (shortcutList.size() > 0) { rMessage() << "EventManager: Shortcuts found in Registry: " << static_cast<int>(shortcutList.size()) << std::endl; for (unsigned int i = 0; i < shortcutList.size(); i++) { const std::string key = shortcutList[i].getAttributeValue("key"); if (_debugMode) { std::cout << "Looking up command: " << shortcutList[i].getAttributeValue("command") << "\n"; std::cout << "Key is: >> " << key << " << \n"; } // Try to lookup the command IEventPtr event = findEvent(shortcutList[i].getAttributeValue("command")); // Check for a non-empty key string if (key != "") { // Check for valid command definitions were found if (!event->empty()) { // Get the modifier string (e.g. "SHIFT+ALT") const std::string modifierStr = shortcutList[i].getAttributeValue("modifiers"); if (!duplicateAccelerator(key, modifierStr, event)) { // Create the accelerator object IAccelerator& accelerator = addAccelerator(key, modifierStr); // Connect the newly created accelerator to the command accelerator.connectEvent(event); } } else { rWarning() << "EventManager: Cannot load shortcut definition (command invalid)." << std::endl; } } } } else { // No accelerator definitions found! rWarning() << "EventManager: No shortcut definitions found..." << std::endl; } }
static int mh_newindex (lua_State* l) { menu* m = lua_touserdata(l,1); const char* nm = luaL_checkstring(l,2); if (streq(nm, "checked")) { if (m->sub) luaL_error(l, "unsupported operation"); int flags = MF_BYCOMMAND | (luaL_checkboolean(l,3)? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(m->parent, m->command, flags); } else if (streq(nm, "enabled")) { if (m->sub) luaL_error(l, "unsupported operation"); int flags = MF_BYCOMMAND | (luaL_checkboolean(l,3)? MF_ENABLED : MF_DISABLED); EnableMenuItem(m->parent, m->command, flags); } else if (streq(nm, "name")) SetMenuName(m->parent, m->position, luaL_checkstring(l,3)); else if (streq(nm, "text")) { const char* str = luaL_checkstring(l,3); const wchar_t* wstr = strcvt(str, CP_UTF8, CP_UTF16, NULL); mh_updateLabel(m, wstr, -1, -1); free(wstr); } else if (streq(nm, "onAction")) { if (m->sub || m->command<IDM_CUSTOMCOMMAND) luaL_error(l, "unsupported operation"); if (!lua_isfunction(l,2)) luaL_typerror(l, 2, "function"); lua_pushlightuserdata(l, m->command); lua_pushvalue(l,3); lua_rawset(l, LUA_REGISTRYINDEX); void** p = getCustomCommand(m->command - IDM_CUSTOMCOMMAND); *p = lua_topointer(l,3); } else if (streq(nm, "accelerator")) { const char* str = NULL; if (!lua_isnil(l,3)) str = luaL_checkstring(l,3); int f, k; if (!(m->sub) && str && parseKeyName(str, &f, &k)) { BOOL b = removeAccelerator(m->command); addAccelerator(f, k, m->command); mh_updateLabel(m, NULL, f, k); } else if (!str) { BOOL b = removeAccelerator(m->command); mh_updateLabel(m, NULL, 0, 0); }} else if (streq(nm, "radio")) { BOOL b = luaL_checkboolean(l,3); MENUITEMINFO mii; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_FTYPE; if (!GetMenuItemInfo(m->parent, m->command, FALSE, &mii)) return 0; if (b) mii.fType|=MFT_RADIOCHECK; else mii.fType&=~MFT_RADIOCHECK; if (!SetMenuItemInfo(m->parent, m->command, FALSE, &mii)) return 0; return 1; } // SUITE else luaL_argerror(l, 2, "unknown property"); return 0; }
SingleGPU_SingleCPU::SingleGPU_SingleCPU() : ComputeNode(new Core(this, new MemoryHierarchy())) { Core * core = dynamic_cast<Core *>(cpu); assert(core != NULL); core->getMemory()->add(new Cache(64*1024, 16, 2)); // L1: 64KB / 16B / 2 cycles core->getMemory()->add(new Cache(1024*1024, 64, 20)); // L2: 1MB / 64B / 20 cycles core->getMemory()->add(new Cache(4*1024*1024, 256, 50, 4, Cache::LRU)); // L3: 4MB / 256B / 50 cycles / 4 ways LRU core->getMemory()->add(new BasicMemory(4*1024*1024*1024lu, 1024, 200)); // MEM: 4 GB / 1KB / 200 cycles addAccelerator(new DummyGPU(this), new PCIe()); }
static int mh_additem (lua_State* l) { menu* m = lua_touserdata(l,1); if (!m->sub) return 0; int k = 2, pos = 0; if (lua_isnumber(l,k)) pos = lua_tointeger(l,k++); if (pos==0) pos = -1; else if (pos>0) pos--; else if (pos<-1) pos += GetMenuItemCount(m->menu); const char* str = luaL_checkstring(l,k++); const char* sShortcut = NULL; if (lua_isstring(l,k)) sShortcut = lua_tostring(l,k++); else if (lua_isnoneornil(l,k)) k++; if (!lua_isfunction(l,k)) luaL_typerror(l, k, "function"); void* p = lua_topointer(l,k++); if (!p) return 0; const wchar_t* wstr = strcvt(str, CP_UTF8, CP_UTF16, NULL); int command = addCustomCommand(p) + IDM_CUSTOMCOMMAND; int kFlags = 0, key=0; if (parseKeyName(sShortcut, &kFlags, &key)) { addAccelerator(kFlags, key, command); const wchar_t* z = mh_buildLabel(wstr, kFlags, key); if (z!=wstr) { free(wstr); wstr = z; }} menu it; it.sub = FALSE; it.parent = m->menu; it.origin = m->origin; it.position = (pos==-1? GetMenuItemCount(m->menu) -1 : pos); it.command = command; InsertMenu(m->menu, pos, MF_STRING | MF_BYPOSITION, command, wstr); DrawMenuBar(win); free(wstr); lua_pushlightuserdata(l, command); lua_pushluafunction(l, p); lua_rawset(l, LUA_REGISTRYINDEX); lua_settop(l,0); lua_pushfulluserdata(l, &it, sizeof(it), "menuhandle"); return 1; }
void loadAccelerators() { xml::NodeList shortcutSets = GlobalRegistry().findXPath("user/ui/input//shortcuts"); // If we have two sets of shortcuts, delete the default ones if (shortcutSets.size() > 1) { GlobalRegistry().deleteXPath("user/ui/input//shortcuts[@name='default']"); } // Find all accelerators xml::NodeList shortcutList = GlobalRegistry().findXPath("user/ui/input/shortcuts//shortcut"); if (!shortcutList.empty()) { globalOutputStream() << "EventManager: Shortcuts found in Registry: " << shortcutList.size() << "\n"; for (unsigned int i = 0; i < shortcutList.size(); i++) { const std::string key = shortcutList[i].getAttributeValue("key"); const std::string command = shortcutList[i].getAttributeValue("command"); // Try to lookup the command IEvent* event = findEvent(command); // Check if valid key / command definitions were found if (key != "" && event != NULL) { // Get the modifier string (e.g. "SHIFT+ALT") const std::string modifierStr = shortcutList[i].getAttributeValue("modifiers"); if (!duplicateAccelerator(key, modifierStr, event)) { // Create the accelerator object IAccelerator* accelerator = addAccelerator(key, modifierStr); // Connect the newly created accelerator to the command accelerator->connectEvent(event); } } } } else { // No accelerator definitions found! globalOutputStream() << "EventManager: No shortcut definitions found...\n"; } }