⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolbarview.cpp

📁 离线的RSS阅读器
💻 CPP
字号:
// ToolBarView.cpp : implementation file
//

#include "stdafx.h"
#include "DiamondReader.h"
#include "ToolBarView.h"
#include "global.h"
#include "MainFrm.h"
#include "ItemListView.h"

extern char* gszFile;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CToolBarView

IMPLEMENT_DYNCREATE(CToolBarView, CFormView)

CToolBarView::CToolBarView()
	: CFormView(CToolBarView::IDD)
{
	//{{AFX_DATA_INIT(CToolBarView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	TCHAR path[255];
	int length = 255;
	getImageDir(path,length);
	strcat(path,"新建频道.bmp");
	this->m_newChannel = new CImageTextButton(path,"新建频道");
	path[length]='\0';
	strcat(path,"新建分组.bmp");
	this->m_newCategory = new CImageTextButton(path,"新建分组");
	path[length]='\0';
	strcat(path,"更新.bmp");
	this->m_updateAll = new CImageTextButton(path,"全部更新");
	path[length]='\0';
	strcat(path,"查找.bmp");
	this->m_seach = new CImageTextButton(path,"查找全部");
	this->m_searchKey = new CMyEdit;
}

CToolBarView::~CToolBarView()
{
	delete m_newCategory;
	delete m_newChannel;
	delete m_seach;
	delete m_searchKey;
	delete m_updateAll;
}

void CToolBarView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CToolBarView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CToolBarView, CFormView)
	//{{AFX_MSG_MAP(CToolBarView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_WM_ERASEBKGND()
	ON_COMMAND(ID_CHANNEL_NEW,newChannel)
	ON_COMMAND(ID_CATEGORY_NEW,newCategory)
	ON_COMMAND(ID_RSS_UPDATE,updateAll)
	ON_COMMAND(ID_RSS_SEARCH,search)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolBarView diagnostics

#ifdef _DEBUG
void CToolBarView::AssertValid() const
{
	CFormView::AssertValid();
}

void CToolBarView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CToolBarView message handlers

void CToolBarView::OnInitialUpdate(){
	CRect rect;
	GetClientRect(&rect);
	rect.top = 1;
	rect.bottom = 23;
	rect.left = 2;
	rect.right = 87;
	m_newChannel->Create(TEXT(""),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP|BS_OWNERDRAW,rect,this,ID_CHANNEL_NEW);
	rect.left = rect.right+1;
	rect.right+=86;
	m_newCategory->Create(TEXT(""),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP|BS_OWNERDRAW,rect,this,ID_CATEGORY_NEW);
	rect.left = rect.right+1;
	rect.right+=86;
	m_updateAll->Create(TEXT(""),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP|BS_OWNERDRAW,rect,this,ID_RSS_UPDATE);
	rect.left = rect.right+3;
	rect.right = rect.left+3;
	m_splitter.Create(TEXT(""),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,rect,this,0);
	m_splitter.EnableWindow(false);
	rect.left = rect.right+3;
	rect.right = rect.left+200;
	m_searchKey->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,rect,this,10000);
	rect.left = rect.right+1;
	rect.right = rect.left+86;
	//GetClientRect(&rect);
	m_seach->Create(TEXT(""),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP|BS_OWNERDRAW,rect,this,ID_RSS_SEARCH);

// 	m_updateAll->EnableWindow(false);
// 	m_seach->EnableWindow(false);
// 	m_newCategory->EnableWindow(false);
// 	m_newChannel->EnableWindow(false);
}

BOOL CToolBarView::OnEraseBkgnd(CDC* pDC){
	CRect   rect;   
	pDC->GetClipBox(&rect);   
	CBrush brush(RGB(222,222,222));   
	CBrush* pOldBrush=pDC->SelectObject(&brush);   
	pDC->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATCOPY);   
	pDC->Draw3dRect(&rect,RGB(255,255,255),RGB(0,0,0));
	pDC->SelectObject(pOldBrush); 
	return true;
}

void CToolBarView::newCategory(){
	CMainFrame *mainframe = (CMainFrame*)AfxGetMainWnd();
	mainframe->newRootCategory();
}

void CToolBarView::newChannel(){
	CMainFrame *mainframe = (CMainFrame*)AfxGetMainWnd();
	mainframe->OnChannelNew();
}

void CToolBarView::updateAll(){
	CMainFrame *mainframe = (CMainFrame*)AfxGetMainWnd();
	mainframe->OnUpdateALL();
}

void CToolBarView::search(){
	CMainFrame *mainframe = (CMainFrame*)AfxGetMainWnd();
	int length = m_searchKey->LineLength(0);
	char *buff = new char[length+1];
	m_searchKey->GetLine(0,buff);

	CString cs;
	m_searchKey->GetWindowText(cs);
	strcpy(buff,(LPTSTR)(LPCTSTR)cs);
	sqlite3 *db;
	sqlite3_open(gszFile,&db);
	char **szResult;
	int nrow = 0,ncol = 0;

	ItemList *result = new ItemList;
	result->nextItem = NULL;
	sqlite3_get_table(db,"select * from ItemList",&szResult,&nrow,&ncol,NULL);
	for (int i=1;i<nrow;i++)
	{
		if (strstr(*(szResult+ncol*i+6),buff))
		{
			ItemList *temp = new ItemList(*(szResult+ncol*i+7),*(szResult+ncol*i+6),*(szResult+ncol*(i)),*(szResult+ncol*(i)+2),*(szResult+ncol*i+5),atoi(*((szResult+ncol*i)+4)),atoi(*((szResult+ncol*i)+3)));
			temp->nextItem = result->nextItem;
			result->nextItem = temp;
		}
	}
	sqlite3_free_table(szResult);
	CItemListView *view = (CItemListView*)mainframe->m_spli2.GetPane(0,0);
	view->showChannel(result->nextItem);
	delete result;

	
}

void CToolBarView::disableButton(int type){
// 	if (type==0)
// 	{
// 		m_updateAll->EnableWindow();
// 		m_seach->EnableWindow();
// 		m_newCategory->EnableWindow();
// 		m_newChannel->EnableWindow();
// 		
// 	}
// 	else if (type==1)
// 	{
// 		m_updateAll->EnableWindow();
// 		m_seach->EnableWindow();
// 		m_newCategory->EnableWindow(false);
// 		m_newChannel->EnableWindow(false);
// 	}
// 	else if (type==2)
// 	{
// 		m_updateAll->EnableWindow(false);
// 		m_seach->EnableWindow(false);
// 		m_newCategory->EnableWindow(false);
// 		m_newChannel->EnableWindow(false);
// 	}
}

void CToolBarView::enableButton(int id,bool enable /* = false */){
	CImageTextButton *buttons[] = {this->m_newCategory,this->m_newChannel,this->m_updateAll,this->m_seach};
	buttons[id]->EnableWindow(enable);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -