本文整理汇总了C++中CAction类的典型用法代码示例。如果您正苦于以下问题:C++ CAction类的具体用法?C++ CAction怎么用?C++ CAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnAction
bool CGUIWindowFullScreen::OnAction(const CAction &action)
{
if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) &&
g_infoManager.IsPlayerChannelPreviewActive() &&
(action.GetID() == ACTION_SELECT_ITEM || CButtonTranslator::GetInstance().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM))
{
// If confirm channel switch is active, channel preview is currently shown
// and the button that caused this action matches (global) action "Select" (OK)
// switch to the channel currently displayed within the preview.
g_application.m_pPlayer->SwitchChannel(g_application.CurrentFileItem().GetPVRChannelInfoTag());
return true;
}
switch (action.GetID())
{
case ACTION_SHOW_OSD:
ToggleOSD();
return true;
case ACTION_TRIGGER_OSD:
TriggerOSD();
return true;
case ACTION_SHOW_GUI:
{
// switch back to the menu
g_windowManager.PreviousWindow();
return true;
}
break;
case ACTION_SHOW_OSD_TIME:
m_bShowCurrentTime = !m_bShowCurrentTime;
g_infoManager.SetShowTime(m_bShowCurrentTime);
return true;
break;
case ACTION_SHOW_INFO:
{
CGUIDialogFullScreenInfo* pDialog = (CGUIDialogFullScreenInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO);
if (pDialog)
{
CFileItem item(g_application.CurrentFileItem());
pDialog->Open();
return true;
}
break;
}
case ACTION_ASPECT_RATIO:
{ // toggle the aspect ratio mode (only if the info is onscreen)
if (m_bShowViewModeInfo)
{
#ifdef HAS_VIDEO_PLAYBACK
g_application.m_pPlayer->SetRenderViewMode(CViewModeSettings::GetNextQuickCycleViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode));
#endif
}
m_bShowViewModeInfo = true;
m_dwShowViewModeTimeout = XbmcThreads::SystemClockMillis();
}
return true;
break;
case ACTION_SHOW_PLAYLIST:
{
CFileItem item(g_application.CurrentFileItem());
if (item.HasPVRChannelInfoTag())
g_windowManager.ActivateWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS);
else if (item.HasVideoInfoTag())
g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST);
else if (item.HasMusicInfoTag())
g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST);
}
return true;
break;
default:
break;
}
return CGUIWindow::OnAction(action);
}
示例2: OnAction
bool CGUISpinControl::OnAction(const CAction &action)
{
switch (action.GetID())
{
case REMOTE_0:
case REMOTE_1:
case REMOTE_2:
case REMOTE_3:
case REMOTE_4:
case REMOTE_5:
case REMOTE_6:
case REMOTE_7:
case REMOTE_8:
case REMOTE_9:
{
if (strlen(m_szTyped) >= 3)
{
m_iTypedPos = 0;
strcpy(m_szTyped, "");
}
int iNumber = action.GetID() - REMOTE_0;
m_szTyped[m_iTypedPos] = iNumber + '0';
m_iTypedPos++;
m_szTyped[m_iTypedPos] = 0;
int iValue;
sscanf(m_szTyped, "%i", &iValue);
switch (m_iType)
{
case SPIN_CONTROL_TYPE_INT:
{
if (iValue < m_iStart || iValue > m_iEnd)
{
m_iTypedPos = 0;
m_szTyped[m_iTypedPos] = iNumber + '0';
m_iTypedPos++;
m_szTyped[m_iTypedPos] = 0;
sscanf(m_szTyped, "%i", &iValue);
if (iValue < m_iStart || iValue > m_iEnd)
{
m_iTypedPos = 0;
strcpy(m_szTyped, "");
return true;
}
}
m_iValue = iValue;
CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
SendWindowMessage(msg);
}
break;
case SPIN_CONTROL_TYPE_TEXT:
{
if (iValue < 0 || iValue >= (int)m_vecLabels.size())
{
m_iTypedPos = 0;
m_szTyped[m_iTypedPos] = iNumber + '0';
m_iTypedPos++;
m_szTyped[m_iTypedPos] = 0;
sscanf(m_szTyped, "%i", &iValue);
if (iValue < 0 || iValue >= (int)m_vecLabels.size())
{
m_iTypedPos = 0;
strcpy(m_szTyped, "");
return true;
}
}
m_iValue = iValue;
CGUIMessage msg(GUI_MSG_CLICKED, GetID(), GetParentID());
SendWindowMessage(msg);
}
break;
}
return true;
}
break;
case ACTION_PAGE_UP:
if (!m_bReverse)
PageDown();
else
PageUp();
return true;
break;
case ACTION_PAGE_DOWN:
if (!m_bReverse)
PageUp();
else
PageDown();
return true;
break;
case ACTION_SELECT_ITEM:
if (m_iSelect == SPIN_BUTTON_UP)
{
MoveUp();
return true;
}
if (m_iSelect == SPIN_BUTTON_DOWN)
{
MoveDown();
//.........这里部分代码省略.........
示例3: OnAction
bool CGUIBaseContainer::OnAction(const CAction &action)
{
if (action.GetID() >= KEY_ASCII)
{
OnJumpLetter((char)(action.GetID() & 0xff));
return true;
}
switch (action.GetID())
{
case ACTION_MOVE_LEFT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_DOWN:
case ACTION_MOVE_UP:
case ACTION_NAV_BACK:
{
if (!HasFocus()) return false;
if (action.GetHoldTime() > HOLD_TIME_START &&
((m_orientation == VERTICAL && (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN)) ||
(m_orientation == HORIZONTAL && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT))))
{ // action is held down - repeat a number of times
float speed = std::min(1.0f, (float)(action.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START));
unsigned int frameDuration = CTimeUtils::GetFrameTime() - m_lastHoldTime;
//scrollrate is minimum 4 items/sec and max rows/10 items/sec
m_scrollItemsPerFrame += std::max(0.004f*(float)frameDuration, (float)(speed * 0.0001f * GetRows() * frameDuration));
m_lastHoldTime = CTimeUtils::GetFrameTime();
if(m_scrollItemsPerFrame < 1.0f)//not enough hold time accumulated for one step
return false;
if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP)
while (m_scrollItemsPerFrame-- >= 1) MoveUp(false);
else
while (m_scrollItemsPerFrame-- >= 1) MoveDown(false);
return true;
}
else
{
//if HOLD_TIME_START is reached we need
//a sane initial value for calculating m_scrollItemsPerPage
m_lastHoldTime = CTimeUtils::GetFrameTime();
m_scrollItemsPerFrame = 0.0f;
return CGUIControl::OnAction(action);
}
}
break;
case ACTION_FIRST_PAGE:
SelectItem(0);
return true;
case ACTION_LAST_PAGE:
if (m_items.size())
SelectItem(m_items.size() - 1);
return true;
case ACTION_NEXT_LETTER:
{
OnNextLetter();
return true;
}
break;
case ACTION_PREV_LETTER:
{
OnPrevLetter();
return true;
}
break;
case ACTION_JUMP_SMS2:
case ACTION_JUMP_SMS3:
case ACTION_JUMP_SMS4:
case ACTION_JUMP_SMS5:
case ACTION_JUMP_SMS6:
case ACTION_JUMP_SMS7:
case ACTION_JUMP_SMS8:
case ACTION_JUMP_SMS9:
{
OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2);
return true;
}
break;
default:
if (action.GetID())
{
return OnClick(action.GetID());
}
}
return false;
}
示例4: OnAction
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
bool handled = true;
if (action.GetID() == (KEY_VKEY | XBMCVK_BACK))
Backspace();
else if (action.GetID() == ACTION_ENTER || (m_isKeyboardNavigationMode && action.GetID() == ACTION_SELECT_ITEM))
OnOK();
else if (action.GetID() == ACTION_SHIFT)
OnShift();
else if (action.GetID() == ACTION_SYMBOLS)
OnSymbols();
// don't handle move left/right and select in the edit control
else if (!m_isKeyboardNavigationMode &&
(action.GetID() == ACTION_MOVE_LEFT ||
action.GetID() == ACTION_MOVE_RIGHT ||
action.GetID() == ACTION_SELECT_ITEM))
handled = false;
else if (action.GetID() == ACTION_VOICE_RECOGNIZE)
OnVoiceRecognition();
else
{
std::wstring wch = L"";
wch.insert(wch.begin(), action.GetUnicode());
std::string ch;
g_charsetConverter.wToUTF8(wch, ch);
handled = CodingCharacter(ch);
if (!handled)
{
// send action to edit control
CGUIControl *edit = GetControl(CTL_EDIT);
if (edit)
handled = edit->OnAction(action);
if (!handled && action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
{
uint8_t b = action.GetID() & 0xFF;
if (b == XBMCVK_TAB)
{
// Toggle left/right key mode
m_isKeyboardNavigationMode = !m_isKeyboardNavigationMode;
if (m_isKeyboardNavigationMode)
{
m_previouslyFocusedButton = GetFocusedControlID();
SET_CONTROL_FOCUS(edit->GetID(), 0);
}
else
SET_CONTROL_FOCUS(m_previouslyFocusedButton, 0);
handled = true;
}
}
}
}
if (!handled) // unhandled by us - let's see if the baseclass wants it
handled = CGUIDialog::OnAction(action);
return handled;
}
示例5: OnAction
bool CGUIDialogKeyboard::OnAction(const CAction &action)
{
bool handled(true);
if (action.GetID() == ACTION_BACKSPACE)
{
Backspace();
}
else if (action.GetID() == ACTION_ENTER)
{
OnOK();
}
else if (action.GetID() == ACTION_CURSOR_LEFT)
{
MoveCursor( -1);
}
else if (action.GetID() == ACTION_CURSOR_RIGHT)
{
if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' '))
{ // add a space
Character(L' ');
}
else
MoveCursor(1);
}
else if (action.GetID() == ACTION_SHIFT)
{
OnShift();
}
else if (action.GetID() == ACTION_SYMBOLS)
{
OnSymbols();
}
else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
{
OnRemoteNumberClick(action.GetID());
}
else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
{ // input from the keyboard (vkey, not ascii)
uint8_t b = action.GetID() & 0xFF;
if (b == 0x24) // home
{
MoveCursor(-GetCursorPos());
}
else if (b == 0x23) // end
{
MoveCursor(m_strEdit.GetLength() - GetCursorPos());
}
else if (b == 0x25) // left
{
MoveCursor( -1);
}
else if (b == 0x27) // right
{
MoveCursor(1);
}
else if (b == 0x0D) // enter
{
OnOK();
}
else if (b == 0x2E) // delete
{
if (GetCursorPos() < m_strEdit.GetLength())
{
MoveCursor(1);
Backspace();
}
}
else if (b == 0x08) Backspace(); // backspace
else if (b == 0x1B) Close(); // escape
}
else if (action.GetID() >= KEY_ASCII)
{ // input from the keyboard
//char ch = action.GetID() & 0xFF;
switch (action.GetUnicode())
{
case 13: // enter
case 10: // enter
OnOK();
break;
case 8: // backspace
Backspace();
break;
case 27: // escape
Close();
break;
default: //use character input
Character(action.GetUnicode());
break;
}
}
else // unhandled by us - let's see if the baseclass wants it
handled = CGUIDialog::OnAction(action);
if (handled && m_filtering == FILTERING_SEARCH)
{ // we did _something_, so make sure our search message filter is reset
SendSearchMessage();
}
return handled;
}
示例6: OnAction
bool CGUIBaseContainer::OnAction(const CAction &action)
{
if (action.GetID() >= KEY_ASCII)
{
OnJumpLetter((char)(action.GetID() & 0xff));
return true;
}
// stop the timer on any other action
m_matchTimer.Stop();
switch (action.GetID())
{
case ACTION_MOVE_LEFT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_DOWN:
case ACTION_MOVE_UP:
case ACTION_NAV_BACK:
case ACTION_PREVIOUS_MENU:
{
if (!HasFocus()) return false;
if (action.GetHoldTime() > HOLD_TIME_START &&
((m_orientation == VERTICAL && (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN)) ||
(m_orientation == HORIZONTAL && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT))))
{ // action is held down - repeat a number of times
float speed = std::min(1.0f, (float)(action.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START));
unsigned int frameDuration = std::min(CTimeUtils::GetFrameTime() - m_lastHoldTime, 50u); // max 20fps
// maximal scroll rate is at least 30 items per second, and at most (item_rows/7) items per second
// i.e. timed to take 7 seconds to traverse the list at full speed.
// minimal scroll rate is at least 10 items per second
float maxSpeed = std::max(frameDuration * 0.001f * 30, frameDuration * 0.001f * GetRows() / 7);
float minSpeed = frameDuration * 0.001f * 10;
m_scrollItemsPerFrame += std::max(minSpeed, speed*maxSpeed); // accelerate to max speed
m_lastHoldTime = CTimeUtils::GetFrameTime();
if(m_scrollItemsPerFrame < 1.0f)//not enough hold time accumulated for one step
return true;
while (m_scrollItemsPerFrame >= 1)
{
if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP)
MoveUp(false);
else
MoveDown(false);
m_scrollItemsPerFrame--;
}
return true;
}
else
{
//if HOLD_TIME_START is reached we need
//a sane initial value for calculating m_scrollItemsPerPage
m_lastHoldTime = CTimeUtils::GetFrameTime();
m_scrollItemsPerFrame = 0.0f;
return CGUIControl::OnAction(action);
}
}
break;
case ACTION_FIRST_PAGE:
SelectItem(0);
return true;
case ACTION_LAST_PAGE:
if (m_items.size())
SelectItem(m_items.size() - 1);
return true;
case ACTION_NEXT_LETTER:
{
OnNextLetter();
return true;
}
break;
case ACTION_PREV_LETTER:
{
OnPrevLetter();
return true;
}
break;
case ACTION_JUMP_SMS2:
case ACTION_JUMP_SMS3:
case ACTION_JUMP_SMS4:
case ACTION_JUMP_SMS5:
case ACTION_JUMP_SMS6:
case ACTION_JUMP_SMS7:
case ACTION_JUMP_SMS8:
case ACTION_JUMP_SMS9:
{
OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2);
return true;
}
break;
default:
if (action.GetID())
{
return OnClick(action.GetID());
}
//.........这里部分代码省略.........
示例7: OnAction
bool CGUIBaseContainer::OnAction(const CAction &action)
{
if (action.GetID() >= KEY_ASCII)
{
OnJumpLetter((char)(action.GetID() & 0xff));
return true;
}
switch (action.GetID())
{
case ACTION_MOVE_LEFT:
case ACTION_MOVE_RIGHT:
case ACTION_MOVE_DOWN:
case ACTION_MOVE_UP:
case ACTION_NAV_BACK:
{
if (!HasFocus()) return false;
if (action.GetHoldTime() > HOLD_TIME_START &&
((m_orientation == VERTICAL && (action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN)) ||
(m_orientation == HORIZONTAL && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT))))
{ // action is held down - repeat a number of times
float speed = std::min(1.0f, (float)(action.GetHoldTime() - HOLD_TIME_START) / (HOLD_TIME_END - HOLD_TIME_START));
unsigned int itemsPerFrame = 1;
if (m_lastHoldTime) // number of rows/10 items/second max speed
itemsPerFrame = std::max((unsigned int)1, (unsigned int)(speed * 0.0001f * GetRows() * (CTimeUtils::GetFrameTime() - m_lastHoldTime)));
m_lastHoldTime = CTimeUtils::GetFrameTime();
if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_UP)
while (itemsPerFrame--) MoveUp(false);
else
while (itemsPerFrame--) MoveDown(false);
return true;
}
else
{
m_lastHoldTime = 0;
return CGUIControl::OnAction(action);
}
}
break;
case ACTION_FIRST_PAGE:
SelectItem(0);
return true;
case ACTION_LAST_PAGE:
if (m_items.size())
SelectItem(m_items.size() - 1);
return true;
case ACTION_NEXT_LETTER:
{
OnNextLetter();
return true;
}
break;
case ACTION_PREV_LETTER:
{
OnPrevLetter();
return true;
}
break;
case ACTION_JUMP_SMS2:
case ACTION_JUMP_SMS3:
case ACTION_JUMP_SMS4:
case ACTION_JUMP_SMS5:
case ACTION_JUMP_SMS6:
case ACTION_JUMP_SMS7:
case ACTION_JUMP_SMS8:
case ACTION_JUMP_SMS9:
{
OnJumpSMS(action.GetID() - ACTION_JUMP_SMS2 + 2);
return true;
}
break;
default:
if (action.GetID())
{
return OnClick(action.GetID());
}
}
return false;
}
示例8: OnAction
bool CGUIDialogNumeric::OnAction(const CAction &action)
{
if (action.GetID() == ACTION_NEXT_ITEM)
OnNext();
else if (action.GetID() == ACTION_PREV_ITEM)
OnPrevious();
else if (action.GetID() == ACTION_BACKSPACE)
OnBackSpace();
else if (action.GetID() == ACTION_ENTER)
OnOK();
else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
OnNumber(action.GetID() - REMOTE_0);
else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
{ // input from the keyboard (vkey, not ascii)
BYTE b = action.GetID() & 0xFF;
if (b == XBMCVK_LEFT) OnPrevious();
else if (b == XBMCVK_RIGHT) OnNext();
else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) OnOK();
else if (b == XBMCVK_BACK) OnBackSpace();
else if (b == XBMCVK_ESCAPE) OnCancel();
}
else if (action.GetID() >= KEY_ASCII) // FIXME make it KEY_UNICODE
{ // input from the keyboard
if (action.GetUnicode() == 10 || action.GetUnicode() == 13) OnOK(); // enter
else if (action.GetUnicode() == 8) OnBackSpace(); // backspace
else if (action.GetUnicode() == 27) OnCancel(); // escape
else if (action.GetUnicode() >= 48 && action.GetUnicode() < 58) // number
OnNumber(action.GetUnicode() - 48);
}
else
return CGUIDialog::OnAction(action);
return true;
}
示例9: OnAction
bool CGUIEditControl::OnAction(const CAction &action)
{
ValidateCursor();
if (m_inputType != INPUT_TYPE_READONLY)
{
if (action.GetID() == ACTION_BACKSPACE)
{
// backspace
if (m_cursorPos)
{
if (!ClearMD5())
m_text2.erase(--m_cursorPos, 1);
UpdateText();
}
return true;
}
else if (action.GetID() == ACTION_MOVE_LEFT ||
action.GetID() == ACTION_CURSOR_LEFT)
{
if (m_cursorPos > 0)
{
m_cursorPos--;
UpdateText(false);
return true;
}
}
else if (action.GetID() == ACTION_MOVE_RIGHT ||
action.GetID() == ACTION_CURSOR_RIGHT)
{
if ((unsigned int) m_cursorPos < m_text2.size())
{
m_cursorPos++;
UpdateText(false);
return true;
}
}
else if (action.GetID() == ACTION_PASTE)
{
ClearMD5();
OnPasteClipboard();
return true;
}
else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII && m_edit.empty())
{
// input from the keyboard (vkey, not ascii)
BYTE b = action.GetID() & 0xFF;
if (b == XBMCVK_HOME)
{
m_cursorPos = 0;
UpdateText(false);
return true;
}
else if (b == XBMCVK_END)
{
m_cursorPos = m_text2.length();
UpdateText(false);
return true;
}
if (b == XBMCVK_LEFT && m_cursorPos > 0)
{
m_cursorPos--;
UpdateText(false);
return true;
}
if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length())
{
m_cursorPos++;
UpdateText(false);
return true;
}
if (b == XBMCVK_DELETE)
{
if (m_cursorPos < m_text2.length())
{
if (!ClearMD5())
m_text2.erase(m_cursorPos, 1);
UpdateText();
return true;
}
}
if (b == XBMCVK_BACK)
{
if (m_cursorPos > 0)
{
if (!ClearMD5())
m_text2.erase(--m_cursorPos, 1);
UpdateText();
}
return true;
}
else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER)
{
// enter - send click message, but otherwise ignore
SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
return true;
}
else if (b == XBMCVK_ESCAPE)
{ // escape - fallthrough to default action
return CGUIButtonControl::OnAction(action);
//.........这里部分代码省略.........
示例10: OnAction
bool CGUIPanelContainer::OnAction(const CAction &action)
{
switch (action.GetID())
{
case ACTION_PAGE_UP:
{
if (GetOffset() == 0)
{ // already on the first page, so move to the first item
SetCursor(0);
}
else
{ // scroll up to the previous page
Scroll( -m_itemsPerPage);
}
return true;
}
break;
case ACTION_PAGE_DOWN:
{
if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow >= (int)m_items.size() || (int)m_items.size() < m_itemsPerPage)
{ // already at the last page, so move to the last item.
SetCursor(m_items.size() - GetOffset() * m_itemsPerRow - 1);
}
else
{ // scroll down to the next page
Scroll(m_itemsPerPage);
}
return true;
}
break;
// smooth scrolling (for analog controls)
case ACTION_SCROLL_UP:
{
m_analogScrollCount += action.GetAmount() * action.GetAmount();
bool handled = false;
while (m_analogScrollCount > AnalogScrollSpeed())
{
handled = true;
m_analogScrollCount -= AnalogScrollSpeed();
if (GetOffset() > 0)// && GetCursor() <= m_itemsPerPage * m_itemsPerRow / 2)
{
Scroll(-1);
}
else if (GetCursor() > 0)
{
SetCursor(GetCursor() - 1);
}
}
return handled;
}
break;
case ACTION_SCROLL_DOWN:
{
m_analogScrollCount += action.GetAmount() * action.GetAmount();
bool handled = false;
while (m_analogScrollCount > AnalogScrollSpeed())
{
handled = true;
m_analogScrollCount -= AnalogScrollSpeed();
if ((GetOffset() + m_itemsPerPage) * m_itemsPerRow < (int)m_items.size())// && GetCursor() >= m_itemsPerPage * m_itemsPerRow / 2)
{
Scroll(1);
}
else if (GetCursor() < m_itemsPerPage * m_itemsPerRow - 1 && GetOffset() * m_itemsPerRow + GetCursor() < (int)m_items.size() - 1)
{
SetCursor(GetCursor() + 1);
}
}
return handled;
}
break;
}
return CGUIBaseContainer::OnAction(action);
}
示例11: msg
void CLayerDlg::OnLayerDel()
{
if(!m_layerListBox.layout_editor)
return;
if(m_layerListBox.GetCurSel() == -1)
return;
CLayer *layer = (CLayer*)m_layerListBox.GetItemDataPtr(m_layerListBox.GetCurSel());
if (layer->m_layerType == LAYER_NONFRAME) return;
if (m_layerListBox.layout_editor->layout->layers.GetCount() == 2)
{
CErrorDlg error;
error.Error("Error removing layer", "You can't remove the last layer.");
return;
}
bool do_delete = false;
if (layer)
{
CExtMsgBox msg(NULL, CONF_DELETE, CONFIRMATION, __EXT_MB_YESNO | __EXT_MB_ICONINFORMATION | __EXT_MB_DO_NOT_ASK_AGAIN, 0, "DeleteLayer", __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY);
int result = msg.DoModal();
if (result == IDYES)
do_delete = true;
else
msg.ResetMsgBox();
}
if (do_delete)
{
POSITION pos = layer->m_zOrder.GetHeadPosition();
vector<long> deletelist;
for (int i = 0; i < layer->m_zOrder.GetCount(); i++) {
deletelist.push_back(layer->m_zOrder.GetNext(pos));
}
for(int i = 0; i < deletelist.size(); i++)
{
m_layerListBox.layout_editor->DeleteObject(deletelist.at(i), TRUE);
}
// START UNDO INFO //
CAction *action = new CAction();
action->m_type = ACTION_CHANGEZORDER;
CArchive *ar = action->Prepare1();
m_layerListBox.layout_editor->SerializeAllZLists(ar);
action->Prepare2();
m_layerListBox.layout_editor->m_undo->AddAction(action);
// END UNDO INFO //
m_layerListBox.layout_editor->layout->layers.RemoveAt(m_layerListBox.layout_editor->layout->layers.Find(layer));
m_layerListBox.DeleteString(m_layerListBox.GetCurSel());
m_layerListBox.SetCurSel(0);
OnSelchange();
g_PropertyBar->Update(layout_editor, TYPE_LAYER, NULL, NULL,NULL, layout_editor->application, 0, layout_editor->layout->layers.GetAt(layout_editor->layout->layers.GetTailPosition())); // update the property editor
m_layerListBox.layout_editor->Invalidate();
CChildFrame* pCF = (CChildFrame*)m_layerListBox.layout_editor->GetParentFrame();
pCF->object_bar.Refresh();
layout_editor->layout->SetChanged(true);
}
}
示例12: GetActionID
unsigned int CKeymapActionMap::GetActionID(const CKey& key)
{
CAction action = CServiceBroker::GetInputManager().GetAction(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog(), key);
return action.GetID();
}
示例13: OnAction
bool CGUIWindowSlideShow::OnAction(const CAction &action)
{
if (m_bScreensaver)
{
g_windowManager.PreviousWindow();
return true;
}
switch (action.GetID())
{
case ACTION_SHOW_CODEC:
{
CGUIDialogPictureInfo *pictureInfo = (CGUIDialogPictureInfo *)g_windowManager.GetWindow(WINDOW_DIALOG_PICTURE_INFO);
if (pictureInfo)
{
// no need to set the picture here, it's done in Render()
pictureInfo->DoModal();
}
}
break;
case ACTION_PREVIOUS_MENU:
case ACTION_NAV_BACK:
case ACTION_STOP:
g_windowManager.PreviousWindow();
break;
case ACTION_NEXT_PICTURE:
ShowNext();
break;
case ACTION_PREV_PICTURE:
ShowPrevious();
break;
case ACTION_MOVE_RIGHT:
if (m_iZoomFactor == 1)
ShowNext();
else
Move(PICTURE_MOVE_AMOUNT, 0);
break;
case ACTION_MOVE_LEFT:
if (m_iZoomFactor == 1)
ShowPrevious();
else
Move( -PICTURE_MOVE_AMOUNT, 0);
break;
case ACTION_MOVE_DOWN:
Move(0, PICTURE_MOVE_AMOUNT);
break;
case ACTION_MOVE_UP:
Move(0, -PICTURE_MOVE_AMOUNT);
break;
case ACTION_PAUSE:
if (m_bSlideShow)
m_bPause = !m_bPause;
break;
case ACTION_PLAYER_PLAY:
if (!m_bSlideShow)
{
m_bSlideShow = true;
m_bPause = false;
}
else if (m_bPause)
m_bPause = false;
break;
case ACTION_ZOOM_OUT:
Zoom(m_iZoomFactor - 1);
break;
case ACTION_ZOOM_IN:
Zoom(m_iZoomFactor + 1);
break;
case ACTION_ROTATE_PICTURE:
Rotate();
break;
case ACTION_ZOOM_LEVEL_NORMAL:
case ACTION_ZOOM_LEVEL_1:
case ACTION_ZOOM_LEVEL_2:
case ACTION_ZOOM_LEVEL_3:
case ACTION_ZOOM_LEVEL_4:
case ACTION_ZOOM_LEVEL_5:
case ACTION_ZOOM_LEVEL_6:
case ACTION_ZOOM_LEVEL_7:
case ACTION_ZOOM_LEVEL_8:
case ACTION_ZOOM_LEVEL_9:
Zoom((action.GetID() - ACTION_ZOOM_LEVEL_NORMAL) + 1);
break;
case ACTION_ANALOG_MOVE:
Move(action.GetAmount()*PICTURE_MOVE_AMOUNT_ANALOG, -action.GetAmount(1)*PICTURE_MOVE_AMOUNT_ANALOG);
break;
default:
return CGUIWindow::OnAction(action);
}
return true;
}
示例14: ExecuteThread
// поток на выполнение...
UINT ExecuteThread(LPVOID pParam)
{
HWND hServer=hServer_;
HWND hTarget=hTarget_;
CGesture* pGesture=pGesture_;
// *** выпоняем
// сообщаяем главному окну
PostMessage(hServer,WM_IDENTIFY,(WPARAM)1,(LPARAM)pGesture);
CAction* pAction;
for(int i=0;i<pGesture->m_Commands.m_nActions;i++)
{
pAction=&pGesture->m_Commands.m_Actions[i];
switch(pAction->m_Type)
{
case 0:
{
CString &s=pAction->m_Param[0];
if(s==_T("Close"))
{
PressHotKey(VK_F4,VK_MENU);
//PostMessage(m_hClientWnd,WM_CLOSE,0,0);
}
if(s==_T("Maximize")) PostMessage(hTarget, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
if(s==_T("Minimize")) PostMessage(hTarget, WM_SYSCOMMAND, SC_MINIMIZE, 0);
if(s==_T("MinimizeAll"))
{
PressHotKey('D',VK_LWIN);
//SendMessage(FindWindow("Shell_TrayWnd",NULL),WM_COMMAND,0x019F,0);
}
if(s==_T("Copy")) PressHotKey('C',VK_CONTROL);
if(s==_T("Paste")) PressHotKey('V',VK_CONTROL);
if(s==_T("Cut")) PressHotKey('X',VK_CONTROL);
if(s==_T("Open")) PressHotKey('O',VK_CONTROL);
if(s==_T("Save")) PressHotKey('S',VK_CONTROL);
if(s==_T("Print")) PressHotKey('P',VK_CONTROL);
if(s==_T("Next")) PressHotKey(VK_RIGHT,VK_MENU);
if(s==_T("Back")) PressHotKey(VK_LEFT,VK_MENU);
if(s==_T("Shutdown"))
{
ExitWindowsEx(EWX_POWEROFF|EWX_SHUTDOWN,0);
}
if(s==_T("NextWindow")) PressHotKey(VK_ESCAPE,VK_MENU);
if(s==_T("PrevWindow"))
{
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_ESCAPE, 0, 0, 0);
keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
}
if(s==_T("Undo")) PressHotKey('Z',VK_CONTROL);
if(s==_T("Redo")) PressHotKey('Y',VK_CONTROL);
if(s==_T("SelectAll")) PressHotKey('A',VK_CONTROL);
if(s==_T("CloseDocument")) PressHotKey(VK_F4,VK_CONTROL);
}
break;
case 1:
{
//if(pAction->m_Param[0].Mid(pAction->m_Param[0].GetLength()-1,4)==".lnk")
ShellExecute(NULL,_T("open"),pAction->m_Param[0],pAction->m_Param[1],pAction->m_Param[2],SW_SHOWNORMAL);
//else
// ShellExecute(NULL,"open","start "+pAction->m_Param[0],pAction->m_Param[1],pAction->m_Param[2],SW_SHOWNORMAL);
}
break;
case 2:
TypeText(pAction->m_Param[0],hTarget);
break;
case 3:
{
int type=0,key=0;
CString s=pAction->m_Param[0];
while(!s.IsEmpty())
{
pAction->GetKeyElement(s,type,key);
if(type==0)
keybd_event(key,0,0,0);
else
keybd_event(key,0,KEYEVENTF_KEYUP,0);
Sleep(100);
}
/* //old
long i=0,m=0;
i=atol(pAction->m_Param[0]);
m=atol(pAction->m_Param[1]);
if((m & HOTKEYF_SHIFT)==HOTKEYF_SHIFT) keybd_event(VK_SHIFT,0,0,0);
if((m & HOTKEYF_CONTROL)==HOTKEYF_CONTROL) keybd_event(VK_CONTROL,0,0,0);
if((m & HOTKEYF_ALT)==HOTKEYF_ALT) keybd_event(VK_MENU,0,0,0);
keybd_event((BYTE)i, 0, 0, 0);
keybd_event((BYTE)i, 0, KEYEVENTF_KEYUP, 0);
if((m & HOTKEYF_SHIFT)==HOTKEYF_SHIFT) keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
if((m & HOTKEYF_CONTROL)==HOTKEYF_CONTROL) keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
if((m & HOTKEYF_ALT)==HOTKEYF_ALT) keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
*/
}
break;
//.........这里部分代码省略.........
示例15: assert
// all linear features are extracted from positive examples
int Segmentor::createAlphabet(const vector<Instance>& vecInsts) {
cout << "Creating Alphabet..." << endl;
int numInstance = vecInsts.size();
hash_map<string, int> char_stat;
hash_map<string, int> bichar_stat;
hash_map<string, int> action_stat;
hash_map<string, int> feat_stat;
hash_map<string, int> word_stat;
assert(numInstance > 0);
static Metric eval;
#if USE_CUDA==1
static CStateItem<gpu> state[m_classifier.MAX_SENTENCE_SIZE];
#else
static CStateItem<cpu> state[m_classifier.MAX_SENTENCE_SIZE];
#endif
static Feature feat;
static vector<string> output;
static CAction answer;
static int actionNum;
m_classifier.initAlphabet();
eval.reset();
for (numInstance = 0; numInstance < vecInsts.size(); numInstance++) {
const Instance &instance = vecInsts[numInstance];
for (int idx = 0; idx < instance.wordsize(); idx++) {
m_word_stat[normalize_to_lowerwithdigit(instance.words[idx])]++;
}
for(int distance = 1; distance <= 2; distance++) {
for (int idx = 0; idx < instance.charsize(); idx++) {
if(idx + distance >= instance.charsize()) break;
string curWord = instance.chars[idx];
for(int idz = 1; idz < distance; idz++){
curWord= curWord + instance.chars[idx+idz];
}
curWord = normalize_to_lowerwithdigit(curWord);
word_stat[curWord]++;
}
}
for (int idx = 0; idx < instance.charsize(); idx++) {
char_stat[instance.chars[idx]]++;
}
for (int idx = 0; idx < instance.charsize() - 1; idx++) {
bichar_stat[instance.chars[idx] + instance.chars[idx + 1]]++;
}
bichar_stat[instance.chars[instance.charsize() - 1] + m_classifier.fe.nullkey]++;
bichar_stat[m_classifier.fe.nullkey + instance.chars[0]]++;
actionNum = 0;
state[actionNum].initSentence(&instance.chars);
state[actionNum].clear();
while (!state[actionNum].IsTerminated()) {
state[actionNum].getGoldAction(instance.words, answer);
action_stat[answer.str()]++;
m_classifier.extractFeature(state+actionNum, answer, feat);
for (int idx = 0; idx < feat._strSparseFeat.size(); idx++) {
feat_stat[feat._strSparseFeat[idx]]++;
}
state[actionNum].move(state+actionNum+1, answer);
actionNum++;
}
if(actionNum-1 != instance.charsize()) {
std::cout << "action number is not correct, please check" << std::endl;
}
state[actionNum].getSegResults(output);
instance.evaluate(output, eval);
if (!eval.bIdentical()) {
std::cout << "error state conversion!" << std::endl;
exit(0);
}
if ((numInstance + 1) % m_options.verboseIter == 0) {
cout << numInstance + 1 << " ";
if ((numInstance + 1) % (40 * m_options.verboseIter) == 0)
cout << std::endl;
cout.flush();
}
if (m_options.maxInstance > 0 && numInstance == m_options.maxInstance)
break;
}
int discount = 2;
hash_map<string, int>::iterator word_iter;
for (word_iter = word_stat.begin(); word_iter != word_stat.end(); word_iter++) {
if (word_iter->second > discount && m_word_stat.find(word_iter->first) == m_word_stat.end()) {
m_word_stat[word_iter->first] = word_iter->second - discount;
}
}
//.........这里部分代码省略.........