예제 #1
0
static void createGUI(lua_State *L)
{
	window *w = malloc(sizeof(window));
	windowInit(w, "main", 300, 400);
	widgetReposition(WIDGET(w), 50, 50);
	widgetShow(WIDGET(w));

	// GL stuff
	widgetEnableGL(WIDGET(w));
	WIDGET(w)->vtbl->doDraw = paintWithGL;
	widgetAddTimerEventHandler(WIDGET(w), EVT_TIMER_SINGLE_SHOT, 3000,
	                           timer, NULL, NULL);
}
예제 #2
0
파일: widget.cpp 프로젝트: BG1/warzone2100
void widgetResizeImpl(widget *self, int w, int h)
{
	const size minSize = widgetGetMinSize(self);
	const size maxSize = widgetGetMaxSize(self);

	// Create an event
	eventResize evtResize;
	evtResize.event = widgetCreateEvent(EVT_RESIZE);

	// Save the current size in the event
	evtResize.oldSize = self->size;

	assert(minSize.x <= w);
	assert(minSize.y <= h);
	assert(w <= maxSize.x);
	assert(h <= maxSize.y);

	self->size.x = w;
	self->size.y = h;

	// Re-create the cairo context at this new size
	widgetCairoCreate(&self->cr, CAIRO_FORMAT_ARGB32, w, h);

	// If a mask is enabled; re-create it also
	if (self->maskEnabled)
	{
		widgetCairoCreate(&self->maskCr, CAIRO_FORMAT_A1, w, h);

		// Re-draw the mask (only done on resize)
		widgetDrawMask(self);
	}

	// If OpenGL is enabled disable and re-enable it
	if (self->openGLEnabled)
	{
		widgetDisableGL(self);
		widgetEnableGL(self);
	}

	// Set the needs redraw flag
	self->needsRedraw = true;

	// If we have any children, we need to redo their layout
	if (vectorSize(self->children))
	{
		widgetDoLayout(self);
	}

	// Fire any EVT_RESIZE callbacks
	widgetFireCallbacks(self, (event *) &evtResize);
}