#include "app.h"
#include "main.h"
#include <wx/datetime.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include "wx/wfstream.h"
#include "wx/datstrm.h"
#include "mystockdetail.h"
#include "wstockconfig.h"
#include "wstockcustomdialog.h"
#include "MyStockDialog.h"
#include "StockHistoryDialog.h"
#include <wx/listimpl.cpp>
WX_DEFINE_LIST(BuyInfoList);
WX_DEFINE_LIST(MainGridDef_StruList);
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
int idMenuQuit = wxNewId();
int idMenuAbout = wxNewId();
int idMenuAddMyStock = wxNewId();
int idMenuConfig = wxNewId();
int idMenuUpdateMyStockFromGoogle = wxNewId();
int idMenuPutMyStockToGoogle = wxNewId();
int REALTIME_DELTA_TIMER_ID=wxNewId();
int idMenuTestNet=wxNewId();
int idMenuGlobalInfo=wxNewId();
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(idMenuQuit, MyFrame::OnQuit)
EVT_MENU(idMenuAbout, MyFrame::OnAbout)
EVT_MENU(idMenuTestNet, MyFrame::OnTestNet)
EVT_MENU(idMenuAddMyStock, MyFrame::OnAddMyStock)
EVT_MENU(idMenuConfig, MyFrame::OnConfigure)
EVT_MENU(idMenuGlobalInfo,MyFrame::OnGlobalInfo)
EVT_MENU(idMenuUpdateMyStockFromGoogle, MyFrame::OnUpdateFromGoogle)
EVT_MENU(idMenuPutMyStockToGoogle, MyFrame::OnPutToGoogle)
EVT_STOCK_DATA_GET_DONE(-1, MyFrame::OnStockDataGetDone)
EVT_TIMER(REALTIME_DELTA_TIMER_ID, MyFrame::OnRealtimeDeltaTimer)
EVT_GRID_CELL_LEFT_DCLICK(MyFrame::OnGridCellDbClick)
EVT_GSPREADSHEETS_GET_DONE(-1, MyFrame::OnUpdateFromGoogleDone)
END_EVENT_TABLE()
MyFrame::MyFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title)
{
#if wxUSE_MENUS
// create a menu bar
wxMenuBar* mbar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu(_T(""));
fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
mbar->Append(fileMenu, _("&File"));
wxMenu* ToolMenu = new wxMenu(_T(""));
ToolMenu->Append(idMenuAddMyStock, _("&Add MyStock\tCtrl-a"), _("Add One Stock Buy Record!"));
ToolMenu->AppendSeparator();
ToolMenu->Append(idMenuUpdateMyStockFromGoogle, _("&Update MyStock\tCtrl-u"),
_("Update MyStock Data from google!"));
ToolMenu->Append(idMenuPutMyStockToGoogle, _("&Put MyStock\tCtrl-u"),
_("Put MyStock Data to google!"));
ToolMenu->AppendSeparator();
ToolMenu->Append(idMenuGlobalInfo, _("&Hide(/Show) Global Info\tCtrl-Alt-s"), _("Hide(/Show) Global Info"));
ToolMenu->Append(idMenuConfig, _("&Configure\tCtrl-Alt-c"), _("Global Configure"));
mbar->Append(ToolMenu, _("&Tool"));
wxMenu* helpMenu = new wxMenu(_T(""));
#ifdef __WXDEBUG__
helpMenu->Append(idMenuTestNet, _("&Test Net\tF2"), _("Test the net connection!"));
#endif
helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application"));
mbar->Append(helpMenu, _("&Help"));
SetMenuBar(mbar);
#endif // wxUSE_MENUS
mainGrid = new wxGrid(this,-1);
mainGrid->CreateGrid(1,5);
mainGrid->SetDefaultCellAlignment(wxALIGN_CENTRE,wxALIGN_CENTRE);
mainGrid->EnableEditing(false);
mainGrid->SetRowLabelSize(50);
gss = new GSpreadSheets(this);
#if wxUSE_STATUSBAR
// create a status bar with some information about the used wxWidgets version
CreateStatusBar(2);
int Widths[]={-1,100};
SetStatusWidths(2,Widths);
SetStatusText(_("Hello wstock user !"),0);
SetStatusText(_("WSTOCK"),1);
#endif // wxUSE_STATUSBAR
//globalInfo=NULL;
globalInfo = new wstockglobalinfo(this,-1,wxT(""),&mystocks);
int x = WStockConfig::GetGlobalInfoX();
if (x<0){
x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X) - globalInfo->GetSize().x;
}
int y = WStockConfig::GetGlobalInfoY();
if (y<0){
y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) - globalInfo->GetSize().y;
}
globalInfo->SetPosition(wxPoint(x,y));
globalInfo->Show();
}
void MyFrame::DoInitData(){
ColDefs.push_back(new MainGridDef_Stru(_("Stock Name"),KT_FIXED,VT_OTHER));
ColDefs.push_back(new MainGridDef_Stru(_("TIME"),KT_REALTIME,VT_OTHER));
ColDefs.push_back(new MainGridDef_Stru(_("PRICE"),KT_REALTIME,VT_COLOR_NUMBER,3));
ColDefs.push_back(new MainGridDef_Stru(_("DELTA"),KT_REALTIME,VT_COLOR_NUMBER));
ColDefs.push_back(new MainGridDef_Stru(_("DELTA RATE"),KT_REALTIME,VT_COLOR_NUMBER));
ColDefs.push_back(new MainGridDef_Stru(_("PRICE 10D AVG"),KT_HISTORY_CALC,VT_OTHER));
ColDefs.push_back(new MainGridDef_Stru(_("PRICE AVG"),KT_MYSTOCK_FIXED,VT_OTHER));
// ColDefs.push_back(new MainGridDef_Stru(_("EXCHANGE"),KT_REALTIME,VT_OTHER));
ColDefs.push_back(new MainGridDef_Stru(_("Total Amount"),KT_MYSTOCK_FIXED,VT_OTHER));
ColDefs.push_back(new MainGridDef_Stru(_("Earnings Yield"),KT_MYSTOCK_REALTIME,VT_COLOR_NUMBER));
ColDefs.push_back(new MainGridDef_Stru(_("Earnings"),KT_MYSTOCK_REALTIME,VT_COLOR_NUMBER));
StocksDataFetch*stock = GetCurFetchObj();
stocks.SetParent(this);
stocks.Init(stock->GetHistoryDataGroupNum());
if (stocks.GetStockNum()==0){
//Now, this is a normal case.no need worry.
//wxLogMessage(_("There is no stock Id in %s,you may need add some into it!"),
// WStockConfig::GetKeyPath().c_str());
}
ClearDataFile();
mystocks.LoadDataFromFile();
mystocks.UpdateStockList(stocks.GetList());
RealTimeDeltaTimer.SetOwner(this,REALTIME_DELTA_TIMER_ID);
}
void MyFrame::UpdateMainGrid(int stockidx){
CurStockStartPos = stockidx;
//mainGrid->BeginBatch();
StocksDataFetch*stock = GetCurFetchObj();
if (stock){
int ColNum = ColDefs.size();
if (mainGrid->GetNumberCols()>ColNum){
mainGrid->DeleteCols(mainGrid->GetNumberCols() - ColNum);
}
else if (mainGrid->GetNumberCols() < ColNum){
mainGrid->AppendCols(ColNum - mainGrid->GetNumberCols());
}
for (size_t i=0;i<ColDefs.size();i++){
mainGrid->SetColLabelValue(i,ColDefs[i]->KeyName);
}
}
int TotalLeft = mystocks.GetList()->GetCount() - stockidx;
if (TotalLeft > 10){ /*TODO:应该计算出目前可以容纳的股票个数*/
TotalLeft = 10;
}
if (mainGrid->GetNumberRows() < TotalLeft){
mainGrid->AppendRows(TotalLeft - mainGrid->GetNumberRows());
}
for (int i=0;i<TotalLeft;i++){
wxString name = (*mystocks.GetList())[i]->GetName();
if (name.Length()<=0){
name = (*mystocks.GetList())[i]->GetId();
}
for (size_t ci=0;ci<ColDefs.size();ci++){
if ((ColDefs[ci]->KeyType == KT_FIXED) ||
(ColDefs[ci]->KeyType == KT_HISTORY_CALC) ||
(ColDefs[ci]->KeyType == KT_MYSTOCK_FIXED)){
//Init the date
UpdateMainGridCell(i,ci);
}
}
{
for (size_t ci=0;ci<ColDefs.size();ci++){
UpdateMainGridCellColor(i,ci);
}
}
/*mainGrid->SetCellValue(i,0,name);
wxString Id=(*mystocks.GetList())[i]->GetId();
mainGrid->SetCellValue(i,stock->GetProptiesNum()+1,
wxString::Format(wxT("%d"),
mystocks.GetDatas()[Id]->GetCurrentAmount()));*/
}
if (mainGrid->GetNumberRows() > TotalLeft){
mainGrid->DeleteRows(TotalLeft,mainGrid->GetNumberRows() - TotalLeft);
}
mainGrid->AutoSizeColumns();
//mainGrid->EndBatch();
if (mystocks.GetList()->size()>0){//if we have some custom value,start update it.
stock->RetriveRealTimeData(mystocks.GetList(), (void*)0);
//if some of the stock history data not ready, retrive it
StockList::Node* node = mystocks.GetList()->GetF
没有合适的资源?快使用搜索试试~ 我知道了~
wstock-1.0.tar.gz_stock-0.0.1.tar.gz_wstoc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 140 浏览量
2022-09-22
20:41:13
上传
评论
收藏 49KB GZ 举报
温馨提示
共58个文件
h:18个
cpp:15个
svn-base:7个
wstock, linux stock software
资源推荐
资源详情
资源评论
收起资源包目录
wstock-1.0.tar.gz (58个子文件)
wstock-1.0
wstock_cfg_linux 120B
app.cpp 1KB
stockplot.cpp 4KB
sinastock.cpp 8KB
wstock.dsw 535B
stockplot.h 456B
sohustock.h 1KB
MyStockDialog.cpp 5KB
mystockdetail.cpp 3KB
wstock.spec 438B
wstockglobalinfo.cpp 7KB
stockhistorydialog.wxg 32KB
mystockdetail.h 934B
wstockgeturl.cpp 6KB
wstock.dsp 7KB
yahoostock.cpp 7KB
stocks.h 9KB
sinastock.h 1KB
wstockcustomdialog.h 2KB
makefile 964B
stocks.xml 355B
wstock 187B
StockHistoryDialog.h 1000B
wstockglobalinfo.h 2KB
StockHistoryDialog.cpp 2KB
zh_CN
get.bat 52B
mak.bat 30B
wstock.po 14KB
wstock.mo 6KB
.svn
all-wcprops 452B
prop-base
wstock.mo.svn-base 53B
get.bat.svn-base 30B
mak.bat.svn-base 30B
props
tmp
prop-base
props
text-base
text-base
wstock.po.svn-base 14KB
wstock.mo.svn-base 6KB
get.bat.svn-base 52B
mak.bat.svn-base 30B
entries 777B
format 2B
wstock.po~ 14KB
wx_pch.h 423B
wstock.layout 4KB
wstockcustomdialog.cpp 8KB
main.cpp 25KB
gspreadsheet.h 1KB
MyStockDialog.h 4KB
wstockconst.h 280B
htmltableparser.h 1KB
wstock.cbp 3KB
main.h 1KB
wstockgeturl.h 2KB
yahoostock.h 1KB
sohustock.cpp 10KB
stocks.cpp 10KB
htmltableparser.cpp 1KB
app.h 474B
gspreadsheet.cpp 13KB
wstockconfig.h 4KB
共 58 条
- 1
资源评论
小贝德罗
- 粉丝: 71
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功