Subversion Repositories Kolibri OS

Rev

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

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