Changeset 28 in chevmsgr


Ignore:
Timestamp:
11/30/15 01:23:56 (8 years ago)
Author:
cheese
Message:

UI
그룹챗

Location:
trunk/msvc14/ChevMsgrClient_MFC
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/msvc14/ChevMsgrClient_MFC/AddGroupChat.cpp

    r27 r28  
    3636END_MESSAGE_MAP()
    3737
     38BOOL CAddGroupChatDlg::OnInitDialog()
     39{
     40    CDialogEx::OnInitDialog();
     41
     42    for (size_t iter = 0; iter < mMsgrClntDlg->idList.size(); iter++)
     43    {
     44        mFriendListToChat.InsertString(iter, str2cstr(mMsgrClntDlg->idList[iter].id));
     45    }
     46
     47    return TRUE;
     48}
    3849
    3950// CAddGroupChat ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
     
    4152{
    4253    // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
    43    
     54    int leftidx = mFriendListToChat.GetCurSel();
     55       
     56    mFriendListToChat.GetText(leftidx, selectedId);
     57    mListSelectFriend.InsertString(mListSelectFriend.GetCount(), selectedId);
     58    mFriendListToChat.DeleteString(leftidx);
    4459}
    4560
     
    4863{
    4964    // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
     65    if (mListSelectFriend.GetCount() <= 1)
     66        return;
     67
     68    mListSelectFriend.GetText(0, groupChat);
     69    for (size_t iter = 1; iter < mListSelectFriend.GetCount(); iter++)
     70    {
     71        mListSelectFriend.GetText(iter, selectedId);
     72        groupChat = groupChat + "," + selectedId;
     73    }
    5074
    5175    CDialogEx::OnOK();
     
    5680{
    5781    // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
     82    int rightidx = mListSelectFriend.GetCurSel();
     83   
     84    if (rightidx < 0)
     85        return;
     86
     87    mListSelectFriend.DeleteString(rightidx);
     88    mListSelectFriend.GetText(rightidx, selectedId);
     89    mFriendListToChat.InsertString(mFriendListToChat.GetCount(), selectedId);
    5890}
  • trunk/msvc14/ChevMsgrClient_MFC/AddGroupChat.h

    r27 r28  
    22#include "msgclnt.h"
    33#include "afxwin.h"
     4#include "ChevMsgrClient_MFCDlg.h"
    45
    56// CAddGroupChat ´ëÈ­ »óÀÚÀÔ´Ï´Ù.
     
    1314    virtual ~CAddGroupChatDlg();
    1415    chev *chev;
     16    CChevMsgrClient_MFCDlg *mMsgrClntDlg;
    1517
    1618// ´ëÈ­ »óÀÚ µ¥ÀÌÅÍÀÔ´Ï´Ù.
     
    2426    DECLARE_MESSAGE_MAP()
    2527public:
     28    virtual BOOL OnInitDialog();
    2629    afx_msg void OnBnClickedAddList();
    2730    afx_msg void OnBnClickedOk();
     
    2932    CListBox mFriendListToChat;
    3033    CListBox mListSelectFriend;
     34    CString selectedId;
     35    CString groupChat;
    3136};
  • trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFC.cpp

    r4 r28  
    4949    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    5050    InitCommonControlsEx(&InitCtrls);
    51 
     51   
    5252    CWinApp::InitInstance();
    5353
     
    5959    // MFC ÄÁÆ®·ÑÀÇ Å׸¶¸¦ »ç¿ëÇϱâ À§ÇØ "Windows ¿øÇü" ºñÁÖ¾ó °ü¸®ÀÚ È°¼ºÈ­
    6060    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
    61 
    6261    // Ç¥ÁØ ÃʱâÈ­
    6362    // ÀÌµé ±â´ÉÀ» »ç¿ëÇÏÁö ¾Ê°í ÃÖÁ¾ ½ÇÇà ÆÄÀÏÀÇ Å©±â¸¦ ÁÙÀÌ·Á¸é
  • trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFCDlg.cpp

    r27 r28  
    8484    ON_BN_CLICKED(IDC_BTN_ADD_FRIEND, &CChevMsgrClient_MFCDlg::OnBnClickedBtnAddFriend)
    8585    ON_BN_CLICKED(IDC_BTN_ADD_CHAT, &CChevMsgrClient_MFCDlg::OnBnClickedBtnAddChat)
     86    ON_LBN_SELCHANGE(IDC_LIST_FRIENDS, &CChevMsgrClient_MFCDlg::OnLbnSelchangeListFriends)
    8687END_MESSAGE_MAP()
    8788
     
    155156    chev.listen(cb);
    156157
    157     CString cstrId;
    158     if (!chev.getFriendList(idList))
    159     {
    160         AfxMessageBox(_T("cannot get friend list"));
    161         ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);
    162     }
    163 
    164     for (size_t iter = 0; iter < idList.size(); iter++)
    165     {
    166         cstrId = str2cstr(idList[iter].id);
    167         this->mFriendListBox.InsertString(this->mFriendListBox.GetCount(), cstrId);
    168     }
     158    UpdateFriendList();
     159
     160    scl.resize(idList.size());
    169161
    170162    return TRUE;  // Æ÷Ä¿½º¸¦ ÄÁÆ®·Ñ¿¡ ¼³Á¤ÇÏÁö ¾ÊÀ¸¸é TRUE¸¦ ¹ÝȯÇÕ´Ï´Ù.
     
    222214int cb_listen(SConversation & chat)
    223215{
    224     gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr(chat.from));
    225     gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr(chat.message));
    226 
    227     gDlg->scl[gDlg->mFriendListBox.GetCurSel()].chatList.push_back(chat);
     216    CString cstr;
     217
     218    if (gDlg->mFriendListBox.GetCurSel() >= 0)
     219    {
     220        gDlg->mFriendListBox.GetText(gDlg->mFriendListBox.GetCurSel(), cstr);
     221
     222        if (cstr2str(cstr) == chat.from)
     223        {
     224            gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr("<" + chat.from + ">"));
     225            gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr(chat.message));
     226            gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), _T(""));
     227        }
     228    }
     229
     230    for (int iter = 0; iter < gDlg->mFriendListBox.GetCount(); iter++)
     231    {
     232        gDlg->mFriendListBox.GetText(iter, cstr);
     233
     234        if (cstr2str(cstr) == chat.from)
     235        {
     236            gDlg->scl[iter].chatList.push_back(chat);
     237            break;
     238        }
     239    }
    228240
    229241    return 0;
     
    263275
    264276    if (chev.tell(conversation))
     277    {
     278        mChatListBox.InsertString(mChatListBox.GetCount(), str2cstr("<" + mId + ">"));
    265279        mChatListBox.InsertString(mChatListBox.GetCount(), chat);
     280        mChatListBox.InsertString(mChatListBox.GetCount(), _T(""));
     281    }
     282
     283    gDlg->scl[gDlg->mFriendListBox.GetCurSel()].chatList.push_back(conversation);
    266284   
    267285    SetDlgItemText(IDC_EDIT_INPUT, _T(""));
     
    271289{
    272290    // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
    273     //chev.addFriend();
    274291    CAddFriendDlg AFDlg;
    275292
     
    278295
    279296    AFDlg.DoModal();
     297    UpdateFriendList();
    280298}
    281299
     
    287305
    288306    AGCDlg.chev = &this->chev;
    289 
     307    AGCDlg.mMsgrClntDlg = this;
    290308    AGCDlg.DoModal();
    291 }
     309
     310    mFriendListBox.InsertString(mFriendListBox.GetCount(), AGCDlg.groupChat);
     311}
     312
     313void CChevMsgrClient_MFCDlg::UpdateFriendList()
     314{
     315    CString cstrId;
     316    if (!chev.getFriendList(idList))
     317    {
     318        AfxMessageBox(_T("cannot get friend list"));
     319        ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);
     320    }
     321
     322    this->mFriendListBox.ResetContent();
     323
     324    for (size_t iter = 0; iter < idList.size(); iter++)
     325    {
     326        cstrId = str2cstr(idList[iter].id);
     327        this->mFriendListBox.InsertString(this->mFriendListBox.GetCount(), cstrId);
     328    }
     329}
     330
     331void CChevMsgrClient_MFCDlg::OnLbnSelchangeListFriends()
     332{
     333    // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
     334    mChatListBox.ResetContent();
     335    int idx = mFriendListBox.GetCurSel();
     336   
     337    if (idx < 0)
     338        return;
     339   
     340    if (scl[idx].sessionId == "")
     341        return;
     342
     343    for (std::list<SConversation>::iterator iter = scl[idx].chatList.begin();
     344    iter != scl[idx].chatList.end(); iter++)
     345    {
     346        mChatListBox.InsertString(mChatListBox.GetCount(), str2cstr("<" + iter->from + ">"));
     347        mChatListBox.InsertString(mChatListBox.GetCount(), str2cstr(iter->message));
     348        mChatListBox.InsertString(mChatListBox.GetCount(), _T(""));
     349    }
     350}
  • trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFCDlg.h

    r27 r28  
    4848    afx_msg void OnBnClickedBtnAddFriend();
    4949    afx_msg void OnBnClickedBtnAddChat();
     50    void UpdateFriendList();
     51    afx_msg void OnLbnSelchangeListFriends();
    5052};
Note: See TracChangeset for help on using the changeset viewer.