⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 event_mouse.c.svn-base

📁 A Flash Player with ActionScript support. Write in C and C++. It have two part, one is Player and an
💻 SVN-BASE
字号:
#include <stdio.h>#include <glib.h>#include <assert.h>#include "player_pub.h"#include "base_types.h"#include "instance.h"#include "swf_file_pub.h"#include "dynamic_text_ins.h"#include "dynamic_text_def.h"#include "spliter_pub.h"#include "render_pub.h"#include "movie_clips_ins.h"#include "button_ins.h"#include "button_def.h"#include "xwin_pub.h"#include "xwin_event.h"#include "action.h"#include "action_fortest.h"#include "drag_drop.h"#include <string.h>#if WITH_DMALLOC#include <dmalloc.h>#endifextern player_t      	*player_p;int	     		moved;GSList 			*sort_list;int			be_eatted;/* * 任何鼠标事件发生,所有 button 均需重新计算状态. * 然后根据状态切换的情况,决定需执行的事件. */static gboolean event_mouse_do(GNode* node_p,gpointer fr_in_p) {    instance_t  *data_p = (instance_t*)(node_p->data);    swf_file_t	*swf_p = data_p->swf_p;    flash_event_t *fe_p = (flash_event_t*)fr_in_p;    btn_ins_t	*bp_data_p;    dtx_ins_t	*dtx_data_p;    mc_ins_t	*mc_data_p;    to_exec_t 	*to_exec_p;    struct ActionRecord *p;    if (node_p->parent == NULL)        return FALSE;    /*    if ((data_p->ins_type == INS_BTN) && ((btn_ins_t*)data_p)->hit_test){    } else {    */    if (data_p->visible == FALSE)        return FALSE;    //    };//    printf("event do %s\n",data_p->name_p);    switch (data_p->ins_type) {    case INS_BTN:        bp_data_p=(btn_ins_t*)data_p;        bp_data_p->last_state = bp_data_p->current_state;        switch (fe_p->event_type) {        case EVENT_MOTION_NOTIFY:            if (moved)                break;            if ((!be_eatted) && (rect_is_point_in(&bp_data_p->hit_area,fe_p->x,fe_p->y))) {                bp_data_p->current_state = bp_data_p->current_state|BtnStateOver; //	over             //   printf("I eat it 1\n");                be_eatted = 1;            } else {                bp_data_p->current_state = bp_data_p->current_state & (~BtnStateOver); // out            }            if (player_p->drag_obj.node_p) {                drag_ing(fe_p->x, fe_p->y);            };            moved = TRUE;            break;        case EVENT_BUTTON_PRESS:            if ((!be_eatted) && (rect_is_point_in(&bp_data_p->hit_area,fe_p->x,fe_p->y))) {                bp_data_p->current_state = BtnStateDown|BtnStateOver; 	// over down             //   printf("I eat it 2\n");                be_eatted = 1;            } else {                bp_data_p->current_state = BtnStateDown;		// out  down            }            break;        case EVENT_BUTTON_RELEASE:            if ((!be_eatted) && (rect_is_point_in(&bp_data_p->hit_area,fe_p->x,fe_p->y))) {                bp_data_p->current_state = BtnStateOver;	// over up             //   printf("I eat it 3\n");                be_eatted = 1;            } else {                bp_data_p->current_state = 0;			// out up            }            break;        };        if (bp_data_p->last_state != bp_data_p->current_state) {            p = btn_on_event(node_p);            //   btn_ins_update_children(node_p);		// XXX 放在这里有些浪费时间,每桢做一次即可.            if (p) {             //   printf("event on button have as\n");                to_exec_p = g_new0(to_exec_t,1);                to_exec_p->as_p = p;                to_exec_p->name_p = ins_node_to_name(node_p->parent);                player_p->actionq_p = g_slist_append(player_p->actionq_p,to_exec_p);                //		printf("---------after append \n");            };        };        break;    case INS_MC:        mc_data_p=(mc_ins_t*)data_p;        switch (fe_p->event_type) {        case EVENT_BUTTON_PRESS:            if ((mc_data_p->actions_p) && (mc_data_p->actions_p->ClipEventMouseDownP)) {                if ((!be_eatted) && (rect_is_point_in(&data_p->boundary,fe_p->x,fe_p->y))) {                    to_exec_p = g_new0(to_exec_t,1);                    to_exec_p->as_p = mc_data_p->actions_p->ClipEventMouseDownP;                    to_exec_p->name_p = ins_node_to_name(node_p);                    player_p->actionq_p = g_slist_append(player_p->actionq_p,to_exec_p);                    be_eatted = 1;                 //   printf("I eat it 4\n");                };            }            break;        case EVENT_BUTTON_RELEASE:            if ((mc_data_p->actions_p) && (mc_data_p->actions_p->ClipEventMouseUpP)) {                if ((!be_eatted) && (rect_is_point_in(&data_p->boundary,fe_p->x,fe_p->y))) {                    to_exec_p = g_new0(to_exec_t,1);                    to_exec_p->as_p = mc_data_p->actions_p->ClipEventMouseUpP;                    to_exec_p->name_p = ins_node_to_name(node_p);                    player_p->actionq_p = g_slist_append(player_p->actionq_p,to_exec_p);                    be_eatted = 1;             //       printf("I eat it 5\n");                };            };            break;        };        break;    case INS_DTX:  			// 如果点击可编辑的 DTX 则将输入焦点赋给它        dtx_data_p=(dtx_ins_t*)data_p;        switch (fe_p->event_type) {        case EVENT_BUTTON_PRESS:            if (((struct DefineEditText*)dtx_data_p->define_p)->Flags & EditTextReadOnly)                break;            dtx_data_p->focusd = FALSE;            if ((!be_eatted) && (rect_is_point_in(&data_p->boundary,fe_p->x,fe_p->y))) {                dtx_data_p->focusd = TRUE;                printf("---------focused------- \n");                free(swf_p->focused_name);                swf_p->focused_name=ins_node_to_name(node_p);                be_eatted = 1;              //  printf("I eat it 6\n");            };            break;        };        break;    default:        break;    };    //		printf("out event_mouse do \n");    return FALSE;};static gboolean event_mouse_do1(GNode* node_p,gpointer fr_in_p) {    sort_list = g_slist_prepend(sort_list, node_p);    return FALSE;};// 输入 flash event 输出 to_exec_t// 找出接 fe_p 的事件,装在 to_exec_t 中返回.void event_mouse(GNode *node_p,flash_event_t *fe_p) {    GSList *p;    sort_list = NULL;    g_node_traverse(node_p,G_PRE_ORDER,G_TRAVERSE_ALL,-1,event_mouse_do1,fe_p);    p = sort_list;    be_eatted = 0;    while ( p ) {        event_mouse_do(p->data,fe_p);        p = p->next;    };    g_slist_free(sort_list);    return;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -