1 ///////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/gridctrl.cpp
3 // Purpose: wxGrid controls
4 // Author: Paul Gammans, Roger Gammans
8 // Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/generic/gridctrl.h"
21 #include "wx/generic/grideditors.h"
24 #include "wx/textctrl.h"
26 #include "wx/combobox.h"
27 #include "wx/settings.h"
29 #include "wx/checkbox.h"
32 #include "wx/tokenzr.h"
33 #include "wx/renderer.h"
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 void wxGridCellRenderer::Draw(wxGrid
& grid
,
44 int WXUNUSED(row
), int WXUNUSED(col
),
47 dc
.SetBackgroundMode( wxBRUSHSTYLE_SOLID
);
50 if ( grid
.IsThisEnabled() )
54 if ( grid
.HasFocus() )
55 clr
= grid
.GetSelectionBackground();
57 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
);
61 clr
= attr
.GetBackgroundColour();
64 else // grey out fields if the grid is disabled
66 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
70 dc
.SetPen( *wxTRANSPARENT_PEN
);
71 dc
.DrawRectangle(rect
);
75 // ----------------------------------------------------------------------------
76 // wxGridCellDateTimeRenderer
77 // ----------------------------------------------------------------------------
81 // Enables a grid cell to display a formatted date and or time
83 wxGridCellDateTimeRenderer::wxGridCellDateTimeRenderer(const wxString
& outformat
, const wxString
& informat
)
86 m_oformat
= outformat
;
87 m_tz
= wxDateTime::Local
;
88 m_dateDef
= wxDefaultDateTime
;
91 wxGridCellRenderer
*wxGridCellDateTimeRenderer::Clone() const
93 wxGridCellDateTimeRenderer
*renderer
= new wxGridCellDateTimeRenderer
;
94 renderer
->m_iformat
= m_iformat
;
95 renderer
->m_oformat
= m_oformat
;
96 renderer
->m_dateDef
= m_dateDef
;
97 renderer
->m_tz
= m_tz
;
102 wxString
wxGridCellDateTimeRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
104 wxGridTableBase
*table
= grid
.GetTable();
106 bool hasDatetime
= false;
109 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_DATETIME
) )
111 void * tempval
= table
->GetValueAsCustom(row
, col
,wxGRID_VALUE_DATETIME
);
115 val
= *((wxDateTime
*)tempval
);
117 delete (wxDateTime
*)tempval
;
124 text
= table
->GetValue(row
, col
);
125 const char * const end
= val
.ParseFormat(text
, m_iformat
, m_dateDef
);
126 hasDatetime
= end
&& !*end
;
130 text
= val
.Format(m_oformat
, m_tz
);
132 // If we failed to parse string just show what we where given?
136 void wxGridCellDateTimeRenderer::Draw(wxGrid
& grid
,
137 wxGridCellAttr
& attr
,
139 const wxRect
& rectCell
,
143 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
145 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
147 // draw the text right aligned by default
148 int hAlign
= wxALIGN_RIGHT
,
149 vAlign
= wxALIGN_INVALID
;
150 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
152 wxRect rect
= rectCell
;
155 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
158 wxSize
wxGridCellDateTimeRenderer::GetBestSize(wxGrid
& grid
,
159 wxGridCellAttr
& attr
,
163 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
166 void wxGridCellDateTimeRenderer::SetParameters(const wxString
& params
)
172 #endif // wxUSE_DATETIME
174 // ----------------------------------------------------------------------------
175 // wxGridCellEnumRenderer
176 // ----------------------------------------------------------------------------
177 // Renders a number as a textual equivalent.
178 // eg data in cell is 0,1,2 ... n the cell could be rendered as "John","Fred"..."Bob"
181 wxGridCellEnumRenderer::wxGridCellEnumRenderer(const wxString
& choices
)
183 if (!choices
.empty())
184 SetParameters(choices
);
187 wxGridCellRenderer
*wxGridCellEnumRenderer::Clone() const
189 wxGridCellEnumRenderer
*renderer
= new wxGridCellEnumRenderer
;
190 renderer
->m_choices
= m_choices
;
194 wxString
wxGridCellEnumRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
196 wxGridTableBase
*table
= grid
.GetTable();
198 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_NUMBER
) )
200 int choiceno
= table
->GetValueAsLong(row
, col
);
201 text
.Printf(wxT("%s"), m_choices
[ choiceno
].c_str() );
205 text
= table
->GetValue(row
, col
);
209 //If we faild to parse string just show what we where given?
213 void wxGridCellEnumRenderer::Draw(wxGrid
& grid
,
214 wxGridCellAttr
& attr
,
216 const wxRect
& rectCell
,
220 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
222 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
224 // draw the text right aligned by default
225 int hAlign
= wxALIGN_RIGHT
,
226 vAlign
= wxALIGN_INVALID
;
227 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
229 wxRect rect
= rectCell
;
232 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
235 wxSize
wxGridCellEnumRenderer::GetBestSize(wxGrid
& grid
,
236 wxGridCellAttr
& attr
,
240 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
243 void wxGridCellEnumRenderer::SetParameters(const wxString
& params
)
253 wxStringTokenizer
tk(params
, wxT(','));
254 while ( tk
.HasMoreTokens() )
256 m_choices
.Add(tk
.GetNextToken());
261 // ----------------------------------------------------------------------------
262 // wxGridCellAutoWrapStringRenderer
263 // ----------------------------------------------------------------------------
267 wxGridCellAutoWrapStringRenderer::Draw(wxGrid
& grid
,
268 wxGridCellAttr
& attr
,
270 const wxRect
& rectCell
,
275 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
277 // now we only have to draw the text
278 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
280 int horizAlign
, vertAlign
;
281 attr
.GetAlignment(&horizAlign
, &vertAlign
);
283 wxRect rect
= rectCell
;
286 grid
.DrawTextRectangle(dc
, GetTextLines(grid
,dc
,attr
,rect
,row
,col
),
287 rect
, horizAlign
, vertAlign
);
292 wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid
& grid
,
294 const wxGridCellAttr
& attr
,
298 dc
.SetFont(attr
.GetFont());
299 const wxCoord maxWidth
= rect
.GetWidth();
301 // Transform logical lines into physical ones, wrapping the longer ones.
303 logicalLines
= wxSplit(grid
.GetCellValue(row
, col
), '\n', '\0');
305 wxArrayString physicalLines
;
306 for ( wxArrayString::const_iterator it
= logicalLines
.begin();
307 it
!= logicalLines
.end();
310 const wxString
& line
= *it
;
312 if ( dc
.GetTextExtent(line
).x
> maxWidth
)
314 // Line does not fit, break it up.
315 BreakLine(dc
, line
, maxWidth
, physicalLines
);
317 else // The entire line fits as is
319 physicalLines
.push_back(line
);
323 return physicalLines
;
327 wxGridCellAutoWrapStringRenderer::BreakLine(wxDC
& dc
,
328 const wxString
& logicalLine
,
330 wxArrayString
& lines
)
332 wxCoord lineWidth
= 0;
336 wxStringTokenizer
wordTokenizer(logicalLine
, wxS(" \t"), wxTOKEN_RET_DELIMS
);
337 while ( wordTokenizer
.HasMoreTokens() )
339 const wxString word
= wordTokenizer
.GetNextToken();
340 const wxCoord wordWidth
= dc
.GetTextExtent(word
).x
;
341 if ( lineWidth
+ wordWidth
< maxWidth
)
343 // Word fits, just add it to this line.
345 lineWidth
+= wordWidth
;
349 // Word does not fit, check whether the word is itself wider that
351 if ( wordWidth
< maxWidth
)
353 // Word can fit in a new line, put it at the beginning
355 lines
.push_back(line
);
357 lineWidth
= wordWidth
;
359 else // Word cannot fit in available width at all.
363 lines
.push_back(line
);
368 // Break it up in several lines.
369 lineWidth
= BreakWord(dc
, word
, maxWidth
, lines
, line
);
375 lines
.push_back(line
);
380 wxGridCellAutoWrapStringRenderer::BreakWord(wxDC
& dc
,
381 const wxString
& word
,
383 wxArrayString
& lines
,
387 dc
.GetPartialTextExtents(word
, widths
);
389 // TODO: Use binary search to find the first element > maxWidth.
390 const unsigned count
= widths
.size();
392 for ( n
= 0; n
< count
; n
++ )
394 if ( widths
[n
] > maxWidth
)
400 // This is a degenerate case: the first character of the word is
401 // already wider than the available space, so we just can't show it
402 // completely and have to put the first character in this line.
406 lines
.push_back(word
.substr(0, n
));
408 // Check if the remainder of the string fits in one line.
410 // Unfortunately we can't use the existing partial text extents as the
411 // extent of the remainder may be different when it's rendered in a
412 // separate line instead of as part of the same one, so we have to
414 const wxString rest
= word
.substr(n
);
415 const wxCoord restWidth
= dc
.GetTextExtent(rest
).x
;
416 if ( restWidth
<= maxWidth
)
422 // Break the rest of the word into lines.
424 // TODO: Perhaps avoid recursion? The code is simpler like this but using a
425 // loop in this function would probably be more efficient.
426 return BreakWord(dc
, rest
, maxWidth
, lines
, line
);
430 wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid
& grid
,
431 wxGridCellAttr
& attr
,
435 wxCoord x
,y
, height
, width
= grid
.GetColSize(col
) -20;
436 // for width, subtract 20 because ColSize includes a magin of 10 pixels
437 // that we do not want here and because we always start with an increment
438 // by 10 in the loop below.
439 int count
= 250; //Limit iterations..
441 wxRect
rect(0,0,width
,10);
443 // M is a nice large character 'y' gives descender!.
444 dc
.GetTextExtent(wxT("My"), &x
, &y
);
449 rect
.SetWidth(width
);
450 height
= y
* (wx_truncate_cast(wxCoord
, GetTextLines(grid
,dc
,attr
,rect
,row
,col
).GetCount()));
452 // Search for a shape no taller than the golden ratio.
453 } while (count
&& (width
< (height
*1.68)) );
456 return wxSize(width
,height
);
460 // ----------------------------------------------------------------------------
461 // wxGridCellStringRenderer
462 // ----------------------------------------------------------------------------
464 void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid
& grid
,
465 const wxGridCellAttr
& attr
,
469 dc
.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT
);
471 // TODO some special colours for attr.IsReadOnly() case?
473 // different coloured text when the grid is disabled
474 if ( grid
.IsThisEnabled() )
479 if ( grid
.HasFocus() )
480 clr
= grid
.GetSelectionBackground();
482 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
);
483 dc
.SetTextBackground( clr
);
484 dc
.SetTextForeground( grid
.GetSelectionForeground() );
488 dc
.SetTextBackground( attr
.GetBackgroundColour() );
489 dc
.SetTextForeground( attr
.GetTextColour() );
494 dc
.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
));
495 dc
.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
498 dc
.SetFont( attr
.GetFont() );
501 wxSize
wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr
& attr
,
503 const wxString
& text
)
505 wxCoord x
= 0, y
= 0, max_x
= 0;
506 dc
.SetFont(attr
.GetFont());
507 wxStringTokenizer
tk(text
, wxT('\n'));
508 while ( tk
.HasMoreTokens() )
510 dc
.GetTextExtent(tk
.GetNextToken(), &x
, &y
);
511 max_x
= wxMax(max_x
, x
);
514 y
*= 1 + text
.Freq(wxT('\n')); // multiply by the number of lines.
516 return wxSize(max_x
, y
);
519 wxSize
wxGridCellStringRenderer::GetBestSize(wxGrid
& grid
,
520 wxGridCellAttr
& attr
,
524 return DoGetBestSize(attr
, dc
, grid
.GetCellValue(row
, col
));
527 void wxGridCellStringRenderer::Draw(wxGrid
& grid
,
528 wxGridCellAttr
& attr
,
530 const wxRect
& rectCell
,
534 wxRect rect
= rectCell
;
537 // erase only this cells background, overflow cells should have been erased
538 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
541 attr
.GetAlignment(&hAlign
, &vAlign
);
543 int overflowCols
= 0;
545 if (attr
.GetOverflow())
547 int cols
= grid
.GetNumberCols();
548 int best_width
= GetBestSize(grid
,attr
,dc
,row
,col
).GetWidth();
549 int cell_rows
, cell_cols
;
550 attr
.GetSize( &cell_rows
, &cell_cols
); // shouldn't get here if <= 0
551 if ((best_width
> rectCell
.width
) && (col
< cols
) && grid
.GetTable())
553 int i
, c_cols
, c_rows
;
554 for (i
= col
+cell_cols
; i
< cols
; i
++)
556 bool is_empty
= true;
557 for (int j
=row
; j
< row
+ cell_rows
; j
++)
559 // check w/ anchor cell for multicell block
560 grid
.GetCellSize(j
, i
, &c_rows
, &c_cols
);
563 if (!grid
.GetTable()->IsEmptyCell(j
+ c_rows
, i
))
572 rect
.width
+= grid
.GetColSize(i
);
580 if (rect
.width
>= best_width
)
584 overflowCols
= i
- col
- cell_cols
+ 1;
585 if (overflowCols
>= cols
)
586 overflowCols
= cols
- 1;
589 if (overflowCols
> 0) // redraw overflow cells w/ proper hilight
591 hAlign
= wxALIGN_LEFT
; // if oveflowed then it's left aligned
593 clip
.x
+= rectCell
.width
;
594 // draw each overflow cell individually
595 int col_end
= col
+ cell_cols
+ overflowCols
;
596 if (col_end
>= grid
.GetNumberCols())
597 col_end
= grid
.GetNumberCols() - 1;
598 for (int i
= col
+ cell_cols
; i
<= col_end
; i
++)
600 clip
.width
= grid
.GetColSize(i
) - 1;
601 dc
.DestroyClippingRegion();
602 dc
.SetClippingRegion(clip
);
604 SetTextColoursAndFont(grid
, attr
, dc
,
605 grid
.IsInSelection(row
,i
));
607 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
608 rect
, hAlign
, vAlign
);
609 clip
.x
+= grid
.GetColSize(i
) - 1;
615 dc
.DestroyClippingRegion();
619 // now we only have to draw the text
620 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
622 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
623 rect
, hAlign
, vAlign
);
626 // ----------------------------------------------------------------------------
627 // wxGridCellNumberRenderer
628 // ----------------------------------------------------------------------------
630 wxString
wxGridCellNumberRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
632 wxGridTableBase
*table
= grid
.GetTable();
634 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_NUMBER
) )
636 text
.Printf(wxT("%ld"), table
->GetValueAsLong(row
, col
));
640 text
= table
->GetValue(row
, col
);
646 void wxGridCellNumberRenderer::Draw(wxGrid
& grid
,
647 wxGridCellAttr
& attr
,
649 const wxRect
& rectCell
,
653 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
655 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
657 // draw the text right aligned by default
658 int hAlign
= wxALIGN_RIGHT
,
659 vAlign
= wxALIGN_INVALID
;
660 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
662 wxRect rect
= rectCell
;
665 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
668 wxSize
wxGridCellNumberRenderer::GetBestSize(wxGrid
& grid
,
669 wxGridCellAttr
& attr
,
673 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
676 // ----------------------------------------------------------------------------
677 // wxGridCellFloatRenderer
678 // ----------------------------------------------------------------------------
680 wxGridCellFloatRenderer::wxGridCellFloatRenderer(int width
,
685 SetPrecision(precision
);
689 wxGridCellRenderer
*wxGridCellFloatRenderer::Clone() const
691 wxGridCellFloatRenderer
*renderer
= new wxGridCellFloatRenderer
;
692 renderer
->m_width
= m_width
;
693 renderer
->m_precision
= m_precision
;
694 renderer
->m_style
= m_style
;
695 renderer
->m_format
= m_format
;
700 wxString
wxGridCellFloatRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
702 wxGridTableBase
*table
= grid
.GetTable();
707 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_FLOAT
) )
709 val
= table
->GetValueAsDouble(row
, col
);
714 text
= table
->GetValue(row
, col
);
715 hasDouble
= text
.ToDouble(&val
);
724 if ( m_precision
== -1 )
726 // default width/precision
731 m_format
.Printf(wxT("%%.%d"), m_precision
);
734 else if ( m_precision
== -1 )
737 m_format
.Printf(wxT("%%%d."), m_width
);
741 m_format
.Printf(wxT("%%%d.%d"), m_width
, m_precision
);
744 bool isUpper
= ( ( m_style
& wxGRID_FLOAT_FORMAT_UPPER
) == wxGRID_FLOAT_FORMAT_UPPER
);
745 if ( ( m_style
& wxGRID_FLOAT_FORMAT_SCIENTIFIC
) == wxGRID_FLOAT_FORMAT_SCIENTIFIC
)
746 m_format
+= isUpper
? wxT('E') : wxT('e');
747 else if ( ( m_style
& wxGRID_FLOAT_FORMAT_COMPACT
) == wxGRID_FLOAT_FORMAT_COMPACT
)
748 m_format
+= isUpper
? wxT('G') : wxT('g');
750 m_format
+= wxT('f');
753 text
.Printf(m_format
, val
);
756 //else: text already contains the string
761 void wxGridCellFloatRenderer::Draw(wxGrid
& grid
,
762 wxGridCellAttr
& attr
,
764 const wxRect
& rectCell
,
768 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
770 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
772 // draw the text right aligned by default
773 int hAlign
= wxALIGN_RIGHT
,
774 vAlign
= wxALIGN_INVALID
;
775 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
777 wxRect rect
= rectCell
;
780 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
783 wxSize
wxGridCellFloatRenderer::GetBestSize(wxGrid
& grid
,
784 wxGridCellAttr
& attr
,
788 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
791 void wxGridCellFloatRenderer::SetParameters(const wxString
& params
)
798 SetFormat(wxGRID_FLOAT_FORMAT_DEFAULT
);
803 wxString tmp
= params
.BeforeFirst(wxT(','), &rest
);
807 if ( tmp
.ToLong(&width
) )
809 SetWidth((int)width
);
813 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params
.c_str());
817 tmp
= rest
.BeforeFirst(wxT(','));
821 if ( tmp
.ToLong(&precision
) )
823 SetPrecision((int)precision
);
827 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params
.c_str());
831 tmp
= rest
.AfterFirst(wxT(','));
834 if ( tmp
[0] == wxT('f') )
836 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
);
838 else if ( tmp
[0] == wxT('e') )
840 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
);
842 else if ( tmp
[0] == wxT('g') )
844 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
);
846 else if ( tmp
[0] == wxT('E') )
848 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
|
849 wxGRID_FLOAT_FORMAT_UPPER
);
851 else if ( tmp
[0] == wxT('F') )
853 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
|
854 wxGRID_FLOAT_FORMAT_UPPER
);
856 else if ( tmp
[0] == wxT('G') )
858 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
|
859 wxGRID_FLOAT_FORMAT_UPPER
);
863 wxLogDebug("Invalid wxGridCellFloatRenderer format "
864 "parameter string '%s ignored", params
);
870 // ----------------------------------------------------------------------------
871 // wxGridCellBoolRenderer
872 // ----------------------------------------------------------------------------
874 wxSize
wxGridCellBoolRenderer::ms_sizeCheckMark
;
876 wxSize
wxGridCellBoolRenderer::GetBestSize(wxGrid
& grid
,
877 wxGridCellAttr
& WXUNUSED(attr
),
882 // compute it only once (no locks for MT safeness in GUI thread...)
883 if ( !ms_sizeCheckMark
.x
)
885 ms_sizeCheckMark
= wxRendererNative::Get().GetCheckBoxSize(&grid
);
888 return ms_sizeCheckMark
;
891 void wxGridCellBoolRenderer::Draw(wxGrid
& grid
,
892 wxGridCellAttr
& attr
,
898 wxGridCellRenderer::Draw(grid
, attr
, dc
, rect
, row
, col
, isSelected
);
900 // draw a check mark in the centre (ignoring alignment - TODO)
901 wxSize size
= GetBestSize(grid
, attr
, dc
, row
, col
);
903 // don't draw outside the cell
904 wxCoord minSize
= wxMin(rect
.width
, rect
.height
);
905 if ( size
.x
>= minSize
|| size
.y
>= minSize
)
907 // and even leave (at least) 1 pixel margin
908 size
.x
= size
.y
= minSize
;
911 // draw a border around checkmark
913 attr
.GetAlignment(&hAlign
, &vAlign
);
916 if (hAlign
== wxALIGN_CENTRE
)
918 rectBorder
.x
= rect
.x
+ rect
.width
/ 2 - size
.x
/ 2;
919 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
920 rectBorder
.width
= size
.x
;
921 rectBorder
.height
= size
.y
;
923 else if (hAlign
== wxALIGN_LEFT
)
925 rectBorder
.x
= rect
.x
+ 2;
926 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
927 rectBorder
.width
= size
.x
;
928 rectBorder
.height
= size
.y
;
930 else if (hAlign
== wxALIGN_RIGHT
)
932 rectBorder
.x
= rect
.x
+ rect
.width
- size
.x
- 2;
933 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
934 rectBorder
.width
= size
.x
;
935 rectBorder
.height
= size
.y
;
939 if ( grid
.GetTable()->CanGetValueAs(row
, col
, wxGRID_VALUE_BOOL
) )
941 value
= grid
.GetTable()->GetValueAsBool(row
, col
);
945 wxString
cellval( grid
.GetTable()->GetValue(row
, col
) );
946 value
= wxGridCellBoolEditor::IsTrueValue(cellval
);
951 flags
|= wxCONTROL_CHECKED
;
953 wxRendererNative::Get().DrawCheckBox( &grid
, dc
, rectBorder
, flags
);