Author Topic: wxScintilla deprecated warnings  (Read 9733 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
wxScintilla deprecated warnings
« on: June 02, 2007, 07:41:50 am »
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)

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

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

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

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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: wxScintilla deprecated warnings
« Reply #1 on: June 02, 2007, 05:59:49 pm »
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
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: wxScintilla deprecated warnings
« Reply #2 on: June 02, 2007, 06:12:20 pm »
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 )

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)))
wxCHECK_VERSION seems to be the more modern way, but I doubt that wxVERSION_NUMBER will be removed.

Regards raph

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: wxScintilla deprecated warnings
« Reply #3 on: June 02, 2007, 06:14:34 pm »
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'


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();
 }
 
 

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;
}


//----------------------------------------------------------------------
« Last Edit: June 02, 2007, 06:56:03 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxScintilla deprecated warnings
« Reply #4 on: June 02, 2007, 06:30:16 pm »
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
Be a part of the solution, not a part of the problem.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: wxScintilla deprecated warnings
« Reply #5 on: June 02, 2007, 06:34:58 pm »

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

Regards,

Biplab

The second code listing I posted is from wxScintilla CVS. We are not using the current release of wxScintilla in C::B.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxScintilla deprecated warnings
« Reply #6 on: June 02, 2007, 06:38:52 pm »
We are not using the current release of wxScintilla in C::B.

Yes, it's not been updated in C::B's repo. :)
Be a part of the solution, not a part of the problem.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla deprecated warnings
« Reply #7 on: June 02, 2007, 09:23:48 pm »
IMHO, wxCHECK_VERSION is the best way to check wx version.
Please don't!
Use e.g. wxMinimumVersion<2,6>::eval from prep.h (part of C::B SDK) for this purpose. We have hardly tried to remove those nasty macros from the code so we shouldn't re-introduce them again.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: wxScintilla deprecated warnings
« Reply #8 on: June 02, 2007, 10:41:51 pm »
IMHO, wxCHECK_VERSION is the best way to check wx version.
Please don't!
Use e.g. wxMinimumVersion<2,6>::eval from prep.h (part of C::B SDK) for this purpose. We have hardly tried to remove those nasty macros from the code so we shouldn't re-introduce them again.
With regards, Morten.

Can you give an example use at compile time? Not at runtime?

Note: I think I have found out how to use it (it must be used at compile and runtime it appears to me), but if you can give directions it could help.

Code
// Example definition
namespace compatibility { typedef TernaryCondTypedef<wxMinimumVersion<2,5>::eval, wxTreeItemIdValue, long int>::eval tree_cookie_t; };

// Example use of definition
compatibility::tree_cookie_t cookie = 0;
Tim S
« Last Edit: June 02, 2007, 10:52:13 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: wxScintilla deprecated warnings
« Reply #9 on: June 02, 2007, 11:03:49 pm »
IMHO, wxCHECK_VERSION is the best way to check wx version.
Please don't!
Use e.g. wxMinimumVersion<2,6>::eval from prep.h (part of C::B SDK) for this purpose. We have hardly tried to remove those nasty macros from the code so we shouldn't re-introduce them again.
With regards, Morten.

wxMiniwhat? O.o How does it work? Man, I didn't even know it existed.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxScintilla deprecated warnings
« Reply #10 on: June 03, 2007, 04:50:30 am »
I don't see any reason why macros are that bad. I've C background and I prefer it. :)

I don't see any way to compile the code with wxWidgets 2.6.x without using macro.
Code
    #if wxCHECK_VERSION(2, 8, 0)
    m_pToolbar->SetInitialSize();
    #else
    m_pToolbar->SetBestFittingSize();
    #endif

Rather this is good to maintain. Next time if we want to drop support of wxWidgets-2.6.x, we just need to remove the appropriate portion of code.
« Last Edit: June 03, 2007, 04:54:05 am by Biplab »
Be a part of the solution, not a part of the problem.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: wxScintilla deprecated warnings
« Reply #11 on: June 03, 2007, 09:49:10 am »
no no no no no : macros are evil.

Such an ifdef for wx, could be a bit acceptable.
But in regular code, hell no.

Read a book from Sutter or Meyer and you will find some good examples on how bad they are.

The only purpose they are in C++ is because C++ had to support also C code.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla deprecated warnings
« Reply #12 on: June 03, 2007, 11:01:04 am »
I don't see any reason why macros are that bad.
There are really good reasons. I'll give you two examples why we would like to use templates instead: If we want tot change the functionality of any macro (imagine e.g. for compatibility flags) we need to change *one* place instead of a hundred across the code. Besides flexibility another reason is that the code is just much more easier to read if you use templates. So I can only really vote for templates.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: wxScintilla deprecated warnings
« Reply #13 on: June 03, 2007, 11:12:43 am »
I agree with you, Martin. I rarely use macro in C::B since prep.h has been introduced. ;)
Be a part of the solution, not a part of the problem.