Fix applying header style of wxMSWHeaderCtrl

Call SetWindowStyleFlag when creating the control. Apply wxHD_BITMAP_ON_RIGHT
style. Get rid of the helper function.
This commit is contained in:
Maarten Bent
2020-01-17 23:04:56 +01:00
parent f5548e399e
commit fd9df06d35
2 changed files with 12 additions and 12 deletions

View File

@@ -72,10 +72,6 @@ private:
// Events. // Events.
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
// Style flag helper function.
long ApplyHeaderReorderFlagToStyle(long style);
// The native header control. // The native header control.
wxMSWHeaderCtrl* m_nativeControl; wxMSWHeaderCtrl* m_nativeControl;
friend class wxMSWHeaderCtrl; friend class wxMSWHeaderCtrl;

View File

@@ -1048,10 +1048,12 @@ bool wxHeaderCtrl::Create(wxWindow *parent,
wxID_ANY, wxID_ANY,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
ApplyHeaderReorderFlagToStyle(wxNO_BORDER), wxNO_BORDER,
wxMSWHeaderCtrlNameStr) ) wxMSWHeaderCtrlNameStr) )
return false; return false;
SetWindowStyle(newStyle);
Bind(wxEVT_SIZE, &wxHeaderCtrl::OnSize, this); Bind(wxEVT_SIZE, &wxHeaderCtrl::OnSize, this);
return true; return true;
@@ -1136,16 +1138,18 @@ void wxHeaderCtrl::SetWindowStyleFlag(long style)
// Update the native control style. // Update the native control style.
long flags = m_nativeControl->GetWindowStyleFlag(); long flags = m_nativeControl->GetWindowStyleFlag();
flags = ApplyHeaderReorderFlagToStyle(flags);
m_nativeControl->SetWindowStyleFlag(flags);
}
long wxHeaderCtrl::ApplyHeaderReorderFlagToStyle(long style)
{
if ( HasFlag(wxHD_ALLOW_REORDER) ) if ( HasFlag(wxHD_ALLOW_REORDER) )
return style | wxHD_ALLOW_REORDER; flags |= wxHD_ALLOW_REORDER;
else
flags &= ~wxHD_ALLOW_REORDER;
return style & ~wxHD_ALLOW_REORDER; if ( HasFlag(wxHD_BITMAP_ON_RIGHT) )
flags |= wxHD_BITMAP_ON_RIGHT;
else
flags &= ~wxHD_BITMAP_ON_RIGHT;
m_nativeControl->SetWindowStyleFlag(flags);
} }
#endif // wxHAS_GENERIC_HEADERCTRL #endif // wxHAS_GENERIC_HEADERCTRL