1 ///////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/gridctrl.cpp
3 // Purpose: wxGrid controls
4 // Author: Paul Gammans, Roger Gammans
7 // Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
19 #include "wx/generic/gridctrl.h"
20 #include "wx/generic/grideditors.h"
23 #include "wx/textctrl.h"
25 #include "wx/combobox.h"
26 #include "wx/settings.h"
28 #include "wx/checkbox.h"
31 #include "wx/tokenzr.h"
32 #include "wx/renderer.h"
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 void wxGridCellRenderer::Draw(wxGrid
& grid
,
43 int WXUNUSED(row
), int WXUNUSED(col
),
46 dc
.SetBackgroundMode( wxBRUSHSTYLE_SOLID
);
49 if ( grid
.IsThisEnabled() )
53 if ( grid
.HasFocus() )
54 clr
= grid
.GetSelectionBackground();
56 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
);
60 clr
= attr
.GetBackgroundColour();
63 else // grey out fields if the grid is disabled
65 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
69 dc
.SetPen( *wxTRANSPARENT_PEN
);
70 dc
.DrawRectangle(rect
);
74 // ----------------------------------------------------------------------------
75 // wxGridCellDateTimeRenderer
76 // ----------------------------------------------------------------------------
80 // Enables a grid cell to display a formatted date and or time
82 wxGridCellDateTimeRenderer::wxGridCellDateTimeRenderer(const wxString
& outformat
, const wxString
& informat
)
85 m_oformat
= outformat
;
86 m_tz
= wxDateTime::Local
;
87 m_dateDef
= wxDefaultDateTime
;
90 wxGridCellRenderer
*wxGridCellDateTimeRenderer::Clone() const
92 wxGridCellDateTimeRenderer
*renderer
= new wxGridCellDateTimeRenderer
;
93 renderer
->m_iformat
= m_iformat
;
94 renderer
->m_oformat
= m_oformat
;
95 renderer
->m_dateDef
= m_dateDef
;
96 renderer
->m_tz
= m_tz
;
101 wxString
wxGridCellDateTimeRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
103 wxGridTableBase
*table
= grid
.GetTable();
105 bool hasDatetime
= false;
108 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_DATETIME
) )
110 void * tempval
= table
->GetValueAsCustom(row
, col
,wxGRID_VALUE_DATETIME
);
114 val
= *((wxDateTime
*)tempval
);
116 delete (wxDateTime
*)tempval
;
123 text
= table
->GetValue(row
, col
);
124 const char * const end
= val
.ParseFormat(text
, m_iformat
, m_dateDef
);
125 hasDatetime
= end
&& !*end
;
129 text
= val
.Format(m_oformat
, m_tz
);
131 // If we failed to parse string just show what we where given?
135 void wxGridCellDateTimeRenderer::Draw(wxGrid
& grid
,
136 wxGridCellAttr
& attr
,
138 const wxRect
& rectCell
,
142 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
144 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
146 // draw the text right aligned by default
147 int hAlign
= wxALIGN_RIGHT
,
148 vAlign
= wxALIGN_INVALID
;
149 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
151 wxRect rect
= rectCell
;
154 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
157 wxSize
wxGridCellDateTimeRenderer::GetBestSize(wxGrid
& grid
,
158 wxGridCellAttr
& attr
,
162 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
165 void wxGridCellDateTimeRenderer::SetParameters(const wxString
& params
)
171 #endif // wxUSE_DATETIME
173 // ----------------------------------------------------------------------------
174 // wxGridCellEnumRenderer
175 // ----------------------------------------------------------------------------
176 // Renders a number as a textual equivalent.
177 // eg data in cell is 0,1,2 ... n the cell could be rendered as "John","Fred"..."Bob"
180 wxGridCellEnumRenderer::wxGridCellEnumRenderer(const wxString
& choices
)
182 if (!choices
.empty())
183 SetParameters(choices
);
186 wxGridCellRenderer
*wxGridCellEnumRenderer::Clone() const
188 wxGridCellEnumRenderer
*renderer
= new wxGridCellEnumRenderer
;
189 renderer
->m_choices
= m_choices
;
193 wxString
wxGridCellEnumRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
195 wxGridTableBase
*table
= grid
.GetTable();
197 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_NUMBER
) )
199 int choiceno
= table
->GetValueAsLong(row
, col
);
200 text
.Printf(wxT("%s"), m_choices
[ choiceno
].c_str() );
204 text
= table
->GetValue(row
, col
);
208 //If we faild to parse string just show what we where given?
212 void wxGridCellEnumRenderer::Draw(wxGrid
& grid
,
213 wxGridCellAttr
& attr
,
215 const wxRect
& rectCell
,
219 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
221 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
223 // draw the text right aligned by default
224 int hAlign
= wxALIGN_RIGHT
,
225 vAlign
= wxALIGN_INVALID
;
226 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
228 wxRect rect
= rectCell
;
231 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
234 wxSize
wxGridCellEnumRenderer::GetBestSize(wxGrid
& grid
,
235 wxGridCellAttr
& attr
,
239 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
242 void wxGridCellEnumRenderer::SetParameters(const wxString
& params
)
252 wxStringTokenizer
tk(params
, wxT(','));
253 while ( tk
.HasMoreTokens() )
255 m_choices
.Add(tk
.GetNextToken());
260 // ----------------------------------------------------------------------------
261 // wxGridCellAutoWrapStringRenderer
262 // ----------------------------------------------------------------------------
266 wxGridCellAutoWrapStringRenderer::Draw(wxGrid
& grid
,
267 wxGridCellAttr
& attr
,
269 const wxRect
& rectCell
,
274 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
276 // now we only have to draw the text
277 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
279 int horizAlign
, vertAlign
;
280 attr
.GetAlignment(&horizAlign
, &vertAlign
);
282 wxRect rect
= rectCell
;
285 grid
.DrawTextRectangle(dc
, GetTextLines(grid
,dc
,attr
,rect
,row
,col
),
286 rect
, horizAlign
, vertAlign
);
291 wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid
& grid
,
293 const wxGridCellAttr
& attr
,
297 dc
.SetFont(attr
.GetFont());
298 const wxCoord maxWidth
= rect
.GetWidth();
300 // Transform logical lines into physical ones, wrapping the longer ones.
302 logicalLines
= wxSplit(grid
.GetCellValue(row
, col
), '\n', '\0');
304 // Trying to do anything if the column is hidden anyhow doesn't make sense
305 // and we run into problems in BreakLine() in this case.
309 wxArrayString physicalLines
;
310 for ( wxArrayString::const_iterator it
= logicalLines
.begin();
311 it
!= logicalLines
.end();
314 const wxString
& line
= *it
;
316 if ( dc
.GetTextExtent(line
).x
> maxWidth
)
318 // Line does not fit, break it up.
319 BreakLine(dc
, line
, maxWidth
, physicalLines
);
321 else // The entire line fits as is
323 physicalLines
.push_back(line
);
327 return physicalLines
;
331 wxGridCellAutoWrapStringRenderer::BreakLine(wxDC
& dc
,
332 const wxString
& logicalLine
,
334 wxArrayString
& lines
)
336 wxCoord lineWidth
= 0;
340 wxStringTokenizer
wordTokenizer(logicalLine
, wxS(" \t"), wxTOKEN_RET_DELIMS
);
341 while ( wordTokenizer
.HasMoreTokens() )
343 const wxString word
= wordTokenizer
.GetNextToken();
344 const wxCoord wordWidth
= dc
.GetTextExtent(word
).x
;
345 if ( lineWidth
+ wordWidth
< maxWidth
)
347 // Word fits, just add it to this line.
349 lineWidth
+= wordWidth
;
353 // Word does not fit, check whether the word is itself wider that
355 if ( wordWidth
< maxWidth
)
357 // Word can fit in a new line, put it at the beginning
359 lines
.push_back(line
);
361 lineWidth
= wordWidth
;
363 else // Word cannot fit in available width at all.
367 lines
.push_back(line
);
372 // Break it up in several lines.
373 lineWidth
= BreakWord(dc
, word
, maxWidth
, lines
, line
);
379 lines
.push_back(line
);
384 wxGridCellAutoWrapStringRenderer::BreakWord(wxDC
& dc
,
385 const wxString
& word
,
387 wxArrayString
& lines
,
391 dc
.GetPartialTextExtents(word
, widths
);
393 // TODO: Use binary search to find the first element > maxWidth.
394 const unsigned count
= widths
.size();
396 for ( n
= 0; n
< count
; n
++ )
398 if ( widths
[n
] > maxWidth
)
404 // This is a degenerate case: the first character of the word is
405 // already wider than the available space, so we just can't show it
406 // completely and have to put the first character in this line.
410 lines
.push_back(word
.substr(0, n
));
412 // Check if the remainder of the string fits in one line.
414 // Unfortunately we can't use the existing partial text extents as the
415 // extent of the remainder may be different when it's rendered in a
416 // separate line instead of as part of the same one, so we have to
418 const wxString rest
= word
.substr(n
);
419 const wxCoord restWidth
= dc
.GetTextExtent(rest
).x
;
420 if ( restWidth
<= maxWidth
)
426 // Break the rest of the word into lines.
428 // TODO: Perhaps avoid recursion? The code is simpler like this but using a
429 // loop in this function would probably be more efficient.
430 return BreakWord(dc
, rest
, maxWidth
, lines
, line
);
434 wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid
& grid
,
435 wxGridCellAttr
& attr
,
439 const int lineHeight
= dc
.GetCharHeight();
441 // Search for a shape no taller than the golden ratio.
443 for ( size
.x
= 10; ; size
.x
+= 10 )
446 numLines
= GetTextLines(grid
, dc
, attr
, size
, row
, col
).size();
447 size
.y
= numLines
* lineHeight
;
448 if ( size
.x
>= size
.y
*1.68 )
455 // ----------------------------------------------------------------------------
456 // wxGridCellStringRenderer
457 // ----------------------------------------------------------------------------
459 void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid
& grid
,
460 const wxGridCellAttr
& attr
,
464 dc
.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT
);
466 // TODO some special colours for attr.IsReadOnly() case?
468 // different coloured text when the grid is disabled
469 if ( grid
.IsThisEnabled() )
474 if ( grid
.HasFocus() )
475 clr
= grid
.GetSelectionBackground();
477 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
);
478 dc
.SetTextBackground( clr
);
479 dc
.SetTextForeground( grid
.GetSelectionForeground() );
483 dc
.SetTextBackground( attr
.GetBackgroundColour() );
484 dc
.SetTextForeground( attr
.GetTextColour() );
489 dc
.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
));
490 dc
.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
493 dc
.SetFont( attr
.GetFont() );
496 wxSize
wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr
& attr
,
498 const wxString
& text
)
500 wxCoord x
= 0, y
= 0, max_x
= 0;
501 dc
.SetFont(attr
.GetFont());
502 wxStringTokenizer
tk(text
, wxT('\n'));
503 while ( tk
.HasMoreTokens() )
505 dc
.GetTextExtent(tk
.GetNextToken(), &x
, &y
);
506 max_x
= wxMax(max_x
, x
);
509 y
*= 1 + text
.Freq(wxT('\n')); // multiply by the number of lines.
511 return wxSize(max_x
, y
);
514 wxSize
wxGridCellStringRenderer::GetBestSize(wxGrid
& grid
,
515 wxGridCellAttr
& attr
,
519 return DoGetBestSize(attr
, dc
, grid
.GetCellValue(row
, col
));
522 void wxGridCellStringRenderer::Draw(wxGrid
& grid
,
523 wxGridCellAttr
& attr
,
525 const wxRect
& rectCell
,
529 wxRect rect
= rectCell
;
532 // erase only this cells background, overflow cells should have been erased
533 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
536 attr
.GetAlignment(&hAlign
, &vAlign
);
538 int overflowCols
= 0;
540 if (attr
.GetOverflow())
542 int cols
= grid
.GetNumberCols();
543 int best_width
= GetBestSize(grid
,attr
,dc
,row
,col
).GetWidth();
544 int cell_rows
, cell_cols
;
545 attr
.GetSize( &cell_rows
, &cell_cols
); // shouldn't get here if <= 0
546 if ((best_width
> rectCell
.width
) && (col
< cols
) && grid
.GetTable())
548 int i
, c_cols
, c_rows
;
549 for (i
= col
+cell_cols
; i
< cols
; i
++)
551 bool is_empty
= true;
552 for (int j
=row
; j
< row
+ cell_rows
; j
++)
554 // check w/ anchor cell for multicell block
555 grid
.GetCellSize(j
, i
, &c_rows
, &c_cols
);
558 if (!grid
.GetTable()->IsEmptyCell(j
+ c_rows
, i
))
567 rect
.width
+= grid
.GetColSize(i
);
575 if (rect
.width
>= best_width
)
579 overflowCols
= i
- col
- cell_cols
+ 1;
580 if (overflowCols
>= cols
)
581 overflowCols
= cols
- 1;
584 if (overflowCols
> 0) // redraw overflow cells w/ proper hilight
586 hAlign
= wxALIGN_LEFT
; // if oveflowed then it's left aligned
588 clip
.x
+= rectCell
.width
;
589 // draw each overflow cell individually
590 int col_end
= col
+ cell_cols
+ overflowCols
;
591 if (col_end
>= grid
.GetNumberCols())
592 col_end
= grid
.GetNumberCols() - 1;
593 for (int i
= col
+ cell_cols
; i
<= col_end
; i
++)
595 clip
.width
= grid
.GetColSize(i
) - 1;
596 dc
.DestroyClippingRegion();
597 dc
.SetClippingRegion(clip
);
599 SetTextColoursAndFont(grid
, attr
, dc
,
600 grid
.IsInSelection(row
,i
));
602 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
603 rect
, hAlign
, vAlign
);
604 clip
.x
+= grid
.GetColSize(i
) - 1;
610 dc
.DestroyClippingRegion();
614 // now we only have to draw the text
615 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
617 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
618 rect
, hAlign
, vAlign
);
621 // ----------------------------------------------------------------------------
622 // wxGridCellNumberRenderer
623 // ----------------------------------------------------------------------------
625 wxString
wxGridCellNumberRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
627 wxGridTableBase
*table
= grid
.GetTable();
629 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_NUMBER
) )
631 text
.Printf(wxT("%ld"), table
->GetValueAsLong(row
, col
));
635 text
= table
->GetValue(row
, col
);
641 void wxGridCellNumberRenderer::Draw(wxGrid
& grid
,
642 wxGridCellAttr
& attr
,
644 const wxRect
& rectCell
,
648 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
650 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
652 // draw the text right aligned by default
653 int hAlign
= wxALIGN_RIGHT
,
654 vAlign
= wxALIGN_INVALID
;
655 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
657 wxRect rect
= rectCell
;
660 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
663 wxSize
wxGridCellNumberRenderer::GetBestSize(wxGrid
& grid
,
664 wxGridCellAttr
& attr
,
668 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
671 // ----------------------------------------------------------------------------
672 // wxGridCellFloatRenderer
673 // ----------------------------------------------------------------------------
675 wxGridCellFloatRenderer::wxGridCellFloatRenderer(int width
,
680 SetPrecision(precision
);
684 wxGridCellRenderer
*wxGridCellFloatRenderer::Clone() const
686 wxGridCellFloatRenderer
*renderer
= new wxGridCellFloatRenderer
;
687 renderer
->m_width
= m_width
;
688 renderer
->m_precision
= m_precision
;
689 renderer
->m_style
= m_style
;
690 renderer
->m_format
= m_format
;
695 wxString
wxGridCellFloatRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
697 wxGridTableBase
*table
= grid
.GetTable();
702 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_FLOAT
) )
704 val
= table
->GetValueAsDouble(row
, col
);
709 text
= table
->GetValue(row
, col
);
710 hasDouble
= text
.ToDouble(&val
);
719 if ( m_precision
== -1 )
721 // default width/precision
726 m_format
.Printf(wxT("%%.%d"), m_precision
);
729 else if ( m_precision
== -1 )
732 m_format
.Printf(wxT("%%%d."), m_width
);
736 m_format
.Printf(wxT("%%%d.%d"), m_width
, m_precision
);
739 bool isUpper
= ( ( m_style
& wxGRID_FLOAT_FORMAT_UPPER
) == wxGRID_FLOAT_FORMAT_UPPER
);
740 if ( ( m_style
& wxGRID_FLOAT_FORMAT_SCIENTIFIC
) == wxGRID_FLOAT_FORMAT_SCIENTIFIC
)
741 m_format
+= isUpper
? wxT('E') : wxT('e');
742 else if ( ( m_style
& wxGRID_FLOAT_FORMAT_COMPACT
) == wxGRID_FLOAT_FORMAT_COMPACT
)
743 m_format
+= isUpper
? wxT('G') : wxT('g');
745 m_format
+= wxT('f');
748 text
.Printf(m_format
, val
);
751 //else: text already contains the string
756 void wxGridCellFloatRenderer::Draw(wxGrid
& grid
,
757 wxGridCellAttr
& attr
,
759 const wxRect
& rectCell
,
763 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
765 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
767 // draw the text right aligned by default
768 int hAlign
= wxALIGN_RIGHT
,
769 vAlign
= wxALIGN_INVALID
;
770 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
772 wxRect rect
= rectCell
;
775 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
778 wxSize
wxGridCellFloatRenderer::GetBestSize(wxGrid
& grid
,
779 wxGridCellAttr
& attr
,
783 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
786 void wxGridCellFloatRenderer::SetParameters(const wxString
& params
)
793 SetFormat(wxGRID_FLOAT_FORMAT_DEFAULT
);
798 wxString tmp
= params
.BeforeFirst(wxT(','), &rest
);
802 if ( tmp
.ToLong(&width
) )
804 SetWidth((int)width
);
808 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params
.c_str());
812 tmp
= rest
.BeforeFirst(wxT(','));
816 if ( tmp
.ToLong(&precision
) )
818 SetPrecision((int)precision
);
822 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params
.c_str());
826 tmp
= rest
.AfterFirst(wxT(','));
829 if ( tmp
[0] == wxT('f') )
831 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
);
833 else if ( tmp
[0] == wxT('e') )
835 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
);
837 else if ( tmp
[0] == wxT('g') )
839 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
);
841 else if ( tmp
[0] == wxT('E') )
843 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
|
844 wxGRID_FLOAT_FORMAT_UPPER
);
846 else if ( tmp
[0] == wxT('F') )
848 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
|
849 wxGRID_FLOAT_FORMAT_UPPER
);
851 else if ( tmp
[0] == wxT('G') )
853 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
|
854 wxGRID_FLOAT_FORMAT_UPPER
);
858 wxLogDebug("Invalid wxGridCellFloatRenderer format "
859 "parameter string '%s ignored", params
);
865 // ----------------------------------------------------------------------------
866 // wxGridCellBoolRenderer
867 // ----------------------------------------------------------------------------
869 wxSize
wxGridCellBoolRenderer::ms_sizeCheckMark
;
871 wxSize
wxGridCellBoolRenderer::GetBestSize(wxGrid
& grid
,
872 wxGridCellAttr
& WXUNUSED(attr
),
877 // compute it only once (no locks for MT safeness in GUI thread...)
878 if ( !ms_sizeCheckMark
.x
)
880 ms_sizeCheckMark
= wxRendererNative::Get().GetCheckBoxSize(&grid
);
883 return ms_sizeCheckMark
;
886 void wxGridCellBoolRenderer::Draw(wxGrid
& grid
,
887 wxGridCellAttr
& attr
,
893 wxGridCellRenderer::Draw(grid
, attr
, dc
, rect
, row
, col
, isSelected
);
895 // draw a check mark in the centre (ignoring alignment - TODO)
896 wxSize size
= GetBestSize(grid
, attr
, dc
, row
, col
);
898 // don't draw outside the cell
899 wxCoord minSize
= wxMin(rect
.width
, rect
.height
);
900 if ( size
.x
>= minSize
|| size
.y
>= minSize
)
902 // and even leave (at least) 1 pixel margin
903 size
.x
= size
.y
= minSize
;
906 // draw a border around checkmark
908 attr
.GetAlignment(&hAlign
, &vAlign
);
911 if (hAlign
== wxALIGN_CENTRE
)
913 rectBorder
.x
= rect
.x
+ rect
.width
/ 2 - size
.x
/ 2;
914 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
915 rectBorder
.width
= size
.x
;
916 rectBorder
.height
= size
.y
;
918 else if (hAlign
== wxALIGN_LEFT
)
920 rectBorder
.x
= rect
.x
+ 2;
921 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
922 rectBorder
.width
= size
.x
;
923 rectBorder
.height
= size
.y
;
925 else if (hAlign
== wxALIGN_RIGHT
)
927 rectBorder
.x
= rect
.x
+ rect
.width
- size
.x
- 2;
928 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
929 rectBorder
.width
= size
.x
;
930 rectBorder
.height
= size
.y
;
934 if ( grid
.GetTable()->CanGetValueAs(row
, col
, wxGRID_VALUE_BOOL
) )
936 value
= grid
.GetTable()->GetValueAsBool(row
, col
);
940 wxString
cellval( grid
.GetTable()->GetValue(row
, col
) );
941 value
= wxGridCellBoolEditor::IsTrueValue(cellval
);
946 flags
|= wxCONTROL_CHECKED
;
948 wxRendererNative::Get().DrawCheckBox( &grid
, dc
, rectBorder
, flags
);