Determine the checkbox size in wxGetGridCheckBoxRect() itself
It doesn't make much sense to pass the size to the function supposed to compute it, so call wxRendererNative::GetCheckBoxSize() from the function itself instead of forcing its callers to do it. No real changes.
This commit is contained in:
@@ -1007,12 +1007,16 @@ private:
|
||||
wxGridDataTypeInfoArray m_typeinfo;
|
||||
};
|
||||
|
||||
// Returns the rect of the check box in a cell with the given alignmens
|
||||
// and the size.
|
||||
// The function is used by wxGridCellBoolEditor and wxGridCellBoolRenderer.
|
||||
wxRect wxGetGridCheckBoxRect(const wxSize& checkBoxSize,
|
||||
const wxRect& cellRect,
|
||||
int hAlign, int vAlign);
|
||||
// Returns the rectangle for showing a check box in a cell with the given
|
||||
// alignment.
|
||||
//
|
||||
// The function is used by wxGridCellBoolEditor and wxGridCellBoolRenderer to
|
||||
// draw a check mark and position wxCheckBox respectively.
|
||||
wxRect
|
||||
wxGetGridCheckBoxRect(wxWindow* win,
|
||||
const wxRect& cellRect,
|
||||
int hAlign,
|
||||
int vAlign);
|
||||
|
||||
#endif // wxUSE_GRID
|
||||
#endif // _WX_GENERIC_GRID_PRIVATE_H_
|
||||
|
@@ -10332,13 +10332,17 @@ wxGridCellEditor* wxGridTypeRegistry::GetEditor(int index)
|
||||
return editor;
|
||||
}
|
||||
|
||||
wxRect wxGetGridCheckBoxRect(const wxSize& checkBoxSize,
|
||||
wxRect wxGetGridCheckBoxRect(wxWindow* win,
|
||||
const wxRect& cellRect,
|
||||
int hAlign, int WXUNUSED(vAlign))
|
||||
int hAlign,
|
||||
int WXUNUSED(vAlign))
|
||||
{
|
||||
// TODO: support vAlign
|
||||
const wxSize checkBoxSize =
|
||||
wxRendererNative::Get().GetCheckBoxSize(win, wxCONTROL_CELL);
|
||||
|
||||
wxRect checkBoxRect;
|
||||
|
||||
// TODO: support vAlign
|
||||
checkBoxRect.SetY(cellRect.y + cellRect.height / 2 - checkBoxSize.y / 2);
|
||||
|
||||
wxCoord minSize = wxMin(cellRect.width, cellRect.height);
|
||||
|
@@ -937,8 +937,11 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
|
||||
// compute it only once (no locks for MT safeness in GUI thread...)
|
||||
if ( !ms_sizeCheckMark.x )
|
||||
{
|
||||
// Use rectangle big enough for the check box to fit into it.
|
||||
const wxRect r(0, 0, 1000, 1000);
|
||||
|
||||
ms_sizeCheckMark =
|
||||
wxRendererNative::Get().GetCheckBoxSize(&grid, wxCONTROL_CELL);
|
||||
wxGetGridCheckBoxRect(&grid, r, wxALIGN_LEFT, wxALIGN_TOP).GetSize();
|
||||
}
|
||||
|
||||
return ms_sizeCheckMark;
|
||||
@@ -958,12 +961,7 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
const wxRect
|
||||
checkBoxRect = wxGetGridCheckBoxRect
|
||||
(
|
||||
GetBestSize(grid, attr, dc, row, col),
|
||||
rect,
|
||||
hAlign, vAlign
|
||||
);
|
||||
checkBoxRect = wxGetGridCheckBoxRect(&grid, rect, hAlign, vAlign);
|
||||
|
||||
bool value;
|
||||
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
|
||||
|
@@ -1224,13 +1224,7 @@ void wxGridCellBoolEditor::SetSize(const wxRect& r)
|
||||
GetCellAttr()->GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
const wxRect
|
||||
checkBoxRect = wxGetGridCheckBoxRect
|
||||
(
|
||||
wxRendererNative::Get().
|
||||
GetCheckBoxSize(GetWindow(), wxCONTROL_CELL),
|
||||
r,
|
||||
hAlign, vAlign
|
||||
);
|
||||
checkBoxRect = wxGetGridCheckBoxRect(GetWindow(), r, hAlign, vAlign);
|
||||
|
||||
// resize the control if required
|
||||
if ( m_control->GetSize() != checkBoxRect.GetSize() )
|
||||
|
Reference in New Issue
Block a user