]> git.saurik.com Git - wxWidgets.git/commitdiff
Put dialog in more sensible place in Forty, got a bit further
authorJulian Smart <julian@anthemion.co.uk>
Thu, 21 Mar 2002 13:10:17 +0000 (13:10 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 21 Mar 2002 13:10:17 +0000 (13:10 +0000)
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

14 files changed:
demos/forty/canvas.cpp
demos/forty/canvas.h
demos/forty/forty.cpp
demos/forty/forty.h
demos/forty/pile.cpp
docs/x11/install.txt
docs/x11/readme.txt
samples/dialogs/dialogs.cpp
src/generic/busyinfo.cpp
src/generic/progdlgg.cpp
src/x11/app.cpp
src/x11/dcclient.cpp
src/x11/evtloop.cpp
src/x11/window.cpp

index 705e949612a971894c43ac598a35b4b0d4885466..ef3ae68b825b72f07fe7f9e5da4975e5beeaa25a 100644 (file)
@@ -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
 */
index 02a65fe385dc39c7facc395a71814aadc8041918..28ef41f1c6e5318dda62f40589ef0973ce4612be 100644 (file)
@@ -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()
 
index a2a1cd4c5bac2a677fc5947533c0e8302f62668f..fbf0f1c546471b007f16c14a7b39357b105eee16 100644 (file)
 #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;
 }
 
index 1fbf6449f150008857b6cd825f264b6ead624584..f3f36baee8c5403f842dd5385070a2beba7dc2f1 100644 (file)
@@ -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
index 4622829964ff0846062289f4ff76fbbe2b52a093..34796835c164503f4bea7a7a7c0219856a279ce8 100644 (file)
@@ -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)
index 4d8e8ac9dc10a535d01af9d4c255eadd680d9609..44e0c95391d2bb7da20c293257bfa01ac3d1d8bc 100644 (file)
@@ -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.
 
index 5c49da7398715ec2fcd3bfc6fdb84145cb5ff894..60e1a43969b674209dc7e1f5f2bcc062d3753338 100644 (file)
@@ -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,
 
index 57cc5bed8d3af89986fa490a2f1df8ad366438b9..5f883f69dffdbdc92e7fdd25f4814b972be40303 100644 (file)
@@ -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++ )
     {
index ce2e3a45d00466acf3acf23b264eaf22d981315c..884318fbe736c86d74ea3b2bbd296d6d674e262d 100644 (file)
 
 
 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);
index 2730fb4d4abe4857540f2a0bfa35f0b1224501a2..ee2f457eff13fd883a7358f6c024168096b73f7e 100644 (file)
@@ -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__
index 8176837135dd6888b9e4ba2e9356e606d55e16f5..165942382a5b571b75974d16365222476484e550 100644 (file)
@@ -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;
index 8307fe264c847e11bceead70b8b456125282aa27..c6c808c37601f1fae95b748e78ecbf2656863f4f 100644 (file)
@@ -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;
index 10c61e19b555b964792d3412448726fb71a74059..15e344b6f0ffed8833f2d7abf3be46a8756fa0ee 100644 (file)
@@ -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);
index 5724880368b341e4de0454ec6e765b47bd839086..7568f13c88bdbea196311864151f52842ebf57d3 100644 (file)
@@ -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 );