59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
------------------------------------------------------------------------------*/
|
|
|
|
|
|
#include "ui/widget_check.h"
|
|
|
|
using namespace GS;
|
|
using namespace GS::S2D;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
void CheckWidget::SetState(bool b_state)
|
|
{
|
|
state = b_state;
|
|
// check_bitmap.SetPicture(state ? "scene2d/ui_check_true.tga" : "scene2d/ui_check_false.tga");
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
void CheckWidget::Refresh()
|
|
{
|
|
check_bitmap.Refresh();
|
|
label.Refresh();
|
|
dirty = check_bitmap.IsDirty() || label.IsDirty();
|
|
}
|
|
void CheckWidget::Invalidate()
|
|
{
|
|
check_bitmap.Invalidate();
|
|
label.Invalidate();
|
|
Widget::Invalidate();
|
|
}
|
|
void CheckWidget::Compose(Picture &output, const iRect &out_rect)
|
|
{
|
|
if (hidden || !dirty)
|
|
return;
|
|
|
|
rect = out_rect;
|
|
rect.sy += (int)border_size.x;
|
|
rect.ey -= (int)border_size.y;
|
|
rect.sx += (int)border_size.z;
|
|
rect.ex -= (int)border_size.w;
|
|
|
|
// Compose check box and label.
|
|
Rect <int> check_rect(rect), label_rect(rect);
|
|
|
|
if (check_bitmap.GetPicture())
|
|
{
|
|
check_rect.ex = check_rect.sx + (check_bitmap.GetPicture()->GetWidth() * 3) / 2;
|
|
label_rect.sx = check_rect.ex;
|
|
}
|
|
check_bitmap.Compose(output, check_rect);
|
|
label.Compose(output, label_rect);
|
|
|
|
dirty = false;
|
|
}
|
|
//------------------------------------------------------------------------------
|