Subversion Repositories Kolibri OS

Rev

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