X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/70d26c3f4ffb24d50457d405c9595fd23f9e5b7c..cc20da41278e57396bda09f540fc649663b8ded8:/demos/poem/wxpoem.cpp diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index 2a2d89c031..09e02e2769 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -33,7 +33,7 @@ #include "wxpoem.h" -#if defined(__WXGTK__) || defined(__WXMOTIF__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXX11__) #include "corner1.xpm" #include "corner2.xpm" #include "corner3.xpm" @@ -206,7 +206,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) dc->SetFont(* NormalFont); long xx; long yy; - dc->GetTextExtent("X", &xx, &yy); + dc->GetTextExtent(_T("X"), &xx, &yy); char_height = (int)yy; if (current_page == 0) @@ -236,7 +236,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) while (ch != 0 && !page_break) { j = 0; -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) while (((ch = poem_buffer[i]) != 13) && (ch != 0)) #else while (((ch = poem_buffer[i]) != 10) && (ch != 0)) @@ -247,7 +247,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) i ++; } -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) if (ch == 13) #else if (ch == 10) @@ -255,7 +255,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) { ch = -1; i ++; -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) // Add another to skip the linefeed i ++; #endif @@ -650,7 +650,7 @@ bool MyApp::OnInit() Corner3 = new wxIcon("icon_3"); Corner4 = new wxIcon("icon_4"); #endif -#if defined(__WXGTK__) || defined(__WXMOTIF__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXX11__) Corner1 = new wxIcon( corner1_xpm ); Corner2 = new wxIcon( corner2_xpm ); Corner3 = new wxIcon( corner3_xpm ); @@ -680,10 +680,16 @@ int MyApp::OnExit() delete Corner3; delete Corner4; + // Causes crash since they're deleted by the global font list +#if 0 delete NormalFont; delete BoldFont; delete ItalicFont; - delete poem_buffer; +#endif + + delete[] poem_buffer; + if (search_string) + delete[] search_string; return 0; } @@ -721,9 +727,12 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) int xx, yy; TheMainWindow->GetClientSize(&xx, &yy); + dc.DrawBitmap(* backingBitmap, 0, 0); +#if 0 wxMemoryDC memDC; memDC.SelectObject(* backingBitmap); dc.Blit(0, 0, backingBitmap->GetWidth(), backingBitmap->GetHeight(), &memDC, 0, 0); +#endif } } @@ -835,9 +844,13 @@ int GetIndex() // Read preferences void ReadPreferences() { +#if wxUSE_RESOURCES +#if wxUSE_RESOURCES wxGetResource("wxPoem", "FontSize", &pointSize); wxGetResource("wxPoem", "X", &XPos); wxGetResource("wxPoem", "Y", &YPos); +#endif +#endif } // Write preferences to disk @@ -845,10 +858,14 @@ void WritePreferences() { #ifdef __WXMSW__ TheMainWindow->GetPosition(&XPos, &YPos); +#if wxUSE_RESOURCES +#if wxUSE_RESOURCES wxWriteResource("wxPoem", "FontSize", pointSize); wxWriteResource("wxPoem", "X", XPos); wxWriteResource("wxPoem", "Y", YPos); #endif +#endif +#endif } // Load a poem from given file, at given point in file. @@ -993,7 +1010,7 @@ long MainWindow::DoSearch(void) // Load index (or compile it if none found) void TryLoadIndex() { - index_ok = LoadIndex(index_filename); + index_ok = (LoadIndex(index_filename) != 0); if (!index_ok || (nitems == 0)) { PoetryError("Index file not found; will compile new one", "wxPoem");