Subversion Repositories Kolibri OS

Rev

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

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