/* Copyright 2010-2011 Grégory Soutadé This file is part of KissCount. KissCount is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. KissCount is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with KissCount. If not, see . */ #include "wxGridCellButtonEditor.h" enum {BUTTON_ID = 1} ; // BEGIN_EVENT_TABLE(wxGridCellButtonEditor, wxEvtHandler) // EVT_BUTTON(BUTTON_ID, wxGridCellButtonEditor::OnButton) // END_EVENT_TABLE() wxGridCellButtonEditor::wxGridCellButtonEditor(const wxString& text) : _text(text), _button(NULL) {} wxGridCellButtonEditor::~wxGridCellButtonEditor() { if (_button) delete _button; } wxGridCellEditor* wxGridCellButtonEditor::Clone () const { return new wxGridCellButtonEditor(_text); } void wxGridCellButtonEditor::BeginEdit (int row, int col, wxGrid *grid) { _row = row; _col = col; _grid = grid; if (_grid) { wxGridEvent event (_grid->GetId(), wxEVT_GRID_CELL_CHANGE, this, _row, _col); _grid->GetEventHandler()->AddPendingEvent(event); } } void wxGridCellButtonEditor::Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) { if (_button) return; _button = new wxButton(parent, id, _text); _button->Connect(id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxGridCellButtonEditor::OnButton), NULL, this); } bool wxGridCellButtonEditor::EndEdit (int row, int col, /*const*/ wxGrid *grid/*, const wxString &oldval, wxString *newval*/) { return false; } void wxGridCellButtonEditor::ApplyEdit (int row, int col, wxGrid *grid) {} void wxGridCellButtonEditor::Reset () {} wxString wxGridCellButtonEditor::GetValue() const { return wxT(""); } void wxGridCellButtonEditor::SetSize (const wxRect &rect) { if (_button) _button->SetSize(rect); } void wxGridCellButtonEditor::Show (bool show, wxGridCellAttr *attr=NULL) { if (_button) _button->Show(show); } void wxGridCellButtonEditor::OnButton(wxCommandEvent& evt) { if (_grid) { wxGridEvent event (_grid->GetId(), wxEVT_GRID_CELL_CHANGE, this, _row, _col); _grid->GetEventHandler()->AddPendingEvent(event); } }