Put dialog in more sensible place in Forty, got a bit further
with running it under wxX11 but still crashes (bad XPM?) Updated wxX11 readme text Added more wxYields to progress dialog Added timer and idle processing to wxApp::Yield for X11 Made busy info dialog thick frame for wxX11, else no decorations Some corrections for Nano-X Made text for busy dialog more sensible in dialogs sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
618f2efa41
commit
868741e9d3
@ -92,7 +92,7 @@ void FortyCanvas::OnDraw(wxDC& dc)
|
||||
{
|
||||
dc.SetFont(* m_font);
|
||||
m_game->Redraw(dc);
|
||||
|
||||
#if 0
|
||||
// if player name not set (and selection dialog is not displayed)
|
||||
// then ask the player for their name
|
||||
if (m_player.Length() == 0 && !m_playerDialog)
|
||||
@ -117,8 +117,40 @@ void FortyCanvas::OnDraw(wxDC& dc)
|
||||
((wxFrame*)GetParent())->Close(TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FortyCanvas::ShowPlayerDialog()
|
||||
{
|
||||
// if player name not set (and selection dialog is not displayed)
|
||||
// then ask the player for their name
|
||||
if (m_player.Length() == 0 && !m_playerDialog)
|
||||
{
|
||||
m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile);
|
||||
m_playerDialog->ShowModal();
|
||||
m_player = m_playerDialog->GetPlayersName();
|
||||
if (m_player.Length() > 0)
|
||||
{
|
||||
// user entered a name - lookup their score
|
||||
int wins, games, score;
|
||||
m_scoreFile->ReadPlayersScore(m_player, wins, games, score);
|
||||
m_game->NewPlayer(wins, games, score);
|
||||
|
||||
wxClientDC dc(this);
|
||||
dc.SetFont(* m_font);
|
||||
m_game->DisplayScore(dc);
|
||||
m_playerDialog->Destroy();
|
||||
m_playerDialog = 0;
|
||||
Refresh(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// user cancelled the dialog - exit the app
|
||||
((wxFrame*)GetParent())->Close(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the main frame is closed
|
||||
*/
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
void EnableHelpingHand(bool enable) { m_helpingHand = enable; }
|
||||
void EnableRightButtonUndo(bool enable) { m_rightBtnUndo = enable; }
|
||||
void LayoutGame();
|
||||
void ShowPlayerDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
|
@ -31,40 +31,6 @@
|
||||
#include "forty.h"
|
||||
#include "card.h"
|
||||
#include "scoredg.h"
|
||||
#ifdef wx_x
|
||||
#include "cards.xbm"
|
||||
#endif
|
||||
|
||||
class FortyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards);
|
||||
virtual ~FortyFrame();
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// Menu callbacks
|
||||
void NewGame(wxCommandEvent& event);
|
||||
void Exit(wxCommandEvent& event);
|
||||
void About(wxCommandEvent& event);
|
||||
void Undo(wxCommandEvent& event);
|
||||
void Redo(wxCommandEvent& event);
|
||||
void Scores(wxCommandEvent& event);
|
||||
void ToggleRightButtonUndo(wxCommandEvent& event);
|
||||
void ToggleHelpingHand(wxCommandEvent& event);
|
||||
void ToggleCardSize(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
enum MenuCommands { NEW_GAME = 10, SCORES, EXIT,
|
||||
UNDO, REDO,
|
||||
RIGHT_BUTTON_UNDO, HELPING_HAND, LARGE_CARDS,
|
||||
ABOUT };
|
||||
|
||||
wxMenuBar* m_menuBar;
|
||||
FortyCanvas* m_canvas;
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(FortyFrame, wxFrame)
|
||||
EVT_MENU(NEW_GAME, FortyFrame::NewGame)
|
||||
@ -106,6 +72,8 @@ bool FortyApp::OnInit()
|
||||
// Show the frame
|
||||
frame->Show(TRUE);
|
||||
|
||||
frame->GetCanvas()->ShowPlayerDialog();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -28,4 +28,38 @@ private:
|
||||
static wxBrush* m_backgroundBrush;
|
||||
};
|
||||
|
||||
class FortyCanvas;
|
||||
class FortyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
FortyFrame(wxFrame* frame, char* title, int x, int y, int w, int h,bool largecards);
|
||||
virtual ~FortyFrame();
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// Menu callbacks
|
||||
void NewGame(wxCommandEvent& event);
|
||||
void Exit(wxCommandEvent& event);
|
||||
void About(wxCommandEvent& event);
|
||||
void Undo(wxCommandEvent& event);
|
||||
void Redo(wxCommandEvent& event);
|
||||
void Scores(wxCommandEvent& event);
|
||||
void ToggleRightButtonUndo(wxCommandEvent& event);
|
||||
void ToggleHelpingHand(wxCommandEvent& event);
|
||||
void ToggleCardSize(wxCommandEvent& event);
|
||||
|
||||
FortyCanvas* GetCanvas() { return m_canvas; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
enum MenuCommands { NEW_GAME = 10, SCORES, EXIT,
|
||||
UNDO, REDO,
|
||||
RIGHT_BUTTON_UNDO, HELPING_HAND, LARGE_CARDS,
|
||||
ABOUT };
|
||||
|
||||
wxMenuBar* m_menuBar;
|
||||
FortyCanvas* m_canvas;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <string.h>
|
||||
#include "card.h"
|
||||
#include "pile.h"
|
||||
#include "forty.h"
|
||||
#include "canvas.h"
|
||||
|
||||
#include "wx/app.h"
|
||||
|
||||
@ -75,12 +77,11 @@ Pile::Pile(int x, int y, int dx, int dy)
|
||||
//+-------------------------------------------------------------+
|
||||
void Pile::Redraw(wxDC& dc )
|
||||
{
|
||||
wxWindow *frame = wxTheApp->GetTopWindow();
|
||||
FortyFrame *frame = (FortyFrame*) wxTheApp->GetTopWindow();
|
||||
wxWindow *canvas = (wxWindow *) NULL;
|
||||
if (frame)
|
||||
{
|
||||
wxNode *node = frame->GetChildren().First();
|
||||
if (node) canvas = (wxWindow*)node->Data();
|
||||
canvas = frame->GetCanvas();
|
||||
}
|
||||
|
||||
if (m_topCard >= 0)
|
||||
|
@ -16,7 +16,7 @@ IMPORTANT NOTE:
|
||||
First steps
|
||||
-----------
|
||||
|
||||
- Download wxX11-x.y.z.tgz, where x.y.z is the version number.
|
||||
- Download wxWindows-X-x.y.z.tgz, where x.y.z is the version number.
|
||||
Download documentation in a preferred format, such as
|
||||
wxWindows-HTML.zip or wxWindows-PDF.zip.
|
||||
|
||||
|
@ -34,9 +34,10 @@ Alternatively, you may also use the bug reporting system
|
||||
linked from the wxWindows web page.
|
||||
|
||||
The library produced by the install process will be called
|
||||
libwx_x11.a (static) and libwx_x11-2.3.so.0.0.0 (shared) so that
|
||||
once a binary incompatible version of wxWindows/X11 comes out
|
||||
we'll augment the library version number to avoid linking problems.
|
||||
libwx_x11univ[d].a (static) and libwx_x11univ[d]-2.3.so.0.0.0
|
||||
(shared) so that once a binary incompatible version of
|
||||
wxWindows/X11 comes out we'll augment the library version number
|
||||
to avoid linking problems.
|
||||
|
||||
Please send problems concerning installation, feature requests,
|
||||
bug reports or comments to the wxWindows users list. Information
|
||||
@ -49,9 +50,20 @@ suitable for any special or general purpose.
|
||||
Status
|
||||
======
|
||||
|
||||
This is new port and doesn't yet compile, but do please join in
|
||||
and help. It's actually quite a simple port since most of the hard work
|
||||
is done by the wxUniversal widgets.
|
||||
Many of the samples are running.
|
||||
|
||||
Some remaining issues:
|
||||
|
||||
- some refresh efficiency issues
|
||||
- progress dialog not working (see dialogs sample)
|
||||
- clipboard implementation missing
|
||||
- drag and drop implementation missing
|
||||
- wxToggleButton implementation missing
|
||||
- wxSpinCtrl implementation missing
|
||||
- tooltips implementation missing
|
||||
- code common to the Motif and X11 ports needs to be
|
||||
merged
|
||||
- need thread safety in event loop
|
||||
|
||||
Regards,
|
||||
|
||||
|
@ -662,7 +662,7 @@ void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxWindowDisabler disableAll;
|
||||
|
||||
wxBusyInfo info("Sleep^H^H^H^H^HWorkiing, please wait...", this);
|
||||
wxBusyInfo info("Working, please wait...", this);
|
||||
|
||||
for ( int i = 0; i < 30; i++ )
|
||||
{
|
||||
|
@ -25,9 +25,13 @@
|
||||
|
||||
|
||||
wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
|
||||
: wxFrame(parent, -1, wxT(""),
|
||||
: wxFrame(parent, -1, wxT("Busy"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
#if defined(__WXX11__)
|
||||
wxTHICK_FRAME | wxFRAME_TOOL_WINDOW)
|
||||
#else
|
||||
wxSIMPLE_BORDER | wxFRAME_TOOL_WINDOW)
|
||||
#endif
|
||||
{
|
||||
wxPanel *panel = new wxPanel( this );
|
||||
wxStaticText *text = new wxStaticText(panel, -1, message);
|
||||
|
@ -270,6 +270,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
|
||||
|
||||
// Update the display (especially on X, GTK)
|
||||
wxYield();
|
||||
wxYield();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
MacUpdateImmediately();
|
||||
@ -330,6 +331,7 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
||||
m_msg->SetLabel(newmsg);
|
||||
|
||||
wxYield();
|
||||
wxYield();
|
||||
}
|
||||
|
||||
if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
|
||||
@ -368,6 +370,7 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
||||
m_msg->SetLabel(_("Done."));
|
||||
}
|
||||
|
||||
wxYield();
|
||||
wxYield();
|
||||
|
||||
(void)ShowModal();
|
||||
@ -382,6 +385,7 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
||||
{
|
||||
// update the display
|
||||
wxYield();
|
||||
wxYield();
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/timer.h"
|
||||
|
||||
#include "wx/univ/theme.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
@ -993,6 +994,11 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
||||
while (wxTheApp && wxTheApp->Pending())
|
||||
wxTheApp->Dispatch();
|
||||
|
||||
#if wxUSE_TIMER
|
||||
wxTimer::NotifyTimers();
|
||||
#endif
|
||||
ProcessIdle();
|
||||
|
||||
s_inYield = FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
@ -1375,7 +1375,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
slen = strlen(text);
|
||||
XCharStruct overall_return;
|
||||
|
||||
(void)XTextExtents(xfont, text.c_str(), slen, &direction,
|
||||
(void)XTextExtents(xfont, (char*) text.c_str(), slen, &direction,
|
||||
&ascent, &descent, &overall_return);
|
||||
|
||||
cx = overall_return.width;
|
||||
|
@ -239,6 +239,16 @@ bool wxEventLoop::Dispatch()
|
||||
|
||||
if (XPending((Display*) wxGetDisplay()) == 0)
|
||||
{
|
||||
#if wxUSE_NANOX
|
||||
GR_TIMEOUT timeout = 10; // Milliseconds
|
||||
// Wait for next event, or timeout
|
||||
GrGetNextEventTimeout(& event, timeout);
|
||||
|
||||
// Fall through to ProcessEvent.
|
||||
// we'll assume that ProcessEvent will just ignore
|
||||
// the event if there was a timeout and no event.
|
||||
|
||||
#else
|
||||
struct timeval tv;
|
||||
tv.tv_sec=0;
|
||||
tv.tv_usec=10000; // TODO make this configurable
|
||||
@ -256,6 +266,7 @@ bool wxEventLoop::Dispatch()
|
||||
// An event was pending, so get it
|
||||
XNextEvent((Display*) wxGetDisplay(), & event);
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
XNextEvent((Display*) wxGetDisplay(), & event);
|
||||
|
@ -856,7 +856,7 @@ void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
|
||||
|
||||
wxCHECK_RET( xwindow, wxT("invalid window") );
|
||||
|
||||
#if 1
|
||||
#if !wxUSE_NANOX
|
||||
|
||||
XWindowAttributes attr;
|
||||
Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
|
||||
|
Loading…
Reference in New Issue
Block a user