本文整理汇总了C++中HotkeyInfo类的典型用法代码示例。如果您正苦于以下问题:C++ HotkeyInfo类的具体用法?C++ HotkeyInfo怎么用?C++ HotkeyInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HotkeyInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool Hotkeys::OnArgComboChange() {
int selectionIdx = _keyList->Selection();
HotkeyInfo *current = &_keyInfo[selectionIdx];
HotkeyInfo::HotkeyActions action
= (HotkeyInfo::HotkeyActions) _action->SelectionIndex();
switch (action) {
case HotkeyInfo::IncreaseVolume:
case HotkeyInfo::DecreaseVolume:
case HotkeyInfo::SetVolume:
current->AllocateArg(1);
current->args[1] = std::to_wstring(_argCombo->SelectionIndex());
break;
case HotkeyInfo::EjectDrive:
current->AllocateArg(0);
/* We can place the selected string directly into the args */
current->args[0] = _argCombo->Selection();
break;
case HotkeyInfo::MediaKey:
current->AllocateArg(0);
current->args[0]
= HotkeyInfo::MediaKeyNames[_argCombo->SelectionIndex()];
break;
}
LoadSelection(selectionIdx);
return true;
}
示例2: UnregisterCustomHotkey
void HotkeysRegistry::UnregisterCustomHotkey(HWND windowHandle, int hotkeyId)
{
for(size_t i = 0; i < hotkeysRegistry.size(); ++i)
{
HotkeyInfo hotkeyInfo = hotkeysRegistry[i];
if(hotkeyInfo.GetHotkeyId() == hotkeyId && hotkeyInfo.GetWindowHandle() == windowHandle)
{
hotkeyInfo.Unregister();
hotkeysRegistry.erase(hotkeysRegistry.begin() + i);
break;
}
}
}
示例3: OnKeyListItemChange
void Hotkeys::OnKeyListItemChange(NMLISTVIEW *lv) {
if (lv->uChanged & LVIF_STATE) {
if (lv->uNewState & LVIS_SELECTED) {
int index = lv->iItem;
#if ENABLE_3RVX_LOG != 0
HotkeyInfo *current = &_keyInfo[index];
CLOG(L"Selecting key combination %d:", index);
QCLOG(L"%s", current->ToString().c_str());
#endif
LoadSelection(index);
}
}
}
示例4: switch
void KeyboardHotkeyProcessor::ProcessHotkeys(HotkeyInfo &hki) {
/* These hotkeys *require* exactly one argument: */
if (hki.args.size() != 1) {
return;
}
switch (hki.action) {
case HotkeyInfo::MediaKey: {
std::wstring &arg = hki.args[0];
unsigned short vk = mediaKeyMap[arg];
CLOG(L"Media key: %s", arg.c_str());
SyntheticKeyboard::SimulateKeypress(vk);
break;
}
case HotkeyInfo::VirtualKey: {
unsigned short vk = (unsigned short) hki.HexArgToInt(0);
if (vk == 0) {
CLOG(L"Ignoring invalid VK value");
return;
}
SyntheticKeyboard::SimulateKeypress(vk);
break;
}
}
}
示例5: RegisterCustomHotkey
void HotkeysRegistry::RegisterCustomHotkey(HotkeyInfo hotkeyInfo)
{
if(!isSuspended)
{
hotkeyInfo.Register();
}
hotkeysRegistry.push_back(hotkeyInfo);
}
示例6: VolumeArgControlStates
void Hotkeys::VolumeArgControlStates(HotkeyInfo &selection) {
_argLabel->Text(_amountVolArgStr);
_argCheck->Text(_amountVolArgStr);
_argCheck->Checked(selection.HasArgs());
_argEdit->Enabled(_argCheck->Checked());
_argEdit->Width(_argEdit->EmSize() * 6);
_argEdit->PlaceRightOf(*_argCheck);
_argEdit->X(_action->X());
_argCombo->Enabled(_argCheck->Checked());
_argCombo->AddItem(_unitsVolArgStr);
_argCombo->AddItem(_percentVolArgStr);
_argCombo->Select(0);
_argCombo->PlaceRightOf(*_argEdit);
_argCombo->Width(_action->Width() - (_argCombo->X() - _action->X()));
if (selection.HasArg(0)) {
_argEdit->Text(selection.args[0]);
}
if (selection.HasArg(1)) {
_argCombo->Select(selection.ArgToInt(1));
}
}
示例7: CurrentHotkeyInfo
bool Hotkeys::OnArgEditTextChange() {
if (_argEdit->Enabled() == false || _argEdit->Visible() == false) {
return FALSE;
}
int currentIndex = _keyList->Selection();
HotkeyInfo *current = CurrentHotkeyInfo();
if (current == NULL) {
return FALSE;
}
switch ((HotkeyInfo::HotkeyActions) current->action) {
case HotkeyInfo::IncreaseVolume:
case HotkeyInfo::DecreaseVolume:
case HotkeyInfo::SetVolume:
case HotkeyInfo::Run:
current->AllocateArg(0);
current->args[0] = _argEdit->Text();
_keyList->ItemText(currentIndex, 1, ActionString(*current));
break;
}
return TRUE;
}
示例8: ProcessHotkeys
void ProcessHotkeys(HotkeyInfo &hki) {
switch (hki.action) {
case HotkeyInfo::IncreaseVolume:
case HotkeyInfo::DecreaseVolume:
case HotkeyInfo::SetVolume:
case HotkeyInfo::Mute:
case HotkeyInfo::VolumeSlider:
if (vOSD) {
vOSD->ProcessHotkeys(hki);
}
break;
case HotkeyInfo::EjectDrive:
case HotkeyInfo::EjectLatestDrive:
if (eOSD) {
eOSD->ProcessHotkeys(hki);
}
break;
case HotkeyInfo::MediaKey:
MediaKeys::ProcessHotkeys(hki);
break;
case HotkeyInfo::Run:
if (hki.HasArgs()) {
ShellExecute(NULL, L"open", hki.args[0].c_str(),
NULL, NULL, SW_SHOWNORMAL);
}
break;
case HotkeyInfo::Settings:
ShellExecute(NULL, L"open", Settings::SettingsApp().c_str(),
NULL, NULL, SW_SHOWNORMAL);
break;
case HotkeyInfo::Exit:
SendMessage(mainWnd, WM_CLOSE, NULL, NULL);
break;
}
}
示例9: CLOG
std::unordered_map<int, HotkeyInfo> Settings::Hotkeys() {
std::unordered_map<int, HotkeyInfo> keyMappings;
if (_root == NULL) {
return keyMappings;
}
tinyxml2::XMLElement *hotkeys = _root->FirstChildElement("hotkeys");
if (hotkeys == NULL) {
return keyMappings;
}
tinyxml2::XMLElement *hotkey = hotkeys->FirstChildElement("hotkey");
for (; hotkey != NULL; hotkey = hotkey->NextSiblingElement()) {
const char *actionStr = hotkey->Attribute("action");
if (actionStr == NULL) {
CLOG(L"No action provided for hotkey; skipping");
continue;
}
int action = -1;
std::wstring wActionStr = StringUtils::Widen(actionStr);
for (unsigned int i = 0; i < HotkeyInfo::ActionNames.size(); ++i) {
const wchar_t *currentAction = HotkeyInfo::ActionNames[i].c_str();
if (_wcsicmp(wActionStr.c_str(), currentAction) == 0) {
action = i;
break;
}
}
if (action == -1) {
CLOG(L"Hotkey action '%s' not recognized; skipping",
wActionStr.c_str());
continue;
}
int combination = -1;
hotkey->QueryIntAttribute("combination", &combination);
if (combination == -1) {
CLOG(L"No key combination provided for hotkey; skipping");
continue;
}
HotkeyInfo hki;
hki.action = action;
hki.keyCombination = combination;
/* Does this hotkey action have any arguments? */
tinyxml2::XMLElement *arg = hotkey->FirstChildElement("arg");
for (; arg != NULL; arg = arg->NextSiblingElement()) {
const char *argStr = arg->GetText();
hki.args.push_back(StringUtils::Widen(argStr));
}
/* Do a validity check on the finished HKI object */
if (hki.Valid() == false) {
continue;
}
/* Whew, we made it! */
CLOG(L"%s", hki.ToString().c_str());
keyMappings[combination] = hki;
}
return keyMappings;
}
示例10: ActionString
void Hotkeys::LoadAction(int index, HotkeyInfo &selection) {
int action = selection.action;
if (action < 0) {
/* Selection has no action */
return;
}
/* First, set the action description */
_keyList->ItemText(index, 1, ActionString(selection));
/* Default visiblities */
bool showLabel = false;
bool showCheck = false;
bool showCombo = false;
bool showEdit = false;
bool showButton = false;
switch ((HotkeyInfo::HotkeyActions) action) {
case HotkeyInfo::IncreaseVolume:
case HotkeyInfo::DecreaseVolume:
VolumeArgControlStates(selection);
showCheck = true; showCombo = true; showEdit = true;
break;
case HotkeyInfo::SetVolume:
VolumeArgControlStates(selection);
showLabel = true; showCombo = true; showEdit = true;
break;
case HotkeyInfo::EjectDrive:
_argLabel->Text(_driveArgStr);
_argCombo->Width(_argCombo->EmSize() * 6);
for (int i = 0; i < 26; ++i) {
wchar_t ch = (wchar_t) i + 65;
_argCombo->AddItem(std::wstring(1, ch));
}
if (selection.HasArgs()) {
_argCombo->Select(selection.args[0]);
}
showLabel = true; showCombo = true;
break;
case HotkeyInfo::MediaKey:
_argLabel->Text(_keyArgStr);
for (std::wstring keys : HotkeyInfo::MediaKeyNames) {
_argCombo->AddItem(_translator->Translate(keys));
}
if (selection.HasArgs()) {
_argCombo->Select(_translator->Translate(selection.args[0]));
}
showLabel = true; showCombo = true;
break;
case HotkeyInfo::VirtualKey:
_argLabel->Text(_vkArgStr);
if (selection.HasArgs()) {
_argEdit->Text(selection.args[0]);
}
showLabel = true; showEdit = true;
break;
case HotkeyInfo::Run:
_argLabel->Text(_pathArgStr);
_argButton->Text(L"…");
_argButton->Width(_argButton->EmSize() * 3);
_argEdit->PlaceRightOf(*_argLabel);
_argEdit->X(_action->X());
_argEdit->Width(_keys->Width() - _argButton->Width() - _argEdit->EmSize());
_argButton->PlaceRightOf(*_argEdit);
if (selection.HasArgs()) {
_argEdit->Text(selection.args[0]);
}
showLabel = true; showEdit = true; showButton = true;
break;
}
/* Update control visibility */
_argLabel->Visible(showLabel);
_argCheck->Visible(showCheck);
_argCombo->Visible(showCombo);
_argEdit->Visible(showEdit);
_argButton->Visible(showButton);
if (_argCheck->Visible() == false) {
/* Controls are only disabled for optional arguments (check box).
* If _argCheck isn't visible, make sure everything is enabled. */
_argEdit->Enable();
_argCombo->Enable();
_argButton->Enable();
}
}