@@ -12,9 +12,9 @@ void c_bitmap::draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *p
1212 lower_fb = surface->m_frame_layers [z_order - 1 ].fb ;
1313 }
1414 unsigned int mask_rgb_16 = GL_RGB_32_to_16 (mask_rgb);
15- int xsize = pBitmap->XSize ;
16- int ysize = pBitmap->YSize ;
17- const unsigned short * pData = (const unsigned short *)pBitmap->pData ;
15+ int xsize = pBitmap->width ;
16+ int ysize = pBitmap->height ;
17+ const unsigned short * pData = (const unsigned short *)pBitmap->pixel_color_array ;
1818 for (int j = 0 ; j < ysize; j++)
1919 {
2020 for (int i = 0 ; i < xsize; i++)
@@ -36,7 +36,7 @@ void c_bitmap::draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *p
3636}
3737void 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)
3838{
39- if (0 == pBitmap || (src_x + width > pBitmap->XSize ) || (src_y + height > pBitmap->YSize ))
39+ if (0 == pBitmap || (src_x + width > pBitmap->width ) || (src_y + height > pBitmap->height ))
4040 {
4141 return ;
4242 }
@@ -47,10 +47,10 @@ void c_bitmap::draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO* p
4747 lower_fb = surface->m_frame_layers [z_order - 1 ].fb ;
4848 }
4949 unsigned int mask_rgb_16 = GL_RGB_32_to_16 (mask_rgb);
50- const unsigned short * pData = (const unsigned short *)pBitmap->pData ;
50+ const unsigned short * pData = (const unsigned short *)pBitmap->pixel_color_array ;
5151 for (int j = 0 ; j < height; j++)
5252 {
53- const unsigned short * p = &pData[src_x + (src_y + j) * pBitmap->XSize ];
53+ const unsigned short * p = &pData[src_x + (src_y + j) * pBitmap->width ];
5454 for (int i = 0 ; i < width; i++)
5555 {
5656 unsigned int rgb = *p++;
@@ -177,6 +177,7 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
177177 m_phy_fb = phy_fb;
178178 m_phy_read_index = m_phy_write_index = 0 ;
179179 memset (m_surface_group, 0 , sizeof (m_surface_group));
180+ m_surface_index = 0 ;
180181 m_surface_cnt = surface_cnt;
181182 ASSERT (m_surface_cnt <= SURFACE_CNT_MAX);
182183
@@ -185,33 +186,16 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
185186 m_surface_group[i] = phy_fb ? new c_surface (this , surface_width, surface_height, color_bytes) : new c_surface_no_fb (this , surface_width, surface_height, color_bytes, gfx_op);
186187 }
187188}
188- c_surface* c_display::alloc_surface (void * usr, Z_ORDER_LEVEL max_zorder)
189+ c_surface* c_display::alloc_surface (Z_ORDER_LEVEL max_zorder)
189190{
190- int i = 0 ;
191- ASSERT (max_zorder < Z_ORDER_LEVEL_MAX);
192- while (i < m_surface_cnt)
193- {
194- if (m_surface_group[i]->m_usr == usr)
195- {
196- // repeat register
197- ASSERT (false );
198- return m_surface_group[i];
199- }
200- i++;
201- }
202- i = 0 ;
203- while (i < m_surface_cnt)
191+ if (max_zorder >= Z_ORDER_LEVEL_MAX || m_surface_index >= m_surface_cnt)
204192 {
205- if (m_surface_group[i]->m_usr == 0 )
206- {
207- m_surface_group[i]->set_surface (usr, max_zorder);
208- return m_surface_group[i];
209- }
210- i++;
193+ ASSERT (false );
194+ return 0 ;
211195 }
212- // no surface for use
213- ASSERT ( false );
214- return 0 ;
196+ int i = m_surface_index++;
197+ m_surface_group[i]-> set_surface (max_zorder );
198+ return m_surface_group[i] ;
215199}
216200int c_display::merge_surface (c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
217201{
@@ -392,14 +376,13 @@ c_surface::c_surface(c_display* display, unsigned int width, unsigned int heigh
392376 m_display = display;
393377 m_phy_fb = display->m_phy_fb ;
394378 m_phy_write_index = &display->m_phy_write_index ;
395- m_fb = m_usr = 0 ;
379+ m_fb = 0 ;
396380 m_top_zorder = m_max_zorder = Z_ORDER_LEVEL_0;
397381 m_is_active = false ;
398382 m_frame_layers[Z_ORDER_LEVEL_0].visible_rect = c_rect (0 , 0 , m_width, m_height);
399383}
400- void c_surface::set_surface (void * wnd_root, Z_ORDER_LEVEL max_z_order)
384+ void c_surface::set_surface (Z_ORDER_LEVEL max_z_order)
401385{
402- m_usr = wnd_root;
403386 m_max_zorder = max_z_order;
404387 if (m_display->m_surface_cnt > 1 )
405388 {
@@ -479,6 +462,10 @@ void c_surface::draw_pixel_on_fb(int x, int y, unsigned int rgb)
479462}
480463void c_surface::fill_rect (int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order)
481464{
465+ x0 = (x0 < 0 ) ? 0 : x0;
466+ y0 = (y0 < 0 ) ? 0 : y0;
467+ x1 = (x1 > (m_width - 1 )) ? (m_width - 1 ) : x1;
468+ y1 = (y1 > (m_height - 1 )) ? (m_height - 1 ) : y1;
482469 rgb = GL_ROUND_RGB_32 (rgb);
483470 if (z_order == m_max_zorder)
484471 {
@@ -507,11 +494,6 @@ void c_surface::fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsi
507494}
508495void c_surface::fill_rect_on_fb (int x0, int y0, int x1, int y1, unsigned int rgb)
509496{
510- if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0 ||
511- x0 >= m_width || x1 >= m_width || y0 >= m_height || y1 >= m_height)
512- {
513- ASSERT (false );
514- }
515497 int display_width = m_display->get_width ();
516498 int display_height = m_display->get_height ();
517499 if (m_color_bytes == 4 )
@@ -561,7 +543,6 @@ void c_surface::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb
561543 }
562544 }
563545 }
564-
565546}
566547unsigned int c_surface::get_pixel (int x, int y, unsigned int z_order)
567548{
@@ -1161,29 +1142,6 @@ void c_wnd::wnd2screen(c_rect &rect) const
11611142 int b = (t + rect.Height () - 1 );
11621143 rect.SetRect (l, t, r, b);
11631144}
1164- void c_wnd::screen2wnd (short &x, short &y) const
1165- {
1166- c_wnd *parent = m_parent;
1167- c_rect rect;
1168- x -= m_wnd_rect.m_left ;
1169- y -= m_wnd_rect.m_top ;
1170- while ( 0 != parent )
1171- {
1172- parent->get_wnd_rect (rect);
1173- x -= rect.m_left ;
1174- y -= rect.m_top ;
1175- parent = parent->m_parent ;
1176- }
1177- }
1178- void c_wnd::screen2wnd (c_rect &rect) const
1179- {
1180- short l = rect.m_left ;
1181- short t = rect.m_top ;
1182- screen2wnd (l, t);
1183- short r = l + rect.Width () - 1 ;
1184- short b = t + rect.Height () - 1 ;
1185- rect.SetRect (l, t, r, b);
1186- }
11871145c_wnd* c_wnd::set_child_focus (c_wnd * focus_child)
11881146{
11891147 ASSERT (0 != focus_child);
@@ -1403,13 +1361,13 @@ bool c_wnd::on_key(KEY_TYPE key)
14031361 }
14041362 return true ;
14051363}
1406- void c_wnd::notify_parent (unsigned int msg_id, unsigned int ctrl_id, int param)
1364+ void c_wnd::notify_parent (unsigned int msg_id, int param)
14071365{
14081366 if (!m_parent)
14091367 {
14101368 return ;
14111369 }
1412- const GL_MSG_ENTRY* entry = m_parent->FindMsgEntry (m_parent->GetMSgEntries (), MSG_TYPE_WND, msg_id, ctrl_id );
1370+ const GL_MSG_ENTRY* entry = m_parent->FindMsgEntry (m_parent->GetMSgEntries (), MSG_TYPE_WND, msg_id, m_resource_id );
14131371 if (0 == entry)
14141372 {
14151373 return ;
@@ -1425,10 +1383,10 @@ void c_wnd::notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param)
14251383 (m_parent->*msg_funcs.func_vvl )(param);
14261384 break ;
14271385 case MSG_CALLBACK_VWV:
1428- (m_parent->*msg_funcs.func_vwv )(ctrl_id );
1386+ (m_parent->*msg_funcs.func_vwv )(m_resource_id );
14291387 break ;
14301388 case MSG_CALLBACK_VWL:
1431- (m_parent->*msg_funcs.func_vwl )(ctrl_id , param);
1389+ (m_parent->*msg_funcs.func_vwl )(m_resource_id , param);
14321390 break ;
14331391 default :
14341392 ASSERT (false );
@@ -1568,7 +1526,7 @@ int c_word::draw_single_char(c_surface* surface, int z_order, unsigned int utf8_
15681526 const LATTICE* p_lattice = get_lattice (font, utf8_code);
15691527 if (p_lattice)
15701528 {
1571- draw_lattice (surface, z_order, x, y, p_lattice->width , font->height , p_lattice->p_data , font_color, bg_color);
1529+ draw_lattice (surface, z_order, x, y, p_lattice->width , font->height , p_lattice->pixel_gray_array , font_color, bg_color);
15721530 return p_lattice->width ;
15731531 }
15741532 }
@@ -2130,15 +2088,15 @@ bool c_button::on_touch(int x, int y, TOUCH_ACTION action)
21302088 {
21312089 m_status = STATUS_FOCUSED;
21322090 on_paint ();
2133- notify_parent (GL_BN_CLICKED, get_id (), 0 );
2091+ notify_parent (GL_BN_CLICKED, 0 );
21342092 }
21352093 return true ;
21362094}
21372095bool c_button::on_key (KEY_TYPE key)
21382096{
21392097 if (key == KEY_ENTER)
21402098 {
2141- notify_parent (GL_BN_CLICKED, get_id (), 0 );
2099+ notify_parent (GL_BN_CLICKED, 0 );
21422100 return false ;// Do not handle KEY_ENTER by other wnd.
21432101 }
21442102 return true ;// Handle KEY_FOWARD/KEY_BACKWARD by parent wnd.
@@ -2829,12 +2787,12 @@ void c_keyboard::on_caps_clicked(unsigned int ctrl_id)
28292787void c_keyboard::on_enter_clicked (unsigned int ctrl_id)
28302788{
28312789 memset (m_str, 0 , sizeof (m_str));
2832- notify_parent (KEYBORAD_CLICK, get_id (), CLICK_ENTER);
2790+ notify_parent (KEYBORAD_CLICK, CLICK_ENTER);
28332791}
28342792void c_keyboard::on_esc_clicked (unsigned int ctrl_id)
28352793{
28362794 memset (m_str, 0 , sizeof (m_str));
2837- notify_parent (KEYBORAD_CLICK, get_id (), CLICK_ESC);
2795+ notify_parent (KEYBORAD_CLICK, CLICK_ESC);
28382796}
28392797void c_keyboard::on_del_clicked (unsigned int ctrl_id)
28402798{
@@ -2843,7 +2801,7 @@ void c_keyboard::on_del_clicked(unsigned int ctrl_id)
28432801 return ;
28442802 }
28452803 m_str[--m_str_len] = 0 ;
2846- notify_parent (KEYBORAD_CLICK, get_id (), CLICK_CHAR);
2804+ notify_parent (KEYBORAD_CLICK, CLICK_CHAR);
28472805}
28482806void c_keyboard::on_char_clicked (unsigned int ctrl_id)
28492807{// ctrl_id = char ascii code.
@@ -2866,7 +2824,7 @@ void c_keyboard::on_char_clicked(unsigned int ctrl_id)
28662824 ASSERT (false );
28672825InputChar:
28682826 m_str[m_str_len++] = ctrl_id;
2869- notify_parent (KEYBORAD_CLICK, get_id (), CLICK_CHAR);
2827+ notify_parent (KEYBORAD_CLICK, CLICK_CHAR);
28702828}
28712829void c_keyboard::on_paint ()
28722830{
@@ -3042,7 +3000,7 @@ void c_list_box::on_touch_down(int x, int y)
30423000 {
30433001 m_status = STATUS_FOCUSED;
30443002 on_paint ();
3045- notify_parent (GL_LIST_CONFIRM, get_id (), m_selected_item);
3003+ notify_parent (GL_LIST_CONFIRM, m_selected_item);
30463004 }
30473005 }
30483006}
@@ -3065,7 +3023,7 @@ void c_list_box::on_touch_up(int x, int y)
30653023 m_status = STATUS_FOCUSED;
30663024 select_item ((y - m_list_wnd_rect.m_top ) / ITEM_HEIGHT);
30673025 on_paint ();
3068- notify_parent (GL_LIST_CONFIRM, get_id (), m_selected_item);
3026+ notify_parent (GL_LIST_CONFIRM, m_selected_item);
30693027 }
30703028 else
30713029 {
@@ -3180,7 +3138,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
31803138 return -1 ;
31813139 }
31823140 c_surface* old_surface = get_surface ();
3183- c_surface* new_surface = old_surface->get_display ()->alloc_surface (slide, max_zorder);
3141+ c_surface* new_surface = old_surface->get_display ()->alloc_surface (max_zorder);
31843142 new_surface->set_active (false );
31853143 set_surface (new_surface);
31863144 slide->connect (this , resource_id ,0 , x, y, width, height, p_child_tree);
@@ -3219,7 +3177,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
32193177 return -1 ;
32203178 }
32213179 c_surface* old_surface = get_surface ();
3222- c_surface* new_surface = old_surface->get_display ()->alloc_surface (slide, max_zorder);
3180+ c_surface* new_surface = old_surface->get_display ()->alloc_surface (max_zorder);
32233181 new_surface->set_active (false );
32243182 set_surface (new_surface);
32253183 c_wnd* page_tmp = slide->connect_clone (this ,resource_id,0 ,x,y,width,height,p_child_tree);
@@ -3338,7 +3296,7 @@ void c_spin_box::on_touch_up(int x, int y)
33383296 m_value = m_cur_value;
33393297 m_status = STATUS_FOCUSED;
33403298 on_paint ();
3341- notify_parent (GL_SPIN_CONFIRM, get_id (), m_value);
3299+ notify_parent (GL_SPIN_CONFIRM, m_value);
33423300 }
33433301}
33443302void c_spin_box::on_focus ()
@@ -3354,9 +3312,9 @@ void c_spin_box::on_kill_focus()
33543312}
33553313void c_spin_box::show_arrow_button ()
33563314{
3357- m_bt_up.connect (this , ID_BT_ARROW_UP, " \xe2\x96\xb2 " /* ▲ */ , 0 , m_wnd_rect.Height (), m_bt_up_rect.Width (),m_bt_up_rect.Height ());
3315+ m_bt_up.connect (this , ID_BT_ARROW_UP, " \xe2\x96\xb2 " /* unicode of up arrow */ , 0 , m_wnd_rect.Height (), m_bt_up_rect.Width (),m_bt_up_rect.Height ());
33583316 m_bt_up.show_window ();
3359- 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 ());
3317+ m_bt_down.connect (this , ID_BT_ARROW_DOWN, " \xe2\x96\xbc " /* unicode of down arrow */ , m_bt_up_rect.Width (), m_wnd_rect.Height (), m_bt_down_rect.Width (),m_bt_down_rect.Height ());
33603318 m_bt_down.show_window ();
33613319 m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS | ATTR_MODAL);
33623320}
@@ -3418,7 +3376,7 @@ void c_spin_box::on_arrow_up_bt_click(unsigned int ctr_id)
34183376 return ;
34193377 }
34203378 m_cur_value += m_step;
3421- notify_parent (GL_SPIN_CHANGE, get_id (), m_cur_value);
3379+ notify_parent (GL_SPIN_CHANGE, m_cur_value);
34223380 on_paint ();
34233381}
34243382void c_spin_box::on_arrow_down_bt_click (unsigned int ctr_id)
@@ -3428,7 +3386,7 @@ void c_spin_box::on_arrow_down_bt_click(unsigned int ctr_id)
34283386 return ;
34293387 }
34303388 m_cur_value -= m_step;
3431- notify_parent (GL_SPIN_CHANGE, get_id (), m_cur_value);
3389+ notify_parent (GL_SPIN_CHANGE, m_cur_value);
34323390 on_paint ();
34333391}
34343392void c_table::set_item (int row, int col, char * str, unsigned int color)
0 commit comments