Corner glitch when placing wxCheckBox in place of wxStaticBox label (Issue #22940)

50 views
Skip to first unread message

charvey2718

unread,
Nov 3, 2022, 8:41:15 AM11/3/22
to wx-...@googlegroups.com, Subscribed

Description

When placing a wxCheckBox at the top of a wxStaticBox, as per the constructor, here, there is a break in the surrounding box in the top-right corner.

2

No break in the surrounding box is expected. The break disappears if I replace the wxCheckbox with a wxString label.

Minimum working example

The issue is reproduced in the following MWE:
1

#include <wx/wx.h>

class MyFrame:public wxFrame {
public:
    MyFrame(wxWindow* parent);
};

class MyApp:public wxApp {
public:
    bool OnInit() {
        wxFrame* frame=new MyFrame(NULL);
        SetTopWindow(frame);
        frame->Show();
        return true;                    
    }
};

DECLARE_APP(MyApp);
IMPLEMENT_APP(MyApp);

MyFrame::MyFrame(wxWindow* parent):wxFrame(parent,wxID_ANY,_("StatBoxMWE"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_FRAME_STYLE) {
	SetClientSize(wxSize(100,100));
	wxBoxSizer* mainSizer=new wxBoxSizer(wxVERTICAL);
	
	wxCheckBox* cb=new wxCheckBox(this,wxID_ANY,_("checkbox"),wxDefaultPosition,wxDefaultSize,wxALIGN_LEFT);
	wxStaticBox* sb=new wxStaticBox(this,wxID_STATIC,cb);
	wxStaticBoxSizer *sbs=new wxStaticBoxSizer(sb,wxVERTICAL);
	
	wxStaticText* text=new wxStaticText(sb,wxID_ANY,_("hello"),wxDefaultPosition,wxDefaultSize,wxALIGN_LEFT);
	sbs->Add(text,0,wxALL,5);
	
	mainSizer->Add(sbs,1,wxEXPAND|wxALL,10);
	SetSizer(mainSizer);
}

Platform and version information

  • wxWidgets version: 3.2.1 (also seen on 3.1.7)
  • wxWidgets port: wxMSW
  • OS: Windows 10 Enterprise


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940@github.com>

PB

unread,
Nov 3, 2022, 9:06:17 AM11/3/22
to wx-...@googlegroups.com, Subscribed

As I wrote on the forums, the issue can be reproduced with the unmodified widgets sample:

  1. Launch the sample.
  2. In the widget list select Native / Static.
  3. Observe that there is no glitch.
  4. In Set style check Checkable box.
  5. The glitch appears.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1302079586@github.com>

VZ

unread,
Nov 8, 2022, 12:35:20 PM11/8/22
to wx-...@googlegroups.com, Subscribed

Yes, I can see this, thanks. Will try to debug.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1307583702@github.com>

VZ

unread,
Nov 8, 2022, 3:28:18 PM11/8/22
to wx-...@googlegroups.com, Subscribed

Copying parts of the static box to wxPaintDC used wrong coordinates, fixed now and this will have to be applied to 3.2.

However in master we actually shouldn't use the custom paint code for wxStaticBox at all, i.e. do as if msw.staticbox.optimized-paint system option were always set to 0 because it's fine to let the control paint itself there because there is no flicker when using WS_EX_COMPOSITED. Unfortunately we still need to keep all this code just in case we need to change the label colour, but we can at least avoid using it by default. And maybe we can still get rid of it.

Anyhow, I've done all this in #22952 now, please test it and let me know if you see any new problems with it (the original one should be fixed).


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1307788083@github.com>

charvey2718

unread,
Nov 8, 2022, 5:10:29 PM11/8/22
to wx-...@googlegroups.com, Subscribed

Many thanks, vadz.
I'm not really familiar with how Github works, but am willing to learn.
What's the correct way to test your commits? Should I download and compile the msw-statbox-paint branch, and test the widgets example locally?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1307893007@github.com>

VZ

unread,
Nov 8, 2022, 5:36:29 PM11/8/22
to wx-...@googlegroups.com, Subscribed

Yes, please get the branch (you can use git fetch https://github.com/vadz/wxWidgets.git && git switch msw-statbox-paint if your Git is not too ancient) and build the library from it -- and then build either the sample or, even better, your application using this version. TIA!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1307931820@github.com>

charvey2718

unread,
Nov 8, 2022, 7:15:20 PM11/8/22
to wx-...@googlegroups.com, Subscribed

The git command you suggested cloned the repo but then said invalid reference for the branch. (I'm on the latest version of git.) Nevermind, I eventually figured out git clone --recurse-submodules --branch msw-statbox-paint https://github.com/vadz/wxWidgets.git and it seemed to work okay.

Unfortunately, compiling failed with the error:

../src/msw/statbox.cpp: In member function 'virtual bool wxStaticBox::SetForegroundColour(const wxCo
lour&)':
../src/msw/statbox.cpp:231:26: error: expected type-specifier before 'wxStaticText'
         m_labelWin = new wxStaticText(this, wxID_ANY, GetLabel());
                          ^~~~~~~~~~~~
make: *** [Makefile:29170: corelib_msw_statbox.o] Error 1

I checked and statbox.cpp didn't include "#include "wx/stattext.h". I added it to line 34 and this seemed to resolve the issue as it then compiled.

I then compiled the widgets sample and my own application, and the staticbox with checkbox now both look fine.

Capture1
Capture2

It looks like your commits do indeed solve the problem (the minor issue above notwithstanding).

Thank you!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1308012188@github.com>

VZ

unread,
Nov 8, 2022, 7:32:37 PM11/8/22
to wx-...@googlegroups.com, Subscribed

Sorry for the compilation problem, I've fixed this issue in the branch but apparently after you had fetched it. And glad to hear that it works for you, thanks for testing!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1308027855@github.com>

VZ

unread,
Nov 12, 2022, 12:06:52 PM11/12/22
to wx-...@googlegroups.com, Subscribed

Closed #22940 as completed via 1c2ec47.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/22940/issue_event/7797068077@github.com>

VZ

unread,
Dec 27, 2022, 5:01:19 PM12/27/22
to wx-...@googlegroups.com, Subscribed

Forgot to mention it, but this was already applied to 3.2 in 5c39d04


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22940/1366200986@github.com>

Reply all
Reply to author
Forward
0 new messages