///////////////////////////////////////////////////////////////////////////// // Name: bidreview.cpp // tag: for reviewing the bidding // 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 #include #endif #include "game.h" #include "bidreview.h" #include "card.h" #include "prefmacros.h" #include "debug.h" static const int SeatPositions[4] = {25,75,125,175}; wxPoint BidReview::defpos = wxPoint(611,0); BidReview::BidReview(wxWindow* parent, aBridgeGame *the_game) : //wxDialog(parent, -1, "Bid Review", defpos, wxSize(200, 205), // wxDIALOG_MODELESS | wxSYSTEM_MENU | wxDEFAULT_DIALOG_STYLE) { FloatWindow(parent, -1, "Bid Review", GetRelativePosition(), wxSize(200, 205), wxDIALOG_MODELESS | wxSYSTEM_MENU | wxDEFAULT_DIALOG_STYLE) { NewHand(the_game->DealerSeat()); SetAutoLayout(true); } BidReview::~BidReview() { } void BidReview::SavePositions() { SetBidReviewPosition(defpos); SetBidReviewShown(IsShown()); } void BidReview::InitStaticVariables() { if (GetRememberWindowPositions()) { defpos = GetBidReviewPosition(); } else { defpos = wxPoint(611,0); } } void BidReview::NewHand(Seat first_bid) { wxLayoutConstraints *c; wxWindow *temp = 0; DestroyChildren(); m_whose_bid = first_bid; int i; for (i = 0; i < 4; i++) { m_last_item = new wxStaticText(this, -1, Seat2String((Seat)i), wxPoint(0,0)); c = new wxLayoutConstraints; c->centreX.SameAs(this, wxLeft, SeatPositions[i]); c->top.SameAs(this, wxTop, 5); c->height.AsIs(); c->width.AsIs(); m_last_item->SetConstraints(c); } for (i=0;icentreX.SameAs(this, wxLeft, SeatPositions[i]); c->top.Below(m_last_item, 5); c->height.AsIs(); c->width.AsIs(); temp->SetConstraints(c); } if (temp) m_last_item = temp; Layout(); } static inline SuitColour suit_to_color(Suit suit) { switch (suit) { case clubs: case spades: return black; case diamonds: case hearts: return red; } } void BidReview::HandleBid(const wxString &player, const wxString &bid) { wxBitmap mybits(40,14); wxMemoryDC dc; dc.SelectObject(mybits); wxBrush back(GetBackgroundColour(), wxSOLID); dc.SetBackground( back ); dc.Clear(); // Interpreting bid... if (bid.Matches("Pass")) { DrawNumber(dc, "Pass", false, false, 7, 0, 26, 12); } else if (bid.Matches("Double")) { DrawNumber(dc, "X", false, false, 7, 0, 26, 12); } else if (bid.Matches("Redouble")) { DrawNumber(dc, "XX", false, false, 7, 0, 26, 12); } else { Suit suit = String2Suit(bid.AfterFirst(' ')); wxString num = bid.BeforeFirst(' '); if (suit != notrump) { DrawNumber(dc, num, suit_to_color(suit) == red, false, 9, 0, 12, 12); DrawSuit(dc, suit, 0, 20,0,12,12); } else { DrawNumber(dc, num+"NT", false, false, 7, 0, 26, 12); } } mybits.SetMask(new wxMask(mybits, GetBackgroundColour())); wxWindow *temp = new wxStaticBitmap(this, -1, mybits); wxLayoutConstraints *c = new wxLayoutConstraints; c->centreX.SameAs(this, wxLeft, SeatPositions[m_whose_bid]); if (m_whose_bid == SOUTH) { c->top.Below(m_last_item, 10); } else { c->centreY.SameAs(m_last_item, wxCentreY, 0); } c->height.AsIs(); c->width.AsIs(); temp->SetConstraints(c); m_last_item = temp; m_whose_bid = RotateSeat(m_whose_bid); Layout(); } wxPoint BidReview::GetRelativePosition() { return defpos; } void BidReview::SetRelativePosition(wxPoint p) { defpos = p; }