?? articleview.cpp.svn-base
字號:
if (::GetSubMenu(hParentMenu, nIndex) == pMenu->m_hMenu) {
// when popup is found, m_pParentMenu is containing menu
state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
break;
}
}
}
}
state.m_nIndexMax = pMenu->GetMenuItemCount();
for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax; state.m_nIndex++) {
state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
if (state.m_nID == 0)
continue; // menu separator or invalid cmd - ignore it
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pMenu != NULL);
if (pMenu->GetSubMenu(state.m_nIndex) != NULL) {
// possibly a popup menu, route to first item of that popup
state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // first item of popup can't be routed to
}
state.DoUpdate(this, FALSE); // popups are never auto disabled
}
else {
// normal menu item
// Auto enable/disable if frame window has 'm_bAutoMenuEnable'
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, TRUE);
}
// adjust for menu deletions and additions
UINT nCount = pMenu->GetMenuItemCount();
if (nCount < state.m_nIndexMax) {
state.m_nIndex -= (state.m_nIndexMax - nCount);
while (state.m_nIndex < nCount &&
pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
{
state.m_nIndex++;
}
}
state.m_nIndexMax = nCount;
}
}
void CArticleView::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) {
if (InFullScreen)
ToFullScreenMode();
else
ToNormalMode();
}
// commands
void CArticleView::OnItemNext() {
LOG0(1, "CArticleView::OnItemNext()");
if (View == NULL) return;
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
if (View->SiteItem != NULL && View->SiteItem->Type == CSiteItem::VFolder) {
CWaitCursor wait;
int oldIdx = View->GetSelectedItem();
int idx = View->GetSelectedItem();
BOOL found = FALSE;
while (!found) {
if (idx < View->GetItemCount() - 1) idx++;
else if (Config.WrapAround) idx = 0;
else idx = oldIdx;
// we are back on the original site
if (idx == oldIdx) {
frame->NoNewMessage();
break;
}
// check
if (View->SiteItem->FlagMask == MESSAGE_READ_STATE) {
CFeedItem *fi = View->GetItem(idx);
if (!fi->IsDeleted() && (fi->IsNew() || fi->IsUnread()))
found = TRUE;
}
else
found = TRUE;
}
if (found) {
View->OpenItem(idx);
View->EnsureVisible(idx);
frame->m_wndBanner.Invalidate();
}
}
else {
CWaitCursor wait;
int oldIdx = View->GetSelectedItem();
int oldSite = Config.ActSiteIdx;
int site = Config.ActSiteIdx;
int idx = View->GetSelectedItem();
BOOL found = FALSE;
while (!found) {
if (idx < View->GetItemCount() - 1) {
idx++;
if (site == oldSite) {
// we are back on the original item
if (idx == oldIdx) break;
}
}
else {
int t = site;
site = View->MoveToNextChannel();
if (t == site) break;
else idx = 0;
}
// check
if (View->GetItemCount() > 0) {
if (Config.MoveToUnread) {
CFeedItem *fi = View->GetItem(idx);
if (!fi->IsDeleted() && (fi->IsNew() || fi->IsUnread()))
found = TRUE;
}
else
found = TRUE;
}
}
if (found) {
View->OpenItem(idx);
View->EnsureVisible(idx);
frame->m_wndBanner.Invalidate();
if (oldSite != site) frame->AddSiteToSave(oldSite);
// TODO: preload the site with unread items if reading only unread
frame->PreloadSite(site);
}
else {
// get back to original site and item
frame->SelectSite(oldSite);
if (View->GetItemCount() > 0) {
View->SetSelectedItem(oldIdx);
View->EnsureVisible(oldIdx);
}
frame->NoNewMessage();
}
}
}
void CArticleView::OnItemPrev() {
LOG0(1, "CArticleView::OnItemPrev()");
if (View == NULL) return;
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
if (View->SiteItem != NULL && View->SiteItem->Type == CSiteItem::VFolder) {
CWaitCursor wait;
int oldIdx = View->GetSelectedItem();
int idx = View->GetSelectedItem();
BOOL found = FALSE;
while (!found) {
if (idx > 0) idx--;
else if (Config.WrapAround) idx = View->GetItemCount() - 1;
else idx = oldIdx;
// we are back on the original site
if (idx == oldIdx) {
frame->NoNewMessage();
break;
}
// check
if (View->SiteItem->FlagMask == MESSAGE_READ_STATE) {
CFeedItem *fi = View->GetItem(idx);
if (!fi->IsDeleted() && (fi->IsNew() || fi->IsUnread()))
found = TRUE;
}
else
found = TRUE;
}
if (found) {
View->OpenItem(idx);
View->EnsureVisible(idx);
frame->m_wndBanner.Invalidate();
}
}
else {
CWaitCursor wait;
int oldIdx = View->GetSelectedItem();
int oldSite = Config.ActSiteIdx;
int site = Config.ActSiteIdx;
int idx = View->GetSelectedItem();
BOOL found = FALSE;
while (!found) {
if (idx > 0) {
idx--;
if (site == oldSite) {
// we are back on the original site
if (idx == oldIdx) break;
}
}
else {
int t = site;
site = View->MoveToPrevChannel();
if (t == site) break;
else idx = View->GetItemCount() - 1;
}
// check
if (View->GetItemCount() > 0) {
if (Config.MoveToUnread) {
CFeedItem *fi = View->GetItem(idx);
if (!fi->IsDeleted() && (fi->IsNew() || fi->IsUnread()))
found = TRUE;
}
else
found = TRUE;
}
}
if (found) {
View->OpenItem(idx);
View->EnsureVisible(idx);
frame->m_wndBanner.Invalidate();
if (oldSite != site) frame->AddSiteToSave(oldSite);
// TODO: preload the site with unread items if reading only unread
frame->PreloadSite(site);
}
else {
// get back to original site and item
frame->SelectSite(oldSite);
if (View->GetItemCount() > 0) {
View->SetSelectedItem(oldIdx);
View->EnsureVisible(oldIdx);
}
frame->NoNewMessage();
}
}
}
void CArticleView::OnItemFlag() {
LOG0(1, "CArticleView::OnItemFlag()");
if (View != NULL) {
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
int selItem = View->GetSelectedItem();
if (m_pArticle->IsFlagged()) {
View->UnflagItem(selItem);
m_pArticle->SetFlags(0, MESSAGE_FLAG);
frame->m_wndBanner.SetFlagged(-1);
}
else {
View->FlagItem(selItem);
m_pArticle->SetFlags(MESSAGE_FLAG, MESSAGE_FLAG);
frame->m_wndBanner.SetFlagged(FLAG_ICON);
}
frame->m_wndBanner.Invalidate();
}
}
void CArticleView::OnUpdateItemFlag(CCmdUI *pCmdUI) {
LOG0(5, "CArticleView::OnUpdateItemFlag()");
pCmdUI->SetCheck(m_pArticle->IsFlagged());
}
void CArticleView::OnRefresh() {
LOG0(3, "CArticleView::OnRefresh()");
ShowArticle();
}
void CArticleView::OnItemOpen() {
LOG0(1, "CArticleView::OnItemOpen()");
ToNormalMode();
if (m_strContextMnuUrl.IsEmpty()) OpenOnlineMessage(m_pArticle->Link, m_pArticle->SiteItem);
else OpenOnlineMessage(m_strContextMnuUrl, m_pArticle->SiteItem);
}
void CArticleView::OnEnclosureOpen() {
LOG0(1, "CArticleView::OnEnclosureOpen()");
if (m_pArticle != NULL && m_pArticle->HasEnclosure()) {
CEnclosureItem *ei = m_pArticle->Enclosures.GetHead();
ToNormalMode();
OpenEnclosure(ei->URL);
}
}
void CArticleView::OnUpdateEnclosureOpen(CCmdUI *pCmdUI) {
LOG0(5, "CArticleView::OnUpdateEnclosureOpen()");
pCmdUI->Enable(m_pArticle->HasEnclosure());
}
void CArticleView::OnEnclosureGet() {
LOG0(1, "CArticleView::OnEnclosureOpen()");
CArray<CFeedItem *, CFeedItem *> items;
items.Add(m_pArticle);
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
frame->m_wndUpdateBar.EnqueueEnclosures(items);
frame->m_wndUpdateBar.Redraw();
frame->m_wndUpdateBar.Start();
}
void CArticleView::OnUpdateEnclosureGet(CCmdUI *pCmdUI) {
if (m_pArticle != NULL && m_pArticle->HasEnclosure()) {
CEnclosureItem *ei = m_pArticle->Enclosures.GetHead();
pCmdUI->Enable(!IsEnclosureCached(ei->URL));
}
else
pCmdUI->Enable(FALSE);
}
void CArticleView::OnEnclosureDelete() {
LOG0(1, "CArticleView::OnEnclosureOpen()");
CArray<CFeedItem *, CFeedItem *> items;
items.Add(m_pArticle);
ClearEnclosures(items);
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
frame->SetupEnclosureBar(m_pArticle);
}
void CArticleView::OnUpdateEnclosureDelete(CCmdUI *pCmdUI) {
if (m_pArticle->HasEnclosure()) {
CEnclosureItem *ei = m_pArticle->Enclosures.GetHead();
pCmdUI->Enable(IsEnclosureCached(ei->URL));
}
else
pCmdUI->Enable(FALSE);
}
void CArticleView::OnCopyUrl() {
LOG0(1, "CArticleView::OnCopyUrl()");
CString link;
if (m_strContextMnuUrl.IsEmpty() && m_pArticle != NULL) link = m_pArticle->Link;
else link = m_strContextMnuUrl;
CopyTextToClipboard(GetSafeHwnd(), link);
}
void CArticleView::OnCopy() {
LOG0(1, "CArticleView::OnCopy()");
LPSTREAM stream = 0; // give us the output stream here
DWORD rsd = 0; // required, can be checked with SUCCEEDED?...
CopySelectionToNewIStream(&rsd, &stream);
if (stream) {
// got it
STATSTG stat = { 0 };
stream->Stat(&stat, 0); // probably check for the S_OK code...
if (LPBYTE buf = (LPBYTE) LocalAlloc(LHND, (UINT) stat.cbSize.QuadPart + 2)) {
ULONG ulNumChars;
// read whole
if (SUCCEEDED(stream->Read(buf, (ULONG) stat.cbSize.QuadPart, &ulNumChars)) &&
ulNumChars == stat.cbSize.QuadPart)
{
CString strSelectedText((LPCWSTR) buf); // our text here!
CopyTextToClipboard(GetSafeHwnd(), strSelectedText);
}
LocalFree(buf);
}
stream->Release();
}
}
void CArticleView::OnUpdateCopy(CCmdUI *pCmdUI) {
BOOL isTextSelected = (BOOL) IsSelection();
pCmdUI->Enable(isTextSelected);
}
void CArticleView::OnLinkOpen() {
LOG0(1, "CArticleView::OnLinkOpen()");
ToNormalMode();
OpenOnlineMessage(m_strContextMnuUrl, m_pArticle->SiteItem);
}
void CArticleView::OnLinkDownload() {
LOG0(1, "CArticleView::OnLinkDownload()");
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
frame->m_wndUpdateBar.EnqueueItem(m_strContextMnuUrl, FILE_TYPE_HTML);
frame->m_wndUpdateBar.Redraw();
frame->m_wndUpdateBar.Start();
}
void CArticleView::OnBookmarkLink(UINT nID) {
ToNormalMode();
// link to bookmark
CString link;
if (m_strContextMnuUrl.IsEmpty() && m_pArticle != NULL) link = m_pArticle->Link;
else link = m_strContextMnuUrl;
int idx = nID - ID_SOCIAL_BOOKMARK_BASE;
CSocialBookmarkSite *sbs = Config.SocialBookmarkSites[idx];
CString url = sbs->Url;
if (url.Replace(_T("[%URL%]"), UrlEncode(link)) != 1) {
Error(IDS_BAD_URL_FMT_SBS);
return;
}
// if the [%TITLE%] is not present, this will do nothing, which is ok
if (m_strContextMenuLinkName.GetLength() > 0)
url.Replace(_T("[%TITLE%]"), UrlEncode(m_pArticle->Title + _T(" - ") + m_strContextMenuLinkName));
else
url.Replace(_T("[%TITLE%]"), UrlEncode(m_pArticle->Title));
// open browser
OpenUrlExt(url);
m_strContextMenuLinkName.Empty();
}
void CArticleView::OnViewImage() {
CString fileName = GetCacheFile(FILE_TYPE_IMAGE, Config.CacheLocation, m_strContextMnuUrl);
if (FileExists(fileName)) ShellOpenFile(fileName); // file is cached -> open it with a local program
else OpenUrlExt(m_strContextMnuUrl); // file not cached -> use web browser to open it
}
void CArticleView::OnCopyImageLocation() {
CopyTextToClipboard(GetSafeHwnd(), m_strContextMnuUrl);
}
void CArticleView::OnSendByEmail() {
ToNormalMode();
CString link;
if (m_strContextMnuUrl.IsEmpty() && m_pArticle != NULL) link = m_pArticle->Link;
else link = m_strContextMnuUrl;
SendByEmail(link);
}
void CArticleView::ToFullScreenMode() {
if (!InFullScreen) {
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
HWND hWnd = frame->GetSafeHwnd();
SHSipPreference(hWnd, SIP_FORCEDOWN); // hide SIP
SetForegroundWindow();
SHFullScreen(hWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
::ShowWindow(frame->m_hwndCmdBar, SW_HIDE);
HDC hDC = ::GetDC(hWnd);
::MoveWindow(hWnd, 0, 0, GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES), TRUE);
::ReleaseDC(hWnd, hDC);
InFullScreen = TRUE;
}
}
void CArticleView::ToNormalMode() {
if (InFullScreen) {
CMainFrame *frame = (CMainFrame *) AfxGetMainWnd();
HWND hWnd = frame->GetSafeHwnd();
SHFullScreen(hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
::ShowWindow(frame->m_hwndCmdBar, SW_SHOW);
#define MENU_HEIGHT 26
RECT rc;
::GetWindowRect(hWnd, &rc);
::MoveWindow(hWnd, rc.left, rc.top + SCALEY(MENU_HEIGHT), rc.right, rc.bottom - (2 * SCALEY(MENU_HEIGHT)), TRUE);
InFullScreen = FALSE;
}
}
void CArticleView::OnFullscreen() {
if (InFullScreen) ToNormalMode();
else ToFullScreenMode();
}
void CArticleView::OnUpdateFullscreen(CCmdUI *pCmdUI) {
pCmdUI->SetCheck(InFullScreen);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -