Go to the documentation of this file.00001
00027
00028
00029
00030
00031
00032 #include "osx_button_gen.h"
00033 #include "button_friend_gen.h"
00034
00035
00036
00037
00042 typedef struct osx_button_data_st_ *osx_button_data_handle;
00043
00044
00045
00046
00047
00048
00049 static void
00050 osx_button_data_delete(osx_button_data_handle *osx_button_data_h);
00051
00052 static bool
00053 osx_button_data_create(osx_button_data_handle *osx_button_data_h, void *context);
00054
00055 static void
00056 osx_button_button_paint(button_handle button_h);
00057
00058
00059
00061 typedef struct osx_button_st_ {
00063 button_st button;
00065 osx_button_data_handle osx_button_data_h;
00066 } osx_button_st;
00067
00068
00069
00070
00071
00078 static osx_button_handle
00079 button_cast_to_osx_button (button_handle button_h)
00080 {
00081 osx_button_handle osx_button_h = NULL;
00082
00083 if (NULL != button_h) {
00084 osx_button_h = (osx_button_handle) ((uint8_t *) button_h -
00085 offsetof(osx_button_st, button));
00086 }
00087
00088 return (osx_button_h);
00089 }
00090
00097 button_handle
00098 osx_button_cast_to_button (osx_button_handle osx_button_h)
00099 {
00100 button_handle button_h = NULL;
00101
00102 if (NULL != osx_button_h) {
00103 button_h = &(osx_button_h->button);
00104 }
00105
00106 return (button_h);
00107 }
00108
00116 void
00117 osx_button_delete (osx_button_handle osx_button_h)
00118 {
00119 if (NULL == osx_button_h) {
00120 return;
00121 }
00122
00123 osx_button_data_delete(&(osx_button_h->osx_button_data_h));
00124
00125 button_friend_delete(&(osx_button_h->button));
00126
00127 free(osx_button_h);
00128 }
00129
00135 static void
00136 osx_button_button_delete (button_handle button_h)
00137 {
00138 if (NULL == button_h) {
00139 return;
00140 }
00141
00142 osx_button_delete(button_cast_to_osx_button(button_h));
00143 }
00144
00148 static button_vtable_st button_vtable = {
00149 osx_button_button_paint,
00150 osx_button_button_delete
00151 };
00152
00160 static bool
00161 osx_button_init (osx_button_handle osx_button_h, void *context)
00162 {
00163 bool rc = false;
00164 bool button_initialized = false;
00165 bool osx_button_data_created = false;
00166
00167 if (NULL == osx_button_h) {
00168 return (false);
00169 }
00170
00171 rc = button_init(&(osx_button_h->button));
00172 if (!rc) {
00173 goto err_exit;
00174 }
00175 button_initialized = true;
00176
00177 rc = button_set_vtable(&(osx_button_h->button),
00178 &button_vtable);
00179 if (!rc) {
00180 goto err_exit;
00181 }
00182
00183 rc = osx_button_data_create(&(osx_button_h->osx_button_data_h), context);
00184 if (!rc) {
00185 goto err_exit;
00186 }
00187 osx_button_data_created = true;
00188
00189 return (true);
00190
00191 err_exit:
00192
00193 if (osx_button_data_created) {
00194 osx_button_data_delete(&(osx_button_h->osx_button_data_h));
00195 }
00196
00197 if (button_initialized) {
00198 button_friend_delete(&(osx_button_h->button));
00199 }
00200
00201 return (rc);
00202 }