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

📄 libfbx-gui.c

📁 libfxb是linux下只写操作framebuffer的一个轻量级的库。
💻 C
字号:
/* *  libfbx-gui.c -- gui routines for libfbx *  (C)opyright 2000-2001 U4X Labs * *  Written by: Paul Mundt <lethal@u4xlabs.com> *  		Michael Bourgeous <nitrogen@u4xlabs.com> *              Mon Dec 11 14:51:49 EST 2000 * *  $Id: libfbx-gui.c,v 1.16 2001/01/25 01:48:32 nitroglycerine Exp $ * *  	This is the place for all the gui specific routines *  for the libfbx system go. * *  See ChangeLog for modifications, CREDITS for credits. * *  All source herein is copyright U4X Labs and its original author.  *  Any code modifications or additions are (C)opyright the original  *  author and U4X Labs respectively. * *  libfbx is free software; you can redistribute it and/or modify it  *  under the terms of the GNU Lesser General Public License as  *  published by the Free Software Foundation; either version 2.1 of  *  the License, or (at your option) any later version. * *  libfbx is distributed in the hope that it will be useful, but  *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  *  GNU Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with libfbx; if not, write to the Free Software  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *  USA */#include <libfbx/libfbx.h>#include <libfbx/libfbx-gui.h>/* * Function:    fb_draw_textbox() * Arguments:   Beginning x, y coords, ending x, y coords. *              Foreground rgb values, background rgb values, *              surface to draw on.          * Returns:     None. * Description: Draws a text box from x1, y1 to x2, y2 with *              specified rgb values for both foreground and *              background on specified surface. */void fb_draw_textbox(int x1, int y1, int x2, int y2,                      int r1, int g1, int b1,                      int r2, int g2, int b2,                      fb_surface *surface){	fb_fill_rect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, r1, g1, b1, surface);	fb_line(x1, y1, x2, y1, r2, g2, b2, surface);	fb_line(x2, y1, x2, y2, r2, g2, b2, surface);	fb_line(x2, y2, x1, y2, r2, g2, b2, surface);	fb_line(x1, y2, x1, y1, r2, g2, b2, surface);}/* * Function:    fb_draw_box() * Arguments:   Beginning x, y coords, ending x, y corrds. *              RGB values, surface to draw on. * Returns:     None. * Description: Draws a box from x1, y1 to x2, y2 with *              specified rgb values on specified surface. *              (Same as fb_fill_rect()). */void fb_draw_box(int x1, int y1, int x2, int y2,                 int r, int g, int b,                 fb_surface *surface){	fb_fill_rect(x1, y1, x2, y2, r, g, b, surface);}/* * Function:    fb_dotted_rect() * Arguments:   Beginning x, y coords, ending x, y corrds. *              RGB values, surface to draw on. * Returns:     None. * Description: Draws a dotted rectangle outline from * 		x1, y1 to x2, y2 with specified rgb  * 		values on specified surface. */void fb_dotted_rect(int x1, int y1, int x2, int y2,		    int fg_r, int fg_g, int fg_b,		    int bg_r, int bg_g, int bg_b,		    fb_surface *surface){	int x = ((x1 + y1) & 1) ? 1 : 0;	int c;	for(c = x1; c <= x2; c++)	{		fb_putpixel(c, y1,			    (((c + y1) & 1) == x) ? fg_r : bg_r,			    (((c + y1) & 1) == x) ? fg_g : bg_g,			    (((c + y1) & 1) == x) ? fg_b : bg_b,			    surface);		fb_putpixel(c, y2,			    (((c+y2) & 1) == x) ? fg_r : bg_r, 			    (((c+y2) & 1) == x) ? fg_g : bg_g, 			    (((c+y2) & 1) == x) ? fg_b : bg_b,			    surface);	}		for (c = y1 + 1; c < y2; c++) 	{		fb_putpixel(x1, c, 			    (((c+x1) & 1) == x) ? fg_r : bg_r,			    (((c+x1) & 1) == x) ? fg_g : bg_g,			    (((c+x1) & 1) == x) ? fg_b : bg_b,			    surface);		fb_putpixel(x2, c, 			    (((c+x1) & 1) == x) ? fg_r : bg_r,			    (((c+x1) & 1) == x) ? fg_g : bg_g,			    (((c+x1) & 1) == x) ? fg_b : bg_b,			    surface);	}}/* * Function:    fb_gui_strlen() * Arguments:   string * Returns:     Length of string in pixels. * Description: Calculates the length of the string in pixels, * 		ignoring the & character. */int fb_gui_strlen(char *string){	int len = 0;	int i = 0;	int u = FALSE;	while(string[i])	{		if(string[i] == '&')		{			if(!u)			{				i++;				u = TRUE;				continue;			}			len += fb_screen->font.width;			u = FALSE;			i++;			continue;		}		if(u)			u = FALSE;		len += fb_screen->font.width;		i++;	}		return len;}/* * Function:    fb_gui_puts() * Arguments:   coordinates, center flag, surface, string, color of underline * Returns:     Length of printed string in pixels. * Description: Uses fb_sputc() to draw text on the screen, * 		but interprets the & character as a directive to * 		underline the next character drawn.  If the center * 		flag is set, text will be horizontally centered  * 		around the coordinates given.  Tab and newline are  * 		untreated. */int fb_gui_puts(int x, int y, int center, int r, int g, int b, fb_surface *surface, char *string){	int pix = 0;	int u = FALSE;	int i = 0;	if(center)		x -= fb_gui_strlen(string) / 2;	while(string[i])	{		if(string[i] == '&')		{			if(!u)			{				i++;				u = TRUE;				continue;			}			if(surface)				fb_sputc(x, y, string[i++], surface);			x += surface->font.width;			pix += surface->font.width;			u = FALSE;			continue;		}				if(u)		{			if(surface)				fb_line(x, y + surface->font.height,					x + surface->font.width,					y + surface->font.height,					r, g, b,					surface); 			u = FALSE;		}				if(surface)			fb_sputc(x, y, string[i++], surface);		x += surface->font.width;		pix += surface->font.width;	}	return pix;}

⌨️ 快捷键说明

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