From 868741e9d30e1b62e8ee27614543e8ae820fd15d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 21 Mar 2002 13:10:17 +0000 Subject: [PATCH] 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 --- demos/forty/canvas.cpp | 34 +++++++++++++++++++++++++++++++++- demos/forty/canvas.h | 1 + demos/forty/forty.cpp | 36 ++---------------------------------- demos/forty/forty.h | 34 ++++++++++++++++++++++++++++++++++ demos/forty/pile.cpp | 7 ++++--- docs/x11/install.txt | 2 +- docs/x11/readme.txt | 24 ++++++++++++++++++------ samples/dialogs/dialogs.cpp | 2 +- src/generic/busyinfo.cpp | 6 +++++- src/generic/progdlgg.cpp | 4 ++++ src/x11/app.cpp | 6 ++++++ src/x11/dcclient.cpp | 2 +- src/x11/evtloop.cpp | 11 +++++++++++ src/x11/window.cpp | 2 +- 14 files changed, 122 insertions(+), 49 deletions(-) diff --git a/demos/forty/canvas.cpp b/demos/forty/canvas.cpp index 705e949612..ef3ae68b82 100644 --- a/demos/forty/canvas.cpp +++ b/demos/forty/canvas.cpp @@ -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 */ diff --git a/demos/forty/canvas.h b/demos/forty/canvas.h index 02a65fe385..28ef41f1c6 100644 --- a/demos/forty/canvas.h +++ b/demos/forty/canvas.h @@ -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() diff --git a/demos/forty/forty.cpp b/demos/forty/forty.cpp index a2a1cd4c5b..fbf0f1c546 100644 --- a/demos/forty/forty.cpp +++ b/demos/forty/forty.cpp @@ -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; } diff --git a/demos/forty/forty.h b/demos/forty/forty.h index 1fbf6449f1..f3f36baee8 100644 --- a/demos/forty/forty.h +++ b/demos/forty/forty.h @@ -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 diff --git a/demos/forty/pile.cpp b/demos/forty/pile.cpp index 4622829964..34796835c1 100644 --- a/demos/forty/pile.cpp +++ b/demos/forty/pile.cpp @@ -40,6 +40,8 @@ #include #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) diff --git a/docs/x11/install.txt b/docs/x11/install.txt index 4d8e8ac9dc..44e0c95391 100644 --- a/docs/x11/install.txt +++ b/docs/x11/install.txt @@ -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. diff --git a/docs/x11/readme.txt b/docs/x11/readme.txt index 5c49da7398..60e1a43969 100644 --- a/docs/x11/readme.txt +++ b/docs/x11/readme.txt @@ -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, diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 57cc5bed8d..5f883f69df 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -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++ ) { diff --git a/src/generic/busyinfo.cpp b/src/generic/busyinfo.cpp index ce2e3a45d0..884318fbe7 100644 --- a/src/generic/busyinfo.cpp +++ b/src/generic/busyinfo.cpp @@ -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); diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 2730fb4d4a..ee2f457eff 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -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__ diff --git a/src/x11/app.cpp b/src/x11/app.cpp index 8176837135..165942382a 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -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; diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 8307fe264c..c6c808c376 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -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; diff --git a/src/x11/evtloop.cpp b/src/x11/evtloop.cpp index 10c61e19b5..15e344b6f0 100644 --- a/src/x11/evtloop.cpp +++ b/src/x11/evtloop.cpp @@ -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); diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 5724880368..7568f13c88 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -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 ); -- 2.45.2