mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-07 01:44:41 +08:00
add radio station selection; remove list and filelist view implementation in STM32 radio; remove warning of RTGUI.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@419 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -117,7 +117,7 @@ static rt_bool_t view_event_handler(struct rtgui_widget* widget, struct rtgui_ev
|
||||
};
|
||||
|
||||
/* check device index */
|
||||
if (dev_index < 0 || dev_index > 4) dev_index = 3;
|
||||
if (dev_index > 4) dev_index = 3;
|
||||
|
||||
/* draw each information */
|
||||
sprintf(line, "设备: %s %s",
|
||||
|
||||
@@ -503,7 +503,7 @@ struct pbuf *rt_dm9000_rx(rt_device_t dev)
|
||||
{
|
||||
rt_uint16_t dummy;
|
||||
|
||||
DM9000_TRACE("dm9000 rx: no pbuf\n");
|
||||
rt_kprintf("dm9000 rx: no pbuf\n");
|
||||
|
||||
/* no pbuf, discard data from DM9000 */
|
||||
data = &dummy;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,55 +0,0 @@
|
||||
#ifndef __FILE_LIST_VIEW_H__
|
||||
#define __FILE_LIST_VIEW_H__
|
||||
|
||||
#include <rtgui/widgets/view.h>
|
||||
|
||||
#define FITEM_FILE 0x0
|
||||
#define FITEM_DIR 0x1
|
||||
struct file_item
|
||||
{
|
||||
rt_uint8_t* name;
|
||||
|
||||
rt_uint32_t type;
|
||||
rt_uint32_t size;
|
||||
};
|
||||
|
||||
/** Gets the type of a filelist view */
|
||||
#define FILELIST_VIEW_TYPE (filelist_view_type_get())
|
||||
/** Casts the object to a filelist */
|
||||
#define FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), FILELIST_VIEW_TYPE, filelist_view_t))
|
||||
/** Checks if the object is a filelist view */
|
||||
#define IS_FILELIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), FILELIST_VIEW_TYPE))
|
||||
|
||||
struct filelist_view
|
||||
{
|
||||
struct rtgui_view parent;
|
||||
|
||||
/* widget private data */
|
||||
|
||||
/* current directory */
|
||||
rt_uint8_t* current_directory;
|
||||
rt_uint8_t* pattern;
|
||||
|
||||
/* the number of item in a page */
|
||||
rt_uint16_t page_items;
|
||||
rt_uint16_t items_count;
|
||||
|
||||
/* the selected item */
|
||||
rt_uint16_t current_item;
|
||||
|
||||
/* items array */
|
||||
struct file_item *items;
|
||||
};
|
||||
typedef struct filelist_view filelist_view_t;
|
||||
|
||||
rtgui_type_t *filelist_view_type_get(void);
|
||||
|
||||
filelist_view_t* filelist_view_create(rtgui_workbench_t* workbench, const char* directory, const char* pattern, const rtgui_rect_t* rect);
|
||||
void filelist_view_destroy(filelist_view_t* view);
|
||||
|
||||
void filelist_view_clear(filelist_view_t* view);
|
||||
|
||||
rt_bool_t filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
void filelist_view_set_directory(filelist_view_t* view, const char* directory);
|
||||
|
||||
#endif
|
||||
@@ -8,12 +8,7 @@
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/netdb.h>
|
||||
|
||||
const char _http_get[] = "GET ";
|
||||
const char _http_host[] = "Host: ";
|
||||
const char _http_getend[] = " HTTP/1.0\r\n";
|
||||
const char _http_user_agent[] = "User-Agent: RT-Thread HTTP Agent\r\n";
|
||||
const char _http_endheader[] = "\r\n";
|
||||
|
||||
const char _http_get[] = "GET %s HTTP/1.0\r\nHost: %s:%d\r\nUser-Agent: RT-Thread HTTP Agent\r\n\r\n";
|
||||
const char _shoutcast_get[] = "GET %s HTTP/1.0\r\nHost: %s:%d\r\nUser-Agent: RT-Thread HTTP Agent\r\nIcy-MetaData: 1\r\nConnection: close\r\n\r\n";
|
||||
|
||||
extern long int strtol(const char *nptr, char **endptr, int base);
|
||||
@@ -167,7 +162,6 @@ const char *http_resolve_address( struct sockaddr_in *server, const char * url,
|
||||
port[w] = url[w + i + 1];
|
||||
port[w] = '\0';
|
||||
|
||||
rt_kprintf("HTTP: using port %s for connection\n", port);
|
||||
break;
|
||||
}
|
||||
else is_domain = 1;
|
||||
@@ -225,51 +219,19 @@ static int http_connect(struct http_session* session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Needs more error checking here.....
|
||||
#if 0
|
||||
rc = send( peer_handle, _http_get, sizeof( _http_get ) - 1, 0 );
|
||||
rc = send( peer_handle, (void*) url, strlen( url ), 0 );
|
||||
rc = send( peer_handle, _http_getend, sizeof( _http_getend ) - 1, 0 );
|
||||
|
||||
rc = send( peer_handle, _http_host, sizeof( _http_host ) - 1, 0 );
|
||||
rc = send( peer_handle, host_addr, strlen( host_addr ), 0 );
|
||||
rc = send( peer_handle, _http_endheader, sizeof( _http_endheader ) - 1, 0 ); // "\r\n"
|
||||
|
||||
rc = send( peer_handle, _http_user_agent, sizeof( _http_user_agent ) - 1, 0 );
|
||||
rc = send( peer_handle, _http_endheader, sizeof( _http_endheader ) - 1, 0 );
|
||||
#else
|
||||
{
|
||||
rt_uint8_t *ptr, *buf;
|
||||
char *buf;
|
||||
rt_uint32_t length;
|
||||
|
||||
buf = rt_malloc (512);
|
||||
ptr = buf;
|
||||
rt_memcpy(ptr, _http_get, sizeof(_http_get) - 1);
|
||||
ptr += sizeof(_http_get) - 1;
|
||||
length = rt_snprintf(buf, 512, _http_get, url, host_addr, server->sin_port);
|
||||
|
||||
rt_memcpy(ptr, url, strlen(url));
|
||||
ptr += strlen(url);
|
||||
|
||||
rt_memcpy(ptr, _http_getend, sizeof(_http_getend) - 1);
|
||||
ptr += sizeof(_http_getend) - 1;
|
||||
|
||||
rt_memcpy(ptr, _http_host, sizeof(_http_host) - 1);
|
||||
ptr += sizeof(_http_host) - 1;
|
||||
|
||||
rt_memcpy(ptr, host_addr, strlen(host_addr));
|
||||
ptr += strlen(host_addr);
|
||||
|
||||
rt_memcpy(ptr, _http_endheader, sizeof(_http_endheader) - 1);
|
||||
ptr += sizeof(_http_endheader) - 1;
|
||||
|
||||
rt_memcpy(ptr, _http_user_agent, sizeof(_http_user_agent) - 1);
|
||||
ptr += sizeof(_http_user_agent) - 1;
|
||||
|
||||
rt_memcpy(ptr, _http_endheader, sizeof(_http_endheader) - 1);
|
||||
ptr += sizeof(_http_endheader) - 1;
|
||||
rc = send(peer_handle, buf,
|
||||
(rt_uint32_t)ptr - (rt_uint32_t)buf, 0);
|
||||
rc = send(peer_handle, buf, length, 0);
|
||||
rt_kprintf("HTTP request:\n%s", buf);
|
||||
|
||||
/* release buffer */
|
||||
rt_free(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
// We now need to read the header information
|
||||
while ( 1 )
|
||||
@@ -425,7 +387,7 @@ static int shoutcast_connect(struct shoutcast_session* session,
|
||||
}
|
||||
|
||||
{
|
||||
rt_uint8_t *buf;
|
||||
char *buf;
|
||||
rt_uint32_t length;
|
||||
|
||||
buf = rt_malloc (512);
|
||||
@@ -498,7 +460,7 @@ static int shoutcast_connect(struct shoutcast_session* session,
|
||||
if (strstr(mimeBuffer, "content-type:"))
|
||||
{
|
||||
/* check content-type */
|
||||
if (strstr(mimeBuffer, "content-type:audio/mpeg") == RT_NULL)
|
||||
if (strstr(mimeBuffer, "content-type: audio/mpeg") == RT_NULL)
|
||||
{
|
||||
rt_kprintf("ICY content is not audio/mpeg.\n");
|
||||
return -1;
|
||||
@@ -574,7 +536,12 @@ rt_size_t shoutcast_session_read(struct shoutcast_session* session, rt_uint8_t *
|
||||
do
|
||||
{
|
||||
bytesRead = recv(session->socket, buffer + totalRead, left, 0);
|
||||
if(bytesRead <= 0) break;
|
||||
if(bytesRead <= 0)
|
||||
{
|
||||
rt_kprintf("no data on recv, len %d,err %d\n", bytesRead,
|
||||
lwip_get_error(session->socket));
|
||||
break;
|
||||
}
|
||||
|
||||
left -= bytesRead;
|
||||
totalRead += bytesRead;
|
||||
@@ -645,7 +612,7 @@ void http_test(char* url)
|
||||
do
|
||||
{
|
||||
rt_memset(buffer, 0, sizeof(buffer));
|
||||
length = http_session_read(session, buffer, sizeof(buffer));
|
||||
length = http_session_read(session, (rt_uint8_t*)buffer, sizeof(buffer));
|
||||
|
||||
rt_kprintf(buffer);rt_kprintf("\n");
|
||||
} while (length > 0);
|
||||
@@ -668,3 +635,4 @@ void shoutcast_test(char* url)
|
||||
shoutcast_session_close(session);
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(shoutcast_test, shoutcast client test);
|
||||
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
#include "listview.h"
|
||||
#include <rtgui/rtgui_theme.h>
|
||||
|
||||
#define LIST_MARGIN 5
|
||||
|
||||
static void _list_view_constructor(struct list_view *view)
|
||||
{
|
||||
/* default rect */
|
||||
struct rtgui_rect rect = {0, 0, 200, 200};
|
||||
|
||||
/* set default widget rect and set event handler */
|
||||
rtgui_widget_set_event_handler(RTGUI_WIDGET(view),list_view_event_handler);
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);
|
||||
|
||||
RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
|
||||
|
||||
view->current_item = 0;
|
||||
view->items_count = 0;
|
||||
view->page_items = 0;
|
||||
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
|
||||
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL;
|
||||
}
|
||||
|
||||
rtgui_type_t *list_view_type_get(void)
|
||||
{
|
||||
static rtgui_type_t *list_view_type = RT_NULL;
|
||||
|
||||
if (!list_view_type)
|
||||
{
|
||||
list_view_type = rtgui_type_create("listview", RTGUI_VIEW_TYPE,
|
||||
sizeof(list_view_t), RTGUI_CONSTRUCTOR(_list_view_constructor), RT_NULL);
|
||||
}
|
||||
|
||||
return list_view_type;
|
||||
}
|
||||
|
||||
void list_view_ondraw(struct list_view* view)
|
||||
{
|
||||
struct rtgui_rect rect, item_rect;
|
||||
struct rtgui_dc* dc;
|
||||
rt_uint16_t page_index, index;
|
||||
struct list_item* item;
|
||||
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
|
||||
if (dc == RT_NULL) return;
|
||||
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
rtgui_dc_fill_rect(dc, &rect);
|
||||
|
||||
/* get item base rect */
|
||||
item_rect = rect;
|
||||
item_rect.y1 += 2;
|
||||
item_rect.y2 = item_rect.y1 + (2 + rtgui_theme_get_selected_height());
|
||||
|
||||
/* get current page */
|
||||
page_index = (view->current_item / view->page_items) * view->page_items;
|
||||
for (index = 0; index < view->page_items; index ++)
|
||||
{
|
||||
if (page_index + index >= view->items_count) break;
|
||||
|
||||
item = &(view->items[page_index + index]);
|
||||
|
||||
if (page_index + index == view->current_item)
|
||||
{
|
||||
rtgui_theme_draw_selected(dc, &item_rect);
|
||||
}
|
||||
item_rect.x1 += LIST_MARGIN;
|
||||
|
||||
if (item->image != RT_NULL)
|
||||
{
|
||||
rtgui_image_blit(item->image, dc, &item_rect);
|
||||
item_rect.x1 += item->image->w + 2;
|
||||
}
|
||||
/* draw text */
|
||||
rtgui_dc_draw_text(dc, item->name, &item_rect);
|
||||
|
||||
if (item->image != RT_NULL)
|
||||
item_rect.x1 -= (item->image->w + 2);
|
||||
item_rect.x1 -= LIST_MARGIN;
|
||||
|
||||
/* move to next item position */
|
||||
item_rect.y1 += (rtgui_theme_get_selected_height() + 2);
|
||||
item_rect.y2 += (rtgui_theme_get_selected_height() + 2);
|
||||
}
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
|
||||
void list_view_update_current(struct list_view* view, rt_uint16_t old_item)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
struct list_item* item;
|
||||
rtgui_rect_t rect, item_rect;
|
||||
|
||||
if (old_item/view->page_items != view->current_item/view->page_items)
|
||||
{
|
||||
/* it's not a same page, update all */
|
||||
rtgui_widget_update(RTGUI_WIDGET(view));
|
||||
return;
|
||||
}
|
||||
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
|
||||
if (dc == RT_NULL) return;
|
||||
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
|
||||
item_rect = rect;
|
||||
/* get old item's rect */
|
||||
item_rect.y1 += 2;
|
||||
item_rect.y1 += (old_item % view->page_items) * (2 + rtgui_theme_get_selected_height());
|
||||
item_rect.y2 = item_rect.y1 + (2 + rtgui_theme_get_selected_height());
|
||||
|
||||
/* draw old item */
|
||||
rtgui_dc_fill_rect(dc, &item_rect);
|
||||
|
||||
item_rect.x1 += LIST_MARGIN;
|
||||
|
||||
item = &(view->items[old_item]);
|
||||
if (item->image != RT_NULL)
|
||||
{
|
||||
rtgui_image_blit(item->image, dc, &item_rect);
|
||||
item_rect.x1 += item->image->w + 2;
|
||||
}
|
||||
rtgui_dc_draw_text(dc, item->name, &item_rect);
|
||||
|
||||
/* draw current item */
|
||||
item_rect = rect;
|
||||
/* get current item's rect */
|
||||
item_rect.y1 += 2;
|
||||
item_rect.y1 += (view->current_item % view->page_items) * (2 + rtgui_theme_get_selected_height());
|
||||
item_rect.y2 = item_rect.y1 + (2 + rtgui_theme_get_selected_height());
|
||||
|
||||
/* draw current item */
|
||||
rtgui_theme_draw_selected(dc, &item_rect);
|
||||
|
||||
item_rect.x1 += LIST_MARGIN;
|
||||
|
||||
item = &(view->items[view->current_item]);
|
||||
if (item->image != RT_NULL)
|
||||
{
|
||||
rtgui_image_blit(item->image, dc, &item_rect);
|
||||
item_rect.x1 += (item->image->w + 2);
|
||||
}
|
||||
rtgui_dc_draw_text(dc, item->name, &item_rect);
|
||||
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
|
||||
rt_bool_t list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
|
||||
{
|
||||
struct list_view* view = RT_NULL;
|
||||
|
||||
view = LIST_VIEW(widget);
|
||||
switch (event->type)
|
||||
{
|
||||
case RTGUI_EVENT_PAINT:
|
||||
list_view_ondraw(view);
|
||||
return RT_FALSE;
|
||||
|
||||
case RTGUI_EVENT_RESIZE:
|
||||
{
|
||||
struct rtgui_event_resize* resize;
|
||||
|
||||
resize = (struct rtgui_event_resize*)event;
|
||||
|
||||
/* recalculate page items */
|
||||
view->page_items = resize->h / (2 + rtgui_theme_get_selected_height());
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_KBD:
|
||||
{
|
||||
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event;
|
||||
if (ekbd->type == RTGUI_KEYDOWN)
|
||||
{
|
||||
rt_uint16_t old_item;
|
||||
|
||||
old_item = view->current_item;
|
||||
switch (ekbd->key)
|
||||
{
|
||||
case RTGUIK_LEFT:
|
||||
if (view->current_item - view->page_items >= 0)
|
||||
view->current_item -= view->page_items;
|
||||
list_view_update_current(view, old_item);
|
||||
return RT_FALSE;
|
||||
|
||||
case RTGUIK_UP:
|
||||
if (view->current_item > 0)
|
||||
view->current_item --;
|
||||
list_view_update_current(view, old_item);
|
||||
return RT_FALSE;
|
||||
|
||||
case RTGUIK_RIGHT:
|
||||
if (view->current_item + view->page_items < view->items_count - 1)
|
||||
view->current_item += view->page_items;
|
||||
list_view_update_current(view, old_item);
|
||||
return RT_FALSE;
|
||||
|
||||
case RTGUIK_DOWN:
|
||||
if (view->current_item < view->items_count - 1)
|
||||
view->current_item ++;
|
||||
list_view_update_current(view, old_item);
|
||||
return RT_FALSE;
|
||||
|
||||
case RTGUIK_RETURN:
|
||||
if (view->items[view->current_item].action != RT_NULL)
|
||||
{
|
||||
view->items[view->current_item].action(view->items[view->current_item].parameter);
|
||||
}
|
||||
return RT_FALSE;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
/* use view event handler */
|
||||
return rtgui_view_event_handler(widget, event);
|
||||
}
|
||||
|
||||
list_view_t* list_view_create(struct list_item* items, rt_uint16_t count, rtgui_rect_t *rect)
|
||||
{
|
||||
struct list_view* view = RT_NULL;
|
||||
|
||||
view = (struct list_view*) rtgui_widget_create(LIST_VIEW_TYPE);
|
||||
if (view != RT_NULL)
|
||||
{
|
||||
view->items = items;
|
||||
view->items_count = count;
|
||||
|
||||
view->page_items = rtgui_rect_height(*rect) / (2 + rtgui_theme_get_selected_height());
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
void list_view_destroy(list_view_t* view)
|
||||
{
|
||||
/* destroy view */
|
||||
rtgui_widget_destroy(RTGUI_WIDGET(view));
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#ifndef __RTGUI_LIST_VIEW_H__
|
||||
#define __RTGUI_LIST_VIEW_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/image.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
#include <rtgui/widgets/view.h>
|
||||
|
||||
typedef void (*item_action)(void* parameter);
|
||||
struct list_item
|
||||
{
|
||||
char* name;
|
||||
rtgui_image_t *image;
|
||||
|
||||
item_action action;
|
||||
void *parameter;
|
||||
};
|
||||
|
||||
/** Gets the type of a list view */
|
||||
#define LIST_VIEW_TYPE (list_view_type_get())
|
||||
/** Casts the object to a filelist */
|
||||
#define LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), LIST_VIEW_TYPE, list_view_t))
|
||||
/** Checks if the object is a filelist view */
|
||||
#define IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), LIST_VIEW_TYPE))
|
||||
|
||||
struct list_view
|
||||
{
|
||||
struct rtgui_view parent;
|
||||
|
||||
/* widget private data */
|
||||
/* list item */
|
||||
struct list_item* items;
|
||||
|
||||
/* total number of items */
|
||||
rt_uint16_t items_count;
|
||||
/* the number of item in a page */
|
||||
rt_uint16_t page_items;
|
||||
/* current item */
|
||||
rt_uint16_t current_item;
|
||||
};
|
||||
typedef struct list_view list_view_t;
|
||||
|
||||
rtgui_type_t *list_view_type_get(void);
|
||||
|
||||
list_view_t* list_view_create(struct list_item* items, rt_uint16_t count,
|
||||
rtgui_rect_t *rect);
|
||||
void list_view_clear(list_view_t* view);
|
||||
|
||||
rt_bool_t list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -523,8 +523,7 @@ void http_mp3(char* url)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(http_mp3, http mp3 decode test);
|
||||
|
||||
/* http mp3 */
|
||||
#include "http.h"
|
||||
/* ice mp3 */
|
||||
static rt_size_t ice_fetch(rt_uint8_t* ptr, rt_size_t len, void* parameter)
|
||||
{
|
||||
struct shoutcast_session* session = (struct shoutcast_session*)parameter;
|
||||
@@ -577,15 +576,4 @@ void ice_mp3(char* url)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(ice_mp3, shoutcast mp3 decode test);
|
||||
|
||||
char ice_url[] = "http://192.168.1.5:8000/stream";
|
||||
void ice()
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("ice", ice_mp3, (void*)ice_url,
|
||||
4096, 0x08, 5);
|
||||
if (tid != RT_NULL) rt_thread_startup(tid);
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(ice, shoutcast thread test);
|
||||
|
||||
#endif
|
||||
|
||||
12
bsp/stm32_radio/mp3.h
Normal file
12
bsp/stm32_radio/mp3.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __MP3_H__
|
||||
#define __MP3_H__
|
||||
|
||||
#include "player_ui.h"
|
||||
|
||||
void mp3_get_info(const char* filename, struct tag_info* info);
|
||||
|
||||
void mp3(char* filename);
|
||||
void http_mp3(char* url);
|
||||
void ice_mp3(char* url);
|
||||
|
||||
#endif
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "netbuffer.h"
|
||||
#include "player_ui.h"
|
||||
|
||||
#define MP3_DECODE_MP_CNT 2
|
||||
#define MP3_DECODE_MP_SZ 2560
|
||||
@@ -151,7 +152,7 @@ rt_size_t net_buf_read(rt_uint8_t* buffer, rt_size_t length)
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "play_list.h"
|
||||
#include "player_ui.h"
|
||||
#include "mp3.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static struct play_item **play_list = RT_NULL;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "player_bg.h"
|
||||
#include "player_ui.h"
|
||||
#include "mp3.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -23,17 +24,7 @@ void player_play_req(const char* fn)
|
||||
rt_mq_send(player_thread_mq, (void*)&request, sizeof(struct player_request));
|
||||
}
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
static const char _fn[] = "/005.mp3";
|
||||
void play()
|
||||
{
|
||||
player_play_file(_fn);
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(play, play mp3 file test);
|
||||
#endif
|
||||
|
||||
void player_stop()
|
||||
void player_stop_req()
|
||||
{
|
||||
is_playing = RT_FALSE;
|
||||
}
|
||||
@@ -109,3 +100,4 @@ void player_init()
|
||||
player_ui_init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,21 +8,23 @@ enum PLAYER_REQUEST_TYPE
|
||||
PLAYER_REQUEST_PLAY_SINGLE_FILE,
|
||||
PLAYER_REQUEST_PLAY_LIST,
|
||||
PLAYER_REQUEST_STOP,
|
||||
PLAYER_REQUEST_NEXT,
|
||||
PLAYER_REQUEST_PREV,
|
||||
};
|
||||
|
||||
struct player_request
|
||||
{
|
||||
enum PLAYER_REQUEST_TYPE type;
|
||||
|
||||
char fn[64];
|
||||
};
|
||||
|
||||
/* get player background status */
|
||||
rt_bool_t player_is_playing(void);
|
||||
void player_stop(void);
|
||||
/* player background thread init */
|
||||
void player_init(void);
|
||||
|
||||
void player_play_list(const char** list);
|
||||
void player_play_file(const char* fn);
|
||||
/* send a stop request to player background thread */
|
||||
void player_stop_req(void);
|
||||
/* send a play request to player background thread */
|
||||
void player_play_req(const char* fn);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,11 +37,16 @@ enum PLAYER_STEP
|
||||
PLAYER_STEP_NEXT,
|
||||
};
|
||||
|
||||
/* init player ui */
|
||||
void player_ui_init(void);
|
||||
|
||||
/* notification function, which invoked by player background thread */
|
||||
void player_notify_play(void);
|
||||
void player_notify_stop(void);
|
||||
|
||||
/* set player information */
|
||||
void player_set_position(rt_uint32_t position);
|
||||
void player_set_title(const char* title);
|
||||
void player_set_buffer_status(rt_bool_t buffering);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,9 +37,7 @@ File 1,1,<.\wav.c><wav.c>
|
||||
File 1,1,<.\netbuffer.c><netbuffer.c>
|
||||
File 1,1,<.\key.c><key.c>
|
||||
File 1,1,<.\info.c><info.c>
|
||||
File 1,1,<.\filelist.c><filelist.c>
|
||||
File 1,1,<.\device_info.c><device_info.c>
|
||||
File 1,1,<.\listview.c><listview.c>
|
||||
File 1,1,<.\player_ui.c><player_ui.c>
|
||||
File 1,1,<.\player_bg.c><player_bg.c>
|
||||
File 1,1,<.\play_list.c><play_list.c>
|
||||
@@ -48,6 +46,7 @@ File 1,1,<.\codec.c><codec.c>
|
||||
File 1,1,<.\spi_flash.c><spi_flash.c>
|
||||
File 1,1,<.\remote.c><remote.c>
|
||||
File 1,1,<.\picture.c><picture.c>
|
||||
File 1,1,<.\station_list.c><station_list.c>
|
||||
File 2,1,<..\..\src\clock.c><clock.c>
|
||||
File 2,1,<..\..\src\idle.c><idle.c>
|
||||
File 2,1,<..\..\src\ipc.c><ipc.c>
|
||||
@@ -210,6 +209,8 @@ File 11,1,<..\..\rtgui\server\topwin.c><topwin.c>
|
||||
File 11,1,<..\..\rtgui\common\font_hz_file.c><font_hz_file.c>
|
||||
File 11,1,<..\..\rtgui\common\hz16font.c><hz16font.c>
|
||||
File 11,1,<..\..\rtgui\common\hz12font.c><hz12font.c>
|
||||
File 11,1,<..\..\rtgui\widgets\list_view.c><list_view.c>
|
||||
File 11,1,<..\..\rtgui\widgets\filelist_view.c><filelist_view.c>
|
||||
File 12,1,<.\Libraries\Mass_Storage\src\hw_config.c><hw_config.c>
|
||||
File 12,1,<.\Libraries\Mass_Storage\src\mass_mal.c><mass_mal.c>
|
||||
File 12,1,<.\Libraries\Mass_Storage\src\memory.c><memory.c>
|
||||
@@ -279,7 +280,7 @@ Options 1,0,0 // Target 'RT-Thread STM32 Radio'
|
||||
OCR_RVCT { 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,8,0,0,8,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,1,0,0,0,0,0,0,0,0,0,0 }
|
||||
RV_STAVEC ()
|
||||
ADSCCFLG { 5,32,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
ADSCMISC ()
|
||||
ADSCMISC (--diag_suppress=870)
|
||||
ADSCDEFN (USE_STDPERIPH_DRIVER, STM32F10X_HD,)
|
||||
ADSCUDEF ()
|
||||
ADSCINCD (.;.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;..\..\libcpu\arm\stm32;..\..\finsh;..\..\net\lwip\src;..\..\net\lwip\src\include;..\..\net\lwip\src\arch\include;..\..\net\lwip\src\include\ipv4;..\..\filesystem\dfs;..\..\filesystem\dfs\include;..\..\filesystem\dfs\filesystems\efsl\src\include;..\..\filesystem\dfs\filesystems\efsl\src\base\include;..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\include;..\..\rtgui\include;..\..\rtgui\common\libz)
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
#define RT_LWIP_TCP_SND_BUF 2048
|
||||
|
||||
/* TCP Window Size */
|
||||
#define RT_LWIP_TCP_WND (1024 * 2)
|
||||
#define RT_LWIP_TCP_WND (1024 * 20)
|
||||
|
||||
/* Enable SNMP protocol */
|
||||
/* #define RT_LWIP_SNMP */
|
||||
|
||||
219
bsp/stm32_radio/station_list.c
Normal file
219
bsp/stm32_radio/station_list.c
Normal file
@@ -0,0 +1,219 @@
|
||||
#include <string.h>
|
||||
#include <dfs_posix.h>
|
||||
#include "station_list.h"
|
||||
|
||||
static rt_uint32_t read_line(int fd, char* line, rt_uint32_t line_size)
|
||||
{
|
||||
char *pos, *next;
|
||||
rt_uint32_t length;
|
||||
|
||||
length = read(fd, line, line_size);
|
||||
if (length > 0)
|
||||
{
|
||||
pos = strstr(line, "\r\n");
|
||||
if (pos == RT_NULL)
|
||||
{
|
||||
pos = strstr(line, "\n");
|
||||
next = pos ++;
|
||||
}
|
||||
else next = pos + 2;
|
||||
|
||||
if (pos != RT_NULL)
|
||||
{
|
||||
*pos = '\0';
|
||||
|
||||
/* move back */
|
||||
lseek(fd, -(length - (next - line)), SEEK_CUR);
|
||||
|
||||
length = pos - line;
|
||||
}
|
||||
else length = 0;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
static char *strncasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
size_t nl=strlen(needle);
|
||||
size_t hl=strlen(haystack);
|
||||
size_t i;
|
||||
|
||||
if (!nl) goto found;
|
||||
if (nl>hl) return 0;
|
||||
for (i=hl-nl+1; i; --i)
|
||||
{
|
||||
if (*haystack==*needle && !strncasecmp(haystack,needle,nl))
|
||||
found:
|
||||
return (char*)haystack;
|
||||
++haystack;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
station list file format:
|
||||
|
||||
[playlist]
|
||||
numberofentries=1
|
||||
File1=http://67.159.5.47:8110
|
||||
Title1=(#1 - 7/500) The Dominican.net Radio
|
||||
*/
|
||||
struct station_list* station_list_create(const char* fn)
|
||||
{
|
||||
int fd;
|
||||
rt_uint32_t length, index;
|
||||
struct station_list* list;
|
||||
char *line, *pos, prefix[8];
|
||||
|
||||
list = (struct station_list*)rt_malloc(sizeof(struct station_list));
|
||||
if (list == RT_NULL) goto _return0; /* no memory */
|
||||
list->count = 0; list->items = RT_NULL;
|
||||
|
||||
#define LINE_BUFFER_SIZE 128
|
||||
line = rt_malloc(LINE_BUFFER_SIZE);
|
||||
if (line == RT_NULL)
|
||||
goto _return1; /* no memory */
|
||||
|
||||
fd = open(fn, O_RDONLY, 0);
|
||||
if (fd < 0) goto _return2; /* open file failed */
|
||||
|
||||
length = read_line(fd, line, LINE_BUFFER_SIZE);
|
||||
pos = strncasestr(line, "[playlist]");
|
||||
if (pos == RT_NULL)
|
||||
{
|
||||
station_list_destroy(list);
|
||||
list = RT_NULL;
|
||||
goto _return2;
|
||||
}
|
||||
|
||||
length = read_line(fd, line, LINE_BUFFER_SIZE);
|
||||
pos = strncasestr(line, "numberofentries=");
|
||||
if (pos != RT_NULL)
|
||||
{
|
||||
list->count = (int)strtol(pos + strlen("numberofentries="), RT_NULL, 10);
|
||||
if (list->count > 0)
|
||||
{
|
||||
list->items = (struct station_item*) rt_malloc (sizeof(struct station_item) * list->count);
|
||||
rt_memset(list->items, 0, sizeof(struct station_item) * list->count);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
station_list_destroy(list);
|
||||
list = RT_NULL;
|
||||
goto _return2;
|
||||
}
|
||||
|
||||
if (list->items == RT_NULL)
|
||||
{
|
||||
station_list_destroy(list);
|
||||
list = RT_NULL;
|
||||
goto _return2;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
while (index < list->count)
|
||||
{
|
||||
length = read_line(fd, line, LINE_BUFFER_SIZE);
|
||||
if (length > 0)
|
||||
{
|
||||
rt_snprintf(prefix, sizeof(prefix), "File%d", index + 1);
|
||||
pos = strncasestr(line, prefix);
|
||||
if (pos != RT_NULL)
|
||||
strncpy(list->items[index].url, pos + strlen(prefix) + 1, 128);
|
||||
|
||||
rt_snprintf(prefix, sizeof(prefix), "Title%d", index + 1);
|
||||
pos = strncasestr(line, prefix);
|
||||
if (pos != RT_NULL)
|
||||
{
|
||||
strncpy(list->items[index].title, pos + strlen(prefix) + 1, 40);
|
||||
index ++;
|
||||
}
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
_return2:
|
||||
close(fd);
|
||||
_return1:
|
||||
rt_free(line);
|
||||
|
||||
_return0:
|
||||
return list;
|
||||
}
|
||||
|
||||
void station_list_destroy(struct station_list* list)
|
||||
{
|
||||
/* release memory */
|
||||
rt_free(list->items);
|
||||
rt_free(list);
|
||||
}
|
||||
|
||||
/* update station list file from network */
|
||||
void station_list_update(struct rtgui_workbench* workbench)
|
||||
{
|
||||
}
|
||||
|
||||
static void station_list_selected(void* parameter)
|
||||
{
|
||||
rtgui_list_view_t *view;
|
||||
|
||||
view = RTGUI_LIST_VIEW(parameter);
|
||||
|
||||
if (view->current_item != 0)
|
||||
rtgui_view_end_modal(RTGUI_VIEW(view), RTGUI_MODAL_OK);
|
||||
else
|
||||
rtgui_view_end_modal(RTGUI_VIEW(view), RTGUI_MODAL_CANCEL);
|
||||
}
|
||||
|
||||
/* select a station from list */
|
||||
struct station_item* station_list_select(struct station_list* list, struct rtgui_workbench* workbench)
|
||||
{
|
||||
rt_size_t index;
|
||||
rtgui_rect_t rect;
|
||||
rtgui_list_view_t *view;
|
||||
struct rtgui_list_item* items;
|
||||
struct station_item* station;
|
||||
char exit_str[] = "·µ»Ø..";
|
||||
|
||||
RT_ASSERT(list != RT_NULL);
|
||||
RT_ASSERT(workbench != RT_NULL);
|
||||
|
||||
station = RT_NULL;
|
||||
|
||||
items = (struct rtgui_list_item*) rt_malloc (sizeof(struct rtgui_list_item) * (list->count + 1));
|
||||
if (items == RT_NULL) return RT_NULL; /* no memory */
|
||||
|
||||
/* create view */
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
|
||||
view = rtgui_list_view_create(items, list->count + 1, &rect);
|
||||
|
||||
items[0].image = RT_NULL;
|
||||
items[0].action = station_list_selected;
|
||||
items[0].name = exit_str;
|
||||
items[0].parameter = view;
|
||||
|
||||
for (index = 1; index < list->count + 1; index ++)
|
||||
{
|
||||
items[index].image = RT_NULL;
|
||||
items[index].action = station_list_selected;
|
||||
items[index].name = list->items[index - 1].title;
|
||||
items[index].parameter = view;
|
||||
}
|
||||
|
||||
/* add view to workbench */
|
||||
rtgui_workbench_add_view(workbench, RTGUI_VIEW(view));
|
||||
|
||||
/* show view as modal */
|
||||
if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
|
||||
{
|
||||
station = &list->items[view->current_item - 1];
|
||||
}
|
||||
|
||||
/* destroy view */
|
||||
rtgui_list_view_destroy(view);
|
||||
|
||||
return station;
|
||||
}
|
||||
|
||||
31
bsp/stm32_radio/station_list.h
Normal file
31
bsp/stm32_radio/station_list.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __STATION_LIST_H__
|
||||
#define __STATION_LIST_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/widgets/list_view.h>
|
||||
#include <rtgui/widgets/workbench.h>
|
||||
|
||||
struct station_item
|
||||
{
|
||||
char title[40];
|
||||
char url[128];
|
||||
};
|
||||
|
||||
struct station_list
|
||||
{
|
||||
rt_uint32_t count;
|
||||
struct station_item* items;
|
||||
};
|
||||
|
||||
struct station_list* station_list_create(const char* fn);
|
||||
void station_list_destroy(struct station_list* list);
|
||||
|
||||
/* update station list file from network */
|
||||
void station_list_update(struct rtgui_workbench* workbench);
|
||||
|
||||
/* select a station from list */
|
||||
struct station_item* station_list_select(struct station_list* list, struct rtgui_workbench* workbench);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
#include <rtgui/widgets/view.h>
|
||||
#include <rtgui/widgets/workbench.h>
|
||||
|
||||
static rt_bool_t view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
|
||||
{
|
||||
/* 我们目前只对绘制事件感兴趣 */
|
||||
if (event->type == RTGUI_EVENT_PAINT)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
struct rtgui_rect rect;
|
||||
|
||||
/* 获得一个设备上下文 */
|
||||
dc = rtgui_dc_begin_drawing(widget);
|
||||
if (dc == RT_NULL) return RT_FALSE; /* 如果获取失败代表什么?这个控件是隐藏的或... */
|
||||
rtgui_widget_get_rect(widget, &rect); /* 获得控件的可视区域 */
|
||||
|
||||
/* 先对所在可视区域全部填充为背景色 */
|
||||
rtgui_dc_fill_rect(dc, &rect);
|
||||
|
||||
/* 绘制一个hello! */
|
||||
rtgui_dc_draw_text(dc, "hello world", &rect);
|
||||
|
||||
/* 通知RTGUI,绘制结束 */
|
||||
rtgui_dc_end_drawing(dc);
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
/* 如果不是绘制事件,使用view原来的事件处理函数处理 */
|
||||
return rtgui_view_event_handler(widget, event);
|
||||
}
|
||||
|
||||
static void workbench_entry(void* parameter)
|
||||
{
|
||||
rt_mq_t mq;
|
||||
struct rtgui_view* view;
|
||||
struct rtgui_workbench* workbench;
|
||||
|
||||
/* 创建GUI应用需要的消息队列 */
|
||||
mq = rt_mq_create("qWB", 256, 4, RT_IPC_FLAG_FIFO);
|
||||
/* 注册当前线程为GUI线程 */
|
||||
rtgui_thread_register(rt_thread_self(), mq);
|
||||
|
||||
/* 创建一个工作台 */
|
||||
workbench = rtgui_workbench_create("main", "workbench");
|
||||
if (workbench == RT_NULL) return;
|
||||
|
||||
/* 创建一个工作台上的一个视图 */
|
||||
view = rtgui_view_create("view");
|
||||
rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);
|
||||
|
||||
/* 在工作台上添加一个视图 */
|
||||
rtgui_workbench_add_view(workbench, view);
|
||||
|
||||
/* 显示这个视图 */
|
||||
rtgui_view_show(view);
|
||||
|
||||
/* 执行工作台事件循环 */
|
||||
rtgui_workbench_event_loop(workbench);
|
||||
|
||||
/* 去注册GUI线程 */
|
||||
rtgui_thread_deregister(rt_thread_self());
|
||||
rt_mq_delete(mq);
|
||||
}
|
||||
|
||||
void workbench_init()
|
||||
{
|
||||
static rt_bool_t inited = RT_FALSE;
|
||||
|
||||
if (inited == RT_FALSE) /* 避免重复初始化而做的保护 */
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("wb",
|
||||
workbench_entry, RT_NULL,
|
||||
2048, 25, 10);
|
||||
|
||||
if (tid != RT_NULL) rt_thread_startup(tid);
|
||||
|
||||
inited = RT_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RT_USING_RTGUI
|
||||
#include <finsh.h>
|
||||
void workbench()
|
||||
{
|
||||
workbench_init();
|
||||
}
|
||||
/* finsh的命令输出,可以直接执行workbench()函数以执行上面的函数 */
|
||||
FINSH_FUNCTION_EXPORT(workbench, workbench demo)
|
||||
#endif
|
||||
@@ -167,7 +167,7 @@ void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtg
|
||||
dc->blit(dc, dc_point, dest, rect);
|
||||
}
|
||||
|
||||
void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtgui_rect* rect)
|
||||
void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect)
|
||||
{
|
||||
rt_uint32_t len;
|
||||
struct rtgui_font *font;
|
||||
|
||||
@@ -120,7 +120,7 @@ void rtgui_font_derefer(struct rtgui_font* font)
|
||||
}
|
||||
|
||||
/* draw a text */
|
||||
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
|
||||
@@ -131,7 +131,7 @@ void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint
|
||||
}
|
||||
}
|
||||
|
||||
int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text)
|
||||
int rtgui_font_get_string_width(struct rtgui_font* font, const char* text)
|
||||
{
|
||||
rtgui_rect_t rect;
|
||||
|
||||
@@ -141,7 +141,7 @@ int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text)
|
||||
return rect.x2 - rect.x1;
|
||||
}
|
||||
|
||||
void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
|
||||
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
|
||||
@@ -157,8 +157,8 @@ void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtg
|
||||
}
|
||||
}
|
||||
|
||||
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect);
|
||||
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
|
||||
struct rtgui_font_engine bmp_font_engine =
|
||||
{
|
||||
RT_NULL,
|
||||
@@ -197,7 +197,7 @@ void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap* font, struct rtgui_dc
|
||||
}
|
||||
}
|
||||
|
||||
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
|
||||
|
||||
@@ -213,7 +213,7 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc
|
||||
}
|
||||
}
|
||||
|
||||
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
|
||||
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#ifdef RTGUI_USING_HZ_BMP
|
||||
|
||||
static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect);
|
||||
static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
|
||||
struct rtgui_font_engine hz_bmp_font_engine =
|
||||
{
|
||||
RT_NULL,
|
||||
@@ -14,7 +14,7 @@ struct rtgui_font_engine hz_bmp_font_engine =
|
||||
rtgui_hz_bitmap_font_get_metrics
|
||||
};
|
||||
|
||||
static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
rt_base_t h;
|
||||
rt_uint8_t* str;
|
||||
@@ -61,7 +61,7 @@ static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui
|
||||
}
|
||||
}
|
||||
|
||||
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
|
||||
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
static int _font_cache_compare(struct hz_cache* node1, struct hz_cache* node2);
|
||||
|
||||
static void rtgui_hz_file_font_load(struct rtgui_font* font);
|
||||
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect);
|
||||
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
|
||||
struct rtgui_font_engine rtgui_hz_file_font_engine =
|
||||
{
|
||||
RT_NULL,
|
||||
@@ -91,7 +91,7 @@ static void rtgui_hz_file_font_load(struct rtgui_font* font)
|
||||
hz_file_font->fd = open(hz_file_font->font_fn, O_RDONLY, 0);
|
||||
}
|
||||
|
||||
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
rt_base_t h;
|
||||
rt_uint8_t* str;
|
||||
@@ -133,7 +133,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
|
||||
}
|
||||
}
|
||||
|
||||
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
|
||||
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data;
|
||||
RT_ASSERT(hz_file_font != RT_NULL);
|
||||
|
||||
@@ -106,7 +106,7 @@ void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2);
|
||||
void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
|
||||
void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtgui_rect* rect);
|
||||
void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect);
|
||||
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
|
||||
void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ struct rtgui_font_engine
|
||||
void (*font_init)(struct rtgui_font* font);
|
||||
void (*font_load)(struct rtgui_font* font);
|
||||
|
||||
void (*font_draw_text)(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text,
|
||||
void (*font_draw_text)(struct rtgui_font* font, struct rtgui_dc* dc, const char* text,
|
||||
rt_ubase_t len, struct rtgui_rect* rect);
|
||||
void (*font_get_metrics)(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
|
||||
void (*font_get_metrics)(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -107,8 +107,8 @@ struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height
|
||||
void rtgui_font_derefer(struct rtgui_font* font);
|
||||
|
||||
/* draw a text */
|
||||
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text);
|
||||
void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
|
||||
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
int rtgui_font_get_string_width(struct rtgui_font* font, const char* text);
|
||||
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -62,8 +62,8 @@ typedef void (*rtgui_onbutton_func_t)(struct rtgui_widget* widget, rtgui_event_t
|
||||
|
||||
rtgui_type_t *rtgui_button_type_get(void);
|
||||
|
||||
rtgui_button_t* rtgui_button_create(unsigned char* text);
|
||||
rtgui_button_t* rtgui_pushbutton_create(unsigned char* text);
|
||||
rtgui_button_t* rtgui_button_create(char* text);
|
||||
rtgui_button_t* rtgui_pushbutton_create(char* text);
|
||||
void rtgui_button_destroy(rtgui_button_t* btn);
|
||||
|
||||
void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define RTGUI_FITEM_DIR 0x1
|
||||
struct rtgui_file_item
|
||||
{
|
||||
rt_uint8_t* name;
|
||||
char* name;
|
||||
|
||||
rt_uint32_t type;
|
||||
rt_uint32_t size;
|
||||
@@ -27,8 +27,8 @@ struct rtgui_filelist_view
|
||||
/* widget private data */
|
||||
|
||||
/* current directory */
|
||||
rt_uint8_t* current_directory;
|
||||
rt_uint8_t* pattern;
|
||||
char* current_directory;
|
||||
char* pattern;
|
||||
|
||||
/* the number of item in a page */
|
||||
rt_uint16_t page_items;
|
||||
|
||||
@@ -37,7 +37,7 @@ struct rtgui_iconbox
|
||||
/* widget private data */
|
||||
struct rtgui_image* image;
|
||||
|
||||
unsigned char *text;
|
||||
char *text;
|
||||
rt_ubase_t text_position;
|
||||
|
||||
rt_bool_t selected;
|
||||
@@ -46,7 +46,7 @@ typedef struct rtgui_iconbox rtgui_iconbox_t;
|
||||
|
||||
rtgui_type_t *rtgui_iconbox_type_get(void);
|
||||
|
||||
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const unsigned char* text, int position);
|
||||
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const char* text, int position);
|
||||
void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox);
|
||||
|
||||
rt_bool_t rtgui_iconbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
|
||||
@@ -32,18 +32,18 @@ struct rtgui_label
|
||||
struct rtgui_widget parent;
|
||||
|
||||
/* label */
|
||||
unsigned char* text;
|
||||
char* text;
|
||||
};
|
||||
typedef struct rtgui_label rtgui_label_t;
|
||||
|
||||
rtgui_type_t *rtgui_label_type_get(void);
|
||||
|
||||
rtgui_label_t* rtgui_label_create(const unsigned char* text);
|
||||
rtgui_label_t* rtgui_label_create(const char* text);
|
||||
void rtgui_label_destroy(rtgui_label_t* label);
|
||||
|
||||
rt_bool_t rtgui_label_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
|
||||
void rtgui_label_set_text(rtgui_label_t* label, const unsigned char* text);
|
||||
unsigned char* rtgui_label_get_text(rtgui_label_t* label);
|
||||
void rtgui_label_set_text(rtgui_label_t* label, const char* text);
|
||||
char* rtgui_label_get_text(rtgui_label_t* label);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ struct rtgui_list_view
|
||||
|
||||
/* widget private data */
|
||||
/* list item */
|
||||
struct rtgui_list_item* items;
|
||||
const struct rtgui_list_item* items;
|
||||
|
||||
/* total number of items */
|
||||
rt_uint16_t items_count;
|
||||
@@ -57,10 +57,13 @@ typedef struct rtgui_list_view rtgui_list_view_t;
|
||||
|
||||
rtgui_type_t *rtgui_list_view_type_get(void);
|
||||
|
||||
rtgui_list_view_t* rtgui_list_view_create(struct rtgui_list_item* items, rt_uint16_t count,
|
||||
rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count,
|
||||
rtgui_rect_t *rect);
|
||||
void rtgui_list_view_destroy(rtgui_list_view_t* view);
|
||||
|
||||
void rtgui_list_view_clear(rtgui_list_view_t* view);
|
||||
|
||||
rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
struct rtgui_textbox_line
|
||||
{
|
||||
rt_uint8_t* line_text;
|
||||
char* line_text;
|
||||
|
||||
struct rtgui_textbox_line *prev, *next;
|
||||
};
|
||||
@@ -51,7 +51,7 @@ struct rtgui_textbox
|
||||
/* current line and position */
|
||||
rt_uint16_t line, line_begin, position, line_length;
|
||||
|
||||
rt_uint8_t* text;
|
||||
char* text;
|
||||
rt_size_t font_width;
|
||||
|
||||
struct rtgui_timer* caret_timer;
|
||||
|
||||
@@ -28,18 +28,18 @@ struct rtgui_wintitle
|
||||
struct rtgui_toplevel parent;
|
||||
|
||||
/* title */
|
||||
rt_uint8_t* title;
|
||||
char* title;
|
||||
};
|
||||
typedef struct rtgui_wintitle rtgui_wintitle_t;
|
||||
|
||||
rtgui_type_t* rtgui_wintitle_type_get(void);
|
||||
|
||||
rtgui_wintitle_t* rtgui_wintitle_create(const rt_uint8_t* title);
|
||||
rtgui_wintitle_t* rtgui_wintitle_create(const char* title);
|
||||
void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle);
|
||||
|
||||
rt_bool_t rtgui_wintile_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
|
||||
|
||||
void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const rt_uint8_t* title);
|
||||
rt_uint8_t *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle);
|
||||
void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const char* title);
|
||||
char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -188,7 +188,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
rtgui_button_t* rtgui_button_create(unsigned char* text)
|
||||
rtgui_button_t* rtgui_button_create(char* text)
|
||||
{
|
||||
struct rtgui_button* btn;
|
||||
|
||||
@@ -208,7 +208,7 @@ rtgui_button_t* rtgui_button_create(unsigned char* text)
|
||||
return btn;
|
||||
}
|
||||
|
||||
rtgui_button_t* rtgui_pushbutton_create(unsigned char* text)
|
||||
rtgui_button_t* rtgui_pushbutton_create(char* text)
|
||||
{
|
||||
rtgui_button_t* btn;
|
||||
|
||||
|
||||
@@ -219,7 +219,6 @@ const static char * folder_xpm[] = {
|
||||
|
||||
/* image for file and folder */
|
||||
static rtgui_image_t *file_image, *folder_image;
|
||||
static struct rtgui_filelist_view *filelist_view = RT_NULL; /* only one view in global */
|
||||
|
||||
static void _rtgui_filelist_view_constructor(struct rtgui_filelist_view *view)
|
||||
{
|
||||
@@ -489,7 +488,7 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct
|
||||
if (strcmp(view->items[view->current_item].name, ".") == 0) return RT_FALSE;
|
||||
if (strcmp(view->items[view->current_item].name, "..") == 0)
|
||||
{
|
||||
rt_uint8_t *ptr;
|
||||
char *ptr;
|
||||
ptr = strrchr(view->current_directory, PATH_SEPARATOR);
|
||||
|
||||
if (ptr == RT_NULL) return RT_FALSE;
|
||||
@@ -526,11 +525,11 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct
|
||||
else
|
||||
{
|
||||
if (view->current_directory[strlen(view->current_directory) - 1] != PATH_SEPARATOR)
|
||||
sprintf(new_path, "%s%c%s",view->current_directory, PATH_SEPARATOR,
|
||||
rt_snprintf(new_path, sizeof(new_path), "%s%c%s",view->current_directory, PATH_SEPARATOR,
|
||||
view->items[view->current_item].name);
|
||||
else
|
||||
sprintf(new_path, "%s%s",view->current_directory,
|
||||
view->items[view->current_item].name);
|
||||
rt_snprintf(new_path, sizeof(new_path), "%s%s",view->current_directory,
|
||||
view->items[view->current_item].name);
|
||||
}
|
||||
rtgui_filelist_view_set_directory(view, new_path);
|
||||
}
|
||||
@@ -616,7 +615,7 @@ void rtgui_filelist_view_clear(rtgui_filelist_view_t* view)
|
||||
|
||||
void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory)
|
||||
{
|
||||
rt_uint8_t fullpath[256];
|
||||
char fullpath[256];
|
||||
struct rtgui_file_item *item;
|
||||
|
||||
RT_ASSERT(view != RT_NULL);
|
||||
@@ -693,9 +692,9 @@ void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char*
|
||||
|
||||
/* build full path for the file */
|
||||
if (directory[strlen(directory) - 1] != PATH_SEPARATOR)
|
||||
sprintf(fullpath, "%s%c%s", directory, PATH_SEPARATOR, dirent->d_name);
|
||||
rt_sprintf(fullpath, "%s%c%s", directory, PATH_SEPARATOR, dirent->d_name);
|
||||
else
|
||||
sprintf(fullpath, "%s%s", directory, dirent->d_name);
|
||||
rt_sprintf(fullpath, "%s%s", directory, dirent->d_name);
|
||||
|
||||
stat(fullpath, &s);
|
||||
if ( s.st_mode & S_IFDIR )
|
||||
@@ -726,4 +725,4 @@ void rtgui_filelist_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_siz
|
||||
|
||||
rt_sprintf(path, "%s%c%s", view->current_directory, PATH_SEPARATOR,
|
||||
view->items[view->current_item].name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ rt_bool_t rtgui_iconbox_event_handler(struct rtgui_widget* widget, struct rtgui_
|
||||
}
|
||||
|
||||
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image,
|
||||
const unsigned char* text,
|
||||
const char* text,
|
||||
int position)
|
||||
{
|
||||
struct rtgui_iconbox* iconbox;
|
||||
@@ -115,7 +115,7 @@ struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image,
|
||||
|
||||
/* set image and text position */
|
||||
iconbox->image = image;
|
||||
iconbox->text = (unsigned char*)rt_strdup((const char*)text);
|
||||
iconbox->text = (char*)rt_strdup((const char*)text);
|
||||
iconbox->text_position = position;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ rt_bool_t rtgui_label_event_handler(struct rtgui_widget* widget, struct rtgui_ev
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
rtgui_label_t* rtgui_label_create(const unsigned char* text)
|
||||
rtgui_label_t* rtgui_label_create(const char* text)
|
||||
{
|
||||
struct rtgui_label* label;
|
||||
|
||||
@@ -80,7 +80,7 @@ rtgui_label_t* rtgui_label_create(const unsigned char* text)
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
|
||||
/* set text */
|
||||
label->text = (unsigned char*)rt_strdup((const char*)text);
|
||||
label->text = (char*)rt_strdup((const char*)text);
|
||||
}
|
||||
|
||||
return label;
|
||||
@@ -91,14 +91,14 @@ void rtgui_label_destroy(rtgui_label_t* label)
|
||||
rtgui_widget_destroy(RTGUI_WIDGET(label));
|
||||
}
|
||||
|
||||
unsigned char* rtgui_label_get_text(rtgui_label_t* label)
|
||||
char* rtgui_label_get_text(rtgui_label_t* label)
|
||||
{
|
||||
RT_ASSERT(label != RT_NULL);
|
||||
|
||||
return label->text;
|
||||
}
|
||||
|
||||
void rtgui_label_set_text(rtgui_label_t* label, const unsigned char* text)
|
||||
void rtgui_label_set_text(rtgui_label_t* label, const char* text)
|
||||
{
|
||||
RT_ASSERT(label != RT_NULL);
|
||||
|
||||
@@ -108,7 +108,7 @@ void rtgui_label_set_text(rtgui_label_t* label, const unsigned char* text)
|
||||
rt_free(label->text);
|
||||
}
|
||||
|
||||
if (text != RT_NULL) label->text = (unsigned char*)rt_strdup((const char*)text);
|
||||
if (text != RT_NULL) label->text = (char*)rt_strdup((const char*)text);
|
||||
else label->text = RT_NULL;
|
||||
|
||||
/* update widget */
|
||||
|
||||
@@ -54,7 +54,7 @@ void rtgui_list_view_ondraw(struct rtgui_list_view* view)
|
||||
struct rtgui_rect rect, item_rect;
|
||||
struct rtgui_dc* dc;
|
||||
rt_uint16_t page_index, index;
|
||||
struct rtgui_list_item* item;
|
||||
const struct rtgui_list_item* item;
|
||||
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
|
||||
if (dc == RT_NULL) return;
|
||||
@@ -103,7 +103,7 @@ void rtgui_list_view_ondraw(struct rtgui_list_view* view)
|
||||
void rtgui_list_view_update_current(struct rtgui_list_view* view, rt_uint16_t old_item)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
struct rtgui_list_item* item;
|
||||
const struct rtgui_list_item* item;
|
||||
rtgui_rect_t rect, item_rect;
|
||||
|
||||
if (old_item/view->page_items != view->current_item/view->page_items)
|
||||
@@ -267,7 +267,7 @@ rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgu
|
||||
return rtgui_view_event_handler(widget, event);
|
||||
}
|
||||
|
||||
rtgui_list_view_t* rtgui_list_view_create(struct rtgui_list_item* items, rt_uint16_t count, rtgui_rect_t *rect)
|
||||
rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count, rtgui_rect_t *rect)
|
||||
{
|
||||
struct rtgui_list_view* view = RT_NULL;
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ static void rtgui_textbox_onkey(struct rtgui_textbox* box, struct rtgui_event_kb
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *c;
|
||||
char *c;
|
||||
|
||||
/* remove character */
|
||||
for (c = &box->text[box->position]; c[1] != '\0'; c++)
|
||||
@@ -176,7 +176,7 @@ static void rtgui_textbox_onkey(struct rtgui_textbox* box, struct rtgui_event_kb
|
||||
/* remove current character */
|
||||
if (box->position != 0)
|
||||
{
|
||||
unsigned char *c;
|
||||
char *c;
|
||||
|
||||
/* remove character */
|
||||
for (c = &box->text[box->position - 1]; c[1] != '\0'; c++)
|
||||
@@ -218,7 +218,7 @@ static void rtgui_textbox_onkey(struct rtgui_textbox* box, struct rtgui_event_kb
|
||||
|
||||
if (box->position < length - 1)
|
||||
{
|
||||
unsigned char* c;
|
||||
char* c;
|
||||
|
||||
for (c = &box->text[length]; c != &box->text[box->position]; c--)
|
||||
*c = *(c-1);
|
||||
|
||||
@@ -43,7 +43,7 @@ rtgui_type_t* rtgui_wintitle_type_get()
|
||||
return wintitle_type;
|
||||
}
|
||||
|
||||
rtgui_wintitle_t* rtgui_wintitle_create(const rt_uint8_t* title)
|
||||
rtgui_wintitle_t* rtgui_wintitle_create(const char* title)
|
||||
{
|
||||
rtgui_wintitle_t* wintitle;
|
||||
|
||||
@@ -61,7 +61,7 @@ void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle)
|
||||
rtgui_widget_destroy(RTGUI_WIDGET(wintitle));
|
||||
}
|
||||
|
||||
void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const rt_uint8_t* title)
|
||||
void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const char* title)
|
||||
{
|
||||
RT_ASSERT(wintitle != RT_NULL);
|
||||
|
||||
@@ -70,11 +70,11 @@ void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const rt_uint8_t* titl
|
||||
rtgui_free(wintitle->title);
|
||||
}
|
||||
|
||||
if (title != RT_NULL) wintitle->title = (unsigned char*)rt_strdup((const char*)title);
|
||||
if (title != RT_NULL) wintitle->title = (char*)rt_strdup((const char*)title);
|
||||
else wintitle->title = RT_NULL;
|
||||
}
|
||||
|
||||
rt_uint8_t *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle)
|
||||
char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle)
|
||||
{
|
||||
RT_ASSERT(wintitle != RT_NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user