00001
00005
00006
00007
00008
00009
00010
00011
00012
00013 #define BPRESSED_CALL 2345
00014 #define CBANIMATION_CALL 6574
00015
00016
00017
00018 #define BCOLOR(r, g, b, a) al_map_rgba(r, g, b, a)
00019
00020
00021
00022 #define TDEFAULT al_map_rgba(0, 0, 0, 255)
00023 #define BDEFAULT al_map_rgba(255, 255, 255, 255)
00024 #define BRED al_map_rgba(255, 0, 0, 255)
00025 #define BGREEN al_map_rgba(0, 255, 0, 255)
00026 #define BBLUE al_map_rgba(0, 0, 255, 255)
00027 #define BBLACK al_map_rgba(0, 0, 0, 255)
00028 #define BWHITE al_map_rgba(255, 255, 255, 255)
00029 #define BHTRANSPARENT al_map_rgba(255, 255, 255, 127)
00030 #define BQTRANSPARENT al_map_rgba(255, 255, 255, 191)
00031 #define WHTRANSPARENT al_map_rgba(0, 0, 0, 127)
00032 #define WQTRANSPARENT al_map_rgba(0, 0, 0, 191)
00033
00034
00035
00036 typedef enum button_properties {
00037 BVISIBLE = 0x1,
00038 BMOUSEOVER = 0x2,
00039 BLPRESSED = 0x4,
00040 BLRELEASED = 0x8,
00041 BRPRESSED = 0x10,
00042 BRRELEASED = 0x20,
00043 BMPRESSED = 0x40,
00044 BMRELEASED = 0x80,
00045 BDRAW = 0x100
00046 } BPROPERTIES;
00047
00048
00049
00050 typedef enum standard_button_animations {
00051 BSHIFTRIGHT,
00052 BBOUNCEVERT,
00053 BBOUNCEHORZ,
00054 BSHIFTLEFT,
00055 SBNONE,
00056 SBRIGHT,
00057 SBLEFT,
00058 SBUP,
00059 SBDOWN
00060 } SBANIMATIONS;
00061
00062
00063
00064 typedef enum custom_button_animations {
00065 BRIGHT,
00066 BLEFT,
00067 BUP,
00068 BDOWN,
00069 BNONE
00070 } CBANIMATIONS;
00071
00072
00073
00074 typedef struct button_images {
00075 char *label;
00076 ALLEGRO_BITMAP *button_image;
00077 float width;
00078 float height;
00079 struct button_images *nextbimage;
00080 struct button_images *prevbimage;
00081 } BIMAGES, *BIMAGESPTR;
00082
00083
00084
00085 typedef struct button_text {
00086 char *text;
00087 ALLEGRO_FONT *text_f;
00088 ALLEGRO_COLOR text_c;
00089 } BTEXT, *BTEXTPTR;
00090
00091
00092
00093 typedef struct button_data {
00094 float x;
00095 float y;
00096 float ox;
00097 float oy;
00098 float limit;
00099 int alpha;
00100 ALLEGRO_COLOR b_color;
00101 SBANIMATIONS sflags;
00102 CBANIMATIONS aflags;
00103 BPROPERTIES bflags;
00104 } BDATA, *BDATAPTR;
00105
00106
00107
00108 typedef struct buttons {
00109 char *blabel;
00110 BIMAGESPTR bimage;
00111 BTEXT btext;
00112 BDATA bdata;
00113 struct buttons *nextbutton;
00114 struct buttons *prevbutton;
00115 } BUTTON, *BUTTONPTR;
00116
00117
00118
00119 typedef void* (*BUTTON_CALLBACK)(BUTTONPTR, void*, int);
00120
00121
00122
00123 BUTTONPTR get_first_element_from_button_list(void);
00124
00125
00126
00127 BIMAGESPTR get_first_element_from_button_image_list(void);
00128
00129
00130
00131 BUTTONPTR set_first_element_in_button_list(BUTTONPTR *newfirst);
00132
00133
00134
00135 BUTTONPTR create_new_button(char *label, char *bimage_label,
00136 char *text, ALLEGRO_FONT *font,
00137 ALLEGRO_COLOR text_color, ALLEGRO_COLOR button_color,
00138 float x, float y, float limit,
00139 CBANIMATIONS aflags, BPROPERTIES bflags,
00140 _Bool add_to_list);
00141
00142
00143
00144 BUTTONPTR add_element_to_button_list(BUTTONPTR *button);
00145
00146
00147
00148 BUTTONPTR remove_element_from_button_list(BUTTONPTR *currentptr);
00149
00150
00151
00152 BUTTONPTR search_button_list_for_element(BUTTONPTR *firstptr, char *label);
00153
00154
00155
00156 BUTTONPTR set_bflags_on_button(BUTTONPTR button, BPROPERTIES bflags);
00157
00158
00159
00160 BUTTONPTR remove_bflags_on_button(BUTTONPTR button, BPROPERTIES bflags);
00161
00162
00163
00164 _Bool empty_button_list(BUTTONPTR firstptr);
00165
00166
00167
00168 BIMAGESPTR create_new_button_image_list(char *labels[], char *images[], int num_elements);
00169
00170
00171
00172 BIMAGESPTR add_element_to_button_image_list(BIMAGESPTR *firstptr, BIMAGESPTR *newptr);
00173
00174
00175
00176 BIMAGESPTR remove_element_from_button_image_list(BIMAGESPTR *firstptr, BIMAGESPTR *currentptr);
00177
00178
00179
00180 BIMAGESPTR search_button_image_list_for_element(BIMAGESPTR firstptr, char *label);
00181
00182
00183
00184 _Bool empty_button_image_list(BIMAGESPTR firstptr);
00185
00186
00187
00188 BUTTON_CALLBACK set_button_callback(BUTTON_CALLBACK bcallb_func);
00189
00190
00191
00192 BUTTON_CALLBACK get_button_callback(void);
00193
00194
00195
00196 void buttoncheck(BUTTON_CALLBACK bcallb_func, void *data);
00197
00198
00199
00200 _Bool is_mouse_over_button(ALLEGRO_MOUSE_STATE *mouse, BUTTONPTR currentptr);
00201
00202
00203
00204 _Bool is_point_over_button(int x, int y, BUTTONPTR currentptr);
00205
00206
00207
00208 void check_for_button_events(BUTTONPTR currentptr);
00209
00210
00211
00212 void render_buttons(void);
00213
00214
00215
00216 void draw_button(BUTTONPTR currentptr);
00217
00218
00219
00220 SBANIMATIONS set_standard_button_animation(SBANIMATIONS sb_new);
00221
00222
00223
00224 SBANIMATIONS get_standard_button_animation(void);
00225
00226
00227
00228 BUTTONPTR standard_button_animations(BUTTONPTR button);
00229
00230
00231
00232 BUTTONPTR custom_button_animations(BUTTONPTR button, CBANIMATIONS cb, float limit, BUTTON_CALLBACK bcall,
00233 void *data);
00234
00235
00236
00237
00238
00239