Corrections to Forty Thieves; wxMemoryDC problem temporarily sorted

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-12-11 09:59:20 +00:00
parent 9ac654169e
commit 16553659df
12 changed files with 118 additions and 50 deletions

View File

@@ -50,7 +50,7 @@ FortyCanvas::FortyCanvas(wxWindow* parent, int x, int y, int w, int h) :
#else
m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
#endif
SetBackgroundColour(*FortyApp::BackgroundColour());
SetBackgroundColour(FortyApp::BackgroundColour());
AllowDoubleClick(true);
m_handCursor = new wxCursor(wxCURSOR_HAND);
@@ -91,7 +91,7 @@ void FortyCanvas::UpdateScores()
void FortyCanvas::OnDraw(wxDC& dc)
{
dc.SetFont(m_font);
dc.SetFont(* m_font);
m_game->Redraw(dc);
// if player name not set (and selection dialog is not displayed)
@@ -141,7 +141,7 @@ void FortyCanvas::OnMouseEvent(wxMouseEvent& event)
wxClientDC dc(this);
PrepareDC(dc);
dc.SetFont(m_font);
dc.SetFont(* m_font);
if (event.LeftDClick())
{
@@ -208,7 +208,7 @@ void FortyCanvas::SetCursorStyle(int x, int y)
wxClientDC dc(this);
PrepareDC(dc);
dc.SetFont(m_font);
dc.SetFont(* m_font);
m_game->Redraw(dc);
}
else
@@ -222,11 +222,11 @@ void FortyCanvas::SetCursorStyle(int x, int y)
// the card under the cursor can go somewhere
if (m_game->CanYouGo(x, y) && m_helpingHand)
{
SetCursor(m_handCursor);
SetCursor(* m_handCursor);
}
else
{
SetCursor(m_arrowCursor);
SetCursor(* m_arrowCursor);
}
}
@@ -241,7 +241,7 @@ void FortyCanvas::Undo()
{
wxClientDC dc(this);
PrepareDC(dc);
dc.SetFont(m_font);
dc.SetFont(* m_font);
m_game->Undo(dc);
}
@@ -249,6 +249,6 @@ void FortyCanvas::Redo()
{
wxClientDC dc(this);
PrepareDC(dc);
dc.SetFont(m_font);
dc.SetFont(* m_font);
m_game->Redo(dc);
}

View File

@@ -138,11 +138,11 @@ Card::~Card()
void Card::Erase(wxDC& dc, int x, int y)
{
wxPen* pen = wxThePenList->FindOrCreatePen(
*FortyApp::BackgroundColour(),
FortyApp::BackgroundColour(),
1,
wxSOLID
);
dc.SetPen(pen);
dc.SetPen(* pen);
dc.SetBrush(FortyApp::BackgroundBrush());
dc.DrawRectangle(x, y, CardWidth, CardHeight);
} // Card::Erase()
@@ -171,18 +171,18 @@ void Card::Erase(wxDC& dc, int x, int y)
//+-------------------------------------------------------------+
void Card::Draw(wxDC& dc, int x, int y)
{
wxBrush* backgroundBrush = dc.GetBackground();
dc.SetBrush(wxWHITE_BRUSH);
dc.SetPen(wxBLACK_PEN);
wxBrush* backgroundBrush = & dc.GetBackground();
dc.SetBrush(* wxWHITE_BRUSH);
dc.SetPen(* wxBLACK_PEN);
dc.DrawRoundedRectangle(x, y, CardWidth, CardHeight, 4);
if (m_wayUp == facedown)
{
dc.SetBackground(wxRED_BRUSH);
dc.SetBackground(* wxRED_BRUSH);
dc.SetBackgroundMode(wxSOLID);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
"BLACK", wxCROSSDIAG_HATCH
);
dc.SetBrush(brush);
dc.SetBrush(* brush);
dc.DrawRoundedRectangle(
x + 4, y + 4,
@@ -193,7 +193,7 @@ void Card::Draw(wxDC& dc, int x, int y)
else
{
wxMemoryDC memoryDC;
memoryDC.SelectObject(m_symbolBmap);
memoryDC.SelectObject(* m_symbolBmap);
// dc.SetBackgroundMode(wxTRANSPARENT);
@@ -324,10 +324,10 @@ void Card::Draw(wxDC& dc, int x, int y)
case 11:
case 12:
case 13:
memoryDC.SelectObject(m_pictureBmap);
memoryDC.SelectObject(* m_pictureBmap);
dc.Blit(x + 5, y - 5 + CardHeight / 4, 40, 45,
&memoryDC, 40 * (m_pipValue - 11), 0, wxCOPY);
memoryDC.SelectObject(m_symbolBmap);
memoryDC.SelectObject(* m_symbolBmap);
dc.Blit(x + 32, y - 3 + CardHeight / 4, 11, 11,
&memoryDC, 11 * m_suit, 14, wxCOPY);
dc.Blit(x + 7, y + 27 + CardHeight / 4, 11, 11,
@@ -336,7 +336,7 @@ void Card::Draw(wxDC& dc, int x, int y)
}
}
dc.SetBackground(backgroundBrush);
dc.SetBackground(* backgroundBrush);
} // Card:Draw()
@@ -349,9 +349,9 @@ void Card::Draw(wxDC& dc, int x, int y)
//+-------------------------------------------------------------+
void Card::DrawNullCard(wxDC& dc, int x, int y)
{
wxPen* pen = wxThePenList->FindOrCreatePen(*FortyApp::TextColour(), 1, wxSOLID);
wxPen* pen = wxThePenList->FindOrCreatePen(FortyApp::TextColour(), 1, wxSOLID);
dc.SetBrush(FortyApp::BackgroundBrush());
dc.SetPen(pen);
dc.SetPen(*pen);
dc.DrawRoundedRectangle(x, y, CardWidth, CardHeight, 4);
} // Card::DrawNullCard()

View File

@@ -110,7 +110,7 @@ const wxBrush& FortyApp::BackgroundBrush()
{
if (!m_backgroundBrush)
{
m_backgroundBrush = new wxBrush(*BackgroundColour(), wxSOLID);
m_backgroundBrush = new wxBrush(BackgroundColour(), wxSOLID);
}
return *m_backgroundBrush;
@@ -132,10 +132,10 @@ FortyFrame::FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h):
{
// set the icon
#ifdef __WXMSW__
SetIcon(new wxIcon("CardsIcon"));
SetIcon(wxIcon("CardsIcon"));
#else
#ifdef GTK_TBD
SetIcon(new wxIcon(Cards_bits, Cards_width, Cards_height));
SetIcon(wxIcon(Cards_bits, Cards_width, Cards_height));
#endif
#endif

View File

@@ -166,12 +166,12 @@ void Game::DoMove(wxDC& dc, Pile* src, Pile* dest)
void Game::DisplayScore(wxDC& dc)
{
wxColour* bgColour = FortyApp::BackgroundColour();
wxPen* pen = wxThePenList->FindOrCreatePen(*bgColour, 1, wxSOLID);
dc.SetTextBackground(*bgColour);
dc.SetTextForeground(*FortyApp::TextColour());
wxColour bgColour = FortyApp::BackgroundColour();
wxPen* pen = wxThePenList->FindOrCreatePen(bgColour, 1, wxSOLID);
dc.SetTextBackground(bgColour);
dc.SetTextForeground(FortyApp::TextColour());
dc.SetBrush(FortyApp::BackgroundBrush());
dc.SetPen(pen);
dc.SetPen(* pen);
// count the number of cards in foundations
m_currentScore = 0;
@@ -746,8 +746,8 @@ void Pack::Redraw(wxDC& dc)
char str[10];
sprintf(str, "%d ", m_topCard + 1);
dc.SetTextBackground(*FortyApp::BackgroundColour());
dc.SetTextForeground(*FortyApp::TextColour());
dc.SetTextBackground(FortyApp::BackgroundColour());
dc.SetTextForeground(FortyApp::TextColour());
dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2);
}

View File

@@ -0,0 +1,61 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for Forty Thieves example (UNIX).
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/makeg95.env
OBJECTS = $(OBJDIR)/forty.$(OBJSUFF) $(OBJDIR)/canvas.$(OBJSUFF) $(OBJDIR)/card.$(OBJSUFF)\
$(OBJDIR)/game.$(OBJSUFF) $(OBJDIR)/pile.$(OBJSUFF) $(OBJDIR)/playerdg.$(OBJSUFF)\
$(OBJDIR)/scoredg.$(OBJSUFF) $(OBJDIR)/scorefil.$(OBJSUFF)\
$(OBJDIR)/forty_resources.$(OBJSUFF)
all: $(OBJDIR) forty$(GUISUFFIX)$(EXESUFF)
wx:
$(OBJDIR):
mkdir $(OBJDIR)
forty$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o forty$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
$(OBJDIR)/forty.$(OBJSUFF): forty.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ forty.$(SRCSUFF)
$(OBJDIR)/canvas.$(OBJSUFF): canvas.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ canvas.$(SRCSUFF)
$(OBJDIR)/card.$(OBJSUFF): card.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ card.$(SRCSUFF)
$(OBJDIR)/playerdg.$(OBJSUFF): playerdg.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ playerdg.$(SRCSUFF)
$(OBJDIR)/scoredg.$(OBJSUFF): scoredg.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ scoredg.$(SRCSUFF)
$(OBJDIR)/scorefil.$(OBJSUFF): scorefil.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ scorefil.$(SRCSUFF)
$(OBJDIR)/pile.$(OBJSUFF): pile.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ pile.$(SRCSUFF)
$(OBJDIR)/game.$(OBJSUFF): game.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ game.$(SRCSUFF)
$(OBJDIR)/forty_resources.o: forty.rc
$(RESCOMP) -i forty.rc -o $(OBJDIR)/forty_resources.o $(RESFLAGS)
clean:
rm -f $(OBJECTS) forty$(GUISUFFIX).exe core *.rsc *.res

View File

@@ -79,7 +79,7 @@ void Pile::Redraw(wxDC& dc )
wxWindow *canvas = (wxWindow *) NULL;
if (frame)
{
wxNode *node = frame->GetChildren()->First();
wxNode *node = frame->GetChildren().First();
if (node) canvas = (wxWindow*)node->Data();
}

View File

@@ -28,7 +28,7 @@
#endif
#if wxUSE_IOSTREAMH
#if defined(__WXMSW__) && !defined(GNUWIN32)
#if defined(__WXMSW__) && !defined(__GNUWIN32__)
#include <strstrea.h>
#else
#include <strstream.h>
@@ -96,7 +96,7 @@ ScoreCanvas::~ScoreCanvas()
void ScoreCanvas::OnDraw(wxDC& dc)
{
dc.SetFont(m_font);
dc.SetFont(* m_font);
const char* str = m_text;
unsigned int tab = 0;