Beispiel #1
0
void demo_widget_paint(struct widget *wid, uint16_t x, uint16_t y)
{
	uint16_t i;
	uint16_t j;
	uint16_t k = 0;
	struct demo_widget *dw = (struct demo_widget *)wid;
	for (j = 0; k < dw->item_cnt; j++) {
		for (i = 0; i < dw->item_cnt; i++) {
			if (j == dw->item_map[i].layer) {
				widget_paint(dw->item_map[i].w, x + dw->item_map[i].x, y + dw->item_map[i].y);
				k++;
			}
		}
	}
}
Beispiel #2
0
/*****************************************************************************
 * FUNCTION
 *  HDIa_widgetSetInFocus
 * DESCRIPTION
 *  
 *  
 *  In integration manual: all widgets involved that have the notification functionality enabled
 *  must be notified of the focus change
 *  
 *  However, in some cases (e.g. Send MsfNotifyFocus to another gadget when removing an text input gadget)
 *  BRS might think that use pointer device to click on another gadget.. and it might enter infinite loop.
 *  
 *  If paintbox window is in focus, we should prepare a clear screen
 *  for paintbox use. (this cannot be moved to widget_paint
 *  because BRS use low-level API to draw on the paintbox,
 *  where widget_paint only draw buttons, outside-look, ...
 * PARAMETERS
 *  handle      [IN]        
 *  focus       [IN]        (Hack: not to send notification)
 * RETURNS
 *  
 *****************************************************************************/
int HDIa_widgetSetInFocus(MSF_UINT32 handle, int focus)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    widget_header_struct *p;
    widget_header_struct *a;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (!handle)
    {
        return 0;
    }

    p = _H(handle)->parent;
    if (!p)
    {
        return 0;
    }

    widget_get_active_childs(a, p);
    ///////////////////////////////////////////////////////////
    // get focus
    if (focus == 1)
    {
        if (a != _H(handle))
        {
            if (!IS_GADGET_TYPE(handle))    /* Any screen or window */
            {
                WGUI_CTX->is_painted_after_first_focus_changed = 0;
                widget_on_window_focus_changed();
            }

            widget_set_active_childs(p, _H(handle));

            /*
             * In paintbox, MsfNotifyFocus and MsfNotifyLostFocus usually represents a mouse event. 
             * * It might cause unexpected side effects.
             */
            if (a != NULL)
            {
                if (!IS_PAINTBOX_TYPE(p))
                {
                    widget_notify(_H(a), MsfNotifyLostFocus);
                }
    
                if (IS_FORM_TYPE(a))
                {
                    widget_form_on_defocused(_H(a));
                }
            }

            // TODO: If we set focus to another "screen", should we set MsfNotifyLostFocus to the old "window"?

            if (IS_SCREEN_TYPE(handle))
            {
                widget_header_struct *child;

                widget_get_active_childs(child, handle);

                if (child)
                {
                    kal_bool clear_screen_flag = KAL_TRUE;

                    if ((_H(a)->module_id == MSF_MODID_MEA && _H(handle)->module_id == MSF_MODID_SMA) || 
                        (_H(a)->module_id == MSF_MODID_SMA && _H(handle)->module_id == MSF_MODID_MEA))
                    {
                        /* If changing force in MEA and SMA MsfScreen, we don't want to clear screen */
                        clear_screen_flag = KAL_FALSE;
                    }
                    if (clear_screen_flag)
                    {
						if (!WGUI_CTX->current_window && IS_DIALOG_TYPE(child))
						{
                           /*
                            * If show MSfWindow in widget screen and it is MsfDialog,
                            * we will clear all screen
                            */
							clear_screen();
						}
						else
						{
							/* If change screen, we should clear screen first. */
							widget_clear(&WGUI_CTX->default_display_size, &WGUI_CTX->display_pos);
						}
                    }

                    HDIa_widgetSetInFocus((MSF_UINT32) child, 1);
                }
            }
        }

        /* If we send notification here. It might enter infinite loop in BRS */
        /* widget_notify(_H(handle),MsfNotifyFocus); */

        /* Tell BRS to update paintbox content */
        if (IS_PAINTBOX_TYPE(handle))
        {
            widget_clear(&WGUI_CTX->default_display_size, &WGUI_CTX->display_pos);
            widget_notify(_H(handle), MsfNotifyStateChange);
        }
        else if (IS_FORM_TYPE(handle))
        {
            widget_form_on_focused(_H(handle));
        }

        widget_send_update_event_to_wap();

        widget_set_current_object(_H(handle));
        widget_set_current_focus(_H(handle), KAL_TRUE);

        widget_paint();
    }
    /////////////////////////////////////////////////////////
    // lose focus
    else    /* focus == 0 || focus == -1 */
    {
        // TODO: Defocusing a gadget and a window/screen is different
        if (a == _H(handle))    /* handle is the active child */
        {
            if (!IS_GADGET_TYPE(handle))    /* Any screen or window */
            {
                WGUI_CTX->is_painted_after_first_focus_changed = 0;
                widget_on_window_focus_changed();
            }
            // It might cause problems
            //                      widget_notify(_H(handle),MsfNotifyLostFocus);

            if (IS_FORM_TYPE(handle))
            {
                widget_form_on_defocused(_H(handle));
            }

            widget_get_next_active_childs(a, p);
            if (a != NULL)  /* Focus to next node */
            {
                widget_hide_active_childs(p, handle);

                if (focus != -1)    /* Maybe we should always send notification */
                {
                    /*
                     * In paintbox, MsfNotifyFocus and MsfNotifyLostFocus usually represents a mouse event. 
                     * * It might cause unexpected side effects.
                     */
                    if (!IS_PAINTBOX_TYPE(p))
                    {
                        widget_notify(_H(a), MsfNotifyFocus);
                    }
                }

                /* e.g. A SEC screen disappear, BRS screen is focused, the paintbox should also be focused */
                if (IS_SCREEN_TYPE(a))
                {
                    widget_header_struct *child;

                    widget_get_active_childs(child, a);

                    if (child)
                    {
                        kal_bool clear_screen_flag = KAL_TRUE;

                        if ((_H(a)->module_id == MSF_MODID_MEA && _H(handle)->module_id == MSF_MODID_SMA) || 
                            (_H(a)->module_id == MSF_MODID_SMA && _H(handle)->module_id == MSF_MODID_MEA))
                        {
                            /* If changing force in MEA and SMA MsfScreen, we don't want to clear screen */
                            clear_screen_flag = KAL_FALSE;
                        }
                        if (clear_screen_flag)
                        {
                            /* If change screen, we should clear screen first. */
                            widget_clear(&WGUI_CTX->default_display_size, &WGUI_CTX->display_pos);
                        }

                        HDIa_widgetSetInFocus((MSF_UINT32) child, 1);
                    }
                }
                else if (IS_FORM_TYPE(a))   /* For example. Remove another window and the focus is changed to a form */
                {
                    widget_form_on_focused(_H(a));
                }
                else if (IS_PAINTBOX_TYPE(a))
                {
                    // if paintbox window is in focus, we should prepare a clear screen
                    // for paintbox use.
                    widget_clear(&WGUI_CTX->default_display_size, &WGUI_CTX->display_pos);

                    /* let BRS to update paintbox content */
                    widget_notify(_H(a), MsfNotifyStateChange);
                }

                widget_set_current_object(_H(a));

            }

            widget_send_update_event_to_wap();
            widget_paint();
        }
    }

    return 1;
}