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 wxArrayString physicalLines
;
305 for ( wxArrayString::const_iterator it
= logicalLines
.begin();
306 it
!= logicalLines
.end();
309 const wxString
& line
= *it
;
311 if ( dc
.GetTextExtent(line
).x
> maxWidth
)
313 // Line does not fit, break it up.
314 BreakLine(dc
, line
, maxWidth
, physicalLines
);
316 else // The entire line fits as is
318 physicalLines
.push_back(line
);
322 return physicalLines
;
326 wxGridCellAutoWrapStringRenderer::BreakLine(wxDC
& dc
,
327 const wxString
& logicalLine
,
329 wxArrayString
& lines
)
331 wxCoord lineWidth
= 0;
335 wxStringTokenizer
wordTokenizer(logicalLine
, wxS(" \t"), wxTOKEN_RET_DELIMS
);
336 while ( wordTokenizer
.HasMoreTokens() )
338 const wxString word
= wordTokenizer
.GetNextToken();
339 const wxCoord wordWidth
= dc
.GetTextExtent(word
).x
;
340 if ( lineWidth
+ wordWidth
< maxWidth
)
342 // Word fits, just add it to this line.
344 lineWidth
+= wordWidth
;
348 // Word does not fit, check whether the word is itself wider that
350 if ( wordWidth
< maxWidth
)
352 // Word can fit in a new line, put it at the beginning
354 lines
.push_back(line
);
356 lineWidth
= wordWidth
;
358 else // Word cannot fit in available width at all.
362 lines
.push_back(line
);
367 // Break it up in several lines.
368 lineWidth
= BreakWord(dc
, word
, maxWidth
, lines
, line
);
374 lines
.push_back(line
);
379 wxGridCellAutoWrapStringRenderer::BreakWord(wxDC
& dc
,
380 const wxString
& word
,
382 wxArrayString
& lines
,
386 dc
.GetPartialTextExtents(word
, widths
);
388 // TODO: Use binary search to find the first element > maxWidth.
389 const unsigned count
= widths
.size();
391 for ( n
= 0; n
< count
; n
++ )
393 if ( widths
[n
] > maxWidth
)
399 // This is a degenerate case: the first character of the word is
400 // already wider than the available space, so we just can't show it
401 // completely and have to put the first character in this line.
405 lines
.push_back(word
.substr(0, n
));
407 // Check if the remainder of the string fits in one line.
409 // Unfortunately we can't use the existing partial text extents as the
410 // extent of the remainder may be different when it's rendered in a
411 // separate line instead of as part of the same one, so we have to
413 const wxString rest
= word
.substr(n
);
414 const wxCoord restWidth
= dc
.GetTextExtent(rest
).x
;
415 if ( restWidth
<= maxWidth
)
421 // Break the rest of the word into lines.
423 // TODO: Perhaps avoid recursion? The code is simpler like this but using a
424 // loop in this function would probably be more efficient.
425 return BreakWord(dc
, rest
, maxWidth
, lines
, line
);
429 wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid
& grid
,
430 wxGridCellAttr
& attr
,
434 wxCoord x
,y
, height
, width
= grid
.GetColSize(col
) -20;
435 // for width, subtract 20 because ColSize includes a magin of 10 pixels
436 // that we do not want here and because we always start with an increment
437 // by 10 in the loop below.
438 int count
= 250; //Limit iterations..
440 wxRect
rect(0,0,width
,10);
442 // M is a nice large character 'y' gives descender!.
443 dc
.GetTextExtent(wxT("My"), &x
, &y
);
448 rect
.SetWidth(width
);
449 height
= y
* (wx_truncate_cast(wxCoord
, GetTextLines(grid
,dc
,attr
,rect
,row
,col
).GetCount()));
451 // Search for a shape no taller than the golden ratio.
452 } while (count
&& (width
< (height
*1.68)) );
455 return wxSize(width
,height
);
459 // ----------------------------------------------------------------------------
460 // wxGridCellStringRenderer
461 // ----------------------------------------------------------------------------
463 void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid
& grid
,
464 const wxGridCellAttr
& attr
,
468 dc
.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT
);
470 // TODO some special colours for attr.IsReadOnly() case?
472 // different coloured text when the grid is disabled
473 if ( grid
.IsThisEnabled() )
478 if ( grid
.HasFocus() )
479 clr
= grid
.GetSelectionBackground();
481 clr
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
);
482 dc
.SetTextBackground( clr
);
483 dc
.SetTextForeground( grid
.GetSelectionForeground() );
487 dc
.SetTextBackground( attr
.GetBackgroundColour() );
488 dc
.SetTextForeground( attr
.GetTextColour() );
493 dc
.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
));
494 dc
.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
497 dc
.SetFont( attr
.GetFont() );
500 wxSize
wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr
& attr
,
502 const wxString
& text
)
504 wxCoord x
= 0, y
= 0, max_x
= 0;
505 dc
.SetFont(attr
.GetFont());
506 wxStringTokenizer
tk(text
, wxT('\n'));
507 while ( tk
.HasMoreTokens() )
509 dc
.GetTextExtent(tk
.GetNextToken(), &x
, &y
);
510 max_x
= wxMax(max_x
, x
);
513 y
*= 1 + text
.Freq(wxT('\n')); // multiply by the number of lines.
515 return wxSize(max_x
, y
);
518 wxSize
wxGridCellStringRenderer::GetBestSize(wxGrid
& grid
,
519 wxGridCellAttr
& attr
,
523 return DoGetBestSize(attr
, dc
, grid
.GetCellValue(row
, col
));
526 void wxGridCellStringRenderer::Draw(wxGrid
& grid
,
527 wxGridCellAttr
& attr
,
529 const wxRect
& rectCell
,
533 wxRect rect
= rectCell
;
536 // erase only this cells background, overflow cells should have been erased
537 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
540 attr
.GetAlignment(&hAlign
, &vAlign
);
542 int overflowCols
= 0;
544 if (attr
.GetOverflow())
546 int cols
= grid
.GetNumberCols();
547 int best_width
= GetBestSize(grid
,attr
,dc
,row
,col
).GetWidth();
548 int cell_rows
, cell_cols
;
549 attr
.GetSize( &cell_rows
, &cell_cols
); // shouldn't get here if <= 0
550 if ((best_width
> rectCell
.width
) && (col
< cols
) && grid
.GetTable())
552 int i
, c_cols
, c_rows
;
553 for (i
= col
+cell_cols
; i
< cols
; i
++)
555 bool is_empty
= true;
556 for (int j
=row
; j
< row
+ cell_rows
; j
++)
558 // check w/ anchor cell for multicell block
559 grid
.GetCellSize(j
, i
, &c_rows
, &c_cols
);
562 if (!grid
.GetTable()->IsEmptyCell(j
+ c_rows
, i
))
571 rect
.width
+= grid
.GetColSize(i
);
579 if (rect
.width
>= best_width
)
583 overflowCols
= i
- col
- cell_cols
+ 1;
584 if (overflowCols
>= cols
)
585 overflowCols
= cols
- 1;
588 if (overflowCols
> 0) // redraw overflow cells w/ proper hilight
590 hAlign
= wxALIGN_LEFT
; // if oveflowed then it's left aligned
592 clip
.x
+= rectCell
.width
;
593 // draw each overflow cell individually
594 int col_end
= col
+ cell_cols
+ overflowCols
;
595 if (col_end
>= grid
.GetNumberCols())
596 col_end
= grid
.GetNumberCols() - 1;
597 for (int i
= col
+ cell_cols
; i
<= col_end
; i
++)
599 clip
.width
= grid
.GetColSize(i
) - 1;
600 dc
.DestroyClippingRegion();
601 dc
.SetClippingRegion(clip
);
603 SetTextColoursAndFont(grid
, attr
, dc
,
604 grid
.IsInSelection(row
,i
));
606 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
607 rect
, hAlign
, vAlign
);
608 clip
.x
+= grid
.GetColSize(i
) - 1;
614 dc
.DestroyClippingRegion();
618 // now we only have to draw the text
619 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
621 grid
.DrawTextRectangle(dc
, grid
.GetCellValue(row
, col
),
622 rect
, hAlign
, vAlign
);
625 // ----------------------------------------------------------------------------
626 // wxGridCellNumberRenderer
627 // ----------------------------------------------------------------------------
629 wxString
wxGridCellNumberRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
631 wxGridTableBase
*table
= grid
.GetTable();
633 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_NUMBER
) )
635 text
.Printf(wxT("%ld"), table
->GetValueAsLong(row
, col
));
639 text
= table
->GetValue(row
, col
);
645 void wxGridCellNumberRenderer::Draw(wxGrid
& grid
,
646 wxGridCellAttr
& attr
,
648 const wxRect
& rectCell
,
652 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
654 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
656 // draw the text right aligned by default
657 int hAlign
= wxALIGN_RIGHT
,
658 vAlign
= wxALIGN_INVALID
;
659 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
661 wxRect rect
= rectCell
;
664 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
667 wxSize
wxGridCellNumberRenderer::GetBestSize(wxGrid
& grid
,
668 wxGridCellAttr
& attr
,
672 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
675 // ----------------------------------------------------------------------------
676 // wxGridCellFloatRenderer
677 // ----------------------------------------------------------------------------
679 wxGridCellFloatRenderer::wxGridCellFloatRenderer(int width
,
684 SetPrecision(precision
);
688 wxGridCellRenderer
*wxGridCellFloatRenderer::Clone() const
690 wxGridCellFloatRenderer
*renderer
= new wxGridCellFloatRenderer
;
691 renderer
->m_width
= m_width
;
692 renderer
->m_precision
= m_precision
;
693 renderer
->m_style
= m_style
;
694 renderer
->m_format
= m_format
;
699 wxString
wxGridCellFloatRenderer::GetString(const wxGrid
& grid
, int row
, int col
)
701 wxGridTableBase
*table
= grid
.GetTable();
706 if ( table
->CanGetValueAs(row
, col
, wxGRID_VALUE_FLOAT
) )
708 val
= table
->GetValueAsDouble(row
, col
);
713 text
= table
->GetValue(row
, col
);
714 hasDouble
= text
.ToDouble(&val
);
723 if ( m_precision
== -1 )
725 // default width/precision
730 m_format
.Printf(wxT("%%.%d"), m_precision
);
733 else if ( m_precision
== -1 )
736 m_format
.Printf(wxT("%%%d."), m_width
);
740 m_format
.Printf(wxT("%%%d.%d"), m_width
, m_precision
);
743 bool isUpper
= ( ( m_style
& wxGRID_FLOAT_FORMAT_UPPER
) == wxGRID_FLOAT_FORMAT_UPPER
);
744 if ( ( m_style
& wxGRID_FLOAT_FORMAT_SCIENTIFIC
) == wxGRID_FLOAT_FORMAT_SCIENTIFIC
)
745 m_format
+= isUpper
? wxT('E') : wxT('e');
746 else if ( ( m_style
& wxGRID_FLOAT_FORMAT_COMPACT
) == wxGRID_FLOAT_FORMAT_COMPACT
)
747 m_format
+= isUpper
? wxT('G') : wxT('g');
749 m_format
+= wxT('f');
752 text
.Printf(m_format
, val
);
755 //else: text already contains the string
760 void wxGridCellFloatRenderer::Draw(wxGrid
& grid
,
761 wxGridCellAttr
& attr
,
763 const wxRect
& rectCell
,
767 wxGridCellRenderer::Draw(grid
, attr
, dc
, rectCell
, row
, col
, isSelected
);
769 SetTextColoursAndFont(grid
, attr
, dc
, isSelected
);
771 // draw the text right aligned by default
772 int hAlign
= wxALIGN_RIGHT
,
773 vAlign
= wxALIGN_INVALID
;
774 attr
.GetNonDefaultAlignment(&hAlign
, &vAlign
);
776 wxRect rect
= rectCell
;
779 grid
.DrawTextRectangle(dc
, GetString(grid
, row
, col
), rect
, hAlign
, vAlign
);
782 wxSize
wxGridCellFloatRenderer::GetBestSize(wxGrid
& grid
,
783 wxGridCellAttr
& attr
,
787 return DoGetBestSize(attr
, dc
, GetString(grid
, row
, col
));
790 void wxGridCellFloatRenderer::SetParameters(const wxString
& params
)
797 SetFormat(wxGRID_FLOAT_FORMAT_DEFAULT
);
802 wxString tmp
= params
.BeforeFirst(wxT(','), &rest
);
806 if ( tmp
.ToLong(&width
) )
808 SetWidth((int)width
);
812 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params
.c_str());
816 tmp
= rest
.BeforeFirst(wxT(','));
820 if ( tmp
.ToLong(&precision
) )
822 SetPrecision((int)precision
);
826 wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params
.c_str());
830 tmp
= rest
.AfterFirst(wxT(','));
833 if ( tmp
[0] == wxT('f') )
835 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
);
837 else if ( tmp
[0] == wxT('e') )
839 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
);
841 else if ( tmp
[0] == wxT('g') )
843 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
);
845 else if ( tmp
[0] == wxT('E') )
847 SetFormat(wxGRID_FLOAT_FORMAT_SCIENTIFIC
|
848 wxGRID_FLOAT_FORMAT_UPPER
);
850 else if ( tmp
[0] == wxT('F') )
852 SetFormat(wxGRID_FLOAT_FORMAT_FIXED
|
853 wxGRID_FLOAT_FORMAT_UPPER
);
855 else if ( tmp
[0] == wxT('G') )
857 SetFormat(wxGRID_FLOAT_FORMAT_COMPACT
|
858 wxGRID_FLOAT_FORMAT_UPPER
);
862 wxLogDebug("Invalid wxGridCellFloatRenderer format "
863 "parameter string '%s ignored", params
);
869 // ----------------------------------------------------------------------------
870 // wxGridCellBoolRenderer
871 // ----------------------------------------------------------------------------
873 wxSize
wxGridCellBoolRenderer::ms_sizeCheckMark
;
875 wxSize
wxGridCellBoolRenderer::GetBestSize(wxGrid
& grid
,
876 wxGridCellAttr
& WXUNUSED(attr
),
881 // compute it only once (no locks for MT safeness in GUI thread...)
882 if ( !ms_sizeCheckMark
.x
)
884 ms_sizeCheckMark
= wxRendererNative::Get().GetCheckBoxSize(&grid
);
887 return ms_sizeCheckMark
;
890 void wxGridCellBoolRenderer::Draw(wxGrid
& grid
,
891 wxGridCellAttr
& attr
,
897 wxGridCellRenderer::Draw(grid
, attr
, dc
, rect
, row
, col
, isSelected
);
899 // draw a check mark in the centre (ignoring alignment - TODO)
900 wxSize size
= GetBestSize(grid
, attr
, dc
, row
, col
);
902 // don't draw outside the cell
903 wxCoord minSize
= wxMin(rect
.width
, rect
.height
);
904 if ( size
.x
>= minSize
|| size
.y
>= minSize
)
906 // and even leave (at least) 1 pixel margin
907 size
.x
= size
.y
= minSize
;
910 // draw a border around checkmark
912 attr
.GetAlignment(&hAlign
, &vAlign
);
915 if (hAlign
== wxALIGN_CENTRE
)
917 rectBorder
.x
= rect
.x
+ rect
.width
/ 2 - size
.x
/ 2;
918 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
919 rectBorder
.width
= size
.x
;
920 rectBorder
.height
= size
.y
;
922 else if (hAlign
== wxALIGN_LEFT
)
924 rectBorder
.x
= rect
.x
+ 2;
925 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
926 rectBorder
.width
= size
.x
;
927 rectBorder
.height
= size
.y
;
929 else if (hAlign
== wxALIGN_RIGHT
)
931 rectBorder
.x
= rect
.x
+ rect
.width
- size
.x
- 2;
932 rectBorder
.y
= rect
.y
+ rect
.height
/ 2 - size
.y
/ 2;
933 rectBorder
.width
= size
.x
;
934 rectBorder
.height
= size
.y
;
938 if ( grid
.GetTable()->CanGetValueAs(row
, col
, wxGRID_VALUE_BOOL
) )
940 value
= grid
.GetTable()->GetValueAsBool(row
, col
);
944 wxString
cellval( grid
.GetTable()->GetValue(row
, col
) );
945 value
= wxGridCellBoolEditor::IsTrueValue(cellval
);
950 flags
|= wxCONTROL_CHECKED
;
952 wxRendererNative::Get().DrawCheckBox( &grid
, dc
, rectBorder
, flags
);