[Git][wxwidgets/wxwidgets][master] Simplify wxSplashScreen drawing code

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 15, 2026, 12:58:37 PM (yesterday) May 15
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • bf386d99
    by Paul Cornett at 2026-05-15T09:31:46-07:00
    Simplify wxSplashScreen drawing code
    
    Use wxBG_STYLE_PAINT, remove all the EVT_ERASE_BACKGROUND stuff,
    and just draw the bitmap in the paint handler.
    

1 changed file:

Changes:

  • src/generic/splash.cpp
    ... ... @@ -20,7 +20,6 @@
    20 20
     #include "wx/splash.h"
    
    21 21
     
    
    22 22
     #ifndef WX_PRECOMP
    
    23
    -    #include "wx/dcmemory.h"
    
    24 23
         #include "wx/dcclient.h"
    
    25 24
     #endif
    
    26 25
     
    
    ... ... @@ -130,10 +129,7 @@ void wxSplashScreen::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
    130 129
     // ----------------------------------------------------------------------------
    
    131 130
     
    
    132 131
     wxBEGIN_EVENT_TABLE(wxSplashScreenWindow, wxWindow)
    
    133
    -#ifdef __WXGTK__
    
    134 132
         EVT_PAINT(wxSplashScreenWindow::OnPaint)
    
    135
    -#endif
    
    136
    -    EVT_ERASE_BACKGROUND(wxSplashScreenWindow::OnEraseBackground)
    
    137 133
     wxEND_EVENT_TABLE()
    
    138 134
     
    
    139 135
     wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent,
    
    ... ... @@ -142,6 +138,7 @@ wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* par
    142 138
         : wxWindow(parent, id, pos, size, style)
    
    143 139
         , m_bitmap(bitmap)
    
    144 140
     {
    
    141
    +    SetBackgroundStyle(wxBG_STYLE_PAINT);
    
    145 142
     
    
    146 143
     #if !defined(__WXGTK__) && wxUSE_PALETTE
    
    147 144
         bool hiColour = (wxDisplayDepth() >= 16) ;
    
    ... ... @@ -153,56 +150,11 @@ wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* par
    153 150
     #endif
    
    154 151
     }
    
    155 152
     
    
    156
    -// VZ: why don't we do it under wxGTK?
    
    157
    -#if !defined(__WXGTK__) && wxUSE_PALETTE
    
    158
    -    #define USE_PALETTE_IN_SPLASH
    
    159
    -#endif
    
    160
    -
    
    161
    -static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y))
    
    162
    -{
    
    163
    -    wxMemoryDC dcMem;
    
    164
    -
    
    165
    -#ifdef USE_PALETTE_IN_SPLASH
    
    166
    -    bool hiColour = (wxDisplayDepth() >= 16) ;
    
    167
    -
    
    168
    -    if (bitmap.GetPalette() && !hiColour)
    
    169
    -    {
    
    170
    -        dcMem.SetPalette(* bitmap.GetPalette());
    
    171
    -    }
    
    172
    -#endif // USE_PALETTE_IN_SPLASH
    
    173
    -
    
    174
    -    dcMem.SelectObjectAsSource(bitmap);
    
    175
    -    dc.Blit(0, 0, bitmap.GetLogicalWidth(), bitmap.GetLogicalHeight(), &dcMem, 0, 0, wxCOPY,
    
    176
    -            true /* use mask */);
    
    177
    -    dcMem.SelectObject(wxNullBitmap);
    
    178
    -
    
    179
    -#ifdef USE_PALETTE_IN_SPLASH
    
    180
    -    if (bitmap.GetPalette() && !hiColour)
    
    181
    -    {
    
    182
    -        dcMem.SetPalette(wxNullPalette);
    
    183
    -    }
    
    184
    -#endif // USE_PALETTE_IN_SPLASH
    
    185
    -}
    
    186
    -
    
    187 153
     void wxSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
    
    188 154
     {
    
    189 155
         wxPaintDC dc(this);
    
    190 156
         if (m_bitmap.IsOk())
    
    191
    -        wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
    
    192
    -}
    
    193
    -
    
    194
    -void wxSplashScreenWindow::OnEraseBackground(wxEraseEvent& event)
    
    195
    -{
    
    196
    -    if (event.GetDC() && m_bitmap.IsOk())
    
    197
    -    {
    
    198
    -        wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0);
    
    199
    -    }
    
    200
    -    else
    
    201
    -    {
    
    202
    -        wxClientDC dc(this);
    
    203
    -        if (m_bitmap.IsOk())
    
    204
    -            wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
    
    205
    -    }
    
    157
    +        dc.DrawBitmap(m_bitmap, 0, 0, true);
    
    206 158
     }
    
    207 159
     
    
    208 160
     #endif // wxUSE_SPLASH


View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help Notification message regarding https://gitlab.com/wxwidgets/wxwidgets/-/commit/bf386d99c039e494680a0fa514fd3e606b33ecc2 at 1778864299

Reply all
Reply to author
Forward
0 new messages