00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "gui/server/gui.h"
00019 #include "gui/components/window.h"
00020 #include "gui/components/startmenu.h"
00021
00022 #include "dev/mouse/mouse.h"
00023
00024 #include "gui/components/button.h"
00025 #include "gui/components/text.h"
00026 #include "gui/components/textarea.h"
00027 #include "gui/components/label.h"
00028 #include "gui/components/folderview.h"
00029
00030 #include "gui/components/list.h"
00031 #include "common/ds/hashmap.h"
00032 #include "gui/svga.h"
00033 #include "common/stdlib.h"
00034 #include "gui/components/cursor.h"
00035
00036 extern "C"
00037 {
00038 #include "gui/components/icon.h"
00039 #include "dev/core/cmos.h"
00040 }
00041
00042
00043
00044 window *focus = (window *)NULL;
00045 window *clamped = (window *)NULL;
00046 DW clamp_x = 0, clamp_y = 0;
00047
00048 COLOR tsk_color;
00049 startmenu *sm;
00050 cursor csr;
00051
00052
00053 void cursor_paint()
00054 {
00055 csr.paint();
00056 }
00057
00058 void runGUI()
00059 {
00060 MSG msg1;
00061 DW i = 0, j, k;
00062 DD ret_val;
00063 char smsg[128];
00064
00065 initgraphics(800,600,16,vbe_mode.PhysBasePtr);
00066
00067 sm = (startmenu *)kmalloc(sizeof(startmenu));
00068 sm->startmenu_init();
00069 csr.cursor_init();
00070 setScreen(SCREEN_COLOR);
00071 repaint();
00072
00073 while(1)
00074 {
00075 printf("\nHello from GUI");
00076 printf("\nAbout to block In GUI RECV");
00077
00078 asm("pushl %0"::"r"(&msg1));
00079 asm("int $0x30"::"a"(4));
00080
00081 printf("\n\n\nfrom_pid %d ",msg1.from_pid);
00082 printf("\nbuffer %s",msg1.msg_buf);
00083
00084 cli();
00085 ret_val = processMessage(&msg1);
00086 sti();
00087
00088 if(msg1.from_pid != KERNEL_PID)
00089 {
00090 asm("pushl %%eax"::"a"(ret_val));
00091 asm("pushl %%eax"::"a"(msg1.from_pid));
00092 asm("int $0x30"::"a"(11));
00093 }
00094
00095 }
00096 }
00097
00098
00099 SDW processMessage(MSG *msg)
00100 {
00101 button *btn_ptr;
00102
00103 switch(msg->type)
00104 {
00105 case CREATE:
00106 return processCreate(msg);
00107 break;
00108
00109 case ADD:
00110 break;
00111
00112 case SHOW:
00113 return processShow(msg);
00114 break;
00115
00116 case HIDE:
00117 return processHide(msg);
00118 break;
00119
00120 case RESIZE:
00121 return processResize(msg);
00122 break;
00123
00124 case ENABLE:
00125 return processEnable(msg);
00126 break;
00127
00128 case DISABLE:
00129 return processDisable(msg);
00130 break;
00131
00132 case DESTROY:
00133 return processDestroy(msg);
00134 break;
00135
00136 case ACTION:
00137 switch(msg->sub_type)
00138 {
00139 case MOUSE:
00140 return processMouse(msg);
00141 break;
00142
00143 case KBD:
00144 return processKBD(msg);
00145 break;
00146
00147 default:
00148 return -1;
00149 break;
00150 }
00151
00152 break;
00153
00154 case FINISHED:
00155 switch(msg->sub_type)
00156 {
00157 case BUT_TYPE:
00158 btn_ptr = (button*)lfind(msg->from_pid,COMP_TYPE,hfind(msg->from_pid,COMP_TYPE,*(DW*)msg->msg_buf));
00159 if(btn_ptr != NULL)
00160 btn_ptr->react();
00161 else
00162 ginfo(50,50,"NULL BUTTON");
00163 break;
00164 }
00165 break;
00166
00167 case SET:
00168 return processSet(msg);
00169 break;
00170 case GET:
00171 return processGet(msg);
00172 break;
00173 case COPY:
00174 return processCopy(msg);
00175 break;
00176 case CUT:
00177 return processCut(msg);
00178 break;
00179 case PASTE:
00180 return processPaste(msg);
00181 break;
00182 default:
00183 break;
00184 }
00185 }
00186
00187
00188 SDW processCreate(MSG *msg)
00189 {
00190 DD i, j;
00191 SDW id, parent_id;
00192 DW pid;
00193 DW cntr_found = ALIAS_MAX;
00194 CREATE_INFO *cr_info;
00195 COMP_CREATE_INFO *cmp_cr_info;
00196 DD phy;
00197
00198
00199 window *win_ptr;
00200 frame *frm_ptr;
00201
00202
00203 button *but_ptr;
00204 text *txt_ptr;
00205 textarea *txtarea_ptr;
00206 label *lbl_ptr;
00207 folderview *fv_ptr;
00208
00209 pid = msg->from_pid;
00210
00211 switch(msg->sub_type)
00212 {
00213 case WINDOW:
00214 cr_info = (CREATE_INFO *)msg->msg_buf;
00215
00216 printf("\nalias_id %d cont_id %d",cr_info->alias_id,cr_info->cntr_id);
00217 printf("\n x %d y %d width %d height %d",cr_info->x,cr_info->y,cr_info->width,cr_info->height);
00218 printf("\ntitle %s",cr_info->title);
00219
00220 if(cr_info->width < MIN_WIDTH)
00221 cr_info->width = MIN_WIDTH;
00222
00223 if(cr_info->height < MIN_HEIGHT)
00224 cr_info->height = MIN_HEIGHT;
00225
00226 if(cr_info->cntr_id)
00227 {
00228 parent_id = hfind(pid,WIND_TYPE,cr_info->cntr_id);
00229 if(parent_id == -1)
00230 return -1;
00231 }
00232 else
00233 {
00234 parent_id = WINDOW_MAX;
00235 }
00236
00237 win_ptr = (window *)kmalloc(sizeof(window));
00238
00239 if(win_ptr == NULL)
00240 return -1;
00241
00242 id = ladd(pid,WIND_TYPE,(void *)win_ptr);
00243
00244 if(id == -1)
00245 {
00246 free((void *)win_ptr);
00247 return -1;
00248 }
00249
00250 if(hadd(pid,WIND_TYPE,cr_info->alias_id,id) == -1)
00251 {
00252 free((void *)win_ptr);
00253 return -1;
00254 }
00255 printf("\n p_id %d id %d winptr %x",parent_id,id,win_ptr);
00256
00257 win_ptr->win_init(id, \
00258 parent_id, \
00259 cr_info->x % SCREEN_WIDTH, cr_info->y % SCREEN_HEIGHT, \
00260 cr_info->width % SCREEN_WIDTH, \
00261 cr_info->height % SCREEN_HEIGHT, \
00262 cr_info->style, \
00263 0, \
00264 cr_info->title \
00265 );
00266
00267 return 0;
00268
00269 break;
00270
00271 case BUTTON:
00272
00273 cmp_cr_info = (COMP_CREATE_INFO *)msg->msg_buf;
00274
00275 printf("\nalias_id %d cont_id %d",cmp_cr_info->alias_id,cmp_cr_info->cntr_id);
00276 printf("\n x %d y %d width %d height %d",cmp_cr_info->x,cmp_cr_info->y,cmp_cr_info->width,cmp_cr_info->height);
00277 printf("\ntitle %s",cmp_cr_info->label);
00278
00279 if(cmp_cr_info->width < MIN_BUT_WIDTH)
00280 cmp_cr_info->width = MIN_BUT_WIDTH;
00281
00282 if(cmp_cr_info->height < MIN_BUT_HEIGHT)
00283 cmp_cr_info->height = MIN_BUT_HEIGHT;
00284
00285
00286 if(cmp_cr_info->cnt_type == WIND_TYPE)
00287 parent_id = hfind(pid,WIND_TYPE,cmp_cr_info->cntr_id);
00288 else
00289 parent_id = hfind(pid,FRM_TYPE,cmp_cr_info->cntr_id);
00290
00291
00292 if(parent_id == -1)
00293 return -1;
00294
00295 if(cmp_cr_info->cnt_type == WIND_TYPE)
00296 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00297 else
00298 frm_ptr = (frame *)lfind(pid,FRM_TYPE,parent_id);
00299
00300 but_ptr = (button *)kmalloc(sizeof(button));
00301
00302 if(but_ptr == NULL)
00303 return -1;
00304
00305 id = ladd(pid,COMP_TYPE,(void *)but_ptr);
00306
00307 if(id == -1)
00308 {
00309 free((void *)but_ptr);
00310 return -1;
00311 }
00312
00313 if(hadd(pid,COMP_TYPE,cmp_cr_info->alias_id,id) == -1)
00314 {
00315 free((void *)but_ptr);
00316 return -1;
00317 }
00318 printf("\n p_id %d id %d winptr %x",parent_id,id,but_ptr);
00319 if(cmp_cr_info->cnt_type == WIND_TYPE)
00320 {
00321 win_ptr->attachComponent(but_ptr);
00322 but_ptr->but_init(id, \
00323 parent_id, \
00324 cmp_cr_info->cnt_type, \
00325 (void *)win_ptr, \
00326 cmp_cr_info->alias_id,\
00327 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00328 cmp_cr_info->width % SCREEN_WIDTH, \
00329 cmp_cr_info->height % SCREEN_HEIGHT, \
00330 cmp_cr_info->style, \
00331 cmp_cr_info->label \
00332 );
00333 }
00334 else
00335 {
00336 frm_ptr->attachComponent(but_ptr);
00337 but_ptr->but_init(id, \
00338 parent_id, \
00339 cmp_cr_info->cnt_type, \
00340 (void *)frm_ptr, \
00341 cmp_cr_info->alias_id,\
00342 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00343 cmp_cr_info->width % SCREEN_WIDTH, \
00344 cmp_cr_info->height % SCREEN_HEIGHT, \
00345 cmp_cr_info->style, \
00346 cmp_cr_info->label \
00347 );
00348
00349 }
00350
00351 return 0;
00352
00353 break;
00354
00355 case TEXT:
00356 cmp_cr_info = (COMP_CREATE_INFO *)msg->msg_buf;
00357
00358 printf("\nalias_id %d cont_id %d",cmp_cr_info->alias_id,cmp_cr_info->cntr_id);
00359 printf("\n x %d y %d width %d height %d",cmp_cr_info->x,cmp_cr_info->y,cmp_cr_info->width,cmp_cr_info->height);
00360 printf("\ntitle %s",cmp_cr_info->label);
00361
00362 if(cmp_cr_info->width < MIN_TEXT_WIDTH)
00363 cmp_cr_info->width = MIN_TEXT_WIDTH;
00364
00365 if(cmp_cr_info->height < MIN_TEXT_HEIGHT)
00366 cmp_cr_info->height = MIN_TEXT_HEIGHT;
00367
00368
00369 if(cmp_cr_info->cnt_type == WIND_TYPE)
00370 parent_id = hfind(pid,WIND_TYPE,cmp_cr_info->cntr_id);
00371 else
00372 parent_id = hfind(pid,FRM_TYPE,cmp_cr_info->cntr_id);
00373
00374
00375 if(parent_id == -1)
00376 return -1;
00377
00378 if(cmp_cr_info->cnt_type == WIND_TYPE)
00379 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00380 else
00381 frm_ptr = (frame *)lfind(pid,FRM_TYPE,parent_id);
00382
00383 txt_ptr = (text *)kmalloc(sizeof(text));
00384
00385 if(txt_ptr == NULL)
00386 return -1;
00387
00388 id = ladd(pid,COMP_TYPE,(void *)txt_ptr);
00389
00390 if(id == -1)
00391 {
00392 free((void *)txt_ptr);
00393 return -1;
00394 }
00395
00396 if(hadd(pid,COMP_TYPE,cmp_cr_info->alias_id,id) == -1)
00397 {
00398 free((void *)txt_ptr);
00399 return -1;
00400 }
00401 printf("\n p_id %d id %d winptr %x",parent_id,id,txt_ptr);
00402 if(cmp_cr_info->cnt_type == WIND_TYPE)
00403 {
00404 win_ptr->attachComponent(txt_ptr);
00405 txt_ptr->text_init(id, \
00406 parent_id, \
00407 cmp_cr_info->cnt_type, \
00408 (void *)win_ptr, \
00409 cmp_cr_info->alias_id,\
00410 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00411 cmp_cr_info->width % SCREEN_WIDTH, \
00412 cmp_cr_info->height % SCREEN_HEIGHT, \
00413 cmp_cr_info->style, \
00414 cmp_cr_info->label \
00415 );
00416 }
00417 else
00418 {
00419 frm_ptr->attachComponent(txt_ptr);
00420 txt_ptr->text_init(id, \
00421 parent_id, \
00422 cmp_cr_info->cnt_type, \
00423 (void *)frm_ptr, \
00424 cmp_cr_info->alias_id,\
00425 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00426 cmp_cr_info->width % SCREEN_WIDTH, \
00427 cmp_cr_info->height % SCREEN_HEIGHT, \
00428 cmp_cr_info->style, \
00429 cmp_cr_info->label \
00430 );
00431
00432 }
00433
00434 return 0;
00435
00436 break;
00437
00438 case TEXTAREA:
00439 cmp_cr_info = (COMP_CREATE_INFO *)msg->msg_buf;
00440
00441 printf("\nalias_id %d cont_id %d",cmp_cr_info->alias_id,cmp_cr_info->cntr_id);
00442 printf("\n x %d y %d width %d height %d",cmp_cr_info->x,cmp_cr_info->y,cmp_cr_info->width,cmp_cr_info->height);
00443 printf("\ntitle %s",cmp_cr_info->label);
00444
00445 if(cmp_cr_info->width < MIN_TEXTAREA_WIDTH)
00446 cmp_cr_info->width = MIN_TEXTAREA_WIDTH;
00447
00448 if(cmp_cr_info->height < MIN_TEXTAREA_HEIGHT)
00449 cmp_cr_info->height = MIN_TEXTAREA_HEIGHT;
00450
00451
00452 if(cmp_cr_info->cnt_type == WIND_TYPE)
00453 parent_id = hfind(pid,WIND_TYPE,cmp_cr_info->cntr_id);
00454 else
00455 parent_id = hfind(pid,FRM_TYPE,cmp_cr_info->cntr_id);
00456
00457
00458 if(parent_id == -1)
00459 return -1;
00460
00461 if(cmp_cr_info->cnt_type == WIND_TYPE)
00462 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00463 else
00464 frm_ptr = (frame *)lfind(pid,FRM_TYPE,parent_id);
00465
00466 txtarea_ptr = (textarea *)kmalloc(sizeof(textarea));
00467
00468 if(txtarea_ptr == NULL)
00469 return -1;
00470
00471 id = ladd(pid,COMP_TYPE,(void *)txtarea_ptr);
00472
00473 if(id == -1)
00474 {
00475 free((void *)txtarea_ptr);
00476 return -1;
00477 }
00478
00479 if(hadd(pid,COMP_TYPE,cmp_cr_info->alias_id,id) == -1)
00480 {
00481 free((void *)txtarea_ptr);
00482 return -1;
00483 }
00484 printf("\n p_id %d id %d winptr %x",parent_id,id,txtarea_ptr);
00485 if(cmp_cr_info->cnt_type == WIND_TYPE)
00486 {
00487 win_ptr->attachComponent(txtarea_ptr);
00488 txtarea_ptr->textarea_init(id, \
00489 parent_id, \
00490 cmp_cr_info->cnt_type, \
00491 (void *)win_ptr, \
00492 cmp_cr_info->alias_id,\
00493 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00494 cmp_cr_info->width % SCREEN_WIDTH, \
00495 cmp_cr_info->height % SCREEN_HEIGHT, \
00496 cmp_cr_info->style, \
00497 cmp_cr_info->label \
00498 );
00499 }
00500 else
00501 {
00502 frm_ptr->attachComponent(txtarea_ptr);
00503 txtarea_ptr->textarea_init(id, \
00504 parent_id, \
00505 cmp_cr_info->cnt_type, \
00506 (void *)frm_ptr, \
00507 cmp_cr_info->alias_id,\
00508 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00509 cmp_cr_info->width % SCREEN_WIDTH, \
00510 cmp_cr_info->height % SCREEN_HEIGHT, \
00511 cmp_cr_info->style, \
00512 cmp_cr_info->label \
00513 );
00514
00515 }
00516
00517 return 0;
00518
00519 break;
00520
00521
00522 case LIST:
00523 break;
00524
00525 case HSCROLLBAR:
00526 break;
00527
00528 case VSCROLLBAR:
00529 break;
00530
00531 case CHECKBOX:
00532 break;
00533
00534 case RADIOBUTTON:
00535 break;
00536
00537 case MENU:
00538
00539
00540
00541
00542 phy = get_phys(msg->from_pid,*(DD *)(msg->msg_buf + 2));
00543
00544
00545
00546 parent_id = hfind(pid,WIND_TYPE,*(DW *)msg->msg_buf);
00547
00548 if(parent_id == -1)
00549 {
00550 ginfo(50,50,"Error");
00551 return -1;
00552 }
00553 else
00554 {
00555
00556 }
00557
00558 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00559
00560 if(win_ptr != NULL)
00561 {
00562 win_ptr->menuInit(phy,msg->from_pid);
00563
00564 win_ptr->paint_win();
00565 mvBuf2Svga();
00566 }
00567
00568
00569
00570 break;
00571
00572 case TOOLBAR:
00573 break;
00574
00575 case FRAME:
00576 break;
00577
00578 case ICON:
00579 break;
00580
00581 case LABEL:
00582 cmp_cr_info = (COMP_CREATE_INFO *)msg->msg_buf;
00583
00584 printf("\nalias_id %d cont_id %d",cmp_cr_info->alias_id,cmp_cr_info->cntr_id);
00585 printf("\n x %d y %d width %d height %d",cmp_cr_info->x,cmp_cr_info->y,cmp_cr_info->width,cmp_cr_info->height);
00586 printf("\ntitle %s",cmp_cr_info->label);
00587
00588 if(cmp_cr_info->width < MIN_LABEL_WIDTH)
00589 cmp_cr_info->width = MIN_LABEL_WIDTH;
00590
00591 if(cmp_cr_info->height < MIN_LABEL_HEIGHT)
00592 cmp_cr_info->height = MIN_LABEL_HEIGHT;
00593
00594
00595 if(cmp_cr_info->cnt_type == WIND_TYPE)
00596 parent_id = hfind(pid,WIND_TYPE,cmp_cr_info->cntr_id);
00597 else
00598 parent_id = hfind(pid,FRM_TYPE,cmp_cr_info->cntr_id);
00599
00600 if(parent_id == -1)
00601 return -1;
00602
00603 if(cmp_cr_info->cnt_type == WIND_TYPE)
00604 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00605 else
00606 frm_ptr = (frame *)lfind(pid,FRM_TYPE,parent_id);
00607
00608 lbl_ptr = (label *)kmalloc(sizeof(label));
00609
00610 if(lbl_ptr == NULL)
00611 return -1;
00612
00613 id = ladd(pid,COMP_TYPE,(void *)lbl_ptr);
00614
00615 if(id == -1)
00616 {
00617 free((void *)lbl_ptr);
00618 return -1;
00619 }
00620
00621 if(hadd(pid,COMP_TYPE,cmp_cr_info->alias_id,id) == -1)
00622 {
00623 free((void *)lbl_ptr);
00624 return -1;
00625 }
00626 printf("\n p_id %d id %d winptr %x",parent_id,id,lbl_ptr);
00627 if(cmp_cr_info->cnt_type == WIND_TYPE)
00628 {
00629 win_ptr->attachComponent(lbl_ptr);
00630 lbl_ptr->label_init(id, \
00631 parent_id, \
00632 cmp_cr_info->cnt_type, \
00633 (void *)win_ptr, \
00634 cmp_cr_info->alias_id,\
00635 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00636 cmp_cr_info->width % SCREEN_WIDTH, \
00637 cmp_cr_info->height % SCREEN_HEIGHT, \
00638 cmp_cr_info->style, \
00639 cmp_cr_info->label \
00640 );
00641 }
00642 else
00643 {
00644 frm_ptr->attachComponent(lbl_ptr);
00645 lbl_ptr->label_init(id, \
00646 parent_id, \
00647 cmp_cr_info->cnt_type, \
00648 (void *)frm_ptr, \
00649 cmp_cr_info->alias_id,\
00650 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00651 cmp_cr_info->width % SCREEN_WIDTH, \
00652 cmp_cr_info->height % SCREEN_HEIGHT, \
00653 cmp_cr_info->style, \
00654 cmp_cr_info->label \
00655 );
00656
00657 }
00658
00659 return 0;
00660 break;
00661
00662 case FOLDERVIEW:
00663 cmp_cr_info = (COMP_CREATE_INFO *)msg->msg_buf;
00664
00665 printf("\nalias_id %d cont_id %d",cmp_cr_info->alias_id,cmp_cr_info->cntr_id);
00666 printf("\n x %d y %d width %d height %d",cmp_cr_info->x,cmp_cr_info->y,cmp_cr_info->width,cmp_cr_info->height);
00667 printf("\ntitle %s",cmp_cr_info->label);
00668
00669 if(cmp_cr_info->width < MIN_FV_WIDTH)
00670 cmp_cr_info->width = MIN_FV_WIDTH;
00671
00672 if(cmp_cr_info->height < MIN_FV_HEIGHT)
00673 cmp_cr_info->height = MIN_FV_HEIGHT;
00674
00675
00676 if(cmp_cr_info->cnt_type == WIND_TYPE)
00677 parent_id = hfind(pid,WIND_TYPE,cmp_cr_info->cntr_id);
00678 else
00679 parent_id = hfind(pid,FRM_TYPE,cmp_cr_info->cntr_id);
00680
00681 if(parent_id == -1)
00682 return -1;
00683
00684 if(cmp_cr_info->cnt_type == WIND_TYPE)
00685 win_ptr = (window *)lfind(pid,WIND_TYPE,parent_id);
00686 else
00687 frm_ptr = (frame *)lfind(pid,FRM_TYPE,parent_id);
00688
00689 fv_ptr = (folderview *)kmalloc(sizeof(folderview));
00690
00691 if(fv_ptr == NULL)
00692 return -1;
00693
00694 id = ladd(pid,COMP_TYPE,(void *)fv_ptr);
00695
00696 if(id == -1)
00697 {
00698 free((void *)fv_ptr);
00699 return -1;
00700 }
00701
00702 if(hadd(pid,COMP_TYPE,cmp_cr_info->alias_id,id) == -1)
00703 {
00704 free((void *)fv_ptr);
00705 return -1;
00706 }
00707 printf("\n p_id %d id %d winptr %x",parent_id,id,fv_ptr);
00708
00709 if(cmp_cr_info->cnt_type == WIND_TYPE)
00710 {
00711 win_ptr->attachComponent(fv_ptr);
00712 fv_ptr->folderview_init(id, \
00713 parent_id, \
00714 cmp_cr_info->cnt_type, \
00715 (void *)win_ptr, \
00716 cmp_cr_info->alias_id,\
00717 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00718 cmp_cr_info->width % SCREEN_WIDTH, \
00719 cmp_cr_info->height % SCREEN_HEIGHT, \
00720 cmp_cr_info->style, \
00721 cmp_cr_info->label \
00722 );
00723 }
00724 else
00725 {
00726 frm_ptr->attachComponent(fv_ptr);
00727 fv_ptr->folderview_init(id, \
00728 parent_id, \
00729 cmp_cr_info->cnt_type, \
00730 (void *)frm_ptr, \
00731 cmp_cr_info->alias_id,\
00732 cmp_cr_info->x % SCREEN_WIDTH,cmp_cr_info->y % SCREEN_HEIGHT, \
00733 cmp_cr_info->width % SCREEN_WIDTH, \
00734 cmp_cr_info->height % SCREEN_HEIGHT, \
00735 cmp_cr_info->style, \
00736 cmp_cr_info->label \
00737 );
00738
00739 }
00740
00741 return 0;
00742 break;
00743
00744 case DIALOG :
00745 cr_info = (CREATE_INFO *)msg->msg_buf;
00746
00747 if(cr_info->width < MIN_WIDTH)
00748 cr_info->width = MIN_WIDTH;
00749
00750 if(cr_info->height < MIN_HEIGHT)
00751 cr_info->height = MIN_HEIGHT;
00752
00753 if(cr_info->cntr_id)
00754 {
00755 parent_id = hfind(pid,WIND_TYPE,cr_info->cntr_id);
00756 if(parent_id == -1)
00757 return -1;
00758 }
00759 else
00760 {
00761 return -1;
00762 }
00763
00764 win_ptr = (window *)kmalloc(sizeof(window));
00765
00766 if(win_ptr == NULL)
00767 return -1;
00768
00769 id = ladd(pid,WIND_TYPE,(void *)win_ptr);
00770
00771 if(id == -1)
00772 {
00773 free((void *)win_ptr);
00774 return -1;
00775 }
00776
00777 if(hadd(pid,WIND_TYPE,cr_info->alias_id,id) == -1)
00778 {
00779 free((void *)win_ptr);
00780 return -1;
00781 }
00782 printf("\n p_id %d id %d winptr %x",parent_id,id,win_ptr);
00783
00784 win_ptr->win_init(id, \
00785 parent_id, \
00786 cr_info->x % SCREEN_WIDTH, cr_info->y % SCREEN_HEIGHT, \
00787 cr_info->width % SCREEN_WIDTH, \
00788 cr_info->height % SCREEN_HEIGHT, \
00789 cr_info->style, \
00790 1 , \
00791 cr_info->title \
00792 );
00793
00794 return 0;
00795 break;
00796 }
00797 }
00798
00799 SDW processShow(MSG *msg)
00800 {
00801 SDW ret;
00802 window *win_ptr;
00803 window *diag_ptr;
00804 DW z_in;
00805
00806 switch(msg->sub_type)
00807 {
00808 case WINDOW:
00809 ret = hfind(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
00810 printf("\nSHOW:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
00811
00812 if(ret == -1)
00813 return -1;
00814
00815 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
00816 win_ptr->style &= ~HIDDEN;
00817
00818 z_in = z_get_max();
00819
00820
00821
00822
00823 z_enq(msg->from_pid,ret,z_in);
00824 break;
00825
00826 case BUTTON:
00827 break;
00828
00829 case TEXT:
00830 break;
00831
00832 case TEXTAREA:
00833 break;
00834
00835 case LIST:
00836 break;
00837
00838 case HSCROLLBAR:
00839 break;
00840
00841 case VSCROLLBAR:
00842 break;
00843
00844 case CHECKBOX:
00845 break;
00846
00847 case RADIOBUTTON:
00848 break;
00849
00850 case MENU:
00851 break;
00852
00853 case TOOLBAR:
00854 break;
00855
00856 case FRAME:
00857 break;
00858
00859 case ICON:
00860 break;
00861 case DIALOG:
00862 ret = hfind(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
00863
00864 if(ret == -1)
00865 return -1;
00866
00867 diag_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
00868 diag_ptr->style &= ~HIDDEN;
00869
00870 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,diag_ptr->parent_id);
00871 win_ptr->attachDialog(diag_ptr);
00872
00873 break;
00874
00875 default:
00876 return -1;
00877 }
00878
00879 repaint();
00880 return 0;
00881 }
00882
00883 SDW processDisable(MSG *msg)
00884 {
00885 SDW ret;
00886 window *win_ptr;
00887 component *comp_ptr;
00888
00889 switch(msg->sub_type)
00890 {
00891 case WINDOW:
00892 ret = hfind(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
00893 printf("\nDEACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
00894
00895 if(ret == -1)
00896 return -1;
00897
00898 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
00899 win_ptr->deactivate();
00900 break;
00901
00902 case BUTTON:
00903
00904 case TEXT:
00905
00906 case TEXTAREA:
00907 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
00908 printf("\nDEACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
00909
00910 if(ret == -1)
00911 return -1;
00912
00913 comp_ptr = (component *)lfind(msg->from_pid,COMP_TYPE,ret);
00914 comp_ptr->deactivate();
00915 break;
00916
00917
00918 case LIST:
00919 break;
00920
00921 case HSCROLLBAR:
00922 break;
00923
00924 case VSCROLLBAR:
00925 break;
00926
00927 case CHECKBOX:
00928 break;
00929
00930 case RADIOBUTTON:
00931 break;
00932
00933 case MENU:
00934 break;
00935
00936 case TOOLBAR:
00937 break;
00938
00939 case FRAME:
00940 break;
00941
00942 case ICON:
00943 break;
00944 case DIALOG:
00945 break;
00946
00947 default:
00948 return -1;
00949 }
00950
00951 repaint();
00952 return 0;
00953 }
00954
00955 SDW processEnable(MSG *msg)
00956 {
00957 SDW ret;
00958 window *win_ptr;
00959 component *comp_ptr;
00960
00961 switch(msg->sub_type)
00962 {
00963 case WINDOW:
00964 ret = hfind(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
00965 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
00966
00967 if(ret == -1)
00968 return -1;
00969
00970 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
00971 win_ptr->activate();
00972 break;
00973
00974 case BUTTON:
00975
00976 case TEXT:
00977
00978 case TEXTAREA:
00979 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
00980 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
00981
00982 if(ret == -1)
00983 return -1;
00984
00985 comp_ptr = (component *)lfind(msg->from_pid,COMP_TYPE,ret);
00986 comp_ptr->activate();
00987 break;
00988
00989
00990 case LIST:
00991 break;
00992
00993 case HSCROLLBAR:
00994 break;
00995
00996 case VSCROLLBAR:
00997 break;
00998
00999 case CHECKBOX:
01000 break;
01001
01002 case RADIOBUTTON:
01003 break;
01004
01005 case MENU:
01006 break;
01007
01008 case TOOLBAR:
01009 break;
01010
01011 case FRAME:
01012 break;
01013
01014 case ICON:
01015 break;
01016
01017 default:
01018 return -1;
01019 }
01020
01021 repaint();
01022 return 0;
01023 }
01024
01025 SDW processDestroy(MSG *msg)
01026 {
01027 SDW ret;
01028 window *win_ptr;
01029
01030 switch(msg->sub_type)
01031 {
01032 case WINDOW:
01033 ret = hremove(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
01034
01035 if(ret == -1)
01036 {
01037 return -1;
01038 }
01039
01040 win_ptr = (window*)lfind(msg->from_pid,WIND_TYPE,ret);
01041 win_ptr->freeAll();
01042 free((void *)win_ptr);
01043
01044 z_remove(msg->from_pid, ret);
01045
01046 printf("\nDESTROY:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01047
01048 break;
01049
01050 case BUTTON:
01051 break;
01052
01053 case TEXT:
01054 break;
01055
01056 case TEXTAREA:
01057 break;
01058
01059 case LIST:
01060 break;
01061
01062 case HSCROLLBAR:
01063 break;
01064
01065 case VSCROLLBAR:
01066 break;
01067
01068 case CHECKBOX:
01069 break;
01070
01071 case RADIOBUTTON:
01072 break;
01073
01074 case MENU:
01075 break;
01076
01077 case TOOLBAR:
01078 break;
01079
01080 case FRAME:
01081 break;
01082
01083 case ICON:
01084 break;
01085 default:
01086 return -1;
01087 }
01088
01089 repaint();
01090 return 0;
01091 }
01092
01093 SDW processHide(MSG *msg)
01094 {
01095 SDW ret;
01096 DW alias_id = *(DW *)msg->msg_buf;
01097 window *win_ptr;
01098 window *diag_ptr;
01099
01100 switch(msg->sub_type)
01101 {
01102 case WINDOW:
01103 ret = hfind(msg->from_pid,WIND_TYPE,alias_id);
01104 printf("\nHIDE:WIND (alias_id) %d ret %d",alias_id,ret);
01105
01106 if(ret == -1)
01107 return -1;
01108
01109 z_remove(msg->from_pid,ret);
01110 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
01111 win_ptr->style |= HIDDEN;
01112 break;
01113
01114 case BUTTON:
01115 break;
01116
01117 case TEXT:
01118 break;
01119
01120 case TEXTAREA:
01121 break;
01122
01123 case LIST:
01124 break;
01125
01126 case HSCROLLBAR:
01127 break;
01128
01129 case VSCROLLBAR:
01130 break;
01131
01132 case CHECKBOX:
01133 break;
01134
01135 case RADIOBUTTON:
01136 break;
01137
01138 case MENU:
01139 break;
01140
01141 case TOOLBAR:
01142 break;
01143
01144 case FRAME:
01145 break;
01146
01147 case ICON:
01148 break;
01149 case DIALOG:
01150 ret = hfind(msg->from_pid,WIND_TYPE,*(DW *)msg->msg_buf);
01151
01152
01153 if(ret == -1)
01154 return -1;
01155
01156 diag_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
01157 diag_ptr->style |= HIDDEN;
01158
01159 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,diag_ptr->parent_id);
01160 win_ptr->detachDialog();
01161
01162 break;
01163 default:
01164 return -1;
01165 }
01166
01167 repaint();
01168 return 0;
01169 }
01170
01171 SDW processResize(MSG *msg)
01172 {
01173 SDW ret;
01174 window *win_ptr;
01175 RESIZE_INFO *rs_info;
01176
01177 switch(msg->sub_type)
01178 {
01179 case WINDOW:
01180 rs_info = (RESIZE_INFO *)msg->msg_buf;
01181
01182 if(rs_info->width < MIN_WIDTH)
01183 rs_info->width = MIN_WIDTH;
01184
01185 if(rs_info->height < MIN_HEIGHT)
01186 rs_info->height = MIN_HEIGHT;
01187
01188 ret = hfind(msg->from_pid,WIND_TYPE,rs_info->alias_id);
01189 printf("\nRESIZE:WIND (alias_id) %d ret %d",rs_info->alias_id,ret);
01190
01191 if(ret == -1)
01192 return -1;
01193
01194 win_ptr = (window *)lfind(msg->from_pid,WIND_TYPE,ret);
01195 win_ptr->x = rs_info->x;
01196 win_ptr->y = rs_info->y;
01197 win_ptr->width = rs_info->width;
01198 win_ptr->height = rs_info->height;
01199 break;
01200
01201 case BUTTON:
01202 break;
01203
01204 case TEXT:
01205 break;
01206
01207 case TEXTAREA:
01208 break;
01209
01210 case LIST:
01211 break;
01212
01213 case HSCROLLBAR:
01214 break;
01215
01216 case VSCROLLBAR:
01217 break;
01218
01219 case CHECKBOX:
01220 break;
01221
01222 case RADIOBUTTON:
01223 break;
01224
01225 case MENU:
01226 break;
01227
01228 case TOOLBAR:
01229 break;
01230
01231 case FRAME:
01232 break;
01233
01234 case ICON:
01235 break;
01236
01237 default:
01238 return -1;
01239 }
01240
01241 repaint();
01242 return 0;
01243 }
01244
01245
01246 SDW processSet(MSG *msg)
01247 {
01248 DD phy;
01249 SDW ret;
01250 text *text_ptr;
01251 textarea *textarea_ptr;
01252 switch(msg->sub_type)
01253 {
01254 case TEXT:
01255 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01256 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01257
01258 if(ret == -1)
01259 return -1;
01260
01261 text_ptr = (text *)lfind(msg->from_pid,COMP_TYPE,ret);
01262 phy = get_phys(msg->from_pid,*(DD *)(msg->msg_buf + 2));
01263 text_ptr->setText((char *) phy);
01264 break;
01265
01266 case TEXTAREA:
01267
01268 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01269 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01270
01271 if(ret == -1)
01272 return -1;
01273
01274
01275 textarea_ptr = (textarea *)lfind(msg->from_pid,COMP_TYPE,ret);
01276 phy = get_phys(msg->from_pid,*(DD *)(msg->msg_buf + 2));
01277 textarea_ptr->setText((char *) phy);
01278 break;
01279 default:
01280 return -1;
01281 }
01282 return 0;
01283 }
01284
01285 SDW processGet(MSG *msg)
01286 {
01287 DD phy;
01288 SDW ret;
01289 text *text_ptr;
01290 textarea *textarea_ptr;
01291 switch(msg->sub_type)
01292 {
01293 case TEXT:
01294 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01295 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01296
01297 if(ret == -1)
01298 return -1;
01299
01300
01301 text_ptr = (text *)lfind(msg->from_pid,COMP_TYPE,ret);
01302 phy = get_phys(msg->from_pid,*(DD *)(msg->msg_buf + 2));
01303
01304 text_ptr->getText((char *) phy);
01305
01306 break;
01307
01308 case TEXTAREA:
01309
01310 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01311 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01312
01313 if(ret == -1)
01314 return -1;
01315
01316
01317 textarea_ptr = (textarea *)lfind(msg->from_pid,COMP_TYPE,ret);
01318 phy = get_phys(msg->from_pid,*(DD *)(msg->msg_buf + 2));
01319
01320 textarea_ptr->getText((char *) phy);
01321 break;
01322 default:
01323 return -1;
01324 }
01325 return 0;
01326
01327 }
01328
01329 SDW processCopy(MSG *msg)
01330 {
01331 SDW ret;
01332 text *text_ptr;
01333 textarea *textarea_ptr;
01334 switch(msg->sub_type)
01335 {
01336 case TEXT:
01337 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01338 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01339
01340 if(ret == -1)
01341 return -1;
01342
01343
01344 text_ptr = (text *)lfind(msg->from_pid,COMP_TYPE,ret);
01345 text_ptr->copy();
01346
01347 break;
01348
01349 case TEXTAREA:
01350
01351 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01352 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01353
01354 if(ret == -1)
01355 return -1;
01356
01357
01358 textarea_ptr = (textarea *)lfind(msg->from_pid,COMP_TYPE,ret);
01359 textarea_ptr->copy();
01360 break;
01361 default:
01362 return -1;
01363 }
01364 return 0;
01365 }
01366
01367 SDW processCut(MSG *msg)
01368 {
01369 SDW ret;
01370 text *text_ptr;
01371 textarea *textarea_ptr;
01372 switch(msg->sub_type)
01373 {
01374 case TEXT:
01375 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01376 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01377
01378 if(ret == -1)
01379 return -1;
01380
01381
01382 text_ptr = (text *)lfind(msg->from_pid,COMP_TYPE,ret);
01383 text_ptr->cut();
01384
01385 break;
01386
01387 case TEXTAREA:
01388
01389 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01390 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01391
01392 if(ret == -1)
01393 return -1;
01394
01395
01396 textarea_ptr = (textarea *)lfind(msg->from_pid,COMP_TYPE,ret);
01397 textarea_ptr->cut();
01398 break;
01399 default:
01400 return -1;
01401 }
01402 return 0;
01403 }
01404
01405 SDW processPaste(MSG *msg)
01406 {
01407 SDW ret;
01408 text *text_ptr;
01409 textarea *textarea_ptr;
01410 switch(msg->sub_type)
01411 {
01412 case TEXT:
01413 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01414 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01415
01416 if(ret == -1)
01417 return -1;
01418
01419
01420 text_ptr = (text *)lfind(msg->from_pid,COMP_TYPE,ret);
01421 text_ptr->paste();
01422
01423 break;
01424
01425 case TEXTAREA:
01426
01427 ret = hfind(msg->from_pid,COMP_TYPE,*(DW *)msg->msg_buf);
01428 printf("\nACTIVATE:WIND (alias_id) %d ret %d",*(DW *)msg->msg_buf,ret);
01429
01430 if(ret == -1)
01431 return -1;
01432
01433
01434 textarea_ptr = (textarea *)lfind(msg->from_pid,COMP_TYPE,ret);
01435 textarea_ptr->paste();
01436 break;
01437 default:
01438 return -1;
01439 }
01440 return 0;
01441
01442 }
01443
01444 void repaint()
01445 {
01446 DW i, j;
01447 window *win;
01448
01449 cli();
01450 drawDesktop();
01451
01452 printf("repaint()");
01453
01454 for(i=0 ; i < z_endptr ; i++)
01455 {
01456 win = (window*)lfind(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01457 win->paint_win();
01458
01459
01460 if(!(win->style & W_MINIMIZE))
01461 focus = win;
01462 }
01463
01464 drawTaskbar();
01465
01466 if(mouse_inited)
01467 {
01468 getimage(mcurx,mcury,16,16, &mouseimg[0][0]);
01469
01470 for(i = mcurx ; i < mcurx+16 ; i++)
01471 {
01472 for(j = mcury ; j < mcury+16 ; j++)
01473 {
01474 if(mouseptr[j-mcury][i-mcurx])
01475 {
01476 setPixel(i,j,0x0);
01477 }
01478 }
01479 }
01480
01481 }
01482
01483 mvBuf2Svga();
01484 }
01485
01486 SDW processMouse(MSG *msg)
01487 {
01488 ENTITY en;
01489 DW x, y, status;
01490 MSG msg1;
01491
01492
01493
01494 x = *(DW*)(msg->msg_buf);
01495 y = *(DW*)(msg->msg_buf+2);
01496 status = *(DW *)(msg->msg_buf+4);
01497
01498
01499
01500
01501
01502 printf("\nValue x : %d y : %d",x,y);
01503 printf("\n mcurx %d mcury %d",mcurx,mcury);
01504
01505 csr.hide();
01506
01507 if(status & CLICK)
01508 {
01509 clamped = (window*)NULL;
01510 clamp_x = 0;
01511 clamp_y = 0;
01512 en = findEntity(x,y);
01513
01514 }
01515 else if(status & MOVE)
01516 {
01517 if(clamped != NULL && clamp_x != 0 && clamp_y != 0)
01518 {
01519 clamped->move(x - clamp_x, y - clamp_y);
01520 clamp_x = x;
01521 clamp_y = y;
01522 }
01523 }
01524
01525
01526 if(en.type != NO_TYPE)
01527 {
01528 msg1.type = WM_CLICKED;
01529 msg1.sub_type = en.type;
01530 msg1.length = sizeof(DD) + 4;
01531 *(DW*)msg1.msg_buf = en.alias_id;
01532
01533 asm("pushl %0"::"r"(&msg1));
01534 asm("pushl %0"::"r"((DD)en.pid));
01535 asm("int $0x30"::"a"(3));
01536 }
01537
01538 return 0;
01539 }
01540
01541 SDW processKBD(MSG *msg)
01542 {
01543 if(focus == NULL)
01544 {
01545
01546 }
01547 else
01548 {
01549
01550 focus->keyPress(*((DW *)msg->msg_buf),*((DW *) msg->msg_buf+1));
01551 }
01552 return 0;
01553 }
01554
01555 ENTITY findEntity(DW x,DW y)
01556 {
01557 SDW i;
01558 DW _x, _y, _width, _height;
01559 window * win_ptr;
01560 window * par_ptr;
01561 ENTITY en;
01562 DW width_max = 100;
01563 DB num_of_tasks;
01564 DW tskWidth, tskHeight, tskOffset = 10;
01565 MSG msg;
01566 DW min,min_p,j;
01567 SDW cur_min = -1;
01568 SDW emb_id;
01569 DW diag_pres = 0;
01570
01571 en.type = NO_TYPE;
01572
01573
01574 if(focus != NULL)
01575 {
01576 if(focus->processMenu(x,y) == 0)
01577 return en;
01578 }
01579
01580
01581 if(processStartMenu(x,y) == 0)
01582 return en;
01583
01584
01585 if(iswithin(x,y,0,SCREEN_HEIGHT,TASKBAR_WIDTH,TASKBAR_HEIGHT))
01586 {
01587
01588 if(iswithin(x,y,SCREEN_WIDTH-TIME_X-105,SCREEN_HEIGHT + TIME_Y,TIME_WIDTH,TIME_HEIGHT))
01589 {
01590 __asm__ __volatile__("pushl %%eax"::"a"("\\timeset"));
01591 __asm__ __volatile__("movl $0x1, %eax");
01592 __asm__ __volatile__("int $0x30");
01593 en.type = NO_TYPE;
01594 return en;
01595 }
01596
01597 num_of_tasks = z_endptr;
01598
01599 if(num_of_tasks != 0)
01600 {
01601 tskWidth = (TASKBAR_WIDTH - START_WIDTH - TIME_WIDTH) / num_of_tasks;
01602 }
01603 else
01604 {
01605 en.type = NO_TYPE;
01606 return en;
01607 }
01608
01609 if(tskWidth > width_max)
01610 tskWidth = width_max;
01611
01612 tskHeight = TASKBAR_HEIGHT - 10;
01613
01614 emb_id = MAX_PROC * WINDOW_MAX;
01615
01616 for(i= num_of_tasks-1 ; i >= 0 ; i--)
01617 {
01618 win_ptr = (window*)lfind(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01619 if(!(win_ptr->style & W_MINIMIZE))
01620 break;
01621 }
01622
01623 emb_id = i;
01624
01625 for(i = 0 ; i < num_of_tasks ; i++)
01626 {
01627 min = MAX_PROC * WINDOW_MAX;
01628
01629 for(j = 0 ; j < num_of_tasks ; j++)
01630 {
01631 if(zorder[j].task_id <= min && zorder[j].task_id > cur_min)
01632 {
01633 min = zorder[j].task_id;
01634 min_p = j;
01635 }
01636 }
01637
01638 cur_min = min;
01639
01640 if(iswithin(x,y,START_WIDTH + i*tskWidth + tskOffset, SCREEN_HEIGHT + 5, tskWidth - tskOffset + 5, tskHeight))
01641 {
01642 win_ptr = (window*)lfind(zorder[min_p].pid,WIND_TYPE,zorder[min_p].window_id);
01643
01644
01645 if(win_ptr->style & W_MINIMIZE)
01646 {
01647 win_ptr->style &= ~W_MINIMIZE;
01648 }
01649
01650 if(emb_id == min_p)
01651 {
01652 win_ptr->style |= W_MINIMIZE;
01653 }
01654
01655 z_moveTop(zorder[min_p].pid,zorder[min_p].window_id);
01656
01657 repaint();
01658 en.type = NO_TYPE;
01659 return en;
01660 }
01661 }
01662 }
01663
01664
01665
01666 for(i = z_endptr-1; i>= 0;i--)
01667 {
01668
01669 diag_pres = 0;
01670 win_ptr = (window *)lfind(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01671
01672 if(win_ptr->style & W_MINIMIZE)
01673 continue;
01674
01675 if(win_ptr->diag != NULL)
01676 {
01677 par_ptr = win_ptr;
01678 win_ptr = win_ptr->diag;
01679 diag_pres = 1;
01680 }
01681
01682 if(win_ptr->style & W_MAXIMIZE)
01683 {
01684 _x = 0;
01685 _y = 0;
01686 _width = SCREEN_WIDTH;
01687 _height = SCREEN_HEIGHT;
01688 }
01689 else
01690 {
01691 _x = win_ptr->x;
01692 _y = win_ptr->y;
01693 _width = win_ptr->width;
01694 _height = win_ptr->height;
01695 }
01696
01697
01698
01699 if(iswithin(x,y,_x,_y,_width,_height))
01700 {
01701
01702 if(win_ptr->style & W_DISABLED)
01703 return en;
01704
01705
01706
01707 if(iswithin(x,y,_x,_y + TITLE_HEIGHT,_width,_height + MENUBAR_HEIGHT))
01708 {
01709 win_ptr->paint_win();
01710 win_ptr->processMenu(x,y);
01711 }
01712
01713
01714
01715 if(iswithin(x,y,_x,_y,_width,TITLE_HEIGHT))
01716 {
01717 if(diag_pres == 0)
01718 {
01719
01720 if(iswithin(x,y,_x+_width-3*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12))
01721 {
01722 z_moveTop(zorder[i].pid,zorder[i].window_id);
01723 win_ptr->style |= W_MINIMIZE;
01724 emboss3D(_x+_width-3*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12,0,_true,2);
01725 mvMini2Svga(_x+_width-3*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12);
01726
01727
01728 repaint();
01729 en.type = NO_TYPE;
01730 return en;
01731 }
01732
01733
01734 if(iswithin(x,y,_x+_width-2*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12))
01735 {
01736
01737 if(win_ptr->style & W_NORESIZE)
01738 return en;
01739
01740 z_moveTop(zorder[i].pid,zorder[i].window_id);
01741
01742
01743 if(win_ptr->style & W_MAXIMIZE)
01744 {
01745 win_ptr->style &= ~W_MAXIMIZE;
01746 }
01747 else
01748 {
01749 win_ptr->style |= W_MAXIMIZE;
01750 }
01751
01752 emboss3D(_x+_width-2*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12,0,_true,2);
01753 mvMini2Svga(_x+_width-2*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12);
01754
01755
01756
01757 repaint();
01758 en.type = NO_TYPE;
01759 return en;
01760 }
01761 }
01762
01763 if(iswithin(x,y,_x+_width-1*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12))
01764 {
01765 if(diag_pres == 0)
01766 {
01767
01768 msg.length = sizeof(DW);
01769 msg.type = WM_DESTROY;
01770 msg.sub_type = WINDOW;
01771 *(DW *)msg.msg_buf = afind(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01772 asm("pushl %0"::"r"(&msg));
01773 asm("pushl %0"::"r"((DD)zorder[i].pid));
01774 asm("int $0x30"::"a"(3));
01775
01776
01777 win_ptr->freeAll();
01778 free(win_ptr);
01779
01780 lremove(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01781 hremove(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01782 z_remove(zorder[i].pid,zorder[i].window_id);
01783 }
01784 else
01785 {
01786 par_ptr->detachDialog();
01787 ginfo(300,400,"diag close");
01788 }
01789
01790 emboss3D(_x+_width-1*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12,0,_true,2);
01791 mvMini2Svga(_x+_width-1*14 - BORDER_WIDTH,_y+BORDER_HEIGHT+3,12,12);
01792
01793 repaint();
01794 en.type = NO_TYPE;
01795 return en;
01796 }
01797 else
01798 {
01799 clamped = win_ptr;
01800 clamp_x = x;
01801 clamp_y = y;
01802
01803 }
01804
01805 }
01806
01807
01808 if(!(win_ptr->style & W_DISABLED))
01809 {
01810 en = win_ptr->findEntity(x,y);
01811 en.pid = zorder[i].pid;
01812 }
01813
01814 z_moveTop(zorder[i].pid,zorder[i].window_id);
01815
01816
01817
01818 repaint();
01819
01820 return en;
01821
01822 }
01823
01824 }
01825
01826
01827 }
01828
01829 SDB processStartMenu(DW x,DW y)
01830 {
01831 SDB ret;
01832 ret = sm->processClick(x,y);
01833 mvBuf2Svga();
01834 return ret;
01835 }
01836
01837 void drawDesktop()
01838 {
01839
01840 setScreen(SCREEN_COLOR);
01841 }
01842
01843 void drawTaskbar()
01844 {
01845 DB num_of_tasks;
01846 DW tskWidth = 0, tskHeight, tskOffset = 10;
01847 window *win_ptr;
01848 DW min,min_p,j;
01849 SDW i;
01850 char temp[20];
01851 SDW cur_min = -1;
01852 DW width_max = 100;
01853 SDW emb_id;
01854
01855
01856 fillrect(0,TOTAL_HEIGHT - TASKBAR_HEIGHT,TASKBAR_WIDTH,TASKBAR_HEIGHT,TASKBAR_COLOR);
01857
01858 emboss3D(0,TOTAL_HEIGHT - TASKBAR_HEIGHT,TASKBAR_WIDTH,TASKBAR_HEIGHT,TOP | RIGHT,_false,3);
01859
01860
01861 fillrect(START_X,SCREEN_HEIGHT + START_Y,START_WIDTH,START_HEIGHT,0xDEAD);
01862 drawstring(START_X+15,SCREEN_HEIGHT + START_Y + 10,"START");
01863 emboss3D(START_X,SCREEN_HEIGHT + START_Y,START_WIDTH,START_HEIGHT,0,_false,2);
01864
01865 num_of_tasks = z_endptr;
01866
01867 if(num_of_tasks != 0)
01868 tskWidth = (TASKBAR_WIDTH - START_WIDTH - TIME_WIDTH) / num_of_tasks;
01869
01870 if(tskWidth > width_max)
01871 tskWidth = width_max;
01872
01873 tskHeight = TASKBAR_HEIGHT - 10;
01874
01875 emb_id = MAX_PROC * WINDOW_MAX;
01876
01877 for(i= num_of_tasks-1 ; i >= 0 ; i--)
01878 {
01879 win_ptr = (window*)lfind(zorder[i].pid,WIND_TYPE,zorder[i].window_id);
01880 if(!(win_ptr->style & W_MINIMIZE))
01881 break;
01882 }
01883
01884 emb_id = i;
01885
01886 cur_min = -1;
01887
01888 for(i = 0 ; i < num_of_tasks ; i++)
01889 {
01890 min = MAX_PROC * WINDOW_MAX;
01891
01892 for(j = 0 ; j < num_of_tasks ; j++)
01893 {
01894 if(zorder[j].task_id <= min && zorder[j].task_id > cur_min)
01895 {
01896 min = zorder[j].task_id;
01897 min_p = j;
01898
01899
01900
01901 }
01902 }
01903 cur_min = min;
01904
01905 win_ptr = (window*)lfind(zorder[min_p].pid,WIND_TYPE,zorder[min_p].window_id);
01906
01907
01908 if(min_p == emb_id)
01909 {
01910 fillrect(START_WIDTH + i*tskWidth + tskOffset, SCREEN_HEIGHT + 5, tskWidth - tskOffset + 5, tskHeight, TASK_AC_COLOR);
01911 emboss3D(START_WIDTH + i*tskWidth + tskOffset, SCREEN_HEIGHT + 5, tskWidth - tskOffset + 5, tskHeight,0,_true,2);
01912 }
01913 else
01914 {
01915 fillrect(START_WIDTH + i*tskWidth + tskOffset, SCREEN_HEIGHT + 5, tskWidth - tskOffset + 5, tskHeight, TASK_INAC_COLOR);
01916 emboss3D(START_WIDTH + i*tskWidth + tskOffset, SCREEN_HEIGHT + 5, tskWidth - tskOffset + 5, tskHeight,0,_false,2);
01917 }
01918
01919 drawstring(START_WIDTH + i*tskWidth + tskOffset + 5, SCREEN_HEIGHT + 10, (char *)strmncpy(temp,win_ptr->title,0,((tskWidth - tskOffset + 5)/7) - 1));
01920
01921 }
01922
01923 draw_time(0);
01924 }
01925
01926 void draw_time(DB flush)
01927 {
01928 TIME t;
01929 DATE d;
01930 char dt[20];
01931
01932 if(!graphics)
01933 return;
01934
01935 gettime(&t);
01936 getdate(&d);
01937
01938 if(d.dd < 10)
01939 {
01940 strcpy(dt,"0");
01941 strcat(dt,itoa(d.dd,10));
01942 }
01943 else
01944 {
01945 strcpy(dt,itoa(d.dd,10));
01946 }
01947 strcat(dt,"/");
01948 if(d.mm < 10)
01949 strcat(dt,"0");
01950 strcat(dt,itoa(d.mm,10));
01951 strcat(dt,"/");
01952 if(d.yy < 10)
01953 strcat(dt,"0");
01954 strcat(dt,itoa(d.yy,10));
01955 strcat(dt," ");
01956 if(t.hour < 10)
01957 strcat(dt,"0");
01958 strcat(dt,itoa(t.hour,10));
01959 strcat(dt,":");
01960 if(t.min < 10)
01961 strcat(dt,"0");
01962 strcat(dt,itoa(t.min,10));
01963
01964
01965
01966 fillrect(SCREEN_WIDTH-TIME_X-105,SCREEN_HEIGHT + TIME_Y,TIME_WIDTH-2,TIME_HEIGHT,0xDEAD);
01967 drawstring(SCREEN_WIDTH-TIME_X-100,SCREEN_HEIGHT + TIME_Y + 10,dt);
01968 emboss3D(SCREEN_WIDTH-TIME_X-105,SCREEN_HEIGHT + TIME_Y,TIME_WIDTH-2,TIME_HEIGHT,0,_false,2);
01969
01970 if(flush)
01971 {
01972
01973 mvMini2Svga(SCREEN_WIDTH-TIME_X-110,SCREEN_HEIGHT + TIME_Y,TIME_WIDTH,TIME_HEIGHT);
01974 }
01975
01976 }
01977
01978 void destroy_win(DW pid)
01979 {
01980 lremoveAll(pid);
01981 z_removeAll(pid);
01982 hremoveAll(pid);
01983 repaint();
01984 }
01985
01986 void sys_init_info()
01987 {
01988 DB i,j;
01989
01990 char *sys[] = { \
01991 "DYNACUBE 1.0 LOADING",\
01992 "---------------------------------",\
01993 "DISABLING HARDWARE INTERRUPTS................",\
01994 "SYSTEM DESCRIPTORS LOADED ..............",\
01995 "PROGRAMMABLE INTERRUPT CONTROLLER (PIC) REMAPPED ................",\
01996 "TASK STUCTURES INITIALIZED .............",\
01997 "PROCESS STUCTURES INITIALIZED .............",\
01998 "SYSTEM QUEUES INITIALIZED .............",\
01999 "GUI ZORDER INITIALIZED .............",\
02000 "SYSTEM HASHTABLES INITIALIZED .............",\
02001 "SYSTEM LISTS INITIALIZED .............",\
02002 "RETRIEVING SVGA INFO .............",\
02003 "PS/2 KEYBOARD INITIALIZED .............",\
02004 "PS/2 MOUSE INITIALIZED .............",\
02005 "SYSTEM MEMORY STRUCTURES INITIALIZED .............",\
02006 "FORKING NULL PROCESS .............",\
02007 "STARTING GUI SERVER ................",\
02008 "STARTING FLOPPY SERVER ................",\
02009 "STARTING FILE SERVER SERVER ................",\
02010 "SYSTEM MEMORY STRUCTURES INITIALIZED .............",\
02011 "SYSTEM TIMER INITIALIZED .............", \
02012 "TIMER IRQ ENABLED .............", \
02013 "KEYBOARD IRQ ENABLED .............", \
02014 "PS/2 MOUSE IRQ ENABLED .............", \
02015 "FLOPPY IRQ ENABLED .............", \
02016 "ENABLING HARDWARE INTERRUPTS................",\
02017 "ABOUT TO START ................",\
02018 ""};
02019
02020 for(i = 0,j = 0 ; i < sizeof(sys)/sizeof(char*) ; i++,j++)
02021 {
02022 if((i+1) % (SCREEN_HEIGHT/20) == 0)
02023 {
02024 j = 0;
02025 setScreen(0x0);
02026 }
02027 cprint(20,(j+1)*20,sys[i],0x7E0);
02028 mvBuf2Svga();
02029
02030 }
02031
02032 }