[wxWidget系列] Updating wxWidget from 2.6.X to 2.8.X

来源:互联网 发布:手绘画图软件 编辑:程序博客网 时间:2024/05/01 14:29

Compile Error and Solution:


1.    wxSizer::IsShown -> wxSizer::IsShown must take one argument.
2.    Int GetCount() const->unsign Int GetCount() const
3.    wxCommandEvent's members is protected, please use related interfaces to access them.
4.    wxHIDE_READONLY is not supported by wxFileDialog.
5.    The type of (*wxLIGHT_GREY) or (wxWHITE_PEN) is const wxColor or const wxPen.
6.    Get/SetTitle() is not support by wxWindow, wxTopLevelWindow supports
7.    wxBitmap/wxImage :OK()->IsOk(). Refer to 12.
8.    wxRect::Inside->wxRect::Contains
9.    wxTreeItemId's wxTreeItemId(long item) and operator long() consthave been deprecated. Please use IsOk() to check if wxTreeItemId isvalid and use default constructor to create invalid wxTreeItemId.
10.    The timer functions are deprecated because they work with oneglobal timer only and wxTimer and/or wxStopWatch classes should be usedinstead. The wxTimer class allows you to execute code at specifiedintervals. The wxStopWatch class allows you to measure time intervals.
11.    wxDialog::OnOK/OnCancel() don't exist any more, use SetAffirmative/EscapeId()
12.    Some classes (notably wxBitmap and wxImage) don't defineoperator==() as it used to work in somewhat unexpected way as itcompared only internal pointers and not the object data. The code usingit will have to be updated:
    * If the object was compared with wxNullXXX, use IsOk() method instead
    * If valid object need to be compared, use IsSameAs() to reproduce the old
      behaviour or change the code to avoid comparing bitmaps &c.

Run-time Error and Solution:


1.    VS 2008 enhance invalid iterator check, such iterator operator+(), ==, !=.
2.    VS 2008 checks whether sort function is valid or not whiledebugging. If the sort function does exist contradictory points, therewill be an error.
In addition, because of doing validation, it will cost double time than before to do sorting in debug mode of VS.
3.    Since wxGrid uses reference number to manage the lifetime ofcell's attributes and renderers, and when the GetCellRenderer() wascalled, the reference number of the renderer is increased, So theDecRef() was called explicitly. Such as call wxGridCellAttr*wxGrid::GetOrCreateCellAttr(int row, int col) const;  Refer towxGridCellWorker and wxGridCellRenderer (base class: wxGridCellWorker).
4.    wxMenuItem::wxMenuItem(wxMenu* parentMenu = NULL, int id =wxID_SEPARATOR, const wxString& text = "", const wxString&helpString = "", wxItemKind kind = wxITEM_NORMAL, wxMenu* subMenu =NULL)
For the custom (non-stock) menu items, text must be specified and whilehelpString may be left empty, it's recommended to pass the itemdescription (which is automatically shown by the library in the statusbar when the menu item is selected) in this parameter.
5.    When using wxBitmapButton of wx289, please don't useSetBitmapSelect() to set the bitmap of the button, because that bitmapwill only be shown when the button is selected.
6.    wx2.8.9 changes the logic of parsing the virtual key from a char, 0 can not be the default key id, please use -1 instead.
7.    Please use wxTreeCtrl's EVT_TREE_ITEM_MENU to handle therequirement of popping context menu, which can handle not only mouseevent and also key event.
8.    Don't forget to add the style of "EXPAND" for your control which you want it to be full fill the space.
9.    Even if the Windows have been hidden, the Sizer also will reservesome space for expendable windows. Thus We should change the proportionflag to control the space allocation.
10.    For bool cell of wxgrid, only "" and "1" are accepted as falseand true from version 2.8.9. But in 2.6.2, both "" and "0" are acceptedas false.
11.    When wxPlot initializes, it need some font files, if it does not exist, gui will crash without any info.
12.    SetSizeHint() is still an API which is needed to pay moreattention, because it may cause some troubles. Maybe you can useLayout() instead or just eliminate it.
13.    If Fit() will use window's best size to display, so if somewindow should change size in different situation, please use Fit()after create the window.
14.    If you want to use EVT_TEXT_ENTER(id, func), please addwxTE_PROCESS_ENTER to window style. In 2.8.9, wxTE_PROCESS_ENTER isnecessary to enable the event wxEVT_COMMAND_TEXT_ENTER.