Author Topic: wxSmith use deprecated commands  (Read 8273 times)

Offline winnie

  • Single posting newcomer
  • *
  • Posts: 9
wxSmith use deprecated commands
« on: August 18, 2019, 10:52:21 am »
I'm using wxSmith with codeblocks 17.12 under ubuntu. I see that it uses wxNewId() that is deprecated, insted it should pass wxID_ANY to the widgets and Connect that is deprecated too, it should use Bind instead.

These are the link to the wxwidgets documentation
https://docs.wxwidgets.org/3.0/group__group__funcmacro__misc.html#gaa2d93c1680369b4227f7de9de58e5fcb
https://docs.wxwidgets.org/3.0/classwx_evt_handler.html#a78719e8b82c9f9c6e4056b3449df1943

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7576
    • My Best Post
Re: wxSmith use deprecated commands
« Reply #1 on: August 18, 2019, 02:50:50 pm »
I'm using wxSmith with codeblocks 17.12 under ubuntu. I see that it uses wxNewId() that is deprecated, insted it should pass wxID_ANY to the widgets and Connect that is deprecated too, it should use Bind instead.

These are the link to the wxwidgets documentation
https://docs.wxwidgets.org/3.0/group__group__funcmacro__misc.html#gaa2d93c1680369b4227f7de9de58e5fcb
https://docs.wxwidgets.org/3.0/classwx_evt_handler.html#a78719e8b82c9f9c6e4056b3449df1943

I am guessing your issue applies to wxSmith generated code; instead of the wxSmith code.
Is this correct?

If yes, can you post two or three cases where the problem exist.

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 winnie

  • Single posting newcomer
  • *
  • Posts: 9
Re: wxSmith use deprecated commands
« Reply #2 on: August 18, 2019, 06:43:48 pm »
Yes I'm talking about the code that wxsmith generate.

This is the example form codeblocks new wxwidgets project but also if I add other buttons wxsmith uses wxNewId() and Connect()

Code
#include "provawxMain.h"
#include <wx/msgdlg.h>

//(*InternalHeaders(provawxDialog)
#include <wx/font.h>
#include <wx/intl.h>
#include <wx/settings.h>
#include <wx/string.h>
//*)

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(provawxDialog)
const long provawxDialog::ID_STATICTEXT1 = wxNewId();
const long provawxDialog::ID_BUTTON1 = wxNewId();
const long provawxDialog::ID_STATICLINE1 = wxNewId();
const long provawxDialog::ID_BUTTON2 = wxNewId();
//*)

BEGIN_EVENT_TABLE(provawxDialog,wxDialog)
    //(*EventTable(provawxDialog)
    //*)
END_EVENT_TABLE()

provawxDialog::provawxDialog(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(provawxDialog)
    Create(parent, id, _("wxWidgets app"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Welcome to\nwxWidgets"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
    wxFont StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    if ( !StaticText1Font.Ok() ) StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    StaticText1Font.SetPointSize(20);
    StaticText1->SetFont(StaticText1Font);
    BoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
    BoxSizer2 = new wxBoxSizer(wxVERTICAL);
    Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
    BoxSizer2->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4);
    StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1"));
    BoxSizer2->Add(StaticLine1, 0, wxALL|wxEXPAND, 4);
    Button2 = new wxButton(this, ID_BUTTON2, _("Quit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
    BoxSizer2->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4);
    BoxSizer1->Add(BoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4);
    SetSizer(BoxSizer1);
    BoxSizer1->Fit(this);
    BoxSizer1->SetSizeHints(this);

    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&provawxDialog::OnAbout);
    Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&provawxDialog::OnQuit);
    //*)
}

provawxDialog::~provawxDialog()
{
    //(*Destroy(provawxDialog)
    //*)
}

void provawxDialog::OnQuit(wxCommandEvent& event)
{
    Close();
}

void provawxDialog::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7576
    • My Best Post
Re: wxSmith use deprecated commands
« Reply #3 on: August 18, 2019, 09:26:48 pm »
I hope this information is enough for any wxSmith developer to work on fixing the problem.

The CB Dev team will likely accept patches to fix the issue; but, might require wx 2.8 compatible code to be an option.

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 BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: wxSmith use deprecated commands
« Reply #4 on: August 19, 2019, 10:55:08 am »
The problem is how we want to solve this?

If we change the code generator then old wx28 projects won't work anymore, and this is not acceptable... I do not like to introduce #ifs in the generated code.
One possibility would be to add a code marker that shows if the file can be wx30 or if it is missing the code has to be generated as wx28 compatible....

For your understanding:
every time you edit a wxSmith item the whole code is newly generated. If we "fix" the code generator to remove depreciated code, also old wx28 projects will get the new code on editing the controls....

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: wxSmith use deprecated commands
« Reply #5 on: August 25, 2019, 05:19:18 pm »
I think we should drop wx28 generator support from wxsmith after we drop wx28 builds of codeblocks...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]