osx_button.c
Go to the documentation of this file.
00001 
00023 #include <stdio.h>
00024 #include <inttypes.h>
00025 #include "osx_button.h"
00026 
00027 /* Not an error, see comments in generated file. */
00028 #include "gen/osx_button_gen.c"
00029 
00033 typedef struct osx_button_data_st_ {
00035     uint64_t id;
00036 } osx_button_data_st;
00037 
00044 static void
00045 osx_button_button_paint (button_handle button_h)
00046 {
00047     osx_button_handle osx_button_h = button_cast_to_osx_button(button_h);
00048 
00049     if (NULL == osx_button_h) {
00050         return;
00051     }
00052 
00053     printf("I'm an OSXButton with ID %"PRIu64"\n",
00054            osx_button_h->osx_button_data_h->id);
00055 }
00056 
00065 static void
00066 osx_button_data_delete (osx_button_data_handle *osx_button_data_h)
00067 {
00068     if ((NULL == osx_button_data_h) || (NULL == *osx_button_data_h)) {
00069         return;
00070     }
00071 
00072     free(*osx_button_data_h);
00073     *osx_button_data_h = NULL;
00074 }
00075 
00084 static bool
00085 osx_button_data_create (osx_button_data_handle *osx_button_data_h,
00086                         void *context)
00087 {
00088     osx_button_data_st *data;
00089     uint64_t button_id;
00090 
00091     if ((NULL == osx_button_data_h) || (NULL == context)) {
00092         return (false);
00093     }
00094 
00095     button_id = *((uint64_t *) context);
00096 
00097     data = calloc(1, sizeof(*data));
00098     if (NULL == data) {
00099         return (false);
00100     }
00101 
00102     /* Initialize the data */
00103     data->id = button_id;
00104 
00105     *osx_button_data_h = data;
00106 
00107     return (true);
00108 }
00109 
00116 osx_button_handle
00117 osx_button_new1 (uint64_t id)
00118 {
00119     osx_button_st *osx_button = NULL;
00120     bool rc;
00121 
00122     osx_button = calloc(1, sizeof(*osx_button));
00123     if (NULL != osx_button) {
00124         rc = osx_button_init(osx_button, &id);
00125         if (!rc) {
00126             goto err_exit;
00127         }
00128     }
00129 
00130     return (osx_button);
00131 
00132 err_exit:
00133 
00134     osx_button_delete(osx_button);
00135 
00136     return (NULL);
00137 }
 All Classes Files Functions Variables Typedefs