Subversion Repositories Kolibri OS

Rev

Rev 327 | Rev 629 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;-----------------------------------------------------------------------------
  2. func flush_cur_tab ;///// SAVE CURRENT TAB DATA TO CONTROL ///////////////////
  3. ;-----------------------------------------------------------------------------
  4. ; EBP = TABITEM*
  5. ;-----------------------------------------------------------------------------
  6.         push    ecx esi edi
  7.         mov     esi,cur_tab
  8.         mov     edi,[tab_bar.Current.Ptr]
  9.         mov     ecx,sizeof.TABITEM/4
  10.         cld
  11.         rep     movsd
  12.         pop     edi esi ecx
  13.         ret
  14. endf
  15.  
  16. ;-----------------------------------------------------------------------------
  17. func set_cur_tab ;///// SET SPECIFIED TAB CURRENT (FOCUS IT) /////////////////
  18. ;-----------------------------------------------------------------------------
  19. ; EBP = TABITEM*
  20. ;-----------------------------------------------------------------------------
  21.         push    ecx esi edi
  22.         cmp     [tab_bar.Current.Ptr],0
  23.         je      @f
  24.         call    flush_cur_tab
  25.     @@: mov     esi,ebp
  26.         mov     edi,cur_tab
  27.         mov     ecx,sizeof.TABITEM/4
  28.         rep     movsd
  29.         mov     [tab_bar.Current.Ptr],ebp
  30. ;       call    update_caption
  31.         pop     edi esi ecx
  32.         ret
  33. endf
  34.  
  35. ;-----------------------------------------------------------------------------
  36. func make_tab_visible ;///// MAKE SPECIFIED TAB VISIBLE IF IT'S OFFSCREEN ////
  37. ;-----------------------------------------------------------------------------
  38.         call    flush_cur_tab
  39.         imul    eax,[tab_bar.Items.Left],sizeof.TABITEM
  40.         add     eax,[tab_bar.Items]
  41.         cmp     eax,ebp
  42.         jb      .go_right
  43.         ja      .go_left
  44.         ret
  45.  
  46.   .go_right:
  47.         push    ebp
  48.         call    get_hidden_tabitems_number
  49.         cmp     ebp,[esp]
  50.         ja      @f
  51.     @@: inc     [tab_bar.Items.Left]
  52.         call    get_hidden_tabitems_number
  53.         cmp     ebp,[esp]
  54.         jbe     @b
  55.     @@: pop     ebp
  56.         ret
  57.  
  58.   .go_left:
  59.         mov     eax,ebp
  60.         sub     eax,[tab_bar.Items]
  61.         jz      @f
  62.         cdq
  63.         mov     ebx,sizeof.TABITEM
  64.         div     ebx
  65.     @@: mov     [tab_bar.Items.Left],eax
  66.         ret
  67. endf
  68.  
  69. ;-----------------------------------------------------------------------------
  70. func create_tab ;///// ADD TAB TO THE END ////////////////////////////////////
  71. ;-----------------------------------------------------------------------------
  72.         push    eax ecx esi edi
  73.  
  74.         inc     [tab_bar.Items.Count]
  75.         imul    ebx,[tab_bar.Items.Count],sizeof.TABITEM
  76.         mov     eax,[tab_bar.Items]
  77.         mov     ecx,eax
  78.         call    mem.ReAlloc
  79.         mov     [tab_bar.Items],eax
  80.         sub     ecx,eax
  81.         sub     [tab_bar.Current.Ptr],ecx
  82.         cmp     [tab_bar.Default.Ptr],0
  83.         je      @f
  84.         sub     [tab_bar.Default.Ptr],ecx
  85.     @@: lea     ebp,[eax+ebx-sizeof.TABITEM]
  86.         call    set_cur_tab
  87.  
  88.         mov     eax,1024
  89.         mov     [cur_editor.Lines.Size],eax
  90.         call    mem.Alloc
  91.         mov     [cur_editor.Lines],eax
  92.         mov     [cur_editor.Lines.Count],1
  93.         mov     [cur_editor.Columns.Count],1
  94.         xor     eax,eax
  95.         mov     [cur_editor.TopLeft.X],eax
  96.         mov     [cur_editor.TopLeft.Y],eax
  97.         mov     [cur_editor.Caret.X],eax
  98.         mov     [cur_editor.Caret.Y],eax
  99.         mov     [cur_editor.SelStart.X],eax
  100.         mov     [cur_editor.SelStart.Y],eax
  101.         mov     edi,[cur_editor.Lines]
  102.         add     edi,4
  103.         mov     ecx,10
  104.         mov     [edi-4],ecx
  105.         mov     [edi+10],eax
  106.         mov     al,' '
  107.         cld
  108.         rep     stosb
  109.  
  110.         mov     esi,s_defname
  111.         mov     edi,cur_editor.FilePath + 1
  112.         mov     ecx,s_defname.size
  113.         rep     movsb
  114.         mov     [cur_editor.FileName],1
  115.  
  116.         mov     [cur_editor.Modified],0
  117.         mov     [cur_editor.AsmMode],0
  118.  
  119.         call    flush_cur_tab
  120.         mov     ebp,[tab_bar.Current.Ptr]
  121.         call    make_tab_visible
  122.         call    update_caption
  123.         cmp     [do_not_draw],0
  124.         jne     @f
  125.         call    align_editor_in_tab
  126.         call    draw_editor
  127.         call    draw_tabctl
  128.         call    draw_statusbar
  129.         call    update_caption
  130.     @@:
  131.         mov     ebp,cur_tab
  132.         pop     edi esi ecx eax
  133.         ret
  134. endf
  135.  
  136. ;-----------------------------------------------------------------------------
  137. func delete_tab ;///// DELETE SPECIFIED TAB //////////////////////////////////
  138. ;-----------------------------------------------------------------------------
  139.         cmp     [tab_bar.Default.Ptr],0
  140.         je      @f
  141.         cmp     ebp,[tab_bar.Default.Ptr]
  142.         je      .lp1
  143.         ja      @f
  144.         sub     [tab_bar.Default.Ptr],sizeof.TABITEM
  145.         jmp     @f
  146.   .lp1:
  147.         mov     [tab_bar.Default.Ptr],0
  148.  
  149.     @@: mov     eax,[ebp+TABITEM.Editor.Lines]
  150.         call    mem.Free
  151.         imul    ecx,[tab_bar.Items.Count],sizeof.TABITEM
  152.         add     ecx,[tab_bar.Items]
  153.         sub     ecx,ebp
  154.         sub     ecx,sizeof.TABITEM
  155.         jle     @f
  156.         cld
  157.         shr     ecx,2
  158.         mov     edi,ebp
  159.         lea     esi,[edi+sizeof.TABITEM]
  160.         rep     movsd
  161.     @@: dec     [tab_bar.Items.Count]
  162.         jz      .no_tabs
  163.         imul    ebx,[tab_bar.Items.Count],sizeof.TABITEM
  164.         push    ebx
  165.         mov     eax,[tab_bar.Items]
  166.         mov     ecx,eax
  167.         call    mem.ReAlloc
  168.         mov     [tab_bar.Items],eax
  169.         sub     ecx,eax
  170.         sub     ebp,ecx
  171.         cmp     [tab_bar.Default.Ptr],0
  172.         je      @f
  173.         sub     [tab_bar.Default.Ptr],ecx
  174.     @@:
  175.         pop     ecx
  176.         add     ecx,[tab_bar.Items]
  177.         sub     ecx,ebp
  178.         ja      @f
  179.         add     ebp,-sizeof.TABITEM
  180.  
  181.     @@: mov     [tab_bar.Current.Ptr],0
  182.         call    set_cur_tab
  183.         call    make_tab_visible
  184.         call    align_editor_in_tab
  185.         call    draw_editor
  186.         call    draw_tabctl
  187.         call    draw_statusbar
  188.         ret
  189.  
  190.   .no_tabs:
  191.         mov     eax,[tab_bar.Items]
  192.         call    mem.Free
  193.         xor     eax,eax
  194.         mov     [tab_bar.Items],eax
  195.         mov     [tab_bar.Current.Ptr],eax
  196.         mov     [tab_bar.Default.Ptr],eax
  197.         ret
  198. endf
  199.  
  200. ;-----------------------------------------------------------------------------
  201. func draw_tabctl ;///// DRAW TAB CONTROL /////////////////////////////////////
  202. ;-----------------------------------------------------------------------------
  203.  
  204.         dec     [tab_bar.Items.Left]
  205.         js      .lp1
  206.     @@: call    get_hidden_tabitems_number
  207.         or      eax,eax
  208.         jnz     .lp1
  209.         dec     [tab_bar.Items.Left]
  210.         jns     @b
  211.   .lp1: inc     [tab_bar.Items.Left]
  212.         mov     eax,[tab_bar.Items.Count]
  213.         cmp     [tab_bar.Items.Left],eax
  214.         jb      @f
  215.         dec     eax
  216.         mov     [tab_bar.Items.Left],eax
  217.     @@:
  218.  
  219.         mov     eax,8
  220.         mov     edx,[tab_bar.Buttons.First]
  221.     @@: cmp     edx,[tab_bar.Buttons.Last]
  222.         ja      @f
  223.         push    edx
  224.         or      edx,0x80000000
  225.         mcall
  226.         pop     edx
  227.         inc     edx
  228.         jmp     @b
  229.     @@:
  230.  
  231.         mov     ebx,[tab_bar.Bounds.Left-2]
  232.         mov     bx,word[tab_bar.Bounds.Right]
  233.         sub     bx,word[tab_bar.Bounds.Left]
  234.         inc     ebx
  235.         mov     ecx,[tab_bar.Bounds.Top-2]
  236.         mov     cx,word[tab_bar.Bounds.Bottom]
  237.         sub     cx,word[tab_bar.Bounds.Top]
  238.         inc     ecx
  239.         mov     edx,[cl_3d_normal]
  240.         call    draw_framerect
  241.  
  242.         mov     al,[tab_bar.Style]
  243.         dec     al
  244.         jz      .tabs_on_top
  245.         dec     al
  246.         jz      .tabs_on_bottom
  247.         dec     al
  248.         jz      .tabs_on_left
  249.         dec     al
  250.         jz      .tabs_on_right
  251.         ret
  252.  
  253.   .tabs_on_top:
  254.         add     ebx,1*65536-2
  255.         mov     ecx,[tab_bar.Bounds.Top-2]
  256.         xor     cx,cx
  257.         add     ecx,1*65536+TBARH
  258.         mcall   13
  259.         add     ecx,(TBARH-1)*65536-(TBARH-1)
  260.         mcall   ,,,[sc.work]
  261.         add     ecx,-1*65536+2
  262.         mov     edx,[cl_3d_inset]
  263.         call    draw_framerect
  264.  
  265.         mov     esi,[tab_bar.Bounds.Left]
  266.         inc     esi
  267.         mov     edi,[tab_bar.Bounds.Top]
  268.         inc     edi
  269.         push    .curr_top .check_horz .next_horz
  270.         call    .draw_tabs
  271.         ret
  272.  
  273.   .tabs_on_bottom:
  274.         add     ebx,1*65536-2
  275.         mov     ecx,[tab_bar.Bounds.Bottom-2]
  276.         xor     cx,cx
  277.         add     ecx,-TBARH*65536+TBARH
  278.         mcall   13
  279.         mov     cx,1
  280.         mcall   ,,,[sc.work]
  281.         add     ecx,-1*65536+2
  282.         mov     edx,[cl_3d_inset]
  283.         call    draw_framerect
  284.  
  285.         mov     esi,[tab_bar.Bounds.Left]
  286.         inc     esi
  287.         mov     edi,[tab_bar.Bounds.Bottom]
  288.         add     edi,-TBARH+1
  289.         push    .curr_bottom .check_horz .next_horz
  290.         call    .draw_tabs
  291.         ret
  292.  
  293.   .tabs_on_left:
  294.         call    get_max_tab_width
  295.         mov     ebx,[tab_bar.Bounds.Left-2]
  296.         mov     bx,ax
  297.         add     ebx,1*65536-1
  298.         add     ecx,1*65536-2
  299.         push    eax
  300.         mcall   13
  301.         pop     ebx
  302.         shl     ebx,16
  303.         add     ebx,1*65536+1
  304.         mcall   ,,,[sc.work]
  305.         add     ebx,-1*65536+2
  306.         mov     edx,[cl_3d_inset]
  307.         call    draw_framerect
  308.  
  309.         mov     esi,[tab_bar.Bounds.Left]
  310.         inc     esi
  311.         mov     edi,[tab_bar.Bounds.Top]
  312.         inc     edi
  313.         push    .curr_left .check_vert .next_vert
  314.         call    .draw_tabs
  315.         ret
  316.  
  317.   .tabs_on_right:
  318.         call    get_max_tab_width
  319.         push    eax
  320.         mov     ebx,[tab_bar.Bounds.Right-2]
  321.         mov     bx,ax
  322.         shl     eax,16
  323.         sub     ebx,eax
  324.         add     ecx,1*65536-2
  325.         mcall   13
  326.         add     ebx,-1*65536
  327.         mov     bx,1
  328.         mcall   ,,,[sc.work]
  329.         add     ebx,-1*65536+2
  330.         mov     edx,[cl_3d_inset]
  331.         call    draw_framerect
  332.  
  333.         mov     esi,[tab_bar.Bounds.Right]
  334.         pop     eax
  335.         sub     esi,eax
  336.         mov     edi,[tab_bar.Bounds.Top]
  337.         inc     edi
  338.         push    .curr_right .check_vert .next_vert
  339.         call    .draw_tabs
  340.         ret
  341.  
  342.  
  343.   .draw_tabs:
  344.         mov     ecx,[tab_bar.Items.Count]
  345.         mov     ebx,[tab_bar.Items.Left]
  346.         imul    ebp,ebx,sizeof.TABITEM
  347.         add     ebp,[tab_bar.Items]
  348.         push    ecx
  349.         sub     [esp],ebx
  350.         add     ebx,1000
  351.         mov     [tab_bar.Buttons.First],ebx
  352.         dec     ebx
  353.         mov     [tab_bar.Buttons.Last],ebx
  354.     @@: push    ecx
  355.  
  356.         call    get_tab_size
  357.  
  358.         call    dword[esp+(8+4)+4]
  359.         jc      .draw_tabs.dontfit
  360.  
  361.         rol     ebx,16
  362.         mov     bx,si
  363.         rol     ebx,16
  364.         rol     ecx,16
  365.         mov     cx,di
  366.         rol     ecx,16
  367.         mov     edx,[cl_3d_inset]
  368.         call    draw_framerect
  369.  
  370.         mov     edx,[sc.work_text]
  371.         cmp     ebp,[tab_bar.Current.Ptr]
  372.         jne     .draw_tabs.inactive
  373.         push    ebx ecx
  374.         call    dword[esp+(8+4)+8+8]
  375.         mcall   13,,,[sc.work]
  376.         pop     ecx ebx
  377.         mov     edx,[color_tbl.text]
  378.   .draw_tabs.inactive:
  379.  
  380.         cmp     ebp,[tab_bar.Default.Ptr]
  381.         jne     .draw_tabs.notdefault
  382.         push    ebx ecx edx
  383.         add     ebx,3*65536
  384.         add     ecx,(TBARH/2-6)*65536
  385.         mov     bx,11
  386.         mov     cx,bx
  387.         call    draw_framerect
  388.         add     ebx,1*65536-2
  389.         add     ecx,1*65536-2
  390.         mcall   13,,,[sc.work]
  391.         shr     ebx,16
  392.         shr     ecx,16
  393.         add     ebx,2
  394.         add     ecx,3
  395.         mov     edx,[esp]
  396.         call    draw_check
  397.         pop     edx ecx ebx
  398.   .draw_tabs.notdefault:
  399.  
  400.         push    ebx ecx esi edx
  401.         lea     eax,[ebp+TABITEM.Editor.FilePath]
  402.         add     eax,[ebp+TABITEM.Editor.FileName]
  403.         mov     edx,eax
  404.         call    strlen
  405.         mov     esi,eax
  406.         shr     ecx,16
  407.         mov     bx,cx
  408.         add     ebx,5*65536+TBARH/2-4
  409.         pop     ecx
  410.         cmp     ebp,[tab_bar.Default.Ptr]
  411.         jne     .lp2
  412.         add     ebx,13*65536
  413.   .lp2: mcall   4
  414.         pop     esi ecx ebx
  415.  
  416.         inc     [tab_bar.Buttons.Last]
  417.         cmp     ebp,[tab_bar.Current.Ptr]
  418.         je      .draw_tabs.active
  419.         push    ebx ecx
  420.         dec     ebx
  421.         dec     ecx
  422.         mov     edx,[tab_bar.Buttons.Last]
  423.         or      edx,0x40000000
  424.         mcall   8
  425.         pop     ecx ebx
  426.   .draw_tabs.active:
  427.  
  428.         call    dword[esp+(8+4)+0]
  429.         add     ebp,sizeof.TABITEM
  430.  
  431.         pop     ecx
  432.         dec     ecx
  433.         dec     dword[esp]
  434.         jnz     @b
  435.  
  436.         add     esp,4
  437.         or      ecx,ecx
  438.         jnz     @f
  439.  
  440.         ret     8
  441.  
  442.   .draw_tabs.dontfit:
  443.  
  444.         add     esp,8
  445.  
  446.     @@: mov     ebx,[tab_bar.Bounds.Right]
  447.         shl     ebx,16
  448.         mov     ecx,[tab_bar.Bounds.Bottom]
  449.         shl     ecx,16
  450.         add     ecx,(-SCRLW-1)*65536+SCRLW
  451.         call    get_max_tab_width
  452.         mov     edx,eax
  453.  
  454.         mov     al,[tab_bar.Style]
  455.         dec     al
  456.         jz      .scroll_on_top
  457.         dec     al
  458.         jz      .scroll_on_bottom
  459.         dec     al
  460.         jz      .scroll_on_left
  461.         dec     al
  462.         jz      .scroll_on_right
  463.         ret
  464.  
  465.   .scroll_on_top:
  466.         add     ebx,(-SCRLW*2-1)*65536+SCRLW
  467.         mov     ecx,[tab_bar.Bounds.Top]
  468.         shl     ecx,16
  469.         add     ecx,1*65536+SCRLW
  470.         jmp     .draw_tabs.draw_scroll
  471.   .scroll_on_bottom:
  472.         add     ebx,(-SCRLW*2-1)*65536+SCRLW
  473.         jmp     .draw_tabs.draw_scroll
  474.   .scroll_on_left:
  475.         mov     ebx,[tab_bar.Bounds.Left]
  476.         add     ebx,edx
  477.         shl     ebx,16
  478.         add     ebx,(-SCRLW*2)*65536+SCRLW
  479.         jmp     .draw_tabs.draw_scroll
  480.   .scroll_on_right:
  481.         shl     edx,16
  482.         sub     ebx,edx
  483.         add     ebx,SCRLW
  484.  
  485.   .draw_tabs.draw_scroll:
  486.         mcall   8,,,'TBG' or 0x40000000
  487.         push    ebx
  488.         add     ebx,SCRLW*65536
  489.         mcall   8,,,'TBL' or 0x40000000
  490.         pop     ebx
  491.         push    ebx ecx
  492.         sar     ebx,16
  493.         sar     ecx,16
  494.         push    ebx ecx SCRLW SCRLW
  495.         call    draw_3d_panel
  496.         add     ebx,SCRLW
  497.         push    ebx ecx SCRLW SCRLW
  498.         call    draw_3d_panel
  499.         pop     ecx ebx
  500.  
  501.         push    '<'
  502.         shr     ecx,16
  503.         mov     bx,cx
  504.         add     ebx,(SCRLW/2-2)*65536+SCRLW/2-3
  505.         mcall   4,,[sc.work_text],esp,1
  506.         add     ebx,0x00020000
  507.         mcall
  508.         add     ebx,(SCRLW-2)*65536
  509.         mov     byte[esp],'>'
  510.         mcall
  511.         add     ebx,0x00020000
  512.         mcall
  513.         add     esp,4
  514.  
  515.         ret     8
  516.  
  517.   .curr_left:
  518.         add     ebx,0x00010000
  519.         add     ecx,1*65536-2
  520.         ret
  521.   .curr_top:
  522.         add     ebx,1*65536-2
  523.         add     ecx,0x00010000
  524.         ret
  525.   .curr_right:
  526.         dec     ebx
  527.         add     ecx,1*65536-2
  528.         ret
  529.   .curr_bottom:
  530.         add     ebx,1*65536-2
  531.         dec     ecx
  532.         ret
  533.  
  534.   .check_horz:
  535.         lea     eax,[esi+ebx-1]
  536.         sub     eax,[tab_bar.Bounds.Right]
  537.         jge     .check.dontfit
  538.         add     eax,SCRLW*2+2
  539.         jl      .check.fit
  540.         cmp     dword[esp+4],1
  541.         jbe     .check.fit
  542.   .check.dontfit:
  543.         stc
  544.         ret
  545.   .check_vert:
  546.         lea     eax,[edi+ecx-1]
  547.         sub     eax,[tab_bar.Bounds.Bottom]
  548.         jge     .check.dontfit
  549.         add     eax,SCRLW+2
  550.         jl      .check.fit
  551.         cmp     dword[esp+4],1
  552.         ja      .check.dontfit
  553.   .check.fit:
  554.         clc
  555.         ret
  556.  
  557.   .next_horz:
  558.         movzx   ebx,bx
  559.         lea     esi,[esi+ebx+1]
  560.         ret
  561.   .next_vert:
  562.         movzx   ecx,cx
  563.         lea     edi,[edi+ecx+1]
  564.         ret
  565. endf
  566.  
  567. ;-----------------------------------------------------------------------------
  568. func get_tab_size ;///// GET TAB WIDTH ///////////////////////////////////////
  569. ;-----------------------------------------------------------------------------
  570. ; EBP = TABITEM*
  571. ;-----------------------------------------------------------------------------
  572.         push    eax
  573.         cmp     [tab_bar.Style],3
  574.         jae     .lp1
  575.         lea     eax,[ebp+TABITEM.Editor.FilePath]
  576.         add     eax,[ebp+TABITEM.Editor.FileName]
  577.         call    strlen
  578.         imul    ebx,eax,6
  579.         add     ebx,9
  580.         cmp     ebp,[tab_bar.Default.Ptr]
  581.         jne     .lp2
  582.         add     ebx,13
  583.         jmp     .lp2
  584.   .lp1: call    get_max_tab_width
  585.         mov     ebx,eax
  586.   .lp2: mov     ecx,TBARH-1
  587.         pop     eax
  588.         ret
  589. endf
  590.  
  591. ;-----------------------------------------------------------------------------
  592. func get_max_tab_width ;///// GET WIDTH OF LONGEST TAB ///////////////////////
  593. ;-----------------------------------------------------------------------------
  594.         push    ebx ecx ebp
  595.         mov     ecx,[tab_bar.Items.Count]
  596.         mov     ebp,[tab_bar.Items]
  597.         xor     ebx,ebx
  598.     @@: dec     ecx
  599.         js      @f
  600.  
  601.         lea     eax,[ebp+TABITEM.Editor.FilePath]
  602.         add     eax,[ebp+TABITEM.Editor.FileName]
  603.         call    strlen
  604.         imul    eax,6
  605.         add     eax,9
  606.  
  607.         add     ebp,sizeof.TABITEM
  608.         cmp     ebx,eax
  609.         jae     @b
  610.         mov     ebx,eax
  611.         jmp     @b
  612.     @@: mov     eax,ebx
  613.         cmp     eax,SCRLW*2+2
  614.         jae     @f
  615.         mov     eax,SCRLW*2+2
  616.     @@: cmp     [tab_bar.Default.Ptr],0
  617.         je      @f
  618.         add     eax,13
  619.     @@: pop     ebp ecx ebx
  620.         ret
  621. endf
  622.  
  623. ;-----------------------------------------------------------------------------
  624. func get_hidden_tabitems_number ;/////////////////////////////////////////////
  625. ;-----------------------------------------------------------------------------
  626.         mov     al,[tab_bar.Style]
  627.         dec     al
  628.         dec     al
  629.         jle     .tabs_horz
  630.         dec     al
  631.         dec     al
  632.         jle     .tabs_vert
  633.         ret
  634.  
  635.   .tabs_horz:
  636.         push    draw_tabctl.check_horz draw_tabctl.next_horz
  637.         call    .calc_tabs
  638.         ret
  639.  
  640.   .tabs_vert:
  641.         push    draw_tabctl.check_vert draw_tabctl.next_vert
  642.         call    .calc_tabs
  643.         ret
  644.  
  645.   .calc_tabs:
  646.         mov     esi,[tab_bar.Bounds.Left]
  647.         inc     esi
  648.         mov     edi,[tab_bar.Bounds.Top]
  649.         inc     edi
  650.         mov     ecx,[tab_bar.Items.Count]
  651.         mov     ebx,[tab_bar.Items.Left]
  652.         imul    ebp,ebx,sizeof.TABITEM
  653.         add     ebp,[tab_bar.Items]
  654.         push    ecx
  655.         sub     [esp],ebx
  656.     @@: push    ecx
  657.  
  658.         call    get_tab_size
  659.  
  660.         call    dword[esp+(8+4)+4]
  661.         jc      .calc_tabs.dontfit
  662.  
  663.         call    dword[esp+(8+4)+0]
  664.         add     ebp,sizeof.TABITEM
  665.  
  666.         pop     ecx
  667.         dec     ecx
  668.         dec     dword[esp]
  669.         jnz     @b
  670.  
  671.         jmp     @f
  672.  
  673.   .calc_tabs.dontfit:
  674.  
  675.         add     esp,4
  676.     @@: pop     ecx
  677.         mov     eax,ecx
  678.         ret     8
  679. endf
  680.  
  681. ;-----------------------------------------------------------------------------
  682. func align_editor_in_tab ;///// ADJUST EDITOR POSITION TO FIT IN TAB /////////
  683. ;-----------------------------------------------------------------------------
  684.         m2m     [cur_editor.Bounds.Left],[tab_bar.Bounds.Left]
  685.         m2m     [cur_editor.Bounds.Top],[tab_bar.Bounds.Top]
  686.         m2m     [cur_editor.Bounds.Right],[tab_bar.Bounds.Right]
  687.         m2m     [cur_editor.Bounds.Bottom],[tab_bar.Bounds.Bottom]
  688.  
  689.         inc     [cur_editor.Bounds.Left]
  690.         inc     [cur_editor.Bounds.Top]
  691.         dec     [cur_editor.Bounds.Right]
  692.         dec     [cur_editor.Bounds.Bottom]
  693.  
  694.         call    get_max_tab_width
  695.         lea     ebx,[eax+1]
  696.  
  697.         mov     al,[tab_bar.Style]
  698.         dec     al
  699.         jz      .tabs_on_top
  700.         dec     al
  701.         jz      .tabs_on_bottom
  702.         dec     al
  703.         jz      .tabs_on_left
  704.         dec     al
  705.         jz      .tabs_on_right
  706.         ret
  707.  
  708.   .tabs_on_top:
  709.         add     [cur_editor.Bounds.Top],TBARH
  710.         ret
  711.  
  712.   .tabs_on_bottom:
  713.         sub     [cur_editor.Bounds.Bottom],TBARH
  714.         ret
  715.  
  716.   .tabs_on_left:
  717.         add     [cur_editor.Bounds.Left],ebx
  718.         ret
  719.  
  720.   .tabs_on_right:
  721.         sub     [cur_editor.Bounds.Right],ebx
  722.         ret
  723. endf
  724.