Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

wxScintilla deprecated warnings

(1/3) > >>

rickg22:

--- Code: ---:: === Code::Blocks, scintilla ===
G:\projects\codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1385: warning: `wxStartTimer' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/stopwatch.h:73)
G:\projects\codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1385: warning: `wxStartTimer' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/stopwatch.h:73)
G:\projects\codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1389: warning: `wxGetElapsedTime' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/stopwatch.h:77)
G:\projects\codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1389: warning: `wxGetElapsedTime' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/stopwatch.h:77)
G:\projects\codeblocks\src\sdk\wxscintilla\src\ScintillaWX.cpp:687: warning: `BeginDrawing' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/dc.h:392)
G:\projects\codeblocks\src\sdk\wxscintilla\src\ScintillaWX.cpp:698: warning: `EndDrawing' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/dc.h:393)
G:\projects\codeblocks\src\sdk\wxscintilla\src\wxscintilla.cpp:182: warning: `SetBestFittingSize' is deprecated (declared at G:/wxWidgets-2.8.4/include/wx/window.h:1410)

--- End code ---

I'm replacing wxStartTimer with an instance of wxStopWatch (it's already present in wx2.6, so there's no problem) as member of ElapsedTime. I checked the code and the ElapsedTime class is not used anywwhere, so there won't be any problems with that.

For SetBestFittingSize, I'm using an #if.


--- Code: ---    #if wxVERSION_NUMBER >= 2800
        SetInitialSize(size);
    #else
        SetBestFittingSize(size);
    #endif

--- End code ---

I checked wx2.8.4's window.h and this is what I see:


--- Code: ---inline void wxWindowBase::SetBestFittingSize(const wxSize& size)
{
    SetInitialSize(size);
}

--- End code ---

So I don't think there'll be any problem with it. But if anything goes wrong, please revert.

stahta01:
Is the use of wxVERSION_NUMBER better than wxCHECK_VERSION or wxCHECK_VERSION_FULL?

In some ways it looks better, but I just wish to confirm that since Code::Blocks use wxCHECK_VERSION most of the time.

Tim S

raph:
I just had a look at version.h
wxVERSION_NUMBER is defined as

--- Code: ---/*  some more defines, not really sure if they're [still] useful */
#define wxVERSION_NUMBER ( (wxMAJOR_VERSION * 1000) + (wxMINOR_VERSION * 100) + wxRELEASE_NUMBER )

--- End code ---

And wxCHECK_VERSION

--- Code: ---/*  check if the current version is at least major.minor.release */
#define wxCHECK_VERSION(major,minor,release) \
    (wxMAJOR_VERSION > (major) || \
    (wxMAJOR_VERSION == (major) && wxMINOR_VERSION > (minor)) || \
    (wxMAJOR_VERSION == (major) && wxMINOR_VERSION == (minor) && wxRELEASE_NUMBER >= (release)))

--- End code ---
wxCHECK_VERSION seems to be the more modern way, but I doubt that wxVERSION_NUMBER will be removed.

Regards raph

stahta01:
Subset of my Berlios Patch 1908.

Notice the wxCHECK_VERSION(2, 6, 2) please verify your patch works with 2.6.1 or drop support for 2.6.1. Unless your patch does not use wxGetLocalTimeMillis. I just back ported the code from wxscintilla in my patch.
Note, I do NOT see why I added an test for 2, 6, 2 in my patch, will look and see if it is needed.

Note: BeginDrawing and EndDrawing do nothing in wxWidgets 2.6 and 2.8.

Tim S

Edit: I see now why I have an test for wxWidgets 2.6.2, the error below is from 2.6.1.

--- Quote ---    In member function `double ElapsedTime::Duration(bool)':
codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1398: error: 'class wxLongLong' has no member named 'ToDouble'

--- End quote ---



--- Code: ---Index: src/sdk/wxscintilla/src/PlatWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/PlatWX.cpp (revision 4032)
+++ src/sdk/wxscintilla/src/PlatWX.cpp (working copy)
@@ -1382,11 +1382,28 @@
 //----------------------------------------------------------------------
 
 ElapsedTime::ElapsedTime() {
+#if !wxCHECK_VERSION(2, 6, 2)
     wxStartTimer();
+#else
+    wxLongLong localTime = wxGetLocalTimeMillis();
+    littleBit = localTime.GetLo();
+    bigBit = localTime.GetHi();
+#endif
 }
 
 double ElapsedTime::Duration(bool reset) {
+#if !wxCHECK_VERSION(2, 6, 2)
     double result = wxGetElapsedTime(reset);
+#else
+    wxLongLong prevTime(bigBit, littleBit);
+    wxLongLong localTime = wxGetLocalTimeMillis();
+    if(reset) {
+        littleBit = localTime.GetLo();
+        bigBit = localTime.GetHi();
+    }
+    wxLongLong duration = localTime - prevTime;
+    double result = duration.ToDouble();
+#endif
     result /= 1000.0;
     return result;
 }
Index: src/sdk/wxscintilla/src/ScintillaWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/ScintillaWX.cpp (revision 4032)
+++ src/sdk/wxscintilla/src/ScintillaWX.cpp (working copy)
@@ -684,7 +684,6 @@
     PRectangle rcClient = GetClientRectangle();
     paintingAllText = rcPaint.Contains(rcClient);
 
-    dc->BeginDrawing();
     ClipChildren(*dc, rcPaint);
     Paint(surfaceWindow, rcPaint);
 
@@ -695,7 +694,6 @@
         FullPaint();
     }
     paintState = notPainting;
-    dc->EndDrawing();
 }
 
 

--- End code ---

From CVS wxCode/components/wxscintilla at current date.

--- Code: ---//----------------------------------------------------------------------

ElapsedTime::ElapsedTime() {
    wxLongLong localTime = wxGetLocalTimeMillis();
    littleBit = localTime.GetLo();
    bigBit = localTime.GetHi();
}

double ElapsedTime::Duration(bool reset) {
    wxLongLong prevTime(bigBit, littleBit);
    wxLongLong localTime = wxGetLocalTimeMillis();
    if(reset) {
        littleBit = localTime.GetLo();
        bigBit = localTime.GetHi();
    }
    wxLongLong duration = localTime - prevTime;
    double result = duration.ToDouble();
    result /= 1000.0;
    return result;
}


//----------------------------------------------------------------------

--- End code ---

Biplab:
IMHO, wxCHECK_VERSION is the best way to check wx version.

I didn't apply any patch to wxScintilla to fix those warnings, as it's not maintained by us. It's always better to put the patch to the appropriate team for their consideration, Unless it's really important (which may cause some trouble in C::B).

We took the similar approach when few users posted wxScintilla update (fold line related). :)

I hope some of us would submit this patch to wxScintilla maintainer so that the other people need not update it.

Regards,

Biplab

Navigation

[0] Message Index

[#] Next page

Go to full version