| 238 | } |
| 239 | |
| 240 | void NumericRenderer::Draw(wxGrid &grid, |
| 241 | wxGridCellAttr &attr, |
| 242 | wxDC &dc, |
| 243 | const wxRect &rect, |
| 244 | int row, |
| 245 | int col, |
| 246 | bool isSelected) |
| 247 | { |
| 248 | wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); |
| 249 | |
| 250 | wxGridTableBase *table = grid.GetTable(); |
| 251 | NumericEditor *ne = |
| 252 | static_cast<NumericEditor *>(grid.GetCellEditor(row, col)); |
| 253 | wxString tstr; |
| 254 | |
| 255 | if (ne) { |
| 256 | double value; |
| 257 | |
| 258 | table->GetValue(row, col).ToDouble(&value); |
| 259 | |
| 260 | NumericTextCtrl tt(mContext, &grid, wxID_ANY, |
| 261 | mType, |
| 262 | ne->GetFormat(), |
| 263 | value, |
| 264 | NumericTextCtrl::Options{}.AutoPos(true), |
| 265 | wxPoint(10000, 10000)); // create offscreen |
| 266 | tstr = tt.GetString(); |
| 267 | |
| 268 | ne->DecRef(); |
| 269 | } |
| 270 | |
| 271 | dc.SetBackgroundMode(wxTRANSPARENT); |
| 272 | |
| 273 | if (grid.IsEnabled()) |
| 274 | { |
| 275 | if (isSelected) |
| 276 | { |
| 277 | dc.SetTextBackground(grid.GetSelectionBackground()); |
| 278 | dc.SetTextForeground(grid.GetSelectionForeground()); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | dc.SetTextBackground(attr.GetBackgroundColour()); |
| 283 | dc.SetTextForeground(attr.GetTextColour()); |
| 284 | } |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); |
| 289 | dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); |
| 290 | } |
| 291 | |
| 292 | dc.SetFont(attr.GetFont()); |
| 293 | |
| 294 | int hAlign, vAlign; |
| 295 | |
| 296 | attr.GetAlignment(&hAlign, &vAlign); |
| 297 | |