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

📄 libfbx-button.c

📁 libfxb是linux下只写操作framebuffer的一个轻量级的库。
💻 C
字号:
/* *  libfbx-button.c -- button routines for libfbx *  (C)opyright 2000-2001 U4X Labs * *  Written by: Michael Bourgeous <nitrogen@u4xlabs.com> *              Wed Jan 17 14:09:49 MST 2000 * *  $Id: libfbx-button.c,v 1.7 2001/01/25 00:57:42 lethal Exp $ * * 	This is where all the button routines for libfbx-gui *  are located. * *  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_button_proc() * Arguments:	Message, dialog, argument * Returns:	GUI status * Description:	Behavior function for libfbx-gui. * 		Draws a button with a text label. * 		Should never be called by the user, * 		but instead assigned to an fb_dialog * 		struct.  Actual function calling is * 		done in the libfbx-gui messaging * 		system. */int fb_button_proc(int msg, fb_dialog *d, int c){	int state1_r, state1_g, state1_b;	int state2_r, state2_g, state2_b;	int g;	int rtm;	switch(msg) {		case FB_MSG_DRAW:			if(d->flags & FB_DIALOG_SELECTED) {				g = 1;				state1_r = d->bg_r;				state1_g = d->bg_g;				state1_b = d->bg_b;				/* TODO: Handle disabled drawing */				state2_r = d->fg_r;				state2_g = d->fg_g;				state2_b = d->fg_b;			} else {				g = 0;				state1_r = d->fg_r;				state1_g = d->fg_g;				state1_b = d->fg_b;				state2_r = d->bg_r;				state2_g = d->bg_g;				state2_b = d->bg_b;			}			fb_fill_rect(d->x + 1 + g, d->y + 1 + g, 				     d->x + d->width - 3 + g, d->y + d->height - 3 + g, 				     state2_r, state2_g, state2_b, 				     fb_screen);			fb_rect(d->x + g, d->y + g,				d->x + d->width - 2 + g, d->y + d->height - 2 + g,				state1_r, state1_g, state1_b,				fb_screen);			rtm = fb_screen->text.mask;			fb_screen->text.mask = TRUE;			fb_set_textcolor(fb_screen->make_color(state1_r, state1_g, state1_b),					 fb_screen->make_color(state2_r, state2_g, state2_b));			fb_gui_puts(d->x + d->width / 2 + g, 				    d->y + d->height / 2 - fb_screen->font.height / 2 + g, 				    TRUE,				    state1_r, state1_g, state1_b,				    fb_screen,				    d->text);						fb_screen->text.mask = rtm;			if(d->flags & FB_DIALOG_SELECTED)			{				fb_line(d->x, d->y, d->x, d->y + d->height - 2,					d->bg_r, d->bg_g, d->bg_b,					fb_screen);				fb_line(d->x, d->y, d->x + d->width - 2, d->y,					d->bg_r, d->bg_g, d->bg_b, fb_screen);			}			else			{				fb_line(d->x + d->width - 1, d->y + 1,					d->x + d->width - 1, d->y + d->height - 2,					0, 0, 0,					fb_screen);				fb_line(d->x + 1, d->y + d->height - 1,						d->x + d->width - 1, d->y + d->height - 1,						0, 0, 0, 						fb_screen);			}						if((d->flags & FB_DIALOG_FOCUSED) && 			   (!(d->flags & FB_DIALOG_SELECTED) || 			    !(d->flags & FB_DIALOG_EXIT)))				fb_dotted_rect(d->x + 1 + g, d->y + 1 + g, 					       d->x + d->width - 3 + g, d->y + d->height - 3 + g,					       state1_r, state1_g, state1_b,					       state2_r, state2_g, state2_b,					       fb_screen);			break;					case FB_MSG_WANTFOCUS:			return FB_DIALOG_WANTFOCUS;					case FB_MSG_KEY:			if(d->flags & FB_DIALOG_EXIT)				return FB_DIALOG_CLOSE;			d->flags ^= FB_DIALOG_SELECTED;			/* Hide mouse here */			/* Send ourselves the draw message */			/* Unhide mouse here */			break;		case FB_MSG_CLICK:			/* TODO: Handle mouse stuff here */			break;	}	return FB_DIALOG_OK;}int fb_check_proc(int msg, fb_dialog *d, int c){	int x;	int fg_r, fg_g, fg_b;	int bg_r, bg_g, bg_b;	if(msg == FB_MSG_DRAW) {		int rtm;		fg_r = (d->flags & FB_DIALOG_DISABLED) ? /* gui_mg_color_r */ d->fg_r : d->fg_r;		fg_g = (d->flags & FB_DIALOG_DISABLED) ? d->fg_g : d->fg_g;		fg_b = (d->flags & FB_DIALOG_DISABLED) ? d->fg_b : d->fg_b;		bg_r = (d->bg_r < 0) ? /* gui_bg_color_r */ d->bg_r : d->bg_r;		bg_g = (d->bg_g < 0) ? d->bg_g : d->bg_g;		bg_b = (d->bg_b < 0) ? d->bg_b : d->bg_b;		rtm = fb_screen->text.mask;		/* if d1 != 0 print text to right of check */		if(d->d1)			x = d->x;		else			x = d->x + 			    fb_screen->font.height / 2 + 			    fb_gui_puts(d->x, d->y + (d->height - fb_screen->font.height) / 2, 					FALSE, 					fg_r, fg_g, fg_b, 					fb_screen, 					d->text);		fb_fill_rect(x + 1, d->y + 1, 			     x + d->height - 2, d->y + d->height - 2, 			     bg_r, bg_g, bg_b,			     fb_screen);		fb_rect(x, d->y, 			x + d->height - 1, d->y + d->height - 1, 			fg_r, fg_g, fg_b,			fb_screen);		if(d->d1)			fb_gui_puts(x + d->height - 1 + fb_screen->font.height / 2,				    d->y + (d->height - fb_screen->font.height) / 2,				    FALSE,				    fg_r, fg_g, fg_b,				    fb_screen,				    d->text);		if(d->flags & FB_DIALOG_SELECTED)		{			fb_line(x, d->y, 				x + d->height - 1, d->y + d->height - 1, 				fg_r, fg_g, fg_b, 				fb_screen);			fb_line(x, d->y + d->height - 1,				x + d->height - 1, d->y,				fg_r, fg_g, fg_b, 				fb_screen);		}				if(d->flags & FB_DIALOG_FOCUSED)			fb_dotted_rect(x + 1, d->y + 1,				       x + d->height - 2, d->y + d->height - 2,				       fg_r, fg_g, fg_b,				       bg_r, bg_g, bg_b,				       fb_screen);		fb_screen->text.mask = rtm;		return FB_DIALOG_OK;	}	return fb_button_proc(msg, d, 0);}/* d->img is the normal button, d->img2 is selected (i.e. toggled), d->img3 is disabled */int fb_icon_proc(int msg, fb_dialog *d, int c){	fb_surface *butimage = d->img; 	int butx;	int buty;	int index;	int indent;	int depth;	if((msg == FB_MSG_DRAW) && (!(d->flags & FB_DIALOG_HIDDEN)))	{		depth = 0;		if((d->img2 == NULL) && (d->flags & FB_DIALOG_SELECTED))		{			depth = d->d1;			if(depth < 1)				depth = 2;		}		if((d->img2 != NULL) && (d->flags & FB_DIALOG_SELECTED))			butimage = d->img2;		if((d->img3 != NULL) && (d->flags & FB_DIALOG_DISABLED))			butimage = d->img3;		indent = d->d2;		if(indent == 0)			indent = 2;		butx = butimage->width;		buty = butimage->height;		fb_stretch_image(butimage, fb_screen, d->x + depth, d->y + depth, d->width - depth, d->height - depth);		if((d->flags & FB_MSG_GOTFOCUS) && (!(d->flags & FB_DIALOG_SELECTED) || !(d->flags & FB_DIALOG_EXIT)))		{			for(index = indent; index < d->width - (indent + 1); index += 2)			{				fb_putpixel(d->x + index + depth, d->y + indent + depth,					    d->fg_r, d->fg_g, d->fg_b, 					    fb_screen);				fb_putpixel(d->x + index + depth, d->y + d->height - (indent + 1) + depth,					    d->fg_r, d->fg_g, d->fg_b,					    fb_screen);			}			for(index = indent; index < d->height - (indent + 1); index += 2) {				fb_putpixel(d->x + indent + depth, d->y + index + depth,					    d->fg_r, d->fg_g, d->fg_b,					    fb_screen);				fb_putpixel(d->x + d->width - (indent + 1) + depth, d->y + index + depth,					    d->fg_r, d->fg_g, d->fg_b,					    fb_screen);			}		}		for(index = 0; index < depth; index++)		{			fb_line(d->x, d->y + index, 				d->x + d->width - 1, d->y + index,				d->bg_r, d->bg_g, d->bg_b, fb_screen);			fb_line(d->x + index, d->y, 				d->x + index, d->y + d->height - 1,				d->bg_r, d->bg_g, d->bg_b,				fb_screen);		}		return FB_DIALOG_OK;	}	return fb_button_proc(msg, d, c);}

⌨️ 快捷键说明

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