[Git][wxwidgets/wxwidgets][master] 4 commits: Don't store bitmaps in wxArrayPtrVoid in widgets sample

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 31, 2025, 7:17:12 PMMay 31
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • b095a1d4
    by Vadim Zeitlin at 2025-05-31T18:57:54+02:00
    Don't store bitmaps in wxArrayPtrVoid in widgets sample
    
    Using wxArrayPtrVoid was ugly and completely unnecessary, just store
    both item labels and bitmaps in a single vector.
    
    No real changes, this is just code cleanup.
    
  • 7c38afe8
    by Vadim Zeitlin at 2025-05-31T19:47:06+02:00
    Fix determining best height of wxBitmapComboBox in wxGTK
    
    Fix the workaround for not getting the correct best size when the
    control is empty (see #23382) to work for wxBitmapComboBox, which
    doesn't use GtkComboBoxText as its widget, too.
    
    Just call gtk_list_store_insert_with_values(), which works for any
    GtkListStore, instead of gtk_combo_box_text_append_text().
    
    Closes #25468.
    
  • 4eaad012
    by Vadim Zeitlin at 2025-06-01T00:45:41+02:00
    Further improve manual linking instructions for wxMSW
    
    Mention the need to link with non-core libraries and Scintilla-related
    libraries when using static build of wxSTC.
    
    Also add a couple of Windows libraries forgotten in 3aaa1846fb (Document
    Windows import libraries to link with, 2025-05-31), see #25471.
    
  • 26c988ee
    by Vadim Zeitlin at 2025-06-01T00:48:27+02:00
    Merge branch 'bmpcbox-size'
    
    Fix read-only wxBitmapComboBox best size in wxGTK.
    
    See #25481.
    

4 changed files:

Changes:

  • docs/changes.txt
    ... ... @@ -392,6 +392,7 @@ wxGTK:
    392 392
     - Don't require libsecret-1.so presence at run-time (#25355).
    
    393 393
     - Fix handling of binary secrets in wxSecretStore (Martin Corino, #24352).
    
    394 394
     - Fix handling total window size with GNOME with X11 (#25348).
    
    395
    +- Fix height of read-only wxBitmapComboBox (#25468).
    
    395 396
     - Fix missing enter/leave window events (#24339).
    
    396 397
     - Fix wxGLCanvas scale when using EGL/Wayland in high DPI (Popax21, #23733).
    
    397 398
     - Fix using wrong colour in wxPrinterDC (#24729).
    

  • docs/msw/install.md
    ... ... @@ -494,15 +494,24 @@ MSVC, you also need to:
    494 494
       depends on which libraries you use and whether you built wxWidgets in
    
    495 495
       monolithic or default multi-lib mode and basically should include all the
    
    496 496
       relevant libraries from the directory above, e.g. `wxmsw34ud_core.lib
    
    497
    -  wxbase34ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib
    
    498
    -  wxexpatd.lib` for a debug build of an application using the core library of
    
    499
    -  wxWidgets 3.4 only (all wxWidgets applications use the base library).
    
    500
    -* When using static wxWidgets libraries, i.e. `WXUSINGDLL` is _not_ defined,
    
    501
    -  also add the list of Windows libraries to link with, which currently includes
    
    502
    -  the following libraries (some of which might be unnecessary depending on your
    
    503
    -  build configuration): `advapi32 comctl32 comdlg32 gdi32 gdiplus kernel32
    
    504
    -  msimg32 ole32 oleacc oleaut32 rpcrt4 shell32 shlwapi user32 uuid uxtheme
    
    505
    -  version wininet winmm winspool ws2_32`.
    
    497
    +  wxbase34ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxwebpd.lib wxzlibd.lib
    
    498
    +  wxregexud.lib wxexpatd.lib` for a debug build of an application using the
    
    499
    +  core library of wxWidgets 3.4 only (all wxWidgets applications use the base
    
    500
    +  library).
    
    501
    +* When using classes from non-core libraries, e.g. `wxPropertyGrid`, also link
    
    502
    +  with the corresponding library, as indicated in the class documentation, i.e.
    
    503
    +  `wxmsw34ud_propgrid.lib` in this case.
    
    504
    +* When using `wxStyledTextCtrl`, if static (not DLL) wxWidgets libraries are
    
    505
    +  used, then, in addition to linking with `wxmsw34ud_stc.lib`, you also need
    
    506
    +  to add `wxlexilla[d].lib` and `wxscintilla[d].lib` the list of libraries
    
    507
    +  to link with.
    
    508
    +* Finally, when using static wxWidgets libraries you must also add all Windows
    
    509
    +  libraries that are used by wxWidgets to the linker input. Currently this
    
    510
    +  means linking with the following libraries (some of which might be
    
    511
    +  unnecessary depending on your build configuration): `advapi32 comctl32
    
    512
    +  comdlg32 gdi32 gdiplus imm32 kernel32 msimg32 ole32 oleacc oleaut32 opengl32
    
    513
    +  rpcrt4 shell32 shlwapi user32 uuid uxtheme version wininet winmm winspool
    
    514
    +  ws2_32`.
    
    506 515
     
    
    507 516
     For example, to compile your program with gcc using debug wxWidgets DLLs
    
    508 517
     you would need to use the following options for the compiler (and `windres`
    

  • samples/widgets/bmpcombobox.cpp
    ... ... @@ -451,16 +451,26 @@ void BitmapComboBoxWidgetsPage::CreateCombo()
    451 451
                 break;
    
    452 452
         }
    
    453 453
     
    
    454
    -    wxArrayString items;
    
    455
    -    wxArrayPtrVoid bitmaps;
    
    454
    +    struct Item
    
    455
    +    {
    
    456
    +        Item(const wxString& text, const wxBitmap& bitmap)
    
    457
    +            : text(text), bitmap(bitmap)
    
    458
    +        {
    
    459
    +        }
    
    460
    +
    
    461
    +        wxString text;
    
    462
    +        wxBitmap bitmap;
    
    463
    +    };
    
    464
    +    std::vector<Item> items;
    
    456 465
         if ( m_combobox )
    
    457 466
         {
    
    458 467
             unsigned int count = m_combobox->GetCount();
    
    468
    +        items.reserve(count);
    
    469
    +
    
    459 470
             for ( unsigned int n = 0; n < count; n++ )
    
    460 471
             {
    
    461
    -            items.Add(m_combobox->GetString(n));
    
    462
    -            wxBitmap bmp = m_combobox->GetItemBitmap(n);
    
    463
    -            bitmaps.Add(new wxBitmap(bmp));
    
    472
    +            items.push_back(Item{m_combobox->GetString(n),
    
    473
    +                                 m_combobox->GetItemBitmap(n)});
    
    464 474
             }
    
    465 475
     
    
    466 476
             m_sizerCombo->Detach( m_combobox );
    
    ... ... @@ -480,12 +490,9 @@ void BitmapComboBoxWidgetsPage::CreateCombo()
    480 490
     
    
    481 491
         NotifyWidgetRecreation(m_combobox);
    
    482 492
     
    
    483
    -    unsigned int count = items.GetCount();
    
    484
    -    for ( unsigned int n = 0; n < count; n++ )
    
    493
    +    for ( const Item& item : items )
    
    485 494
         {
    
    486
    -        wxBitmap* bmp = (wxBitmap*) bitmaps[n];
    
    487
    -        m_combobox->Append(items[n], *bmp);
    
    488
    -        delete bmp;
    
    495
    +        m_combobox->Append(item.text, item.bitmap);
    
    489 496
         }
    
    490 497
     
    
    491 498
         m_sizerCombo->Add(m_combobox, 0, wxGROW | wxALL, 5);
    

  • src/gtk/choice.cpp
    ... ... @@ -432,7 +432,17 @@ wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const
    432 432
             if (gtk_tree_model_get_iter_first(model, &iter))
    
    433 433
                 model = nullptr;
    
    434 434
             else
    
    435
    -            gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_widget), "Gg");
    
    435
    +        {
    
    436
    +            gtk_list_store_insert_with_values
    
    437
    +            (
    
    438
    +                GTK_LIST_STORE(model),
    
    439
    +                nullptr,                // No output iterator.
    
    440
    +                -1,                     // Position: append.
    
    441
    +                m_stringCellIndex,      // Text column index.
    
    442
    +                "Gg",                   // This column value.
    
    443
    +                -1                      // Terminate the list of values.
    
    444
    +            );
    
    445
    +        }
    
    436 446
         }
    
    437 447
     #endif
    
    438 448
     
    

Reply all
Reply to author
Forward
0 new messages