applied patch #935127: "wxDIALOG_MODAL and wxDIALOG_MODELESS cleaning"; some cosmetic cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27430 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth
2004-05-25 12:44:56 +00:00
parent be5a51fb59
commit 2a21ac1590
19 changed files with 585 additions and 618 deletions

View File

@@ -182,7 +182,7 @@ void MyApp::PropertyListTest(bool useDialog)
if (useDialog) if (useDialog)
{ {
propDialog = new PropListDialog(view, NULL, _T("Property Sheet Test"), propDialog = new PropListDialog(view, NULL, _T("Property Sheet Test"),
wxDefaultPosition, wxSize(400, 500), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODELESS); wxDefaultPosition, wxSize(400, 500));
m_childWindow = propDialog; m_childWindow = propDialog;
} }
else else
@@ -230,7 +230,7 @@ void MyApp::PropertyFormTest(bool useDialog)
if (useDialog) if (useDialog)
{ {
propDialog = new PropFormDialog(view, NULL, _T("Property Form Test"), propDialog = new PropFormDialog(view, NULL, _T("Property Form Test"),
wxDefaultPosition, wxSize(380, 250), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); wxDefaultPosition, wxSize(380, 250));
m_childWindow = propDialog; m_childWindow = propDialog;
} }
else else

File diff suppressed because it is too large Load Diff

View File

@@ -1643,7 +1643,7 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList
wxBeginBusyCursor(); wxBeginBusyCursor();
wxPropertyStringListEditorDialog *dialog = new wxPropertyStringListEditorDialog(parent, wxPropertyStringListEditorDialog *dialog = new wxPropertyStringListEditorDialog(parent,
title, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); title, wxPoint(10, 10), wxSize(400, 400));
dialog->m_stringList = stringList; dialog->m_stringList = stringList;

View File

@@ -6,9 +6,7 @@
// Created: 21/07/97 // Created: 21/07/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1993-1998 Chris Breeze // Copyright: (c) 1993-1998 Chris Breeze
// Licence: wxWindows licence // Licence: wxWindows licence
//---------------------------------------------------------------------------
// Last modified: 22nd July 1998 - ported to wxWidgets 2.0
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -33,57 +31,55 @@
const int ID_LISTBOX = 101; const int ID_LISTBOX = 101;
BEGIN_EVENT_TABLE(PlayerSelectionDialog, wxDialog) BEGIN_EVENT_TABLE(PlayerSelectionDialog, wxDialog)
EVT_SIZE(PlayerSelectionDialog::OnSize) EVT_SIZE(PlayerSelectionDialog::OnSize)
EVT_BUTTON(wxID_OK, PlayerSelectionDialog::ButtonCallback) EVT_BUTTON(wxID_OK, PlayerSelectionDialog::ButtonCallback)
EVT_BUTTON(wxID_CANCEL, PlayerSelectionDialog::ButtonCallback) EVT_BUTTON(wxID_CANCEL, PlayerSelectionDialog::ButtonCallback)
EVT_LISTBOX(ID_LISTBOX, PlayerSelectionDialog::SelectCallback) EVT_LISTBOX(ID_LISTBOX, PlayerSelectionDialog::SelectCallback)
EVT_CLOSE(PlayerSelectionDialog::OnCloseWindow) EVT_CLOSE(PlayerSelectionDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
PlayerSelectionDialog::PlayerSelectionDialog( PlayerSelectionDialog::PlayerSelectionDialog(
wxWindow* parent, wxWindow* parent,
ScoreFile* file ScoreFile* file
) : ) :
wxDialog(parent, wxID_ANY, _T("Player Selection"), wxDialog(parent, wxID_ANY, _T("Player Selection"), wxDefaultPosition),
wxDefaultPosition, wxDefaultSize, m_scoreFile(file)
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
m_scoreFile(file)
{ {
wxStaticText* msg = new wxStaticText(this, wxID_ANY, _T("Please select a name or type a new one:")); wxStaticText* msg = new wxStaticText(this, wxID_ANY, _T("Please select a name or type a new one:"));
wxListBox* list = new wxListBox( wxListBox* list = new wxListBox(
this, ID_LISTBOX, this, ID_LISTBOX,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
0, 0, 0, 0,
wxLB_SINGLE wxLB_SINGLE
); );
wxArrayString players;
m_scoreFile->GetPlayerList(players);
for (unsigned int i = 0; i < players.Count(); i++)
{
list->Append(players[i]);
}
m_textField = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, 0); wxArrayString players;
m_scoreFile->GetPlayerList(players);
for (unsigned int i = 0; i < players.Count(); i++)
{
list->Append(players[i]);
}
m_OK = new wxButton(this, wxID_OK, _T("OK")); m_textField = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize);
m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); m_OK = new wxButton(this, wxID_OK, _T("OK"));
button_sizer->Add( m_OK, 0, wxALL, 10 ); m_cancel = new wxButton(this, wxID_CANCEL, _T("Cancel"));
button_sizer->Add( m_cancel, 0, wxALL, 10 );
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
topsizer->Add( msg, 0, wxALL , 10 ); button_sizer->Add( m_OK, 0, wxALL, 10 );
topsizer->Add( list, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 ); button_sizer->Add( m_cancel, 0, wxALL, 10 );
topsizer->Add( m_textField, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10 );
topsizer->Add( button_sizer, 0, wxALIGN_LEFT );
SetSizer( topsizer ); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
topsizer->Add( msg, 0, wxALL , 10 );
topsizer->Add( list, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );
topsizer->Add( m_textField, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 10 );
topsizer->Add( button_sizer, 0, wxALIGN_LEFT );
SetSizer( topsizer );
topsizer->SetSizeHints( this );
topsizer->SetSizeHints( this );
CentreOnParent(); CentreOnParent();
} }
@@ -93,58 +89,58 @@ PlayerSelectionDialog::~PlayerSelectionDialog()
void PlayerSelectionDialog::OnSize(wxSizeEvent& WXUNUSED(event)) void PlayerSelectionDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{ {
Layout(); Layout();
} }
const wxString& PlayerSelectionDialog::GetPlayersName() const wxString& PlayerSelectionDialog::GetPlayersName()
{ {
/* /*
m_player = ""; m_player = wxEmptyString;
Show(true); Show(true);
*/ */
return m_player; return m_player;
} }
void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void PlayerSelectionDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{ {
m_player = _T(""); m_player = wxEmptyString;
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
void PlayerSelectionDialog::SelectCallback(wxCommandEvent& event) void PlayerSelectionDialog::SelectCallback(wxCommandEvent& event)
{ {
if (event.GetEventType() == wxEVT_COMMAND_LISTBOX_SELECTED) if (event.GetEventType() == wxEVT_COMMAND_LISTBOX_SELECTED)
{ {
// if (event.IsSelection()) // if (event.IsSelection())
m_textField->SetValue(event.GetString()); m_textField->SetValue(event.GetString());
} }
} }
void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event) void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
{ {
if (event.GetId() == wxID_OK) if (event.GetId() == wxID_OK)
{ {
wxString name = m_textField->GetValue(); wxString name = m_textField->GetValue();
if (!name.IsNull() && name.Length() > 0) if (!name.IsNull() && name.Length() > 0)
{ {
if (name.Contains(_T('@'))) if (name.Contains(_T('@')))
{ {
wxMessageBox(_T("Names should not contain the '@' character"), _T("Forty Thieves")); wxMessageBox(_T("Names should not contain the '@' character"), _T("Forty Thieves"));
} }
else else
{ {
m_player = name; m_player = name;
EndModal(wxID_OK); EndModal(wxID_OK);
} }
} }
else else
{ {
wxMessageBox(_T("Please enter your name"), _T("Forty Thieves")); wxMessageBox(_T("Please enter your name"), _T("Forty Thieves"));
} }
} }
else else
{ {
m_player = _T(""); m_player = wxEmptyString;
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
} }

View File

@@ -6,9 +6,7 @@
// Created: 21/07/97 // Created: 21/07/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1993-1998 Chris Breeze // Copyright: (c) 1993-1998 Chris Breeze
// Licence: wxWindows licence // Licence: wxWindows licence
//---------------------------------------------------------------------------
// Last modified: 22nd July 1998 - ported to wxWidgets 2.0
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__) #if defined(__GNUG__) && !defined(__APPLE__)
@@ -38,49 +36,49 @@
class ScoreCanvas : public wxScrolledWindow class ScoreCanvas : public wxScrolledWindow
{ {
public: public:
ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size); ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size);
virtual ~ScoreCanvas(); virtual ~ScoreCanvas();
void OnDraw(wxDC& dc); void OnDraw(wxDC& dc);
private: private:
wxFont* m_font; wxFont *m_font;
wxString m_text; wxString m_text;
}; };
ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size) : ScoreCanvas::ScoreCanvas(wxWindow* parent, ScoreFile* scoreFile, const wxPoint& pos, wxSize& size) :
wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER) wxScrolledWindow(parent, wxID_ANY, pos, size, wxSUNKEN_BORDER)
{ {
SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE);
#ifdef __WXGTK__ #ifdef __WXGTK__
m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL); m_font = wxTheFontList->FindOrCreateFont(12, wxROMAN, wxNORMAL, wxNORMAL);
#else #else
m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL); m_font = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
#endif #endif
wxArrayString players; wxArrayString players;
scoreFile->GetPlayerList( players); scoreFile->GetPlayerList( players);
wxString os; wxString os;
os << wxT("Player\tWins\tGames\tScore\n"); os << wxT("Player\tWins\tGames\tScore\n");
for (unsigned int i = 0; i < players.Count(); i++) for (unsigned int i = 0; i < players.Count(); i++)
{ {
int wins, games, score; int wins, games, score;
scoreFile->ReadPlayersScore(players[i], wins, games, score); scoreFile->ReadPlayersScore(players[i], wins, games, score);
int average = 0; int average = 0;
if (games > 0) if (games > 0)
{ {
average = (2 * score + games) / (2 * games); average = (2 * score + games) / (2 * games);
} }
os << players[i] << wxT('\t') os << players[i] << wxT('\t')
<< wins << wxT('\t') << wins << wxT('\t')
<< games << wxT('\t') << games << wxT('\t')
<< average << wxT('\n'); << average << wxT('\n');
} }
os << wxT('\0'); os << wxT('\0');
m_text = os; m_text = os;
} }
ScoreCanvas::~ScoreCanvas() ScoreCanvas::~ScoreCanvas()
@@ -89,45 +87,45 @@ ScoreCanvas::~ScoreCanvas()
void ScoreCanvas::OnDraw(wxDC& dc) void ScoreCanvas::OnDraw(wxDC& dc)
{ {
dc.SetFont(* m_font); dc.SetFont(* m_font);
const wxChar* str = m_text; const wxChar* str = m_text;
unsigned int tab = 0; unsigned int tab = 0;
unsigned int tabstops[] = { 5, 100, 150, 200 }; unsigned int tabstops[] = { 5, 100, 150, 200 };
// get the line spacing for the current font // get the line spacing for the current font
int lineSpacing; int lineSpacing;
{ {
long w, h; long w, h;
dc.GetTextExtent(wxT("Testing"), &w, &h); dc.GetTextExtent(wxT("Testing"), &w, &h);
lineSpacing = (int)h; lineSpacing = (int)h;
} }
int y = 0; int y = 0;
while (*str) while (*str)
{ {
wxChar text[256]; wxChar text[256];
wxChar* dest = text; wxChar* dest = text;
while (*str && *str >= ' ') *dest++ = *str++;
*dest = '\0';
dc.DrawText(text, tabstops[tab], y); while (*str && *str >= ' ') *dest++ = *str++;
*dest = '\0';
if (*str == '\t') dc.DrawText(text, tabstops[tab], y);
{
if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1) if (*str == '\t')
{ {
tab++; if (tab < sizeof(tabstops) / sizeof(tabstops[0]) - 1)
} {
} tab++;
else if (*str == '\n') }
{ }
tab = 0; else if (*str == '\n')
y += lineSpacing; {
} tab = 0;
if (*str) str++; y += lineSpacing;
} }
if (*str) str++;
}
} }
#endif #endif
@@ -136,31 +134,30 @@ BEGIN_EVENT_TABLE(ScoreDialog, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) : ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
wxDialog(parent, wxID_ANY, _("Scores"), wxDialog(parent, wxID_ANY, _("Scores"),
wxDefaultPosition, wxSize(400, 300), wxDefaultPosition, wxSize(400, 300)),
wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE), m_scoreFile(file)
m_scoreFile(file)
{ {
// create grid with players // create grid with players
wxArrayString players; wxArrayString players;
file->GetPlayerList(players); file->GetPlayerList(players);
wxSize sz = wxSize(400, 300); wxSize sz = wxSize(400, 300);
#if USE_GRID_FOR_SCORE #if USE_GRID_FOR_SCORE
wxGrid* list = new wxGrid(this, wxID_ANY, wxDefaultPosition, sz, 0); wxGrid* list = new wxGrid(this, wxID_ANY, wxDefaultPosition, sz, 0);
list->CreateGrid(players.Count(), 4); list->CreateGrid(players.Count(), 4);
for (unsigned int i = 0; i < players.Count(); i++) for (unsigned int i = 0; i < players.Count(); i++)
{ {
int wins, games, score; int wins, games, score;
wxString string_value; wxString string_value;
file->ReadPlayersScore(players[i], wins, games, score); file->ReadPlayersScore(players[i], wins, games, score);
int average = 0; int average = 0;
if (games > 0) if (games > 0)
{ {
average = (2 * score + games) / (2 * games); average = (2 * score + games) / (2 * games);
} }
list->SetCellValue(i,0,players[i]); list->SetCellValue(i,0,players[i]);
string_value.Printf( _T("%u"), wins ); string_value.Printf( _T("%u"), wins );
list->SetCellValue(i,1,string_value); list->SetCellValue(i,1,string_value);
@@ -181,7 +178,7 @@ ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
list->EnableDragColSize(false); list->EnableDragColSize(false);
list->EnableDragGridSize(false); list->EnableDragGridSize(false);
#else #else
ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz); ScoreCanvas* list = new ScoreCanvas(this, m_scoreFile, wxDefaultPosition, sz);
#endif #endif
// locate and resize with sizers // locate and resize with sizers
@@ -193,7 +190,7 @@ ScoreDialog::ScoreDialog(wxWindow* parent, ScoreFile* file) :
GetSizer()->Fit(this); GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
CentreOnParent(); CentreOnParent();
} }
@@ -203,7 +200,7 @@ ScoreDialog::~ScoreDialog()
void ScoreDialog::Display() void ScoreDialog::Display()
{ {
Show(true); Show(true);
} }
void ScoreDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void ScoreDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))

View File

@@ -6,9 +6,7 @@
// Created: 21/07/97 // Created: 21/07/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1993-1998 Chris Breeze // Copyright: (c) 1993-1998 Chris Breeze
// Licence: wxWindows licence // Licence: wxWindows licence
//---------------------------------------------------------------------------
// Last modified: 14th May 1998 - ported to wxWidgets 2.0
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -41,65 +39,65 @@
ScoreFile::ScoreFile(const wxString& appName) ScoreFile::ScoreFile(const wxString& appName)
{ {
#if 0 #if 0
wxString filename; wxString filename;
m_configFilename << "/usr/local/share/" << appName << ".scores"; m_configFilename << "/usr/local/share/" << appName << ".scores";
if (access(m_configFilename, F_OK) == 0) if (access(m_configFilename, F_OK) == 0)
{ {
if (access(m_configFilename, R_OK | W_OK) != 0) if (access(m_configFilename, R_OK | W_OK) != 0)
{ {
// file is not r/w - use local file instead // file is not r/w - use local file instead
m_configFilename = wxFileConfig::GetLocalFileName(appName); m_configFilename = wxFileConfig::GetLocalFileName(appName);
} }
} }
else else
{ {
int fd = creat(m_configFilename, 0666); int fd = creat(m_configFilename, 0666);
if (fd < 0) if (fd < 0)
{ {
// failed to create file - use local file instead // failed to create file - use local file instead
m_configFilename = wxFileConfig::GetLocalFileName(appName); m_configFilename = wxFileConfig::GetLocalFileName(appName);
} }
else else
{ {
// ensure created file has rw-rw-rw permissions // ensure created file has rw-rw-rw permissions
close(fd); close(fd);
} }
} }
#endif #endif
m_config = new wxConfig(appName, _T("wxWidgets"), appName, _T(""), m_config = new wxConfig(appName, _T("wxWidgets"), appName, wxEmptyString,
wxCONFIG_USE_LOCAL_FILE); // only local wxCONFIG_USE_LOCAL_FILE); // only local
} }
ScoreFile::~ScoreFile() ScoreFile::~ScoreFile()
{ {
delete m_config; delete m_config;
#ifdef __WXGTK__ #ifdef __WXGTK__
// ensure score file has rw-rw-rw permissions // ensure score file has rw-rw-rw permissions
// (wxFileConfig sets them to rw-------) // (wxFileConfig sets them to rw-------)
chmod(m_configFilename, 0666); chmod(m_configFilename, 0666);
#endif #endif
} }
void ScoreFile::GetPlayerList( wxArrayString &list ) void ScoreFile::GetPlayerList( wxArrayString &list )
{ {
m_config->SetPath(_T("/Players")); m_config->SetPath(_T("/Players"));
int length = m_config->GetNumberOfGroups(); int length = m_config->GetNumberOfGroups();
if (length <= 0) return; if (length <= 0) return;
wxString player; wxString player;
long index; long index;
if (m_config->GetFirstGroup(player, index)) if (m_config->GetFirstGroup(player, index))
{ {
list.Add( player ); list.Add( player );
while (m_config->GetNextGroup(player, index)) while (m_config->GetNextGroup(player, index))
{ {
list.Add( player ); list.Add( player );
} }
} }
} }
@@ -111,73 +109,73 @@ long ScoreFile::CalcCheck(const wxString& name, int p1, int p2, int p3)
size_t i, max = name.length(); size_t i, max = name.length();
for(i = 0; i < max; ++i ) for(i = 0; i < max; ++i )
{ {
check = (check << 1) ^ (long)name[i]; check = (check << 1) ^ (long)name[i];
check = ((check >> 23) ^ check) & 0xFFFFFF; check = ((check >> 23) ^ check) & 0xFFFFFF;
} }
check = (check << 1) ^ (long)p1; check = (check << 1) ^ (long)p1;
check = ((check >> 23) ^ check) & 0xFFFFFF; check = ((check >> 23) ^ check) & 0xFFFFFF;
check = (check << 1) ^ (long)p2; check = (check << 1) ^ (long)p2;
check = ((check >> 23) ^ check) & 0xFFFFFF; check = ((check >> 23) ^ check) & 0xFFFFFF;
check = (check << 1) ^ (long)p3; check = (check << 1) ^ (long)p3;
check = ((check >> 23) ^ check) & 0xFFFFFF; check = ((check >> 23) ^ check) & 0xFFFFFF;
return check; return check;
} }
wxString ScoreFile::GetPreviousPlayer() const wxString ScoreFile::GetPreviousPlayer() const
{ {
wxString result; wxString result;
m_config->SetPath(_T("/General")); m_config->SetPath(_T("/General"));
m_config->Read(_T("LastPlayer"), &result); m_config->Read(_T("LastPlayer"), &result);
return result; return result;
} }
void ScoreFile::ReadPlayersScore( void ScoreFile::ReadPlayersScore(
const wxString& player, const wxString& player,
int& wins, int& wins,
int& games, int& games,
int& score) int& score)
{ {
long check = 0; long check = 0;
long myWins = 0, myGames = 0, myScore = 0; long myWins = 0, myGames = 0, myScore = 0;
games = wins = score = 0; games = wins = score = 0;
m_config->SetPath(_T("/Players")); m_config->SetPath(_T("/Players"));
m_config->SetPath(player); m_config->SetPath(player);
if (m_config->Read(_T("Score"), &myScore, 0L) && if (m_config->Read(_T("Score"), &myScore, 0L) &&
m_config->Read(_T("Games"), &myGames, 0L) && m_config->Read(_T("Games"), &myGames, 0L) &&
m_config->Read(_T("Wins"), &myWins, 0L) && m_config->Read(_T("Wins"), &myWins, 0L) &&
m_config->Read(_T("Check"), &check, 0L)) m_config->Read(_T("Check"), &check, 0L))
{ {
if (check != CalcCheck(player, myGames, myWins, myScore)) if (check != CalcCheck(player, myGames, myWins, myScore))
{ {
wxMessageBox(_T("Score file corrupted"), _T("Warning"), wxMessageBox(_T("Score file corrupted"), _T("Warning"),
wxOK | wxICON_EXCLAMATION); wxOK | wxICON_EXCLAMATION);
} }
else else
{ {
games = myGames; games = myGames;
wins = myWins; wins = myWins;
score = myScore; score = myScore;
} }
} }
WritePlayersScore(player, wins, games, score); WritePlayersScore(player, wins, games, score);
} }
void ScoreFile::WritePlayersScore(const wxString& player, int wins, int games, int score) void ScoreFile::WritePlayersScore(const wxString& player, int wins, int games, int score)
{ {
if (player) if (player)
{ {
m_config->SetPath(_T("/General")); m_config->SetPath(_T("/General"));
m_config->Write(_T("LastPlayer"), wxString(player)); // Without wxString tmp, thinks it's bool in VC++ m_config->Write(_T("LastPlayer"), wxString(player)); // Without wxString tmp, thinks it's bool in VC++
m_config->SetPath(_T("/Players")); m_config->SetPath(_T("/Players"));
m_config->SetPath(player); m_config->SetPath(player);
m_config->Write(_T("Score"), (long)score); m_config->Write(_T("Score"), (long)score);
m_config->Write(_T("Games"), (long)games); m_config->Write(_T("Games"), (long)games);
m_config->Write(_T("Wins"), (long)wins); m_config->Write(_T("Wins"), (long)wins);
m_config->Write(_T("Check"), CalcCheck(player, games, wins, score)); m_config->Write(_T("Check"), CalcCheck(player, games, wins, score));
} }
} }

View File

@@ -78,14 +78,11 @@ END_EVENT_TABLE()
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent) LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent)
: wxDialog(parent, -1, : wxDialog(parent, wxID_ANY, _("Sample games"),
_("Sample games"), wxDefaultPosition, wxDefaultSize)
wxDefaultPosition,
wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
{ {
m_value = 0; m_value = 0;
// create and populate the list of available samples // create and populate the list of available samples
m_list = new wxListBox( this, ID_LISTBOX, m_list = new wxListBox( this, ID_LISTBOX,
wxDefaultPosition, wxDefaultPosition,
@@ -97,11 +94,11 @@ LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent)
m_list->Append(g_patterns[i].m_name); m_list->Append(g_patterns[i].m_name);
// descriptions // descriptions
wxStaticBox *statbox = new wxStaticBox( this, -1, _("Description")); wxStaticBox *statbox = new wxStaticBox( this, wxID_ANY, _("Description"));
m_life = new Life(); m_life = new Life();
m_life->SetPattern(g_patterns[0]); m_life->SetPattern(g_patterns[0]);
m_canvas = new LifeCanvas( this, m_life, FALSE ); m_canvas = new LifeCanvas( this, m_life, false );
m_text = new wxTextCtrl( this, -1, m_text = new wxTextCtrl( this, wxID_ANY,
g_patterns[0].m_description, g_patterns[0].m_description,
wxDefaultPosition, wxDefaultPosition,
wxSize(300, 60), wxSize(300, 60),
@@ -118,14 +115,13 @@ LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent)
wxBoxSizer *sizer3 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *sizer3 = new wxBoxSizer( wxVERTICAL );
sizer3->Add( CreateTextSizer(_("Select one configuration")), 0, wxALL, 10 ); sizer3->Add( CreateTextSizer(_("Select one configuration")), 0, wxALL, 10 );
sizer3->Add( new wxStaticLine(this, -1), 0, wxGROW | wxLEFT | wxRIGHT, 10 ); sizer3->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 10 );
sizer3->Add( sizer2, 1, wxGROW | wxALL, 5 ); sizer3->Add( sizer2, 1, wxGROW | wxALL, 5 );
sizer3->Add( new wxStaticLine(this, -1), 0, wxGROW | wxLEFT | wxRIGHT, 10 ); sizer3->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 10 );
sizer3->Add( CreateButtonSizer(wxOK | wxCANCEL), 0, wxCENTRE | wxALL, 10 ); sizer3->Add( CreateButtonSizer(wxOK | wxCANCEL), 0, wxCENTRE | wxALL, 10 );
// activate // activate
SetSizer(sizer3); SetSizer(sizer3);
SetAutoLayout(TRUE);
sizer3->SetSizeHints(this); sizer3->SetSizeHints(this);
sizer3->Fit(this); sizer3->Fit(this);
Centre(wxBOTH | wxCENTRE_ON_SCREEN); Centre(wxBOTH | wxCENTRE_ON_SCREEN);
@@ -164,35 +160,31 @@ void LifeSamplesDialog::OnListBox(wxCommandEvent& event)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
LifeAboutDialog::LifeAboutDialog(wxWindow *parent) LifeAboutDialog::LifeAboutDialog(wxWindow *parent)
: wxDialog(parent, -1, : wxDialog(parent, wxID_ANY, _("About Life!"),
_("About Life!"), wxDefaultPosition, wxDefaultSize)
wxDefaultPosition,
wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
{ {
// logo // logo
wxBitmap bmp = wxBITMAP(life); wxBitmap bmp = wxBITMAP(life);
#if !defined(__WXGTK__) && !defined(__WXMOTIF__) && !defined(__WXMAC__) #if !defined(__WXGTK__) && !defined(__WXMOTIF__) && !defined(__WXMAC__)
bmp.SetMask(new wxMask(bmp, *wxBLUE)); bmp.SetMask(new wxMask(bmp, *wxBLUE));
#endif #endif
wxStaticBitmap *sbmp = new wxStaticBitmap(this, -1, bmp); wxStaticBitmap *sbmp = new wxStaticBitmap(this, wxID_ANY, bmp);
// layout components // layout components
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
sizer->Add( sbmp, 0, wxCENTRE | wxALL, 10 ); sizer->Add( sbmp, 0, wxCENTRE | wxALL, 10 );
sizer->Add( new wxStaticLine(this, -1), 0, wxGROW | wxLEFT | wxRIGHT, 5 ); sizer->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 5 );
sizer->Add( CreateTextSizer(_("Life! version 2.2 for wxWidgets\n\n\ sizer->Add( CreateTextSizer(_("Life! version 2.2 for wxWidgets\n\n\
(c) 2000 Guillermo Rodriguez Garcia\n\n\ (c) 2000 Guillermo Rodriguez Garcia\n\n\
<guille@iies.es>\n\n\ <guille@iies.es>\n\n\
Portions of the code are based in XLife;\n\ Portions of the code are based in XLife;\n\
XLife is (c) 1989 by Jon Bennett et al.")), XLife is (c) 1989 by Jon Bennett et al.")),
0, wxCENTRE | wxALL, 20 ); 0, wxCENTRE | wxALL, 20 );
sizer->Add( new wxStaticLine(this, -1), 0, wxGROW | wxLEFT | wxRIGHT, 5 ); sizer->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 5 );
sizer->Add( CreateButtonSizer(wxOK), 0, wxCENTRE | wxALL, 10 ); sizer->Add( CreateButtonSizer(wxOK), 0, wxCENTRE | wxALL, 10 );
// activate // activate
SetSizer(sizer); SetSizer(sizer);
SetAutoLayout(TRUE);
sizer->SetSizeHints(this); sizer->SetSizeHints(this);
sizer->Fit(this); sizer->Fit(this);
Centre(wxBOTH | wxCENTRE_ON_SCREEN); Centre(wxBOTH | wxCENTRE_ON_SCREEN);

View File

@@ -44,7 +44,7 @@ class LifeCanvas : public wxWindow
{ {
public: public:
// ctor and dtor // ctor and dtor
LifeCanvas(wxWindow* parent, Life* life, bool interactive = TRUE); LifeCanvas(wxWindow* parent, Life* life, bool interactive = true);
~LifeCanvas(); ~LifeCanvas();
// view management // view management

View File

@@ -39,7 +39,7 @@ bool MyApp::OnInit(void)
{ {
// Create the main window // Create the main window
#if USE_TABBED_DIALOG #if USE_TABBED_DIALOG
dialog = new MyDialog((wxFrame *) NULL, -1, (char *) "Tabbed Dialog", wxPoint(-1, -1), wxSize(365, 390), wxDIALOG_MODAL|wxDEFAULT_DIALOG_STYLE); dialog = new MyDialog((wxFrame *) NULL, wxID_ANY, (char *) "Tabbed Dialog", wxPoint(-1, -1), wxSize(365, 390));
dialog->ShowModal(); dialog->ShowModal();

View File

@@ -36,7 +36,7 @@ IMPLEMENT_APP(MyApp)
bool MyApp::OnInit(void) bool MyApp::OnInit(void)
{ {
// Create the main frame window // Create the main frame window
dialog = new MyDialog(NULL, wxID_ANY, wxT("wxTaskBarIcon Test Dialog"), wxDefaultPosition, wxSize(365, 290), wxDIALOG_MODELESS|wxDEFAULT_DIALOG_STYLE); dialog = new MyDialog(NULL, wxID_ANY, wxT("wxTaskBarIcon Test Dialog"), wxDefaultPosition, wxSize(365, 290));
dialog->Show(true); dialog->Show(true);

View File

@@ -171,7 +171,7 @@ void MyFrame::OnToggleBell(wxCommandEvent& event)
MyDialog::MyDialog( wxWindow *parent, const wxString& title, MyDialog::MyDialog( wxWindow *parent, const wxString& title,
const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) : const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) :
wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxRESIZE_BORDER) wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
{ {
// Sizers automatically ensure a workable layout. // Sizers automatically ensure a workable layout.
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );

View File

@@ -144,8 +144,7 @@ void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data) bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data)
{ {
if ( !wxDialog::Create(parent, -1, wxT("Colour"), if ( !wxDialog::Create(parent, -1, wxT("Colour"),
wxPoint(0, 0), wxSize(900, 900), wxPoint(0, 0), wxSize(900, 900)) )
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL) )
return FALSE; return FALSE;
dialogParent = parent; dialogParent = parent;

View File

@@ -82,8 +82,7 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
long max, long max,
const wxPoint& pos) const wxPoint& pos)
: wxDialog(parent, -1, caption, : wxDialog(parent, -1, caption,
pos, wxDefaultSize, pos, wxDefaultSize)
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL )
{ {
m_value = value; m_value = value;
m_max = max; m_max = max;

View File

@@ -107,7 +107,6 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
: wxDialog(parent, -1, _("Print"), : wxDialog(parent, -1, _("Print"),
wxPoint(0, 0), wxSize(600, 600), wxPoint(0, 0), wxSize(600, 600),
wxDEFAULT_DIALOG_STYLE | wxDEFAULT_DIALOG_STYLE |
wxDIALOG_MODAL |
wxTAB_TRAVERSAL) wxTAB_TRAVERSAL)
{ {
if ( data ) if ( data )
@@ -121,7 +120,6 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
: wxDialog(parent, -1, _("Print"), : wxDialog(parent, -1, _("Print"),
wxPoint(0, 0), wxSize(600, 600), wxPoint(0, 0), wxSize(600, 600),
wxDEFAULT_DIALOG_STYLE | wxDEFAULT_DIALOG_STYLE |
wxDIALOG_MODAL |
wxTAB_TRAVERSAL) wxTAB_TRAVERSAL)
{ {
if ( data ) if ( data )
@@ -133,7 +131,7 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent)) void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent))
{ {
// wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
// wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL); // wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL);
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
@@ -405,7 +403,7 @@ wxDC *wxGenericPrintDialog::GetPrintDC()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data): wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data):
wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL) wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL)
{ {
Init(data); Init(data);
} }
@@ -598,7 +596,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent,
_("Page Setup"), _("Page Setup"),
wxPoint(0, 0), wxPoint(0, 0),
wxSize(600, 600), wxSize(600, 600),
wxDIALOG_MODAL|wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL ) wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL )
{ {
if (data) if (data)
m_pageData = *data; m_pageData = *data;

View File

@@ -144,8 +144,8 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
if ( maximum > 0 ) if ( maximum > 0 )
{ {
// note that we can't use wxGA_SMOOTH because it happens to also mean // note that we can't use wxGA_SMOOTH because it happens to
// wxDIALOG_MODAL and will cause the dialog to be modal. Have an extra // cause the dialog to be modal. Have an extra
// style argument to wxProgressDialog, perhaps. // style argument to wxProgressDialog, perhaps.
m_gauge = new wxGauge(this, -1, m_maximum, m_gauge = new wxGauge(this, -1, m_maximum,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,

View File

@@ -177,12 +177,6 @@ bool wxDialog::IsModal() const
void wxDialog::SetModal( bool WXUNUSED(flag) ) void wxDialog::SetModal( bool WXUNUSED(flag) )
{ {
/*
if (flag)
m_windowStyle |= wxDIALOG_MODAL;
else
if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL;
*/
wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") ); wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") );
} }

View File

@@ -133,7 +133,7 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message,
m_needParent = FALSE; m_needParent = FALSE;
if (!PreCreation( parent, pos, wxDefaultSize ) || if (!PreCreation( parent, pos, wxDefaultSize ) ||
!CreateBase( parent, -1, pos, wxDefaultSize, style | wxDIALOG_MODAL, wxDefaultValidator, wxT("filedialog") )) !CreateBase( parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("filedialog") ))
{ {
wxFAIL_MSG( wxT("wxXX creation failed") ); wxFAIL_MSG( wxT("wxXX creation failed") );
return; return;

View File

@@ -177,12 +177,6 @@ bool wxDialog::IsModal() const
void wxDialog::SetModal( bool WXUNUSED(flag) ) void wxDialog::SetModal( bool WXUNUSED(flag) )
{ {
/*
if (flag)
m_windowStyle |= wxDIALOG_MODAL;
else
if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL;
*/
wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") ); wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") );
} }

View File

@@ -133,7 +133,7 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message,
m_needParent = FALSE; m_needParent = FALSE;
if (!PreCreation( parent, pos, wxDefaultSize ) || if (!PreCreation( parent, pos, wxDefaultSize ) ||
!CreateBase( parent, -1, pos, wxDefaultSize, style | wxDIALOG_MODAL, wxDefaultValidator, wxT("filedialog") )) !CreateBase( parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("filedialog") ))
{ {
wxFAIL_MSG( wxT("wxXX creation failed") ); wxFAIL_MSG( wxT("wxXX creation failed") );
return; return;