Subversion Repositories Kolibri OS

Rev

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

  1. diff16 'tp-tabctl.asm',0,$
  2.  
  3. ;-----------------------------------------------------------------------------
  4. proc flush_cur_tab ;///// SAVE CURRENT TAB DATA TO CONTROL ///////////////////
  5. ;-----------------------------------------------------------------------------
  6. ; EBP = TABITEM*
  7. ;-----------------------------------------------------------------------------
  8.         push    ecx esi edi
  9.         mov     edi,[tab_bar.Current.Ptr]
  10.         or      edi,edi
  11.         jz      @f
  12.         mov     esi,cur_tab
  13.         mov     ecx,sizeof.TABITEM/4
  14.         cld
  15.         rep     movsd
  16.     @@: pop     edi esi ecx
  17.         ret
  18. endp
  19.  
  20. ;-----------------------------------------------------------------------------
  21. proc set_cur_tab ;///// SET SPECIFIED TAB CURRENT (FOCUS IT) /////////////////
  22. ;-----------------------------------------------------------------------------
  23. ; EBP = TABITEM*
  24. ;-----------------------------------------------------------------------------
  25.         push    ecx esi edi
  26.         call    flush_cur_tab
  27.         mov     esi,ebp
  28.         mov     edi,cur_tab
  29.         mov     ecx,sizeof.TABITEM/4
  30.         rep     movsd
  31.         mov     [tab_bar.Current.Ptr],ebp
  32. ;       call    update_caption
  33.         pop     edi esi ecx
  34.         ret
  35. endp
  36.  
  37. ;-----------------------------------------------------------------------------
  38. proc make_tab_visible ;///// MAKE SPECIFIED TAB VISIBLE IF IT'S OFFSCREEN ////
  39. ;-----------------------------------------------------------------------------
  40.         call    flush_cur_tab
  41.         imul    eax,[tab_bar.Items.Left],sizeof.TABITEM
  42.         add     eax,[tab_bar.Items]
  43.         cmp     eax,ebp
  44.         jb      .go_right
  45.         ja      .go_left
  46.         ret
  47.  
  48.   .go_right:
  49.         push    ebp
  50.         call    get_hidden_tabitems_number
  51.         cmp     ebp,[esp]
  52.         ja      @f
  53.     @@: inc     [tab_bar.Items.Left]
  54.         call    get_hidden_tabitems_number
  55.         cmp     ebp,[esp]
  56.         jbe     @b
  57.     @@: pop     ebp
  58.         ret
  59.  
  60.   .go_left:
  61.         mov     eax,ebp
  62.         sub     eax,[tab_bar.Items]
  63.         jz      @f
  64.         cdq
  65.         mov     ebx,sizeof.TABITEM
  66.         div     ebx
  67.     @@: mov     [tab_bar.Items.Left],eax
  68.         ret
  69. endp
  70.  
  71. ;-----------------------------------------------------------------------------
  72. proc create_tab ;///// ADD TAB TO THE END ////////////////////////////////////
  73. ;-----------------------------------------------------------------------------
  74.         push    eax ecx esi edi
  75.  
  76.         inc     [tab_bar.Items.Count]
  77.         imul    ebx,[tab_bar.Items.Count],sizeof.TABITEM
  78.         mov     eax,[tab_bar.Items]
  79.         mov     ecx,eax
  80.         stdcall mem.ReAlloc,eax,ebx
  81.         mov     [tab_bar.Items],eax
  82.         sub     ecx,eax
  83.         sub     [tab_bar.Current.Ptr],ecx
  84.         cmp     [tab_bar.Default.Ptr],0
  85.         je      @f
  86.         sub     [tab_bar.Default.Ptr],ecx
  87.     @@: lea     ebp,[eax+ebx-sizeof.TABITEM]
  88.         call    set_cur_tab
  89.  
  90.         mov     eax,1024
  91.         mov     [cur_editor.Lines.Size],eax
  92.         stdcall mem.Alloc,eax
  93.         mov     [cur_editor.Lines],eax
  94.         mov     [cur_editor.Lines.Count],1
  95.         mov     [cur_editor.Columns.Count],1
  96.         xor     eax,eax
  97.         mov     [cur_editor.TopLeft.X],eax
  98.         mov     [cur_editor.TopLeft.Y],eax
  99.         mov     [cur_editor.Caret.X],eax
  100.         mov     [cur_editor.Caret.Y],eax
  101.         mov     [cur_editor.SelStart.X],eax
  102.         mov     [cur_editor.SelStart.Y],eax
  103.         mov     edi,[cur_editor.Lines]
  104.         add     edi,4
  105.         mov     ecx,10
  106.         mov     [edi-4],ecx
  107.         mov     [edi+10],eax
  108.         mov     al,' '
  109.         cld
  110.         rep     stosb
  111.  
  112.         mov     esi,s_defname
  113.         mov     edi,cur_editor.FilePath + 1
  114.         mov     ecx,s_defname.size
  115.         rep     movsb
  116.         mov     [cur_editor.FileName],1
  117.  
  118.         mov     [cur_editor.Modified],0
  119.         mov     [cur_editor.AsmMode],0
  120.  
  121.         call    flush_cur_tab
  122.         mov     ebp,[tab_bar.Current.Ptr]
  123.         call    make_tab_visible
  124.         call    update_caption
  125.         cmp     [do_not_draw],0
  126.         jne     @f
  127.         call    align_editor_in_tab
  128.         call    draw_editor
  129.         call    draw_tabctl
  130.         call    draw_statusbar
  131.         call    update_caption
  132.     @@:
  133.         mov     ebp,cur_tab
  134.         pop     edi esi ecx eax
  135.         ret
  136. endp
  137.  
  138. ;-----------------------------------------------------------------------------
  139. proc delete_tab ;///// DELETE SPECIFIED TAB //////////////////////////////////
  140. ;-----------------------------------------------------------------------------
  141.         cmp     [tab_bar.Default.Ptr],0
  142.         je      @f
  143.         cmp     ebp,[tab_bar.Default.Ptr]
  144.         je      .lp1
  145.         ja      @f
  146.         sub     [tab_bar.Default.Ptr],sizeof.TABITEM
  147.         jmp     @f
  148.   .lp1:
  149.         mov     [tab_bar.Default.Ptr],0
  150.  
  151.     @@: stdcall mem.Free,[ebp+TABITEM.Editor.Lines]
  152.         imul    ecx,[tab_bar.Items.Count],sizeof.TABITEM
  153.         add     ecx,[tab_bar.Items]
  154.         sub     ecx,ebp
  155.         sub     ecx,sizeof.TABITEM
  156.         jle     @f
  157.         cld
  158.         shr     ecx,2
  159.         mov     edi,ebp
  160.         lea     esi,[edi+sizeof.TABITEM]
  161.         rep     movsd
  162.     @@: dec     [tab_bar.Items.Count]
  163.         jz      .no_tabs
  164.         imul    ebx,[tab_bar.Items.Count],sizeof.TABITEM
  165.         push    ebx
  166.         mov     eax,[tab_bar.Items]
  167.         mov     ecx,eax
  168.         stdcall mem.ReAlloc,eax,ebx
  169.         mov     [tab_bar.Items],eax
  170.         sub     ecx,eax
  171.         sub     ebp,ecx
  172.         cmp     [tab_bar.Default.Ptr],0
  173.         je      @f
  174.         sub     [tab_bar.Default.Ptr],ecx
  175.     @@:
  176.         pop     ecx
  177.         add     ecx,[tab_bar.Items]
  178.         sub     ecx,ebp
  179.         ja      @f
  180.         add     ebp,-sizeof.TABITEM
  181.  
  182.     @@: mov     [tab_bar.Current.Ptr],0
  183.         call    set_cur_tab
  184.         call    make_tab_visible
  185.         call    align_editor_in_tab
  186.         call    draw_editor
  187.         call    draw_tabctl
  188.         call    draw_statusbar
  189.         ret
  190.  
  191.   .no_tabs:
  192.         stdcall mem.Free,[tab_bar.Items]
  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. endp
  199.  
  200. ;-----------------------------------------------------------------------------
  201. proc 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,[sc.work_text];[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. endp
  566.  
  567. ;-----------------------------------------------------------------------------
  568. proc 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. endp
  590.  
  591. ;-----------------------------------------------------------------------------
  592. proc 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. endp
  622.  
  623. ;-----------------------------------------------------------------------------
  624. proc 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. endp
  680.  
  681. ;-----------------------------------------------------------------------------
  682. proc 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. endp
  724.