bool CFriendsUI::SelectItem(int iIndex, bool bTakeFocus) { if( iIndex == m_iCurSel ) return true; // We should first unselect the currently selected item if( m_iCurSel >= 0 ) { CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { pFriendListItem->SetFixedHeight(kFriendListItemNormalHeight); CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); if (pOperatorPannel != NULL) { pOperatorPannel->SetVisible(false); } } pListItem->Select(false); } } m_iCurSel = -1; } if( iIndex < 0 ) return false; if (!__super::SelectItem(iIndex, bTakeFocus)) return false; CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { pFriendListItem->SetFixedHeight(kFriendListItemSelectedHeight); CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); if (pOperatorPannel != NULL) { pOperatorPannel->SetVisible(true); } } } return true; }
void CBookClient::InEdit() { m_bEdit = !m_bEdit; int num = this->GetCount(); CContainerUI* pCtrl = NULL; for (int i = 0; i < num; ++i) { pCtrl = static_cast<CContainerUI*>(this->GetItemAt(i)); pCtrl = static_cast<CContainerUI*>(pCtrl->FindSubControl(_T("btnbookdel"))); ASSERT(pCtrl != NULL); pCtrl->SetVisible(m_bEdit); } }
void ChatDialog::OnPrepare(TNotifyUI& msg) { TCHAR szBuf[MAX_PATH] = {0}; CControlUI* background = paint_manager_.FindControl(kBackgroundControlName); if (background != NULL) { #if defined(UNDER_WINCE) _stprintf(szBuf, _T("file='%s' corner='600,200,1,1'"), bgimage_.c_str()); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("file='%s' corner='600,200,1,1'"), bgimage_.c_str()); #endif background->SetBkImage(szBuf); background->SetBkColor(bkcolor_); } CButtonUI* log_button = static_cast<CButtonUI*>(paint_manager_.FindControl(kLogoButtonControlName)); if (log_button != NULL) { #if defined(UNDER_WINCE) _stprintf(szBuf, _T("%s"), friend_.logo.c_str()); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("%s"), friend_.logo.c_str()); #endif log_button->SetNormalImage(szBuf); } CControlUI* nick_name = paint_manager_.FindControl(kNickNameControlName); if (nick_name != NULL) nick_name->SetText(friend_.nick_name.c_str()); CControlUI* desciption = paint_manager_.FindControl(kDescriptionControlName); if (desciption != NULL) desciption->SetText(friend_.description.c_str()); CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); }
void CMainWindow::OnBtn_Font(TNotifyUI& msg) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("FontBar"))); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MINIMIZE); #else SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MAXIMIZE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(true); #else SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_RESTORE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(false); #else SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CRect rcEmotionBtn = msg.pSender->GetPos(); CRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) { POINT pt = {0}; CRect rcFontbar = pFontbar->GetPos(); CRect rcColorBtn = msg.pSender->GetPos(); CRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcFontbar.top; pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); new CColorPicker(this, pt); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); InitWindow(); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 0) { if (_tcsicmp(msg.pSender->GetName(), _T("shockbtn"))==0) { theApp->ShakeToWho(friend_); } else if (_tcsicmp(msg.pSender->GetName(), _T("trans_file"))==0) { OnTransFile(msg); } else if (_tcsicmp(msg.pSender->GetName(), _T("empty_richedit")) == 0) { int lSelBegin,lSelEnd; lSelEnd = lSelBegin = m_pMsgView->GetTextLength(); m_pMsgView->SetSel(0, lSelEnd);//选择全部 m_pMsgView->ReplaceSel(_T(""), false); } else if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MINIMIZE); #else SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MAXIMIZE); CControlUI* pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(true); #else SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_RESTORE); CControlUI* pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(false); #else SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(GetPaintMgr()->FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CDuiRect rcEmotionBtn = msg.pSender->GetPos(); RECT rcWindow; GetWindowRect( &rcWindow ); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { SendMsg(); } } else if( _tcsicmp(msg.sType, _T("return")) == 0 ) { if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0) { SendMsg(); } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { // CContainerUI* pFontbar = static_cast<CContainerUI*>(GetPaintMgr()->FindControl(kFontbarControlName)); // if (pFontbar != NULL) // { // POINT pt = {0}; // CDuiRect rcFontbar = pFontbar->GetPos(); // CDuiRect rcColorBtn = msg.pSender->GetPos(); // RECT rcWindow; // GetWindowRect( &rcWindow); // // pt.y = rcWindow.top + rcFontbar.top; // pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); // new CColorPicker(this, pt); // } static CHOOSECOLOR cc; static COLORREF crCustCoLors[16]; cc.lStructSize=sizeof(CHOOSECOLOR); cc.hwndOwner= this->m_hWnd; cc.hInstance=NULL; cc.rgbResult = RGB(0,0,0); cc.lpCustColors=crCustCoLors; cc.Flags=CC_RGBINIT|CC_FULLOPEN | CC_ANYCOLOR; cc.lCustData=0; cc.lpfnHook=NULL; cc.lpTemplateName=NULL; if(TRUE == ChooseColor(&cc)) { TCHAR szBuf[MAX_PATH] = {0}; #if defined(UNDER_CE) _stprintf(szBuf, _T("FF%02X%02X%02X"), GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("FF%02X%02X%02X"), GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)); #endif LPTSTR pstr = NULL; text_color_ = _tcstoul(szBuf, &pstr, 16); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CDuiRect rcEmotionBtn = msg.pSender->GetPos(); CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); new CEmotion(this,pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName)); CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName)); if( pRichEdit == NULL ) return; pRichEdit->SetFocus(); CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength()); //CDuiString sText=pRichEdit->GetEditGifStr(); if( sText.IsEmpty() ) return; int textlen = sText.GetLength(); if (textlen > 512) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); } else { int imNum = friend_.id; TCHAR sendmesg[513] = {0}; _stprintf_s(sendmesg,512,_T("%s"),sText.GetData()); int len = strlen(sendmesg); if (len !=textlen) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); } frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen); //显示在 SendMsg(g_myself_info.nick_name,sText); pRichEdit->SetText(_T("")); //test //CDuiString strbmp; //strbmp.Format("c:\\1.gif"); //pRichEdit->InsertGif(strbmp); } } } else if( _tcsicmp(msg.sType, _T("return")) == 0 ) { if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0) { CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName)); CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName)); if( pRichEdit == NULL ) return; pRichEdit->SetFocus(); CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength()); if( sText.IsEmpty() ) return; int textlen = sText.GetLength(); if (textlen > 512) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); } else { int imNum = friend_.id; TCHAR sendmesg[513] = {0}; _stprintf_s(sendmesg,512,_T("%s"),sText.GetData()); int len = strlen(sendmesg); if (len !=textlen) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); } frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen); //显示在 SendMsg(g_myself_info.nick_name,sText); pRichEdit->SetText(_T("")); } } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) { POINT pt = {0}; CDuiRect rcFontbar = pFontbar->GetPos(); CDuiRect rcColorBtn = msg.pSender->GetPos(); CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcFontbar.top; pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); new CColorPicker((ChatDialog*)this, pt); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }