Menu

#234 C::B build against wx3, wxListBook show icons badly

Undefined
open
nobody
Bug_Report
2016-02-12
2015-10-07
ollydbg
No

My bug report in forum: Re: Build C::B against wx3.02 with gcc 5.2 under Windows

The screen shot(left: cb build with wx3, right: with 2x 2.8)
screen shot

Discussion

1 2 > >> (Page 1 of 2)
  • ollydbg

    ollydbg - 2015-10-07
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
     My bug report in forum: [Re: Build C::B against wx3.02 with gcc 5.2 under Windows](http://forums.codeblocks.org/index.php/topic,20607.msg140384.html#msg140384)
    
    -The screen shot
    +The screen shot(left: cb build with wx3, right: with 2x 2.8)
     ![screen shot](http://imagizer.imageshack.us/v2/327x524q90/903/Fs5ita.png)
    
     
  • ollydbg

    ollydbg - 2016-01-04

    This is where the XRC is loaded:

    EditorConfigurationDlg::EditorConfigurationDlg(wxWindow* parent)
        : m_TextColourControl(nullptr),
        m_Theme(nullptr),
        m_Lang(HL_NONE),
        m_DefCodeFileType(0),
        m_ThemeModified(false),
        m_EnableChangebar(false),
        m_pImageList(nullptr)
    {
        wxXmlResource::Get()->LoadObject(this, parent, _T("dlgConfigureEditor"),_T("wxScrollingDialog"));
    

    The XRC file is located in:

    src\resources\editor_configuration.xrc
    

    I see that in the xrc, the listbookpage(in the page wxWidgets: XRC File Format ) doesn't have the icon or image property, and it is set in the function:

        // add all plugins configuration panels
        AddPluginPanels();
    

    Not sure where is cause of such issue.

     
  • Teodor Petrov

    Teodor Petrov - 2016-01-04

    Have you checked the size of the two list controls?
    Probalby the easiest way to debug this is to step into the loading functions to see what happens.

    By the looks of it the images are resized and this is causing the uglyness.

     
    • ollydbg

      ollydbg - 2016-01-04

      When the XRC is loading, there is no image in the listctrl. All the images were added here:

      void EditorConfigurationDlg::UpdateListbookImages()
      {
          wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
          int sel = lb->GetSelection();
      
          if (SettingsIconsStyle(Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/environment/settings_size"), 0)))
          {
              SetSettingsIconsStyle(lb->GetListView(), sisNoIcons);
              lb->SetImageList(nullptr);
          }
          else
          {
              lb->SetImageList(m_pImageList);
              // set page images according to their on/off status
              for (size_t i = 0; i < IMAGES_COUNT + m_PluginPanels.GetCount(); ++i)
                  lb->SetPageImage(i, (i * 2) + (sel == (int)i ? 0 : 1));
              SetSettingsIconsStyle(lb->GetListView(), sisLargeIcons);
          }
      
          // update the page title
          wxString label = lb->GetPageText(sel);
          // replace any stray & with && because label makes it an underscore
          while (label.Replace(_T(" & "), _T(" && ")))
              ;
          XRCCTRL(*this, "lblBigTitle", wxStaticText)->SetLabel(label);
          XRCCTRL(*this, "pnlTitleInfo", wxPanel)->Layout();
      }
      

      I will try to see what is the size of "lb->GetListView()".

       
  • Teodor Petrov

    Teodor Petrov - 2016-01-04

    Also in wxGTK it looks fine with wx3.0.

     
  • ollydbg

    ollydbg - 2016-01-05
    void EditorConfigurationDlg::AddPluginPanels()
    {
        const wxString base = _T("images/settings/");
        // for plugins who do not supply icons, use common generic icons
        const wxString noimg = _T("images/settings/generic-plugin");
    
        wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
        // get all configuration panels which are about the editor.
        Manager::Get()->GetPluginManager()->GetConfigurationPanels(cgEditor, lb, m_PluginPanels);
    
        int length = 40;
    
        for (size_t i = 0; i < m_PluginPanels.GetCount(); ++i)
        {
            cbConfigurationPanel* panel = m_PluginPanels[i];
            panel->SetParentDialog(this);
            lb->AddPage(panel, panel->GetTitle());
    
            wxString onFile = ConfigManager::LocateDataFile(base + panel->GetBitmapBaseName() + _T(".png"), sdDataGlobal | sdDataUser);
            if (onFile.IsEmpty())
                onFile = ConfigManager::LocateDataFile(noimg + _T(".png"), sdDataGlobal | sdDataUser);
            wxString offFile = ConfigManager::LocateDataFile(base + panel->GetBitmapBaseName() + _T("-off.png"), sdDataGlobal | sdDataUser);
            if (offFile.IsEmpty())
                offFile = ConfigManager::LocateDataFile(noimg + _T("-off.png"), sdDataGlobal | sdDataUser);
            wxBitmap bmp = cbLoadBitmap(onFile);
            wxImage wx_image2 = bmp.ConvertToImage();
            wx_image2.Rescale(length, length);
            wxBitmap bmp2(wx_image2);
            m_pImageList->Add(bmp2);
            bmp = cbLoadBitmap(offFile);
            wxImage wx_image3 = bmp.ConvertToImage();
            wx_image3.Rescale(length, length);
            wxBitmap bmp3(wx_image3);
            m_pImageList->Add(bmp3);
            lb->SetPageImage(lb->GetPageCount() - 1, m_pImageList->GetImageCount() - 2);
        }
    
        UpdateListbookImages();
    }
    
    void EditorConfigurationDlg::LoadListbookImages()
    {
        const wxString base = ConfigManager::GetDataFolder() + _T("/images/settings/");
    
        int length = 40;
        m_pImageList = new wxImageList(length, length);
        wxBitmap bmp;
        for (int i = 0; i < IMAGES_COUNT; ++i)
        {
            bmp = cbLoadBitmap(base + base_imgs[i] + _T(".png"));
            wxImage wx_image2 = bmp.ConvertToImage();
            wx_image2.Rescale(length, length);
            wxBitmap bmp2(wx_image2);
            m_pImageList->Add(bmp2);
            bmp = cbLoadBitmap(base + base_imgs[i] + _T("-off.png"));
            wxImage wx_image3 = bmp.ConvertToImage();
            wx_image3.Rescale(length, length);
            wxBitmap bmp3(wx_image3);
            m_pImageList->Add(bmp3);
        }
    }
    

    I can scale the bitmap size of the listview inside the listbook, if I set to 40, then I see the icons are shown in the middle of the listview. But if I change it to 120, I see the same effect, that is the icons are moved a bit to the left edge of the listview, also the image the automatically scaled when put inside the listview.

     
    • Teodor Petrov

      Teodor Petrov - 2016-01-05

      What is this code in EditorConfigurationDlg::LoadListbookImages? Mine is totally different. If you want other people to understand you post patches not whole function out of scope.

       
  • ollydbg

    ollydbg - 2016-01-05

    The notebook sample in the wx git(3.x) head does not expose such issue, I can just use large images, such as 80 x 80 icons, the code need to change is:

        // create a dummy image list with a few icons
        const wxSize imageSize(80, 80);
    
        m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
    

    It is much simpler, it just set the image list by the function call:

        // wxToolbook doesn't work without icons so always use them for it.
        if ( m_chkShowImages || m_type == Type_Toolbook )
        {
            m_bookCtrl->SetImageList(m_imageList);
        }
    

    While, in our C::B's code, we did more things, such as set image for each panel.

     

    Last edit: ollydbg 2016-01-05
  • Teodor Petrov

    Teodor Petrov - 2016-01-06

    BTW: Can you try with wx-master if this same problem exists?

     
  • ollydbg

    ollydbg - 2016-01-06

    I build C::B trunk against wx-master. (The wx library version is 3.1)
    I can still see the same issue as C::B against wx 3.0.2.

     
  • ollydbg

    ollydbg - 2016-01-06

    If C::B is build with such patch

     src/src/editorconfigurationdlg.cpp | 33 +++++++++++++++++++++++++++------
     1 file changed, 27 insertions(+), 6 deletions(-)
    
    diff --git a/src/src/editorconfigurationdlg.cpp b/src/src/editorconfigurationdlg.cpp
    index 3ee0c1d..2acd1d9 100644
    --- a/src/src/editorconfigurationdlg.cpp
    +++ b/src/src/editorconfigurationdlg.cpp
    @@ -279,8 +279,13 @@ EditorConfigurationDlg::EditorConfigurationDlg(wxWindow* parent)
    
         // make sure everything is laid out properly
         GetSizer()->SetSizeHints(this);
    +    wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
    +    wxListView* lv = lb->GetListView();
    +    wxSize sz = lv->GetSize();
         CentreOnParent();
         Layout();
    +    sz = lv->GetSize();
    +    return;
     }
    
     EditorConfigurationDlg::~EditorConfigurationDlg()
    @@ -304,6 +309,8 @@ void EditorConfigurationDlg::AddPluginPanels()
         // get all configuration panels which are about the editor.
         Manager::Get()->GetPluginManager()->GetConfigurationPanels(cgEditor, lb, m_PluginPanels);
    
    +    int length = 40;
    +
         for (size_t i = 0; i < m_PluginPanels.GetCount(); ++i)
         {
             cbConfigurationPanel* panel = m_PluginPanels[i];
    @@ -316,9 +323,16 @@ void EditorConfigurationDlg::AddPluginPanels()
             wxString offFile = ConfigManager::LocateDataFile(base + panel->GetBitmapBaseName() + _T("-off.png"), sdDataGlobal | sdDataUser);
             if (offFile.IsEmpty())
                 offFile = ConfigManager::LocateDataFile(noimg + _T("-off.png"), sdDataGlobal | sdDataUser);
    -
    -        m_pImageList->Add(cbLoadBitmap(onFile));
    -        m_pImageList->Add(cbLoadBitmap(offFile));
    +        wxBitmap bmp = cbLoadBitmap(onFile);
    +        wxImage wx_image2 = bmp.ConvertToImage();
    +        wx_image2.Rescale(length, length);
    +        wxBitmap bmp2(wx_image2);
    +        m_pImageList->Add(bmp2);
    +        bmp = cbLoadBitmap(offFile);
    +        wxImage wx_image3 = bmp.ConvertToImage();
    +        wx_image3.Rescale(length, length);
    +        wxBitmap bmp3(wx_image3);
    +        m_pImageList->Add(bmp3);
             lb->SetPageImage(lb->GetPageCount() - 1, m_pImageList->GetImageCount() - 2);
         }
    
    @@ -329,14 +343,21 @@ void EditorConfigurationDlg::LoadListbookImages()
     {
         const wxString base = ConfigManager::GetDataFolder() + _T("/images/settings/");
    
    -    m_pImageList = new wxImageList(80, 80);
    +    int length = 40;
    +    m_pImageList = new wxImageList(length, length);
         wxBitmap bmp;
         for (int i = 0; i < IMAGES_COUNT; ++i)
         {
             bmp = cbLoadBitmap(base + base_imgs[i] + _T(".png"));
    -        m_pImageList->Add(bmp);
    +        wxImage wx_image2 = bmp.ConvertToImage();
    +        wx_image2.Rescale(length, length);
    +        wxBitmap bmp2(wx_image2);
    +        m_pImageList->Add(bmp2);
             bmp = cbLoadBitmap(base + base_imgs[i] + _T("-off.png"));
    -        m_pImageList->Add(bmp);
    +        wxImage wx_image3 = bmp.ConvertToImage();
    +        wx_image3.Rescale(length, length);
    +        wxBitmap bmp3(wx_image3);
    +        m_pImageList->Add(bmp3);
         }
     }
    

    Then, the result C::B with have 40 sized icon in the Editor configure dialog, and the icon is correctly centered in the listview.

     
  • ollydbg

    ollydbg - 2016-01-06
    
    

    void EditorConfigurationDlg::AddPluginPanels()
    {
    const wxString base = _T("images/settings/");
    // for plugins who do not supply icons, use common generic icons
    const wxString noimg = _T("images/settings/generic-plugin");

    wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
    // get all configuration panels which are about the editor.
    Manager::Get()->GetPluginManager()->GetConfigurationPanels(cgEditor, lb, m_PluginPanels);
    
    for (size_t i = 0; i < m_PluginPanels.GetCount(); ++i)
    {
        cbConfigurationPanel* panel = m_PluginPanels[i];
        panel->SetParentDialog(this);
        lb->AddPage(panel, panel->GetTitle());
    
        wxString onFile = ConfigManager::LocateDataFile(base + panel->GetBitmapBaseName() + _T(".png"), sdDataGlobal | sdDataUser);
        if (onFile.IsEmpty())
            onFile = ConfigManager::LocateDataFile(noimg + _T(".png"), sdDataGlobal | sdDataUser);
        wxString offFile = ConfigManager::LocateDataFile(base + panel->GetBitmapBaseName() + _T("-off.png"), sdDataGlobal | sdDataUser);
        if (offFile.IsEmpty())
            offFile = ConfigManager::LocateDataFile(noimg + _T("-off.png"), sdDataGlobal | sdDataUser);
    
        m_pImageList->Add(cbLoadBitmap(onFile));
        m_pImageList->Add(cbLoadBitmap(offFile));
        lb->SetPageImage(lb->GetPageCount() - 1, m_pImageList->GetImageCount() - 2);
    }
    
    UpdateListbookImages();
    

    }

    I notices that the m_pImageList will be set to listbook inside the UpdateListbookImages() function, but I see the function call before.
    

    lb->SetPageImage(lb->GetPageCount() - 1, m_pImageList->GetImageCount() - 2);

    Here, the lb does not know what does the imageId means. Since it does not know the full image list.
    
     
  • ollydbg

    ollydbg - 2016-01-07

    I just create a very simple wx application, and when I hit a button, a dialog is opened, and I just load the file content "editor_configuration.xrc", and later, I just load several images, and set images on the listbook, it works just fine. See the screen shot as attachment.

     
  • ollydbg

    ollydbg - 2016-01-07

    To build the wx sample, you may get an build error, since there is no wxScintilla control, so you need to remove such component from the UI. To load and set the images, I just use such code:

        const wxSize imageSize(80, 80);
    
        m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
        m_imageList->
            Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
    
        Listbook1->SetImageList(m_imageList);
    
        for(int i=0;i<5;i++)
        {
            Listbook1->SetPageImage(i,i);
        }
    

    So, I guess the issue is inside C::B?

    I use wxDialog as a sample, and our C::B use wxScrollingDialog, but I don't think there are much difference.

     
  • ollydbg

    ollydbg - 2016-01-08

    I just removed all the non-GUI related code in the constructor of EditorConfigurationDlg, and I still see the wrong position of the icons. This issue also happens if I change the EditorConfigurationDlg class from wxScrollingDialog to wxDialog? (I simply replace the text wxScrollingDialog to wxDialog in the editorconfigurationdlg.cpp and the editorconfigurationdlg.h, also inside the editor_configuration.xrc. )

    So, what is the reason? I really don't know. A dialog opened from C::B is behaves badly compared if opened from a minimal sample wx app?

    Any hints?

     
  • ollydbg

    ollydbg - 2016-01-08

    Oh my god, if I simplify the listbook xrc, and I see even a very simple listbook which have only one panel will also expose this error, see the image shot as attachment.

     
  • ollydbg

    ollydbg - 2016-01-08

    Even a much simplier wxDialog.

     
  • Teodor Petrov

    Teodor Petrov - 2016-01-08

    Probably this is asymetric to have a space for a vertical scrollbar.
    What happens if you add more items in the listbook and there are items that are not visible?

     
  • ollydbg

    ollydbg - 2016-01-09

    The same issue, see the screen shot below, that's why I reduce the panel number to 1.

     
  • Teodor Petrov

    Teodor Petrov - 2016-01-19
    • Type: Undefined --> Bug_Report
     
  • ollydbg

    ollydbg - 2016-01-20

    Without the XRC file, I can still reproduce this bug inside C::B, see: https://groups.google.com/d/msg/wx-users/eA2pNgviez8/ifbIpukmAQAJ But I can't reproduce this inside a minimal wx sample program.

     
  • Teodor Petrov

    Teodor Petrov - 2016-01-21

    I'd debug them side by side inside the wxwidgets code to see what is different.

     
  • ollydbg

    ollydbg - 2016-01-21

    I can reproduce this bug in a very simple wx sample code under WinXP&MinGW-Build5.2, but another wx user can't not reproduce this bug on Win7&VC++2008.
    See that wx-user maillist discussion.

     
  • ollydbg

    ollydbg - 2016-01-24

    I see this issue in our wx 2.8 based C::B, see this forum report and screen shot:
    Bad icons of C::B in the 16.01 release

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.