Subversion Repositories Kolibri OS

Rev

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