From 3ce8d7bfd62223b0ae38dd512448d8c163887193 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 23 Aug 2007 16:38:58 +0000 Subject: [PATCH] make speed tab's colors user-configurable --- wx/speed-stats.cc | 30 ++++++++++++++++++++++++++++++ wx/speed-stats.h | 26 ++++++++++++++++---------- wx/xmission.cc | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/wx/speed-stats.cc b/wx/speed-stats.cc index d96fdaf77..ca0c158ff 100644 --- a/wx/speed-stats.cc +++ b/wx/speed-stats.cc @@ -61,6 +61,36 @@ SpeedStats :: ~SpeedStats() delete myBitmap; } +/** +*** +**/ + +void +SpeedStats :: SetColor( int i, const wxColour& c ) +{ + assert( 0<=i && i #include #include #include @@ -499,6 +500,10 @@ MyFrame :: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size myTrayIcon = new wxTaskBarIcon; SetIcon( myLogoIcon ); + /** + *** Prefs + **/ + long port; wxString key = _T("port"); if( !myConfig->Read( key, &port, 9090 ) ) @@ -508,9 +513,36 @@ MyFrame :: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size key = _T("save-path"); wxString wxstr; if( !myConfig->Read( key, &wxstr, wxFileName::GetHomeDir() ) ) - myConfig->Write( key, wxstr ); + myConfig->Write( key, wxstr ); mySavePath = toStr( wxstr ); - std::cerr << __FILE__ << ':' << __LINE__ << " save-path is [" << mySavePath << ']' << std::endl; + + const wxString default_colors[SpeedStats::N_COLORS] = { + _T("#000000"), // background + _T("#32cd32"), // frame + _T("#ff0000"), // all up + _T("#ff00ff"), // all down + _T("#ffff00"), // torrent up + _T("#00ff88") // torrent down + }; + wxColor speedColors[SpeedStats::N_COLORS]; + for( int i=0; iRead( key, &wxstr, _T("") ); + std::string str = toStr( wxstr ); + if( (str.size()!=7) + || (str[0]!='#') + || !isxdigit(str[1]) || !isxdigit(str[2]) + || !isxdigit(str[3]) || !isxdigit(str[4]) + || !isxdigit(str[5]) || !isxdigit(str[6])) + { + myConfig->Write( key, default_colors[i] ); + str = toStr( default_colors[i] ); + } + int r, g, b; + sscanf( str.c_str()+1, "%02x%02x%02x", &r, &g, &b ); + speedColors[i].Set( r, g, b ); + } /** *** Menu @@ -614,6 +646,8 @@ MyFrame :: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size tmp = new wxButton( notebook, wxID_ANY, _T("Hello World")); notebook->AddPage( tmp, _T("Files") ); mySpeedStats = new SpeedStats( notebook, wxID_ANY ); + for( int i=0; iSetColor( i, speedColors[i] ); notebook->AddPage( mySpeedStats, _T("Speed"), true ); tmp = new wxButton( notebook, wxID_ANY, _T("Hello World")); notebook->AddPage( tmp, _T("Logger") );