Use renderer to draw checkmark

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-11-17 13:52:37 +00:00
parent 2f5157911b
commit 2f26ad2872

View File

@@ -1520,10 +1520,12 @@ void wxGridCellChoiceEditor::Create(wxWindow* parent,
wxWindowID id, wxWindowID id,
wxEvtHandler* evtHandler) wxEvtHandler* evtHandler)
{ {
int style = wxBORDER_NONE;
if (!m_allowOthers)
style |= wxCB_READONLY;
m_control = new wxComboBox(parent, id, wxEmptyString, m_control = new wxComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
m_choices, m_choices, style );
m_allowOthers ? 0 : wxCB_READONLY);
wxGridCellEditor::Create(parent, id, evtHandler); wxGridCellEditor::Create(parent, id, evtHandler);
} }
@@ -2204,8 +2206,7 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
wxSize size = checkbox->GetBestSize(); wxSize size = checkbox->GetBestSize();
wxCoord checkSize = size.y + 2 * wxGRID_CHECKMARK_MARGIN; wxCoord checkSize = size.y + 2 * wxGRID_CHECKMARK_MARGIN;
// FIXME wxGTK::wxCheckBox::GetBestSize() gives "wrong" result #if defined(__WXMOTIF__)
#if defined(__WXGTK__) || defined(__WXMOTIF__)
checkSize -= size.y / 2; checkSize -= size.y / 2;
#endif #endif
@@ -2234,7 +2235,7 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
if ( size.x >= minSize || size.y >= minSize ) if ( size.x >= minSize || size.y >= minSize )
{ {
// and even leave (at least) 1 pixel margin // and even leave (at least) 1 pixel margin
size.x = size.y = minSize - 2; size.x = size.y = minSize;
} }
// draw a border around checkmark // draw a border around checkmark
@@ -2275,26 +2276,11 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
value = wxGridCellBoolEditor::IsTrueValue(cellval); value = wxGridCellBoolEditor::IsTrueValue(cellval);
} }
if ( value ) int flags = 0;
{ if (value)
wxRect rectMark = rectBorder; flags |= wxCONTROL_CHECKED;
#ifdef __WXMSW__ wxRendererNative::Get().DrawCheckBox( &grid, dc, rectBorder, flags );
// MSW DrawCheckMark() is weird (and should probably be changed...)
rectMark.Inflate(-wxGRID_CHECKMARK_MARGIN / 2);
rectMark.x++;
rectMark.y++;
#else
rectMark.Inflate(-wxGRID_CHECKMARK_MARGIN);
#endif
dc.SetTextForeground(attr.GetTextColour());
dc.DrawCheckMark(rectMark);
}
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(wxPen(attr.GetTextColour(), 1, wxSOLID));
dc.DrawRectangle(rectBorder);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -8473,7 +8459,7 @@ void wxGrid::ShowCellEditControl()
if (rect.GetRight() > client_right) if (rect.GetRight() > client_right)
rect.SetRight( client_right - 1 ); rect.SetRight( client_right - 1 );
} }
editor->SetCellAttr( attr ); editor->SetCellAttr( attr );
editor->SetSize( rect ); editor->SetSize( rect );
if (nXMove != 0) if (nXMove != 0)