void CUIChat::AdjustScroll() { // Line buffer 갯수 조절 int iCurLinePos = m_pScrollbar->GetCurrentPos(); // 현재 scroll bar가 가리키고 있는 line BOOL bAutoScroll = (m_pScrollbar->GetMaxPos() == iCurLinePos) ? TRUE : FALSE; // while (m_LineBuffers[m_eChatBuffer].size() > MAX_CHAT_LINES && 0 < iCurLinePos) // MAX_CHAT_LINES은 최대 line의 수 (단 스크롤바가 0인 곳에 있으면 line을 지우지 않으므로 500개를 넘길 수 있다) while (m_LineBuffer.size() > MAX_CHAT_LINES && 0 < iCurLinePos) // MAX_CHAT_LINES은 최대 line의 수 (단 스크롤바가 0인 곳에 있으면 line을 지우지 않으므로 500개를 넘길 수 있다) { // 한줄 지우기 // __ChatInfo* pTemp = m_LineBuffers[m_eChatBuffer].front(); __ChatInfo* pTemp = m_LineBuffer.front(); if (pTemp) delete pTemp; // m_LineBuffers[m_eChatBuffer].pop_front(); m_LineBuffer.pop_front(); --iCurLinePos; } // int iLineBufferSize = m_LineBuffers[m_eChatBuffer].size(); int iLineBufferSize = m_LineBuffer.size(); int iMaxScrollPos = iLineBufferSize-m_iChatLineCount; if (iMaxScrollPos<0) iMaxScrollPos = 0; m_pScrollbar->SetRange(0, iMaxScrollPos); // scroll bar range 설정 // 자동으로 스크롤이면 if ( bAutoScroll) iCurLinePos = iMaxScrollPos; if (iCurLinePos < 0) iCurLinePos = 0; // 스크롤바 현재 위치 재설정 m_pScrollbar->SetCurrentPos(iCurLinePos); // 스크롤바에 맞는 채팅 Line 설정 SetTopLine(iCurLinePos); }
void SciEdit::MakeLineVisible(long lLine) { long lTl = GetTopLine(); long lLl = lTl + GetVisibleLines(); if ((lLine-1 < lTl) || (lLine-1 > lLl)) SetTopLine(lLine); }
void CUIChat::RecalcLineBuffers() // 채팅창 사이즈가 변했을때 호출해주면 line buffer를 다시 계산해서 넣어준다. { int iMaxScrollPos = 0; // for(int i = 0; i < CHAT_BUFFER_COUNT; i++) // { // line buffer 초기화하기 ChatListItor itor; // for(itor = m_LineBuffers[i].begin(); m_LineBuffers[i].end() != itor; ++itor) for(itor = m_LineBuffer.begin(); m_LineBuffer.end() != itor; ++itor) { __ChatInfo* pLineBuff = (*itor); if (pLineBuff) delete pLineBuff; } // m_LineBuffers[i].clear(); m_LineBuffer.clear(); // Line buffer 다시 넣기 // for(itor = m_ChatBuffers[i].begin(); m_ChatBuffers[i].end() != itor; ++itor) for(itor = m_ChatBuffer.begin(); m_ChatBuffer.end() != itor; ++itor) { __ChatInfo* pChatBuff = (*itor); // if (pChatBuff) AddLineBuffer((e_ChatBuffer)i, pChatBuff->szChat, pChatBuff->color); if (pChatBuff) AddLineBuffer(pChatBuff->szChat, pChatBuff->color); } // Line buffer 갯수 조절 // while (m_LineBuffers[i].size() > MAX_CHAT_LINES) // MAX_CHAT_LINES은 최대 line의 수 while (m_LineBuffer.size() > MAX_CHAT_LINES) // MAX_CHAT_LINES은 최대 line의 수 { // 한줄 지우기 // __ChatInfo* pLineBuff = m_LineBuffers[i].front(); __ChatInfo* pLineBuff = m_LineBuffer.front(); if (pLineBuff) delete pLineBuff; // m_LineBuffers[i].pop_front(); m_LineBuffer.pop_front(); } // if(i == m_eChatBuffer) // { // int iLineBufferSize = m_LineBuffers[i].size(); int iLineBufferSize = m_LineBuffer.size(); iMaxScrollPos = iLineBufferSize-m_iChatLineCount; // } // } // 스크롤바 현재 위치 재설정 if (iMaxScrollPos<0) iMaxScrollPos = 0; m_pScrollbar->SetRange(0, iMaxScrollPos); // scroll bar range 설정 m_pScrollbar->SetCurrentPos(iMaxScrollPos); // 스크롤바에 맞는 채팅 Line 설정 SetTopLine(iMaxScrollPos); }
bool CUITradeList::ReceiveMessage(CN3UIBase* pSender, DWORD dwMsg) { if (dwMsg == UIMSG_BUTTON_CLICK) { if(pSender->m_szID == "btn_close") Close(); } else if (dwMsg == UIMSG_SCROLLBAR_POS) { // 스크롤바에 맞는 채팅 Line 설정 int iCurLinePos = m_pScrollbar->GetCurrentPos(); SetTopLine(iCurLinePos); } return true; }
/*--------------------------------------------------------------------------*/ SIGNED PegTextBox::Message(const PegMessage &Mesg) { switch (Mesg.wType) { case PM_VSCROLL: if (Mesg.lData != miTopLine) { Invalidate(); SIGNED iCount = miTopLine - (SIGNED) Mesg.lData; SIGNED iShift = iCount * miLineHeight; MoveClientObjects(0, iShift, FALSE); miTopLine = (SIGNED) Mesg.lData; // If FAST_BLIT is not defined, just redraw the lines of text // in my client area: #ifndef FAST_BLIT Draw(); #else // If we have scrolled more than the height of the client area, // just redraw myself #ifdef PEG_FULL_CLIPPING if (abs(iCount) >= miVisible || !ViewportList()) { Draw(); break; } if (!ViewportList()->mView.Contains(mClient)) { Draw(); break; } #else if (abs(iCount) >= miVisible) { Draw(); break; } #endif // Here for scrolling just a line or so. To improve speed, // we use RectMove to move most of the text, and just draw // the newly exposed lines. SIGNED iLine; PegRect ShiftRect = mClient; ShiftRect -= TB_WHITESPACE; ShiftRect.wBottom = ShiftRect.wTop + (miVisible * miLineHeight) - 1; PegPoint Put; Put.x = ShiftRect.wLeft; ClipToClient(); BeginDraw(); // Scroll as much as possible using RectMove() // if iCount < 0, we are advancing miTopLine and the lines // need to move up. Otherwise the lines need to move down. if (iCount < 0) // scroll lines up { Put.y = ShiftRect.wTop; ShiftRect.wTop -= iShift; Screen()->RectMove(this, ShiftRect, Put); iLine = miTopLine + miVisible + iCount; Put.y += (iLine - miTopLine) * miLineHeight; while (iLine < miTopLine + miVisible) { DrawTextLine(iLine, Put, TRUE); Put.y += miLineHeight; iLine++; } } else // scroll lines down { ShiftRect.wBottom -= iShift; Put.y = ShiftRect.wTop + iShift; Screen()->RectMove(this, ShiftRect, Put); // Draw top line(s) Put.y = mClient.wTop + TB_WHITESPACE; iLine = miTopLine; while (iLine < miTopLine + iCount) { DrawTextLine(iLine, Put, TRUE); Put.y += miLineHeight; iLine++; } } EndDraw(); EndClipToClient(); #endif } break; case PM_HSCROLL: if (Mesg.lData != miLeftOffset) { SIGNED iShift = miLeftOffset - (SIGNED) Mesg.lData; miLeftOffset = (SIGNED) Mesg.lData; // Let PegWindow do the shifting: ClipToClient(); MoveClientObjects(iShift, 0); EndClipToClient(); } break; #ifdef PEG_KEYBOARD_SUPPORT case PM_KEY: switch(Mesg.iData) { case PK_PGUP: SetTopLine(miTopLine - miVisible); break; case PK_PGDN: SetTopLine(miTopLine + miVisible); break; default: return PegWindow::Message(Mesg); } break; #endif default: return(PegWindow::Message(Mesg)); } return 0; }
/*--------------------------------------------------------------------------*/ void PegTextBox::SetTopLineToEnd(void) { SetTopLine(miTotalLines); }
bool CUIChat::ReceiveMessage(CN3UIBase* pSender, DWORD dwMsg) { if(NULL == pSender) return false; if(dwMsg == UIMSG_BUTTON_CLICK) { e_ChatMode eCM = N3_CHAT_UNKNOWN; if(pSender == m_pBtn_Normal) eCM = N3_CHAT_NORMAL; else if(pSender == m_pBtn_Private) eCM = N3_CHAT_PRIVATE; else if(pSender == m_pBtn_PartyOrForce) eCM = N3_CHAT_PARTY; else if(pSender == m_pBtn_KnightsOrGuild) eCM = N3_CHAT_CLAN; else if(pSender == m_pBtn_Shout) eCM = N3_CHAT_SHOUT; if(pSender == m_pBtn_Check) ChatListenEnable(); if(N3_CHAT_UNKNOWN != eCM) this->ChangeChattingMode(eCM); // 채팅 모드가 바뀌면.. } else if (dwMsg == UIMSG_SCROLLBAR_POS) { // 스크롤바에 맞는 채팅 Line 설정 int iCurLinePos = m_pScrollbar->GetCurrentPos(); SetTopLine(iCurLinePos); } //son, chat_in else if (dwMsg == UIMSG_EDIT_RETURN) { CN3UIEdit* pEdit = (CN3UIEdit*)pSender; //채팅 m_pEdit->SetString(""); 해버린 후에는 m_pEdit->GetString();해서 얻어온 포인터가 // 유효하지 않은 포인터가 되므로 주의.. // buffer에 카피해둠. m_szString = m_pEdit->GetString(); int iStrLen = m_szString.size(); if (iStrLen > 0) { if(iStrLen > 1 && '/' == m_szString[0]) { CGameProcedure::s_pProcMain->ParseChattingCommand(m_szString); } else if(iStrLen > 1 && '@' == m_szString[0]) { int iTmp = m_szString.find(' '); if(iTmp > 0) { std::string szID = m_szString.substr(1, iTmp-1); CGameProcedure::s_pProcMain->MsgSend_ChatSelectTarget(szID); CGameProcedure::s_pProcMain->MsgSend_Chat(N3_CHAT_PRIVATE, &(m_szString[1])); } } else if(iStrLen > 1 && '#' == m_szString[0]) // 파티 { CGameProcedure::s_pProcMain->MsgSend_Chat(N3_CHAT_PARTY, &(m_szString[1])); } else if(iStrLen > 1 && '$' == m_szString[0]) // 클랜 { CGameProcedure::s_pProcMain->MsgSend_Chat(N3_CHAT_CLAN, &(m_szString[1])); } else if(iStrLen > 1 && '!' == m_szString[0]) // 외치기 { CGameProcedure::s_pProcMain->MsgSend_Chat(N3_CHAT_SHOUT, &(m_szString[1])); } else { CGameProcedure::s_pProcMain->MsgSend_Chat(m_eChatMode, m_szString); // this->SetFocus(); } } // 화면에 표시되는 글씨는 지운다. // this->SetString(""); // ::SetWindowText(s_hWndEdit, ""); SetEnableKillFocus(true); } //son, chat_in return true; }
void CUITradeList::Open(int iIDTarget) { SetVisible(true); if (iIDTarget == -1) return; __TABLE_EXCHANGE_QUEST* pQuest = NULL; __TABLE_PLAYER_LOOKS* pPlayer = NULL; __TABLE_ITEM_BASIC* pItem = NULL; // 아이디 = 직업 코드*1000 + 001부터.. (직업 코드+1)*100 + 001까지.. int i, iIDFirst, iIDIndexFirst, iIDIndexLast, iDivide, iTotalCount; iIDFirst = iIDTarget*1000+1; iIDIndexFirst = CGameBase::s_pTbl_Exchange_Quest->IDToIndex(iIDFirst); if ( iIDIndexFirst == -1 ) return; // 아무런 리스트도 가지고 있지 않다.. iTotalCount = CGameBase::s_pTbl_Exchange_Quest->GetSize(); iIDIndexLast = 0; for( i = iIDIndexFirst; i < iTotalCount; i++ ) { pQuest = CGameBase::s_pTbl_Exchange_Quest->GetIndexedData(i); if (!pQuest) { iIDIndexLast = i; break; } iDivide = pQuest->dwID / 1000; if ( iDivide != (iIDFirst / 1000) ) { iIDIndexLast = i; break; } } if (!iIDIndexLast) iIDIndexLast = iTotalCount; // 메시지 박스 텍스트 표시.. char pszID[32]; for( i = iIDIndexFirst; i < iIDIndexFirst + 40; i++ ) { pQuest = CGameBase::s_pTbl_Exchange_Quest->GetIndexedData(i); if (pQuest) { iDivide = pQuest->dwID / 1000; pPlayer = CGameBase::s_pTbl_NPC_Looks->Find(iDivide); m_sStr[i-iIDIndexFirst] = pPlayer->szName; m_sStr[i-iIDIndexFirst] += "에게 "; pItem = CGameBase::s_pTbl_Items_Basic->Find(pQuest->iCondition0); if(pItem) m_sStr[i-iIDIndexFirst] += pItem->szName; else m_sStr[i-iIDIndexFirst] += "NULL Item"; m_sStr[i-iIDIndexFirst] += "과 "; pItem = CGameBase::s_pTbl_Items_Basic->Find(pQuest->iCondition1); if(pItem) m_sStr[i-iIDIndexFirst] += pItem->szName; else m_sStr[i-iIDIndexFirst] += "NULL Item"; m_sStr[i-iIDIndexFirst] += "를 "; sprintf(pszID, "%d",i); m_sStr[i-iIDIndexFirst] += pszID; m_sStr[i-iIDIndexFirst] += "\n"; } else m_sStr[i-iIDIndexFirst] = ""; } SetTopLine(m_pScrollbar->GetCurrentPos()); }
int main() { // Configure UART2 for no interrupts at 9600 baud. Include a reset of // the RX flag as required. OpenUART2(UART_EN, UART_TX_ENABLE, BRGVAL); IFS1bits.U2RXIF = 0; // This variable is defined as 2 to specify that UART2 will be used for // stdin/stdout. __C30_UART = 2; /****************************************************************************** * Your code goes in between this comment and the following one with asterisks. *****************************************************************************/ LcdInit(); //initialize our lcd InitButtons(); //initialize our buttons InitMorseDecoder(); //initialize morse tree printf("Type Morse With Buttons Above\n"); SetTopLine(greet); while(1) { if(ReceivedInput(temp)) { //check for user input printf("Your input: %c\n", temp); //echo input EncodeCharacter(temp, out); //encode the character then display printf("In Morse: %c%c%c%c%c%c\n", out[0], out[1], out[2], out[3], out[4], out[5]); } char x = CheckButtonEvents(); //check for button event if (x == 0x00) { // check if no Buttons were pressed if(flag0 != 1) { SetTopLine(greet); } flag0 = 1; } else if (x & Button6DownEvent) { // check if Button 6 was pressed if(flag1 != 1) { toDecode[position] = dash; //save input to current slot toDecode[position+1] = space; position++; //increment to next slot SetBottomLine(toDecode); //display total line array } flag1 = 1; //flag is on } else if (x & Button6UpEvent) { // check if Button 6 was released flag1 = 0; //clear flag } else if (x & Button5DownEvent) { // check if Button 5 was pressed if(flag2 != 1) { toDecode = (char *)GetBottomLine(); //decode what ever is in bottom line } flag2 = 1; } else if (x & Button5UpEvent) { // check if Button 5 was released decodeChar[0] = DecodeCharacter(toDecode); // decode our input topline[Pos] = decodeChar[0]; // add next decoded char Pos++; SetTopLine(topline); SetBottomLine(empty); // clear bottom line on LCD int i; for(i = 0; i < 16; i++) { toDecode[i] = ' '; // clear bottom line } position = 0; // start at new line of input flag2 = 0; } else if (x & Button4DownEvent) { // check if Button 4 was pressed flag3 = 1; //flag is on } else if (x & Button4UpEvent) { // check if Button 3 was released topline[Pos] = ' '; // add space for next decodedc char Pos++; SetTopLine(topline); SetBottomLine(empty); int i; for(i = 0; i < 16; i++) { toDecode[i] = ' '; // clear bottom line } position = 0; // start at new line of input flag3 = 0; } else if (x & Button3DownEvent) { // check if Button 3 was pressed if(flag4 != 1) { toDecode[position] = dot; toDecode[position + 1] = space; position++; SetBottomLine(toDecode); } flag4 = 1; //flag is on } else if (x & Button3UpEvent) { // check if Button 3 was released flag4 = 0; //clear flag } } /****************************************************************************** * Your code goes in between this comment and the preceeding one with asterisks *****************************************************************************/ while (1); }