menu.cpp

00001 /***************************************************************************
00002                           menu.cpp  -  description
00003                              -------------------
00004     begin                : Mon Mar 29 2004
00005     copyright            : (C) 2004 by Dynacube Team
00006     email                :
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 "gui/components/menu.h"
00019  #include "gui/components/menubar.h"
00020 
00021  #include "gui/components/window.h"
00022 
00023  extern "C"
00024  {
00025          #include "gui/gui_common.h"
00026  }
00027 
00028  #define MENU_COLOR     MENUBAR_COLOR
00029  DB mn_summa_x_offset = 5, mn_summa_y_offset = 5;
00030 
00031  void menu::paint()
00032  {
00033          DB i;
00034 
00035          getimage(x,y,width+2,height+2,buf);
00036 
00037    fillrect(x,y,width,height,MENU_COLOR);
00038 
00039    for(i = 0 ; i < no_item ; i++)
00040    {
00041                  cprint(x+mn_summa_x_offset,y+mn_summa_y_offset*(i+1)+i*10,mnuitem[i].lbl,0x0);
00042          }
00043 
00044          emboss3D(x,y,width,height,0/*LEFT|BOTTOM|RIGHT*/,_false,1);
00045  }
00046 
00047  SDB menu::process(DW _x, DW _y)
00048  {
00049          DB i;
00050          MSG msg;
00051 
00052          if(iswithin(_x,_y,x,y,width,height))
00053          {
00054                 for(i = 0 ; i < no_item ; i++)
00055                 {
00056                  if(iswithin(_x,_y,x,y+mn_summa_y_offset*(i+1)+i*10,width,mn_summa_y_offset+10))
00057                  {
00058                      msg.type     = WM_CLICKED;
00059                  msg.sub_type = MENU_TYPE;
00060                      msg.length   = sizeof(DD);
00061                      *(DW*)msg.msg_buf = mnuitem[i].cmdCode;
00062 
00063                      asm("pushl %0"::"r"(&msg));
00064                      asm("pushl %0"::"r"(__pid));
00065                      asm("int $0x30"::"a"(3));
00066                  }
00067                 }
00068                 
00069                 return 0;
00070          }
00071          else
00072          {
00073                 restoreImage(mcurx,mcury);
00074                 return -1;
00075          }
00076  }
00077 
00078  void menu::menu_restore()
00079  {
00080          putimage(x,y,width+2,height+2,buf);
00081  }
00082 
00083  void menu::menu_init(void *_cnt_ptr, DB _no_item, MENUITEM *_mnuitem, DW _pid)
00084  {
00085         DB i;
00086 
00087         cnt_ptr = _cnt_ptr;
00088         no_item = _no_item;
00089         __pid   = _pid;
00090 
00091         width = MN_MAX_CHAR*7;
00092         height = (no_item) * (10 + mn_summa_y_offset);
00093 
00094         for(i = 0 ; i < no_item ; i++)
00095         {
00096                 strcpy(mnuitem[i].lbl,_mnuitem[i].lbl);
00097                 mnuitem[i].cmdCode = _mnuitem[i].cmdCode;
00098         }
00099 
00100         buf     = (COLOR *)kmalloc((width+2)*(height+2)*2);
00101  }

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