jongough / ocpn_draw_pi

OpenCPN general drawing plug in
8 stars 17 forks source link

wxFormBuilder setup #474

Closed bdbcat closed 3 years ago

bdbcat commented 3 years ago

Jon... I am working on adapting some of the ocpn_draw_pi dialogs to work acceptably on small Android devices. I do not seems to be able to setup wxFormBuilder to generate the same code as I see in the "Forms" directories.

For example, on ODPropertiesDialogDef.cpp, your github master source starts like:

///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Jul  6 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "ODPropertiesDialogDef.h"

///////////////////////////////////////////////////////////////////////////

ODPropertiesDialogDef::ODPropertiesDialogDef()
{
}

ODPropertiesDialogDef::ODPropertiesDialogDef( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
{
    this->Create( parent, id, title, pos, size, style );
}

bool ODPropertiesDialogDef::Create( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
{
    if ( !wxDialog::Create( parent, id, title, pos, size, style ) )
    {
        return false;
    }

    this->SetSizeHints( wxDefaultSize, wxDefaultSize );

When I make a small change to the .fbp file, I get this from the wxFB generated code:

///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "ODPropertiesDialogDef.h"

///////////////////////////////////////////////////////////////////////////

ODPropertiesDialogDef::ODPropertiesDialogDef( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );

    m_SizerProperties = new wxBoxSizer( wxVERTICAL );

Note that your code has a simple CTOR calling a Create() method. My generated code has no such Create() method, but all the work is done in the CTOR. I can see that we are not using the same wxFB version. I am running from the wxFB flatpak Release, from the wxFB github listings. I think there may be some wxFB setting to specify the properties of the generated code. But I cannot find it. Or maybe this is solely due to the wxFB version differences.

Any ideas? Thanks Dave

jongough commented 3 years ago

wxFormbuilder did not have any way of delaying creation of the objects when you created the dialog. For android if you want to change the font you have to do it before you create any objects that will use it otherwise if you change the font afterwards the actual font changes but the size of the objects does not. This then makes a mess of the dialog box.

To counter this I helped develop a mod to wxFormbuilder that allows you to select if you want to use 'Create' or not. So you will need to use a version of wxFormBuilder generated after 7th June 2021, https://github.com/wxFormBuilder/wxFormBuilder. I have a ubuntu version of it built if you want to use that, just let me know and I will email you it.

bdbcat commented 3 years ago

Jon... Thanks for the fill. Makes perfect sense, and only way to do the fonts so that they that will cooperate with the sizers, or vice versa. I tried a build of wxFB from its github HEAD. Crashed immediately. So if you have a Ubuntu PKG ready to go, I would surely appreciate it. Thanks Dave

jongough commented 3 years ago

In OD I use the Forms directory for working with wxFormbuilder and save the files (fbp & Def.h/c), then I copy them to the include and src where they will be found during the build process. I do this so that I don't cause issues if I hit the wrong key at the wrong time in wxFormbuilder.

bdbcat commented 3 years ago

Jon... If you have a .deb for wxFormBuilder, installable on Ubuntu 18.04, I would really appreciate it.

Multiple build-from-source tries according to wxFormBuilder github repo instructions are failing. Seems to build OK, but crashes immediately on C++ code generation step.

Thanks Dave

jongough commented 3 years ago

I have cobbled together a deb file which I have attached (just remove the zip suffix). It should work, it does for me on a Ubuntu 20.04.

To get the build to work for me I have to remove the media bit from the meson.build file, lines 34, 35 & 36. wxformbuilder-jg-2.9.1.deb.zip

bdbcat commented 3 years ago

Thanks, I'll check it out.

jongough commented 3 years ago

I presume this can be closed as you managed to work with the supplied version.

bdbcat commented 3 years ago

Thanks for the pointers. I found that the current wxFB source will build correctly, but the installer assumes a multi-arch environment. A little bit of symlink-ing fixed it up. The result produces the desired output.