mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 02:26:11 +00:00
Improve CheckBox style a bit.
This commit is contained in:
parent
6f9e0e3876
commit
20a1795218
|
@ -30,39 +30,54 @@ void CheckBox::setIsChecked(bool b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* uncheckedBitmap = {
|
static const char* uncheckedBitmap = {
|
||||||
"############"
|
"###########"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"# #"
|
||||||
"# #"
|
"###########"
|
||||||
"############"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
static const char* checkedBitmap = {
|
static const char* checkedBitmap = {
|
||||||
"############"
|
"############"
|
||||||
"# #"
|
"# #"
|
||||||
"# # # #"
|
"# ## #"
|
||||||
"# # # #"
|
"# ## #"
|
||||||
"# # # #"
|
"# ## #"
|
||||||
"# ## #"
|
"# ## #"
|
||||||
"# ## #"
|
"# ## #"
|
||||||
"# # # #"
|
"# ## ## #"
|
||||||
"# # # #"
|
"# ## ## #"
|
||||||
"# # # #"
|
"# ### #"
|
||||||
"# #"
|
"# #"
|
||||||
"############"
|
"############"
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char* checkedBitmap = {
|
||||||
|
"###########"
|
||||||
|
"## ##"
|
||||||
|
"# # # #"
|
||||||
|
"# # # #"
|
||||||
|
"# # # #"
|
||||||
|
"# # #"
|
||||||
|
"# # # #"
|
||||||
|
"# # # #"
|
||||||
|
"# # # #"
|
||||||
|
"## ##"
|
||||||
|
"###########"
|
||||||
|
};
|
||||||
|
|
||||||
void CheckBox::onPaint(PaintEvent&)
|
void CheckBox::onPaint(PaintEvent&)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
auto bitmap = CBitmap::createFromASCII(isChecked() ? checkedBitmap : uncheckedBitmap, 12, 12);
|
auto bitmap = CBitmap::createFromASCII(isChecked() ? checkedBitmap : uncheckedBitmap, 11, 11);
|
||||||
|
|
||||||
auto textRect = rect();
|
auto textRect = rect();
|
||||||
textRect.setLeft(bitmap->width() + 4);
|
textRect.setLeft(bitmap->width() + 4);
|
||||||
|
@ -70,7 +85,7 @@ void CheckBox::onPaint(PaintEvent&)
|
||||||
|
|
||||||
Point bitmapPosition;
|
Point bitmapPosition;
|
||||||
bitmapPosition.setX(2);
|
bitmapPosition.setX(2);
|
||||||
bitmapPosition.setY(height() / 2 - bitmap->height() / 2);
|
bitmapPosition.setY(height() / 2 - bitmap->height() / 2 - 1);
|
||||||
|
|
||||||
painter.fillRect(rect(), backgroundColor());
|
painter.fillRect(rect(), backgroundColor());
|
||||||
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0));
|
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0));
|
||||||
|
|
Loading…
Reference in a new issue