00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027
00028 #include <App.h>
00029 #include <Window.h>
00030 #include <gadgets/gadget_Group.h>
00031 #include <gadgets/gadget_Test.h>
00032 #include <gadgets/gadget_Icon.h>
00033 #include <gadgets/gadget_Space.h>
00034 #include <gadgets/gadget_Button.h>
00035 #include <gadgets/gadget_Compound.h>
00036 #include <gadgets/gadget_Scroller.h>
00037 #include <classes.h>
00038
00039 #include <Client.h>
00040
00041
00042 static char *ggpix[]={ "pix_desc.png", "pix_desc2.png" };
00043 static int actpix=0;
00044 static char myapp[]="TestApp";
00045 static Window_t *mainwin;
00046 static gadget_Check_t checklist[]=
00047 {
00048 { 9, "Button", GADGET_REQUIRED },
00049 { 11, "Button", GADGET_REQUIRED },
00050 { 10, "Icon", 0L },
00051 GADGET_CHECK_DONE
00052 };
00053 static gadget_Check_t sub_checklist[]=
00054 {
00055 { 5, "Button", GADGET_REQUIRED },
00056 { 4, "Scroller", 0L },
00057 GADGET_CHECK_DONE
00058 };
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 static int my_timer(Window_t *win, u32 userdata)
00097 {
00098 static int i=0;
00099 printf("timer_timeout %lu (%d)\n",userdata,i++);
00100 return((i<2?0:1));
00101 }
00102
00103
00104 static int sub_event_handler(gui_App_t *app, Window_t *win, u32 gadget_id, int event, u32 event_data)
00105 {
00106 int ret=CLIENT_DISCARD_EVENT;
00107 printf("SUB: sender=%ld -- EVENT: %d (DATA=%d)\n",gadget_id,event,(int)event_data);
00108 if(event==CBK_WINDOW_ACTIVATED) { ret=0; printf("SUBwindow activated\n"); }
00109 if(event==CBK_WINDOW_INACTIVATED) { ret=0; printf("SUBwindow inactivated\n"); }
00110 if(event==CBK_WINDOW_CLOSED) { ret=0; printf("window closed %ld\n",event_data); }
00111 if(event==CBK_WINDOW_OPENED) { ret=0; printf("window opened %ld\n",event_data); }
00112 if(event==CBK_GADGET_CLICKED&&gadget_id==5)
00113 {
00114 printf("sub window close!!\n");
00115 client_CloseWindow(app,win);
00116 ret=0;
00117 }
00118 if(event==CBK_GADGET_CLICKED&&gadget_id==7)
00119 {
00120 actpix=1-actpix;
00121 client_CallAGadget(app,mainwin,10,MET_ICON_SET_IMAGE,TAG_ICO_IMAGENAME,(u32)ggpix[actpix],TAG_DONE);
00122 ret=0;
00123 }
00124 if(event==CBK_WINDOW_CLOSE)
00125 {
00126 printf("sub window close!!(2)\n");
00127 client_CloseWindow(app,win);
00128 ret=0;
00129 }
00130 return(ret);
00131 }
00132
00133
00134 static int test_event_handler(gui_App_t *app, Window_t *win, u32 gadget_id, int event, u32 event_data)
00135 {
00136 static char *skins[3]={"tst3Skin","tst4Skin","tst2Skin"};
00137 static int currskin=0;
00138 int ret=CLIENT_DISCARD_EVENT;
00139 u32 rv=0L;
00140 Rect_t rct;
00141 Window_t *subwin;
00142
00143 printf("sender=%ld -- EVENT: %d (DATA=%d)\n",gadget_id,event,(int)event_data);
00144 if(event==CBK_WINDOW_ACTIVATED) { ret=0; printf("MAINwindow activated\n"); }
00145 if(event==CBK_WINDOW_INACTIVATED) { ret=0; printf("MAINwindow inactivated\n"); }
00146 if(event==CBK_WINDOW_CLOSED) { ret=0; printf("window closed %ld\n",event_data); }
00147 if(event==CBK_WINDOW_OPENED) { ret=0; printf("window opened %ld\n",event_data); }
00148 if(event==CBK_CHILD_WINDOW_OPENED)
00149 {
00150 printf("CBK_CHILD_WINDOW_OPENED - subwindow\n");
00151 ret=0;
00152 }
00153 if(event==CBK_CHILD_WINDOW_CLOSED)
00154 {
00155 printf("CBK_CHILD_WINDOW_CLOSED - subwindow\n");
00156 ret=0;
00157 }
00158 if(event==CBK_GADGET_CLICKED&&gadget_id==9)
00159 {
00160 actpix=1-actpix;
00161 rv=client_CallSGadget(app,win,10,MET_ICON_SET_IMAGE,TAG_ICO_IMAGENAME,(u32)ggpix[actpix],TAG_DONE);
00162 ret=0;
00163 }
00164 if(event==CBK_GADGET_CLICKED&&gadget_id==20)
00165 {
00166 if(++currskin>2) currskin=0;
00167 printf("NEW SKIN: '%s'\n",skins[currskin]);
00168 client_ChangeSkin(app,win,skins[currskin]);
00169 ret=0;
00170 }
00171 if(event==CBK_GADGET_CLICKED&&gadget_id==11)
00172 {
00173 rct.left=150;
00174 rct.top=150;
00175 rct.width=300;
00176 rct.height=200;
00177 ret=0;
00178 if(NULL!=(subwin=client_OpenWindow(app,&rct,"SubWindow",
00179 sub_event_handler,GLWF_SMART_REFRESH,
00180 TAG_WIN_TITLE,(u32)"Test subwindow",
00181 TAG_WIN_PXTOP,40,
00182 TAG_WIN_PXLEFT,10,
00183 TAG_WIN_PXWIDTH,350,
00184 TAG_WIN_PXHEIGHT,250,
00185 TAG_WIN_FONTNAME, "Times",
00186 TAG_WIN_FONTSIZE, 20,
00187 TAG_WIN_CHECKLIST, (u32)sub_checklist,
00188 TAG_WIN_PARENT,win,
00189 TAG_WIN_PARENTDATA,3072,
00190 TAG_WIN_WINFLAGS,WIN_FLAGS_SLEEPPARENT|WIN_FLAGS_NOBORDER,
00191 TAG_WIN_USERDATA,1052L,
00192 TAG_DONE)
00193 )) {
00194 printf("window2 opened\n");
00195 }
00196 }
00197 if(event==CBK_WINDOW_CLOSE)
00198 {
00199 printf("hulye!!\n");
00200 client_CloseWindow(app,win);
00201 client_SendCloseApp(app->conn,app);
00202 ret=0;
00203 }
00204 return(ret);
00205 }
00206
00207
00208 char *app_name(void)
00209 {
00210 return(myapp);
00211 }
00212
00213
00214 int app_Init(gui_App_t *app)
00215 {
00216 Rect_t rct;
00217 Window_t *win;
00218
00219 rct.left=100;
00220 rct.top=100;
00221 rct.width=600;
00222 rct.height=400;
00223 if(NULL!=(mainwin=win=client_OpenWindow(app,&rct,"MainWindow",
00224 test_event_handler,GLWF_SMART_REFRESH,
00225 TAG_WIN_TITLE,(u32)"Test application",
00226 TAG_WIN_TOP,10,
00227 TAG_WIN_BOTTOM,55,
00228 TAG_WIN_LEFT,10,
00229 TAG_WIN_RIGHT,60,
00230 TAG_WIN_FONTNAME, "Arial",
00231 TAG_WIN_FONTSIZE, 18,
00232 TAG_WIN_CHECKLIST, (u32)checklist,
00233 TAG_WIN_USERDATA,338L,
00234
00235 TAG_DONE)
00236 )) client_TimerStart(app,win,10000,GUI_TIMER_REPEAT,(u32)112,my_timer);
00237
00238 return(0);
00239 }
00240
00241
00242 void app_CleanUp(gui_App_t *app)
00243 {
00244 return;
00245 }