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