GitHubLionel / wxMathPlot

An enhanced version of the wxMathPlot component for wxWidgets
14 stars 5 forks source link

code with new wxSmith #14

Closed GitHubLionel closed 6 months ago

GitHubLionel commented 1 year ago

I update the code with my wxSmith version.

asmwarrior commented 1 year ago

Good, can you show the code changes? Maybe, some C::B devs can review you changes, and apply your contribution to the Code::Blocks svn trunk.

asmwarrior commented 1 year ago

Oh, I see you have some un-wanted code changes

#ifndef HEADER_E1D3326BF670B452
#define HEADER_E1D3326BF670B452

Please disable a plugin named header guard. This plugin will add some ugly header guard.

GitHubLionel commented 1 year ago

Ok, I disable this plugin. I also have created the option to have const array for wxChoice in wxSmith. And I push the change I made in wxSmith sources.

asmwarrior commented 1 year ago

Ok, I disable this plugin. I also have created the option to have const array for wxChoice in wxSmith. And I push the change I made in wxSmith sources.

Good work! Let me report back to C::B forum, and I think C::B devs are interested to incorporate your contribution. Thanks.

GitHubLionel commented 1 year ago

For wxChoice, maybe it will be better to have a local checkbox choice in properties list (like "Is member") rather than in global wxSmith property editor. I am looking for that but it is a bit more complicated to modify widget properties list. EDIT : In fact, it was quite easy !

asmwarrior commented 6 months ago

I have a feature request here in our C::B ticket system, see:

Code::Blocks / Tickets / #1473 wxSmith which supports generating empty IDs(from github GitHubLionel)

asmwarrior commented 6 months ago

Hi, FYI:

Code::Blocks / SVN Repo / Commit [r13522]

Your code is in Code::Blocks' svn repo now, thanks.

asmwarrior commented 6 months ago

FYI:

I add a post in the C::B forum about the wxSmith's new feature:

new feature of wxSmith in r13522

GitHubLionel commented 6 months ago

Hi, I test the new code from svn repo. Work ok, I generate the same code for wxMathPlot. It should be great to update the official binary releases

asmwarrior commented 6 months ago

Hi, I test the new code from svn repo. Work ok, I generate the same code for wxMathPlot. It should be great to update the official binary releases

Good to know that, thanks.

Our C::B administrator will make C::B release, but they are always busy, not sure it will happen in the near future. You can try some nightly build version of C::B from C::B's forum.

asmwarrior commented 6 months ago

I think this issue if complete, so you can close it, thanks.

asmwarrior commented 5 months ago

I have another question, here is the test code: (the code is mainly generated by chatGPT)

#include <wx/wx.h>

class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title);

private:
    void OnMenuItem1Selected(wxCommandEvent& event);
    void OnMenuItem2Selected(wxCommandEvent& event);

    wxDECLARE_EVENT_TABLE();
};

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
    // Empty as we use Bind instead
wxEND_EVENT_TABLE()

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("wxWidgets Menu Example");
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600))
{
    wxMenuBar* menuBar = new wxMenuBar;

    wxMenu* menuFile = new wxMenu;
    wxMenuItem* menuItem1 = new wxMenuItem(menuFile, wxID_ANY, "&Item 1\tCtrl-1", "This is item 1");
    wxMenuItem* menuItem2 = new wxMenuItem(menuFile, wxID_ANY, "&Item 2\tCtrl-2", "This is item 2");

    menuFile->Append(menuItem1);
    menuFile->Append(menuItem2);

    menuBar->Append(menuFile, "&File");

    SetMenuBar(menuBar);

    // debug only code
    int id1 = menuItem1->GetId();
    int id2 = menuItem2->GetId();

    // Bind each menu item to its respective event handler
    Bind(wxEVT_MENU, &MyFrame::OnMenuItem1Selected, this, menuItem1->GetId());
    Bind(wxEVT_MENU, &MyFrame::OnMenuItem2Selected, this, menuItem2->GetId());
}

void MyFrame::OnMenuItem1Selected(wxCommandEvent& event)
{
    wxLogMessage("Menu item 1 selected!");
}

void MyFrame::OnMenuItem2Selected(wxCommandEvent& event)
{
    wxLogMessage("Menu item 2 selected!");
}

The above code works fine. So, you see, for menu items, I still use wxID_ANY.

I ask such question because I see this:

+                            if (IdString.IsEmpty())
+                            {
+                                if ((ItemClassname == _T("wxMenuItem")) || (ItemClassname == _T("wxToolBarToolBase")))
+                                {
+                                    wxMessageBox(wxString::Format(_("This widget <%s> need ID for bind function"), VarNameString));
+                                }
+                                else
+                                {
+                                    if (UseBind)
+                                        Context->m_EventsConnectingCode << VarNameString << "->Bind(" << Type << ", " << Method << ", this);\n";
+                                    else
+                                        Context->m_EventsConnectingCode << VarNameString << "->Connect(" << Type << ", (wxObjectEventFunction)" << Method << ", NULL, this);\n";
+                                }
+                            }

In your code contribution here: https://sourceforge.net/p/codeblocks/code/13522/

So, I believe that menu item can have wxID_ANY. I just debugged for a while, and I see that id1 and id2 are all negative values, and they are different values.

GitHubLionel commented 5 months ago

Well I probably had good reasons for that but I don't remember them any more ! I think that if you use wxID_ANY, then id is automatically created by wxWidget. But C::B need to have different id.

asmwarrior commented 5 months ago

Well I probably had good reasons for that but I don't remember them any more ! I think that if you use wxID_ANY, then id is automatically created by wxWidget. But C::B need to have different id.

That's sad to hear. Hope you can remember something about this someday later.