add wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK and semi-automatic header resizing support
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57186 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -45,6 +45,10 @@ const unsigned int wxNO_COLUMN = static_cast<unsigned>(-1);
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxHeaderCtrlNameStr[] = "wxHeaderCtrl";
|
||||
|
||||
BEGIN_EVENT_TABLE(wxHeaderCtrlBase, wxControl)
|
||||
EVT_HEADER_SEPARATOR_DCLICK(wxID_ANY, wxHeaderCtrlBase::OnSeparatorDClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void wxHeaderCtrlBase::ScrollWindow(int dx,
|
||||
int WXUNUSED_UNLESS_DEBUG(dy),
|
||||
const wxRect * WXUNUSED_UNLESS_DEBUG(rect))
|
||||
@@ -60,6 +64,19 @@ void wxHeaderCtrlBase::ScrollWindow(int dx,
|
||||
DoScrollHorz(dx);
|
||||
}
|
||||
|
||||
void wxHeaderCtrlBase::OnSeparatorDClick(wxHeaderCtrlEvent& event)
|
||||
{
|
||||
const unsigned col = event.GetColumn();
|
||||
|
||||
int w = wxWindowBase::GetTextExtent(GetColumn(col).GetTitle()).x;
|
||||
w += 2*GetCharWidth(); // add some arbitrary margins around text
|
||||
|
||||
if ( !UpdateColumnWidthToFit(col, w) )
|
||||
event.Skip();
|
||||
else
|
||||
UpdateColumn(col);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxHeaderCtrlSimple implementation
|
||||
// ============================================================================
|
||||
@@ -145,3 +162,5 @@ const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_CLICK = wxNewEventType();
|
||||
const wxEventType wxEVT_COMMAND_HEADER_DCLICK = wxNewEventType();
|
||||
const wxEventType wxEVT_COMMAND_HEADER_RIGHT_DCLICK = wxNewEventType();
|
||||
const wxEventType wxEVT_COMMAND_HEADER_MIDDLE_DCLICK = wxNewEventType();
|
||||
|
||||
const wxEventType wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK = wxNewEventType();
|
||||
|
||||
Reference in New Issue
Block a user