:: === 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.
#if wxVERSION_NUMBER >= 2800
SetInitialSize(size);
#else
SetBestFittingSize(size);
#endif
I checked wx2.8.4's window.h and this is what I see:
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.
I just had a look at version.h
wxVERSION_NUMBER is defined as
/* 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
/* 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
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.
In member function `double ElapsedTime::Duration(bool)':
codeblocks\src\sdk\wxscintilla\src\PlatWX.cpp:1398: error: 'class wxLongLong' has no member named 'ToDouble'
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.
//----------------------------------------------------------------------
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;
}
//----------------------------------------------------------------------
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.
// 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
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.
#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.