- Added wxBookCtrlBase::FindPage() (troelsk).
- Added wxDocument::Activate() (troelsk).
- Added wxDocManager::FindDocumentByPath() (troelsk).
+- Added wxEVT_GRID_COL_AUTO_SIZE event (Igor Korot).
wxGTK:
int SendEvent(const wxEventType evtType, const wxString& s = wxString())
{ return SendEvent(evtType, m_currentCellCoords, s); }
- // send wxEVT_GRID_{ROW,COL}_SIZE
- void SendGridSizeEvent(wxEventType type,
+ // send wxEVT_GRID_{ROW,COL}_SIZE or wxEVT_GRID_COL_AUTO_SIZE, return true
+ // if the event was processed, false otherwise
+ bool SendGridSizeEvent(wxEventType type,
int row, int col,
const wxMouseEvent& mouseEv);
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGING, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGED, wxGridEvent );
#define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn)
#define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn)
#define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn)
+#define EVT_GRID_CMD_COL_AUTO_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_AUTO_SIZE, id, fn)
#define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn)
#define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn)
#define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
#define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn)
#define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn)
#define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn)
+#define EVT_GRID_COL_AUTO_SIZE(fn) EVT_GRID_CMD_COL_AUTO_SIZE(wxID_ANY, fn)
#define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
#define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn)
#define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
type.
@event{EVT_GRID_COL_SIZE(func)}
Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
+ @event{EVT_GRID_COL_AUTO_SIZE(func)}
+ This event is sent when a column must be resized to its best size, e.g.
+ when the user double clicks the column divider. The default
+ implementation simply resizes the column to fit the column label (but
+ not its contents as this could be too slow for big grids). This macro
+ corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since
+ wxWidgets 2.9.5.
@event{EVT_GRID_ROW_SIZE(func)}
Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
@endEventTable
wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
wxEventType wxEVT_GRID_ROW_SIZE;
wxEventType wxEVT_GRID_COL_SIZE;
+wxEventType wxEVT_GRID_COL_AUTO_SIZE;
wxEventType wxEVT_GRID_RANGE_SELECT;
wxEventType wxEVT_GRID_CELL_CHANGING;
wxEventType wxEVT_GRID_CELL_CHANGED;
EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
EVT_GRID_ROW_SIZE( GridFrame::OnRowSize )
EVT_GRID_COL_SIZE( GridFrame::OnColSize )
+ EVT_GRID_COL_AUTO_SIZE( GridFrame::OnColAutoSize )
EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
EVT_GRID_CELL_CHANGING( GridFrame::OnCellValueChanging )
ev.Skip();
}
+void GridFrame::OnColAutoSize( wxGridSizeEvent &event )
+{
+ // Fit even-numbered columns to their contents while using the default
+ // behaviour for the odd-numbered ones to be able to see the difference.
+ int col = event.GetRowOrCol();
+ if ( col % 2 )
+ {
+ wxLogMessage("Auto-sizing column %d to fit its contents", col);
+ grid->AutoSizeColumn(col);
+ }
+ else
+ {
+ event.Skip();
+ }
+}
void GridFrame::OnSelectCell( wxGridEvent& ev )
{
void OnCellLeftClick( wxGridEvent& );
void OnRowSize( wxGridSizeEvent& );
void OnColSize( wxGridSizeEvent& );
+ void OnColAutoSize( wxGridSizeEvent& );
void OnSelectCell( wxGridEvent& );
void OnRangeSelected( wxGridRangeSelectEvent& );
void OnCellValueChanging( wxGridEvent& );
wxDEFINE_EVENT( wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
+wxDEFINE_EVENT( wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_MOVE, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_SORT, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
// adjust column width depending on label text
//
// TODO: generate RESIZING event, see #10754
- AutoSizeColLabelSize( colEdge );
+ if ( !SendGridSizeEvent(wxEVT_GRID_COL_AUTO_SIZE, -1, colEdge, event) )
+ AutoSizeColLabelSize( colEdge );
SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, colEdge, event);
// event generation helpers
// ----------------------------------------------------------------------------
-void
+bool
wxGrid::SendGridSizeEvent(wxEventType type,
int row, int col,
const wxMouseEvent& mouseEv)
mouseEv.GetY() + GetColLabelSize(),
mouseEv);
- GetEventHandler()->ProcessEvent(gridEvt);
+ return GetEventHandler()->ProcessEvent(gridEvt);
}
// Generate a grid event based on a mouse event and return: