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.XP < prev    next >
Text File  |  2002-09-22  |  13KB  |  286 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //----------------------------------------------------------------------------//
  3. //-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
  4. //----------------------------------------------------------------------------//
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7.  
  8.  
  9. //
  10.  
  11. //
  12. // Library for Graphic User Interface
  13. // (Using GDISTYLE of Microsoft Windows XP)
  14. //
  15. // copyright 2002 Libor Bareτ
  16.  
  17. void DrawFrameControl(RECT* lpRect,unsigned nType, long nState,char* szText,unsigned hBitmap){ // for 7/*DFC_EDIT*/ is hBitmap replaced by hFont !!!!!!
  18.     int left,top,right,bottom;
  19.     RectToVariable(lpRect,left,top,right,bottom);
  20.     long bClientEdge = (nState & 0x00200000L/*WS_CLIENTEDGE*/);
  21.     long bFocus = (nState & 0x00400000L/*WS_FOCUS*/);
  22.     long bMouseOver = (nState & 0x00100000L/*WS_MOUSEOVER*/);
  23.     long bPushed = (nState & 0x0000200L/*DFCS_PUSHED*/);
  24.     long bFlat = (nState & 0x0001000L/*DFCS_FLAT*/);
  25.     long bInactive = (nState & 0x00080000L/*DFCS_INACTIVE*/);
  26.     HideMouse();
  27.     switch(nType){
  28.                           case 14/*DFC_TEXT*/:
  29.                                   TextOut(left,top,szText,(bInactive)?3:4,0,FONT_TAHOMA_8);
  30.                                   break;
  31.                           case 13/*DFC_GROUPBOX*/:
  32.                                   Draw3dRect2(left,top+7,right,bottom,0,0);
  33.                                   GrKresliP²edm╪t(140,1,left,top+7);
  34.                                   GrKresliP²edm╪t(141,1,right-3,top+7);
  35.                                   GrKresliP²edm╪t(142,1,right-3,bottom-3);
  36.                                   GrKresliP²edm╪t(143,1,left,bottom-3);
  37.                                                                   RECT r;CopyRect(&r,lpRect);InflateRect(&r,-9,0,-6,30);
  38.                                                                   DrawText(szText,&r,2,1,0x10,FONT_TAHOMA_8);
  39.                                   //TextOut(left+9,top,szText,2,1,FONT_TAHOMA_8);
  40.  
  41.  
  42.                                   break;
  43.               case 10/*DFC_SCROLLBARVER*/:
  44.                GrNastavBarvuPozadí(0);
  45.                GrNastavV∞plσ(1,&Vzorek);
  46.                FillSolidRect2(left,top+17,right,bottom-17,5);
  47.                RECT rrr;
  48.                CopyRect(&rrr,lpRect);
  49.                rrr.bottom = rrr.top+17;
  50.                DrawFrameControl(&rrr,3/*DFC_SCROLL*/,0x0000010L/*DFCS_SCROLLUP*/,0,0);
  51.                rrr.bottom = bottom;
  52.                rrr.top = bottom-17;
  53.                DrawFrameControl(&rrr,3/*DFC_SCROLL*/,0x0000020L/*DFCS_SCROLLDOWN*/,0,0);
  54.                GrNastavV∞plσ(0);
  55.                break;
  56.           case 9/*DFC_LISTBOX*/:
  57.                //f((bClientEdge)){
  58.                //      DrawEdge(lpRect,0x0001/*DES_CLIENT*/);
  59.                //      xplus+=2;
  60.                //
  61.                //lse {
  62.                      Draw3dRect(lpRect,3,3);
  63.                      Draw3dRect2(left+1,top+1,right-1,bottom-1,5,5);
  64.  
  65.                 //
  66.                 RECT re;
  67.                 SetRect(&re,right-18,top+2,right-2,bottom-2);
  68.                 FillSolidRect2(left+1,top+1,right-19,bottom-1,5);
  69.                 DrawFrameControl(&re,10/*DFC_SCROLLBARVER*/,0x0000020L/*DFCS_SCROLLDOWN*/|0x0000010L/*DFCS_SCROLLUP*/,0,0);
  70.  
  71.                     break;
  72.           case 8/*DFC_COMBOBOX*/:
  73.                 int pplus=0;
  74.                 pplus =1;
  75.                 RECT rx;
  76.                 SetRect(&rx,right-15-pplus,top+pplus,right-pplus,bottom-pplus);
  77.                 //rx.left = right-15-pplus;rx.right=right-pplus;rx.top=top+pplus;rx.bottom=bottom-pplus;
  78.                 pplus =0;
  79.                 unsigned bColor = (bFocus || bMouseOver)?12:5;
  80.                 if((bClientEdge)){
  81.                      Draw3dRect(lpRect,bColor,bColor);
  82.                      Draw3dRect2(right-17,top,right-17,bottom,bColor,bColor);
  83.                  }
  84.  
  85.                 pplus =1;
  86.                           RECT rc;
  87.                           CopyRect(&rc,lpRect);
  88.                           rc.left+=8;
  89.  
  90.                 if(bFocus){
  91.                           Draw3dRect2(left+1,top+1,right-18,bottom-1,5,5);
  92.                           FillSolidRect2(left+pplus+1,top+pplus+1,right-1-pplus-17,bottom-1-pplus,12);
  93.                                                   DrawText(szText,&rc,5,12,0x00000004 /*DT_VCENTER*/|0x00000000,FONT_TAHOMA_8);
  94.                                 }
  95.                 else {
  96.                           Draw3dRect2(left+1,top+1,right-18,bottom-1,5,5);
  97.                           FillSolidRect2(left+pplus,top+pplus,right-pplus-18,bottom-pplus,5);
  98.                                                   DrawText(szText,&rc,4,5,0x00000004 /*DT_VCENTER*/|0x00000000,FONT_TAHOMA_8);
  99.  
  100.                                 }
  101.                  FillSolidRect(&rx,13);
  102.                         GrKresliP²edm╪t((bColor==12)?15019:15004,1,rx.right-10,rx.top+8);
  103.  
  104.  
  105.                break;
  106.            case 7/*DFC_EDIT*/:
  107.                    if(bClientEdge)Draw3dRect(lpRect,13,13);
  108.                    FillSolidRect2(left+1,top+1,right-1,bottom-1,5);
  109.                                    break;
  110.            case 2/*DFC_MENU*/:
  111.                int flated=0;
  112.                if(nState & 0x0000001L/*DFCS_MENUCHECKED*/){
  113.                    FillSolidRect2(left+1,top+1,right-1,bottom-1,1);
  114.                    LineFromTo2(left,top,right-1,top,15);
  115.                    LineFromTo2(left,top+1,left,bottom,15);
  116.                    LineFromTo2(right,bottom,right,top,15);
  117.                    LineFromTo2(right-1,bottom,left+1,bottom,1);
  118.                }
  119.                else if(bMouseOver){
  120.                    FillSolidRect2(left+1,top+1,right-1,bottom-1,13);
  121.                    Draw3dRect(lpRect,12,12);
  122.  
  123.  
  124.                }
  125.                else
  126.                    FillSolidRect(lpRect,1);
  127.                TextOut(left+6+flated,top+3+flated,szText,4,0,FONT_TAHOMA_8);
  128.                break;
  129.            case 3/*DFC_SCROLL*/:
  130.                   int deltaplus = (bPushed && bMouseOver)?1:0;
  131.                   int iy; iy=(bottom - top)/2-1+top+deltaplus;
  132.                   int ix; ix=(right - left)/2-3+left+deltaplus;
  133.  
  134.                   FillSolidRect2(left+1,top+1,right-1,bottom-1,0);
  135.                   if(bPushed && bMouseOver){
  136.                                           Draw3dRect(lpRect,3,3);
  137.                                   }
  138.                                   else{
  139.                                           DrawEdge(lpRect,0x0004/*DES_MODAL*/);
  140.                                   }
  141.                        if (nState & 0x0000010L/*DFCS_SCROLLUP*/)GrKresliP²edm╪t(15003/*IDB_SCROLLUP*/,1,ix,iy);
  142.                        else  GrKresliP²edm╪t(15004/*IDB_SCROLLDOWN*/,1,ix,iy);
  143.  
  144.  
  145.  
  146.                break;
  147.            case 4/*DFC_BUTTON*/:
  148.  
  149.                     if(nState & 0x0000001L/*DFCS_BUTTONCHECK*/ || nState & 0x0000002L/*DFCS_BUTTONRADIO*/){
  150.                                                 char id=(bInactive)?144:126;
  151.  
  152.                       if(nState & 0x0000002L/*DFCS_BUTTONRADIO*/)id+=2;
  153.                       if(MouseEvent.Tlaƒítka == 1 && bMouseOver)id-=15;
  154.                       if(bPushed)id-=1;
  155.                                           if(MouseEvent.Tlaƒítka != 1 && bMouseOver)id+=11;
  156.                       GrKresliP²edm╪t(id,1,left,top);
  157.  
  158.                       TextOut(left+18,top,szText,(bInactive)?3:4,0,FONT_TAHOMA_8);
  159.  
  160.  
  161.  
  162.                     }
  163.                     else if(nState & 0x0000004L/*DFCS_BUTTONPUSH*/){
  164.                                           char id=76,color;
  165.                                           color = 5;
  166.                                           if(bFocus){id=46;color=13;}
  167.                                           if(bMouseOver){id=48;color = 7;}
  168.                                           if(bInactive){id=78;color=5;}
  169.                                                if(bPushed){
  170.                                                   if(bMouseOver){id=66;color=1;}
  171.                                                   else{id=76;color=5;}
  172.                                                   FillSolidRect2(left+2,top+2,right-2,bottom-2,color);
  173.  
  174.                                                }
  175.                                           // draw cells
  176.                                              Draw3dRect(lpRect,(bInactive)?0:12/*BLUE*/,(bInactive)?0:12/*BLUE*/);
  177.                                              Draw3dRect2(left+1,top+1,right-1,bottom-1,color/*BLUE*/,color/*BLUE*/);
  178.                                              Draw3dRect2(left+2,top+2,right-2,bottom-2,color/*BLUE*/,color/*BLUE*/);
  179.                                              if(id==76){
  180.                                                   LineFromTo2(left+4,bottom-1,right-4,bottom-1,0);
  181.                                                   LineFromTo2(right-1,top+4,right-1,bottom-4,0);
  182.                                              }
  183.                                              if(!bInactive){
  184.                                                   LineFromTo2(left+4,bottom+1,right-4,bottom+1,5);
  185.                                              }
  186.                                              else
  187.                                                   Draw3dRect2(left-1,top-1,right+1,bottom+1,1,1);
  188.  
  189.                                           // draw cornels
  190.                                              GrKresliP²edm╪t(id,1,left-1,top-1);
  191.                                              GrKresliP²edm╪t(id+1,1,right-4,top-1);
  192.                                              GrKresliP²edm╪t(id+15,1,left-1,bottom-3);
  193.                                              GrKresliP²edm╪t(id+16,1,right-4,bottom-3);
  194.  
  195.                                           //if(!bMouseOver || MouseEvent.Tlaƒítka == 1){
  196.                                                                                          DrawText(szText,lpRect,(bInactive)?3:4,(bPushed && bMouseOver)?1:5,DT_CENTER|DT_VCENTER,FONT_TAHOMA_8);
  197.                                                   
  198.                                           //}
  199.                                           
  200.                     }
  201.  
  202.               break;
  203.        }
  204.  
  205.        ShowMouse();
  206.  
  207.  
  208. }
  209. void DrawPopUpMenu(unsigned hWnd, long lParam, long wParam){
  210.     RECT * lpRect = &GetWindow(hWnd)->Rect;
  211.     int left ,top,right,bottom;
  212.     RectToVariable(lpRect,left,top,right,bottom);
  213.     if(wParam != 2){HideMouse();}
  214.     if(lParam == -1){
  215.          if(m_POPUPMENU_TOMENU == 1){
  216.               int k2 = IDC_MENU_RECT[IDC_MENU_OVER]-1;
  217.                           if(IDC_MENU_OVER != 0){k2-=IDC_MENU_RECT[IDC_MENU_OVER-1]+1;}
  218.               LineFromTo2(left+1,top,left+k2-2,top,1);
  219.               LineFromTo2(left+(k2)+1,top,right-1,top,15);
  220.          }
  221.          else {
  222.              LineFromTo2(left,top,right-1,top,15);
  223.          }
  224.          LineFromTo2(left,top,left,bottom,15);
  225.          LineFromTo2(right,bottom,right,top,15);
  226.          LineFromTo2(right-1,bottom,left+1,bottom,15);
  227.          FillSolidRect2(left+1,top+2,left+24,bottom-1,1);
  228.          FillSolidRect2(left+25,top+1,right-1,bottom-1,5);
  229.          LineFromTo2(left+1,top+1,right-1,top+1,5);
  230.          LineFromTo2(left+1,bottom-1,right-1,bottom-1,5);
  231.  
  232.          int i;
  233.          for(i=0;i < m_POPUPMENU_ROWS; i++){
  234.               DrawPopUpMenu(3 /* IDC_POPUPMENU */,i,2);
  235.          }
  236.     }
  237.     else {
  238.          int img = m_POPUPMENU_IMAGES[lParam];
  239.          int enable = m_POPUPMENU_ENABLE[lParam];
  240.          top = top+2+((lParam != 0)?m_POPUPMENU_HEIGHTS[lParam-1]:0);
  241.          bottom = top+3+m_POPUPMENU_HEIGHTS[lParam];
  242.          if(m_POPUPMENU_selitem == lParam){
  243.              FillSolidRect2(left+2,top,right-3,top+21,13);
  244.              Draw3dRect2(left+2,top,right-2,top+22,12,12);
  245.              if(img != -1){
  246.                GrKresliP²edm╪t(img+1,1,left+3,top);
  247.              }
  248.  
  249.          }
  250.          else {
  251.              if(wParam != 2){
  252.                    FillSolidRect2(left+2,top,left+24,top+22,1);
  253.                    FillSolidRect2(left+25,top,right-2,top+22,5);
  254.              }
  255.              if(img != -1){
  256.                  if((enable!=0))GrKresliP²edm╪t(img,1,left+3,top);
  257.                  else GrKresliP²edm╪t(img+15000,1,left+3,top);
  258.              }
  259.  
  260.  
  261.          }
  262.  
  263.  
  264.  
  265.          if(m_POPUPMENU_STRINGS[lParam] == "-"){
  266.                     LineFromTo2(left+34,top+2,right-1,top+2,3);
  267.  
  268.          }
  269.          else {
  270.              if(enable != 0){
  271.                          TextOut(left+35,top+5,m_POPUPMENU_STRINGS[lParam],4,(m_POPUPMENU_selitem == lParam)?13:5,FONT_TAHOMA_8);
  272.              }
  273.              else {
  274.                         TextOut(left+35,top+5,m_POPUPMENU_STRINGS[lParam],3,5,FONT_TAHOMA_8);
  275.              }
  276.          }
  277.  
  278.  
  279.      }
  280.         if(wParam != 2){ShowMouse();}
  281. }
  282. ///////////////////////////////////////////////////////////////////////////
  283. ///////////////////////////////////////////////////////////////////////////
  284. ///////////////////////////////////////////////////////////////////////////
  285. ///////////////////////////////////////////////////////////////////////////
  286.