Example #1
0
void checkbox_w::paint( context &ctxt )
{
	_checked.set_position( x(), y() );
	_unchecked.set_position( x(), y() );
	bool c = _state;
	if ( _tracking )
		c = _current;
	if ( c )
		_checked.draw( ctxt.hw_context() );
	else
		_unchecked.draw( ctxt.hw_context() );
}
Example #2
0
void checkbox_w::build( context &ctxt )
{
	const style &s = ctxt.get_style();

	draw::paint c;
	platform::context &hwc = ctxt.hw_context();
	gl::api &ogl = hwc.api();

	_unchecked.rebuild( hwc );
	_checked.rebuild( hwc );

	c.set_fill_color( s.active_icon( s.background_color() ) );
	_unchecked.add( ogl, draw::iconCheckBoxEmpty(), c );

	c.set_fill_color( s.dominant_color() );
	_checked.add( ogl, draw::iconCheckBoxChecked(), c );

	size sz = s.widget_minimum_size();
	auto native = ctxt.to_native( sz );
	_unchecked.shape_size( native.w(), native.h() );
	_checked.shape_size( native.w(), native.h() );
	_unchecked.set_size( sz.w(), sz.h() );
	_checked.set_size( sz.w(), sz.h() );

	auto &l = layout_target();
	l->set_minimum( sz );
	l->set_maximum( sz );
}