]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/console/console.cpp
Playing with wxgrid, adding optionnally native columns labels
[wxWidgets.git] / samples / console / console.cpp
index a151a12468b12153d868f69bf250b0bd51c37121..4eed13cd22de48d57b14de8658110c64d5983b12 100644 (file)
@@ -27,6 +27,7 @@
 #include "wx/log.h"
 #include "wx/apptrait.h"
 #include "wx/platinfo.h"
+#include "wx/wxchar.h"
 
 // without this pragma, the stupid compiler precompiles #defines below so that
 // changing them doesn't "take place" later!
@@ -69,7 +70,6 @@
     #define TEST_MIME
     #define TEST_MODULE
     #define TEST_PATHLIST
-    #define TEST_ODBC
     #define TEST_PRINTF
     #define TEST_REGCONF
     #define TEST_REGEX
@@ -720,6 +720,24 @@ static void TestFileCopy()
     wxPuts(wxEmptyString);
 }
 
+static void TestTempFile()
+{
+    wxPuts(_T("*** wxTempFile test ***"));
+
+    wxTempFile tmpFile;
+    if ( tmpFile.Open(_T("test2")) && tmpFile.Write(_T("the answer is 42")) )
+    {
+        if ( tmpFile.Commit() )
+            wxPuts(_T("File committed."));
+        else
+            wxPuts(_T("ERROR: could't commit temp file."));
+
+        wxRemoveFile(_T("test2"));
+    }
+
+    wxPuts(wxEmptyString);
+}
+
 #endif // TEST_FILE
 
 // ----------------------------------------------------------------------------
@@ -1364,7 +1382,7 @@ static void TestMimeAssociate()
                             _T(""),             // print cmd
                             _T("XYZ File"),     // description
                             _T(".xyz"),         // extensions
-                            NULL                // end of extensions
+                            wxNullPtr           // end of extensions
                          );
     ftInfo.SetShortDesc(_T("XYZFile")); // used under Win32 only
 
@@ -1640,26 +1658,6 @@ static void TestRegExInteractive()
 
 #endif // TEST_REGEX
 
-// ----------------------------------------------------------------------------
-// database
-// ----------------------------------------------------------------------------
-
-#if !wxUSE_ODBC
-    #undef TEST_ODBC
-#endif
-
-#ifdef TEST_ODBC
-
-#include "wx/db.h"
-
-static void TestDbOpen()
-{
-    HENV henv;
-    wxDb db(henv);
-}
-
-#endif // TEST_ODBC
-
 // ----------------------------------------------------------------------------
 // printf() tests
 // ----------------------------------------------------------------------------
@@ -2766,6 +2764,7 @@ static void TestStackWalk(const char *argv0)
 #ifdef TEST_STDPATHS
 
 #include "wx/stdpaths.h"
+#include "wx/wxchar.h"      // wxPrintf
 
 static void TestStandardPaths()
 {
@@ -2781,6 +2780,7 @@ static void TestStandardPaths()
     wxPrintf(_T("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str());
     wxPrintf(_T("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str());
     wxPrintf(_T("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str());
+    wxPrintf(_T("Executable path:\t%s\n"), stdp.GetExecutablePath().c_str());
     wxPrintf(_T("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir().c_str());
     wxPrintf(_T("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str());
     wxPrintf(_T("Localized res. dir:\t%s\n"),
@@ -2923,6 +2923,52 @@ static void TestStopWatch()
     wxPuts(_T(", ok."));
 }
 
+#include "wx/timer.h"
+#include "wx/evtloop.h"
+
+void TestTimer()
+{
+    wxPuts(_T("*** Testing wxTimer ***\n"));
+
+    class MyTimer : public wxTimer
+    {
+    public:
+        MyTimer() : wxTimer() { m_num = 0; }
+
+        virtual void Notify()
+        {
+            wxPrintf(_T("%d"), m_num++);
+            fflush(stdout);
+
+            if ( m_num == 10 )
+            {
+                wxPrintf(_T("... exiting the event loop"));
+                Stop();
+
+                wxEventLoop::GetActive()->Exit(0);
+                wxPuts(_T(", ok."));
+            }
+
+            fflush(stdout);
+        }
+
+    private:
+        int m_num;
+    };
+
+    wxEventLoop loop;
+
+    wxTimer timer1;
+    timer1.Start(100, true /* one shot */);
+    timer1.Stop();
+    timer1.Start(100, true /* one shot */);
+
+    MyTimer timer;
+    timer.Start(500);
+
+    loop.Run();
+}
+
 #endif // TEST_TIMER
 
 // ----------------------------------------------------------------------------
@@ -4205,19 +4251,19 @@ int main(int argc, char **argv)
 #if wxUSE_CMDLINE_PARSER
     static const wxCmdLineEntryDesc cmdLineDesc[] =
     {
-        { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"),
+        { wxCMD_LINE_SWITCH, "h", "help", "show this help message",
             wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
-        { wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") },
-        { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"),   _T("be quiet") },
+        { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
+        { wxCMD_LINE_SWITCH, "q", "quiet",   "be quiet" },
 
-        { wxCMD_LINE_OPTION, _T("o"), _T("output"),  _T("output file") },
-        { wxCMD_LINE_OPTION, _T("i"), _T("input"),   _T("input dir") },
-        { wxCMD_LINE_OPTION, _T("s"), _T("size"),    _T("output block size"),
+        { wxCMD_LINE_OPTION, "o", "output",  "output file" },
+        { wxCMD_LINE_OPTION, "i", "input",   "input dir" },
+        { wxCMD_LINE_OPTION, "s", "size",    "output block size",
             wxCMD_LINE_VAL_NUMBER },
-        { wxCMD_LINE_OPTION, _T("d"), _T("date"),    _T("output file date"),
+        { wxCMD_LINE_OPTION, "d", "date",    "output file date",
             wxCMD_LINE_VAL_DATE },
 
-        { wxCMD_LINE_PARAM,  NULL, NULL, _T("input file"),
+        { wxCMD_LINE_PARAM,  NULL, NULL, "input file",
             wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
 
         { wxCMD_LINE_NONE }
@@ -4304,6 +4350,7 @@ int main(int argc, char **argv)
     TestFileRead();
     TestTextFileRead();
     TestFileCopy();
+    TestTempFile();
 #endif // TEST_FILE
 
 #ifdef TEST_FILENAME
@@ -4345,12 +4392,10 @@ int main(int argc, char **argv)
 #endif // TEST_FTP
 
 #ifdef TEST_MIME
-    wxLog::AddTraceMask(_T("mime"));
-    #if TEST_ALL
-        TestMimeEnum();
-        TestMimeOverride();
-        TestMimeAssociate();
-    #endif
+    //wxLog::AddTraceMask(_T("mime"));
+    TestMimeEnum();
+    TestMimeOverride();
+    // TestMimeAssociate();
     TestMimeFilename();
 #endif // TEST_MIME
 
@@ -4368,10 +4413,6 @@ int main(int argc, char **argv)
     TestPathList();
 #endif // TEST_PATHLIST
 
-#ifdef TEST_ODBC
-    TestDbOpen();
-#endif // TEST_ODBC
-
 #ifdef TEST_PRINTF
     TestPrintf();
 #endif // TEST_PRINTF
@@ -4429,6 +4470,7 @@ int main(int argc, char **argv)
 
 #ifdef TEST_TIMER
     TestStopWatch();
+    TestTimer();
 #endif // TEST_TIMER
 
 #ifdef TEST_DATETIME