#ifndef _ANOD_TEXT_PAGE_ #define _ANOD_TEXT_PAGE_ #include #define INPUT(type) type #define OUTPUT(type) type* typedef uint32_t atp_counter_t; typedef int32_t atp_itemval_t; typedef const char* atp_text_t; typedef uint8_t atp_boolean_t; typedef uint8_t atp_pageopt_t; typedef uint8_t atp_color_t; typedef uint8_t atp_placement_t; typedef uint8_t atp_error_t; typedef void * atp_callerdata_t; // error type #define ATP_SUCCESS 0 #define ATP_POWER_OFF 1 #define ATP_INDEX_OUTOFRANGE 2 #define ATP_NO_ACTION 3 #define ATP_INVALID_VALUE 4 // color type SAME AS console #define ATP_COLOR_LIGHT 0 #define ATP_COLOR_RED 1 #define ATP_COLOR_GREEN 2 #define ATP_COLOR_YELLOW 3 #define ATP_COLOR_BLUE 4 #define ATP_COLOR_MAGENTA 5 #define ATP_COLOR_CYAN 6 #define ATP_COLOR_WHITE 7 // text align #define ATP_PLACEMENT_LEFT 0 #define ATP_PLACEMENT_RIGHT 1 #define ATP_PLACEMENT_CENTER 2 // page option #define ATP_PAGE_NOOPTION 0 // 1 reserve for power off #define ATP_PAGE_UPDATE 2 // UPDATE THE CURSOR ROW #define ATP_PAGE_REFRESH 3 // UPDATE THE WHOLE PAGE #define ATP_PAGE_DOSELECT 4 // SAME AS SELECT #define ATP_PAGE_PREVITEM 5 #define ATP_PAGE_NEXTITEM 6 #define ATP_PAGE_PREVPAGE 7 #define ATP_PAGE_NEXTPAGE 8 typedef struct { atp_text_t text; atp_text_t extra_text; atp_itemval_t value; atp_color_t text_color; atp_color_t extra_text_color; } atp_itemcfg_t; typedef struct { atp_text_t text; atp_color_t text_color; atp_placement_t text_align; } atp_linecfg_t; typedef atp_error_t (*atp_lineprovider_t)( INPUT(atp_callerdata_t) some_data_provided_by_caller, INPUT(atp_counter_t) line_index_of_this_page, OUTPUT(atp_linecfg_t) configuration_of_this_line ); typedef atp_error_t (*atp_itemprovider_t)( INPUT(atp_callerdata_t) some_data_provided_by_caller, INPUT(atp_counter_t) index_of_current_option_item, OUTPUT(atp_itemcfg_t) configuration_of_current_option_item ); typedef atp_pageopt_t (*atp_keyhandler_t)( INPUT(atp_callerdata_t) some_data_provided_by_caller, INPUT(atp_counter_t) index_of_selected_item, INPUT(atp_boolean_t) is_x_key_down, INPUT(atp_boolean_t) is_y_key_down, INPUT(atp_boolean_t) is_l_key_down, INPUT(atp_boolean_t) is_r_key_down, INPUT(atp_boolean_t) is_start_key_down, INPUT(atp_boolean_t) is_select_key_down ); extern atp_error_t atp_show( INPUT(atp_counter_t) line_count_of_this_page, INPUT(atp_lineprovider_t) line_information_provider, INPUT(atp_callerdata_t) some_data_from_caller ); extern atp_error_t atp_select( INPUT(atp_text_t) title_lessthan_9lines_for_this_select_page, INPUT(atp_counter_t) item_count_exclude_title_of_this_select_page, INPUT(atp_itemprovider_t) item_information_provider, INPUT(atp_keyhandler_t) extra_key_handler, INPUT(atp_callerdata_t) some_data_from_caller, INPUT(atp_counter_t) index_of_default_selected_item, INPUT(atp_boolean_t) ignore_no_action, OUTPUT(atp_itemval_t) value_of_select_item ); extern atp_error_t atp_tips( INPUT(atp_text_t) tips_at_bottom_left, INPUT(atp_text_t) tips_at_bottom_right ); #undef INPUT #undef OUTPUT #endif//_ANOD_TEXT_PAGE_