Subversion Repositories Kolibri OS

Rev

Rev 675 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. ;button's types
  3. bt_check_text_type                 = 00000001b
  4. bt_check_picture_type              = 00000010b
  5. bt_check_picture_text_type         = 00000100b
  6. bt_no_draw                         = 00001000b
  7. bt_check_3D_type                   = 00010000b
  8. bt_check_full_redraw               = 10000000b
  9. bt_full_redraw_off                 = 01111111b
  10.  
  11. ;button's flags
  12. bt_crossing                        = 00000001b
  13. bt_crossing_pressing               = 00000011b
  14. bt_crossing_pressing_off           = 11111100b
  15.  
  16. bt_control_data_size               = 50
  17.  
  18. ;****************************************************
  19. ;******************craete Button**********************
  20. ;****************************************************
  21. ;IN
  22. ;pointer to parend
  23. ;pointer to Buttton's structure
  24. ;OUT
  25. ;pointer to initialized Button's structure
  26. align 4
  27.  
  28. craete_button:
  29.  
  30.       push ebx
  31.       push ecx
  32.       push edx
  33.       push esi
  34.       push edi
  35.       push ebp
  36.  
  37.       mov ebx,[esp+24+4] ;parend
  38.       mov eax,[esp+24+8] ;control
  39.  
  40.       mov [PointerToStructureForButton],eax
  41.  
  42.       mov eax,control_header_size+bt_control_data_size
  43.       call craete_control
  44.  
  45.       ;set all button's parameters in control
  46.       mov ecx,dword button
  47.       mov [eax],dword button
  48.  
  49.       mov ecx,bt_control_data_size
  50.       mov esi,[PointerToStructureForButton]
  51.       mov edi,eax
  52.       add edi,control_header_size
  53.       rep movsb
  54.  
  55.       mov ebx,[PointerToStructureForButton]
  56.       xor ecx,ecx
  57.       xor edx,edx
  58.       xor esi,esi
  59.       xor edi,edi
  60.       mov cx,[ebx+2]   ;button x
  61.       mov dx,[ebx+4]   ;button y
  62.       mov si,[ebx+6]   ;button size x
  63.       mov di,[ebx+8]   ;button size y
  64.  
  65.       call get_skin_height
  66.       add ecx,border_width
  67.       add edx,[skin_height]
  68.       ;copy information to control
  69.       mov [eax+24],ecx
  70.       mov [eax+28],edx
  71.       mov [eax+32],esi
  72.       mov [eax+36],edi
  73.  
  74.       pop ebp
  75.       pop edi
  76.       pop esi
  77.       pop edx
  78.       pop ecx
  79.       pop ebx
  80.  
  81.       ret 8
  82.  
  83. ;****************************************************
  84. ;*******************Draw Button**********************
  85. ;****************************************************
  86. ;IN
  87. ;pointer to control of button
  88. ;message
  89. ;OUT
  90. ;not returned value
  91. align 4
  92.  
  93. button:
  94.  
  95.       ;get message
  96.       mov eax,[esp+8]
  97.  
  98.       ;get pointer to control of button
  99.       mov esi,[esp+4]
  100.       mov [PointerForButton],esi
  101.       ;copy control to local control
  102.       mov edi,dword Button
  103.       mov ecx,control_header_size+bt_control_data_size
  104.       cld
  105.       rep movsb
  106.  
  107.  
  108.       cmp [eax],dword 1
  109.       jne no_redraw_all_button
  110.  
  111.       or [Button.type],bt_check_full_redraw
  112.       no_redraw_all_button:
  113.  
  114.       cmp [eax],dword 2
  115.       jne no_keys_button
  116.  
  117.       jmp exit_button
  118.       no_keys_button:
  119.  
  120.       cmp [eax],dword 3
  121.       jne no_pressed_button_button
  122.  
  123.       jmp exit_button
  124.       no_pressed_button_button:
  125.  
  126.       cmp [eax],dword 6
  127.       jne no_mouse_button
  128.  
  129.       mov esi,[eax+4]
  130.       mov edi,[eax+8]
  131.       mov ecx,[eax+12]
  132.       mov [Button.mouseX],si
  133.       mov [Button.mouseY],di
  134.       mov [ButtonsOfMouse],ecx
  135.  
  136.       no_mouse_button:
  137.  
  138.  
  139.       cmp [eax],dword -1
  140.       jne no_delete_button
  141.  
  142.       jmp exit_button
  143.       no_delete_button:
  144.  
  145.       ;load coordinats and size from control
  146.       mov eax,[PointerForButton]
  147.       mov ebx,[eax+24]           ;x
  148.       mov ecx,[eax+28]           ;y
  149.       mov edx,[eax+32]           ;size x
  150.       mov esi,[eax+36]           ;size y
  151.       ;set current coordinats and sizes in zakladka
  152.       mov [Button.x],bx
  153.       mov [Button.y],cx
  154.       mov [Button.width],dx
  155.       mov [Button.height],si
  156.  
  157.  
  158.       mov [Button.color2],0xffffff
  159.  
  160.       xor eax,eax
  161.       mov al,[Button.type]
  162.       and al,bt_check_full_redraw
  163.       test al,al
  164.       jz  no_redraw_button
  165.  
  166.       and [Button.type],bt_full_redraw_off
  167.  
  168.       mov esi,dword Button
  169.       mov edi,[PointerForButton]
  170.       add esi,control_header_size
  171.       add edi,control_header_size
  172.       mov ecx,2
  173.       cld
  174.       rep movsb
  175.  
  176.       ;if bit 3 is tru than no draw button
  177.       mov al,[Button.type]
  178.       and al,bt_no_draw
  179.       test al,al
  180.       jnz  no_draw_button
  181.  
  182.       ;generate colors tables
  183.       mov eax,[Button.color1]
  184.       mov ebx,0xffffff
  185.       mov ecx,20
  186.       mov edx,dword colors_table1
  187.       call gradient
  188.  
  189.       xor eax,eax
  190.       mov ebx,[Button.color1]
  191.       mov ecx,20
  192.       mov edx,dword colors_table2
  193.       call gradient
  194.  
  195.       xor eax,eax
  196.       mov al,[Button.type]
  197.  
  198.       and al,bt_check_3D_type
  199.       test al,al
  200.       jz no_3d_button
  201.  
  202.       ;draw gradient up rectangle
  203.       mov eax,[Button.color1]
  204.       mov ebx,[Button.color2]
  205.       and eax,0xffffff
  206.       and ebx,0xffffff
  207.       xor ecx,ecx
  208.       xor edx,edx
  209.       xor esi,esi
  210.       xor edi,edi
  211.       mov cx,[Button.x]
  212.       mov dx,[Button.y]
  213.       mov si,[Button.width]
  214.       mov di,[Button.height]
  215.       add cx,1
  216.       add dx,2
  217.       sub si,1
  218.       sub di,3
  219.       call rectangle_gradient_up
  220.  
  221.       mov eax,[Button.color1]
  222.       mov [Line.color],eax
  223.  
  224.       ;draw left vertical line
  225.       xor eax,eax
  226.       xor ebx,ebx
  227.       xor ecx,ecx
  228.       mov ax,[Button.x]
  229.       mov bx,[Button.y]
  230.       mov cx,[Button.height]
  231.       mov [Line.x1],eax
  232.       mov [Line.x2],eax
  233.       mov [Line.y1],ebx
  234.       mov [Line.y2],ebx
  235.       add [Line.y1],3
  236.       add [Line.y2],ecx
  237.       call DrawLine
  238.  
  239.       ;draw right vertical line
  240.       xor eax,eax
  241.       xor ebx,ebx
  242.       xor ecx,ecx
  243.       xor esi,esi
  244.       mov ax,[Button.x]
  245.       mov bx,[Button.y]
  246.       mov cx,[Button.height]
  247.       mov si,[Button.width]
  248.       add eax,esi
  249.       mov [Line.x1],eax
  250.       mov [Line.x2],eax
  251.       mov [Line.y1],ebx
  252.       mov [Line.y2],ebx
  253.       add [Line.y1],3
  254.       add [Line.y2],ecx
  255.       call DrawLine
  256.  
  257.       ;draw down 1 horizontal line
  258.       xor eax,eax
  259.       xor ebx,ebx
  260.       xor ecx,ecx
  261.       xor esi,esi
  262.       mov ax,[Button.x]
  263.       mov bx,[Button.y]
  264.       mov cx,[Button.height]
  265.       mov si,[Button.width]
  266.       add ebx,ecx
  267.       mov [Line.x1],eax
  268.       mov [Line.x2],eax
  269.       mov [Line.y1],ebx
  270.       mov [Line.y2],ebx
  271.       add [Line.x1],1
  272.       sub esi,1
  273.       add [Line.x2],esi
  274.       call DrawLine
  275.  
  276.       ;draw up light horizontal rectangle
  277.       xor ecx,ecx
  278.       xor esi,esi
  279.       mov si,[Button.height]
  280.       mov di,[Button.width]
  281.       mov eax,13
  282.       mov bx,[Button.x]
  283.       mov cx,[Button.y]
  284.       mov edx,0xffffff
  285.       add ebx,2
  286.       add ecx,1
  287.       shl ebx,16
  288.       shl ecx,16
  289.       sub edi,3
  290.       add ebx,edi
  291.       add ecx,2
  292.       mcall
  293.  
  294.       ;draw left light vertical line
  295.       xor eax,eax
  296.       xor ebx,ebx
  297.       xor ecx,ecx
  298.       xor edx,edx
  299.       mov ax,[Button.x]
  300.       mov bx,[Button.y]
  301.       mov cx,[Button.height]
  302.  
  303.       ;calculate color
  304.       mov dx,[Button.height]
  305.       sub edx,3+2
  306.       mov esi,[pointer+edx*3]
  307.       and esi,0xffffff
  308.       add eax,1
  309.       mov [Line.x1],eax
  310.       mov [Line.x2],eax
  311.       mov [Line.y1],ebx
  312.       mov [Line.y2],ebx
  313.       mov [Line.color],esi; dword 0xffffff
  314.       add [Line.y1],2
  315.       sub ecx,3
  316.       add [Line.y2],ecx
  317.       call DrawLine
  318.  
  319.       ;draw right light vertical line
  320.       xor eax,eax
  321.       xor ebx,ebx
  322.       xor ecx,ecx
  323.       xor edx,edx
  324.       mov ax,[Button.x]
  325.       mov bx,[Button.y]
  326.       mov cx,[Button.height]
  327.  
  328.       add ax,[Button.width]
  329.       sub eax,1
  330.       mov [Line.x1],eax
  331.       mov [Line.x2],eax
  332.       mov [Line.y1],ebx
  333.       mov [Line.y2],ebx
  334.       add [Line.y1],2
  335.       sub ecx,3
  336.       add [Line.y2],ecx
  337.       call DrawLine
  338.  
  339.       mov eax,[pointer+3*3]
  340.       and eax,0xffffff
  341.       mov [Button.color2],eax
  342.       mov [Line.color],eax
  343.  
  344.       ;draw up light left vertical line 1
  345.       xor eax,eax
  346.       xor ebx,ebx
  347.       xor ecx,ecx
  348.       xor esi,esi
  349.       mov ax,[Button.x]
  350.       mov bx,[Button.y]
  351.       mov cx,[Button.height]
  352.       mov si,[Button.width]
  353.       mov [Line.x1],eax
  354.       mov [Line.x2],eax
  355.       mov [Line.y1],ebx
  356.       mov [Line.y2],ebx
  357.       add [Line.y2],2
  358.       call DrawLine
  359.  
  360.       ;draw up light right vertical line 1
  361.       xor eax,eax
  362.       xor ebx,ebx
  363.       xor ecx,ecx
  364.       xor esi,esi
  365.       mov ax,[Button.x]
  366.       mov bx,[Button.y]
  367.       mov cx,[Button.height]
  368.       mov si,[Button.width]
  369.       add eax,esi
  370.       mov [Line.x1],eax
  371.       mov [Line.x2],eax
  372.       mov [Line.y1],ebx
  373.       mov [Line.y2],ebx
  374.       add [Line.y2],2
  375.       call DrawLine
  376.  
  377.       ;draw up light left vertical line 2
  378.       xor eax,eax
  379.       xor ebx,ebx
  380.       xor ecx,ecx
  381.       xor esi,esi
  382.       mov ax,[Button.x]
  383.       mov bx,[Button.y]
  384.       mov cx,[Button.height]
  385.       mov si,[Button.width]
  386.       add eax,1
  387.       mov [Line.x1],eax
  388.       mov [Line.x2],eax
  389.       mov [Line.y1],ebx
  390.       mov [Line.y2],ebx
  391.       add [Line.y2],1
  392.       call DrawLine
  393.  
  394.       ;draw up light right vertical line 2
  395.       xor eax,eax
  396.       xor ebx,ebx
  397.       xor ecx,ecx
  398.       xor esi,esi
  399.       mov ax,[Button.x]
  400.       mov bx,[Button.y]
  401.       mov cx,[Button.height]
  402.       mov si,[Button.width]
  403.       add eax,esi
  404.       sub eax,1
  405.       mov [Line.x1],eax
  406.       mov [Line.x2],eax
  407.       mov [Line.y1],ebx
  408.       mov [Line.y2],ebx
  409.       add [Line.y2],1
  410.       call DrawLine
  411.  
  412.       ;draw up light horizontal line
  413.       xor eax,eax
  414.       xor ebx,ebx
  415.       xor ecx,ecx
  416.       xor esi,esi
  417.       mov ax,[Button.x]
  418.       mov bx,[Button.y]
  419.       mov cx,[Button.height]
  420.       mov si,[Button.width]
  421.       mov [Line.x1],eax
  422.       mov [Line.x2],eax
  423.       mov [Line.y1],ebx
  424.       mov [Line.y2],ebx
  425.       add [Line.x1],2
  426.       sub esi,2
  427.       add [Line.x2],esi
  428.       call DrawLine
  429.  
  430.       mov eax,[pointer+3*3]
  431.       mov ebx,[pointer+3*9]
  432.       and eax,0xffffff
  433.       and ebx,0xffffff
  434.       call calculate_average_color
  435.  
  436.       mov [Pixel.color],eax
  437.  
  438.       ;(x,y)
  439.       xor eax,eax
  440.       xor ebx,ebx
  441.       mov ax,[Button.x]
  442.       mov bx,[Button.y]
  443.       mov [Pixel.x],eax
  444.       mov [Pixel.y],ebx
  445.       call DrawPixel
  446.  
  447.       ;(x+size_x,y)
  448.       xor eax,eax
  449.       xor ebx,ebx
  450.       xor ecx,ecx
  451.       mov ax,[Button.x]
  452.       mov bx,[Button.y]
  453.       mov cx,[Button.width]
  454.       add eax,ecx
  455.       mov [Pixel.x],eax
  456.       mov [Pixel.y],ebx
  457.       call DrawPixel
  458.  
  459.       ;(x+1,y+1)
  460.       xor eax,eax
  461.       xor ebx,ebx
  462.       mov ax,[Button.x]
  463.       mov bx,[Button.y]
  464.       add eax,1
  465.       add ebx,1
  466.       mov [Pixel.x],eax
  467.       mov [Pixel.y],ebx
  468.       call DrawPixel
  469.  
  470.       ;(x+size_x-1,y+1)
  471.       xor eax,eax
  472.       xor ebx,ebx
  473.       xor ecx,ecx
  474.       mov ax,[Button.x]
  475.       mov bx,[Button.y]
  476.       mov cx,[Button.width]
  477.       add eax,ecx
  478.       sub eax,1
  479.       add ebx,1
  480.       mov [Pixel.x],eax
  481.       mov [Pixel.y],ebx
  482.       call DrawPixel
  483.  
  484.       ;(x,y+size_y)
  485.       xor eax,eax
  486.       xor ebx,ebx
  487.       mov ax,[Button.x]
  488.       mov bx,[Button.y]
  489.       add bx,[Button.height]
  490.       mov [Pixel.x],eax
  491.       mov [Pixel.y],ebx
  492.       call DrawPixel
  493.  
  494.       ;(x+size_x,y+size_y)
  495.       xor eax,eax
  496.       xor ebx,ebx
  497.       xor ecx,ecx
  498.       mov ax,[Button.x]
  499.       mov bx,[Button.y]
  500.       mov cx,[Button.width]
  501.       add eax,ecx
  502.       add bx,[Button.height]
  503.       mov [Pixel.x],eax
  504.       mov [Pixel.y],ebx
  505.       call DrawPixel
  506.  
  507.       ;(x+1,y+size_y-2)
  508.       xor eax,eax
  509.       xor ebx,ebx
  510.       mov ax,[Button.x]
  511.       mov bx,[Button.y]
  512.       add eax,1
  513.       add bx,[Button.height]
  514.       sub ebx,2
  515.       mov [Pixel.x],eax
  516.       mov [Pixel.y],ebx
  517.       call DrawPixel
  518.  
  519.       ;(x+size_x-1,y+size_y-2)
  520.       xor eax,eax
  521.       xor ebx,ebx
  522.       xor ecx,ecx
  523.       mov ax,[Button.x]
  524.       mov bx,[Button.y]
  525.       mov cx,[Button.width]
  526.       add eax,ecx
  527.       sub eax,1
  528.       add bx,[Button.height]
  529.       sub ebx,2
  530.       mov [Pixel.x],eax
  531.       mov [Pixel.y],ebx
  532.       call DrawPixel
  533.  
  534.       no_3d_button:
  535.  
  536.       ;****************************
  537.       ;*********2D button**********
  538.       ;****************************
  539.       xor eax,eax
  540.       mov al,[Button.type]
  541.       and al,bt_check_3D_type
  542.       test al,al
  543.       jnz no_2D_button
  544.  
  545.       mov edx,[colors_table1+18]
  546.       and edx,0xffffff
  547.  
  548.       xor ebx,ebx
  549.       xor ecx,ecx
  550.       xor esi,esi
  551.       xor edi,edi
  552.       mov si,[Button.width]
  553.       mov di,[Button.height]
  554.       mov eax,13
  555.       mov bx,[Button.x]
  556.       mov cx,[Button.y]
  557.       add ebx,1
  558.       add ecx,1
  559.       sub si,1
  560.       sub di,1
  561.       shl ebx,16
  562.       shl ecx,16
  563.       add ebx,esi
  564.       add ecx,edi
  565.       mcall
  566.  
  567.       mov eax,[colors_table1+15*3]
  568.       and eax,0xffffff
  569.       mov [Line.color],eax
  570.  
  571.       xor eax,eax
  572.       xor ebx,ebx
  573.       xor ecx,ecx
  574.       mov ax,[Button.x]
  575.       mov bx,[Button.y]
  576.       mov cx,[Button.height]
  577.       mov [Line.x1],eax
  578.       mov [Line.x2],eax
  579.       mov [Line.y1],ebx
  580.       mov [Line.y2],ebx
  581.       add [Line.y2],ecx
  582.       call DrawLine
  583.  
  584.       xor eax,eax
  585.       xor ebx,ebx
  586.       xor esi,esi
  587.       mov ax,[Button.x]
  588.       mov bx,[Button.y]
  589.       mov si,[Button.width]
  590.       mov [Line.x1],eax
  591.       mov [Line.x2],eax
  592.       mov [Line.y1],ebx
  593.       mov [Line.y2],ebx
  594.       add [Line.x2],esi
  595.       call DrawLine
  596.  
  597.       mov eax,[colors_table2+8*3]
  598.       and eax,0xffffff
  599.       mov [Line.color],eax
  600.  
  601.       xor eax,eax
  602.       xor ebx,ebx
  603.       xor ecx,ecx
  604.       xor esi,esi
  605.       mov ax,[Button.x]
  606.       mov bx,[Button.y]
  607.       mov cx,[Button.height]
  608.       mov si,[Button.width]
  609.       add eax,esi
  610.       mov [Line.x1],eax
  611.       mov [Line.x2],eax
  612.       mov [Line.y1],ebx
  613.       mov [Line.y2],ebx
  614.       add [Line.y2],ecx
  615.       call DrawLine
  616.  
  617.       xor eax,eax
  618.       xor ebx,ebx
  619.       xor ecx,ecx
  620.       xor esi,esi
  621.       mov ax,[Button.x]
  622.       mov bx,[Button.y]
  623.       mov cx,[Button.height]
  624.       mov si,[Button.width]
  625.       add ebx,ecx
  626.       mov [Line.x1],eax
  627.       mov [Line.x2],eax
  628.       mov [Line.y1],ebx
  629.       mov [Line.y2],ebx
  630.       add [Line.x2],esi
  631.       call DrawLine
  632.  
  633.       no_2D_button:
  634.  
  635.       no_draw_button:
  636.  
  637.       ;check drawing text on the button
  638.       xor eax,eax
  639.       mov al,[Button.type]
  640.  
  641.       and al,bt_check_text_type
  642.       test al,al
  643.       jz no_button_only_with_text
  644.  
  645.        call DrawStringOnTheButton
  646.        jmp end_case_button
  647.       no_button_only_with_text:
  648.  
  649.       ;check drawing picture on the button
  650.       xor eax,eax
  651.       mov al,[Button.type]
  652.       and al,bt_check_picture_type
  653.       test al,al
  654.       jz no_button_only_with_picture
  655.  
  656.         call DrawPictureOnTheButton
  657.         jmp end_case_button
  658.       no_button_only_with_picture:
  659.  
  660.  
  661.       xor eax,eax
  662.       mov al,[Button.type]
  663.       and al,bt_check_picture_text_type
  664.       test al,al
  665.       jz no_button_with_text_and_picture
  666.  
  667.       ;draw string in coordinats (textX,textY)
  668.       xor eax,eax
  669.       xor ebx,ebx
  670.       mov ax,[Button.textX]
  671.       mov bx,[Button.textY]
  672.       add ax,[Button.x]
  673.       add bx,[Button.y]
  674.       mov [Font.x],eax
  675.       mov [Font.y],ebx
  676.       call DrawString
  677.  
  678.       ;draw picture in coordinats (imageX,imageY)
  679.       xor eax,eax
  680.       xor ebx,ebx
  681.       mov ax,[Button.imageX]
  682.       mov bx,[Button.imageY]
  683.       add ax,[Button.x]
  684.       add bx,[Button.y]
  685.       mov [xo],eax
  686.       mov [x],eax
  687.       mov [y],ebx
  688.  
  689.       xor esi,esi
  690.       xor edi,edi
  691.       mov si,[Button.imageSizeX]
  692.       mov di,[Button.imageSizeY]
  693.       mov ebp,[Button.image]
  694.  
  695.       xor eax,eax
  696.       inc eax
  697.  
  698.         loop_y_image_:
  699.  
  700.           mov ebx,[xo]
  701.           mov [x],ebx
  702.  
  703.           xor esi,esi
  704.           mov si,[Button.imageSizeX]
  705.  
  706.           loop_x_image_:
  707.  
  708.              mov edx,[ebp]
  709.              and edx,0xffffff
  710.              cmp edx,[Button.transparentColor]
  711.              je no_draw_pixel_
  712.  
  713.                mov ebx,[x]
  714.                mov ecx,[y]
  715.                mcall
  716.              no_draw_pixel_:
  717.  
  718.              add ebp,3
  719.              add [x],1
  720.           dec esi
  721.           jnz  loop_x_image_
  722.  
  723.           add [y],1
  724.         dec edi
  725.         jnz loop_y_image_
  726.  
  727.       no_button_with_text_and_picture:
  728.  
  729.       no_redraw_button:
  730.  
  731.       end_case_button:
  732.  
  733.       xor eax,eax
  734.       xor ebx,ebx
  735.       xor ecx,ecx
  736.       xor edx,edx
  737.       xor esi,esi
  738.       xor edi,edi
  739.       mov ax,[Button.x]
  740.       mov bx,[Button.y]
  741.       mov cx,[Button.width]
  742.       mov dx,[Button.height]
  743.       mov si,[Button.mouseX]
  744.       mov di,[Button.mouseY]
  745.       call CheckCrossingBox
  746.  
  747.       cmp eax,0xffffff
  748.       jne no_crossing
  749.  
  750.         xor ebx,ebx
  751.         mov bl,[Button.type]
  752.         and bl,bt_check_3D_type
  753.         test bl,bl
  754.         jz button_active_2D
  755.  
  756.          push eax
  757.            mov eax,[ButtonsOfMouse]
  758.  
  759.            cmp eax,1
  760.            je button_pressed_3d_
  761.  
  762.              xor eax,eax
  763.              mov al,[Button.type]
  764.              and al,bt_no_draw
  765.              test al,al
  766.              jnz no_draw_active_button_3d_
  767.  
  768.                call Draw3DActiveButton
  769.  
  770.              no_draw_active_button_3d_:
  771.  
  772.              mov [Button.flag],byte bt_crossing
  773.            jmp exit_button_pressed_3d_
  774.  
  775.            button_pressed_3d_:
  776.  
  777.            xor eax,eax
  778.            mov al,[Button.type]
  779.            and al,bt_no_draw
  780.            test al,al
  781.            jnz no_draw_pressed_button_3d_
  782.  
  783.             call DrawPressed3DButton
  784.  
  785.            no_draw_pressed_button_3d_:
  786.  
  787.            mov [Button.flag],byte bt_crossing_pressing
  788.  
  789.            exit_button_pressed_3d_:
  790.  
  791.          pop eax
  792.  
  793.          ;save flag
  794.          mov esi,dword Button
  795.          mov edi,[PointerForButton]
  796.          add esi,control_header_size
  797.          add edi,control_header_size
  798.          mov ecx,2
  799.          cld
  800.          rep movsb
  801.          jmp no_crossing
  802.  
  803.         button_active_2D:
  804.  
  805.          push eax
  806.            mov eax,[ButtonsOfMouse]
  807.  
  808.            cmp eax,1
  809.            je button_pressed_2d
  810.  
  811.            xor eax,eax
  812.            mov al,[Button.type]
  813.            and al,bt_no_draw
  814.            test al,al
  815.            jnz no_active_button_2d_
  816.  
  817.             call Draw2DActiveButton
  818.  
  819.            no_active_button_2d_:
  820.  
  821.            mov [Button.flag],byte bt_crossing
  822.            jmp exit_button_pressed_2d
  823.            button_pressed_2d:
  824.  
  825.            xor eax,eax
  826.            mov al,[Button.type]
  827.            and al,bt_no_draw
  828.            test al,al
  829.            jnz no_draw_pressed_button_2d_
  830.  
  831.             call DrawPressed2DButton
  832.  
  833.            no_draw_pressed_button_2d_:
  834.  
  835.            mov [Button.flag],byte bt_crossing_pressing
  836.            exit_button_pressed_2d:
  837.  
  838.          pop eax
  839.  
  840.          ;save flag
  841.          mov esi,dword Button
  842.          mov edi,[PointerForButton]
  843.          add esi,control_header_size
  844.          add edi,control_header_size
  845.          mov ecx,2
  846.          cld
  847.          rep movsb
  848.       no_crossing:
  849.  
  850.       cmp eax,0xffffff
  851.       je yes_crossing
  852.       xor ebx,ebx
  853.       mov bl,[Button.flag]
  854.       and bl,bt_crossing
  855.       test bl,bl
  856.       jz yes_crossing
  857.  
  858.         xor ebx,ebx
  859.         mov bl,[Button.type]
  860.         and bl,bt_check_3D_type
  861.         test bl,bl
  862.         jz button_put_2D
  863.  
  864.          push eax
  865.  
  866.          xor eax,eax
  867.          mov al,[Button.type]
  868.          and al,bt_no_draw
  869.          test al,al
  870.          jnz no_draw_button_active_3d__
  871.  
  872.           call Put3DActiveButton
  873.          no_draw_button_active_3d__:
  874.  
  875.          pop eax
  876.  
  877.          and [Button.flag],bt_crossing_pressing_off
  878.          mov esi,dword Button
  879.          mov edi,[PointerForButton]
  880.          add edi,control_header_size
  881.          add esi,control_header_size
  882.          mov ecx,2
  883.          cld
  884.          rep movsb
  885.          jmp yes_crossing
  886.  
  887.         button_put_2D:
  888.  
  889.         push eax
  890.  
  891.         xor eax,eax
  892.         mov al,[Button.type]
  893.         and al,bt_no_draw
  894.         test al,al
  895.         jnz no_draw_button_active_2d__
  896.  
  897.          call Put2DActiveButton
  898.  
  899.         no_draw_button_active_2d__:
  900.  
  901.         pop eax
  902.  
  903.         and [Button.flag],bt_crossing_pressing_off
  904.         mov esi,dword Button
  905.         mov edi,[PointerForButton]
  906.         add esi,control_header_size
  907.         add edi,control_header_size
  908.         mov ecx,2
  909.         cld
  910.         rep movsb
  911.       yes_crossing:
  912.  
  913.       exit_button:
  914.  
  915.       ret 8
  916.  
  917. DrawStringOnTheButton:
  918.  
  919.       ;xor ebx,ebx
  920.       mov ebx,[Button.text]
  921.       call GetLengthString
  922.       imul eax,6  ;[Font.sizeX]
  923.       xor ebx,ebx
  924.       mov bx,[Button.width]
  925.       shr eax,1
  926.       shr ebx,1
  927.       sub ebx,eax
  928.       xor eax,eax
  929.       mov ax,[Button.x]
  930.       add eax,ebx
  931.       mov [Font.x],eax
  932.       xor ebx,ebx
  933.       mov bx,[Button.height]
  934.       shr ebx,1
  935.       sub ebx,3;[Font.sizeY]
  936.       xor eax,eax
  937.       mov ax,[Button.y]
  938.       add eax,ebx
  939.       mov [Font.y],eax
  940.       call DrawString
  941.  
  942.       ret
  943.  
  944. DrawPictureOnTheButton:
  945.  
  946.         xor esi,esi
  947.         xor edi,edi
  948.         xor eax,eax
  949.         xor ebx,ebx
  950.         mov ax,[Button.height]
  951.         mov bx,[Button.width]
  952.         mov di,[Button.imageSizeY]
  953.         mov si,[Button.imageSizeX]
  954.         shr ax,1
  955.         shr bx,1
  956.         shr si,1
  957.         shr di,1
  958.         sub ax,di
  959.         sub bx,si
  960.         add ax,[Button.y]
  961.         add bx,[Button.x]
  962.         mov [xo],ebx
  963.         mov [x],ebx
  964.         mov [y],eax
  965.  
  966.         xor esi,esi
  967.         xor edi,edi
  968.         mov si,[Button.imageSizeX]
  969.         mov di,[Button.imageSizeY]
  970.         mov ebp,[Button.image]
  971.  
  972.         xor eax,eax
  973.         inc eax
  974.  
  975.         loop_y_image:
  976.  
  977.            mov ebx,[xo]
  978.            mov [x],ebx
  979.  
  980.           xor esi,esi
  981.           mov si,[Button.imageSizeX]
  982.  
  983.           loop_x_image:
  984.  
  985.              mov edx,[ebp]
  986.              and edx,0xffffff
  987.              cmp edx,[Button.transparentColor]
  988.              je no_draw_pixel
  989.  
  990.                mov ebx,[x]
  991.                mov ecx,[y]
  992.                mcall
  993.              no_draw_pixel:
  994.  
  995.              add ebp,3
  996.              add [x],1
  997.           dec esi
  998.           jnz  loop_x_image
  999.  
  1000.           add [y],1
  1001.         dec edi
  1002.         jnz loop_y_image
  1003.  
  1004.       ret
  1005.  
  1006.  
  1007. Draw3DActiveButton:
  1008.  
  1009.       ;call calculate_average_color
  1010.       mov [Line.color],0xffffff;eax
  1011.  
  1012.       xor eax,eax
  1013.       xor ebx,ebx
  1014.       xor ecx,ecx
  1015.       mov ax,[Button.x]
  1016.       mov bx,[Button.y]
  1017.       mov cx,[Button.height]
  1018.       mov [Line.x1],eax
  1019.       mov [Line.x2],eax
  1020.       mov [Line.y1],ebx
  1021.       mov [Line.y2],ebx
  1022.       add [Line.y1],3
  1023.       sub ecx,1
  1024.       add [Line.y2],ecx
  1025.       call DrawLine
  1026.  
  1027.       xor eax,eax
  1028.       xor ebx,ebx
  1029.       xor ecx,ecx
  1030.       xor esi,esi
  1031.       mov ax,[Button.x]
  1032.       mov bx,[Button.y]
  1033.       mov cx,[Button.height]
  1034.       mov si,[Button.width]
  1035.       add eax,esi
  1036.       mov [Line.x1],eax
  1037.       mov [Line.x2],eax
  1038.       mov [Line.y1],ebx
  1039.       mov [Line.y2],ebx
  1040.       add [Line.y1],3
  1041.       sub ecx,1
  1042.       add [Line.y2],ecx
  1043.       call DrawLine
  1044.  
  1045.       xor eax,eax
  1046.       xor ebx,ebx
  1047.       xor ecx,ecx
  1048.       xor esi,esi
  1049.       mov ax,[Button.x]
  1050.       mov bx,[Button.y]
  1051.       mov cx,[Button.height]
  1052.       add ebx,ecx
  1053.       mov [Line.x1],eax
  1054.       mov [Line.x2],eax
  1055.       mov [Line.y1],ebx
  1056.       mov [Line.y2],ebx
  1057.       add [Line.x1],1
  1058.       xor ecx,ecx
  1059.       mov cx,[Button.width]
  1060.       sub ecx,1
  1061.       add [Line.x2],ecx
  1062.       call DrawLine
  1063.  
  1064.       xor eax,eax
  1065.       xor ebx,ebx
  1066.       xor ecx,ecx
  1067.       xor esi,esi
  1068.       mov ax,[Button.x]
  1069.       mov bx,[Button.y]
  1070.       mov [Line.x1],eax
  1071.       mov [Line.x2],eax
  1072.       mov [Line.y1],ebx
  1073.       mov [Line.y2],ebx
  1074.       add [Line.x1],1
  1075.       xor ecx,ecx
  1076.       mov cx,[Button.width]
  1077.       sub ecx,1
  1078.       add [Line.x2],ecx
  1079.       call DrawLine
  1080.  
  1081.       ret
  1082.  
  1083. Put3DActiveButton:
  1084.  
  1085.       mov eax,[Button.color1]
  1086.       mov ebx,0xffffff
  1087.       mov ecx,20
  1088.       mov edx,dword pointer
  1089.       call gradient
  1090.  
  1091.       mov eax,[pointer+3];[Button.color1]
  1092.       and eax,0xffffff
  1093.       mov [Line.color],eax
  1094.  
  1095.       xor eax,eax
  1096.       xor ebx,ebx
  1097.       xor ecx,ecx
  1098.       mov ax,[Button.x]
  1099.       mov bx,[Button.y]
  1100.       mov cx,[Button.height]
  1101.       mov [Line.x1],eax
  1102.       mov [Line.x2],eax
  1103.       mov [Line.y1],ebx
  1104.       mov [Line.y2],ebx
  1105.       add [Line.y1],3
  1106.       sub ecx,1
  1107.       add [Line.y2],ecx
  1108.       call DrawLine
  1109.  
  1110.       xor eax,eax
  1111.       xor ebx,ebx
  1112.       xor ecx,ecx
  1113.       xor esi,esi
  1114.       mov ax,[Button.x]
  1115.       mov bx,[Button.y]
  1116.       mov cx,[Button.height]
  1117.       mov si,[Button.width]
  1118.       add eax,esi
  1119.       mov [Line.x1],eax
  1120.       mov [Line.x2],eax
  1121.       mov [Line.y1],ebx
  1122.       mov [Line.y2],ebx
  1123.       add [Line.y1],3
  1124.       sub ecx,1
  1125.       add [Line.y2],ecx
  1126.       call DrawLine
  1127.  
  1128.  
  1129.       xor eax,eax
  1130.       xor ebx,ebx
  1131.       xor ecx,ecx
  1132.       xor esi,esi
  1133.       mov ax,[Button.x]
  1134.       mov bx,[Button.y]
  1135.       mov cx,[Button.height]
  1136.       add ebx,ecx
  1137.       mov [Line.x1],eax
  1138.       mov [Line.x2],eax
  1139.       mov [Line.y1],ebx
  1140.       mov [Line.y2],ebx
  1141.       add [Line.x1],1
  1142.       xor ecx,ecx
  1143.       mov cx,[Button.width]
  1144.       sub ecx,1
  1145.       add [Line.x2],ecx
  1146.       call DrawLine
  1147.  
  1148.       xor eax,eax
  1149.       xor ebx,ebx
  1150.       xor ecx,ecx
  1151.       xor esi,esi
  1152.       mov ax,[Button.x]
  1153.       mov bx,[Button.y]
  1154.       mov [Line.x1],eax
  1155.       mov [Line.x2],eax
  1156.       mov [Line.y1],ebx
  1157.       mov [Line.y2],ebx
  1158.       add [Line.x1],1
  1159.       xor ecx,ecx
  1160.       mov cx,[Button.width]
  1161.       sub ecx,1
  1162.       add [Line.x2],ecx
  1163.       call DrawLine
  1164.  
  1165.       ret
  1166.  
  1167. DrawPressed3DButton:
  1168.  
  1169.  
  1170.       mov eax,[Button.color1]
  1171.       mov ebx,0xffffff
  1172.       mov ecx,20
  1173.       mov edx,dword pointer
  1174.       call gradient
  1175.  
  1176.       mov edx,[pointer+3]
  1177.       and edx,0xffffff
  1178.       mov [Line.color],edx
  1179.  
  1180.       xor eax,eax
  1181.       xor ebx,ebx
  1182.       xor ecx,ecx
  1183.       mov ax,[Button.x]
  1184.       mov bx,[Button.y]
  1185.       mov cx,[Button.height]
  1186.       mov [Line.x1],eax
  1187.       mov [Line.x2],eax
  1188.       mov [Line.y1],ebx
  1189.       mov [Line.y2],ebx
  1190.       add [Line.y1],3
  1191.       sub ecx,1
  1192.       add [Line.y2],ecx
  1193.       call DrawLine
  1194.  
  1195.       xor eax,eax
  1196.       xor ebx,ebx
  1197.       xor ecx,ecx
  1198.       xor esi,esi
  1199.       mov ax,[Button.x]
  1200.       mov bx,[Button.y]
  1201.       mov cx,[Button.height]
  1202.       mov si,[Button.width]
  1203.       add eax,esi
  1204.       mov [Line.x1],eax
  1205.       mov [Line.x2],eax
  1206.       mov [Line.y1],ebx
  1207.       mov [Line.y2],ebx
  1208.       add [Line.y1],3
  1209.       sub ecx,1
  1210.       add [Line.y2],ecx
  1211.       call DrawLine
  1212.  
  1213.       xor eax,eax
  1214.       xor ebx,ebx
  1215.       xor ecx,ecx
  1216.       xor esi,esi
  1217.       mov ax,[Button.x]
  1218.       mov bx,[Button.y]
  1219.       mov cx,[Button.height]
  1220.       add ebx,ecx
  1221.       mov [Line.x1],eax
  1222.       mov [Line.x2],eax
  1223.       mov [Line.y1],ebx
  1224.       mov [Line.y2],ebx
  1225.       add [Line.x1],1
  1226.       xor ecx,ecx
  1227.       mov cx,[Button.width]
  1228.       sub ecx,1
  1229.       add [Line.x2],ecx
  1230.       call DrawLine
  1231.  
  1232.       xor eax,eax
  1233.       xor ebx,ebx
  1234.       xor ecx,ecx
  1235.       xor esi,esi
  1236.       mov ax,[Button.x]
  1237.       mov bx,[Button.y]
  1238.       mov [Line.x1],eax
  1239.       mov [Line.x2],eax
  1240.       mov [Line.y1],ebx
  1241.       mov [Line.y2],ebx
  1242.       add [Line.x1],1
  1243.       xor ecx,ecx
  1244.       mov cx,[Button.width]
  1245.       sub ecx,1
  1246.       add [Line.x2],ecx
  1247.       call DrawLine
  1248.  
  1249.       ret
  1250.  
  1251. Draw2DActiveButton:
  1252.  
  1253.       mov edx,[colors_table1]
  1254.       and edx,0xffffff
  1255.       ;mov [Button.color2],edx
  1256.  
  1257.       xor eax,eax
  1258.       xor ebx,ebx
  1259.       xor ecx,ecx
  1260.       mov ax,[Button.x]
  1261.       mov bx,[Button.y]
  1262.       mov cx,[Button.height]
  1263.       mov [Line.x1],eax
  1264.       mov [Line.x2],eax
  1265.       mov [Line.y1],ebx
  1266.       mov [Line.y2],ebx
  1267.       mov [Line.color],edx
  1268.       add [Line.y2],ecx
  1269.       call DrawLine
  1270.  
  1271.       xor eax,eax
  1272.       xor ebx,ebx
  1273.       xor esi,esi
  1274.       mov ax,[Button.x]
  1275.       mov bx,[Button.y]
  1276.       mov si,[Button.width]
  1277.       mov [Line.x1],eax
  1278.       mov [Line.x2],eax
  1279.       mov [Line.y1],ebx
  1280.       mov [Line.y2],ebx
  1281.       add [Line.x2],esi
  1282.       call DrawLine
  1283.  
  1284.       xor eax,eax
  1285.       xor ebx,ebx
  1286.       xor ecx,ecx
  1287.       xor esi,esi
  1288.       mov ax,[Button.x]
  1289.       mov bx,[Button.y]
  1290.       mov cx,[Button.height]
  1291.       mov si,[Button.width]
  1292.       add eax,esi
  1293.       mov [Line.x1],eax
  1294.       mov [Line.x2],eax
  1295.       mov [Line.y1],ebx
  1296.       mov [Line.y2],ebx
  1297.       add [Line.y2],ecx
  1298.       call DrawLine
  1299.  
  1300.       xor eax,eax
  1301.       xor ebx,ebx
  1302.       xor ecx,ecx
  1303.       xor esi,esi
  1304.       mov ax,[Button.x]
  1305.       mov bx,[Button.y]
  1306.       mov cx,[Button.height]
  1307.       mov si,[Button.width]
  1308.       add ebx,ecx
  1309.       mov [Line.x1],eax
  1310.       mov [Line.x2],eax
  1311.       mov [Line.y1],ebx
  1312.       mov [Line.y2],ebx
  1313.       add [Line.x2],esi
  1314.       call DrawLine
  1315.  
  1316.       ret
  1317.  
  1318. Put2DActiveButton:
  1319.  
  1320.       mov edx,[pointer+15*3]
  1321.       and edx,0xffffff
  1322.  
  1323.       xor eax,eax
  1324.       xor ebx,ebx
  1325.       xor ecx,ecx
  1326.       mov ax,[Button.x]
  1327.       mov bx,[Button.y]
  1328.       mov cx,[Button.height]
  1329.       mov [Line.x1],eax
  1330.       mov [Line.x2],eax
  1331.       mov [Line.y1],ebx
  1332.       mov [Line.y2],ebx
  1333.       mov [Line.color],edx
  1334.       add [Line.y2],ecx
  1335.       call DrawLine
  1336.  
  1337.       xor eax,eax
  1338.       xor ebx,ebx
  1339.       xor esi,esi
  1340.       mov ax,[Button.x]
  1341.       mov bx,[Button.y]
  1342.       mov si,[Button.width]
  1343.       mov [Line.x1],eax
  1344.       mov [Line.x2],eax
  1345.       mov [Line.y1],ebx
  1346.       mov [Line.y2],ebx
  1347.       add [Line.x2],esi
  1348.       call DrawLine
  1349.  
  1350.       mov edx,[colors_table2+8*3]
  1351.       and edx,0xffffff
  1352.  
  1353.       xor eax,eax
  1354.       xor ebx,ebx
  1355.       xor ecx,ecx
  1356.       xor esi,esi
  1357.       mov ax,[Button.x]
  1358.       mov bx,[Button.y]
  1359.       mov cx,[Button.height]
  1360.       mov si,[Button.width]
  1361.       add eax,esi
  1362.       mov [Line.x1],eax
  1363.       mov [Line.x2],eax
  1364.       mov [Line.y1],ebx
  1365.       mov [Line.y2],ebx
  1366.       mov [Line.color],edx
  1367.       add [Line.y2],ecx
  1368.       call DrawLine
  1369.  
  1370.       xor eax,eax
  1371.       xor ebx,ebx
  1372.       xor ecx,ecx
  1373.       xor esi,esi
  1374.       mov ax,[Button.x]
  1375.       mov bx,[Button.y]
  1376.       mov cx,[Button.height]
  1377.       mov si,[Button.width]
  1378.       add ebx,ecx
  1379.       mov [Line.x1],eax
  1380.       mov [Line.x2],eax
  1381.       mov [Line.y1],ebx
  1382.       mov [Line.y2],ebx
  1383.       add [Line.x2],esi
  1384.       call DrawLine
  1385.  
  1386.       ret
  1387.  
  1388. DrawPressed2DButton:
  1389.  
  1390.       xor eax,eax
  1391.       xor ebx,ebx
  1392.       xor ecx,ecx
  1393.       mov ax,[Button.x]
  1394.       mov bx,[Button.y]
  1395.       mov cx,[Button.height]
  1396.       mov [Line.x1],eax
  1397.       mov [Line.x2],eax
  1398.       mov [Line.y1],ebx
  1399.       mov [Line.y2],ebx
  1400.       and [Line.color],0
  1401.       add [Line.y2],ecx
  1402.       call DrawLine
  1403.  
  1404.       xor eax,eax
  1405.       xor ebx,ebx
  1406.       xor esi,esi
  1407.       mov ax,[Button.x]
  1408.       mov bx,[Button.y]
  1409.       ;mov cx,[Button.height]
  1410.       mov si,[Button.width]
  1411.       mov [Line.x1],eax
  1412.       mov [Line.x2],eax
  1413.       mov [Line.y1],ebx
  1414.       mov [Line.y2],ebx
  1415.       add [Line.x2],esi
  1416.       call DrawLine
  1417.  
  1418.       xor eax,eax
  1419.       xor ebx,ebx
  1420.       xor ecx,ecx
  1421.       xor esi,esi
  1422.       mov ax,[Button.x]
  1423.       mov bx,[Button.y]
  1424.       mov cx,[Button.height]
  1425.       mov si,[Button.width]
  1426.       add eax,esi
  1427.       mov [Line.x1],eax
  1428.       mov [Line.x2],eax
  1429.       mov [Line.y1],ebx
  1430.       mov [Line.y2],ebx
  1431.       mov [Line.color],0xffffff
  1432.       add [Line.y2],ecx
  1433.       call DrawLine
  1434.  
  1435.       xor eax,eax
  1436.       xor ebx,ebx
  1437.       xor ecx,ecx
  1438.       xor esi,esi
  1439.       mov ax,[Button.x]
  1440.       mov bx,[Button.y]
  1441.       mov cx,[Button.height]
  1442.       mov si,[Button.width]
  1443.       add ebx,ecx
  1444.       mov [Line.x1],eax
  1445.       mov [Line.x2],eax
  1446.       mov [Line.y1],ebx
  1447.       mov [Line.y2],ebx
  1448.       add [Line.x2],esi
  1449.       call DrawLine
  1450.  
  1451.       ret
  1452.