second merge of the 2.2 branch (RL)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7973 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,11 +37,11 @@
|
||||
|
||||
//#define TEST_ARRAYS
|
||||
//#define TEST_CMDLINE
|
||||
#define TEST_DATETIME
|
||||
//#define TEST_DATETIME
|
||||
//#define TEST_DIR
|
||||
//#define TEST_DLLLOADER
|
||||
//#define TEST_EXECUTE
|
||||
//#define TEST_FILE
|
||||
#define TEST_FILE
|
||||
//#define TEST_FILECONF
|
||||
//#define TEST_HASH
|
||||
//#define TEST_LIST
|
||||
@@ -53,9 +53,10 @@
|
||||
//#define TEST_STRINGS
|
||||
//#define TEST_THREADS
|
||||
//#define TEST_TIMER
|
||||
//#define TEST_VCARD
|
||||
//#define TEST_VCARD -- don't enable this (VZ)
|
||||
//#define TEST_WCHAR
|
||||
//#define TEST_ZIP
|
||||
//#define TEST_ZLIB
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class for container objects
|
||||
@@ -367,7 +368,7 @@ static void TestFileRead()
|
||||
|
||||
puts("File dump:\n----------");
|
||||
|
||||
static const size_t len = 1024;
|
||||
static const off_t len = 1024;
|
||||
char buf[len];
|
||||
for ( ;; )
|
||||
{
|
||||
@@ -403,6 +404,24 @@ static void TestTextFileRead()
|
||||
{
|
||||
printf("Number of lines: %u\n", file.GetLineCount());
|
||||
printf("Last line: '%s'\n", file.GetLastLine().c_str());
|
||||
|
||||
wxString s;
|
||||
|
||||
puts("\nDumping the entire file:");
|
||||
for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() )
|
||||
{
|
||||
printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
|
||||
}
|
||||
printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
|
||||
|
||||
puts("\nAnd now backwards:");
|
||||
for ( s = file.GetLastLine();
|
||||
file.GetCurrentLine() != 0;
|
||||
s = file.GetPrevLine() )
|
||||
{
|
||||
printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
|
||||
}
|
||||
printf("%6u: %s\n", file.GetCurrentLine() + 1, s.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1643,6 +1662,58 @@ static void TestZipStreamRead()
|
||||
|
||||
#endif // TEST_ZIP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ZLIB stream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_ZLIB
|
||||
|
||||
#include <wx/zstream.h>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
static const wxChar *FILENAME_GZ = _T("test.gz");
|
||||
static const char *TEST_DATA = "hello and hello again";
|
||||
|
||||
static void TestZlibStreamWrite()
|
||||
{
|
||||
puts("*** Testing Zlib stream reading ***\n");
|
||||
|
||||
wxFileOutputStream fileOutStream(FILENAME_GZ);
|
||||
wxZlibOutputStream ostr(fileOutStream, 0);
|
||||
printf("Compressing the test string... ");
|
||||
ostr.Write(TEST_DATA, sizeof(TEST_DATA));
|
||||
if ( !ostr )
|
||||
{
|
||||
puts("(ERROR: failed)");
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("(ok)");
|
||||
}
|
||||
|
||||
puts("\n----- done ------");
|
||||
}
|
||||
|
||||
static void TestZlibStreamRead()
|
||||
{
|
||||
puts("*** Testing Zlib stream reading ***\n");
|
||||
|
||||
wxFileInputStream fileInStream(FILENAME_GZ);
|
||||
wxZlibInputStream istr(fileInStream);
|
||||
printf("Archive size: %u\n", istr.GetSize());
|
||||
|
||||
puts("Dumping the file:");
|
||||
while ( !istr.Eof() )
|
||||
{
|
||||
putchar(istr.GetC());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
puts("\n----- done ------");
|
||||
}
|
||||
|
||||
#endif // TEST_ZLIB
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// date time
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -2484,7 +2555,25 @@ static void TestTimeMS()
|
||||
|
||||
printf("Now = %s\n", dt1.Format("%H:%M:%S:%l").c_str());
|
||||
printf("UNow = %s\n", dt2.Format("%H:%M:%S:%l").c_str());
|
||||
printf("Difference is %s\n", (dt2 - dt1).Format("%l").c_str());
|
||||
printf("Dummy loop: ");
|
||||
for ( int i = 0; i < 6000; i++ )
|
||||
{
|
||||
//for ( int j = 0; j < 10; j++ )
|
||||
{
|
||||
wxString s;
|
||||
s.Printf("%g", sqrt(i));
|
||||
}
|
||||
|
||||
if ( !(i % 100) )
|
||||
putchar('.');
|
||||
}
|
||||
puts(", done");
|
||||
|
||||
dt1 = dt2;
|
||||
dt2 = wxDateTime::UNow();
|
||||
printf("UNow = %s\n", dt2.Format("%H:%M:%S:%l").c_str());
|
||||
|
||||
printf("Loop executed in %s ms\n", (dt2 - dt1).Format("%l").c_str());
|
||||
|
||||
puts("\n*** done ***");
|
||||
}
|
||||
@@ -3434,7 +3523,8 @@ int main(int argc, char **argv)
|
||||
#endif // TEST_LOG
|
||||
|
||||
#ifdef TEST_FILE
|
||||
TestFileRead();
|
||||
if ( 0 )
|
||||
TestFileRead();
|
||||
TestTextFileRead();
|
||||
#endif // TEST_FILE
|
||||
|
||||
@@ -3524,10 +3614,10 @@ int main(int argc, char **argv)
|
||||
TestTimeArithmetics();
|
||||
TestTimeHolidays();
|
||||
TestTimeFormat();
|
||||
TestTimeMS();
|
||||
|
||||
TestTimeZoneBug();
|
||||
}
|
||||
TestTimeMS();
|
||||
if ( 0 )
|
||||
TestInteractive();
|
||||
#endif // TEST_DATETIME
|
||||
@@ -3546,6 +3636,12 @@ int main(int argc, char **argv)
|
||||
TestZipStreamRead();
|
||||
#endif // TEST_ZIP
|
||||
|
||||
#ifdef TEST_ZLIB
|
||||
if ( 0 )
|
||||
TestZlibStreamWrite();
|
||||
TestZlibStreamRead();
|
||||
#endif // TEST_ZLIB
|
||||
|
||||
wxUninitialize();
|
||||
|
||||
return 0;
|
||||
|
@@ -308,7 +308,7 @@ bool MyApp::OnInit()
|
||||
// parse the cmd line
|
||||
int x = 50,
|
||||
y = 50;
|
||||
if ( argc == 2 )
|
||||
if ( argc == 3 )
|
||||
{
|
||||
wxSscanf(argv[1], "%d", &x);
|
||||
wxSscanf(argv[2], "%d", &y);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -20,9 +20,11 @@
|
||||
enum DialogModes {mView,mCreate,mEdit,mSearch};
|
||||
|
||||
// ID for the menu quit command
|
||||
#define FILE_CREATE 100
|
||||
#define FILE_EXIT 199
|
||||
#define EDIT_PARAMETERS 200
|
||||
#define FILE_CREATE 100
|
||||
#define FILE_RECREATE_TABLE 110
|
||||
#define FILE_RECREATE_INDEXES 120
|
||||
#define FILE_EXIT 199
|
||||
#define EDIT_PARAMETERS 200
|
||||
#define ABOUT_DEMO 300
|
||||
|
||||
// this seems to be missing, Robert Roebling (?)
|
||||
@@ -129,11 +131,13 @@ class DatabaseDemoFrame: public wxFrame
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnCreate(wxCommandEvent& event);
|
||||
void OnRecreateTable(wxCommandEvent& event);
|
||||
void OnRecreateIndexes(wxCommandEvent& event);
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnEditParameters(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
void CreateDataTable();
|
||||
void CreateDataTable(bool recreate);
|
||||
void BuildEditorDialog();
|
||||
void BuildParameterDialog(wxWindow *parent);
|
||||
|
||||
@@ -147,8 +151,8 @@ DECLARE_EVENT_TABLE()
|
||||
class CeditorDlg : public wxPanel
|
||||
{
|
||||
private:
|
||||
bool widgetPtrsSet;
|
||||
wxString saveName;
|
||||
bool widgetPtrsSet;
|
||||
wxString saveName;
|
||||
|
||||
// Pointers to all widgets on the dialog
|
||||
wxButton *pCreateBtn, *pEditBtn, *pDeleteBtn, *pCopyBtn, *pSaveBtn, *pCancelBtn;
|
||||
@@ -163,8 +167,9 @@ class CeditorDlg : public wxPanel
|
||||
wxStaticText *pNativeLangMsg;
|
||||
|
||||
public:
|
||||
enum DialogModes mode;
|
||||
Ccontact *Contact; // this is the table object that will be being manipulated
|
||||
bool initialized;
|
||||
enum DialogModes mode;
|
||||
Ccontact *Contact; // this is the table object that will be being manipulated
|
||||
|
||||
CeditorDlg(wxWindow *parent);
|
||||
|
||||
@@ -173,6 +178,7 @@ class CeditorDlg : public wxPanel
|
||||
void OnCommand(wxWindow& win, wxCommandEvent& event);
|
||||
void OnActivate(bool) {}; // necessary for hot keys
|
||||
|
||||
bool Initialize();
|
||||
void FieldsEditable();
|
||||
void SetMode(enum DialogModes m);
|
||||
bool PutData();
|
||||
@@ -343,7 +349,7 @@ class CqueryDlg : public wxDialog
|
||||
wxStaticBox *pQueryHintGrp;
|
||||
wxStaticText *pQueryHintMsg;
|
||||
|
||||
wxTextCtrl *pFocusTxt;
|
||||
wxTextCtrl *pFocusTxt;
|
||||
|
||||
CqueryDlg(wxWindow *parent, wxDb *pDb, char *tblName[], char *pWhereArg);
|
||||
~CqueryDlg();
|
||||
|
@@ -93,9 +93,10 @@ const int LISTDB_NO_SPACES_BETWEEN_COLS = 3;
|
||||
* NOTE: The value returned by this function is for temporary use only and
|
||||
* should be copied for long term use
|
||||
*/
|
||||
char *GetExtendedDBErrorMsg2(char *ErrFile, int ErrLine)
|
||||
const char *GetExtendedDBErrorMsg2(char *ErrFile, int ErrLine)
|
||||
{
|
||||
static wxString msg;
|
||||
msg = "";
|
||||
|
||||
wxString tStr;
|
||||
|
||||
@@ -128,12 +129,15 @@ char *GetExtendedDBErrorMsg2(char *ErrFile, int ErrLine)
|
||||
msg.Append(pDbList->PtrDb->errorList[i]);
|
||||
if (wxStrcmp(pDbList->PtrDb->errorList[i],"") != 0)
|
||||
msg.Append("\n");
|
||||
// Clear the errmsg buffer so the next error will not
|
||||
// end up showing the previous error that have occurred
|
||||
wxStrcpy(pDbList->PtrDb->errorList[i],"");
|
||||
}
|
||||
}
|
||||
}
|
||||
msg += "\n";
|
||||
|
||||
return (char*) (const char*) msg;
|
||||
return /*(char*) (const char*) msg*/msg.c_str();
|
||||
} // GetExtendedDBErrorMsg
|
||||
|
||||
|
||||
@@ -407,8 +411,10 @@ void ClookUpDlg::OnClose(wxCloseEvent& event)
|
||||
if (lookup2)
|
||||
delete lookup2;
|
||||
|
||||
SetReturnCode(1);
|
||||
|
||||
while (wxIsBusy()) wxEndBusyCursor();
|
||||
event.Skip();
|
||||
event.Skip();
|
||||
|
||||
// return TRUE;
|
||||
|
||||
|
@@ -304,7 +304,7 @@ void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
|
||||
void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString pwd = wxGetPasswordFromUser("Enter password:",
|
||||
"Passowrd entry dialog",
|
||||
"Password entry dialog",
|
||||
"",
|
||||
this);
|
||||
if ( !!pwd )
|
||||
|
@@ -367,7 +367,8 @@ MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent )
|
||||
|
||||
void MyCanvas::DrawTestPoly( int x, int y,wxDC &dc,int transparent )
|
||||
{
|
||||
wxBrush* brush4 = new wxBrush(*gs_bmp4);
|
||||
// wxBrush* brush4 = new wxBrush(*gs_bmp4);
|
||||
wxBrush* brush4 = new wxBrush(*wxBLACK,wxFDIAGONAL_HATCH);
|
||||
wxBrush* brush4_mono = new wxBrush(*gs_bmp4_mono);
|
||||
wxBrush* brush36 = new wxBrush(*gs_bmp36);
|
||||
|
||||
@@ -1015,6 +1016,7 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
|
||||
m_owner->PrepareDC(dc);
|
||||
|
||||
dc.SetBackgroundMode( m_owner->m_backgroundMode );
|
||||
@@ -1080,6 +1082,13 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
||||
case Show_Ops:
|
||||
DrawWithLogicalOps(dc);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
dc.SetPen( *wxBLACK_PEN );
|
||||
dc.DrawLine( 0,0,100,100 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,12 +1229,12 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnShow(wxCommandEvent& event)
|
||||
{
|
||||
m_canvas->Show((ScreenToShow)(event.GetInt() - MenuShow_First));
|
||||
m_canvas->Show((ScreenToShow)(event.GetId() - MenuShow_First));
|
||||
}
|
||||
|
||||
void MyFrame::OnOption(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetInt())
|
||||
switch (event.GetId())
|
||||
{
|
||||
case MapMode_Text:
|
||||
m_mapMode = wxMM_TEXT;
|
||||
|
Binary file not shown.
@@ -47,7 +47,9 @@ class MyFrame: public wxFrame
|
||||
public:
|
||||
MyFrame();
|
||||
|
||||
virtual ~MyFrame() { delete m_menu; }
|
||||
virtual ~MyFrame();
|
||||
|
||||
void LogMenuEvent(const wxCommandEvent& event);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
@@ -88,6 +90,25 @@ private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// A small helper class which intercepts all menu events and logs them
|
||||
class MyEvtHandler : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
MyEvtHandler(MyFrame *frame) { m_frame = frame; }
|
||||
|
||||
void OnMenuEvent(wxCommandEvent& event)
|
||||
{
|
||||
m_frame->LogMenuEvent(event);
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
private:
|
||||
MyFrame *m_frame;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -164,6 +185,10 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_RIGHT_DOWN(MyFrame::OnRightDown)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler)
|
||||
EVT_MENU(-1, MyEvtHandler::OnMenuEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
@@ -202,7 +227,7 @@ MyFrame::MyFrame()
|
||||
m_menu = NULL;
|
||||
m_countDummy = 0;
|
||||
|
||||
CreateStatusBar();
|
||||
CreateStatusBar(2);
|
||||
|
||||
// create the menubar
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
@@ -267,6 +292,17 @@ MyFrame::MyFrame()
|
||||
|
||||
// associate the menu bar with the frame
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
// intercept all menu events and log them in this custom event handler
|
||||
PushEventHandler(new MyEvtHandler(this));
|
||||
}
|
||||
|
||||
MyFrame::~MyFrame()
|
||||
{
|
||||
delete m_menu;
|
||||
|
||||
// delete the event handler installed in ctor
|
||||
PopEventHandler(TRUE);
|
||||
}
|
||||
|
||||
wxMenu *MyFrame::CreateDummyMenu(wxString *title)
|
||||
@@ -302,6 +338,23 @@ wxMenuItem *MyFrame::GetLastMenuItem() const
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::LogMenuEvent(const wxCommandEvent& event)
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxString msg = wxString::Format("Menu command %d", id);
|
||||
if ( GetMenuBar()->FindItem(id)->IsCheckable() )
|
||||
{
|
||||
msg += wxString::Format(" (the item is currently %schecked)",
|
||||
event.IsChecked() ? "" : "not ");
|
||||
}
|
||||
|
||||
SetStatusText(msg, 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// menu callbacks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close(TRUE);
|
||||
|
Reference in New Issue
Block a user