24#include <wx/renderer.h>
36 int aCol,
bool isSelected )
38 int arrowWidth = aRect.GetHeight();
40 wxRect textRect = aRect;
41 textRect.width = std::max( 0, textRect.width - arrowWidth );
43 wxGridCellStringRenderer::Draw( aGrid, aAttr, aDC, textRect, aRow, aCol, isSelected );
45 wxRect arrowRect = aRect;
46 arrowRect.x += textRect.width;
47 arrowRect.width = arrowWidth;
49 aDC.DrawRectangle( arrowRect );
51 wxRendererNative::Get().DrawDropArrow( &aGrid, aDC, arrowRect );
57 wxSize size = wxGridCellStringRenderer::GetBestSize( aGrid, aAttr, aDC, aRow, aCol );
87 m_control =
new wxComboBox( aParent, wxID_ANY, wxEmptyString,
88 wxDefaultPosition, wxDefaultSize,
m_names );
90 wxGridCellEditor::Create(aParent, aId, aEventHandler);
96 return Combo()->GetValue();
102 wxRect rect( aRect );
105#if defined( __WXMAC__ )
109 Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
115 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
118 evtHandler->SetInSetFocus(
true );
124 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
132 Combo()->SelectAll();
134#ifdef __WXOSX_COCOA__
144#if !defined(__WXGTK__)
145 evtHandler->SetInSetFocus(
false );
152 const wxString value =
Combo()->GetValue();
168 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
179 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
183 evtHandler->SetInSetFocus(
false );
189 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
194 wxFocusEvent event( wxEVT_KILL_FOCUS, m_control->GetId() );
195 event.SetEventObject( m_control );
196 evtHandler->ProcessEvent( event );
Renders a combobox cell's text with an always-visible dropdown arrow, so it reads as a dropdown even ...
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxSize GetBestSize(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, int aRow, int aCol) override
wxGridCellRenderer * Clone() const override
bool EndEdit(int aRow, int aCol, const wxGrid *, const wxString &, wxString *aNewVal) override
void onComboDropDown(wxCommandEvent &aEvent)
GRID_CELL_COMBOBOX(const wxArrayString &names)
~GRID_CELL_COMBOBOX() override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
void onComboCloseUp(wxCommandEvent &aEvent)
wxString GetValue() const override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
wxComboBox * Combo() const
void SetSize(const wxRect &aRect) override
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
wxGridCellEditor * Clone() const override