Subversion Repositories Kolibri OS

Rev

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

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