00001 00092 #include <stdio.h> 00093 #include "win_factory.h" 00094 #include "osx_factory.h" 00095 00101 static void 00102 generate_gui (gui_factory_handle gui_factory_h) 00103 { 00104 button_handle button1 = NULL, button2 = NULL, button3 = NULL; 00105 00106 if (NULL == gui_factory_h) { 00107 return; 00108 } 00109 00110 /* 00111 * The will create some buttons, call their paint functions, and then delete 00112 * them. Use your imagination for much more complicated GUIs being built in 00113 * real life. 00114 */ 00115 button1 = gui_factory_create_button(gui_factory_h); 00116 if (NULL == button1) { 00117 goto err_exit; 00118 } 00119 00120 button2 = gui_factory_create_button(gui_factory_h); 00121 if (NULL == button2) { 00122 goto err_exit; 00123 } 00124 00125 button3 = gui_factory_create_button(gui_factory_h); 00126 if (NULL == button3) { 00127 goto err_exit; 00128 } 00129 00130 button_paint(button1); 00131 button_paint(button2); 00132 button_paint(button3); 00133 00134 button_delete(button1); 00135 button_delete(button2); 00136 button_delete(button3); 00137 00138 return; 00139 00140 err_exit: 00141 00142 if (NULL != button1) { 00143 button_delete(button1); 00144 } 00145 00146 if (NULL != button2) { 00147 button_delete(button2); 00148 } 00149 00150 if (NULL != button3) { 00151 button_delete(button3); 00152 } 00153 } 00154 00158 int 00159 main (int argc, char *argv[]) 00160 { 00161 win_factory_handle win_factory_h; 00162 osx_factory_handle osx_factory_h; 00163 00164 win_factory_h = win_factory_new1(); 00165 if (NULL == win_factory_h) { 00166 return (1); 00167 } 00168 00169 osx_factory_h = osx_factory_new1(); 00170 if (NULL == osx_factory_h) { 00171 return (1); 00172 } 00173 00174 printf("\n*** Generating Windows GUI ***\n\n"); 00175 generate_gui(win_factory_cast_to_gui_factory(win_factory_h)); 00176 printf("\n*** Generating OSX GUI ***\n\n"); 00177 generate_gui(osx_factory_cast_to_gui_factory(osx_factory_h)); 00178 00179 win_factory_delete(win_factory_h); 00180 osx_factory_delete(osx_factory_h); 00181 00182 printf("\n"); 00183 00184 return (0); 00185 }