1 /*
2  * file mi_label.c - menu title
3  *
4  * $Id: mi_label.c,v 1.8 2006/02/09 21:21:24 fzago Exp $
5  *
6  * Program XBLAST
7  * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published
11  * by the Free Software Foundation; either version 2; or (at your option)
12  * any later version
13  *
14  * This program is distributed in the hope that it will be entertaining,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.
21  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 
24 #include "xblast.h"
25 
26 /*
27  * local macros
28  */
29 #define FF_LABEL (FF_Large | FF_White | FF_Center | FF_Boxed )
30 #define FF_LABEL1 (FF_Small | FF_White | FF_Center  )
31 #define FF_LABEL2 (FF_Small | FF_White | FF_Center | FF_Boxed  )
32 
33 /*
34  *  local types
35  */
36 typedef struct
37 {
38 	XBMenuItem item;
39 	const char *text;
40 	Sprite *sprite;
41 } XBMenuLabelItem;
42 
43 /*
44  * standard label, boxed, large
45  */
46 XBMenuItem *
MenuCreateLabel(int x,int y,int w,const char * text)47 MenuCreateLabel (int x, int y, int w, const char *text)
48 {
49 	/* create item */
50 	XBMenuLabelItem *label = calloc (1, sizeof (XBMenuLabelItem));
51 	assert (label != NULL);
52 	MenuSetItem (&label->item, MIT_Label, x, y, w, CELL_H, NULL, NULL, NULL, NULL);
53 	/* set item specific data */
54 	label->text = text;
55 	label->sprite =
56 		CreateTextSprite (text, (x + 1) * BASE_X, (y + 1) * BASE_Y, (w - 2) * BASE_X,
57 						  (CELL_H - 2) * BASE_Y, FF_LABEL, SPM_MAPPED);
58 	return &label->item;
59 }								/* MenuCreateLabel */
60 
61 /*
62  * variant label, framed. small
63  */
64 XBMenuItem *
MenuCreateLabel1(int x,int y,int w,const char * text)65 MenuCreateLabel1 (int x, int y, int w, const char *text)
66 {
67 	/* create item */
68 	XBMenuLabelItem *label = calloc (1, sizeof (XBMenuLabelItem));
69 	assert (label != NULL);
70 	MenuSetItem (&label->item, MIT_Label, x, y, w, CELL_H, NULL, NULL, NULL, NULL);
71 	/* set item specific data */
72 	label->text = text;
73 	label->sprite =
74 		CreateTextSprite (text, (x + 1) * BASE_X, (y + 1) * BASE_Y + 6, (w - 2) * BASE_X,
75 						  (CELL_H - 2) * BASE_Y, FF_LABEL1, SPM_MAPPED);
76 	/* add frame */
77 	MenuAddLargeFrame (x / CELL_W, (x + w - 1) / CELL_W, (y + 1) / CELL_H);
78 	return &label->item;
79 }								/* MenuCreateLabel1 */
80 
81 /*
82  * variant label, boxed, small
83  */
84 XBMenuItem *
MenuCreateLabel2(int x,int y,int w,const char * text)85 MenuCreateLabel2 (int x, int y, int w, const char *text)
86 {
87 	/* create item */
88 	XBMenuLabelItem *label = calloc (1, sizeof (XBMenuLabelItem));
89 	assert (label != NULL);
90 	MenuSetItem (&label->item, MIT_Label, x, y, w, CELL_H, NULL, NULL, NULL, NULL);
91 	/* set item specific data */
92 	label->text = text;
93 	label->sprite =
94 		CreateTextSprite (text, (x + 1) * BASE_X, (y + 1) * BASE_Y + 6, (w - 2) * BASE_X,
95 						  (CELL_H - 2) * BASE_Y, FF_LABEL2, SPM_MAPPED);
96 	return &label->item;
97 }								/* MenuCreateLabel2 */
98 
99 /*
100  * delete a label
101  */
102 void
MenuDeleteLabel(XBMenuItem * item)103 MenuDeleteLabel (XBMenuItem * item)
104 {
105 	XBMenuLabelItem *label = (XBMenuLabelItem *) item;
106 	assert (label != NULL);
107 	assert (label->sprite != NULL);
108 	DeleteSprite (label->sprite);
109 }								/* MenuDeleteLabel */
110 
111 /*
112  * end of file mi_label.c
113  */
114