Subversion Repositories Kolibri OS

Rev

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

  1. align 4
  2. draw_but_toolbar: ;ôóíêöèÿ äëÿ ðèñîâàíèÿ ïàíåëè èíñòðóìåíòîâ
  3.         pushad
  4.         mov edi,tedit0
  5.  
  6.         mov ecx,0x40000000
  7.         mov edx,(5 shl 16)+25
  8.         bt word[panel_but],0
  9.         jnc @f
  10.                 call draw_but_icon ;New
  11.         @@:
  12.  
  13.         inc cx
  14.         bt word[panel_but+1],0
  15.         jnc @f
  16.                 add edx,25 shl 16
  17.                 call draw_but_icon ;Open
  18.         @@:
  19.  
  20.         stdcall [ted_can_save],edi
  21.         cmp al,1
  22.         je @f
  23.                 and ecx,0xffff
  24.         @@:
  25.         inc cx
  26.         bt word[panel_but+2],0
  27.         jnc @f
  28.                 add edx,25 shl 16
  29.                 call draw_but_icon ;Save
  30.         @@:
  31.         or ecx,0x40000000
  32.  
  33.         inc cx
  34.         bt word[panel_but+3],0
  35.         jnc @f
  36.                 add edx,30 shl 16
  37.                 call draw_but_icon ;Select word
  38.         @@:
  39.  
  40.         call [ted_is_select]
  41.         or al,al
  42.         jnz @f
  43.                 and ecx,0xffff
  44.         @@:
  45.         inc cx
  46.         bt word[panel_but+4],0
  47.         jnc @f
  48.                 add edx,25 shl 16
  49.                 call draw_but_icon ;Cut
  50.         @@:
  51.  
  52.         inc cx
  53.         bt word[panel_but+5],0
  54.         jnc @f
  55.                 add edx,25 shl 16
  56.                 call draw_but_icon ;Copy
  57.         @@:
  58.         or ecx,0x40000000
  59.  
  60.         cmp dword[buf],0
  61.         jne @f
  62.                 and ecx,0xffff
  63.         @@:
  64.         inc cx
  65.         bt word[panel_but+6],0
  66.         jnc @f
  67.                 add edx,25 shl 16
  68.                 call draw_but_icon ;Paste
  69.         @@:
  70.         or ecx,0x40000000
  71.  
  72.         inc cx
  73.         bt word[panel_but+7],0
  74.         jnc @f
  75.                 add edx,25 shl 16
  76.                 call draw_but_icon ;Found
  77.         @@:
  78.  
  79.         inc cx
  80.         bt word[panel_but+8],0
  81.         jnc @f
  82.                 add edx,25 shl 16
  83.                 call draw_but_icon ;Replace
  84.         @@:
  85.  
  86.         inc cx
  87.         bt word[panel_but+9],0
  88.         jnc @f
  89.                 add edx,25 shl 16
  90.                 call draw_but_icon ;Key words
  91.         @@:
  92.  
  93.         call [ted_is_select]
  94.         or al,al
  95.         jnz @f
  96.                 and ecx,0xffff
  97.         @@:
  98.         inc cx
  99.         bt word[panel_but+10],0
  100.         jnc @f
  101.                 add edx,30 shl 16
  102.                 call draw_but_icon ;Upper
  103.         @@:
  104.  
  105.         inc cx
  106.         bt word[panel_but+11],0
  107.         jnc @f
  108.                 add edx,25 shl 16
  109.                 call draw_but_icon ;Lower
  110.         @@:
  111.  
  112.         inc cx
  113.         bt word[panel_but+12],0
  114.         jnc @f
  115.                 add edx,25 shl 16
  116.                 call draw_but_icon ;Reverse
  117.         @@:
  118.         or ecx,0x40000000
  119.  
  120.         mov ebx,ted_tim_undo
  121.         cmp ted_tim_ch,ebx
  122.         jg @f
  123.                 and ecx,0xffff
  124.         @@:
  125.         inc cx
  126.         bt word[panel_but+13],0
  127.         jnc @f
  128.                 add edx,30 shl 16
  129.                 call draw_but_icon ;Undo
  130.         @@:
  131.         or ecx,0x40000000
  132.  
  133.         cmp ted_tim_undo,1
  134.         jge @f
  135.                 and ecx,0xffff
  136.         @@:
  137.         inc cx
  138.         bt word[panel_but+14],0
  139.         jnc @f
  140.                 add edx,25 shl 16
  141.                 call draw_but_icon ;Redo
  142.         @@:
  143.         or ecx,0x40000000
  144.  
  145.         inc cx
  146.         bt word[panel_but+15],0
  147.         jnc @f
  148.                 add edx,30 shl 16
  149.                 call draw_but_icon ;Invisible on|off
  150.         @@:
  151.  
  152.         inc cx
  153.         bt word[panel_but+16],0
  154.         jnc @f
  155.                 add edx,25 shl 16
  156.                 call draw_but_icon
  157.         @@:
  158.  
  159.         inc cx
  160.         bt word[panel_but+17],0
  161.         jnc @f
  162.                 add edx,25 shl 16
  163.                 call draw_but_icon ;Âûáîð ôàéëà ïîäñâåòêè
  164.         @@:
  165.  
  166.         inc cx
  167.         bt word[panel_but+18],0
  168.         jnc @f
  169.                 add edx,30 shl 16
  170.                 call draw_but_icon ;cp 1251 -> 866
  171.         @@:
  172.  
  173.         inc cx
  174.         bt word[panel_but+19],0
  175.         jnc @f
  176.                 add edx,25 shl 16
  177.                 call draw_but_icon ;cp 866 -> 1251
  178.         @@:
  179.  
  180.         popad
  181.         ret
  182.  
  183. ;txtBUp db 24
  184. ;txtBDn db 25
  185. ;txtBRi db 26
  186. ;txtBLe db 27
  187.  
  188. ;input:
  189. ; edi = pointer to tedit struct
  190. align 4
  191. proc draw_panel_find
  192.         cmp ted_panel_id,TED_PANEL_FIND ;if not panel
  193.         jne @f
  194.         push eax ebx ecx edx
  195.                 mov ecx,ted_wnd_t
  196.                 shl ecx,16
  197.                 mov cx,20
  198.                 mcall SF_DRAW_RECT,TED_PANEL_WIDTH,,[sc.work]
  199.  
  200.                 mov ebx,30*65536+25
  201.                 add ebx,ted_wnd_t
  202.                 mov ecx,[sc.work_text]
  203.                 or ecx,0x80000000
  204.                 mcall SF_DRAW_TEXT,,,txtFindCapt
  205.  
  206.                 stdcall [edit_box_draw], edit2
  207.  
  208.                 mov ecx,ted_wnd_t
  209.                 add cx,20+15 ; 15 - height text box
  210.                 shl ecx,16
  211.                 add ecx,ted_wnd_h
  212.                 mov edx,ted_scr_h
  213.                 add cx,word[edx+sb_offs_size_y]
  214.                 sub cx,20+15-1 ; 15 - height text box
  215.                 mcall SF_DRAW_RECT,TED_PANEL_WIDTH,,[sc.work]
  216.  
  217.                 mov ecx,ted_wnd_t
  218.                 add cx,20+15+5
  219.                 shl ecx,16
  220.                 mov cx,20
  221.                 mcall SF_DEFINE_BUTTON,5*65536+85,,201,[sc.work_button] ;201 - button id
  222.  
  223.                 mov ebx,15*65536+(20+15+10)
  224.                 add ebx,ted_wnd_t
  225.                 mov ecx,[sc.work_text]
  226.                 or ecx,0x80000000
  227.                 mcall SF_DRAW_TEXT,,,txtFindNext
  228.         pop edx ecx ebx eax
  229.         jmp .end_f
  230.         @@:
  231.         push eax edx
  232.                 mov edx,201
  233.                 or edx,0x80000000
  234.                 mcall SF_DEFINE_BUTTON
  235.         pop edx eax
  236.         .end_f:
  237.         ret
  238. endp
  239.  
  240. ;input:
  241. ; edi = pointer to tedit struct
  242. align 4
  243. proc draw_panel_syntax
  244.         cmp ted_panel_id,TED_PANEL_SYNTAX ;if not panel
  245.         jne @f
  246.         pushad
  247.  
  248.         mov ecx,ted_wnd_t
  249.         shl ecx,16
  250.         mov cx,20
  251.         mcall SF_DRAW_RECT,TED_PANEL_WIDTH,,[sc.work] ;ðèñîâàíèå âåðõíåãî ôîíîâîãî ïðÿìîóãîëüíèêà
  252.  
  253.         stdcall dword[tl_draw], tree1
  254.         mov [ws_dir_lbox.all_redraw],1 ;äëÿ ïîëíîé ïåðåðèñîâêè äî÷åðíåãî ñêðîëëèíãà
  255.         stdcall dword[scrollbar_ver_draw], dword ws_dir_lbox
  256.  
  257.         ror ecx,16
  258.         add ecx,dword[tree1.box_height]
  259.         add ecx,20
  260.         and ecx,0xffff
  261.         ror ecx,16
  262.         add ecx,ted_wnd_h
  263.         mov esi,ted_scr_h
  264.         add cx,word[esi+sb_offs_size_y]
  265.         sub cx,20
  266.         sub ecx,dword[tree1.box_height]
  267.         inc cx
  268.         int 0x40 ;ðèñîâàíèå íèæíåãî ôîíîâîãî ïðÿìîóãîëüíèêà
  269.  
  270.         mov ecx,ted_wnd_t
  271.         add ecx,25
  272.         add ecx,dword[tree1.box_height]
  273.         shl ecx,16
  274.         mov cx,20
  275.         mcall SF_DEFINE_BUTTON,(5 shl 16)+65,,200,[sc.work_button] ;200 - button id
  276.  
  277.         mov ebx,(30 shl 16)+5
  278.         add ebx,ted_wnd_t
  279.         mov ecx,[sc.work_text]
  280.         or ecx,0x80000000
  281.         mcall SF_DRAW_TEXT,,,txtFormatCapt
  282.  
  283.         mov ebx,(10 shl 16)+31
  284.         add ebx,dword[tree1.box_height]
  285.         add ebx,ted_wnd_t
  286.         mcall ,,,txtFormatApply
  287.  
  288.         popad
  289.         jmp .end_f
  290.         @@:
  291.                 push eax edx
  292.                 mov edx,200
  293.                 or edx,0x80000000
  294.                 mcall SF_DEFINE_BUTTON ;åñëè íåò ïàíåëè òî óäàëÿåì êíîïêó
  295.                 pop edx eax
  296.         .end_f:
  297.         ret
  298. endp
  299.  
  300. MIN_M_WND_H equ 100 ;ìèíèìàëüíàÿ âûñîòà ãëàâíîãî îêíà
  301. ;input:
  302. ; edi = pointer to tedit struct
  303. align 4
  304. EvSize:
  305.         pushad
  306.         mov ebx,ted_scr_h
  307.         mov esi,ted_scr_w
  308.  
  309.         m2m ted_wnd_w,[procinfo.client_box.width] ;ñòàâèì øèðèíó îêíà ðåäàêòîðà ðàâíîé øèðèíå âñåãî îêíà
  310.         mov eax,ted_wnd_l
  311.         sub ted_wnd_w,eax ;îòíèìàåì îòñòóï ñëåâà
  312.         movzx eax,word[esi+sb_offs_size_x]
  313.         sub ted_wnd_w,eax ;îòíèìàåì øèðèíó âåðò. ñêðîëëèíãà
  314.  
  315.         m2m ted_wnd_h,[procinfo.client_box.height] ;ñòàâèì âûñîòó îêíà ðåäàêòîðà ðàâíîé âûñîòå âñåãî îêíà
  316.         cmp ted_wnd_h,MIN_M_WND_H
  317.         jg @f
  318.                 mov ted_wnd_h,MIN_M_WND_H
  319.         @@:
  320.  
  321.         movzx eax,word[ebx+sb_offs_size_y]
  322.         sub ted_wnd_h,eax             ;îòíèìàåì âûñîòó ãîðèç. ñêðîëëèíãà
  323.         mov eax,ted_wnd_t
  324.         sub ted_wnd_h,eax             ;îòíèìàåì îòñòóï ñâåðõó
  325.  
  326.         stdcall [ted_init_scroll_bars], tedit0,2
  327.  
  328.         mov eax,ted_wnd_t
  329.         mov edi,dword tree1
  330.         mov tl_box_top,eax ;=ted_wnd_t
  331.         add tl_box_top,20
  332.  
  333.         mov [edit2.top],eax ;=ted_wnd_t
  334.         add dword[edit2.top],20
  335.  
  336.         popad
  337.         ret
  338.  
  339. ;input:
  340. ;  ecx = 0x4000____
  341. ;   cx = icon index
  342. ;  edx = x*2^16+y
  343. align 4
  344. draw_but_icon:
  345.         push eax ebx
  346.  
  347.         mov eax,SF_DEFINE_BUTTON
  348.         push ecx edx esi
  349.                 mov ebx,edx
  350.                 mov edx,ecx
  351.                 add edx,3
  352.                 mov cx,bx
  353.                 shl ecx,16
  354.                 mov cx,19 ;=20-1
  355.                 mov bx,19 ;=20-1
  356.                 mov esi,ebx
  357.                 shr esi,16
  358.                 add esi,20
  359.                 cmp esi,[procinfo.client_box.width]
  360.                 jge @f ;êíîïêà íå âëåçëà â îêíî
  361.                         mov esi,[sc.work_button]
  362.                         int 0x40 ;ñòàâèì êíîïêó
  363.                         mov eax,SF_PUT_IMAGE
  364.                 @@:
  365.         pop esi edx ecx
  366.  
  367.         cmp eax,SF_PUT_IMAGE
  368.         jne @f ;êíîïêà íå âëåçëà â îêíî
  369.                 mov ebx,[bmp_icon]
  370.                 bt ecx,30 ;if (ecx & 0x40000000)
  371.                 jc .gray
  372.                         add ebx,TOOLBAR_ICONS_SIZE ;ïåðåìåùàåìñÿ íà ñåðûå êíîïêè
  373.                 .gray:
  374.                 push ecx
  375.                 and ecx,0xffff
  376.                 imul ecx,1200
  377.                 add ebx,ecx
  378.                 mov ecx,(20 shl 16)+20
  379.                 int 0x40 ;ñòàâèì ðèñóíîê íà êíîïêó
  380.                 pop ecx
  381.         @@:
  382.         pop ebx eax
  383.         ret
  384.  
  385. ;descrition:
  386. ; ôóíêöèÿ äëÿ ãåíåðèðîâàíèÿ ñåðûõ èêîíîê
  387. ;input:
  388. ; buf_rgb - áóôåð ñ âõîäíûì 24 áèòíûì öâåòíûì èçîáðàæåíèåì
  389. ; buf_g24 - áóôåð ñ âûõîäíûì 24 áèòíûì ñåðûì èçîáðàæåíèåì
  390. ; pixels - ÷èñëî ïèêñåëåé â èçîáðàæåíèè
  391. align 4
  392. proc img_to_gray, buf_rgb:dword, buf_g24:dword, pixels:dword
  393. pushad
  394.         mov esi,[buf_rgb]
  395.         mov edi,[buf_g24]
  396.         mov ecx,[pixels]
  397.         mov ebx,3
  398.         @@:
  399.                 movzx eax,byte[esi]
  400.                 movzx edx,byte[esi+1]
  401.                 add eax,edx
  402.                 movzx edx,byte[esi+2]
  403.                 add eax,edx
  404.                 xor edx,edx
  405.                 div ebx ;shr eax,2
  406.                 mov ah,al
  407.                 mov word[edi],ax
  408.                 mov byte[edi+2],al
  409.                 add esi,3
  410.                 add edi,3
  411.                 loop @b
  412. popad
  413.         ret
  414. endp
  415.  
  416.