Ejemplo n.º 1
0
/**
@method grab -> self
@method grab=( grab ) -> self

Controls grabbing of all mouse and keyboard input for the display.
Grabbing the input is not neccessary to receive keyboard and mouse events,
but it ensures all input will go to your application.
It also keeps the mouse locked inside your window.
It is best to not always grab the input,
since it prevents the end user from doing anything else on their system.
@grab is true or false.
*/
static VALUE eventqueue_set_grab(VALUE self, VALUE grabOn)
{
    if(NUM2BOOL(grabOn)){
        SDL_WM_GrabInput(SDL_GRAB_ON);
    }else{
        SDL_WM_GrabInput(SDL_GRAB_OFF);
    }
    return self;
}
Ejemplo n.º 2
0
VALUE ARGSS::ABitmap::rgradient_fill_rect(int argc, VALUE* argv, VALUE self) {
	ARGSS::ABitmap::CheckDisposed(self);
	if (argc < 3) raise_argn(argc, 3);
	else if (argc < 5) {
		bool vertical = false;
		if (argc == 4) {
			vertical = NUM2BOOL(argv[3]);
		}
	Bitmap::Get(self)->GradientFillRect(Rect(argv[0]), Color(argv[1]), Color(argv[2]), vertical);
	} else if (argc < 6) raise_argn(argc, 6);
	else if (argc < 8) {
		bool vertical = false;
		if (argc == 4) {
			vertical = NUM2BOOL(argv[6]);
		}
		Bitmap::Get(self)->GradientFillRect(Rect(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), NUM2INT(argv[3])), Color(argv[4]), Color(argv[5]), vertical);
	}
	else raise_argn(argc, 7);
	return self;
}
Ejemplo n.º 3
0
///////////////////////////////////////////////////////////
/// Draw text
///////////////////////////////////////////////////////////
void Bitmap::TextDraw(Rect rect, std::string text, int align) {
	if (text.length() == 0) return;
	if (rect.IsOutOfBounds(GetWidth(), GetHeight())) return;

	VALUE font_id = rb_iv_get(id, "@font");
	VALUE name_id = rb_iv_get(font_id, "@name");
	Color color = Color(rb_iv_get(font_id, "@color"));
	int size = NUM2INT(rb_iv_get(font_id, "@size"));
	bool bold = NUM2BOOL(rb_iv_get(font_id, "@bold"));
	bool italic = NUM2BOOL(rb_iv_get(font_id, "@italic"));

	Bitmap* text_bmp = Text::Draw(text, StringValuePtr(name_id), color, size, bold, italic, false);

	if (text_bmp->GetWidth() > rect.width) {
		int stretch = (int)(text_bmp->GetWidth() * 0.4);
		if (rect.width > stretch) stretch = rect.width;
		Rect resample_rect(0, 0, text_bmp->GetWidth(), text_bmp->GetHeight());
		Bitmap* resampled = text_bmp->Resample(stretch, text_bmp->GetHeight(), resample_rect);
		delete text_bmp;
		text_bmp = resampled;
	}
	Rect src_rect(0, 0, rect.width, rect.height);
	int y = rect.y;
	if (rect.height > text_bmp->GetHeight()) y += ((rect.height - text_bmp->GetHeight()) / 2);
	int x = rect.x;
	if (rect.width > text_bmp->GetWidth()) {
		if (align == 1) {
			x += (rect.width - text_bmp->GetWidth()) / 2;
		} else if (align == 2) {
			x += rect.width - text_bmp->GetWidth();
		}
	}
	Blit(x, y, text_bmp, src_rect, (int)color.alpha);
	delete text_bmp;

	Changed();
}