Subversion Repositories Kolibri OS

Rev

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

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