void KUiLogin::Show() { KWndShowAnimate::Show(); KUiLoginBackGround::SetConfig(m_szLoginBg); char szAccount[32]; m_RememberAccount.CheckButton(g_LoginLogic.GetLoginAccount(szAccount)); g_LoginLogic.LoadAccountSetting(); m_InvisibleLogin.CheckButton(g_LoginLogic.IsInvisibleLogin()); m_Account.SetText(szAccount); if (szAccount[0]) Wnd_SetFocusWnd(&m_PassWord); else Wnd_SetFocusWnd(&m_Account); }
//-------------------------------------------------------------------------- // 功能:隐藏窗口 //-------------------------------------------------------------------------- void KWndWindow::Hide() { m_Style &= ~WND_S_VISIBLE; g_MouseOver.OnWndClosed((void*)this); KWndWindow* pFocus = Wnd_GetFocusWnd(); while(pFocus) { if (pFocus != this) pFocus = pFocus->m_pParentWnd; else { Wnd_SetFocusWnd(NULL); break; } } Wnd_ReleaseExclusive(this); // if (m_pFirstChild) // { // KWndWindow* pChild = m_pFirstChild; // while (pChild) // { // pChild->Hide(); // // pChild = pChild->m_pNextWnd; // } // } }
void KUiConnectInfo::SetInfoMsg(LOGIN_BG_INFO_MSG_INDEX eIndex) { m_DelRoleBgImg.LeaveAlone(); m_DelRoleBtn.LeaveAlone(); m_CancelDelRoleBtn.LeaveAlone(); m_ConfirmBtn.LeaveAlone(); m_ContinueBtn.LeaveAlone(); m_InputPwdWnd.LeaveAlone(); // m_BtnUnlockLink.LeaveAlone(); m_RoleName.LeaveAlone(); m_szMessage[0] = 0; m_nMsgLen = 0; m_nColor2CharacterStartIndex = 0; m_nColor2CharacterEndIndex = 0; KIniFile* pIni = g_UiBase.GetCommConfigFile(); if (pIni) { char szKey[8]; char szBuff[64]; itoa(eIndex, szKey, 10); pIni->GetString("InfoString", szKey, "", szBuff, sizeof(szBuff)); m_nMsgLen = sprintf(m_szMessage, szBuff, m_szString); if (m_nMsgLen) { m_uLastMsgColorChanageTime = IR_GetCurrentTime(); m_nColor2CharacterEndIndex = TSplitString(m_szMessage, m_nColor2CharacterStartIndex + 1, false); } } if (eIndex == CI_MI_TO_DEL_ROLE) //13=要删除角色 { AddChild(&m_DelRoleBgImg); AddChild(&m_InputPwdWnd); AddChild(&m_DelRoleBtn); AddChild(&m_RoleName); char szBuff[64]; sprintf(szBuff, "角色名字:%s", m_szString); m_RoleName.SetText(szBuff); AddChild(&m_CancelDelRoleBtn); Wnd_SetFocusWnd(&m_InputPwdWnd); } else if (eIndex == CI_MI_TO_TRANSFER_ROLE) { AddChild(&m_ContinueBtn); } else if (eIndex != CI_MI_ENTERING_GAME) { // if(eIndex == CI_MI_ACCOUNT_LOCKED) // { // AddChild(&m_BtnUnlockLink); // } AddChild(&m_ConfirmBtn); } }
//显示窗口 void KUiGetString::Show() { int Left, Top; ALW_GetWndPosition(Left, Top, m_Width, m_Height); SetPosition(Left, Top); KWndImage::Show(); Wnd_SetFocusWnd(&m_StringEdit); Wnd_SetExclusive((KWndWindow*)this); }
//-------------------------------------------------------------------------- // 功能:隐藏窗口 //-------------------------------------------------------------------------- void KWndWindow::Hide() { m_Style &= ~WND_S_VISIBLE; g_MouseOver.OnWndClosed((void*)this); KWndWindow* pFocus = Wnd_GetFocusWnd(); while(pFocus) { if (pFocus != this) pFocus = pFocus->m_pParentWnd; else { Wnd_SetFocusWnd(NULL); break; } } Wnd_ReleaseExclusive(this); }
//-------------------------------------------------------------------------- // 功能:禁止或者允许窗口被操作 //-------------------------------------------------------------------------- void KWndEdit::Enable(int bEnable) { if (bEnable) { m_Style &= ~WND_S_DISABLE; } else { if (m_Flag & WNDEDIT_F_HAVE_FOCUS) Wnd_SetFocusWnd(NULL); m_Style |= WND_S_DISABLE; } if (m_Flag & WNDEDIT_ES_WIN32_WND) { ::EnableWindow(m_hWin32Wnd, bEnable); } }
void KUiConnectInfo::SetInfoMsg(LOGIN_BG_INFO_MSG_INDEX eIndex) { m_DelRoleBgImg.LeaveAlone(); m_DelRoleBtn.LeaveAlone(); m_CancelDelRoleBtn.LeaveAlone(); m_ConfirmBtn.LeaveAlone(); m_InputPwdWnd.LeaveAlone(); m_szMessage[0] = 0; m_nMsgLen = 0; m_nColor2CharacterStartIndex = 0; m_nColor2CharacterEndIndex = 0; KIniFile* pIni = g_UiBase.GetCommConfigFile(); if (pIni) { char szKey[8]; itoa(eIndex, szKey, 10); pIni->GetString("InfoString", szKey, "", m_szMessage, sizeof(m_szMessage)); m_nMsgLen = strlen(m_szMessage); if (m_nMsgLen) { m_uLastMsgColorChanageTime = IR_GetCurrentTime(); m_nColor2CharacterEndIndex = TSplitString(m_szMessage, m_nColor2CharacterStartIndex + 1, false); } } if (eIndex == CI_MI_TO_DEL_ROLE) //13=要删除角色 { AddChild(&m_DelRoleBgImg); AddChild(&m_InputPwdWnd); AddChild(&m_DelRoleBtn); AddChild(&m_CancelDelRoleBtn); Wnd_SetFocusWnd(&m_InputPwdWnd); } else if (eIndex != CI_MI_ENTERING_GAME) { AddChild(&m_ConfirmBtn); } }
//-------------------------------------------------------------------------- // 功能:设置独占窗口 //-------------------------------------------------------------------------- void Wnd_SetExclusive(KWndWindow* pWnd) { int i; if (pWnd) { if (s_WndStation.pFocusWnd && s_WndStation.pFocusWnd->GetOwner() != pWnd->GetOwner()) Wnd_SetFocusWnd(NULL); for (i = 0; i < 4; i++) { if (s_WndStation.pExclusiveWnd[i] == pWnd) { for (int j = i; j > 0; j--) s_WndStation.pExclusiveWnd[j] = s_WndStation.pExclusiveWnd[j - 1]; s_WndStation.pExclusiveWnd[0] = pWnd; return; } } s_WndStation.pExclusiveWnd[3] = s_WndStation.pExclusiveWnd[2]; s_WndStation.pExclusiveWnd[2] = s_WndStation.pExclusiveWnd[1]; s_WndStation.pExclusiveWnd[1] = s_WndStation.pExclusiveWnd[0]; s_WndStation.pExclusiveWnd[0] = pWnd; } }
//隐藏窗口 void KUiGetString::Hide() { Wnd_SetFocusWnd(NULL); Wnd_ReleaseExclusive((KWndWindow*)this); KWndImage::Hide(); }
void KUiLogin::OnKeyDown(unsigned int uKey) { if (uKey == VK_RETURN) { if (m_Cancel.IsButtonActive()) OnCancel(); else OnLogin(); } else if (uKey == VK_TAB) { if ((GetKeyState(VK_SHIFT) & 0x8000) == 0) { // 如果没有按住Shift if (m_InvisibleLogin.IsButtonActive()) m_Login.SetCursorAbove(); else if (m_Login.IsButtonActive()) m_RememberAccount.SetCursorAbove(); else if (m_RememberAccount.IsButtonActive()) m_Cancel.SetCursorAbove(); else { int x, y, cx; m_Account.GetAbsolutePos(&x, &y); m_Account.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_Account); } } else { // 如果按住Shift if (m_InvisibleLogin.IsButtonActive()) { int x, y, cx; m_PassWord.GetAbsolutePos(&x, &y); m_PassWord.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_PassWord); } else if (m_Login.IsButtonActive()) { m_InvisibleLogin.SetCursorAbove(); } else if (m_RememberAccount.IsButtonActive()) { m_Login.SetCursorAbove(); } else // if m_Cancel.IsButtonActive() { m_RememberAccount.SetCursorAbove(); } } } else if (uKey == VK_SPACE) { if (m_Login.IsButtonActive()) OnLogin(); else if (m_Cancel.IsButtonActive()) OnCancel(); else if (m_RememberAccount.IsButtonActive()) m_RememberAccount.CheckButton(!m_RememberAccount.IsButtonChecked()); else if (m_InvisibleLogin.IsButtonActive()) m_InvisibleLogin.CheckButton(!m_InvisibleLogin.IsButtonChecked()); } else if (uKey == VK_LEFT) m_Login.SetCursorAbove(); else if (uKey == VK_RIGHT) m_Cancel.SetCursorAbove(); else if (uKey == VK_ESCAPE) OnCancel(); }
//-------------------------------------------------------------------------- // 功能:窗口函数 //-------------------------------------------------------------------------- int KUiLogin::WndProc(unsigned int uMsg, unsigned int uParam, int nParam) { int nRet = 0; switch(uMsg) { case WND_N_BUTTON_CLICK: if (uParam == (unsigned int)(KWndWindow*)&m_Login) OnLogin(); else if (uParam == (unsigned int)(KWndWindow*)&m_Cancel) OnCancel(); break; case WND_N_EDIT_SPECIAL_KEY_DOWN: if (nParam == VK_TAB) { if ((GetKeyState(VK_SHIFT) & 0x8000) == 0) { // 如果没有按住Shift if (uParam == (unsigned int)(KWndWindow*)&m_Account) { int x, y, cx; m_PassWord.GetAbsolutePos(&x, &y); m_PassWord.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_PassWord); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { Wnd_SetFocusWnd(NULL); m_InvisibleLogin.SetCursorAbove(); nRet = 1; } } else { // 如果按住Shift if (uParam == (unsigned int)(KWndWindow*)&m_Account) { Wnd_SetFocusWnd(NULL); m_Cancel.SetCursorAbove(); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { int x, y, cx; m_Account.GetAbsolutePos(&x, &y); m_Account.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_Account); nRet = 1; } } } else if (nParam == VK_RETURN) { if (uParam == (unsigned int)(KWndWindow*)&m_Account) { Wnd_SetFocusWnd(&m_PassWord); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { OnLogin(); nRet = 1; } } else if (nParam == VK_ESCAPE) { OnCancel(); nRet = 1; } break; case WM_KEYDOWN: OnKeyDown(uParam); nRet = 1; break; case WM_SYSKEYDOWN: if (uParam == 'A') OnEnableAutoLogin(); break; case WND_N_EDIT_CHANGE: if(uParam == (unsigned int)(&m_Account)) { char szBuffer[32]; m_Account.GetText(szBuffer, sizeof(szBuffer), true); g_LoginLogic.SetLoginAccount(szBuffer); g_LoginLogic.LoadAccountSetting(); m_InvisibleLogin.CheckButton(g_LoginLogic.IsInvisibleLogin()); } break; default: nRet = KWndShowAnimate::WndProc(uMsg, uParam, nParam); break; } return nRet; }
//-------------------------------------------------------------------------- // 功能:窗口函数(处理消息) //-------------------------------------------------------------------------- int KWndEdit::WndProc(unsigned int uMsg, unsigned int uParam, int nParam) { int nRet = 0; if (m_Flag & WNDEDIT_ES_WIN32_WND) { if (uMsg == WM_KEYDOWN) nRet = OnKeyDownWin32(uParam, nParam); if (uMsg == WND_M_SET_FOCUS) Win32Edit_SetFocus(m_hWin32Wnd, true); else if (uMsg == WND_M_KILL_FOCUS) Win32Edit_SetFocus(m_hWin32Wnd, false); return 0; } switch(uMsg) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: if (IsVisible() && Wnd_GetFocusWnd() != (KWndWindow*)this) { Wnd_SetFocusWnd((KWndWindow*)this); } else nRet = KWndWindow::WndProc(uMsg, uParam, nParam); break; case WM_IME_CHAR: case WM_CHAR: if ((m_Flag & WNDEDIT_F_HAVE_FOCUS) && ((m_Style & WND_S_DISABLE) == 0)) { if (InsertChar(uParam)) UpdateData(); nRet = 1; } break; case WM_KEYDOWN: if (!IsDisable()) nRet = OnKeyDown(uParam, nParam); break; case WND_M_SET_FOCUS: if (m_pText) { if (m_Flag & WNDEDIT_ES_IME_AVAILABLE) { s_Ime.EnableLanguageChange(); if (s_LastTimeIsIme) s_Ime.OpenIME(); } // m_nCaretPos = m_nTextLen; //把光标位置设在文本末尾 m_Flag |= WNDEDIT_F_HAVE_FOCUS; m_nCaretTime = 0; // CreateCaret(::g_GetMainHWnd(), (HBITMAP)NULL, 2, m_nFontSize); m_nCaretX = m_nAbsoluteLeft; m_nCaretY = m_nAbsoluteTop; SetCaretPos(m_nCaretX, m_nCaretY); s_Ime.SetCaretPos(m_nCaretX, m_nCaretY); // ShowCaret(::g_GetMainHWnd()); } break; case WND_M_KILL_FOCUS: // DestroyCaret(); if (m_Flag & WNDEDIT_ES_IME_AVAILABLE) s_LastTimeIsIme = s_Ime.IsIme(); s_Ime.DisableLanguageChange(); s_Ime.CloseIME(); m_Flag &= ~WNDEDIT_F_HAVE_FOCUS; break; case WM_SYSKEYDOWN: if (m_pParentWnd) nRet = m_pParentWnd->WndProc(uMsg, uParam, nParam); break; case WM_MOUSEWHEEL: if (!IsDisable()) { int zDelta = GET_Y_LPARAM(uParam); if (zDelta != 0) nRet = OnKeyDown(zDelta < 0 ? VK_DOWN : VK_UP, 0); } break; case WM_MOVING: case WM_MOVE: { if (m_Flag & WNDEDIT_ES_WIN32_WND) { Win32Edit_UpdateSizePos(m_hWin32Wnd, m_nAbsoluteLeft, m_nAbsoluteTop, m_Width, m_Height); break; } } default: nRet = KWndWindow::WndProc(uMsg, uParam, nParam); break; } return nRet; }
void KUiTaskNote_Personal::Hide() { Wnd_SetFocusWnd(NULL); KWndPage::Hide(); }
void KUiTaskNote_Personal::Show() { Wnd_SetFocusWnd(&m_Editor); KWndPage::Show(); }
//-------------------------------------------------------------------------- // 功能:处理输入 //-------------------------------------------------------------------------- void Wnd_ProcessInput(unsigned int uMsg, unsigned int uParam, int nParam) { KWndWindow* pActiveWnd = NULL; static bool bLastCursorEventProcessedByGameSpace = false; //====鼠标指针消息==== if ((uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) || uMsg == WM_MOUSEHOVER) { int x = 0; int y = 0; if (uMsg != WM_MOUSEWHEEL) { x = LOWORD(nParam); y = HIWORD(nParam); } else { s_WndStation.Cursor.GetPosition(x, y); } //====设置鼠标指针图形位置==== s_WndStation.Cursor.SetPosition(x, y); if (KPopupMenu::HandleInput(uMsg, uParam, nParam)) { if (bLastCursorEventProcessedByGameSpace) { bLastCursorEventProcessedByGameSpace = false; g_UiBase.SetCurrentCursor(); } return; } g_MouseOver.UpdateCursorPos(x, y); if (s_WndStation.pCaptureMouseWnd) pActiveWnd = s_WndStation.pCaptureMouseWnd; else if (s_WndStation.pExclusiveWnd[0] == NULL) { //====取得鼠标所指的最上层窗口面板==== //====让被鼠标点击的窗口成为最上层窗口面板==== if ((uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN) && s_WndStation.DragInfo.bDragging == 0) pActiveWnd = Wnd_GetActive(x, y, true); else pActiveWnd = Wnd_GetActive(x, y, false); } else //有独占窗口时,Active窗口就是它了 pActiveWnd = s_WndStation.pExclusiveWnd[0]; { KWndWindow* pTopWnd = NULL; if (pActiveWnd) pTopWnd = pActiveWnd->TopChildFromPoint(x, y); //只传给位于鼠标指针下方的最上层的窗口 if (pTopWnd != s_WndStation.pMouseOverWnd) { g_MouseOver.CancelMouseHoverInfo(); KWndWindow* pOverParent = NULL; if (s_WndStation.pMouseOverWnd) { s_WndStation.pMouseOverWnd->WndProc(WND_M_MOUSE_LEAVE, 0, 0); pOverParent = s_WndStation.pMouseOverWnd->GetParent(); if (pOverParent) { pOverParent->WndProc(WND_N_MOUSE_LEAVE_CHILD, (unsigned int)s_WndStation.pMouseOverWnd, 0); } } if (pTopWnd) { pTopWnd->WndProc(WND_M_MOUSE_ENTER, 0, 0); pOverParent = pTopWnd->GetParent(); if (pOverParent) { pOverParent->WndProc(WND_N_MOUSE_ENTER_CHILD, (unsigned int)pTopWnd, 0); } } s_WndStation.pMouseOverWnd = pTopWnd; } if (s_WndStation.pFocusWnd && pTopWnd != s_WndStation.pFocusWnd && (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN)) { Wnd_SetFocusWnd(NULL); } } bool bPrecessedByGameSpace = false; if (s_WndStation.pMouseOverWnd) s_WndStation.pMouseOverWnd->WndProc(uMsg, uParam, nParam); else if (s_WndStation.pCaptureMouseWnd) s_WndStation.pCaptureMouseWnd->WndProc(uMsg, uParam, nParam); else if (s_WndStation.pExclusiveWnd[0] == NULL && s_WndStation.bGameSpaceNotHandleInput == false && s_WndStation.pGameSpaceWnd) { s_WndStation.pGameSpaceWnd->WndProc(uMsg, uParam, nParam); bLastCursorEventProcessedByGameSpace = true; bPrecessedByGameSpace = true; } if (bPrecessedByGameSpace == false && bLastCursorEventProcessedByGameSpace) { bLastCursorEventProcessedByGameSpace = false; g_UiBase.SetCurrentCursor(); } } else {//====处理其他消息(其实都是键盘输入消息)==== if (KPopupMenu::HandleInput(uMsg, uParam, nParam)) return; if (s_WndStation.pFocusWnd && s_WndStation.pFocusWnd->WndProc(uMsg, uParam, nParam)) return; if (s_WndStation.pExclusiveWnd[0]) { s_WndStation.pExclusiveWnd[0]->WndProc(uMsg, uParam, nParam); return; } if (uMsg == WM_KEYDOWN || (uMsg == WM_KEYUP && uParam == VK_SNAPSHOT)) { int nModifier = 0; if (GetKeyState(VK_CONTROL) & 0x8000) nModifier |= HOTKEYF_CONTROL; if (GetKeyState(VK_SHIFT) & 0x8000) nModifier |= HOTKEYF_SHIFT; if (GetKeyState(VK_MENU) & 0x8000) nModifier |= HOTKEYF_ALT; if (KShortcutKeyCentre::HandleKeyInput(uParam, nModifier)) return; } else if (uMsg == WM_SYSKEYDOWN) { int nModifier = 0; if (GetKeyState(VK_CONTROL) & 0x8000) nModifier |= HOTKEYF_CONTROL; if (GetKeyState(VK_SHIFT) & 0x8000) nModifier |= HOTKEYF_SHIFT; if (GetKeyState(VK_MENU) & 0x8000) nModifier |= HOTKEYF_ALT; if (KShortcutKeyCentre::HandleKeyInput(uParam, nModifier)) return; } int bHandle = false; for (int i = 0; i < 3 && bHandle == false; i++) { if (i == 0) pActiveWnd = s_WndStation.TopLayerRoot.GetNextWnd(); else if (i == 1) pActiveWnd = s_WndStation.NormalLayerRoot.GetNextWnd(); else pActiveWnd = s_WndStation.LowLayerRoot.GetNextWnd(); while(pActiveWnd) { KWndWindow* pNextWnd = pActiveWnd->GetNextWnd(); if (pActiveWnd->IsVisible() && pActiveWnd->WndProc(uMsg, uParam, nParam)) { bHandle = true; break; } pActiveWnd = pNextWnd; } } if (bHandle == false && s_WndStation.pGameSpaceWnd && s_WndStation.bGameSpaceNotHandleInput == false) { s_WndStation.pGameSpaceWnd->WndProc(uMsg, uParam, nParam); } } }