Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved.    ;;
  4. ;; Distributed under terms of the GNU General Public License       ;;
  5. ;;                                                                 ;;
  6. ;;   Written by hidnplayr@kolibrios.org                            ;;
  7. ;;                                                                 ;;
  8. ;;         GNU GENERAL PUBLIC LICENSE                              ;;
  9. ;;          Version 2, June 1991                                   ;;
  10. ;;                                                                 ;;
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12.  
  13.  
  14. draw_window:    ; Completely redraw the window, recalculate all coordinates and sizes
  15.  
  16.         pusha
  17.  
  18.         mcall   9, thread_info, -1                      ; get information about this thread
  19.         mov     eax, [thread_info.box.width]            ; window xsize
  20.         mov     ebx, [thread_info.box.height]           ; ysize
  21.         mov     edx, [thread_info.client_box.width]     ; work area xsize
  22.         mov     esi, [thread_info.client_box.height]    ; ysize
  23.         sub     eax, edx
  24.         sub     ebx, esi
  25.  
  26.         cmp     edx, WIN_MIN_X
  27.         jae     .x_ok
  28.         mov     edx, WIN_MIN_X
  29.   .x_ok:
  30.         mov     [xsize], edx
  31.         add     edx, eax
  32.  
  33.         cmp     esi, WIN_MIN_Y
  34.         jae     .y_ok
  35.         mov     esi, WIN_MIN_Y
  36.   .y_ok:
  37.         mov     [ysize], esi
  38.         add     esi, ebx
  39.         mcall   67, -1, -1                              ; set the new sizes
  40.  
  41.         popa
  42.  
  43.   .dont_resize:
  44.  
  45.         pusha
  46.  
  47.         mcall   12, 1
  48.         xor     eax, eax                                ; draw window
  49.         mov     ebx, WIN_MIN_X+10
  50.         mov     ecx, WIN_MIN_Y+30
  51.         mov     edx, [colors.work]
  52.         add     edx, 0x33000000
  53.         mov     edi, str_programname
  54.         mcall
  55.                        
  56.         test    [thread_info.wnd_state], 100b           ; skip if window is rolled up
  57.         jne     .exit
  58.  
  59. ; calculate available space for textbox and coordinates for scrollbars
  60.         mov     eax, [ysize]
  61.         sub     eax, TOP_Y + INPUTBOX_HEIGHT - 1
  62.         mov     [scroll2.y_size], ax
  63.         mov     [scroll1.y_size], ax
  64.         sub     eax, 4
  65.         xor     edx, edx
  66.         mov     ecx, FONT_HEIGHT
  67.         div     ecx
  68.         mov     [textbox_height], eax
  69.         mov     [scroll2.cur_area], eax
  70.         mov     [scroll1.cur_area], eax
  71.  
  72.         mov     eax, [xsize]
  73.         sub     eax, SCROLLBAR_WIDTH
  74.         mov     [scroll1.x_pos], ax
  75.         mov     edi, [window_active]
  76.         cmp     [edi + window.type], WINDOWTYPE_CHANNEL
  77.         jne     @f
  78.         sub     eax, USERLIST_WIDTH + SCROLLBAR_WIDTH + 2
  79.   @@:
  80.         mov     [scroll2.x_pos], ax
  81.         sub     eax, 10
  82.         xor     edx, edx
  83.         mov     ecx, FONT_WIDTH
  84.         div     ecx
  85.         mov     [textbox_width], eax
  86.  
  87. ; recalculate text line breaks (because height/width might have changed..)
  88. ; meanwhile, recalculate line number of current line
  89.         mov     esi, [edi + window.text_print]
  90.         mov     al, byte[esi]
  91.         push    eax
  92.         mov     byte[esi], 0
  93.         push    esi
  94.  
  95.         mov     esi, [edi + window.text_start]
  96.         call    text_insert_newlines
  97.         mov     [edi + window.text_lines], edx
  98.         mov     [edi + window.text_scanned], esi
  99.         mov     [edi + window.text_line_print], edx
  100.  
  101.         pop     esi
  102.         pop     eax
  103.         mov     byte[esi], al
  104.  
  105. ; and redraw the textbox (and scrollbar if needed)
  106.         mov     [scroll2.all_redraw], 1
  107.         call    draw_channel_text
  108.  
  109. ; Draw userlist if active window is a channel
  110.         mov     edi, [window_active]
  111.         cmp     [edi + window.type], WINDOWTYPE_CHANNEL
  112.         jne     .not_channel
  113.  
  114.         mov     [scroll1.all_redraw], 1
  115.         call    draw_user_list
  116.  
  117. ; draw a vertical separator line when there is no scrollbar
  118.         cmp     [scroll2.all_redraw], 1
  119.         jne     .not_channel
  120.  
  121.         mov     ebx, [xsize]
  122.         sub     ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH + 3
  123.         push    bx
  124.         shl     ebx, 16
  125.         pop     bx
  126.         mov     ecx, [ysize]
  127.         add     ecx, TOP_Y shl 16 - (INPUTBOX_HEIGHT)
  128.         mov     edx, [colors.work_graph]
  129.         mcall   38
  130.   .not_channel:
  131.  
  132. ; draw editbox
  133.         mov     eax, [ysize]
  134.         sub     eax, INPUTBOX_HEIGHT
  135.         mov     [edit1.top], eax
  136.  
  137.         mov     eax, [xsize]
  138.         mov     [edit1.width], eax
  139.  
  140.         invoke  edit_box_draw, edit1
  141.  
  142. ; draw tabs
  143.         call    draw_window_tabs
  144.                
  145.   .exit:
  146.         mcall   12, 2
  147.         popa
  148.         ret
  149.  
  150.  
  151.  
  152. draw_user_list:
  153.  
  154.         pusha
  155.  
  156.         ; Do we need a scrollbar?
  157.         mov     ebx, [window_active]
  158.         mov     eax, [ebx + window.users]
  159.         mov     [scroll1.max_area], eax
  160.         cmp     [scroll1.cur_area], eax
  161.         jae     .noscroll
  162.  
  163.         ; Is the current position greater then the max position?
  164.         cmp     eax, [scroll1.position]
  165.         ja      @f
  166.         mov     [scroll1.position], eax
  167.   @@:
  168.         ; OK, draw the scrollbar
  169.         invoke  scrollbar_draw, scroll1
  170.  
  171.         ; dont redraw scrollbar completely next time,
  172.         ; unless draw_window asks us to by setting [scroll1.all_redraw] back to 1
  173.         mov     [scroll1.all_redraw], 0
  174.         jmp     .scroll_done
  175.  
  176.   .noscroll:
  177.         mov     [scroll1.position], 0
  178.   .scroll_done:
  179.  
  180.         ; draw an invisible button, where the usernames will go
  181.         mov     ebx, [xsize]
  182.         sub     ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH
  183.         shl     ebx, 16
  184.         push    ebx
  185.         mov     bx, USERLIST_WIDTH
  186.         mov     ecx, [ysize]
  187.         add     ecx, TEXT_Y shl 16 - (TEXT_Y + 16)
  188.         push    ecx ebx
  189.         mov     edx, WINDOW_BTN_LIST + 1 shl 29 + 1 shl 30
  190.         mcall   8
  191.  
  192.         ; draw a filled rectangle to clear previously printed names
  193.         pop     ebx ecx
  194.         mov     edx, [colors.work]
  195.         mcall   13
  196.  
  197. ; now, draw the names according to the scrollbar position and window size
  198.         mov     eax, [scroll1.position]
  199.         xor     edx, edx
  200.         mov     ecx, MAX_NICK_LEN
  201.         mul     ecx
  202.         mov     edx, eax
  203.         mov     eax, [window_active]
  204.         mov     ebp, [eax + window.selected]
  205.         add     edx, [eax + window.data_ptr]
  206.         sub     ebp, [scroll1.position]
  207.         add     edx, window_data.names
  208.  
  209.         pop     ebx
  210.         mov     bx, TEXT_Y
  211.         mov     ecx, [colors.work_text]
  212.         or      ecx, 0x90000000                 ; 8x16 font, zero terminated string
  213.         mov     eax, 4                          ; draw text
  214.  
  215.         mov     edi, [textbox_height]           ; how many names will fit on screen
  216.   .loop:
  217.         cmp     byte[edx], 0                    ; end of list?
  218.         je      .done
  219.  
  220.         dec     ebp                             ; is this name selected?
  221.         jnz     .nothighlight
  222.                                                 ; yes, highlight it
  223.         pusha
  224.         mov     cx, bx
  225.         mov     bx, USERLIST_WIDTH
  226.         shl     ecx, 16
  227.         mov     cx, FONT_HEIGHT
  228.         mov     edx, 0x00000055                 ; blue!
  229.         mcall   13
  230.         popa
  231.  
  232.         mov     ecx, 0x9000ffff                 ; cyan!
  233.         mcall
  234.  
  235.         mov     ecx, [colors.work_text]
  236.         or      ecx, 0x90000000                 ; 8x16 font, zero terminated string
  237.         jmp     .next
  238.  
  239.   .nothighlight:
  240.         mcall
  241.  
  242.   .next:
  243.         add     edx, MAX_NICK_LEN
  244.         add     ebx, FONT_HEIGHT
  245.         dec     edi
  246.         jnz     .loop
  247.  
  248.   .done:
  249.         popa
  250.  
  251.         ret
  252.  
  253.  
  254. draw_window_tabs:
  255.  
  256. ; Draw horizontal line
  257.  
  258.         mov     ebx, [xsize]
  259.         mov     edx, [colors.work_graph]
  260.         mov     ecx, TOP_Y SHL 16 + TOP_Y
  261.         mcall   38
  262.  
  263. ; Create the buttons
  264.  
  265.         mov     eax, 8
  266.         mov     ebx, TAB_WIDTH
  267.         mov     ecx, TOP_SPACE shl 16 + TAB_HEIGHT
  268.         mov     edx, WINDOW_BTN_START
  269.         mov     edi, windows
  270.   .more_btn:
  271.         mov     esi, [colors.work_button]
  272.         cmp     [window_active], edi
  273.         jne     @f
  274.         not     esi
  275.         and     esi, 0x00ffffff
  276.       @@:
  277.         mcall
  278.         inc     edx
  279.         add     ebx, (TAB_WIDTH + TAB_SPACE) shl 16
  280.         add     edi, sizeof.window
  281.         cmp     [edi + window.data_ptr], 0
  282.         jne     .more_btn
  283.  
  284. ; Draw the close window button
  285.         mov     edi, [window_active]
  286.         cmp     [edi + window.type], WINDOWTYPE_SERVER  ; dont let the user close server window
  287.         je      @f
  288.  
  289. ;        mov     eax, 8
  290.         mov     ebx, [xsize]
  291.         sub     ebx, SCROLLBAR_WIDTH
  292.         shl     ebx, 16
  293.         mov     bx, SCROLLBAR_WIDTH
  294.         mov     ecx, TOP_SPACE shl 16 + TAB_HEIGHT - 1
  295.         mov     edx, WINDOW_BTN_CLOSE
  296.         mov     esi, 0x00aa0000         ; red !
  297.         mcall
  298.   @@:
  299.  
  300. ; Draw the windownames onto the buttons
  301.  
  302.         mov     eax, 4
  303.         mov     ebx, 5 shl 16 + TOP_SPACE + 4 ;;;;
  304.         mov     esi, MAX_WINDOWS
  305.         mov     edi, windows
  306.   .more:
  307.         mov     ecx, [colors.work_button_text]
  308.         test    [edi + window.flags], FLAG_UPDATED
  309.         jz      @f
  310.         mov     ecx, 0x00aa0000         ; RED!
  311.   @@:
  312.         or      ecx, 0x80000000         ; ASCIIZ string
  313.         lea     edx, [edi + window.name]
  314.         mcall
  315.         add     edi, sizeof.window      ; get ptr to next window
  316.         cmp     [edi + window.data_ptr], 0
  317.         je      .enough
  318.         add     ebx, (TAB_WIDTH + TAB_SPACE) shl 16
  319.         dec     esi
  320.         jnz     .more
  321.   .enough:
  322.  
  323.         ret
  324.  
  325.  
  326.  
  327. highlight_updated_tabs:
  328.         mov     eax, 4
  329.         mov     ebx, 5 shl 16 + TOP_SPACE + 4 ;;;;
  330.         mov     ecx, 0x80aa0000
  331.         mov     esi, MAX_WINDOWS
  332.         mov     edi, windows
  333.   .more_:
  334.         test    [edi + window.flags], FLAG_UPDATED
  335.         jz      .next
  336.         lea     edx, [edi + window.name]
  337.         mcall
  338.   .next:
  339.         add     edi, sizeof.window      ; get ptr to next window
  340.         cmp     [edi + window.data_ptr], 0
  341.         je      .enough_
  342.         add     ebx, (TAB_WIDTH + TAB_SPACE) shl 16
  343.         dec     esi
  344.         jnz     .more_
  345.   .enough_:
  346.  
  347.         ret