source: svn/trunk/newcon3bcm2_21bu/nexus/app/nanotv/bapp_util.h @ 2

Last change on this file since 2 was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile:  $
11 * $brcm_Revision:  $
12 * $brcm_Date: $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21#ifndef BAPP_UTIL_H__
22#define BAPP_UTIL_H__
23#ifdef LINUX
24#include "bgfx_types.h"
25#include "bsettop_types.h"
26#else
27#include "bsettop_gfx.h"
28#include "bdispatch.h"
29#endif
30#include "fstore.h"
31
32#ifdef BCM_DEBUG
33#define BAPP_ASSERT(expr) {                                         \
34    if (!expr)                                                      \
35        printf("%s failed at %s:%d\n",#expr, __FILE__, __LINE__);   \
36    }
37#else
38#define BAPP_ASSERT(expr) if (!(expr)) ;
39#endif
40
41/*
42 * Utility data structure to use for pseudo IO
43 */
44typedef struct bin_read_t
45{
46    unsigned char *data;
47    unsigned int  size;
48    unsigned int  cnt;
49}bin_read_t;
50
51#define RAND_MAX    1000
52#define RAND_INT(x) (((x) * rand())/RAND_MAX)
53unsigned int rand(void);
54
55/*
56Summary:
57    Sleep for the specified number of milliseconds.
58*/
59
60void bapp_sleep(unsigned int ms);
61
62/*
63Summary:
64    Construct a UNI string in the buffer provided from the cstring.
65*/
66unsigned int c_to_uni_str(
67                        unsigned char *str_p,        /* Null terminated c-string */
68                        unsigned int *p_uni_str,    /* buffer to use for contructing UNI string */
69                        unsigned int max_size       /* maximum buffer size in words */
70                         );
71/*
72Summary:
73    Construct a UNI string in the buffer provided from the null terminated UTF-16 string.
74*/
75unsigned int utf16_to_uni_str(
76                        unsigned short *str_p,       /* NULL terminated (0x0000) UTF - 16 string */
77                        unsigned int *p_uni_str,    /* buffer to use for contructing UNI string */
78                        unsigned int max_size       /* maximum buffer size in words */
79                         );
80
81/*
82Summary:
83    Utility IO function.
84Description:
85    Utility IO function to be used for pseudo IO.
86*/
87
88int bin_read( void *buffer, int size, int count, void *fp );
89int bin_set(void *fp, int offset, int whence );
90unsigned int bin_tell(void *fp );
91
92/*
93Summary:
94    finds a break in the string (space).
95Description:
96    finds a break in the string (space).
97*/
98unsigned int find_break_uni(
99                unsigned int* str,          /* UNI string */
100                unsigned int max            /* Number of characters in UNI string */
101               );
102#ifdef OLD_TEXTBOX
103/*
104Summary:
105    Draw text at x,y and within the specified w,h.
106Description:
107    Draw text at x,y and within the specified w,h.
108*/
109int text_box(bgfx_surf_t *p_surf,               /* bgfx surface */
110             bgfx_font_t *font,                 /* bgfx font */
111            uint16_t x,                         /* x location in pixels */
112            uint16_t y,                         /* y location in pixels */
113            uint16_t width,                     /* width in pixels */
114            uint16_t height,                    /* height in pixels */ 
115            unsigned int *msg,                  /* UNI string */
116            unsigned int msg_len,               /* Number of characters in the msg */
117            bgfx_pixel c,                       /* palette index */
118            int line_spacing                    /* number of vertical pixels between lines */
119            );
120#else
121#define text_box(surf,font,x,y,w,h,msg,len,c,lspace)    \
122        bgfx_draw_text_box(surf,x,y,w,h,(const unsigned long*)msg,len,font,c,lspace)
123#endif
124/*
125Summary:
126    Same as text box but with shadow.
127Description:
128    Same as text box but with shadow.
129*/
130int text_box_shadow(bgfx_surf_t *p_surf,       /* bgfx surface */
131             bgfx_font_t *font,                 /* bgfx font */
132            uint16_t x,                         /* x location in pixels */
133            uint16_t y,                         /* y location in pixels */
134            uint16_t width,                     /* width in pixels */
135            uint16_t height,                    /* height in pixels */ 
136            unsigned int *msg,                  /* UNI string */
137            unsigned int msg_len,               /* Number of characters in the msg */
138            bgfx_pixel c_f,                     /* palette index for forground text*/
139            bgfx_pixel c_b,                     /* palette index for background text */
140            int shadow_offset,                  /* offset from xy to place shaddow (can be negative) */
141            int line_spacing                    /* number of vertical pixels between lines */
142            );
143
144/*
145Summary:
146    Draw a button.
147Description:
148    Draw a button.
149*/
150void draw_button(bgfx_surf_t *p_surf,           /* bgfx surface */
151             bgfx_font_t *font,                 /* bgfx font */
152            uint16_t x,                         /* x location in pixels */
153            uint16_t y,                         /* y location in pixels */
154            uint16_t width,                     /* width in pixels */
155            uint16_t height,                    /* height in pixels */ 
156            unsigned int *msg,                  /* UNI string */
157            unsigned int msg_len,               /* Number of characters in the msg */
158            int state,                          /* button state, 1 - on, 0 - off */
159            int type                            /* button type, 1 - check box, 0 - menu */
160            );
161
162int tsid_to_utc_offset(unsigned short tsid, int *p_offset, char *p_dst);
163
164int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
165
166#endif /* BAPP_UTIL_H__ */
Note: See TracBrowser for help on using the repository browser.