///////////////////////////////////////////////////////////////////////////// // Name: scorewin.cpp // tag: a window showing the current score // Author: David Roundy // Modified by: // Created: 9/2001 // Copyright: (c) 2001 David Roundy // Licence: GPL /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes . #include #ifndef WX_PRECOMP #include #endif #include #include "scorebase.h" #include "scorewin.h" #include "floatwindow.h" #include "prefmacros.h" #include "debug.h" wxPoint ScoreWin::defpos = wxPoint(611,200); ScoreWin::ScoreWin(wxWindow* parent, aBridgeScoreBase *the_score) : FloatWindow(parent, -1, "Scores", GetRelativePosition(), wxSize(200, 150), wxDEFAULT_FRAME_STYLE) { m_score = the_score; m_ns_above_line = new wxStaticText(this, -1, "-",wxPoint(10,43), wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); m_ew_above_line = new wxStaticText(this, -1, "-",wxPoint(100,43), wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); m_ns_below_line = new wxStaticText(this, -1, "-",wxPoint(10,70), wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); m_ew_below_line = new wxStaticText(this, -1, "-",wxPoint(100,70), wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); wxStaticLine *hello = new wxStaticLine(this, -1, wxPoint(30,65), wxSize(140,0)); hello = new wxStaticLine(this, -1, wxPoint(30,39), wxSize(140,0)); wxStaticText *hi = new wxStaticText(this, -1, "North/South", wxPoint(10,20),wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); hi = new wxStaticText(this, -1, "East/West", wxPoint(100,20),wxSize(90,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); m_vulnerable_text = new wxStaticText(this, -1, "Neither vulnerable", wxPoint(25,3),wxSize(140,20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE); UpdateScores(); } ScoreWin::~ScoreWin() { } void ScoreWin::SavePositions() { SetScoreWindowPosition(defpos); SetScoreWindowShown(IsShown()); } void ScoreWin::InitStaticVariables() { if (GetRememberWindowPositions()) { defpos = GetScoreWindowPosition(); } else { defpos = wxPoint(611,0); } } void ScoreWin::UpdateScores() { wxString score = ""; if (m_score->BelowLineNS()) score << m_score->BelowLineNS(); m_ns_below_line->SetLabel(score); score = ""; if (m_score->BelowLineEW()) score << m_score->BelowLineEW(); m_ew_below_line->SetLabel(score); score = ""; if (m_score->AboveLineNS()) score << m_score->AboveLineNS(); m_ns_above_line->SetLabel(score); score = ""; if (m_score->AboveLineEW()) score << m_score->AboveLineEW(); m_ew_above_line->SetLabel(score); if (m_score->IsEWVulnerable() && m_score->IsNSVulnerable()) { m_vulnerable_text->SetLabel("Both Vulnerable"); } else if (m_score->IsEWVulnerable()) { m_vulnerable_text->SetLabel("E/W Vulnerable"); } else if (m_score->IsNSVulnerable()) { m_vulnerable_text->SetLabel("N/S Vulnerable"); } else { m_vulnerable_text->SetLabel("Neither Vulnerable"); } } wxPoint ScoreWin::GetRelativePosition() { return defpos; } void ScoreWin::SetRelativePosition(wxPoint p) { defpos = p; }