Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. lang equ ru
  2.  
  3. ;
  4. ;   Assembler
  5. ;     SMALL
  6. ;       CODE
  7. ;         GUI
  8. ;           Libary
  9. ;
  10. ;   Ver 0.01
  11. ;
  12.  
  13. macro gui_text x,y,color,font_size,text {
  14.    db 4 ; type of gui element 4 - text
  15.    dw y, x
  16.    dd (1 shl 31)+color+((font_size-1) shl 24)
  17.    db text, 0
  18. }
  19.  
  20. macro gui_button id,x,y,w,h,bcolor,tcolor,text {
  21.    db 8 ; type of gui element 8 - button with text
  22.    dw id, w, x, h, y
  23.    dd bcolor
  24.    dd (1 shl 31)+tcolor
  25.    db text, 0
  26. }
  27.  
  28. macro gui_end {
  29.    db 255 ; type of gui element 255 - end of gui marker
  30. }
  31.  
  32. macro draw_gui address
  33. {
  34.    mov esi,address
  35.    call draw_gui_proc
  36.  
  37. if ~ defined draw_gui_used
  38. draw_gui_used equ 1
  39.    jmp end_draw_gui_proc
  40. draw_gui_proc:
  41. next_element:
  42.    xor eax,eax
  43.    mov al,byte [esi]
  44. ; eax =4 draw label
  45.    cmp eax,4
  46.    jne no_label
  47.    mov ebx,[esi+1]     ; x,y
  48.    mov ecx,[esi+1+4]   ; color
  49.    lea edx,[esi+1+4+4] ; text offset
  50.    add esi,9
  51.    mcall
  52.    jmp skip_string
  53. no_label:
  54. ; eax = 8 draw button
  55.    cmp eax,8
  56.    jne no_draw_button
  57.    xor edx,edx
  58.    mov dx,[esi+1]        ; id
  59.    mov ebx,[esi+3]     ; x,xs
  60.    mov ecx,[esi+7]   ; y,ys
  61.    push esi
  62.    mov esi,[esi+11] ; button color
  63.    mcall
  64.    pop esi
  65.  
  66.    lea ebp,[esi+19]      ; start of text
  67.    call get_size_of_string
  68.    mov ebx,6
  69.    mul ebx
  70.  
  71.    mov bx,[esi+3]
  72.    sub bx,ax
  73.    shr bx,1
  74.    add bx,[esi+5]
  75.  
  76.    mov dx,[esi+7]
  77.    sub dx,7
  78.    shr dx,1
  79.    add dx,[esi+9]
  80.  
  81.    shl ebx,16
  82.    mov bx,dx
  83.  
  84.    mov ecx,[esi+15]       ; text color
  85.    lea edx,[esi+19]       ; text offset
  86.    mov eax,4
  87.    add esi,19
  88.    mcall
  89.    jmp skip_string
  90. no_draw_button:
  91.    cmp eax,255
  92.    je end_of_gui
  93. ; unknown gui element
  94.    int3
  95. end_of_gui:
  96.    ret
  97.  
  98. get_size_of_string:
  99.    xor eax,eax
  100. next_bt:
  101.    cmp byte [ebp],0
  102.    jne no_en
  103.    ret
  104. no_en:
  105.    inc ebp
  106.    inc eax
  107.    jmp next_bt
  108. ; function for skip string of text
  109. next_byte:
  110.    inc esi
  111. skip_string:
  112.    cmp byte [esi],0
  113.    jne next_byte
  114.    inc esi
  115.    jmp next_element
  116. end_draw_gui_proc:
  117.  
  118. end if
  119.  
  120. }