⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realscreen.cc

📁 基于SDL实现的GUI
💻 CC
字号:
#include <assert.h>#include <string.h>#include <stdlib.h>#include "SDL_gui.h"#define MAX_UPDATES 200GUI_RealScreen::GUI_RealScreen(const char *aname, SDL_Surface *surface): GUI_Screen(aname, surface){	n_updates = 0;	updates = new SDL_Rect[MAX_UPDATES];}GUI_RealScreen::~GUI_RealScreen(void){	delete [] updates;}void GUI_RealScreen::FlushUpdates(void){	if (n_updates)	{		screen_surface->UpdateRects(n_updates, updates);		n_updates = 0;	}}/* return true if r1 is inside r2 */static int inside(const SDL_Rect *r1, const SDL_Rect *r2){	return		r1->x >= r2->x && r1->x + r1->w <= r2->x + r2->w &&		r1->y >= r2->y && r1->y + r1->h <= r2->y + r2->h;}void GUI_RealScreen::UpdateRect(const SDL_Rect *r){	if (r->x < 0 || r->y < 0 || 		r->x + r->w > screen_surface->GetWidth() ||		r->y + r->h > screen_surface->GetHeight())	{		fprintf(stderr, "Bad UpdateRect x=%d y=%d w=%d h=%d screen w=%d h=%d\n", 			r->x, r->y, r->w, r->h,			screen_surface->GetWidth(), screen_surface->GetHeight());		abort();	}			int i;	for (i=0; i<n_updates; i++)	{		/* if the new rect is inside one that is already */		/* being updated, then just ignore it. */		if (inside(r, &updates[i]))		   	return;		/* if the new rect contains a rect already being */		/* updated, then replace the new rect. */		/* FIXME: ideally, it should remove all rects which are inside */		 			if (inside(&updates[i], r))		{			updates[i] = *r;			return;	 	}	 }	updates[n_updates++] = *r;	if (n_updates >= MAX_UPDATES)		FlushUpdates();}void GUI_RealScreen::Update(int force){	if (screen_surface->IsDoubleBuffered())		force = 1;	GUI_Screen::Update(force);	if (screen_surface->IsDoubleBuffered())		screen_surface->Flip();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -