1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: Changes Since wxWidgets 2.8</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Documentation</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Changes Since wxWidgets 2.8 </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This topic describes backwards-incompatible changes in wxWidgets 3.0 compared to the last stable release and is very important to read if you are updating from the 2.8 or an older version.</p>
<p>And even if you hadn't used any previous version of wxWidgets and are starting directly with 3.0, it can still be useful to have at least a quick look at it just to know that some of the older examples and tutorials may not be applicable any more to wxWidgets 3.0.</p>
<p>The incompatible changes can be grouped into the following categories:</p>
<ul>
<li><a class="el" href="overview_changes_since28.html#overview_changes_unicode">Unicode-related Changes</a> </li>
<li><a class="el" href="overview_changes_since28.html#overview_changes_other">Miscellaneous Other Changes</a></li>
</ul>
<hr/>
<h1><a class="anchor" id="overview_changes_unicode"></a>
Unicode-related Changes</h1>
<p>If you used Unicode build of wxWidgets 2.8 or previous version, please read <a class="el" href="overview_unicode.html">Unicode Support in wxWidgets</a> for the details about how the API changed in 3.0 as a lot of the information which was correct before doesn't apply any longer.</p>
<p>For example, the notorious (due to the confusion they created) macros <code><a class="el" href="group__group__funcmacro__string.html#ga437ea6ba615b75dac8603e96ec864160" title="This macro can be used with character and string literals (in other words, 'x' or "foo") to automatic...">wxT()</a></code> and <code><a class="el" href="group__group__funcmacro__string.html#ga7dfc2888539861afe6c4337ef315472b" title="This macro is exactly the same as wxT() and is defined in wxWidgets simply because it may be more int...">_T()</a></code> are not needed at all any longer. Basically, you can remove them from any code which used them. On the other hand, there is no particular harm in leaving them neither as the code will still compile and work correctly – you only need to remove them if you think that your code looks tidier without them. You also don't need to use <code>wxChar</code> any longer but can directly use the standard <code>wchar_t</code> type even if, again, <code>wxChar</code> continues to work.</p>
<p>The most serious backwards-incompatible change is related to the change of return type of <a class="el" href="classwx_string.html#a6418ec90c6d4ffe0b05702be1b35df4f" title="Returns a lightweight intermediate class which is in turn implicitly convertible to both const char* ...">wxString::c_str()</a> method: it returns a special proxy object instead of a simple <code>char*</code> or <code>wchar_t*</code> now. Because of this, you cannot pass its result to any standard vararg functions such as <code>printf()</code> any more as described in <a class="el" href="overview_unicode.html#overview_unicode_compilation_errors">Unicode-Related Compilation Errors</a>. All wxWidgets functions, such as wxPrintf(), <a class="el" href="group__group__funcmacro__log.html#ga249358701f3c2d410088ddf7a61d8564" title="For all normal, informational messages.">wxLogMessage()</a> &c still work with it, but passing it to <code>printf()</code> will now result in a crash. It is strongly advised to recompile your code with a compiler warning about passing non-POD objects to vararg functions, such as g++.</p>
<p>The change of the type of <a class="el" href="classwx_string.html#a6418ec90c6d4ffe0b05702be1b35df4f" title="Returns a lightweight intermediate class which is in turn implicitly convertible to both const char* ...">wxString::c_str()</a> can also result in compilation errors when passing its result to a function overloaded to take both narrow and wide strings and in this case you must select the version which you really want to use, e.g.: </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> OpenLogFile(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename);</div>
<div class="line"><span class="keywordtype">void</span> OpenLogFile(<span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *filename);</div>
<div class="line"></div>
<div class="line"><a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> s;</div>
<div class="line">OpenLogFile(s); <span class="comment">// ERROR: ambiguity</span></div>
<div class="line">OpenLogFile(s.<a class="code" href="classwx_string.html#a6418ec90c6d4ffe0b05702be1b35df4f" title="Returns a lightweight intermediate class which is in turn implicitly convertible to both const char* ...">c_str</a>()); <span class="comment">// ERROR: ambiguity</span></div>
<div class="line">OpenLogFile(s.<a class="code" href="classwx_string.html#a667b135c20008042653f82b739f6c3ab" title="Explicit conversion to C string in the internal representation (either wchar_t* or UTF-8-encoded char...">wx_str</a>()); <span class="comment">// OK: function called depends on the build</span></div>
<div class="line">OpenLogFile(s.<a class="code" href="classwx_string.html#adcfd12e6d0765b1d74bccc3d63d02e98" title="Returns the multibyte (C string) representation of the string using conv's wxMBConv::cWC2MB method an...">mb_str</a>()); <span class="comment">// OK: always calls narrow string overload</span></div>
<div class="line">OpenLogFile(s.<a class="code" href="classwx_string.html#a6cd4782263a3ed4064eca915eb6e27e6" title="Converts the strings contents to the wide character representation and returns it as a temporary wxWC...">wc_str</a>()); <span class="comment">// OK: always calls wide string overload</span></div>
</div><!-- fragment --><p> A common example of such problem arises with <code>std::fstream</code> class constructor in Microsoft Visual C++ standard library implementation. In addition to a constructor from <code>const</code> <code>char</code> * which this class must have, it also provides a constructor taking a wide character file name. Because of this, code like the following </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <fstream></span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> MyFunc(<span class="keyword">const</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a>& filename)</div>
<div class="line">{</div>
<div class="line"> std::ifstream ifs(filename.<a class="code" href="classwx_string.html#a6418ec90c6d4ffe0b05702be1b35df4f" title="Returns a lightweight intermediate class which is in turn implicitly convertible to both const char* ...">c_str</a>());</div>
<div class="line"> ...</div>
<div class="line">}</div>
</div><!-- fragment --><p> does not compile when using Microsoft Visual C++ and needs to be changed to use mb_str() (which will not work for file names containing Unicode characters, consider using wxWidgets classes and functions to work with such file names as they are not supported by standard C++ library).</p>
<p>The other class of incompatible changes is due to modifying some virtual methods to use <code><a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a></code> parameters instead of <code>const</code> <code>wxChar*</code> ones to make them accept both narrow and wide strings. This is not a problem if you simply call these functions but you need to change the signature of the derived class versions if you override them as otherwise they wouldn't be called any more. Again, the best way to ensure that this problem doesn't arise is to rebuild your code using a compiler which warns about function signature mismatch (you can use <code>-Woverloaded-virtual</code> g++ option).</p>
<p>Finally, a few structure fields, notable <code><a class="el" href="structwx_cmd_line_entry_desc.html#a1fa5b1fb90ff3051a011a6ce10261796" title="The usual, short, name of the switch or the option.">wxCmdLineEntryDesc::shortName</a></code>, <code>longName</code> and <code>description</code> fields have been changed to be of type <code>const</code> <code>char*</code> instead of <code>const</code> <code>wxChar*</code> so you will need to remove <code><a class="el" href="group__group__funcmacro__string.html#ga437ea6ba615b75dac8603e96ec864160" title="This macro can be used with character and string literals (in other words, 'x' or "foo") to automatic...">wxT()</a></code> or <code><a class="el" href="group__group__funcmacro__string.html#ga7dfc2888539861afe6c4337ef315472b" title="This macro is exactly the same as wxT() and is defined in wxWidgets simply because it may be more int...">_T()</a></code> if you used it with their initializers.</p>
<h1><a class="anchor" id="overview_changes_other"></a>
Miscellaneous Other Changes</h1>
<ul>
<li>Default location of <a class="el" href="classwx_file_config.html" title="wxFileConfig implements wxConfigBase interface for storing and retrieving configuration information u...">wxFileConfig</a> files has changed under Windows, you will need to update your code if you access these files directly.</li>
</ul>
<ul>
<li><a class="el" href="classwx_window.html#a59452a5bd42f5ea4b31d7fc4aa59644f" title="Returns true if the window is enabled, i.e. if it accepts user input, false otherwise.">wxWindow::IsEnabled()</a> now returns false if a window parent (and not necessarily the window itself) is disabled, new function IsThisEnabled() with the same behaviour as old IsEnabled() was added.</li>
</ul>
<ul>
<li>Generating <a class="el" href="classwx_navigation_key_event.html" title="This event class contains information about navigation events, generated by navigation keys such as t...">wxNavigationKeyEvent</a> events doesn't work any more under wxGTK (and other platforms in the future), use <a class="el" href="classwx_window.html#a86904f6785df4af6036b33383490a805" title="Performs a keyboard navigation action starting from this window.">wxWindow::Navigate()</a> or NavigateIn() instead.</li>
</ul>
<ul>
<li>Sizers distribute only the extra space between the stretchable items according to their proportions and not all available space. We believe the new behaviour corresponds better to user expectations but if you did rely on the old behaviour you will have to update your code to set the minimal sizes of the sizer items to be in the same proportion as the items proportions to return to the old behaviour.</li>
</ul>
<ul>
<li><a class="el" href="classwx_window.html#a15c678314cfc1d807196bc298b713ed3" title="Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all.">wxWindow::Freeze</a>/Thaw() are not virtual any more, if you overrode them in your code you need to override DoFreeze/Thaw() instead now.</li>
</ul>
<ul>
<li><a class="el" href="classwx_calendar_ctrl.html" title="The calendar control allows the user to pick a date.">wxCalendarCtrl</a> has native implementation in wxGTK, but it has less features than the generic one. The native implementation is used by default, but you can still use wxGenericCalendarCtrl instead of <a class="el" href="classwx_calendar_ctrl.html" title="The calendar control allows the user to pick a date.">wxCalendarCtrl</a> in your code if you need the extra features.</li>
</ul>
<ul>
<li>wxDocument::FileHistoryLoad() and <a class="el" href="classwx_file_history.html#a2537201495686a3a6a26701e158ecfb3" title="Loads the file history from the given config object.">wxFileHistory::Load()</a> now take const reference to <a class="el" href="classwx_config_base.html" title="wxConfigBase defines the basic interface of all config classes.">wxConfigBase</a> argument and not just a reference, please update your code if you overrode these functions and change the functions in the derived classes to use const reference as well.</li>
</ul>
<ul>
<li><p class="startli">Calling wxConfig::Write() with an enum value will fail to compile because wxConfig now tries to convert all unknown types to <a class="el" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> automatically using <a class="el" href="group__group__funcmacro__misc.html#ga0adf8026ea8ed126420a2e7ef9edc678" title="Converts the given wxColour into a string.">wxToString()</a> function.</p>
<p class="startli">The simplest solution is to cast the enum value to int, e.g. </p>
<div class="fragment"><div class="line"><span class="keyword">enum</span> Colour { Red, Green, Blue };</div>
<div class="line"></div>
<div class="line">wxConfig conf;</div>
<div class="line">conf.Write(<span class="stringliteral">"MyFavouriteColour"</span>, Red); <span class="comment">// ERROR: no match</span></div>
<div class="line">conf.Write(<span class="stringliteral">"MyFavouriteColour"</span>, <span class="keywordtype">int</span>(Red)); <span class="comment">// OK</span></div>
</div><!-- fragment --><p class="startli">Another possibility which exists now is to provide an overload of <a class="el" href="group__group__funcmacro__misc.html#ga0adf8026ea8ed126420a2e7ef9edc678" title="Converts the given wxColour into a string.">wxToString()</a> (and <a class="el" href="group__group__funcmacro__misc.html#ga598ae7504c6436af325490b41f4b5e90" title="Converts string to a wxColour best represented by the given string.">wxFromString()</a>) for your own type, e.g.</p>
<div class="fragment"><div class="line"><a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> <a class="code" href="group__group__funcmacro__misc.html#ga0adf8026ea8ed126420a2e7ef9edc678" title="Converts the given wxColour into a string.">wxToString</a>(Colour col)</div>
<div class="line">{</div>
<div class="line"> <span class="keywordflow">return</span> col == Red ? <span class="stringliteral">"R"</span> : col == Green ? <span class="stringliteral">"G"</span> : <span class="stringliteral">"B"</span>;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">bool</span> <a class="code" href="group__group__funcmacro__misc.html#ga598ae7504c6436af325490b41f4b5e90" title="Converts string to a wxColour best represented by the given string.">wxFromString</a>(<span class="keyword">const</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a>& s, Colour* col)</div>
<div class="line">{</div>
<div class="line"> <span class="keywordflow">if</span> ( s.<a class="code" href="classwx_string.html#af63f200410b56436a830550905e20539">length</a>() != 1 )</div>
<div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">switch</span> ( s[0].GetValue() )</div>
<div class="line"> {</div>
<div class="line"> <span class="keywordflow">case</span> <span class="charliteral">'R'</span>: *col = Red; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"> <span class="keywordflow">case</span> <span class="charliteral">'G'</span>: *col = Green; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"> <span class="keywordflow">case</span> <span class="charliteral">'B'</span>: *col = Blue; <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line">}</div>
</div><!-- fragment --><p class="startli">Of course, this will change the format of the wxConfig output which may be undesirable.</p>
</li>
</ul>
<ul>
<li>wxTE_AUTO_SCROLL style is deprecated as it's always on by default anyhow in the ports which support it so you should simply remove any mentions of it from your code.</li>
</ul>
<ul>
<li>If you use <a class="el" href="classwx_scrolled.html#a117dc8edabb3e1250199eab089e4fa5b" title="Call this function to tell wxScrolled to perform the actual scrolling on a different window (and not ...">wxScrolled<T>::SetTargetWindow()</a> you must override <a class="el" href="classwx_scrolled.html#a81800886d1d5f094caeee683e707de12" title="Function which must be overridden to implement the size available for the scroll target for the given...">wxScrolled<T>::GetSizeAvailableForScrollTarget()</a> method to compute the size available for the scroll target as function of the main window size, please see the documentation of this method for more details.</li>
</ul>
<ul>
<li>Signature of <a class="el" href="classwx_data_view_custom_renderer.html#a36d6d5c64097bb48f67a712ddb7f97bf" title="Override this to start a drag operation.">wxDataViewCustomRenderer::StartDrag()</a> virtual method changed. You will need to change it in your derived renderer class too if you override it.</li>
</ul>
<ul>
<li><a class="el" href="classwx_data_view_custom_renderer.html#a242d0992df73be6830e66d74b211974d" title="Override this to react to the activation of a cell.">wxDataViewCustomRenderer::Activate()</a> and <a class="el" href="classwx_data_view_custom_renderer.html#ab7fe7693a94fee896eb0b60b843cd474" title="Override this to react to a left click.">wxDataViewCustomRenderer::LeftClick()</a> were replaced with the new <a class="el" href="classwx_data_view_custom_renderer.html#a76e85467c89adae6612236d803a552fc" title="Override this to react to cell activation.">wxDataViewCustomRenderer::ActivateCell()</a> method. You will need to change it in your derived renderer class accordingly. </li>
</ul>
</div></div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:42 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|