- wxAUI: update floating window position and not only size on resize (MacGyver).
- Added wxComboCtrl::SetTextCtrlStyle().
- Also update client data in wxRearrangeList control (John Roberts).
+- Generate more click events in wxGrid when using native header (John Roberts).
GTK:
private:
wxGrid *GetOwner() const { return static_cast<wxGrid *>(GetParent()); }
+ static wxMouseEvent GetDummyMouseEvent()
+ {
+ // make up a dummy event for the grid event to use -- unfortunately we
+ // can't do anything else here
+ wxMouseEvent e;
+ e.SetState(wxGetMouseState());
+ return e;
+ }
+
// override the base class method to update our m_columns array
virtual void OnColumnCountChanging(unsigned int count)
{
// as this is done by the user we should notify the main program about
// it
-
- // make up a dummy event for the grid event to use -- unfortunately we
- // can't do anything else here
- wxMouseEvent e;
- e.SetState(wxGetMouseState());
- GetOwner()->SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, idx, e);
+ GetOwner()->SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, idx,
+ GetDummyMouseEvent());
}
// overridden to react to the columns order changes in the customization
// event handlers forwarding wxHeaderCtrl events to wxGrid
void OnClick(wxHeaderCtrlEvent& event)
{
+ GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_CLICK,
+ -1, event.GetColumn(),
+ GetDummyMouseEvent());
+
GetOwner()->DoColHeaderClick(event.GetColumn());
}
+ void OnDoubleClick(wxHeaderCtrlEvent& event)
+ {
+ if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_LEFT_DCLICK,
+ -1, event.GetColumn(),
+ GetDummyMouseEvent()) )
+ {
+ event.Skip();
+ }
+ }
+
+ void OnRightClick(wxHeaderCtrlEvent& event)
+ {
+ if ( !GetOwner()->SendEvent(wxEVT_GRID_LABEL_RIGHT_CLICK,
+ -1, event.GetColumn(),
+ GetDummyMouseEvent()) )
+ {
+ event.Skip();
+ }
+ }
+
void OnBeginResize(wxHeaderCtrlEvent& event)
{
GetOwner()->DoStartResizeCol(event.GetColumn());
are using the grid to display tabular data and don't have thousands of
columns in it.
- Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and
- @c wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column
- labels if the native columns header is used (but this limitation could
- possibly be lifted in the future).
+ Another difference between the default behaviour and the native header
+ behaviour is that the latter provides the user with a context menu
+ (which appears on right clicking the header) allowing to rearrange the
+ grid columns if CanDragColMove() returns @true. If you want to prevent
+ this from happening for some reason, you need to define a handler for
+ @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in
+ particular doesn't skip the event) as this will prevent the default
+ right click handling from working.
+
+ Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not
+ generated for the column labels if the native columns header is used
+ (but this limitation could possibly be lifted in the future).
*/
void UseNativeColHeader(bool native = true);
BEGIN_EVENT_TABLE(wxGridHeaderCtrl, wxHeaderCtrl)
EVT_HEADER_CLICK(wxID_ANY, wxGridHeaderCtrl::OnClick)
+ EVT_HEADER_DCLICK(wxID_ANY, wxGridHeaderCtrl::OnDoubleClick)
+ EVT_HEADER_RIGHT_CLICK(wxID_ANY, wxGridHeaderCtrl::OnRightClick)
EVT_HEADER_BEGIN_RESIZE(wxID_ANY, wxGridHeaderCtrl::OnBeginResize)
EVT_HEADER_RESIZING(wxID_ANY, wxGridHeaderCtrl::OnResizing)