📄 object.h
字号:
typedef struct t_event {
l_dword type; /* type of event */
l_dword message; /* message of event */
p_object obj; /* pointer to object that made event */
l_int time;
void *info;
l_char reserved[20];
} t_event;
extern t_event event_main;
extern l_big event_timer;
extern p_object event_stop;
/*
t_point structure
*/
typedef struct t_point {
l_rect x;
l_rect y;
} t_point;
/*
rectangle structure
*/
typedef struct t_rect {
struct t_point a;
struct t_point b;
} t_rect;
extern t_rect rect_empty;
/* process definition */
extern l_bool go_process;
#define PROCESS_ACTIVE true
#define PROCESS_PASSIVE false
#define ACTIVE_PROCESS(o) OBJECT(o)->process = PROCESS_ACTIVE
#define PASSIVE_PROCESS(o) OBJECT(o)->process = PROCESS_PASSIVE
#define REMOVE_PROCESS(o) OBJECT(o)->process = PROCESS_PASSIVE
#define GET_PROCESS(o) OBJECT(o)->process
#define RESET_PROCESS(o,pr) OBJECT(o)->process = (pr)
#define IS_ACTIVE_PROCESS(o) (OBJECT(o)->process == PROCESS_ACTIVE)
#define PLAY_PROCESS(o,ev) OBJECT(o)->play_process(o, ev)
#define IS_OKTOSUBPROCESS(o) 1
#define STOP_PROCESS() go_process = false
#define START_PROCESS() go_process = true
int program_int ( void );
#define INTMAIN(e) program.translate_event(&program, e);
/*
main object structure
*/
typedef struct t_object {
l_dword tag; /* tag of object = id of object type */
l_dword state; /* current state of object */
l_dword options; /* options of object */
l_dword end_state;
l_int phase; /* current phase of process for sub objects */
l_int tick;
l_tag data_type;
l_process process;
l_big process_time;
l_int process_tick;
p_object owner; /* the parent of object */
p_object next; /* next object */
p_object prev; /* previous object */
p_object last; /* the last sub object */
p_object prefer; /* the sub object, that is prefere */
l_char reserved[48];
l_bool (*done) ( p_object o );
p_object (*find_match_view) ( p_object o, l_dword sta, l_dword opt, l_bool forward );
p_object (*find_match) ( p_object o, l_dword sta, l_dword opt, l_bool forward );
p_object (*owner_view) ( p_object o );
p_object (*next_view) ( p_object o );
p_object (*prev_view) ( p_object o );
p_object (*last_view) ( p_object o );
p_object (*first_view) ( p_object o );
p_object (*next_to_last) ( p_object o );
p_object (*prev_to_first) ( p_object o );
p_object (*prev_view_to_first) ( p_object o );
p_object (*next_view_to_last) ( p_object o );
void (*setup) ( p_object o );
void (*after_init) ( p_object o );
p_object (*insert) ( p_object o, p_object sub );
p_object (*insert_before) ( p_object o, p_object sub, p_object before );
void (*put_in_front_of) ( p_object o, p_object before );
void (*remove) ( p_object o, p_object sub );
p_object (*first) ( p_object o );
l_bool (*select) ( p_object o );
void (*set_state) ( p_object o, l_dword st, l_bool set );
void (*set_options) ( p_object o, l_dword op, l_bool set );
l_bool (*is_state) ( p_object o, l_dword st );
l_bool (*is_options) ( p_object o, l_dword op );
p_object (*at) ( p_object o, l_long index );
l_long (*index_of) ( p_object o, p_object p );
void (*func_callback) ( p_object s );
int (*put_into_stillprocess) ( p_object o, p_object s );
int (*clear_from_stillprocess) ( p_object o, p_object s );
l_bool (*get_data) ( p_object o, t_data *rec );
l_bool (*set_data) ( p_object o, t_data *rec );
l_bool (*select_data) ( p_object o, l_int data_style, l_bool set );
void (*set_prefer) ( p_object o, p_object prefer );
void (*reset_prefer) ( p_object o );
l_dword (*valid) ( p_object o, l_dword msg );
void (*get_event) ( p_object o, t_event *event );
void (*put_event) ( p_object o, t_event *event );
l_dword (*execute) ( p_object o );
void (*play_process) ( p_object o, t_event *event );
void (*for_each_event) ( p_object o, t_event *event );
void (*translate_event) ( p_object o, t_event *event );
} t_object;
extern t_object program;
#define OBJECT(o) ((p_object)(o))
/* others functions */
void _afree ( void **p );
#define afree(x) _afree((void**)(x));
/* time functions */
void aclock ( void );
l_big time_get_mili ( void );
l_big time_diff_mili ( l_big mili );
#define _time_get_mili() ((l_big)atimer)
#define _time_diff_mili(m) ((l_big)atimer-(l_big)(m))
/* string function */
l_text set_format_text_nice ( l_text *dest, l_int size, l_text format, ... ); // To do ....
/* other object functions */
l_bool is_active ( t_object *e );
l_bool is_my_object ( t_object *o, t_object *e );
#define is_my_message(o,e) is_my_object(o, e->obj)
/* first in first out */
l_ptr fifo_add ( l_ptr list, l_ptr src, l_int size, l_int where );
l_ptr fifo_get ( l_ptr *list, l_int size, l_int where );
#define fifo_add_rect(l,s,w) ((t_rect*)fifo_add((l_ptr)l, (l_ptr)s, sizeof(t_rect), w))
#define fifo_get_rect(l,w) ((t_rect*)fifo_get((l_ptr*)l, sizeof(t_rect), w))
/* origin function */
t_point point_assign ( l_rect x, l_rect y );
t_rect rect_assign ( l_rect ax, l_rect ay, l_rect bx, l_rect by );
t_rect rect_move ( t_rect r, l_rect mx, l_rect my );
t_point rect_size ( t_rect r );
t_rect rect_cliped ( t_rect r, t_rect d );
l_bool rect_overlay ( t_rect r, t_rect d );
l_rect rect_sizex ( t_rect r );
l_rect rect_sizey ( t_rect r );
l_bool rect_check_empty ( t_rect r );
l_bool rect_equals ( t_rect r, t_rect nr );
l_bool rect_contains ( t_rect r, t_point p );
void rect_double_overlay ( t_rect* fr, t_rect *lr );
/* object functions */
extern t_object *(*obj_init) ( t_object *o );
t_object *_obj_init ( t_object *o );
l_bool obj_done ( p_object o );
p_object obj_find_match_view ( p_object o, l_dword sta, l_dword opt, l_bool forward );
p_object obj_find_match ( p_object o, l_dword sta, l_dword opt, l_bool forward );
t_object* obj_owner_view ( p_object o );
t_object* obj_next_view ( p_object o );
t_object* obj_prev_view ( p_object o );
t_object* obj_last_view ( p_object o );
t_object* obj_first_view ( p_object o );
p_object obj_next_to_last ( p_object o );
p_object obj_prev_to_first ( p_object o );
t_object* obj_prev_view_to_first ( p_object o );
t_object* obj_next_view_to_last ( p_object o );
void obj_after_init ( p_object o );
void obj_setup ( p_object o );
t_object* obj_insert ( p_object o, p_object sub );
t_object* obj_insert_before ( p_object o, p_object sub, p_object before );
void obj_put_in_front_of ( p_object o, p_object before );
void obj_remove ( p_object o, p_object sub );
t_object* obj_first ( p_object o );
l_bool obj_select ( p_object o );
void obj_set_state ( p_object o, l_dword st, l_bool set );
void obj_set_options ( p_object o, l_dword ot, l_bool set );
l_bool obj_is_state ( p_object o, l_dword st );
l_bool obj_is_options ( p_object o, l_dword ot );
int obj_put_into_stillprocess ( p_object o, p_object s );
int obj_clear_from_stillprocess ( p_object o, p_object s );
l_bool obj_get_data ( p_object o, t_data *rec );
l_bool obj_set_data ( p_object o, t_data *rec );
l_bool obj_select_data ( p_object o, l_int data_style, l_bool set );
p_object obj_at ( p_object o, l_long index );
l_long obj_index_of ( p_object o, p_object p );
void obj_set_prefer ( p_object o, p_object prefer );
void obj_reset_prefer ( p_object o );
l_dword obj_execute ( p_object o );
l_dword obj_valid ( p_object o, l_dword msg );
void obj_get_event ( p_object o, t_event *event );
void obj_put_event ( p_object o, t_event *event );
void obj_play_process ( p_object o, t_event *event );
void obj_for_each_event ( p_object o, t_event *event );
void obj_translate_event ( p_object o, t_event *event );
t_object* dispose ( t_object *o );
void dispose_all ( t_object *o );
void init_stillprocess ( p_object o, l_int milis );
#define done_stillprocess(o) init_stillprocess(o, -1)
void set_event ( t_event *event, l_dword type, l_dword message, p_object obj );
void set_event_info ( t_event *event, l_dword type, l_dword message, p_object obj, void *rec );
void message_all_info ( l_dword type, l_dword message, p_object obj, void *info );
void message_info ( p_object o, l_dword type, l_dword message, p_object obj, void *info );
#define message(o,t,m,ob) message_info(o,t,m,ob,NULL)
#define message_all(t,m,ob) message_all_info(t,m,ob,NULL)
l_ptr copy_type ( l_ptr what, l_long size );
#define obj_exist(o) (o ? OBJECT(o)->tag: -1)
#define WHILE(t) while(program_int()&&(##t))
#define FOR(t1,t2,t3) for((##t1);program_int()&&(##t2);(##t3))
#define _while(t) WHILE(t)
#define _for(t1,t2,t3) FOR(t1,t2,t3)
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -