home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 December / PCWorld_2002-12_cd.bin / Software / Komercni / Baltik / katB.exe / katB / DESIGN / DESIGN_C.MEN < prev    next >
Text File  |  2002-09-24  |  6KB  |  193 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //----------------------------------------------------------------------------//
  3. //-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
  4. //----------------------------------------------------------------------------//
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7.  
  8. POINT m_POPUPMENU_PLACEMENT_SIZE;
  9. int m_POPUPMENU_ROWS=0;
  10. unsigned PopUpMenuHitTest(int x,int y);
  11. string  m_POPUPMENU_STRINGS[20];
  12. int m_POPUPMENU_HEIGHTS[20];
  13. int m_POPUPMENU_selitem=-1;
  14. int m_POPUPMENU_IDS[20];
  15. int m_POPUPMENU_IMAGES[20];
  16. char m_POPUPMENU_ENABLE[20];
  17.  
  18. #define SetMenuCount(x) m_POPUPMENU_ROWS=x
  19.  
  20.  
  21. void MENUITEM(unsigned nMenuItem,nID,string szText,hBitmap,char bEnable){
  22.      m_POPUPMENU_IDS[nMenuItem] = nID;
  23.         if(szText == "-")m_POPUPMENU_IDS[nMenuItem] = -1;
  24.            m_POPUPMENU_STRINGS[nMenuItem] = szText;
  25.         m_POPUPMENU_IMAGES[nMenuItem] = hBitmap;
  26.             m_POPUPMENU_ENABLE[nMenuItem] = bEnable;
  27.  
  28. }
  29. void GetTextExtent(string szText,SIZE &returnsize, char FontType);
  30. void SetPoint(POINT * pt, int x, int y){
  31.   pt->left = x;
  32.   pt->top = y;
  33.  
  34. }
  35. void RecallPopUpMenuSize(){
  36.     int i,ac=0;
  37.     int nMaxWidth=0;
  38.     SIZE tmpW;
  39.     for(i = 0;i < m_POPUPMENU_ROWS;i++){
  40.     GetTextExtent(m_POPUPMENU_STRINGS[i],tmpW,FONT_TAHOMA_8);
  41.     if(nMaxWidth < tmpW.x)nMaxWidth=tmpW.x;
  42.     
  43. #ifdef _XP_THEME
  44.                  if(m_POPUPMENU_STRINGS[i] == "-")ac+=4;
  45.          else ac+=22;
  46. #else
  47.                  if(m_POPUPMENU_STRINGS[i] == "-")ac+=8;
  48.          else ac+=19;
  49.  
  50. #endif
  51.          m_POPUPMENU_HEIGHTS[i] = ac;
  52.     }
  53.         if(nMaxWidth < 140)nMaxWidth = 100;
  54.  
  55. #ifdef _XP_THEME
  56.         SetPoint(&m_POPUPMENU_PLACEMENT_SIZE,nMaxWidth+64,ac+4);
  57. #else
  58.         SetPoint(&m_POPUPMENU_PLACEMENT_SIZE,nMaxWidth+54,ac+5);
  59. #endif
  60.  
  61. }
  62. void StopTrackingPopUpMenu(){
  63.         RecallPopUpMenuSize();
  64.    RECT rect;CopyRect(&rect,GetWindowRect(3 /* IDC_POPUPMENU */));
  65.    STYLEMINUS(GetWindow(3 /* IDC_POPUPMENU */)->dwStyle,0x00020000L/*WS_VISIBLE*/);
  66.    m_PopUpMenuFilter = 0;
  67.    int x =m_POPUPMENU_TOMENU;
  68.    m_POPUPMENU_TOMENU =0;
  69.    m_POPUPMENU_selitem=-1;
  70.    if(x){
  71.                      SendMessage(1 /* IDC_MENU */,8/*WM_PAINT */ ,IDC_MENU_OVER,0);
  72.    }
  73.  
  74.  
  75.    ReleaseCapture();
  76.    int mx=rect.right-rect.left,my=rect.bottom-rect.top;
  77.    if(m_ObjectWithFocus != 2){
  78.        GrKresliP²edm╪ty(16001,1,rect.left,rect.top,mx/39+1,my/29+1);
  79.    }
  80.    else {
  81.       Diagram__ScreenToClient2(rect);
  82.       Diagram__OnDrawClipRect(rect.left,rect.top,rect.right,rect.bottom);
  83.    }
  84.  
  85.  
  86. }
  87. void TrackPopUpMenu(int x, int y){
  88.    if(m_POPUPMENU_ROWS == 0)return;
  89.    RecallPopUpMenuSize();
  90.    int mx = m_POPUPMENU_PLACEMENT_SIZE.left;
  91.    int my = m_POPUPMENU_PLACEMENT_SIZE.top;
  92.    GetWindow(3 /* IDC_POPUPMENU */)->dwStyle|=0x00020000L/*WS_VISIBLE*/;
  93.    SetCapture(3 /* IDC_POPUPMENU */);
  94.    m_PopUpMenuFilter = 1;
  95.  
  96.    if(mx+x > GrMaxX())x=GrMaxX()-mx;
  97.    if(my+y > GrMaxY() && y-my > 33)y-=my;
  98.    if(m_ObjectWithFocus != 2){
  99.    if(my > 290){GrNastavObrazP²edm╪tà(17001,x,y+290,mx/39+1,(my-290)/29+1,1);}
  100.    GrNastavObrazP²edm╪tà(16001,x,y,mx/39+1,((((my)/29+1)>=10)?10:((my)/29+1)),1);
  101.    }
  102.  
  103.  
  104.    SetWindowRect2(3 /* IDC_POPUPMENU */,x,y,x+mx,y+my);
  105.    Invalidate(3 /* IDC_POPUPMENU */);
  106.  
  107.    m_POPUPMENU_selitem=-1;
  108.    while(MouseEvent.Tlaƒítka & 2){
  109.      AnimMouse();
  110.  
  111.    }
  112. }
  113. unsigned PopUpMenuHitTest(int x,int y){
  114.     int e;
  115.     RECT rc,*r=GetWindowRect(3 /* IDC_POPUPMENU */);
  116.     CopyRect(&rc,r);
  117.         InflateRect(&rc,-4,-3,-4,0);
  118.     rc.bottom=rc.top;
  119.     for(e=0;e < m_POPUPMENU_ROWS; e++){
  120.         rc.bottom = r->top+3+ m_POPUPMENU_HEIGHTS[e]-1;
  121.         if(PtInRect(x,y,&rc))return e;
  122.         rc.top = r->top+3+ m_POPUPMENU_HEIGHTS[e];
  123.     }
  124.     return -1;
  125. }
  126. void LoadMenu(int nStartPos,int nSize){
  127.        // We must put code for all menu thread (not only for this function to binary file)
  128.        // similar as in all function ...
  129.          int nPos;
  130.          MENU* pMenu;
  131.          m_POPUPMENU_ROWS=nSize;
  132.          for(nPos=0;nPos < nSize;nPos++){
  133.                  pMenu = &m_MenuArray[nPos+nStartPos];
  134.                  MENUITEM(nPos,pMenu->nID,pMenu->strItem,pMenu->hBitmap,1);
  135.          }
  136. }
  137. void SetMainMenu(unsigned idThread){
  138.        long bCellFocus = m_nInterCellFocus > -1;
  139.        long nType = 0;
  140.        if(bCellFocus)nType = Diagram__GetFocusCell()->nType;
  141.         switch(idThread){
  142.            case 0 /*IDM_FILE*/:
  143.                    LoadMenu(0,9);
  144.                    break;
  145.        case 1 /*IDM_EDIT*/:
  146.                    LoadMenu(9,5);
  147.                    m_POPUPMENU_ENABLE[0]=bCellFocus && nType != 4;
  148.                    m_POPUPMENU_ENABLE[1]=bCellFocus && nType != 4;
  149.                    m_POPUPMENU_ENABLE[2]=m_MEMORY_CELL.nType != 0; // null memory
  150.                    m_POPUPMENU_ENABLE[3]=bCellFocus;
  151.                    m_POPUPMENU_ENABLE[4]=m_nm_DiagramCellsSize > 0;
  152.                    break;
  153.        case 4/*IDM_HELP*/:
  154.                    LoadMenu(14,4);
  155.                    if(NoXP && UnderXP){
  156.                    m_POPUPMENU_ENABLE[0] = 0;m_POPUPMENU_ENABLE[1] = 0;
  157.                    }
  158.                    break;
  159.        case 2/*IDM_INSERT*/ :
  160.                    LoadMenu(18,5);
  161.                    m_POPUPMENU_ENABLE[1]=(bCellFocus)&&(m_nm_DiagramCellsSize > 0)&&nType != 4;
  162.                    m_POPUPMENU_ENABLE[3]=bCellFocus&&nType < 3;
  163.                    m_POPUPMENU_ENABLE[4]=bCellFocus&&nType < 3;
  164.  
  165.  
  166.                    break;
  167.        case 3/*IDM_VIEW*/:
  168.     if( _UNDER_WINDOWS_2k){
  169.                    LoadMenu(34,1);
  170.                    m_POPUPMENU_IMAGES[0] = 147;
  171.     }
  172.     else
  173.                    LoadMenu(23,3);
  174.                    m_POPUPMENU_IMAGES[GrMód()-3] = 147/*IDB_CHECKED*/;
  175.                    break;
  176.        default:  //  ERROR !!!! Nothing to set
  177.                    return;
  178.  
  179.         }
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186. }
  187.  
  188. // KONEC SOUBORU
  189.  
  190. ///////////////////////////////////////////////////////////////////////////
  191. ///////////////////////////////////////////////////////////////////////////
  192. ///////////////////////////////////////////////////////////////////////////
  193.