explorer.c

00001 /***************************************************************************
00002                           explorer.c  -  description
00003                           --------------------------
00004     begin                : 
00005     copyright            : (C) 2003 by Dynacube Team
00006     email                : mdshah82@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018  #include "common/string.h"
00019  #include "gui/client/client_gui.h"
00020 
00021  typedef struct
00022  {
00023   char lbl[MN_MAX_CHAR];
00024   DB cmdCode; //To be sent to the client
00025  } _MENUITEM;
00026 
00027   typedef struct
00028   {
00029    DB no_item;
00030    _MENUITEM mnuitem[MN_MAX_ITEM];
00031   } _MENU;
00032 
00033   typedef struct
00034   {
00035    DB no_menu;
00036 
00037    struct
00038    {
00039     char label[MB_MAX_CHAR];
00040     _MENU menu_ptr;
00041    }mnu[MB_MAX_MENU];
00042 
00043   } _MENUBAR;
00044 
00045  int main()
00046  {
00047   volatile MSG msg;
00048   CREATE_INFO cr;
00049   COMP_CREATE_INFO cmp;
00050   RESIZE_INFO rs;
00051   SDD ret_val = -1;
00052   DB i, j;
00053   _MENUBAR mybar;
00054   _MENU mymenu[5];
00055 
00056   char *menubar[] = {"File","Edit","View"};
00057   char *menuitem[] = {"New","Open","Exit","Cut","Copy","Paste","100%","200%","500%"};
00058 
00059   volatile char text[4096];
00060 
00061      strcpy(text,"hi hello");
00062 
00063      msg.length = sizeof(cr);
00064      msg.type   = CREATE;
00065      msg.sub_type = WINDOW;
00066      cr.alias_id = 101;
00067      cr.cntr_id = 0;
00068      cr.height = 200;
00069      cr.width = 400;
00070      cr.style  = 0;
00071      cr.x = 100;
00072      cr.y = 50;
00073      strcpy(cr.title,"Explorer");
00074 
00075      memcpy(msg.msg_buf,&cr,sizeof(cr));
00076 
00077      asm("pushl %0"::"r"(&msg));
00078      asm("pushl %0"::"r"(GUI_PID));
00079 
00080      asm("int $0x30"::"a"(3));
00081 
00082      cr.alias_id = 102;
00083      cr.cntr_id = 0;
00084      cr.height = 200;
00085      cr.width = 200;
00086      cr.style  = 0;
00087      cr.x = 150;
00088      cr.y = 75;
00089         //     cr.style = W_DISABLED;
00090      strcpy(cr.title,"Explorer 2");
00091 
00092      memcpy(msg.msg_buf,&cr,sizeof(cr));
00093 
00094      asm("pushl %0"::"r"(&msg));
00095      asm("pushl %0"::"r"(GUI_PID));
00096      asm("int $0x30"::"a"(3));
00097 
00098 
00099      msg.sub_type = BUTTON;
00100      cmp.alias_id = 201;
00101      cmp.cntr_id = 101;
00102      cmp.cnt_type = WIND_TYPE;
00103      cmp.height = 20;
00104      cmp.width = 70;
00105      cmp.x = 200;
00106      cmp.y = 30;
00107      cmp.style = 0;
00108      strcpy(cmp.label,"BUTTON 1");
00109 
00110      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00111 
00112      asm("pushl %0"::"r"(&msg));
00113      asm("pushl %0"::"r"(GUI_PID));
00114      asm("int $0x30"::"a"(3));
00115 
00116      msg.sub_type = TEXT;
00117      cmp.alias_id = 202;
00118      cmp.cntr_id = 101;
00119      cmp.cnt_type = WIND_TYPE;
00120      cmp.height = 20;
00121      cmp.width = 50;
00122      cmp.x = 100;
00123      cmp.y = 30;
00124 //     cmp.style = DISABLED;
00125      strcpy(cmp.label,"TEX");
00126 
00127      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00128 
00129      asm("pushl %0"::"r"(&msg));
00130      asm("pushl %0"::"r"(GUI_PID));
00131      asm("int $0x30"::"a"(3));
00132 
00133 
00134      msg.sub_type = TEXT;
00135      cmp.alias_id = 207;
00136      cmp.cntr_id = 101;
00137      cmp.cnt_type = WIND_TYPE;
00138      cmp.height = 20;
00139      cmp.width = 50;
00140      cmp.x = 100;
00141      cmp.y = 5;
00142 //     cmp.style = DISABLED;
00143      strcpy(cmp.label,"TEXT2");
00144 
00145      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00146 
00147      asm("pushl %0"::"r"(&msg));
00148      asm("pushl %0"::"r"(GUI_PID));
00149      asm("int $0x30"::"a"(3));
00150 
00151      msg.sub_type = LABEL;
00152      cmp.alias_id = 203;
00153      cmp.cntr_id = 101;
00154      cmp.cnt_type = WIND_TYPE;
00155      cmp.height = 20;
00156      cmp.width = 50;
00157      cmp.x = 50;
00158      cmp.y = 30;
00159      cmp.style = 0;
00160      strcpy(cmp.label,"LABEL");
00161 
00162      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00163 
00164      asm("pushl %0"::"r"(&msg));
00165      asm("pushl %0"::"r"(GUI_PID));
00166      asm("int $0x30"::"a"(3));
00167 
00168 
00169      msg.sub_type = TEXTAREA;
00170      cmp.alias_id = 206;
00171      cmp.cntr_id = 101;
00172      cmp.cnt_type = WIND_TYPE;
00173      cmp.height = 50;
00174      cmp.width = 100;
00175      cmp.x = 100;
00176      cmp.y = 70;
00177      cmp.style = 0;
00178      strcpy(cmp.label,"TEXT1");
00179 
00180      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00181 
00182      asm("pushl %0"::"r"(&msg));
00183      asm("pushl %0"::"r"(GUI_PID));
00184      asm("int $0x30"::"a"(3));
00185 
00186      msg.sub_type = TEXTAREA;
00187      cmp.alias_id = 208;
00188      cmp.cntr_id = 101;
00189      cmp.cnt_type = WIND_TYPE;
00190      cmp.height = 50;
00191      cmp.width = 100;
00192      cmp.x = 210;
00193      cmp.y = 70;
00194      cmp.style = 0;
00195      strcpy(cmp.label,"TEXT2");
00196 
00197      memcpy(msg.msg_buf,&cmp,sizeof(cmp));
00198 
00199      asm("pushl %0"::"r"(&msg));
00200      asm("pushl %0"::"r"(GUI_PID));
00201      asm("int $0x30"::"a"(3));
00202 
00203      strcpy(text,"TEXT1\n hai2all \n hello \n great to see you \n");
00204      msg.type     = SET;
00205      msg.sub_type = TEXTAREA;
00206      msg.length   = 10;//sizeof(DW) + sizeof(DD);
00207      msg.msg_buf[0] = 206;
00208      *(DD*)(msg.msg_buf+2) = text;
00209 
00210 
00211      asm("pushl %0"::"r"(&msg));
00212      asm("pushl %0"::"r"(GUI_PID));
00213      asm("int $0x30"::"a"(3));
00214 
00215 
00216      msg.type   = CREATE;
00217      msg.sub_type = WINDOW;
00218      msg.length = sizeof(cr);
00219      cr.alias_id = 103;
00220      cr.cntr_id = 0;
00221      cr.height = 0;
00222      cr.width = 0;
00223      cr.style  = 0;
00224      cr.x = 300;
00225      cr.y = 130;
00226      strcpy(cr.title,"Explorer 3");
00227 
00228      memcpy(msg.msg_buf,&cr,sizeof(cr));
00229 
00230      asm("pushl %0"::"r"(&msg));
00231      asm("pushl %0"::"r"(GUI_PID));
00232      asm("int $0x30"::"a"(3));
00233 
00234      msg.type     = SHOW;
00235      msg.sub_type = WINDOW;
00236      msg.length   = sizeof(DW);
00237      msg.msg_buf[0] = 101;
00238 
00239      asm("pushl %0"::"r"(&msg));
00240      asm("pushl %0"::"r"(GUI_PID));
00241      asm("int $0x30"::"a"(3));
00242 
00243      asm("pushl %eax");
00244      asm("popl %0"::"r"(ret_val));
00245 
00246      mybar.no_menu = 3;
00247      for(i = 0 ; i < mybar.no_menu ; i++)
00248      {
00249                 strcpy(mybar.mnu[i].label, menubar[i]);
00250      }
00251 
00252      for(i = 0 ; i < mybar.no_menu ; i++)
00253      {
00254         mybar.mnu[i].menu_ptr.no_item = 3;
00255 
00256                 for(j = 0 ; j < mybar.mnu[i].menu_ptr.no_item ; j++)
00257                 {
00258                  mybar.mnu[i].menu_ptr.mnuitem[j].cmdCode = i*10+j;
00259                  strcpy(mybar.mnu[i].menu_ptr.mnuitem[j].lbl,menuitem[i*3+j]);//itoa(i*10+j,10));
00260                 }
00261      }
00262 
00263 
00264 
00265      msg.type     = CREATE;
00266      msg.sub_type = MENU;
00267      msg.length   = 10;
00268      msg.msg_buf[0] = 101;
00269      *(DD*)(msg.msg_buf+2) = &mybar;
00270 
00271      asm("pushl %0"::"r"(&msg));
00272      asm("pushl %0"::"r"(GUI_PID));
00273      asm("int $0x30"::"a"(3));
00274 
00275      asm("pushl %eax");
00276      asm("popl %0"::"r"(ret_val));
00277 
00278      i = 0;
00279 
00280      while(1)
00281      {
00282        asm("pushl %0"::"r"(&msg));
00283        asm("int $0x30"::"a"(4));
00284 
00285        switch(msg.type)
00286        {
00287          case WM_CLICKED:
00288 
00289                 switch(msg.sub_type)
00290                                 {
00291                          case BUT_TYPE:
00292                                                 msg.type     = GET;
00293                                         msg.sub_type = TEXT;
00294                                         msg.length   = 10;//sizeof(DW) + sizeof(DD);
00295                                         msg.msg_buf[0] = 202;
00296                                                 *(DD*)(msg.msg_buf+2) = text;
00297 
00298                                                 asm("pushl %0"::"r"(&msg));
00299                                         asm("pushl %0"::"r"(GUI_PID));
00300                                                 asm("int $0x30"::"a"(3));
00301 
00302                                                 msg.type     = SET;
00303                                         msg.sub_type = TEXT;
00304                                         msg.length   = 10;//sizeof(DW) + sizeof(DD);
00305                                         msg.msg_buf[0] = 207;
00306                                                 *(DD*)(msg.msg_buf+2) = text;
00307 
00308                                                 asm("pushl %0"::"r"(&msg));
00309                                         asm("pushl %0"::"r"(GUI_PID));
00310                                         asm("int $0x30"::"a"(3));
00311 
00312                         msg.type     = FINISHED;
00313                         msg.sub_type = BUT_TYPE;
00314                         msg.length   = sizeof(DD);
00315                                                 msg.msg_buf[0] = 201;
00316 
00317                         asm("pushl %0"::"r"(&msg));
00318                         asm("pushl %0"::"r"(GUI_PID));
00319                         asm("int $0x30"::"a"(3));
00320 
00321                       break;
00322 
00323                       case MENU_TYPE:
00324                                                 msg.type     = SET;
00325                                                 msg.sub_type = TEXT;
00326                                                 msg.length   = 10;//sizeof(DW) + sizeof(DD);
00327                                                 *(DD*)(msg.msg_buf+2) = itoa(*(DW*)msg.msg_buf,10);
00328                                                 msg.msg_buf[0] = 207;
00329 
00330                                                 asm("pushl %0"::"r"(&msg));
00331                                                 asm("pushl %0"::"r"(GUI_PID));
00332                                                 asm("int $0x30"::"a"(3));
00333                                                 break;
00334                 }
00335                 break;
00336 
00337          case WM_KEYPRESS:
00338                 break;
00339 
00340          case WM_DESTROY:
00341                 break;
00342        }
00343 
00344      }
00345      
00346      while(1);
00347 }

Generated on Thu Jul 27 23:52:25 2006 for Dynacube by  doxygen 1.4.7