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

📄 mdi.cpp

📁 理财小工具
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	wxDateTime curdate=wxDateTime::Today() - wxDateSpan::Months(4);	for (int i=0; i<5; i++)	{		wxDouble monthtotal=0;		MoneytypeCountList tmplist;		moneybook->GetMonthTotalCnt(root, &monthtotal,curdate,&tmplist);		MonthDataElem *pelem = new MonthDataElem(monthtotal,curdate);		for (MoneytypeCountList::Node *node=tmplist.GetFirst(); node;node=node->GetNext())		{			MoneytypeCountNode *cur = node->GetData();			int xmlnodeindex=-1;			for (MyXmlNodeList::Node *xmlnode=globelist.GetFirst(); xmlnode;xmlnode=xmlnode->GetNext())			{				xmlnodeGNode*curxml = xmlnode->GetData();				if (curxml->xmlNode == cur->moneytype)				{					xmlnodeindex = globelist.IndexOf(curxml);					break;				}			}			if (xmlnodeindex==-1)			{				xmlnodeGNode*tmpnode = new xmlnodeGNode(cur->moneytype);				globelist.Append(tmpnode);				xmlnodeindex=globelist.IndexOf(tmpnode);						wxString *tempwxstr = frame->moneybook->GetFolderDesc(cur->moneytype);				subframe->canvas->mycolors.Append(new ColourDescElem(gColorBrush[xmlnodeindex % MAX_COLOR_BRUSH_COUNT],tempwxstr->mb_str()));				delete(tempwxstr);			}			pelem->children.Append(new childvalueElem(cur->acount,xmlnodeindex));					}		tmplist.DeleteContents(TRUE);		monthtotal=0;		subframe->canvas->valuelist.Append(pelem);		curdate+=wxDateSpan::Month();	}	globelist.DeleteContents(TRUE);	strcpy(subframe->canvas->title,title);	    subframe->Show(TRUE);	}void MyFrame::OnCalcHouseFee(wxCommandEvent& WXUNUSED(event)){	wxDouble totalcnt,monthrate;	long terms,paymothed;	wxDateTime startdate;	MyCalcHouseFeeDialog dlg(this);	if (frame->moneybook->GetHousePay(&totalcnt, &monthrate, &terms, &startdate,&paymothed))	{		dlg.SetValue(totalcnt,monthrate,terms,paymothed);	}    dlg.ShowModal();		}void MyStatusBar::OnDbClick(wxMouseEvent& event){	wxRect tmprect;	if (GetFieldsCount() == 4)	{		if (GetFieldRect(3,tmprect))		{			if (tmprect.Inside(event.m_x,event.m_y))			{				wxString outp;								wxDouble lastMonthIn=0,lastMonthOut=0;				frame->moneybook->GetMonthTotalCnt(frame->moneybook->InComingNode, &lastMonthIn, wxDateTime::Today()-wxDateSpan::Month());				outp.append(wxString::Format(_("lastMonthIn: %.2f "),lastMonthIn));				frame->moneybook->GetMonthTotalCnt(frame->moneybook->OutGoingNode, &lastMonthOut, wxDateTime::Today()-wxDateSpan::Month());				outp.append(wxString::Format(_("lastMonthOut: %.2f "),lastMonthOut));				wxDouble  BaseAcount = frame->moneybook->GetTotalInComing() + frame->moneybook->GetBaseInComing()  - frame->moneybook->GetTotalOutGoing()					- frame->moneybook->GetBaseOutGoing();				outp.append(wxString::Format(_("BaseAcount: %.2f\n"),BaseAcount));				wxDouble TotalCnt; wxDouble MonthRate; long terms; wxDateTime startdate; long PayMethod;				frame->moneybook->GetHousePay(&TotalCnt, &MonthRate, &terms, &startdate, &PayMethod);				MonthRate /= 100;				outp.append(wxString::Format(_("Your house Total Acount:%.2f, MonthRate:%f"),TotalCnt,MonthRate));				outp.append(wxString::Format(_("start from :%s\n"),startdate.FormatISODate().c_str()));								wxDouble needpay,hascash;				int passedmonth = wxDateTime::Today().GetYear()*12+wxDateTime::Today().GetMonth()								- startdate.GetYear() * 12 - startdate.GetMonth();				wxDouble PerMonth = lastMonthIn -  lastMonthOut;				outp.append(wxString::Format(_("Last month your saved %.2f\n"),PerMonth));				int i;				if (PayMethod == 0)				{					wxDouble BaseLose = 0;					wxDouble PerMonthPay = MoneyBook::GetHouseFeeSameCountPlusTax(TotalCnt, MonthRate,terms);					outp.append(wxString::Format(_("Each month you need pay %.2f\n"),PerMonthPay));					for (i=0; i<terms+10;i++)					{						needpay = (TotalCnt - BaseLose) * (MonthRate + 1);						hascash	= BaseAcount + (i - passedmonth + 1)*PerMonth;						if (startdate + wxDateSpan::Months(i) >= wxDateTime::Today())						{							outp.append(wxString::Format(_("%s you need pay totally:%.2f you have %.2f BaseLose: %.2f\n"),								(startdate + wxDateSpan::Months(i)).FormatISODate().c_str(),needpay,hascash,BaseLose));						}						if (needpay<=hascash)						{							outp.append(wxString::Format(_("%s you can pay off your house"),(startdate + wxDateSpan::Months(i)).FormatISODate().c_str()));							break;						}						else						{							BaseLose += (PerMonthPay - ((TotalCnt - BaseLose)*MonthRate));						}					}				}				else				{					for (i=0; i<terms;i++)					{						needpay = (TotalCnt - (TotalCnt / terms) * i) * (MonthRate + 1);						hascash	= BaseAcount+ (i - passedmonth + 1)*PerMonth;						if (startdate + wxDateSpan::Months(i) >= wxDateTime::Today())						{							outp.append(wxString::Format(_("%s you need pay totally:%.2f you have %.2f\n"),								(startdate + wxDateSpan::Months(i)).FormatISODate().c_str(),needpay,hascash));						}						if (needpay<=hascash)						{							outp.append(wxString::Format(_("%s you can pay off your house"),(startdate + wxDateSpan::Months(i)).FormatISODate().c_str()));							break;						}					}				}				if (i>=terms)				{					outp.append(_("You may delay to pay off your house!"));				}							    wxMessageDialog dialog(NULL, outp,			      _("House Fee Result"), wxNO_DEFAULT|wxOK);				dialog.ShowModal();			}		}	}}void MyFrame::OnViewMonthOut(wxCommandEvent& WXUNUSED(event)){		CreateChart(moneybook->outgoingitem,_("Last 5 Month(s) Total OutGoing Chart"));	}void MyFrame::OnCreateCustomChart(wxCommandEvent& WXUNUSED(event)){;	}void MyFrame::OnCreateChart(wxCommandEvent& WXUNUSED(event)){	wxTreeItemId id=textWindow->GetSelection();	if (id.IsOk())	{				wxString tmp = wxString::Format(_("Last 5 Month(s) Total %s Chart"),textWindow->GetItemText(id).mb_str());		CreateChart(id,tmp.mb_str());		}	else	{		wxLogError("You should choose one type to create Chart!");	}}void MyFrame::OnCreateCustomBrowser(wxCommandEvent& WXUNUSED(event)){    MyCalendarDialog dlg(this);    dlg.ShowModal();	}	void MyFrame::OnCreateBrowserWin(wxCommandEvent& WXUNUSED(event)){	wxTreeItemId treeitem = textWindow->GetSelection();	if (treeitem.IsOk())	{		CreateBrowserWindow(&treeitem,FALSE);	}}	void MyFrame::OnAddMoneyType(wxCommandEvent& WXUNUSED(event)){  wxTextEntryDialog dialog(this,                           _("Money Type Add"),                           _("Please Input the Type Desc:"),                           "",                           wxOK | wxCANCEL);  if (dialog.ShowModal() == wxID_OK)  {  	wxTreeItemId id = textWindow->GetSelection();	if (id.IsOk())	{		wxString str=dialog.GetValue();		MB_ClassInInfo ClassInfo;		strcpy(ClassInfo.Desc,str);  		if (!moneybook->AddMoneyType(&id, &ClassInfo))		{			wxLogError(_("Problem when add money type!"));		}	}	else	{		wxLogError(_("You Should Choose one base Type!"));	}  }}void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){    Close();}void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ){	    (void)wxMessageBox(wxString::Format(_("wxWindows 2.0 MDI Demo %s\nAuthor: Julian Smart (c) 1997\nUsage: mdi.exe"),gVersion), _("About MDI Demo"));}void MyFrame::RecursionShowRec(xmlNodePtr pid, MyGridFrame *pFrame, bool showall, bool thismonthonly, wxDateTime thedate){	xmlNodePtr cur;	cur = xmlGetLastChild(pid);	while (cur != NULL)	{		xmlChar*nodeprop = xmlGetProp(cur, (const xmlChar*)"Type");		if (xmlStrcmp(nodeprop,(const xmlChar*)"Folder")==0)		{			RecursionShowRec(cur,pFrame,showall,thismonthonly,thedate);		}		else if (xmlStrcmp(cur->name,(const xmlChar*)"MoneyRecs")==0)		{			if (thismonthonly)			{				wxDateTime tmpdate(thedate);				xmlNodePtr thismonth = frame->moneybook->GetMonthFolder(cur, &tmpdate);				if (thismonth != NULL)				{					xmlNodePtr recnode= xmlGetLastChild(thismonth);					while (recnode!=NULL)					{						if ((pFrame->grid->GetRows()<MAX_REC_SHOW) ||(showall))						{							xmlChar *sdate,*sacount,*smemo;							sdate = xmlGetProp(recnode,(const xmlChar*)"Date");							sacount = xmlGetProp(recnode,(const xmlChar*)"Acount");							smemo = xmlNodeGetContent(recnode);							wxString *temp = new wxString(wxConvUTF8.cMB2WC((const char*)smemo),*wxConvCurrent);							pFrame->AppendRecToGrid(new xmlnodeGNode(recnode), wxString(sdate), wxString(sacount), *temp);							delete(temp);							xmlFree(sdate);							xmlFree(sacount);							xmlFree(smemo);						}						else						{							return;						}						recnode = recnode->prev;					}				}			}			else			{				xmlNodePtr monthnode = xmlGetLastChild(cur);				while (monthnode != NULL)				{					xmlNodePtr recnode= xmlGetLastChild(monthnode);					while (recnode!=NULL)					{						if ((pFrame->grid->GetRows()<MAX_REC_SHOW) ||(showall))						{							xmlChar *sdate,*sacount,*smemo;							sdate = xmlGetProp(recnode,(const xmlChar*)"Date");							sacount = xmlGetProp(recnode,(const xmlChar*)"Acount");							smemo = xmlNodeGetContent(recnode);							wxString *temp = new wxString(wxConvUTF8.cMB2WC((const char*)smemo),*wxConvCurrent);							pFrame->AppendRecToGrid(new xmlnodeGNode(recnode), wxString(sdate), wxString(sacount), *temp);							delete(temp);							xmlFree(sdate);							xmlFree(sacount);							xmlFree(smemo);						}						else						{							return;						}						recnode = recnode->prev;					}										monthnode = monthnode->prev;				}			}		}		xmlFree(nodeprop);		cur = cur->prev;	}}void MyFrame::CreateBrowserWindow(wxTreeItemId *pid, bool thisMonthOnly, wxDateTime thedate){    MyGridFrame *subframe = new MyGridFrame(frame, _("Canvas Frame"),                                    wxPoint(-1, -1), wxSize(-1, -1),                                    wxDEFAULT_FRAME_STYLE);		    wxString title;    title.Printf(_("Canvas Frame %d"), ++gs_nFrames);    subframe->SetTitle(title);    // Give it an icon#ifdef __WXMSW__    subframe->SetIcon(wxIcon(_T("chrt_icn")));#else    subframe->SetIcon(wxIcon( mondrian_xpm ));#endif	if (pid!=NULL)	{		xmlnodeTreeItemData* pitemdata;		pitemdata  = (xmlnodeTreeItemData *)textWindow->GetItemData(*pid);		if (NULL != pitemdata) 		{		    RecursionShowRec(pitemdata->xmlNode,subframe,FALSE,thisMonthOnly,thedate);		}	}	subframe->recheight = frame->stdata.recheight;	for (int i=0;i<3;i++) subframe->colwidth[i] = frame->stdata.colswidth[i];	subframe->UpdateUIBaseOnSize();    subframe->Show(TRUE);	subframe->EnableAutoModify = TRUE;}void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ){	wxTreeItemId treeitem = textWindow->GetSelection();	if (treeitem.IsOk())	{		CreateBrowserWindow(&treeitem);	}}void MyFrame::OnSize(wxSizeEvent& event){    int w, h;    GetClientSize(&w, &h);    textWindow->SetSize(0, 0, 200, h);    GetClientWindow()->SetSize(200, 0, w - 200, h);    // FIXME: On wxX11, we need the MDI frame to process this    // event, but on other platforms this should not    // be done.#ifdef __WXUNIVERSAL__       event.Skip();#endif}void MyFrame::OnTreeItemSelChanging(wxTreeEvent& event){	wxTreeItemId id=event.GetItem();	wxTreeItemId oldid=event.GetOldItem();	wxToolBar* toolBar = GetToolBar();	if (toolBar==NULL) return;	for (int i=POPUP_CREATEBROWSERWIN; i<=POPUP_SETBASE; i++)	{		toolBar->EnableTool(i,FALSE);	}		if (moneybook->IsFolderNode(id))	{		toolBar->EnableTool(POPUP_CREATEBROWSERWIN,TRUE);		toolBar->EnableTool(POPUP_ADDMONEYTYPE,TRUE);		if (moneybook->CanBeDelete(id))		{			toolBar->EnableTool(POPUP_SETASDEFAULT,TRUE);			toolBar->EnableTool(POPUP_DELETETYPE,TRUE);					}		else		{			toolBar->EnableTool(POPUP_SETBASE,TRUE);		}	}	if (oldid.IsOk())	{		if (textWindow->GetItemText(oldid).Find("<---") != -1)		{			wxString temp=textWindow->GetItemText(oldid);			temp.Replace("<---","");			textWindow->SetItemText(oldid,temp);		}	}	if (id.IsOk())	{		if (textWindow->GetItemText(id).Find("<---") == -1)		{			wxString temp=textWindow->GetItemText(id);			temp+="<---";			textWindow->SetItemText(id,temp);				}	}	}void MyFrame::OnTreeItemRightClick(wxTreeEvent& event){    wxString title;	wxTreeItemId id=event.GetItem();	wxPoint pt=event.GetPoint();	    wxMenu menu("");	if (moneybook->IsFolderNode(id))	{	    menu.Append(POPUP_CREATEBROWSERWIN, _("&Create Browser Window"));	    menu.Append(POPUP_CREATECUSTOMBROWSER, _("&Query Month Records"));		menu.Append(POPUP_ADDMONEYTYPE,_("&Create Money Type"));		menu.Append(POPUP_CREATECHART,_("&Create Last 5 Month Chart"));					if (moneybook->CanBeDelete(id))		{			menu.Append(POPUP_SETASDEFAULT,_("&Set As Default"));			menu.Append(POPUP_DELETETYPE,_("&Delete Money Type"));		}		else		{			menu.Append(POPUP_SETBASE,_("&Set Base Acount"));		}	}    textWindow->PopupMenu(&menu, pt);}void MyFrame::InitToolBar(wxToolBar* toolBar){    wxBitmap* bitmaps[8];    bitmaps[0] = new wxBitmap( new_xpm );    bitmaps[1] = new wxBitmap( open_xpm );    bitmaps[2] = new wxBitmap( save_xpm );    bitmaps[3] = new wxBitmap( copy_xpm );    bitmaps[4] = new wxBitmap( cut_xpm );    bitmaps[5] = new wxBitmap( paste_xpm );    bitmaps[6] = new wxBitmap( paste_xpm );    bitmaps[7] = new wxBitmap( paste_xpm );    int width = 24;    int currentX = 5;    toolBar->AddTool( POPUP_CREATEBROWSERWIN, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Create Browser Window"));    currentX += width + 5;    toolBar->AddTool( POPUP_CREATECUSTOMBROWSER, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Query Month Records"));    currentX += width + 5;    toolBar->AddTool(POPUP_ADDMONEYTYPE, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Add Money Type"));    currentX += width + 5;    toolBar->AddSeparator();    toolBar->AddTool(POPUP_DELETETYPE, *bitmaps[3], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Delete Money Type"));    currentX += width + 5;    toolBar->AddTool(POPUP_SETASDEFAULT, *bitmaps[4], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Set As Default Type"));    currentX += width + 5;    toolBar->AddTool(POPUP_SETBASE, *bitmaps[5], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Set Base Acount"));    //currentX += width + 5;    //toolBar->AddSeparator();    //toolBar->AddTool(6, *bitmaps[6], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _T("Print"));    //currentX += width + 5;    //toolBar->AddSeparator();    //toolBar->AddTool(7, *bitmaps[7], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, _T("Help"));    toolBar->Realize();    int i;

⌨️ 快捷键说明

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