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

@@ -41,10 +41,8 @@ Using project files:
2. Open src/wxvc.dsp, set Debug or Release configuration, and 2. Open src/wxvc.dsp, set Debug or Release configuration, and
compile. This will produce lib/wxvc.lib or lib/wxvc_debug.lib. compile. This will produce lib/wxvc.lib or lib/wxvc_debug.lib.
3. Open a sample project file, choose a configuration, and compile. 3. Open a sample project file, choose a configuration, and compile.
Currently only the minimal and mdi samples have project files. The project files don't use precompiled headers, to save
To create others, copy the .dsp/.dsw files from the minimal space, but you can switch PCH compiling on for greater speed.
sample and globally replace 'MinimalVC' and 'minimal' with
suitable names. Add any other required source files.
Using makefiles: Using makefiles:

View File

@@ -22,9 +22,14 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/event.h" #include "wx/event.h"
#ifdef __MINGW32__ #ifdef __GNUWIN32__
#undef GetFirstChild() # ifdef GetFirstChild
#undef GetNextSibling() # undef GetFirstChild
# endif
# ifdef GetNextSibling
# undef GetNextSibling
# endif
#endif #endif
// the type for "untyped" data // the type for "untyped" data

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -85,7 +85,11 @@ void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
} }
// Check if the bitmap has the correct depth for this device context // Check if the bitmap has the correct depth for this device context
if (bitmap.Ok() && (bitmap.GetDepth() != GetDepth())) // if (bitmap.Ok() && (bitmap.GetDepth() != GetDepth()))
// JACS 11/12/98: disabling this since the Forty Thieves sample
// shows this not working properly. In fact, if loading from a resource,
// the depth should become the screen depth, so why was it being called?
if (0)
{ {
// Make a new bitmap that has the correct depth. // Make a new bitmap that has the correct depth.
wxBitmap newBitmap = bitmap.GetBitmapForDC(* this); wxBitmap newBitmap = bitmap.GetBitmapForDC(* this);

View File

@@ -963,13 +963,13 @@ void wxPropertySheet::UpdateAllViews( wxPropertyView *WXUNUSED(thisView) )
// Add a property // Add a property
void wxPropertySheet::AddProperty(wxProperty *property) void wxPropertySheet::AddProperty(wxProperty *property)
{ {
m_properties.Append(property->GetName().GetData(), property); m_properties.Append((const char*) property->GetName(), property);
} }
// Get property by name // Get property by name
wxProperty *wxPropertySheet::GetProperty(wxString name) wxProperty *wxPropertySheet::GetProperty(wxString name)
{ {
wxNode *node = m_properties.Find(name.GetData()); wxNode *node = m_properties.Find((const char*) name);
if (!node) if (!node)
return NULL; return NULL;
else else
@@ -1018,14 +1018,14 @@ wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
ClearRegistry(); ClearRegistry();
} }
void wxPropertyValidatorRegistry::RegisterValidator(wxString& typeName, wxPropertyValidator *validator) void wxPropertyValidatorRegistry::RegisterValidator(const wxString& typeName, wxPropertyValidator *validator)
{ {
Put(typeName.GetData(), validator); Put((const char*) typeName, validator);
} }
wxPropertyValidator *wxPropertyValidatorRegistry::GetValidator(wxString& typeName) wxPropertyValidator *wxPropertyValidatorRegistry::GetValidator(const wxString& typeName)
{ {
return (wxPropertyValidator *)Get(typeName.GetData()); return (wxPropertyValidator *)Get((const char*) typeName);
} }
void wxPropertyValidatorRegistry::ClearRegistry(void) void wxPropertyValidatorRegistry::ClearRegistry(void)

View File

@@ -150,8 +150,8 @@ class wxPropertyValidatorRegistry: public wxHashTable
wxPropertyValidatorRegistry(void); wxPropertyValidatorRegistry(void);
~wxPropertyValidatorRegistry(void); ~wxPropertyValidatorRegistry(void);
virtual void RegisterValidator(wxString& roleName, wxPropertyValidator *validator); virtual void RegisterValidator(const wxString& roleName, wxPropertyValidator *validator);
virtual wxPropertyValidator *GetValidator(wxString& roleName); virtual wxPropertyValidator *GetValidator(const wxString& roleName);
void ClearRegistry(void); void ClearRegistry(void);
}; };