Subversion Repositories Kolibri OS

Rev

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

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