///////////////////////////////////////////////////////////////////////////// // Name: matchwin.cpp // tag: a window showing the current match // 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 "matchwin.h" #include "seats.h" #include "debug.h" BEGIN_EVENT_TABLE(MatchWin, wxFrame) EVT_CLOSE(MatchWin::OnCloseWindow) END_EVENT_TABLE() wxPoint MatchWin::defpos = wxDefaultPosition; MatchWin::MatchWin(wxWindow* parent, aBridgeScoreBase *the_score, wxString the_names[]) : wxFrame(parent, -1, "Match over!", defpos, wxSize(400, 300), wxDEFAULT_FRAME_STYLE) { m_score = the_score; wxLayoutConstraints *c; int ns_score = m_score->AboveLineNS() + m_score->BelowLineNS(); int ew_score = m_score->AboveLineEW() + m_score->BelowLineEW(); wxStaticText *congrats = new wxStaticText(this, -1, "Congratulations", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.SameAs(this, wxTop, 3); c->height.AsIs(); // c->width.AsIs(); congrats->SetConstraints(c); wxStaticText *names; if (ns_score > ew_score) { names = new wxStaticText(this, -1, the_names[NORTH] +" and " + the_names[SOUTH] + "!", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); } else { names = new wxStaticText(this, -1, the_names[EAST] + " and " + the_names[WEST] + "!", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); } c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.Below(congrats, 5); c->height.AsIs(); names->SetConstraints(c); wxString myscore; myscore.Printf("%d", ew_score); wxStaticText *ewtitle = new wxStaticText(this, -1, "East/West", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.Below(names, 5); c->height.AsIs(); ewtitle->SetConstraints(c); wxStaticText *ew = new wxStaticText(this, -1, myscore, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.Below(ewtitle, 5); c->height.AsIs(); ew->SetConstraints(c); myscore.Printf("%d", ns_score); wxStaticText *nstitle = new wxStaticText(this, -1, "North/South", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.Below(ew, 5); c->height.AsIs(); nstitle->SetConstraints(c); wxStaticText *ns = new wxStaticText(this, -1, myscore, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); c = new wxLayoutConstraints; c->left.SameAs(this, wxLeft, 5); c->right.SameAs(this, wxRight, 5); c->top.Below(nstitle, 5); c->height.AsIs(); ns->SetConstraints(c); Layout(); SetAutoLayout( TRUE ); } MatchWin::~MatchWin() { defpos = GetPosition(); } void MatchWin::OnCloseWindow(wxCloseEvent& event) { defpos = GetPosition(); delete this; }