Go to the documentation of this file.00001
00023 #include "osx_button.h"
00024
00025
00026 #include "gen/osx_factory_gen.c"
00027
00031 typedef struct osx_factory_data_st_ {
00033 uint64_t next_button_id;
00034 } osx_factory_data_st;
00035
00043 static button_handle
00044 osx_factory_gui_factory_create_button (gui_factory_handle gui_factory_h)
00045 {
00046 osx_button_handle osx_button_h;
00047 osx_factory_handle osx_factory_h;
00048 button_handle button_h = NULL;
00049 uint64_t id;
00050
00051 osx_factory_h = gui_factory_cast_to_osx_factory(gui_factory_h);
00052
00053 if (NULL == osx_factory_h) {
00054 return (NULL);
00055 }
00056
00057 id = (osx_factory_h->osx_factory_data_h->next_button_id)++;
00058 osx_button_h = osx_button_new1(id);
00059 if (NULL != osx_button_h) {
00060 button_h = osx_button_cast_to_button(osx_button_h);
00061 }
00062
00063 return (button_h);
00064 }
00065
00074 static void
00075 osx_factory_data_delete (osx_factory_data_handle *osx_factory_data_h)
00076 {
00077 if ((NULL == osx_factory_data_h) || (NULL == *osx_factory_data_h)) {
00078 return;
00079 }
00080
00081 free(*osx_factory_data_h);
00082 *osx_factory_data_h = NULL;
00083 }
00084
00093 static bool
00094 osx_factory_data_create (osx_factory_data_handle *osx_factory_data_h,
00095 void * context)
00096 {
00097 osx_factory_data_st *data;
00098
00099 if (NULL == osx_factory_data_h) {
00100 return (false);
00101 }
00102
00103 data = calloc(1, sizeof(*data));
00104 if (NULL == data) {
00105 return (false);
00106 }
00107
00108
00109 data->next_button_id = 1;
00110
00111 *osx_factory_data_h = data;
00112
00113 return (true);
00114 }
00115
00121 osx_factory_handle
00122 osx_factory_new1 (void)
00123 {
00124 osx_factory_st *osx_factory = NULL;
00125 bool rc;
00126
00127 osx_factory = calloc(1, sizeof(*osx_factory));
00128 if (NULL != osx_factory) {
00129 rc = osx_factory_init(osx_factory, NULL);
00130 if (!rc) {
00131 goto err_exit;
00132 }
00133 }
00134
00135 return (osx_factory);
00136
00137 err_exit:
00138
00139 osx_factory_delete(osx_factory);
00140
00141 return (NULL);
00142 }