Fixed missing checkbox alignment
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -21,6 +21,7 @@ All:
|
|||||||
Stieber)
|
Stieber)
|
||||||
- Improved contrib/utils/convertrc parsing (David J. Cooke)
|
- Improved contrib/utils/convertrc parsing (David J. Cooke)
|
||||||
- Fixed handling of URLs and filenames in wxFileSystem
|
- Fixed handling of URLs and filenames in wxFileSystem
|
||||||
|
- Implemented alignment for wxGrid bool editor and renderer
|
||||||
|
|
||||||
OLD CHANGES
|
OLD CHANGES
|
||||||
===========
|
===========
|
||||||
|
@@ -302,6 +302,9 @@ public:
|
|||||||
wxControl* GetControl() { return m_control; }
|
wxControl* GetControl() { return m_control; }
|
||||||
void SetControl(wxControl* control) { m_control = control; }
|
void SetControl(wxControl* control) { m_control = control; }
|
||||||
|
|
||||||
|
wxGridCellAttr* GetCellAttr() { return m_attr; }
|
||||||
|
void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; }
|
||||||
|
|
||||||
// Creates the actual edit control
|
// Creates the actual edit control
|
||||||
virtual void Create(wxWindow* parent,
|
virtual void Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@@ -368,6 +371,9 @@ protected:
|
|||||||
// the control we show on screen
|
// the control we show on screen
|
||||||
wxControl* m_control;
|
wxControl* m_control;
|
||||||
|
|
||||||
|
// a temporary pointer to the attribute being edited
|
||||||
|
wxGridCellAttr* m_attr;
|
||||||
|
|
||||||
// if we change the colours/font of the control from the default ones, we
|
// if we change the colours/font of the control from the default ones, we
|
||||||
// must restore the default later and we save them here between calls to
|
// must restore the default later and we save them here between calls to
|
||||||
// Show(TRUE) and Show(FALSE)
|
// Show(TRUE) and Show(FALSE)
|
||||||
|
@@ -424,6 +424,7 @@ static inline int GetScrollY(int y)
|
|||||||
wxGridCellEditor::wxGridCellEditor()
|
wxGridCellEditor::wxGridCellEditor()
|
||||||
{
|
{
|
||||||
m_control = NULL;
|
m_control = NULL;
|
||||||
|
m_attr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1216,7 +1217,32 @@ void wxGridCellBoolEditor::SetSize(const wxRect& r)
|
|||||||
size.y -= 2;
|
size.y -= 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_control->Move(r.x + r.width/2 - size.x/2, r.y + r.height/2 - size.y/2);
|
int hAlign = wxALIGN_CENTRE;
|
||||||
|
int vAlign = wxALIGN_CENTRE;
|
||||||
|
if (GetCellAttr())
|
||||||
|
GetCellAttr()->GetAlignment(& hAlign, & vAlign);
|
||||||
|
|
||||||
|
int x = 0, y = 0;
|
||||||
|
if (hAlign == wxALIGN_LEFT)
|
||||||
|
{
|
||||||
|
x = r.x + 2;
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
x += 2;
|
||||||
|
#endif
|
||||||
|
y = r.y + r.height/2 - size.y/2;
|
||||||
|
}
|
||||||
|
else if (hAlign == wxALIGN_RIGHT)
|
||||||
|
{
|
||||||
|
x = r.x + r.width - size.x - 2;
|
||||||
|
y = r.y + r.height/2 - size.y/2;
|
||||||
|
}
|
||||||
|
else if (hAlign == wxALIGN_CENTRE)
|
||||||
|
{
|
||||||
|
x = r.x + r.width/2 - size.x/2;
|
||||||
|
y = r.y + r.height/2 - size.y/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_control->Move(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGridCellBoolEditor::Show(bool show, wxGridCellAttr *attr)
|
void wxGridCellBoolEditor::Show(bool show, wxGridCellAttr *attr)
|
||||||
@@ -1950,11 +1976,31 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw a border around checkmark
|
// draw a border around checkmark
|
||||||
|
int vAlign, hAlign;
|
||||||
|
attr.GetAlignment(& hAlign, &vAlign);
|
||||||
|
|
||||||
wxRect rectBorder;
|
wxRect rectBorder;
|
||||||
rectBorder.x = rect.x + rect.width/2 - size.x/2;
|
if (hAlign == wxALIGN_CENTRE)
|
||||||
rectBorder.y = rect.y + rect.height/2 - size.y/2;
|
{
|
||||||
rectBorder.width = size.x;
|
rectBorder.x = rect.x + rect.width/2 - size.x/2;
|
||||||
rectBorder.height = size.y;
|
rectBorder.y = rect.y + rect.height/2 - size.y/2;
|
||||||
|
rectBorder.width = size.x;
|
||||||
|
rectBorder.height = size.y;
|
||||||
|
}
|
||||||
|
else if (hAlign == wxALIGN_LEFT)
|
||||||
|
{
|
||||||
|
rectBorder.x = rect.x + 2;
|
||||||
|
rectBorder.y = rect.y + rect.height/2 - size.y/2;
|
||||||
|
rectBorder.width = size.x;
|
||||||
|
rectBorder.height = size.y;
|
||||||
|
}
|
||||||
|
else if (hAlign == wxALIGN_RIGHT)
|
||||||
|
{
|
||||||
|
rectBorder.x = rect.x + rect.width - size.x - 2;
|
||||||
|
rectBorder.y = rect.y + rect.height/2 - size.y/2;
|
||||||
|
rectBorder.width = size.x;
|
||||||
|
rectBorder.height = size.y;
|
||||||
|
}
|
||||||
|
|
||||||
bool value;
|
bool value;
|
||||||
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
|
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
|
||||||
@@ -7388,6 +7434,7 @@ void wxGrid::ShowCellEditControl()
|
|||||||
rect.SetRight(client_right-1);
|
rect.SetRight(client_right-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor->SetCellAttr(attr);
|
||||||
editor->SetSize( rect );
|
editor->SetSize( rect );
|
||||||
editor->Show( TRUE, attr );
|
editor->Show( TRUE, attr );
|
||||||
|
|
||||||
@@ -7396,6 +7443,7 @@ void wxGrid::ShowCellEditControl()
|
|||||||
CalcDimensions();
|
CalcDimensions();
|
||||||
|
|
||||||
editor->BeginEdit(row, col, this);
|
editor->BeginEdit(row, col, this);
|
||||||
|
editor->SetCellAttr(NULL);
|
||||||
|
|
||||||
editor->DecRef();
|
editor->DecRef();
|
||||||
attr->DecRef();
|
attr->DecRef();
|
||||||
|
Reference in New Issue
Block a user