refactor widgets

This commit is contained in:
idea4good 2019-07-03 16:45:58 +08:00
parent a9f16894e1
commit 108da59727
36 changed files with 359 additions and 510 deletions

View File

@ -1,4 +1,4 @@
# GuiLite - All donations will be used to help sick kids
# GuiLite - The smallest GUI library
![badge_build](https://img.shields.io/badge/build-passing-brightgreen.svg) ![badge_docker](https://img.shields.io/badge/docker%20build-passing-brightgreen.svg) ![badge_platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS%20%7C%20iOS%20%7C%20Android%20%7C%20MCU-brightgreen.svg) ![badge_lincense](https://img.shields.io/badge/license-Apache%202-blue.svg) ![badge_lincense](https://img.shields.io/badge/architecture-amd64%20%7C%20arm%20%7C%20arm64-blue.svg)
- [中文](README_zh.md)
- [Features](#Features)
@ -106,5 +106,4 @@ GuiLite is the smallest and simplest GUI library.
## Thanks and Charity
- Thanks for the help from QQ group, you guys make GuiLite better! And welcome new friend to join us.<br>[<img src="doc/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
- Thanks for the donations from [Gitee users](https://gitee.com/idea4good/GuiLite), all donations will be used to help sick kids
- Check the charity action [here](doc/CharityTracker.md)
- [Sponsor & Help sick kids](https://idea4good.github.io)

View File

@ -1,4 +1,4 @@
# GuiLite超轻量UI框架 - 所有捐赠都用于救助“大病”儿童
# GuiLite超轻量UI框架 - 最小的GUI库
![badge_build](https://img.shields.io/badge/build-passing-brightgreen.svg) ![badge_docker](https://img.shields.io/badge/docker%20build-passing-brightgreen.svg) ![badge_platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS%20%7C%20iOS%20%7C%20Android%20%7C%20MCU-brightgreen.svg) ![badge_lincense](https://img.shields.io/badge/license-Apache%202-blue.svg) ![badge_lincense](https://img.shields.io/badge/architecture-amd64%20%7C%20arm%20%7C%20arm64-blue.svg)
- [功能介绍](#功能介绍)
- [快速上手](#快速上手)
@ -105,5 +105,4 @@ GuiLite是最简单易学的GUI库。
## 致谢和慈善
- 感谢开发者群的所有同学是你们塑造了今天的GuiLite也欢迎新的大神/小白加入我们。<br>[<img src="doc/qq.group.jpg">](https://jq.qq.com/?_wv=1027&k=5EO8D9i)
- 感谢来自[码云用户](https://gitee.com/idea4good/GuiLite)的捐赠,每一分捐赠都会用来救助大病儿童。
- [大病儿童帮扶记录](doc/CharityTracker.md)
- [赞助 & 救助大病儿童](https://idea4good.github.io)

View File

@ -129,7 +129,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg
if(i >= MAX_TIMER_CNT)
{
ASSERT(FALSE);
ASSERT(false);
return (-1);
}
return (i);
@ -150,7 +150,7 @@ static void* real_timer_routine(void*)
}
else
{
ASSERT(FALSE);
ASSERT(false);
}
}
return 0;
@ -161,7 +161,7 @@ static void expire_real_timer(int sigo)
char dummy = 0x33;
if(s_real_timer_fifo.write(&dummy, 1) <= 0)
{
ASSERT(FALSE);
ASSERT(false);
}
}

View File

@ -30,7 +30,7 @@ void _assert(const char* file, int line)
memset(s_buf, 0, sizeof(s_buf));
sprintf_s(s_buf, sizeof(s_buf), "vvvvvvvvvvvvvvvvvvvvvvvvvvvv\n\nAssert@ file = %s, line = %d\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", file, line);
OutputDebugStringA(s_buf);
printf(s_buf);
printf(s_buf);
fflush(stdout);
assert(false);
}
@ -44,8 +44,8 @@ void log_out(const char* log)
}
else
{
printf(log);
fflush(stdout);
printf(log);
fflush(stdout);
OutputDebugStringA(log);
}
}
@ -85,7 +85,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam)
}
Sleep(TIMER_UNIT);
}
return NULL;
return 0;
}
static int init_mul_timer()
@ -97,7 +97,7 @@ static int init_mul_timer()
}
memset(&timer_manage, 0, sizeof(struct _timer_manage));
DWORD pid;
CreateThread(NULL, 0, timer_routine, NULL, 0, &pid);
CreateThread(0, 0, timer_routine, 0, 0, &pid);
s_is_init = true;
return 1;
}
@ -107,7 +107,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg
init_mul_timer();
int i;
if(timer_proc == NULL || interval <= 0)
if(timer_proc == 0 || interval <= 0)
{
return (-1);
}
@ -128,7 +128,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg
if(i >= MAX_TIMER_CNT)
{
ASSERT(FALSE);
ASSERT(false);
return (-1);
}
return (i);
@ -149,7 +149,7 @@ static DWORD WINAPI fire_real_timer(LPVOID lpParam)
}
else
{
ASSERT(FALSE);
ASSERT(false);
}
}
return 0;
@ -176,7 +176,7 @@ static DWORD WINAPI trigger_real_timer(LPVOID lpParam)
void start_real_timer(void (*func)(void* arg))
{
if(NULL == func)
if(0 == func)
{
return;
}
@ -187,8 +187,8 @@ void start_real_timer(void (*func)(void* arg))
static DWORD s_pid;
if(s_pid == 0)
{
CreateThread(NULL, 0, trigger_real_timer, NULL, 0, &s_pid);
CreateThread(NULL, 0, fire_real_timer, NULL, 0, &s_pid);
CreateThread(0, 0, trigger_real_timer, 0, 0, &s_pid);
CreateThread(0, 0, fire_real_timer, 0, 0, &s_pid);
}
}
@ -204,7 +204,7 @@ void register_timer(int milli_second,void func(void* ptmr, void* parg))
long get_time_in_second()
{
return time(NULL);
return time(0);
}
T_TIME get_time()
@ -240,7 +240,7 @@ T_TIME second_to_day(long second)
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg)
{
DWORD pid = 0;
CreateThread(NULL, 0, LPTHREAD_START_ROUTINE(start_routine), arg, 0, &pid);
CreateThread(0, 0, LPTHREAD_START_ROUTINE(start_routine), arg, 0, &pid);
*thread_id = pid;
}

View File

@ -44,7 +44,7 @@ void c_audio::init()
}
unsigned long pid;
create_thread(&pid, NULL, render_thread, NULL);
create_thread(&pid, 0, render_thread, 0);
s_flag = true;
}

View File

@ -16,7 +16,7 @@
#define AUDIO_BYTE_RATE (AUDIO_SAMPLE_RATE * AUDIO_BLOCK_ALIGN)
#define AUDIO_OUTPUT_BUF_LEN (10000000 * 5) //5 seconds long.
#define CHECK_ERROR(ret) if(ret != 0){ASSERT(FALSE);}
#define CHECK_ERROR(ret) if(ret != 0){ASSERT(false);}
typedef struct
{
@ -58,7 +58,7 @@ static int register_wav_resouce(AUDIO_TYPE type, wchar_t* wav_path)
return 0;
}
void* hFile = CreateFile(wav_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
void* hFile = CreateFile(wav_path, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (INVALID_HANDLE_VALUE == hFile)
{
log_out("Open wave file failed\n");
@ -69,16 +69,16 @@ static int register_wav_resouce(AUDIO_TYPE type, wchar_t* wav_path)
GetFileSizeEx(hFile, &ret);
int size = ret.LowPart;
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, 0x2C, NULL, FILE_BEGIN))
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, 0x2C, 0, FILE_BEGIN))
{
ASSERT(FALSE);
ASSERT(false);
return -2;
}
size -= 0x2C;
BYTE* p_data = (BYTE*)malloc(size);
DWORD read_num;
ReadFile(hFile, p_data, size, &read_num, NULL);
ReadFile(hFile, p_data, size, &read_num, 0);
s_wav_resource[type].p_data = p_data;
s_wav_resource[type].size = size;
@ -100,7 +100,7 @@ static int load_wav_chunk(BYTE* p_des, int des_size, BYTE* p_src, int src_size)
static int play_wav(BYTE* p_data, int size)
{
if (NULL == p_data || 0 >= size)
if (0 == p_data || 0 >= size)
{
return -1;
}
@ -108,7 +108,7 @@ static int play_wav(BYTE* p_data, int size)
UINT32 bufferFrameCount;
UINT32 numFramesAvailable;
UINT32 numFramesPadding;
BYTE* p_buffer = NULL;
BYTE* p_buffer = 0;
int ret = s_audio_client->GetBufferSize(&bufferFrameCount);
CHECK_ERROR(ret);
@ -154,7 +154,7 @@ static void* render_thread(void* param)
if (AUDIO_MAX <= request.type)
{
ASSERT(FALSE);
ASSERT(false);
continue;
}
play_wav(s_wav_resource[request.type].p_data, s_wav_resource[request.type].size);
@ -171,23 +171,23 @@ static int init_audio_client()
//For desktop only, could not pass Windows Store certification.
/*
int ret = CoInitializeEx(NULL, COINIT_MULTITHREADED);
int ret = CoInitializeEx(0, COINIT_MULTITHREADED);
CHECK_ERROR(ret);
IMMDeviceEnumerator *pEnumerator = nullptr;
ret = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL,
ret = CoCreateInstance(__uuidof(MMDeviceEnumerator), 0,
CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),
(void**)&pEnumerator);
CHECK_ERROR(ret);
IMMDevice* audio_output_device;
pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &audio_output_device);
if (NULL == audio_output_device)
if (0 == audio_output_device)
{
ASSERT(FALSE);
ASSERT(false);
}
ret = audio_output_device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&s_audio_client);
ret = audio_output_device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, 0, (void**)&s_audio_client);
CHECK_ERROR(ret);
return 0;
*/
@ -211,10 +211,10 @@ void c_audio::init()
int ret = s_audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
AUDIO_OUTPUT_BUF_LEN * 2, 0, &s_wav_format, NULL);
AUDIO_OUTPUT_BUF_LEN * 2, 0, &s_wav_format, 0);
CHECK_ERROR(ret);
s_audio_event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
s_audio_event = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS);
ret = s_audio_client->SetEventHandle(s_audio_event);
CHECK_ERROR(ret);
@ -222,7 +222,7 @@ void c_audio::init()
CHECK_ERROR(ret);
unsigned long pid;
create_thread(&pid, NULL, render_thread, NULL);
create_thread(&pid, 0, render_thread, 0);
s_flag = true;
}

View File

@ -11,7 +11,7 @@ c_fifo::c_fifo()
m_write_mutex = malloc(sizeof(pthread_mutex_t));
sem_init((sem_t*)m_read_sem, 0, 0);
pthread_mutex_init((pthread_mutex_t*)m_write_mutex, NULL);
pthread_mutex_init((pthread_mutex_t*)m_write_mutex, 0);
}
int c_fifo::read(void* buf, int len)
@ -31,7 +31,7 @@ int c_fifo::read(void* buf, int len)
}
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
return i;
}
@ -60,7 +60,7 @@ int c_fifo::write(void* buf, int len)
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
else
{

View File

@ -1,11 +1,10 @@
#include "../../core_include/api.h"
#include "../../core_include/msg.h"
c_fifo::c_fifo()
{
m_head = m_tail = 0;
m_read_sem = m_write_mutex = NULL;
m_read_sem = m_write_mutex = 0;
}
int c_fifo::read(void* buf, int len)
@ -24,7 +23,7 @@ int c_fifo::read(void* buf, int len)
}
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
return i;
}
@ -50,7 +49,7 @@ int c_fifo::write(void* buf, int len)
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
return i;
}

View File

@ -5,11 +5,11 @@
c_fifo::c_fifo()
{
m_head = m_tail = 0;
m_read_sem = CreateSemaphore(NULL, // default security attributes
m_read_sem = CreateSemaphore(0, // default security attributes
0, // initial count
1, // maximum count
NULL); // unnamed semaphore
m_write_mutex = CreateMutex(NULL, FALSE, NULL);
0); // unnamed semaphore
m_write_mutex = CreateMutex(0, false, 0);
}
int c_fifo::read(void* buf, int len)
@ -29,7 +29,7 @@ int c_fifo::read(void* buf, int len)
}
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
return i;
}
@ -58,11 +58,11 @@ int c_fifo::write(void* buf, int len)
if(i != len)
{
ASSERT(FALSE);
ASSERT(false);
}
else
{
ReleaseSemaphore(m_read_sem, 1, NULL);
ReleaseSemaphore(m_read_sem, 1, 0);
}
return i;
}

View File

@ -6,125 +6,60 @@
void c_bitmap::draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, int x, int y, unsigned int mask_rgb)
{
if (0 == pBitmap) { return; }
draw_bitmap_565(surface, z_order, x, y, pBitmap->XSize, pBitmap->YSize,
(unsigned char const *)pBitmap->pData, mask_rgb);
}
void c_bitmap::draw_bitmap_in_rect(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, unsigned int mask_rgb)
{
if (0 == pBitmap) { return; }
int x, y;
get_bitmap_pos(pBitmap, rect, align_type, x, y);
draw_bitmap_565_in_rect(surface, z_order, rect.m_left + x, rect.m_top + y,
(rect.m_right - rect.m_left + 1), (rect.m_bottom - rect.m_top + 1),
pBitmap->XSize, pBitmap->YSize, (unsigned char const *)pBitmap->pData, mask_rgb);
}
void c_bitmap::get_bitmap_pos(const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, int &x, int &y)
{
int x_size = pBitmap->XSize;
int y_size = pBitmap->YSize;
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;
x = y = 0;
switch (align_type & ALIGN_HMASK)
if (0 == pBitmap)
{
case ALIGN_HCENTER:
if (width > x_size)
{
x = (width - x_size)/2;
}
break;
case ALIGN_LEFT:
x = 0;
break;
case ALIGN_RIGHT:
if (width > x_size)
{
x = width - x_size;
}
break;
default:
ASSERT(0);
break;
return;
}
switch (align_type & ALIGN_VMASK)
{
case ALIGN_VCENTER:
if (height > y_size)
{
y = (height - y_size)/2;
}
break;
case ALIGN_TOP:
y = 0;
break;
case ALIGN_BOTTOM:
if (height > y_size)
{
y = height - y_size;
}
break;
default:
ASSERT(0);
break;
}
}
void c_bitmap::draw_bitmap_565(c_surface* surface, int z_order, int x, int y, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_rgb)
{
unsigned short* lower_fb = NULL;
unsigned short* lower_fb = 0;
int lower_fb_width = surface->m_width;
if (z_order >= Z_ORDER_LEVEL_1)
{
lower_fb = surface->m_frame_layers[z_order - 1].fb;
if (z_order >= Z_ORDER_LEVEL_1)
{
lower_fb = surface->m_frame_layers[z_order - 1].fb;
}
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
const unsigned short* pData = (const unsigned short*)pPixel;
for (int j = 0; j < ysize; j++)
int xsize = pBitmap->XSize;
int ysize = pBitmap->YSize;
const unsigned short* pData = (const unsigned short*)pBitmap->pData;
for (int j = 0; j < ysize; j++)
{
const unsigned short * p = pData;
for (int i = 0; i < xsize; i++)
for (int i = 0; i < xsize; i++)
{
unsigned int rgb = *p++;
unsigned int rgb = *pData++;
if (mask_rgb_16 == rgb)
{
if (lower_fb)
{//restore lower layer
surface->draw_pixel(x + i, y + j, GL_RGB_16_to_32(lower_fb[(y + j) * lower_fb_width + x + i]), z_order);
}
}
}
else
{
surface->draw_pixel(x + i, y + j, GL_RGB_16_to_32(rgb), z_order);
}
}
pData += xsize;
}
}
void c_bitmap::draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, int y, int width, int height, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_rgb)
void c_bitmap::draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO* pBitmap, int x, int y, int src_x, int src_y, int width, int height, unsigned int mask_rgb)
{
unsigned short* lower_fb = NULL;
if (0 == pBitmap || (src_x + width > pBitmap->XSize) || (src_y + height > pBitmap->XSize))
{
return;
}
unsigned short* lower_fb = 0;
int lower_fb_width = surface->m_width;
if (z_order >= Z_ORDER_LEVEL_1)
{
lower_fb = surface->m_frame_layers[z_order - 1].fb;
if (z_order >= Z_ORDER_LEVEL_1)
{
lower_fb = surface->m_frame_layers[z_order - 1].fb;
}
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
const unsigned short* pData = (const unsigned short*)pPixel;
for (int j = 0; j < ysize; j++)
const unsigned short* pData = (const unsigned short*)pBitmap->pData;
for (int j = 0; j < height; j++)
{
if (j >= height) { break; }
const unsigned short * p = pData;
for (int i = 0; i < xsize; i++)
const unsigned short* p = &pData[src_x + (src_y + j) * pBitmap->XSize];
for (int i = 0; i < width; i++)
{
if (i >= width) { break; }
unsigned int rgb = *p++;
if (mask_rgb_16 == rgb)
{
@ -138,6 +73,5 @@ void c_bitmap::draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, i
surface->draw_pixel(x + i, y + j, GL_RGB_16_to_32(rgb), z_order);
}
}
pData += xsize;
}
}

View File

@ -49,7 +49,7 @@ void c_cmd_target::load_cmd_msg()
continue;
}
bExist = FALSE;
bExist = false;
for (int i = 0; i < ms_user_map_size; i++)
{
//repeat register, return.
@ -60,7 +60,7 @@ void c_cmd_target::load_cmd_msg()
break;
}
}
if (TRUE == bExist)
if (true == bExist)
{
p_entry++;
continue;
@ -73,12 +73,12 @@ void c_cmd_target::load_cmd_msg()
ms_user_map_size++;
if (USR_MSG_MAX == ms_user_map_size)
{
ASSERT(FALSE);
ASSERT(false);
}
}
else
{
ASSERT(FALSE);
ASSERT(false);
break;
}
p_entry++;

View File

@ -15,7 +15,7 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
if (color_bytes != 2 && color_bytes != 4)
{
log_out("Support 16 bits, 32 bits color only!");
ASSERT(FALSE);
ASSERT(false);
}
m_width = display_width;
@ -43,7 +43,7 @@ c_surface* c_display::alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder)
if (m_surface_group[i]->m_usr == usr)
{
//repeat register
ASSERT(FALSE);
ASSERT(false);
return m_surface_group[i];
}
i++;
@ -52,7 +52,7 @@ c_surface* c_display::alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder)
i = 0;
while (i < m_surface_cnt)
{
if (m_surface_group[i]->m_usr == NULL)
if (m_surface_group[i]->m_usr == 0)
{
m_surface_group[i]->set_surface(usr, max_zorder);
return m_surface_group[i];
@ -60,8 +60,8 @@ c_surface* c_display::alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder)
i++;
}
//no surface for use
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
@ -72,14 +72,14 @@ int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y
if (offset < 0 || offset > surface_width || y0 < 0 || y0 >= surface_height ||
y1 < 0 || y1 >= surface_height || x0 < 0 || x0 >= surface_width || x1 < 0 || x1 >= surface_width)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
int width = (x1 - x0 + 1);
if (width < 0 || width > surface_width || width < offset)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
@ -148,13 +148,13 @@ void* c_display::get_updated_fb(int* width, int* height, bool force_update)
*width = get_width();
*height = get_height();
}
if (force_update)
{
return m_phy_fb;
if (force_update)
{
return m_phy_fb;
}
if (m_phy_read_index == m_phy_write_index)
{//No update
return NULL;
return 0;
}
m_phy_read_index = m_phy_write_index;
return m_phy_fb;

View File

@ -18,7 +18,7 @@ c_surface::c_surface(c_display* display, unsigned int width, unsigned int heigh
m_display = display;
m_phy_fb = display->m_phy_fb;
m_phy_write_index = &display->m_phy_write_index;
m_fb = m_usr = NULL;
m_fb = m_usr = 0;
m_top_zorder = m_max_zorder = Z_ORDER_LEVEL_0;
m_is_active = false;
m_frame_layers[Z_ORDER_LEVEL_0].rect = c_rect(0, 0, m_width, m_height);
@ -35,9 +35,9 @@ void c_surface::set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order)
}
for(int i = Z_ORDER_LEVEL_0; i < m_max_zorder; i++)
{//Top layber fb always be NULL
{//Top layber fb always be 0
m_frame_layers[i].fb = (unsigned short*)calloc(m_width * m_height, sizeof(unsigned short));
ASSERT(NULL != m_frame_layers[i].fb);
ASSERT(0 != m_frame_layers[i].fb);
}
}
@ -49,7 +49,7 @@ void c_surface::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
}
if (z_order > m_max_zorder)
{
ASSERT(FALSE);
ASSERT(false);
return;
}
rgb = GL_ROUND_RGB_32(rgb);
@ -65,7 +65,7 @@ void c_surface::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
if (0 == m_frame_layers[z_order].rect.PtInRect(x, y))
{
ASSERT(FALSE);
ASSERT(false);
return;
}
((unsigned short*)(m_frame_layers[z_order].fb))[x + y * m_width] = GL_RGB_32_to_16(rgb);
@ -78,7 +78,7 @@ void c_surface::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
bool is_covered = false;
for (int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--)
{
if (TRUE == m_frame_layers[tmp_z_order].rect.PtInRect(x, y))
if (true == m_frame_layers[tmp_z_order].rect.PtInRect(x, y))
{
is_covered = true;
break;
@ -150,7 +150,7 @@ void c_surface::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb
if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0 ||
x0 >= m_width || x1 >= m_width || y0 >= m_height || y1 >= m_height)
{
ASSERT(FALSE);
ASSERT(false);
}
int display_width = m_display->get_width();
int display_height = m_display->get_height();
@ -162,7 +162,7 @@ void c_surface::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb
for (; y0 <= y1; y0++)
{
x = x0;
fb = m_fb ? &((unsigned int*)m_fb)[y0 * m_width + x] : NULL;
fb = m_fb ? &((unsigned int*)m_fb)[y0 * m_width + x] : 0;
phy_fb = &((unsigned int*)m_phy_fb)[y0 * display_width + x];
*m_phy_write_index = *m_phy_write_index + 1;
for (; x <= x1; x++)
@ -186,7 +186,7 @@ void c_surface::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb
for (; y0 <= y1; y0++)
{
x = x0;
fb = m_fb ? &((unsigned short*)m_fb)[y0 * m_width + x] : NULL;
fb = m_fb ? &((unsigned short*)m_fb)[y0 * m_width + x] : 0;
phy_fb = &((unsigned short*)m_phy_fb)[y0 * display_width + x];
*m_phy_write_index = *m_phy_write_index + 1;
for (; x <= x1; x++)
@ -210,7 +210,7 @@ unsigned int c_surface::get_pixel(int x, int y, unsigned int z_order)
if (x >= m_width || y >= m_height || x < 0 || y < 0 ||
z_order >= Z_ORDER_LEVEL_MAX)
{
ASSERT(FALSE);
ASSERT(false);
return 0;
}
@ -345,12 +345,12 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
void c_surface::draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order, unsigned int size)
{
for (unsigned int offset = 0; offset < size; offset++)
{
for (unsigned int offset = 0; offset < size; offset++)
{
draw_hline(x0 + offset, x1 - offset, y0 + offset, rgb, z_order);
draw_hline(x0 + offset, x1 - offset, y1 - offset, rgb, z_order);
draw_vline(x0 + offset, y0 + offset, y1 - offset, rgb, z_order);
draw_vline(x1 - offset, y0 + offset, y1 - offset, rgb, z_order);
draw_vline(x1 - offset, y0 + offset, y1 - offset, rgb, z_order);
}
}
@ -360,22 +360,22 @@ int c_surface::set_frame_layer(c_rect& rect, unsigned int z_order)
{
return 0;
}
if (rect.m_left < 0 || rect.m_left >= m_width ||
rect.m_right < 0 || rect.m_right >= m_width ||
rect.m_top < 0 || rect.m_top >= m_height ||
rect.m_bottom < 0 || rect.m_bottom >=m_height)
{
ASSERT(FALSE);
return -1;
if (rect.m_left < 0 || rect.m_left >= m_width ||
rect.m_right < 0 || rect.m_right >= m_width ||
rect.m_top < 0 || rect.m_top >= m_height ||
rect.m_bottom < 0 || rect.m_bottom >=m_height)
{
ASSERT(false);
return -1;
}
if (!(z_order > Z_ORDER_LEVEL_0 && z_order < Z_ORDER_LEVEL_MAX))
{
ASSERT(FALSE);
ASSERT(false);
return -2;
}
if (z_order < m_top_zorder)
{
ASSERT(FALSE);
ASSERT(false);
return -3;
}
m_top_zorder = (Z_ORDER_LEVEL)z_order;
@ -411,7 +411,7 @@ int c_surface::flush_scrren(int left, int top, int right, int bottom)
if(left < 0 || left >= m_width || right < 0 || right >= m_width ||
top < 0 || top >= m_height || bottom < 0 || bottom >= m_height)
{
ASSERT(FALSE);
ASSERT(false);
}
if(!m_is_active || (0 == m_phy_fb) || (0 == m_fb))
@ -458,11 +458,11 @@ void c_surface_no_fb::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned i
{
return;
}
if (m_gfx_op->fill_rect)
{
return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb);
}
if (m_gfx_op->fill_rect)
{
return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb);
}
if (m_gfx_op->draw_pixel && m_is_active)
{
for (int y = y0; y <= y1; y++)
@ -474,9 +474,9 @@ void c_surface_no_fb::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned i
}
}
if (!m_fb) { return; }
if(m_color_bytes == 4)
{
if (!m_fb) { return; }
if(m_color_bytes == 4)
{
unsigned int *fb;
for (int y = y0; y <= y1; y++)
{
@ -485,7 +485,7 @@ void c_surface_no_fb::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned i
{
*fb++ = rgb;
}
}
}
}
else if (m_color_bytes == 2)
{
@ -504,9 +504,9 @@ void c_surface_no_fb::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned i
void c_surface_no_fb::draw_pixel_on_fb(int x, int y, unsigned int rgb)
{
if (m_gfx_op && m_gfx_op->draw_pixel && m_is_active)
if (m_gfx_op && m_gfx_op->draw_pixel && m_is_active)
{
m_gfx_op->draw_pixel(x, y, rgb);
m_gfx_op->draw_pixel(x, y, rgb);
}
if (!m_fb) { return; }

View File

@ -11,7 +11,7 @@ int c_theme::add_font(FONT_TYPE index, const FONT_INFO* font)
{
if (index >= FONT_MAX)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
s_font_map[index] = font;
@ -22,8 +22,8 @@ const FONT_INFO* c_theme::get_font(FONT_TYPE index)
{
if (index >= FONT_MAX)
{
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
return s_font_map[index];
}
@ -32,7 +32,7 @@ int c_theme::add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp)
{
if (index >= BITMAP_MAX)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
s_bmp_map[index] = bmp;
@ -43,8 +43,8 @@ const BITMAP_INFO* c_theme::get_bmp(BITMAP_TYPE index)
{
if (index >= BITMAP_MAX)
{
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
return s_bmp_map[index];
}
@ -53,7 +53,7 @@ int c_theme::add_color(COLOR_TYPE index, const unsigned int color)
{
if (index >= COLOR_MAX)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
s_color_map[index] = color;
@ -64,8 +64,8 @@ const unsigned int c_theme::get_color(COLOR_TYPE index)
{
if (index >= COLOR_MAX)
{
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
return s_color_map[index];
}

View File

@ -1,15 +1,15 @@
#include "../core_include/api.h"
#include "../core_include/rect.h"
#include "../core_include/cmd_target.h"
#include "../core_include/api.h"
#include "../core_include/resource.h"
#include "../core_include/bitmap.h"
#include "../core_include/surface.h"
#include "../core_include/wnd.h"
c_wnd::c_wnd(): m_status(STATUS_NORMAL), m_style(GL_ATTR_VISIBLE), m_parent(NULL), m_top_child(NULL), m_prev_sibling(NULL), m_next_sibling(NULL),
m_str(0), m_font_color(0), m_bg_color(0), m_resource_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(NULL), m_surface(NULL)
c_wnd::c_wnd(): m_status(STATUS_NORMAL), m_attr(ATTR_VISIBLE), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0),
m_str(0), m_font_color(0), m_bg_color(0), m_resource_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0)
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
@ -17,7 +17,7 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
{
if(0 == resource_id)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
@ -31,9 +31,9 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
m_z_order = parent->m_z_order;
m_surface = parent->m_surface;
}
if(NULL == m_surface)
if(0 == m_surface)
{
ASSERT(FALSE);
ASSERT(false);
return -2;
}
@ -64,7 +64,7 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
int c_wnd::load_child_wnd(WND_TREE *p_child_tree)
{
if (NULL == p_child_tree)
if (0 == p_child_tree)
{
return 0;
}
@ -75,7 +75,7 @@ int c_wnd::load_child_wnd(WND_TREE *p_child_tree)
{
if (0 != p_cur->p_wnd->m_resource_id)
{//This wnd has been used! Do not share!
ASSERT(FALSE);
ASSERT(false);
return -1;
}
else
@ -94,8 +94,8 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
{
if(0 == resource_id)
{
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
c_wnd* wnd = clone();
@ -113,10 +113,10 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
{
wnd->m_surface = m_surface;
}
if(NULL == wnd->m_surface)
if(0 == wnd->m_surface)
{
ASSERT(FALSE);
return NULL;
ASSERT(false);
return 0;
}
/* (cs.x = x * 1024 / 768) for 1027*768=>800*600 quickly*/
@ -146,7 +146,7 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
int c_wnd::load_clone_child_wnd(WND_TREE *p_child_tree)
{
if (NULL == p_child_tree)
if (0 == p_child_tree)
{
return 0;
}
@ -170,10 +170,10 @@ void c_wnd::disconnect()
return;
}
if (NULL != m_top_child)
if (0 != m_top_child)
{
c_wnd *child = m_top_child;
c_wnd *next_child = NULL;
c_wnd *next_child = 0;
while (child)
{
@ -208,11 +208,11 @@ c_wnd* c_wnd::get_wnd_ptr(unsigned short id) const
return child;
}
void c_wnd::set_style(unsigned int style)
void c_wnd::set_attr(WND_ATTRIBUTION attr)
{
m_style = style;
m_attr = attr;
if ( GL_ATTR_DISABLED == (m_style & GL_ATTR_DISABLED) )
if ( ATTR_DISABLED == (attr & ATTR_DISABLED) )
{
m_status = STATUS_DISABLED;
}
@ -227,15 +227,15 @@ void c_wnd::set_style(unsigned int style)
int c_wnd::is_focus_wnd() const
{
if ( (m_style & GL_ATTR_VISIBLE)
&& !(m_style & GL_ATTR_DISABLED)
&& (m_style & GL_ATTR_FOCUS))
if ( (m_attr & ATTR_VISIBLE)
&& !(m_attr & ATTR_DISABLED)
&& (m_attr & ATTR_FOCUS))
{
return TRUE;
return true;
}
else
{
return FALSE;
return false;
}
}
@ -266,7 +266,7 @@ void c_wnd::wnd2screen(int &x, int &y) const
x += m_wnd_rect.m_left;
y += m_wnd_rect.m_top;
while ( NULL != parent )
while ( 0 != parent )
{
parent->get_wnd_rect(rect);
x += rect.m_left;
@ -295,7 +295,7 @@ void c_wnd::screen2wnd(short &x, short &y) const
x -= m_wnd_rect.m_left;
y -= m_wnd_rect.m_top;
while ( NULL != parent )
while ( 0 != parent )
{
parent->get_wnd_rect(rect);
x -= rect.m_left;
@ -317,7 +317,7 @@ void c_wnd::screen2wnd(c_rect &rect) const
c_wnd* c_wnd::set_child_focus(c_wnd * focus_child)
{
ASSERT(NULL != focus_child);
ASSERT(0 != focus_child);
ASSERT(focus_child->m_parent == this);
c_wnd *old_focus_child = m_focus_child;
@ -343,33 +343,33 @@ c_wnd* c_wnd::set_child_focus(c_wnd * focus_child)
void c_wnd::add_child_2_tail(c_wnd *child)
{
if( NULL == child )return;
if( 0 == child )return;
if(child == get_wnd_ptr(child->m_resource_id))return;
if ( NULL == m_top_child )
if ( 0 == m_top_child )
{
m_top_child = child;
child->m_prev_sibling = NULL;
child->m_next_sibling = NULL;
child->m_prev_sibling = 0;
child->m_next_sibling = 0;
}
else
{
c_wnd *last_child = get_last_child();
if (NULL == last_child)
if (0 == last_child)
{
ASSERT(FALSE);
ASSERT(false);
}
last_child->m_next_sibling = child;
child->m_prev_sibling = last_child;
child->m_next_sibling = NULL;
child->m_next_sibling = 0;
}
}
c_wnd* c_wnd::get_last_child() const
{
if ( NULL == m_top_child )
if ( 0 == m_top_child )
{
return NULL;
return 0;
}
c_wnd *child = m_top_child;
@ -384,29 +384,29 @@ c_wnd* c_wnd::get_last_child() const
int c_wnd::unlink_child(c_wnd *child)
{
if ((NULL == child)
if ((0 == child)
|| (this != child->m_parent))
{
return -1;
}
if (NULL == m_top_child)
if (0 == m_top_child)
{
return -2;
}
int find = FALSE;
int find = false;
c_wnd *tmp_child = m_top_child;
if (tmp_child == child)
{
m_top_child = child->m_next_sibling;
if (NULL != child->m_next_sibling)
if (0 != child->m_next_sibling)
{
child->m_next_sibling->m_prev_sibling = NULL;
child->m_next_sibling->m_prev_sibling = 0;
}
find = TRUE;
find = true;
}
else
{
@ -415,12 +415,12 @@ int c_wnd::unlink_child(c_wnd *child)
if (child == tmp_child->m_next_sibling)
{
tmp_child->m_next_sibling = child->m_next_sibling;
if (NULL != child->m_next_sibling)
if (0 != child->m_next_sibling)
{
child->m_next_sibling->m_prev_sibling = tmp_child;
}
find = TRUE;
find = true;
break;
}
@ -428,15 +428,15 @@ int c_wnd::unlink_child(c_wnd *child)
}
}
if (TRUE == find)
if (true == find)
{
if (m_focus_child == child)
{
m_focus_child = NULL;
m_focus_child = 0;
}
child->m_next_sibling = NULL;
child->m_prev_sibling = NULL;
child->m_next_sibling = 0;
child->m_prev_sibling = 0;
return 1;
}
else
@ -447,11 +447,11 @@ int c_wnd::unlink_child(c_wnd *child)
void c_wnd::show_window()
{
if (GL_ATTR_VISIBLE == (m_style & GL_ATTR_VISIBLE))
if (ATTR_VISIBLE == (m_attr & ATTR_VISIBLE))
{
on_paint();
c_wnd *child = m_top_child;
if ( NULL != child )
if ( 0 != child )
{
while ( child )
{
@ -469,17 +469,17 @@ bool c_wnd::on_touch(int x, int y, TOUCH_ACTION action)
y -= m_wnd_rect.m_top;
c_wnd* child = m_top_child;
c_wnd* target_wnd = NULL;
c_wnd* target_wnd = 0;
int target_z_order = Z_ORDER_LEVEL_0;
while (child)
{
if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
if (ATTR_VISIBLE == (child->m_attr & ATTR_VISIBLE))
{
child->get_wnd_rect(rect);
if (TRUE == rect.PtInRect(x, y) || child->m_style & GL_ATTR_MODAL)
if (true == rect.PtInRect(x, y) || child->m_attr & ATTR_MODAL)
{
if (TRUE == child->is_focus_wnd())
if (true == child->is_focus_wnd())
{
if (child->m_z_order >= target_z_order)
{
@ -492,7 +492,7 @@ bool c_wnd::on_touch(int x, int y, TOUCH_ACTION action)
child = child->m_next_sibling;
}
if (target_wnd == NULL)
if (target_wnd == 0)
{
return false;
}
@ -522,12 +522,12 @@ bool c_wnd::on_key(KEY_TYPE key)
if (!old_focus_wnd)
{// No current focus wnd, new one.
c_wnd *child = m_top_child;
c_wnd *new_focus_wnd = NULL;
c_wnd *new_focus_wnd = 0;
while (child)
{
if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
if (ATTR_VISIBLE == (child->m_attr & ATTR_VISIBLE))
{
if (TRUE == child->is_focus_wnd())
if (true == child->is_focus_wnd())
{
new_focus_wnd = child;
new_focus_wnd->m_parent->set_child_focus(new_focus_wnd);
@ -568,7 +568,7 @@ void c_wnd::notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param)
return;
}
const GL_MSG_ENTRY* entry = m_parent->FindMsgEntry(m_parent->GetMSgEntries(), MSG_TYPE_WND, msg_id, ctrl_id);
if (NULL == entry)
if (0 == entry)
{
return;
}
@ -591,7 +591,7 @@ void c_wnd::notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param)
(m_parent->*msg_funcs.func_vwl)(ctrl_id, param);
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
}

View File

@ -46,7 +46,7 @@ inline static int get_utf8_code(const char* s, unsigned int& output_utf8_code)
output_utf8_code = (*us << 24) | ((*(us + 1)) << 16) | (*(us + 2) << 8) | *(us + 3);
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
return utf8_bytes;
@ -68,7 +68,7 @@ void c_word::draw_value(c_surface* surface, int z_order, int value, int dot_posi
void c_word::draw_string_in_rect(c_surface* surface, int z_order, const char *s, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type)
{
if(NULL == s)
if(0 == s)
{
return;
}
@ -79,7 +79,7 @@ void c_word::draw_string_in_rect(c_surface* surface, int z_order, const char *s,
void c_word::draw_string(c_surface* surface, int z_order, const char *s, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type)
{
if (NULL == s)
if (0 == s)
{
return;
}
@ -96,11 +96,6 @@ void c_word::draw_string(c_surface* surface, int z_order, const char *s, int x,
void c_word::value_2_string(int value, int dot_position, char* buf, int len)
{
memset(buf, 0, len);
if (XXX == value)
{
sprintf(buf, "%s", "---");
return;
}
switch (dot_position)
{
case 0:
@ -116,7 +111,7 @@ void c_word::value_2_string(int value, int dot_position, char* buf, int len)
sprintf(buf, "%.3f", value*1.0 / 1000);
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
}
@ -141,7 +136,7 @@ const LATTICE* c_word::get_lattice(const FONT_INFO* font, unsigned int utf8_code
}
middle = (first + last) / 2;
}
return NULL;
return 0;
}
int c_word::draw_single_char(c_surface* surface, int z_order, unsigned int utf8_code, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color)
@ -217,7 +212,7 @@ void c_word::draw_lattice(c_surface* surface, int z_order, int x, int y, int wid
int c_word::get_str_size(const char *s, const FONT_INFO* font, int& width, int& height)
{
if(NULL == s || NULL == font)
if(0 == s || 0 == font)
{
width = height = 0;
return -1;

View File

@ -2,18 +2,6 @@
#define API_H
#define REAL_TIME_TASK_CYCLE_MS 50
#define XXX -999
#define NULL 0
#define TRUE 1
#define FALSE 0
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log));
void _assert(const char* file, int line);
#define ASSERT(condition) \
do{ \
if(!(condition))_assert(__FILE__, __LINE__);\
}while(0)
void log_out(const char* log);
#define GL_ARGB(a, r, g, b) ((((unsigned int)(a)) << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
#define GL_ARGB_A(rgb) ((((unsigned int)(rgb)) >> 24) & 0xFF)
@ -25,7 +13,17 @@ void log_out(const char* log);
#define GL_RGB_32_to_16(rgb) (((((unsigned int)(rgb)) & 0xFF) >> 3) | ((((unsigned int)(rgb)) & 0xFC00) >> 5) | ((((unsigned int)(rgb)) & 0xF80000) >> 8))
#define GL_RGB_16_to_32(rgb) ((0xFF << 24) | ((((unsigned int)(rgb)) & 0x1F) << 3) | ((((unsigned int)(rgb)) & 0x7E0) << 5) | ((((unsigned int)(rgb)) & 0xF800) << 8))
typedef struct _T_TIME
#define ALIGN_HCENTER 0x00000000L
#define ALIGN_LEFT 0x01000000L
#define ALIGN_RIGHT 0x02000000L
#define ALIGN_HMASK 0x03000000L
#define ALIGN_VCENTER 0x00000000L
#define ALIGN_TOP 0x00100000L
#define ALIGN_BOTTOM 0x00200000L
#define ALIGN_VMASK 0x00300000L
typedef struct
{
unsigned short year;
unsigned short month;
@ -36,6 +34,14 @@ typedef struct _T_TIME
unsigned short second;
}T_TIME;
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log));
void _assert(const char* file, int line);
#define ASSERT(condition) \
do{ \
if(!(condition))_assert(__FILE__, __LINE__);\
}while(0)
void log_out(const char* log);
long get_time_in_second();
T_TIME second_to_day(long second);
T_TIME get_time();

View File

@ -7,11 +7,7 @@ class c_bitmap
{
public:
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, int x, int y, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
static void draw_bitmap_in_rect(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
private:
static void draw_bitmap_565(c_surface* surface, int z_order, int x, int y, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
static void get_bitmap_pos(const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, int &x, int &y);
static void draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, int y, int width, int height, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO* pBitmap, int x, int y, int src_x, int src_y, int width, int height, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
};
#endif

View File

@ -11,7 +11,7 @@ class c_display {
public:
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
unsigned int surface_width, unsigned int surface_height,
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = NULL);
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
c_surface* alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder);
int merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
unsigned int get_width() { return m_width; }

View File

@ -1,16 +1,6 @@
#ifndef RECT_H
#define RECT_H
#define ALIGN_HCENTER 0x00000000L
#define ALIGN_LEFT 0x01000000L
#define ALIGN_RIGHT 0x02000000L
#define ALIGN_HMASK 0x03000000L
#define ALIGN_VCENTER 0x00000000L
#define ALIGN_TOP 0x00100000L
#define ALIGN_BOTTOM 0x00200000L
#define ALIGN_VMASK 0x00300000L
class c_rect
{
public:

View File

@ -4,7 +4,7 @@
class c_frame_layer
{
public:
c_frame_layer() { fb = NULL;}
c_frame_layer() { fb = 0;}
unsigned short* fb;
c_rect rect;
};
@ -63,7 +63,7 @@ protected:
int m_height; //in pixels
int m_color_bytes; //16 bits, 32 bits only
void* m_fb; //Top frame buffer you could see
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be NULL
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
void* m_usr;
bool m_is_active;
Z_ORDER_LEVEL m_max_zorder;

View File

@ -1,18 +1,20 @@
#ifndef WND_H
#define WND_H
//Window attribution
#define GL_ATTR_VISIBLE 0x80000000L
#define GL_ATTR_DISABLED 0x40000000L
#define GL_ATTR_FOCUS 0x20000000L
#define GL_ATTR_MODAL 0x10000000L// Handle touch action at high priority
typedef struct struct_font_info FONT_INFO;
typedef struct struct_color_rect COLOR_RECT;
class c_wnd;
class c_surface;
typedef enum
{
ATTR_VISIBLE = 0x80000000L,
ATTR_DISABLED = 0x40000000L,
ATTR_FOCUS = 0x20000000L,
ATTR_MODAL = 0x10000000L// Handle touch action at high priority
}WND_ATTRIBUTION;
typedef enum
{
STATUS_NORMAL,
@ -53,9 +55,9 @@ public:
c_wnd();
virtual ~c_wnd() {};
virtual int connect(c_wnd *parent, unsigned short resource_id, const char* str,
short x, short y, short width, short height, WND_TREE* p_child_tree = NULL);
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
virtual c_wnd* connect_clone(c_wnd *parent, unsigned short resource_id, const char* str,
short x, short y, short width, short height, WND_TREE* p_child_tree = NULL);
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
void disconnect();
virtual c_wnd* clone() = 0;
virtual void on_init_children() {}
@ -65,8 +67,8 @@ public:
unsigned short get_id() const { return m_resource_id; }
int get_z_order() { return m_z_order; }
c_wnd* get_wnd_ptr(unsigned short id) const;
unsigned int get_style() const { return m_style; }
void set_style(unsigned int style);
unsigned int get_attr() const { return m_attr; }
void set_attr(WND_ATTRIBUTION attr);
void set_str(const char* str) { m_str = str; }
int is_focus_wnd() const;
@ -114,7 +116,7 @@ protected:
virtual void on_kill_focus() {};
protected:
WND_STATUS m_status;
unsigned int m_style;
WND_ATTRIBUTION m_attr;
c_rect m_wnd_rect;// position relative to parent wnd.
c_wnd* m_parent;
c_wnd* m_top_child;

View File

@ -1,32 +0,0 @@
# Charity tracker
[中文](#大病儿童救助记录)
- We give to sick kids
- Each give was replied with "Donated from GuiLite Dev" for easy searching
## How to work
![WorkFlow](CharityWorkFlow.png)
## Tracker list
| Date Given | Amount | Recipient Organization | Kid's name | Reason |
| --- | --- | --- | --- | --- |
| 2019-6-24 | ¥20 | China Charities Aid Foundation for Children | Yan Wang | [Blood cancer](https://yglian.qschou.com/gongyi/publicSite/detail?ChannelId=zhech&id=201905230000000050026157&mp=toutiao20190624) |
| 2019-6-25 | ¥20 | China Charities Aid Foundation for Children | Yixuan Wu | [Blood cancer](https://www.toutiao.com/a6706325979037434375/?timestamp=1561466239&app=news_article&group_id=6706325979037434375&req_id=201906252037190100180692204641D7D) |
| 2019-6-25 | ¥20 | China Charities Aid Foundation for Children | Chenchen | [Neuroblastoma](https://m.toutiaocdn.com/group/6706384216721998339/?app=news_article&timestamp=1561466189&req_id=2019062520362901001703913820265FD&group_id=6706384216721998339) |
| 2019-6-28 | ¥20 | China Charities Aid Foundation for Children | Xinliang Wang | [Fire burn](https://m.toutiaocdn.com/item/6707482644117979661/?app=news_article&timestamp=1561734886&req_id=201906282314460100160191554395E50&group_id=6707482644117979661) |
| 2019-6-28 | ¥20 | China Charities Aid Foundation for Children | Zihan Lin | [Acute lymphoblastic leukemia](https://m.toutiaocdn.com/item/6707041382608929291/?app=news_article&timestamp=1561734915&req_id=201906282315150101520440935242685&group_id=6707041382608929291) |
| 2019-6-28 | ¥20 | China Charities Aid Foundation for Children | Ziyang Li | [Pancreatoblastoma](https://m.toutiaocdn.com/item/6706008540542140940/?app=news_article&timestamp=1561734932&req_id=2019062823153101001703913896979C2&group_id=6706008540542140940) |
# 大病儿童救助记录
- 我们救助“大病”儿童
- 每条救助下面都有回复“GuiLite开发者捐助”,以便查询
## 救助流程
![WorkFlow](CharityWorkFlow.png)
## 救助记录
| 救助日期 | 金额 | 收款机构 | 受助者姓名 | 受助原因 |
| --- | --- | --- | --- | --- |
| 2019-6-24 | ¥20 | 中华少年儿童慈善救助基金会 | 王研 | [血癌](https://yglian.qschou.com/gongyi/publicSite/detail?ChannelId=zhech&id=201905230000000050026157&mp=toutiao20190624) |
| 2019-6-25 | ¥20 | 中华少年儿童慈善救助基金会 | 吴奕轩 | [血癌](https://www.toutiao.com/a6706325979037434375/?timestamp=1561466239&app=news_article&group_id=6706325979037434375&req_id=201906252037190100180692204641D7D) |
| 2019-6-25 | ¥20 | 中华少年儿童慈善救助基金会 | 晨晨 | [神经母细胞瘤](https://m.toutiaocdn.com/group/6706384216721998339/?app=news_article&timestamp=1561466189&req_id=2019062520362901001703913820265FD&group_id=6706384216721998339) |
| 2019-6-28 | ¥20 | 中华少年儿童慈善救助基金会 | 王兴亮 | [烧伤](https://m.toutiaocdn.com/item/6707482644117979661/?app=news_article&timestamp=1561734886&req_id=201906282314460100160191554395E50&group_id=6707482644117979661) |
| 2019-6-28 | ¥20 | 中华少年儿童慈善救助基金会 | 林子涵 | [急性淋巴细胞白血病](https://m.toutiaocdn.com/item/6707041382608929291/?app=news_article&timestamp=1561734915&req_id=201906282315150101520440935242685&group_id=6707041382608929291) |
| 2019-6-28 | ¥20 | 中华少年儿童慈善救助基金会 | 李子洋| [胰母细胞瘤](https://m.toutiaocdn.com/item/6706008540542140940/?app=news_article&timestamp=1561734932&req_id=2019062823153101001703913896979C2&group_id=6706008540542140940) |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -11,7 +11,7 @@
void c_button::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
m_font_type = c_theme::get_font(FONT_DEFAULT);
m_font_color = c_theme::get_color(COLOR_WND_FONT);
}
@ -63,43 +63,29 @@ void c_button::on_paint()
switch(m_status)
{
case STATUS_NORMAL:
if (m_bitmap_normal)
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
if (m_str)
{
c_bitmap::draw_bitmap_in_rect(m_surface, m_z_order, m_bitmap_normal, rect, m_style);
}
else
{
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_NORMAL), ALIGN_HCENTER | ALIGN_VCENTER);
}
break;
case STATUS_FOCUSED:
if (m_bitmap_focus)
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
if (m_str)
{
c_bitmap::draw_bitmap_in_rect(m_surface, m_z_order, m_bitmap_focus, rect, m_style);
}
else
{
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_FOCUS), ALIGN_HCENTER | ALIGN_VCENTER);
}
break;
case STATUS_PUSHED:
if (m_bitmap_pushed)
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_PUSHED), m_z_order);
m_surface->draw_rect(rect, c_theme::get_color(COLOR_WND_BORDER), 2, m_z_order);
if (m_str)
{
c_bitmap::draw_bitmap_in_rect(m_surface, m_z_order, m_bitmap_pushed, rect, m_style);
}
else
{
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_PUSHED), m_z_order);
m_surface->draw_rect(rect, c_theme::get_color(COLOR_WND_BORDER), 2, m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_PUSHED), ALIGN_HCENTER | ALIGN_VCENTER);
}
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
if (m_str)
{
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
}
}

View File

@ -12,7 +12,7 @@
DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX];
void c_dialog::pre_create_wnd()
{
m_style = 0;// no focus/visible
m_attr = WND_ATTRIBUTION(0);// no focus/visible
m_z_order = Z_ORDER_LEVEL_1;
m_bg_color = GL_RGB(33, 42, 53);
}
@ -38,14 +38,14 @@ c_dialog* c_dialog::get_the_dialog(c_surface* surface)
return ms_the_dialogs[i].dialog;
}
}
return NULL;
return 0;
}
int c_dialog::open_dialog(c_dialog* p_dlg, bool modal_mode)
{
if (NULL == p_dlg)
if (0 == p_dlg)
{
ASSERT(FALSE);
ASSERT(false);
return 0;
}
c_dialog* cur_dlg = get_the_dialog(p_dlg->get_surface());
@ -56,14 +56,14 @@ int c_dialog::open_dialog(c_dialog* p_dlg, bool modal_mode)
if(cur_dlg)
{
cur_dlg->set_style(0);
cur_dlg->set_attr(WND_ATTRIBUTION(0));
}
c_rect rc;
p_dlg->get_screen_rect(rc);
p_dlg->get_surface()->set_frame_layer(rc, Z_ORDER_LEVEL_1);
p_dlg->set_style(modal_mode ? (GL_ATTR_VISIBLE | GL_ATTR_FOCUS | GL_ATTR_MODAL) : (GL_ATTR_VISIBLE | GL_ATTR_FOCUS));
p_dlg->set_attr(modal_mode ? (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS | ATTR_MODAL) : (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS));
p_dlg->show_window();
p_dlg->set_me_the_dialog();
return 1;
@ -73,13 +73,13 @@ int c_dialog::close_dialog(c_surface* surface)
{
c_dialog* dlg = get_the_dialog(surface);
if (NULL == dlg)
if (0 == dlg)
{
return 0;
}
c_rect rc;
dlg->set_style(0);
dlg->set_attr(WND_ATTRIBUTION(0));
surface->set_frame_layer(rc, dlg->m_z_order);
//clear the dialog
@ -87,11 +87,11 @@ int c_dialog::close_dialog(c_surface* surface)
{
if(ms_the_dialogs[i].surface == surface)
{
ms_the_dialogs[i].dialog = NULL;
ms_the_dialogs[i].dialog = 0;
return 1;
}
}
ASSERT(FALSE);
ASSERT(false);
return -1;
}
@ -109,7 +109,7 @@ int c_dialog::set_me_the_dialog()
for(int i = 0; i < SURFACE_CNT_MAX; i++)
{
if(ms_the_dialogs[i].surface == NULL)
if(ms_the_dialogs[i].surface == 0)
{
ms_the_dialogs[i].dialog = this;
if(this)
@ -119,6 +119,6 @@ int c_dialog::set_me_the_dialog()
return 1;
}
}
ASSERT(FALSE);
ASSERT(false);
return -2;
}

View File

@ -23,7 +23,7 @@ static c_keyboard s_keyboard;
void c_edit::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
m_kb_style = STYLE_ALL_BOARD;
m_font_type = c_theme::get_font(FONT_DEFAULT);
m_font_color = c_theme::get_color(COLOR_WND_FONT);
@ -35,7 +35,7 @@ void c_edit::pre_create_wnd()
void c_edit::set_text(const char* str)
{
if (str != NULL && strlen(str) < sizeof(m_str))
if (str != 0 && strlen(str) < sizeof(m_str))
{
strcpy(m_str, str);
}
@ -124,9 +124,10 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_NORMAL), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
@ -134,32 +135,25 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_FOCUS), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_PUSHED:
if (m_z_order == m_parent->get_z_order())
{
m_z_order++;
m_style |= GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS | ATTR_MODAL);
show_keyboard();
}
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_BORDER), m_parent->get_z_order(), 2);
strlen(m_str_input) ? c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str_input, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_PUSHED), ALIGN_HCENTER | ALIGN_VCENTER) :
c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_PUSHED), ALIGN_HCENTER | ALIGN_VCENTER);
break;
default:
ASSERT(FALSE);
break;
}
if (strlen(m_str_input))
{
c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str_input, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
}
else
{
c_word::draw_string_in_rect(m_surface, m_parent->get_z_order(), m_str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
ASSERT(false);
}
}
@ -195,7 +189,7 @@ void c_edit::on_key_board_click(unsigned int ctrl_id, long param)
on_paint();
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
}

View File

@ -37,7 +37,7 @@ c_gesture::c_gesture(c_wnd* root, c_slide_group* group, c_fifo* hid_fifo)
m_down_x = m_down_y = m_move_x = m_move_y = 0;
unsigned long pid;
create_thread(&pid, NULL, task_handle_msg, this);
create_thread(&pid, 0, task_handle_msg, this);
}
bool c_gesture::handle_flip(MSG_INFO &msg)
@ -75,7 +75,7 @@ bool c_gesture::handle_flip(MSG_INFO &msg)
bool c_gesture::on_move(int x)
{
if (m_slide_group == NULL)
if (m_slide_group == 0)
{
return true;
}
@ -99,7 +99,7 @@ bool c_gesture::on_move(int x)
bool c_gesture::on_flip(int x)
{
if (m_slide_group == NULL)
if (m_slide_group == 0)
{
return true;
}
@ -132,14 +132,14 @@ bool c_gesture::on_flip(int x)
int c_gesture::flip_left()
{
if (m_slide_group == NULL)
if (m_slide_group == 0)
{
return -1;
}
int index = m_slide_group->get_active_slide_index();
if((index + 1) >= MAX_PAGES ||
m_slide_group->get_slide(index + 1) == NULL ||
m_slide_group->get_slide(index) == NULL)
m_slide_group->get_slide(index + 1) == 0 ||
m_slide_group->get_slide(index) == 0)
{
return -2;
}
@ -167,14 +167,14 @@ int c_gesture::flip_left()
int c_gesture::flip_right()
{
if (m_slide_group == NULL)
if (m_slide_group == 0)
{
return -1;
}
int index = m_slide_group->get_active_slide_index();
if(index <= 0 ||
m_slide_group->get_slide(index - 1) == NULL ||
m_slide_group->get_slide(index) == NULL)
m_slide_group->get_slide(index - 1) == 0 ||
m_slide_group->get_slide(index) == 0)
{
return -2;
}
@ -204,8 +204,8 @@ void c_gesture::move_left()
{
int index = m_slide_group->get_active_slide_index();
if((index + 1) >= MAX_PAGES ||
m_slide_group->get_slide(index + 1) == NULL ||
m_slide_group->get_slide(index) == NULL)
m_slide_group->get_slide(index + 1) == 0 ||
m_slide_group->get_slide(index) == 0)
{
return;
}
@ -223,8 +223,8 @@ void c_gesture::move_right()
{
int index = m_slide_group->get_active_slide_index();
if(index <= 0 ||
m_slide_group->get_slide(index - 1) == NULL ||
m_slide_group->get_slide(index) == NULL)
m_slide_group->get_slide(index - 1) == 0 ||
m_slide_group->get_slide(index) == 0)
{
return;
}

View File

@ -12,7 +12,7 @@
//Changing key width/height will change the width/height of keyboard
#define KEY_WIDTH 65
#define KEY_HEIGHT 38
#define KEY_HEIGHT 38
#define KEYBOARD_WIDTH ((KEY_WIDTH + 2) * 10)
#define KEYBOARD_HEIGHT ((KEY_HEIGHT + 2) * 4)
@ -75,7 +75,7 @@ WND_TREE g_key_board_children[] =
{&s_button_space, ' ', 0, ((KEY_WIDTH / 2) + POS_X(3)), POS_Y(3), SPACE_WIDTH, KEY_HEIGHT},
{&s_button_dot, '.', 0, ((KEY_WIDTH / 2) + POS_X(6)), POS_Y(3), DOT_WIDTH, KEY_HEIGHT},
{&s_button_enter, '\n', 0, POS_X(8), POS_Y(3), ENTER_WIDTH, KEY_HEIGHT},
{NULL,0,0,0,0,0,0}
{0,0,0,0,0,0,0}
};
WND_TREE g_number_board_children[] =
@ -97,7 +97,7 @@ WND_TREE g_number_board_children[] =
{&s_button_esc, 0x1B, 0, POS_X(0), POS_Y(3), KEY_WIDTH, KEY_HEIGHT},
{&s_button_0, '0', 0, POS_X(1), POS_Y(3), KEY_WIDTH, KEY_HEIGHT},
{&s_button_dot, '.', 0, POS_X(2), POS_Y(3), KEY_WIDTH, KEY_HEIGHT},
{NULL,0,0,0,0,0,0}
{0,0,0,0,0,0,0}
};
GL_BEGIN_MESSAGE_MAP(c_keyboard)
@ -154,22 +154,22 @@ int c_keyboard::connect(c_wnd *user, unsigned short resource_id, KEYBOARD_STYLE
{//Place keyboard at the bottom of user's parent window.
c_rect user_parent_rect;
user->get_parent()->get_wnd_rect(user_parent_rect);
return c_wnd::connect(user, resource_id, NULL, (0 - user_rect.m_left), (user_parent_rect.Height() - user_rect.m_top - KEYBOARD_HEIGHT), KEYBOARD_WIDTH, KEYBOARD_HEIGHT, g_key_board_children);
return c_wnd::connect(user, resource_id, 0, (0 - user_rect.m_left), (user_parent_rect.Height() - user_rect.m_top - KEYBOARD_HEIGHT), KEYBOARD_WIDTH, KEYBOARD_HEIGHT, g_key_board_children);
}
else if(style == STYLE_NUM_BOARD)
{//Place keyboard below the user window.
return c_wnd::connect(user, resource_id, NULL, 0, user_rect.Height(), NUM_BOARD_WIDTH, NUM_BOARD_HEIGHT, g_number_board_children);
return c_wnd::connect(user, resource_id, 0, 0, user_rect.Height(), NUM_BOARD_WIDTH, NUM_BOARD_HEIGHT, g_number_board_children);
}
else
{
ASSERT(FALSE);
ASSERT(false);
}
return -1;
}
void c_keyboard::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
m_cap_status = STATUS_UPPERCASE;
memset(m_str, 0, sizeof(m_str));
m_str_len = 0;
@ -222,7 +222,7 @@ void c_keyboard::on_char_clicked(unsigned int ctrl_id)
}
goto InputChar;
}
ASSERT(FALSE);
ASSERT(false);
InputChar:
m_str[m_str_len++] = ctrl_id;
notify_parent(KEYBORAD_CLICK, get_id(), CLICK_CHAR);
@ -252,37 +252,37 @@ void c_keyboard_button::on_paint()
m_surface->draw_rect(rect, c_theme::get_color(COLOR_WND_BORDER), 2, m_z_order);
break;
default:
ASSERT(FALSE);
ASSERT(false);
break;
}
if (m_resource_id == 0x14)
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "Caps", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "Caps", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == 0x1B)
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "Esc", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "Esc", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == ' ')
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "Space", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "Space", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == '\n')
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "Enter", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "Enter", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == '.')
{
return c_word::draw_string_in_rect(m_surface, m_z_order, ".", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, ".", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == 0x7F)
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "Back", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "Back", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
else if (m_resource_id == 0x90)
{
return c_word::draw_string_in_rect(m_surface, m_z_order, "?123", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
return c_word::draw_string_in_rect(m_surface, m_z_order, "?123", rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}
char letter[] = { 0, 0 };
@ -294,5 +294,5 @@ void c_keyboard_button::on_paint()
{
letter[0] = m_resource_id;
}
c_word::draw_string_in_rect(m_surface, m_z_order, letter, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
c_word::draw_string_in_rect(m_surface, m_z_order, letter, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr);
}

View File

@ -11,9 +11,8 @@
void c_label::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | ALIGN_LEFT | ALIGN_VCENTER;
m_font_color = GL_RGB(255,255,255);
m_attr = ATTR_VISIBLE;
m_font_color = c_theme::get_color(COLOR_WND_FONT);
m_font_type = c_theme::get_font(FONT_DEFAULT);
}
@ -25,6 +24,6 @@ void c_label::on_paint()
if (m_str)
{
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_parent->get_bg_color(), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, m_parent->get_bg_color(), ALIGN_LEFT | ALIGN_VCENTER);
}
}

View File

@ -16,7 +16,7 @@
void c_list_box::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
memset(m_item_array, 0, sizeof(m_item_array));
m_item_total = 0;
m_selected_item = 0;
@ -48,18 +48,20 @@ void c_list_box::on_paint()
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_NORMAL), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_FOCUS), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_PUSHED:
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_PUSHED), m_z_order);
@ -73,20 +75,12 @@ void c_list_box::on_paint()
m_z_order++;
}
m_surface->set_frame_layer(m_list_screen_rect, m_z_order);
m_style |= GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS | ATTR_MODAL);
show_list();
return;
}
break;
default:
ASSERT(FALSE);
break;
}
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), ALIGN_HCENTER | ALIGN_VCENTER);
if (m_item_total)
{
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
ASSERT(false);
}
}
@ -161,7 +155,6 @@ void c_list_box::update_list_size()
void c_list_box::show_list()
{
m_surface->fill_rect(m_list_screen_rect, GL_RGB(17, 17, 17), m_z_order);
//draw all items
c_rect tmp_rect;
for (int i = 0; i < m_item_total; i++)
@ -170,24 +163,25 @@ void c_list_box::show_list()
tmp_rect.m_right = m_list_screen_rect.m_right;
tmp_rect.m_top = m_list_screen_rect.m_top + i * ITEM_HEIGHT;
tmp_rect.m_bottom = tmp_rect.m_top + ITEM_HEIGHT;
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[i], tmp_rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), ALIGN_HCENTER | ALIGN_VCENTER);
m_surface->draw_hline(tmp_rect.m_left, tmp_rect.m_right, tmp_rect.m_bottom, GL_RGB(99, 108, 124), m_z_order);
}
//draw selected item
tmp_rect.m_left = m_list_screen_rect.m_left;
tmp_rect.m_right = m_list_screen_rect.m_right;
tmp_rect.m_top = m_list_screen_rect.m_top + m_selected_item * ITEM_HEIGHT;
tmp_rect.m_bottom = tmp_rect.m_top + ITEM_HEIGHT;
m_surface->fill_rect(tmp_rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], tmp_rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), ALIGN_HCENTER | ALIGN_VCENTER);
if (m_selected_item == i)
{
m_surface->fill_rect(tmp_rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[i], tmp_rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_FOCUS), ALIGN_HCENTER | ALIGN_VCENTER);
}
else
{
m_surface->fill_rect(tmp_rect, GL_RGB(17, 17, 17), m_z_order);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[i], tmp_rect, m_font_type, m_font_color, GL_RGB(17, 17, 17), ALIGN_HCENTER | ALIGN_VCENTER);
}
}
}
int c_list_box::add_item(char* str)
{
if (m_item_total >= MAX_ITEM_NUM)
{
ASSERT(FALSE);
ASSERT(false);
return -1;
}
m_item_array[m_item_total++] = str;
@ -206,7 +200,7 @@ void c_list_box::select_item(short index)
{
if (index < 0 || index >= m_item_total)
{
ASSERT(FALSE);
ASSERT(false);
}
m_selected_item = index;
}

View File

@ -12,7 +12,7 @@ c_slide_group::c_slide_group()
{
for(int i = 0; i < MAX_PAGES; i++)
{
m_slides[i] = NULL;
m_slides[i] = 0;
}
m_active_slide_index = 0;
}
@ -31,7 +31,7 @@ int c_slide_group::set_active_slide(int index, bool is_redraw)
for(int i = 0; i < MAX_PAGES; i++)
{
if(m_slides[i] == NULL)
if(m_slides[i] == 0)
{
continue;
}
@ -57,7 +57,7 @@ int c_slide_group::set_active_slide(int index, bool is_redraw)
int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree, Z_ORDER_LEVEL max_zorder)
{
if(NULL == slide)
if(0 == slide)
{
return -1;
}
@ -74,7 +74,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
{
if(m_slides[i] == slide)
{//slide has lived
ASSERT(FALSE);
ASSERT(false);
return -2;
}
i++;
@ -84,7 +84,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
i = 0;
while(i < MAX_PAGES)
{
if(m_slides[i] == NULL)
if(m_slides[i] == 0)
{
m_slides[i] = slide;
slide->show_window();
@ -94,14 +94,14 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
}
//no more slide can be add
ASSERT(FALSE);
ASSERT(false);
return -3;
}
int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree, Z_ORDER_LEVEL max_zorder)
{
if(NULL == slide)
if(0 == slide)
{
return -1;
}
@ -118,7 +118,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
{
if(m_slides[i] == page_tmp)
{//slide has lived
ASSERT(FALSE);
ASSERT(false);
return -2;
}
i++;
@ -128,7 +128,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
i = 0;
while(i < MAX_PAGES)
{
if(m_slides[i] == NULL)
if(m_slides[i] == 0)
{
m_slides[i] = page_tmp;
page_tmp->show_window();
@ -138,7 +138,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
}
//no more slide can be add
ASSERT(FALSE);
ASSERT(false);
return -3;
}
@ -154,9 +154,9 @@ void c_slide_group::disabel_all_slide()
}
bool c_slide_group::on_touch(int x, int y, TOUCH_ACTION action)
{
{
x -= m_wnd_rect.m_left;
y -= m_wnd_rect.m_top;
y -= m_wnd_rect.m_top;
if (m_slides[m_active_slide_index])
{
m_slides[m_active_slide_index]->on_touch(x, y, action);
@ -165,7 +165,7 @@ bool c_slide_group::on_touch(int x, int y, TOUCH_ACTION action)
}
bool c_slide_group::on_key(KEY_TYPE key)
{
{
if (m_slides[m_active_slide_index])
{
m_slides[m_active_slide_index]->on_key(key);

View File

@ -20,7 +20,7 @@ GL_END_MESSAGE_MAP()
void c_spin_box::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
m_font_type = c_theme::get_font(FONT_DEFAULT);
m_font_color = c_theme::get_color(COLOR_WND_FONT);
@ -52,7 +52,7 @@ bool c_spin_box::on_touch(int x, int y, TOUCH_ACTION action)
void c_spin_box::on_touch_down(int x, int y)
{
if (FALSE == m_wnd_rect.PtInRect(x, y))
if (false == m_wnd_rect.PtInRect(x, y))
{//maybe click on up/down arrow button
return;
}
@ -64,7 +64,7 @@ void c_spin_box::on_touch_down(int x, int y)
void c_spin_box::on_touch_up(int x, int y)
{
if (FALSE == m_wnd_rect.PtInRect(x, y))
if (false == m_wnd_rect.PtInRect(x, y))
{//maybe click on up/down arrow button
return;
}
@ -103,14 +103,14 @@ void c_spin_box::show_arrow_button()
m_bt_down.connect(this, ID_BT_ARROW_DOWN, "\xe2\x96\xbc"/*▼*/, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
m_bt_down.show_window();
m_style |= GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS | ATTR_MODAL);
}
void c_spin_box::hide_arrow_button()
{
m_bt_up.disconnect();
m_bt_down.disconnect();
m_style &= ~GL_ATTR_MODAL;
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
}
void c_spin_box::on_paint()
@ -130,6 +130,7 @@ void c_spin_box::on_paint()
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_NORMAL), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
@ -139,6 +140,7 @@ void c_spin_box::on_paint()
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_FOCUS), ALIGN_HCENTER | ALIGN_VCENTER);
break;
case STATUS_PUSHED:
if (m_z_order == m_parent->get_z_order())
@ -152,15 +154,11 @@ void c_spin_box::on_paint()
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_BORDER), m_parent->get_z_order(), 2);
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, GL_RGB(2, 124, 165), GL_ARGB(0, 0, 0, 0), m_style);
return;
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, m_font_color, c_theme::get_color(COLOR_WND_PUSHED), ALIGN_HCENTER | ALIGN_VCENTER);
break;
default:
ASSERT(FALSE);
break;
ASSERT(false);
}
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
}
void c_spin_box::on_arrow_up_bt_click(unsigned int ctr_id)

View File

@ -21,9 +21,9 @@
c_wave_ctrl::c_wave_ctrl()
{
m_wave = NULL;
m_bg_fb = NULL;
m_wave_name_font = m_wave_unit_font = NULL;
m_wave = 0;
m_bg_fb = 0;
m_wave_name_font = m_wave_unit_font = 0;
m_wave_name = m_wave_unit = 0;
m_max_data = 500;
m_min_data = 0;
@ -78,9 +78,9 @@ void c_wave_ctrl::set_wave_speed(unsigned int speed)
void c_wave_ctrl::clear_data()
{
if(m_wave == NULL)
if(m_wave == 0)
{
ASSERT(FALSE);
ASSERT(false);
return;
}
m_wave->clear_data();
@ -88,9 +88,9 @@ void c_wave_ctrl::clear_data()
bool c_wave_ctrl::is_data_enough()
{
if(m_wave == NULL)
if(m_wave == 0)
{
ASSERT(FALSE);
ASSERT(false);
return false;
}
return (m_wave->get_cnt() - m_frame_len_map[m_frame_len_map_index] * m_wave_speed);
@ -98,9 +98,9 @@ bool c_wave_ctrl::is_data_enough()
void c_wave_ctrl::refresh_wave(unsigned char frame)
{
if(m_wave == NULL)
if(m_wave == 0)
{
ASSERT(FALSE);
ASSERT(false);
return;
}
@ -117,7 +117,7 @@ void c_wave_ctrl::refresh_wave(unsigned char frame)
int y_min,y_max;
if(m_max_data == m_min_data)
{
ASSERT(FALSE);
ASSERT(false);
}
y_max = m_wave_bottom + WAVE_LINE_WIDTH - (m_wave_bottom - m_wave_top)*(min - m_min_data)/(m_max_data - m_min_data);
y_min = m_wave_bottom - WAVE_LINE_WIDTH - (m_wave_bottom - m_wave_top)*(max - m_min_data)/(m_max_data - m_min_data);

View File

@ -10,11 +10,6 @@ class c_button : public c_wnd
{
public:
virtual c_wnd* clone(){return new c_button();}
void set_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_normal = pBitmap; }
void set_focus_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_focus = pBitmap; }
void set_pushed_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_pushed = pBitmap; }
void set_disable_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_disable = pBitmap; }
protected:
virtual void on_paint();
virtual void on_focus();
@ -23,11 +18,6 @@ protected:
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
virtual bool on_key(KEY_TYPE key);
const BITMAP_INFO* m_bitmap_normal;
const BITMAP_INFO* m_bitmap_focus;
const BITMAP_INFO* m_bitmap_pushed;
const BITMAP_INFO* m_bitmap_disable;
};
#endif

View File

@ -11,10 +11,10 @@ public:
c_wnd* get_active_slide(){return m_slides[m_active_slide_index];}
int get_active_slide_index(){return m_active_slide_index;}
int add_slide(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree = NULL,
short width, short height, WND_TREE* p_child_tree = 0,
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
int add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree = NULL,
short width, short height, WND_TREE* p_child_tree = 0,
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
void disabel_all_slide();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);