Many thanks for the extensive commentary.
Though, our original post was in two parts, and clearly the second part had overcome the vast majority of issues that were raised in the first part. As such, and while we appreciate your time, we are not sure why you had taken time to comment on so many items, and only, in the first part, that had been clearly resolved in the second part, and prior to your response (e.g. all the non declared bits, just for example).
Regarding some of your queries:
1) The code is produced in CB with wxSmith as a wxWidget project, and amongst other things:
a) It creates the code automatically.
b) Much of that code can't be changed in any manageable way, since every time wxSmith has a go at it, it deletes/re-writes large chunks of code, so any edits we had made in those parts vanish. That is decidedly not how a pure wxWidgets programme seems to work, and clearly it is what contributed the some of the issues in part 1 of the original post, but which was overcome by the second part of the original post.
c) The structure of the code produced automatically by wxSmith seems to be different is subtle, and perhaps important ways, compared to what we have seen in our research of "pure" wx code. We are too new at this to be able to comment on the implications of that.
d) Thank you for the link (
http://docs.wxwidgets.org/3.0.0/classwx_text_entry.html#a90f876b2dd83ba5c97ba0c193b386e9f), but it is of little help, as clearly we had been using that already (as in the code example in our original post). The issue is that wxSmith declares the widgets as Private, so there is no direct way to use/change them from outside of the core code.
Indeed, as the second part of our post demonstrates, wx doesn't like its bits being changed from the "outside" (such as from OnInit()), and that is why, when we found on the wxWidget forum (as stated in the post prior to your response), we used
void CB_SRList_wxFrame::SetValue_of_FileName_TextCtrl1(wxString t)
{
this->FileName_TextCtrl1->SetValue(t);
}
which (as must be clear from the post) we managed to make a "member" and we managed to "declare", once we figured out that wxSmith kept deleting our edits, and so we required a different approach, and which apparently worked (wrt to creating a member "manually", as we could not figure a way to do it from wxSmith directly, which seemed to would make this a CB question for that reason alone).
e) As such, and given this is essentially our first proper wxWidget/wsSmith project, we could not be sure how much of the difficulties were a CB issue or a wx issue, or possibly some combination of both.
... and thus it seemed reasonably to ask the question on the CB forum also, though clearly, the attention is on the SECOND part of the original post.
... as it happens we also asked the question on the wxWidget forum, as yet there has not been a response ... I hope they don't tell us that it's a CB matter, go back to CB.
Any way, for the record, and I am not sure how much of this you want (as in the past we've been told not to create long posts), but here is the code (the crucial line is in CB_SRList_wxApp.cpp, further down, and I have commented it ... if a line has something like //DrO in it, then it is one of ours), :
CB_SRList_wxMain.cpp:
/***************************************************************
* Name: CB_SRList_wxMain.cpp
* Purpose: Navigation Tool/Plug-In for Fortran procedures, etc
* Author: ()
* Created: 2016-04-15
* Copyright: ()
* License:
**************************************************************/
#include "wx_pch.h"
#include "CB_SRList_wxMain.h"
#include <wx/msgdlg.h>
//!#include <wx/event.h> //! DrO
#include <iostream> //! DrO
//(*InternalHeaders(CB_SRList_wxFrame)
#include <wx/intl.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(CB_SRList_wxFrame)
const long CB_SRList_wxFrame::ID_STATICTEXT1 = wxNewId();
const long CB_SRList_wxFrame::ID_CHOICE1 = wxNewId();
const long CB_SRList_wxFrame::ID_GRID1 = wxNewId();
const long CB_SRList_wxFrame::ID_TEXTCTRL1 = wxNewId();
const long CB_SRList_wxFrame::ID_BUTTON1 = wxNewId();
const long CB_SRList_wxFrame::ID_PANEL1 = wxNewId();
const long CB_SRList_wxFrame::ID_MENUITEM1 = wxNewId();
const long CB_SRList_wxFrame::idMenuQuit = wxNewId();
const long CB_SRList_wxFrame::ID_MENUITEM2 = wxNewId();
const long CB_SRList_wxFrame::idMenuAbout = wxNewId();
const long CB_SRList_wxFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(CB_SRList_wxFrame,wxFrame)
//(*EventTable(CB_SRList_wxFrame)
//*)
END_EVENT_TABLE()
CB_SRList_wxFrame::CB_SRList_wxFrame(wxWindow* parent,wxWindowID id)
{
void SetValue_of_FileName_TextCtrl1( wxString t); // DrO
//(*Initialize(CB_SRList_wxFrame)
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;
Create(parent, id, _("Fortran Navigation"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
SetClientSize(wxSize(459,592));
Move(wxPoint(900,39));
Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("Sort by: "), wxPoint(216,8), wxSize(72,24), wxALIGN_RIGHT, _T("ID_STATICTEXT1"));
Choice1 = new wxChoice(Panel1, ID_CHOICE1, wxPoint(296,8), wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
Grid1 = new wxGrid(Panel1, ID_GRID1, wxPoint(0,104), wxSize(447,436), 0, _T("ID_GRID1"));
Grid1->CreateGrid(30,5);
Grid1->EnableEditing(true);
Grid1->EnableGridLines(true);
Grid1->SetRowLabelSize(25);
Grid1->SetDefaultColSize(70, true);
Grid1->SetColLabelValue(0, _("Line"));
Grid1->SetColLabelValue(1, _("Type"));
Grid1->SetColLabelValue(2, _("Procedure"));
Grid1->SetColLabelValue(3, _("Kind"));
Grid1->SetColLabelValue(4, _("References"));
Grid1->SetDefaultCellFont( Grid1->GetFont() );
Grid1->SetDefaultCellTextColour( Grid1->GetForegroundColour() );
FileName_TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, _("FileName"), wxPoint(8,56), wxSize(432,21), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
ReCalcButton = new wxButton(Panel1, ID_BUTTON1, _("ReCalc"), wxPoint(32,16), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem3 = new wxMenuItem(Menu1, ID_MENUITEM1, _("Open"), wxEmptyString, wxITEM_NORMAL);
Menu1->Append(MenuItem3);
Menu1->AppendSeparator();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu3 = new wxMenu();
MenuItem4 = new wxMenuItem(Menu3, ID_MENUITEM2, _("ReCalc"), wxEmptyString, wxITEM_NORMAL);
Menu3->Append(MenuItem4);
MenuBar1->Append(Menu3, _("Action"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CB_SRList_wxFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CB_SRList_wxFrame::OnAbout);
//*)
}
CB_SRList_wxFrame::~CB_SRList_wxFrame()
{
//(*Destroy(CB_SRList_wxFrame)
//*)
}
void CB_SRList_wxFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void CB_SRList_wxFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void CB_SRList_wxFrame::SetValue_of_FileName_TextCtrl1(wxString t) // DrO
{
this->FileName_TextCtrl1->SetValue(t);
}
CB_SRList_wxMain.h
/***************************************************************
* Name: CB_SRList_wxMain.h
* Purpose: Defines Application Frame
* Author: ()
* Created: 2016-04-15
* Copyright: ()
* License:
**************************************************************/
#ifndef CB_SRLIST_WXMAIN_H
#define CB_SRLIST_WXMAIN_H
//(*Headers(CB_SRList_wxFrame)
#include <wx/stattext.h>
#include <wx/menu.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/grid.h>
#include <wx/choice.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/statusbr.h>
//*)
class CB_SRList_wxFrame: public wxFrame
{
public:
CB_SRList_wxFrame(wxWindow* parent,wxWindowID id = -1);
virtual ~CB_SRList_wxFrame();
void SetValue_of_FileName_TextCtrl1( wxString t); // DrO
private:
//(*Handlers(CB_SRList_wxFrame)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnPaint(wxPaintEvent& event);
void OnFileName_TextCtrl1TextEnter(wxCommandEvent& event);
//*)
//(*Identifiers(CB_SRList_wxFrame)
static const long ID_STATICTEXT1;
static const long ID_CHOICE1;
static const long ID_GRID1;
static const long ID_TEXTCTRL1;
static const long ID_BUTTON1;
static const long ID_PANEL1;
static const long ID_MENUITEM1;
static const long idMenuQuit;
static const long ID_MENUITEM2;
static const long idMenuAbout;
static const long ID_STATUSBAR1;
//*)
//(*Declarations(CB_SRList_wxFrame)
wxTextCtrl* FileName_TextCtrl1;
wxMenu* Menu3;
wxMenuItem* MenuItem4;
wxPanel* Panel1;
wxStaticText* StaticText1;
wxGrid* Grid1;
wxButton* ReCalcButton;
wxMenuItem* MenuItem3;
wxStatusBar* StatusBar1;
wxChoice* Choice1;
//*)
DECLARE_EVENT_TABLE()
};
#endif // CB_SRLIST_WXMAIN_H
CB_SRList_wxApp.cpp, I have put a comment at the line where we the difficulties in
/***************************************************************
* Name: CB_SRList_wxApp.cpp
* Purpose: Code for Application Class
* Author: ()
* Created: 2016-04-15
* Copyright: ()
* License:
**************************************************************/
#include "wx_pch.h"
#include "CB_SRList_wxApp.h"
#include <iostream> //! DrO
//(*AppHeaders
#include "CB_SRList_wxMain.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(CB_SRList_wxApp);
static wxString InitialFileName_wxs; // DrO
bool lInitialFileName_wxs; // DrO
bool CB_SRList_wxApp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
CB_SRList_wxFrame* Frame = new CB_SRList_wxFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
//*)
int CmdArgC = wxApp::argc; //! DrO
wxChar ** CmdArgV = wxApp::argv; //! DrO
lInitialFileName_wxs = FALSE; // DrO
//! also create count, for latter "full Char(Len=n)" assignment
if( CmdArgC != 2) // DrO
{
return wxsOK;
};
int CmdArgIndex = 1; // DrO
int CharCount = 0; // DrO
for (int j = 0; CmdArgV[CmdArgIndex][j] != '\0'; ++j) // DrO
{
CharCount = CharCount + 1;
}
if( CharCount < 1 ) // DrO
{
return wxsOK;
};
char ArgVCharFull[CharCount+1] = {'\0'}; // DrO
//! CONVERT TO Char(Len=CharCount)
//! ------------------------------
//! Start at 1 to skip the program name, since
//! -----------------------------------
for ( int j = 0; j<CharCount ; ++j) // DrO
{
ArgVCharFull[j] = CmdArgV[CmdArgIndex][j];
}
lInitialFileName_wxs = TRUE; // DrO
InitialFileName_wxs = wxString::FromUTF8(ArgVCharFull); // DrO
CB_SRList_wxFrame::SetValue_of_FileName_TextCtrl1( InitialFileName_wxs); // DrO// <<<<<<<<<<<<<< This is where the problems are
return wxsOK;
}
/***************************************************************
* Name: CB_SRList_wxApp.h
* Purpose: Defines Application Class
* Author: ()
* Created: 2016-04-15
* Copyright: ()
* License:
**************************************************************/
#ifndef CB_SRLIST_WXAPP_H
#define CB_SRLIST_WXAPP_H
#include <wx/app.h>
class CB_SRList_wxApp : public wxApp
{
public:
virtual bool OnInit();
};
#endif // CB_SRLIST_WXAPP_H