//************************************************************************ // Initializes the screen //************************************************************************ bool CListScreen::Initialize() { if(!CScreen::Initialize()) return false; m_Controller = CHeliumController::getInstance(); m_Playlist.Initialize(); m_Playlist.SetOrigin(0,0); m_Playlist.SetSize(GetWidth(),GetHeight()-6); m_ListPositionLabel.Initialize(); m_ListPositionLabel.SetAlignment(DT_CENTER); m_ListPositionLabel.SetWordWrap(TRUE); m_ListPositionLabel.SetOrigin(GetWidth()/2-20,36); m_ListPositionLabel.SetSize(40,8); m_ListPositionLabel.SetFontFaceName(_T("Small Fonts")); m_ListPositionLabel.SetFontPointSize(5); m_ListPositionLabel.SetText(_T("-/-")); AddObject(&m_ListPositionLabel); AddObject(&m_Playlist); SetButtonBitmap(0,IDB_BACK); SetButtonBitmap(1,IDB_PLAYPAUSE); SetButtonBitmap(2,IDB_UP); SetButtonBitmap(3,IDB_DOWN); m_updateTimer.Start(); return true; }
//************************************************************************ // Initializes the screen //************************************************************************ bool CContactlistScreen::Initialize() { if(!CScreen::Initialize()) return false; m_ContactList.Initialize(); m_ContactList.SetOrigin(0, 0); m_ContactList.SetSize(GetWidth()-5, GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0)); m_ContactList.SetFont(CConfig::GetFont(FONT_CLIST)); m_ContactList.SetDrawTreeLines(CConfig::GetBoolSetting(CLIST_DRAWLINES)); m_ContactList.SetColumns(CConfig::GetBoolSetting(CLIST_COLUMNS)?2:1); AddObject(&m_ContactList); m_Scrollbar.Initialize(); m_Scrollbar.SetOrigin(GetWidth()-4,0); m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0)); m_ContactList.SetScrollbar(&m_Scrollbar); AddObject(&m_Scrollbar); SetButtonBitmap(0,IDB_UP); SetButtonBitmap(1,IDB_DOWN); SetButtonBitmap(2,IDB_HISTORY); SetButtonBitmap(3,IDB_CHAT); return true; }
//************************************************************************ // Initializes the screen //************************************************************************ bool CChatScreen::Initialize() { if(!CScreen::Initialize()) return false; m_InfoText.Initialize(); m_UserName.Initialize(); m_UserStatus.Initialize(); m_UserProto.Initialize(); m_Input.Initialize(); m_TextLog.Initialize(); m_Scrollbar.Initialize(); UpdateObjects(); // other attributes m_InfoText.SetAlignment(DT_CENTER); m_InfoText.SetWordWrap(TRUE); m_InfoText.SetText(_T("")); m_InfoText.Show(0); m_UserName.SetAlignment(DT_CENTER); m_UserName.SetWordWrap(TRUE); m_UserName.SetText(_T("Proto")); m_UserStatus.SetAlignment(DT_LEFT); m_UserStatus.SetWordWrap(TRUE); m_UserStatus.SetText(_T("Status")); m_UserProto.SetAlignment(DT_RIGHT); m_UserProto.SetWordWrap(TRUE); m_UserProto.SetText(_T("User")); m_Input.Show(0); m_TextLog.Show(1); m_TextLog.SetScrollbar(&m_Scrollbar); AddObject(&m_Scrollbar); AddObject(&m_TextLog); AddObject(&m_Input); AddObject(&m_InfoText); AddObject(&m_UserName); AddObject(&m_UserStatus); AddObject(&m_UserProto); SetButtonBitmap(0,IDB_UP); SetButtonBitmap(1,IDB_DOWN); SetButtonBitmap(2,IDB_HISTORY); SetButtonBitmap(3,IDB_REPLY); return true; }
//************************************************************************ // sends the message //************************************************************************ void CChatScreen::SendCurrentMessage() { if(m_Input.GetText().empty()) { DeactivateMessageMode(); return; } ASSERT(m_eReplyState == REPLY_STATE_INPUT); m_eReplyState = REPLY_STATE_SENDING; m_Input.DeactivateInput(); m_InfoText.SetText(CAppletManager::TranslateString(_T("Sending message..."))); m_InfoText.Show(1); m_Input.Show(0); m_hMessage = CAppletManager::SendMessageToContact(m_hContact,m_Input.GetText()); if(m_hMessage == NULL) { DeactivateMessageMode(); return; } SetButtonBitmap(2,NULL); SetButtonBitmap(3,NULL); }
//************************************************************************ // Initializes the screen //************************************************************************ bool CNotificationScreen::Initialize() { if(!CScreen::Initialize()) return false; m_EventText.Initialize(); m_MessageText.Initialize(); m_TitleText.Initialize(); m_Scrollbar.Initialize(); m_Timestamp.Initialize(); m_Timestamp.SetAlignment(DT_RIGHT); m_TitleText.SetText(_T("Trillian")); m_TitleText.SetAlignment(DT_LEFT); m_EventText.SetAlignment(DT_CENTER); m_EventText.SetWordWrap(TRUE); m_MessageText.SetScrollbar(&m_Scrollbar); UpdateObjects(); AddObject(&m_Scrollbar); AddObject(&m_EventText); AddObject(&m_MessageText); AddObject(&m_TitleText); AddObject(&m_Timestamp); SetButtonBitmap(0,IDB_UP); SetButtonBitmap(1,IDB_DOWN); return true; }
//************************************************************************ // Initializes the screen //************************************************************************ bool CEventScreen::Initialize() { if(!CScreen::Initialize()) return false; m_EventLog.Initialize(); m_EventLog.SetOrigin(0,0); m_EventLog.SetSize(GetWidth()-5,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?6:0)); m_EventLog.SetFont(CConfig::GetFont(FONT_LOG)); AddObject(&m_EventLog); m_Scrollbar.Initialize(); m_Scrollbar.SetOrigin(GetWidth()-4,0); m_Scrollbar.SetSize(4,GetHeight()-(CConfig::GetBoolSetting(SHOW_LABELS)?5:0)); m_EventLog.SetScrollbar(&m_Scrollbar); AddObject(&m_Scrollbar); SetButtonBitmap(0,IDB_UP); SetButtonBitmap(1,IDB_DOWN); SetButtonBitmap(2,IDB_CLIST); SetButtonBitmap(3,NULL); return true; }
//************************************************************************ // Updates the 4th softkey label //************************************************************************ void CEventScreen::UpdateChatButton() { CListEntry<CEventLogEntry*> *pItem = m_EventLog.GetSelectedEntry(); if(!pItem || pItem->GetType() != ITEM) return; CEventLogEntry *pEntry = ((CListItem<CEventLogEntry*>*)pItem)->GetItemData(); if(pEntry->hContact) SetButtonBitmap(3,IDB_CHAT); else SetButtonBitmap(3,NULL); }
//************************************************************************ // invalidates the message mode //************************************************************************ void CChatScreen::InvalidateMessageMode(tstring strError) { m_eReplyState = REPLY_STATE_FAILED; m_InfoText.SetText(strError); SetButtonBitmap(2,IDB_BACK); SetButtonBitmap(3,IDB_SEND); if(IsMaximized()) Minimize(); }
//************************************************************************ // updates the use softkey label //************************************************************************ void CContactlistScreen::UpdateUseSoftkeyLabel() { CListEntry<CContactData*,CContactListGroup*> *pEntry = m_ContactList.GetSelectedEntry(); if(!pEntry) return; if(pEntry->GetType() == CONTAINER) { if(((CListContainer<CContactData*,CContactListGroup*>*)pEntry)->IsOpen()) SetButtonBitmap(3,IDB_MINUS); else SetButtonBitmap(3,IDB_PLUS); } else { SetButtonBitmap(3,IDB_CHAT); } }
//************************************************************************ // Called when an event is received //************************************************************************ void CNotificationScreen::OnEventReceived(CEvent *pEvent) { // check wether this events needs notification if(!pEvent->bNotification) return; CNotificationEntry *pEntry = new CNotificationEntry(); pEntry->eType = pEvent->eType; pEntry->strTitle = pEvent->strSummary; if(pEvent->eType == EVENT_MSG_RECEIVED || (pEvent->eType == EVENT_IRC_RECEIVED && (pEvent->iValue == GC_EVENT_MESSAGE || pEvent->iValue == GC_EVENT_NOTICE))) { pEntry->bMessage = true; tstring strUser = CAppletManager::GetContactDisplayname(pEvent->hContact); if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO) pEntry->strText = pEvent->strValue; else pEntry->strText = strUser + (pEvent->eType == EVENT_IRC_RECEIVED?_T(" - "):_T(": "))+ pEvent->strValue; } else { pEntry->bMessage = false; if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO && pEvent->eType == EVENT_IRC_RECEIVED ) pEntry->strText = pEvent->strValue; else pEntry->strText = pEvent->strDescription; } pEntry->hContact = pEvent->hContact; pEntry->Time = pEvent->Time; if(m_pEntry) { m_LNotifications.push_back(pEntry); SetButtonBitmap(2,IDB_NEXT); } else { DisplayNotification(pEntry); SetButtonBitmap(2,NULL); } }
//************************************************************************ // deactivates the input mode //************************************************************************ void CChatScreen::DeactivateMessageMode() { m_Input.Reset(); m_Input.SetScrollbar(NULL); m_TextLog.SetScrollbar(&m_Scrollbar); m_TextLog.Show(1); m_InfoText.Show(0); m_Input.Show(0); m_Input.DeactivateInput(); m_eReplyState = REPLY_STATE_NONE; SetButtonBitmap(2,IDB_HISTORY); SetButtonBitmap(3,IDB_REPLY); if(IsMaximized()) Minimize(); }
//************************************************************************ // Called when an event is received //************************************************************************ void CNotificationScreen::OnEventReceived(CEvent *pEvent) { // check wether this events needs notification if(!pEvent->bNotification) return; CNotificationEntry *pEntry = new CNotificationEntry(); if(pEvent->eType == EVENT_MSG_RECEIVED) { pEntry->bMessage = true; //tstring strUser = toTstring((char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pEvent->hContact, NULL)); //if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_INFO) // pEntry->strText = pEvent->strValue; //else pEntry->strText = pEvent->pContact->strDisplayName + _T(": ") + pEvent->strValue; } else { pEntry->bMessage = false; pEntry->strText = pEvent->strDescription; } pEntry->strSection = pEvent->strSection; pEntry->Time = pEvent->Time; pEntry->pContact = pEvent->pContact; pEntry->iConnectionID = pEvent->iConnectionID; pEntry->eType = pEvent->eType; if(m_pEntry) { m_LNotifications.push_back(pEntry); SetButtonBitmap(2,IDB_NEXT); } else { DisplayNotification(pEntry); SetButtonBitmap(2,NULL); } }
//************************************************************************ // Called when an LCD-button is pressed //************************************************************************ void CNotificationScreen::OnLCDButtonDown(int iButton) { CScreen::OnLCDButtonDown(iButton); if(m_MessageText.IsVisible() && ( iButton <= 1 || iButton >=4)) { if(iButton== 1 || iButton == 5) m_MessageText.ScrollDown(); else m_MessageText.ScrollUp(); SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000); } else if(iButton == 2 && m_LNotifications.size() >= 1) { CNotificationEntry *pEntry = *(m_LNotifications.begin()); m_LNotifications.pop_front(); if(m_LNotifications.size() >= 1) SetButtonBitmap(2,IDB_NEXT); else SetButtonBitmap(2,NULL); DisplayNotification(pEntry); SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000); } else if(iButton == 3 && m_pEntry && m_pEntry->pContact) { SetExpiration(0); CLCDConnection *pLCDCon = CAppletManager::GetInstance()->GetLCDConnection(); pLCDCon->SetAsForeground(1); pLCDCon->SetAsForeground(0); CAppletManager::GetInstance()->ActivateChatScreen(m_pEntry->pContact,m_pEntry->iConnectionID); } else SetExpiration(0); }
//************************************************************************ // activates the input mode //************************************************************************ void CChatScreen::ActivateMessageMode() { m_InfoText.Show(0); m_TextLog.Show(0); m_TextLog.SetScrollbar(NULL); m_Input.SetScrollbar(&m_Scrollbar); if(m_eReplyState != REPLY_STATE_FAILED) m_Input.Reset(); m_Input.Show(1); m_Input.ActivateInput(); m_eReplyState = REPLY_STATE_INPUT; SetButtonBitmap(2,IDB_BACK); SetButtonBitmap(3,IDB_SEND); if(CConfig::GetBoolSetting(SESSION_REPLY_MAXIMIZED)) Maximize(); else Minimize(); }
//************************************************************************ // Called when an LCD-button is pressed //************************************************************************ void CNotificationScreen::OnLCDButtonDown(int iButton) { CScreen::OnLCDButtonDown(iButton); if((iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_RIGHT) && m_LNotifications.size() >= 1) { CNotificationEntry *pEntry = *(m_LNotifications.begin()); m_LNotifications.pop_front(); if(m_LNotifications.size() >= 1) SetButtonBitmap(2,IDB_NEXT); else SetButtonBitmap(2,NULL); DisplayNotification(pEntry); SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000); } else if((iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) && m_pEntry && m_pEntry->hContact) { SetExpiration(0); CLCDConnection *pLCDCon = CAppletManager::GetInstance()->GetLCDConnection(); pLCDCon->SetAsForeground(1); pLCDCon->SetAsForeground(0); CAppletManager::GetInstance()->ActivateChatScreen(m_pEntry->hContact); } else if(!m_MessageText.IsVisible()) { SetExpiration(0); } else { if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) { m_MessageText.ScrollDown(); } else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) { m_MessageText.ScrollUp(); } SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000); } }
//************************************************************************ // displays the specified notification //************************************************************************ void CNotificationScreen::DisplayNotification(CNotificationEntry *pEntry) { if(m_pEntry) delete m_pEntry; m_pEntry = pEntry; tstring strTime = CAppletManager::GetFormattedTimestamp(&pEntry->Time); if(CConfig::GetIntSetting(NOTIFY_TITLE) == NOTIFY_TITLE_NAME) { if(CConfig::GetBoolSetting(NOTIFY_SECTION)) m_TitleText.SetText(_T(" Trillian: ") + (pEntry->strSection.empty()?_T("My Contacts"):pEntry->strSection)); else m_TitleText.SetText(_T(" Trillian")); } if(CConfig::GetBoolSetting(NOTIFY_TIMESTAMPS)) m_Timestamp.SetText(strTime); else m_Timestamp.SetText(_T("")); if(pEntry->pContact) SetButtonBitmap(3,IDB_CHAT); else SetButtonBitmap(3,NULL); if(pEntry->bMessage) { SetButtonBitmap(0,IDB_UP); SetButtonBitmap(1,IDB_DOWN); m_Scrollbar.Show(1); m_MessageText.Show(1); m_EventText.Show(0); m_MessageText.SetText(pEntry->strText.c_str()); } else { SetButtonBitmap(0,NULL); SetButtonBitmap(1,NULL); m_Scrollbar.Show(0); m_MessageText.Show(0); m_EventText.Show(1); m_EventText.SetText(pEntry->strText.c_str()); } }
void MyGameTreeCtrl::LoadSkin() { while(m_ImageList.GetImageCount() > 0) { m_ImageList.Remove(0); } for(vector<CBitmap*>::iterator iter=m_vecBitmap.begin(); iter!=m_vecBitmap.end(); iter++) { (*iter)->DeleteObject(); delete (*iter); } m_vecBitmap.clear(); m_mapBitmap2Index.clear(); CDC* pDC = GetDC(); ISkinMgr* pSkinMgr = AfxGetUIManager()->UIGetSkinMgr(); SetScrollBitmap(pSkinMgr->GetDibBmp("ScrollVert"), pSkinMgr->GetDibBmp("ScrollHorz")); CDibBitmap* pDibBitmap = pSkinMgr->GetDibBmp( "IconTreeNodeCategory" ); CBitmap* pBitmap1 = new CBitmap(); pBitmap1->Attach( pDibBitmap->CreateBitmap( pDC ) ); m_vecBitmap.push_back( pBitmap1); m_ImageList.Add( pBitmap1 ,RGB(0,0,0)); m_mapBitmap2Index["IconTreeNodeCategory"] = 0; SetImageList( &m_ImageList,TVSIL_NORMAL ); SetButtonBitmap( pSkinMgr->GetDibBmp("QQTreeBtnSCNormal"),pSkinMgr->GetDibBmp("QQTreeBtnSCOver"),pSkinMgr->GetDibBmp("QQTreeBtnSCDown") ); ReleaseDC(pDC); m_colorNormalItemText = pSkinMgr->GetColor("QQTreeNorText"); m_colorSelectItemBK = pSkinMgr->GetColor("QQTreeSelBk"); m_colorSelectItemText = pSkinMgr->GetColor("QQTreeSelText"); SetBackColor( pSkinMgr->GetColor("QQTreeBk")); }