///////////////////////////////////////////////////////////////////////////// // Name: lasttrick.cpp // tag: a window showing the last trick. // Author: David Roundy // Modified by: // Copyright: (c) 2002 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 "lasttrick.h" #include "seats.h" #include "colors.h" #include "prefmacros.h" #include "debug.h" class theTricks: public wxScrolledWindow { public: theTricks(wxWindow* parent, int x, int y, int w, int h); virtual ~theTricks(); void ShowTrick(wxString south, wxString north, wxString east, wxString west); private: wxCard* m_played[4]; }; wxPoint LastTrick::defpos = wxPoint(-37,-137); LastTrick::LastTrick(wxWindow* parent) : FloatWindow(parent, -1, "Last Trick", GetRelativePosition(), wxSize(165, 185), wxDEFAULT_FRAME_STYLE) { m_tricks = new theTricks(this, 0,0,165,185); //if (defpos == wxPoint(-1,-1)) { // Move(wxDefaultPosition); // defpos = GetPosition() - GetParent()->GetPosition(); //} } LastTrick::~LastTrick() { delete m_tricks; } void LastTrick::SavePositions() { SetLastTrickPosition(defpos); SetLastTrickShown(IsShown()); } void LastTrick::InitStaticVariables() { if (GetRememberWindowPositions()) { defpos = GetLastTrickPosition(); } else { defpos = wxPoint(611,350); } } wxPoint LastTrick::GetRelativePosition() { return defpos; } void LastTrick::SetRelativePosition(wxPoint p) { defpos = p; } void LastTrick::ShowTrick(wxString south, wxString north, wxString east, wxString west) { if (!south.IsSameAs(east)) m_tricks->ShowTrick(south, north, east, west); } void theTricks::ShowTrick(wxString south, wxString north, wxString east, wxString west) { wxClientDC dc(this); m_played[SOUTH]->SetSameAs(Card(south, faceup)); m_played[NORTH]->SetSameAs(Card(north, faceup)); m_played[EAST]->SetSameAs(Card(east, faceup)); m_played[WEST]->SetSameAs(Card(west, faceup)); int i; for(i=0;i<4;i++) { m_played[i]->Refresh(); } } theTricks::theTricks(wxWindow* parent, int x, int y, int w, int h) : wxScrolledWindow(parent, -1, wxPoint(x, y), wxSize(w, h)) { SetBackgroundColour(aBridgeBackgroundColour()); SetForegroundColour(aBridgeTextColour()); SetFont(aBridgeFont()); m_played[SOUTH] = new wxCard(this, 1, facedown, wxPoint( 55, 85)); m_played[EAST] = new wxCard(this, 1, facedown, wxPoint(105, 45)); m_played[NORTH] = new wxCard(this, 1, facedown, wxPoint( 55, 5)); m_played[WEST] = new wxCard(this, 1, facedown, wxPoint( 5, 45)); } theTricks::~theTricks() { }