Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 996 → Rev 2971

/kernel/branches/kolibri_pe/gui/button.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/kolibri_pe/gui/font.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/kernel/branches/kolibri_pe/gui/win.c
0,0 → 1,204
 
#include <types.h>
#include <core.h>
#include <spinlock.h>
#include <link.h>
#include <mm.h>
#include <slab.h>
 
 
slab_cache_t *win_slab;
 
link_t win_list;
 
window_t *win_slot[256];
 
extern int current_task;
 
void fill_disp_data(int left, int top, int right,
int bottom, int slot);
 
void update_disp_data(window_t *win)
{
do{
// fill_disp_data(win->wrect.left, win->wrect.top,
// win->wrect.right,win->wrect.bottom,
// win->slot);
 
 
__asm__ __volatile__ (
"call _set_screen \n\t"
:
:"b" (win->wrect.left),
"a" (win->wrect.top),
"c" (win->wrect.right-win->wrect.left+1),
"d" (win->wrect.bottom-win->wrect.top+1),
"S" (win->slot)
:"edi");
 
__asm__ __volatile__ (
""
:::"eax", "ebx", "ecx", "edx", "esi");
 
win = (window_t*)win->link.prev;
} while(&win->link != &win_list);
}
 
void insert_window(window_t *win)
{
if( list_empty(&win_list))
list_prepend(&win->link, &win_list);
else
{
window_t *tmp;
tmp = (window_t*)win_list.next;
 
while( &tmp->link != &win_list)
{
if(win->style <= tmp->style)
break;
tmp = (window_t*)tmp->link.next;
}
list_insert(&win->link, &tmp->link);
};
update_disp_data(win);
};
 
u32_t sys_create_window(char *caption, u32_t style,
int x, int y, int width, int height)
{
window_t *win;
int r, b;
 
DBG("\ncreate window %s, x %d y %d\n"
"width %d height %d\n",caption, x,y, width, height);
 
win = (window_t*)slab_alloc(win_slab,0);
 
link_initialize(&win->link);
 
r = x+width-1;
b = y+height-1;
 
win->wrect.left = x;
win->wrect.top = y;
win->wrect.right = r;
win->wrect.bottom = b;
 
win->crect.left = x;
win->crect.top = y;
win->crect.right = r;
win->crect.bottom = b;
 
win->style = style;
win->slot = current_task;
 
list_initialize(&win->queue);
win->qflags = 0;
 
win->caption = caption;
 
win_slot[current_task] = win;
return current_task;
}
 
#define QS_PAINT 1
 
bool sys_show_window(u32_t handle)
{
window_t *win;
 
win = win_slot[current_task];
 
insert_window(win);
win->qflags |= QS_PAINT;
 
return true;
};
 
void sys_get_event(event_t *ev)
{
window_t *win;
 
win = win_slot[current_task];
 
if(win->qflags & QS_PAINT)
{
ev->code = 1;
ev->win = win->slot;
ev->val1 = 0;
ev->val2 = 0;
ev->x = 0;
ev->y = 0;
win->qflags&= ~QS_PAINT;
};
}
 
static inline draw_bar(int x, int y, int w, int h, u32_t color)
{
int_draw_bar(x, y, w, h, color);
__asm__ __volatile__ (
""
:::"ebx", "esi", "edi");
};
 
static inline hline(int x, int y, int w, color_t color)
{
int_hline(x, y, w, color);
__asm__ __volatile__ (
""
:::"esi", "edi");
};
 
static inline vline(int x, int y, int h, color_t color)
{
int_vline(x, y, h, color);
__asm__ __volatile__ (
""
:::"esi", "edi");
};
 
static inline rectangle(int x, int y, int w, int h, color_t color)
{
int_rectangle(x, y, w, h, color);
__asm__ __volatile__ (
""
:::"esi", "edi");
};
 
extern color_t skin_active;
 
void sys_def_window_proc(event_t *ev)
{
window_t *win;
 
win = win_slot[current_task];
 
if(ev->code =1)
{
int w, h;
color_t *skin = &skin_active;
 
w = win->wrect.right-win->wrect.left+1;
h = win->wrect.bottom - win->wrect.top+1;
 
rectangle(win->wrect.left, win->wrect.top,
w, h, skin[1]);
 
rectangle(win->wrect.left+1, win->wrect.top+1,
w-2, h-2, skin[2]);
 
rectangle(win->wrect.left+2, win->wrect.top+2,
w-4, h-4, skin[2]);
 
rectangle(win->wrect.left+3, win->wrect.top+3,
w-6, h-6, skin[2]);
 
rectangle(win->wrect.left+4, win->wrect.top+4,
w-8, h-8, skin[0]);
 
// draw_bar(win->wrect.left+4, win->wrect.top+4,
// w-8, h-8, skin[1]);
 
};
};
/kernel/branches/kolibri_pe/gui/window.inc
22,7 → 22,7
mov al,[edi+WDATA.fl_wstyle]
and al,0x0F
cmp al,0x03
jne @f
jb @f
mov eax,[_skinh]
add eax,3
ret
557,7 → 557,6
 
 
 
 
check_window_position:
 
pushad ; window inside screen ?
862,7 → 861,6
jnz noinside2
call [drawbar]
noinside2:
 
popad
 
ret
1130,13 → 1128,11
ret
 
 
iglobal
window_moving db 'K : Window - move/resize',13,10,0
window_moved db 'K : Window - done',13,10,0
endg
;iglobal
; window_moving db 'K : Window - move/resize',13,10,0
; window_moved db 'K : Window - done',13,10,0
;endg
 
bPressedMouseXY_W db 0x0
 
; check window touch
align 4
checkwindows:
1164,34 → 1160,60
popad
ret
.mouse_buttons_pressed:
;..................................... start 2/4 : modified by vhanla .................
uglobal
bPressedMouseXY_W db 0x0
endg
;..................................... end 2/4 : modified by vhanla ...................
mov esi,[TASK_COUNT]
inc esi
 
;..................................... start 3/4 : modified by vhanla .................
cmp [bPressedMouseXY_W],0
jnz @f
mov [bPressedMouseXY_W],1
cmp [bPressedMouseXY_W],1
ja @f
inc [bPressedMouseXY_W]
jnc @f
;mov ax,[MOUSE_X]
;mov [mx],ax
;mov ax,[MOUSE_Y]
;mov [my],ax
mov eax,dword[MOUSE_X]
mov dword[mx],eax
@@:
;..................................... end 3/4 : modified by vhanla ...................
 
movzx eax,word [MOUSE_Y]
movzx ebx,word [MOUSE_X]
mov ecx, [Screen_Max_X]
add ebx, [_display_data]
inc ecx
mul ecx
movzx edi, byte [ebx+eax]
 
cwloop:
cmp esi,2
jb .exit
 
movzx esi, word [WIN_STACK + edi * 2]
 
dec esi
movzx edi, word [WIN_POS + esi * 2] ; ebx
shl edi, 5
add edi, window_data
; mov edi, ebx
mov ecx, [edi + WDATA.box.left]
mov edx, [edi + WDATA.box.top]
 
movzx eax,word [MOUSE_X]
movzx ebx,word [MOUSE_Y]
mov eax,ecx
mov ebx,edx
test [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
jnz cwloop
 
;..................................... start 4/4 : modified by vhanla .................
movzx eax, word [mx]; movzx eax,word[MOUSE_X]
movzx ebx, word [my]; movzx ebx,word[MOUSE_Y]
;..................................... endt 4/4 : modified by vhanla ..................
cmp ecx, eax
jae cwloop
cmp edx, ebx
jae cwloop
add ecx, [edi + WDATA.box.width]
add edx, [edi + WDATA.box.height]
cmp eax, ecx
jae cwloop
cmp ebx, edx
jae cwloop
 
pushad
mov eax, esi
mov ebx, [TASK_COUNT]
1198,10 → 1220,14
cmp eax, ebx ; is this window active?
jz .move_resize_window
 
cmp [bPressedMouseXY_W], 1
ja .exit_popa
 
; eax = position in windowing stack
; redraw must ?
lea esi, [WIN_POS + esi * 2]
call waredraw
.exit_popa:
add esp, 32
 
.exit:
1252,10 → 1278,10
 
.continue:
 
push esi
mov esi, window_moving
call sys_msg_board_str
pop esi
; push esi
; mov esi, window_moving
; call sys_msg_board_str
; pop esi
 
mov ecx, [timer_ticks] ; double-click ?
mov edx, ecx
1311,6 → 1337,7
call drawwindowframes
 
mov [reposition],0
mov [MOUSE_DOWN],byte 1 ; no reaction to mouse up/down
 
; move window
 
1320,6 → 1347,7
 
call checkVga_N13
 
mov [MOUSE_BACKGROUND],byte 0
 
call [draw_pointer]
 
1328,7 → 1356,7
popad
 
mov esi,[WIN_TEMP_XY]
cmp esi, dword [MOUSE_X]
cmp esi,[MOUSE_X]
je cwb
 
mov cx,[MOUSE_X]
1608,8 → 1636,8
 
retwm:
 
mov esi,window_moved
call sys_msg_board_str
; mov esi,window_moved
; call sys_msg_board_str
 
popad
 
1745,3 → 1773,405
ret
 
 
;ebx x
;eax y
;ecx width
;edx height
;esi slot
 
align 4
_set_screen:
push edx
add ebx, [_display_data]
mul [_screen_width]
lea ebx, [eax+ebx]
 
mov eax, esi
mov ah, al
mov esi, eax
shl eax, 16
or eax, esi
 
pop edx
mov esi, ecx
.row:
 
mov edi, ebx
add ebx, [_screen_width]
 
mov ecx, esi
 
dec edx
js .done
.16:
cmp ecx, 16
jb .8
 
mov [edi], eax
mov [edi+4], eax
mov [edi+8], eax
mov [edi+12], eax
add edi, 16
sub ecx, 16
jmp .16
.8:
shr ecx, 2
rep stosd
mov ecx, esi
and ecx, 3
rep stosb
jmp .row
.done:
ret
 
;[esp+4] ebp
;[esp+8] x
;[esp+12] y
;[esp+16] w
;[esp+20] h
;[esp+24] color
 
;ebx disp data
;edx dest
 
public _int_draw_bar
align 4
_int_draw_bar:
 
lea ecx, [esp+4]
call lock_cursor
 
sub esp, 4
mov [esp], ebp
 
mov ebx, [esp+8]
mov eax, [esp+12]
mul [_screen_width]
add ebx, [_display_data]
lea ebx, [eax+ebx]
 
mov edi, [esp+8]
mov eax, [esp+12]
mul [BytesPerScanLine]
 
cmp byte [ScreenBPP], 24
je .24
 
lea ecx, [LFB_BASE+eax+edi*4]
 
mov eax, [esp+24]
mov edx, [CURRENT_TASK]
.row32:
mov edi, ecx
mov esi, ebx
 
add ecx, [BytesPerScanLine]
add ebx, [_screen_width]
 
dec dword [esp+20]
js .done
 
mov ebp, [esp+16]
 
align 16
.draw32:
cmp dl, byte [esi]
jne @f
 
stosd
@@:
inc esi
dec ebp
jnz .draw32
jmp .row32
.done:
call unlock_cursor
 
mov ebp, [esp]
add esp, 4
ret
 
.24:
lea ecx, [LFB_BASE+edi*3]
add ecx, eax
 
mov eax, [esp+24]
mov edx, eax
shr edx, 8
mov dl, [CURRENT_TASK]
.row24:
mov edi, ecx
mov esi, ebx
 
add ecx, [BytesPerScanLine]
add ebx, [_screen_width]
 
dec dword [esp+20]
js .done
 
mov ebp, [esp+16]
 
align 16
.draw24:
cmp dl, byte [esi]
jne @f
 
mov [edi], ax
mov [edi+2], dh
@@:
add edi, 3
inc esi
dec ebp
jnz .draw24
jmp .row24
 
 
 
;[esp+4] x
;[esp+8] y
;[esp+12] w
;[esp+16] color
 
;esi disp data
;edi dest
 
 
public _int_hline
align 4
_int_hline:
 
mov esi, [esp+4]
mov eax, [esp+8]
mov ecx, [esp+12]
 
mul [_screen_width]
add esi, [_display_data]
add esi, eax
 
mov edi, [esp+4]
mov eax, [esp+8]
mul [BytesPerScanLine]
 
cmp byte [ScreenBPP], 24
je .24
 
lea edi, [LFB_BASE+eax+edi*4]
 
mov eax, [esp+16]
 
.32_kernel:
mov edx, [CURRENT_TASK]
 
align 16
.draw32:
cmp dl, byte [esi]
jne @f
 
stosd
@@:
inc esi
dec ecx
jnz .draw32
 
ret
.24:
lea edi, [LFB_BASE+edi*3]
add edi, eax
 
mov eax, [esp+16]
 
.24_kernel:
mov edx, eax
shr edx, 8
mov dl, [CURRENT_TASK]
 
align 16
.draw24:
cmp dl, byte [esi]
jne @f
 
mov [edi], ax
mov [edi+2], dh
@@:
add edi, 3
inc esi
dec ecx
jnz .draw24
 
ret
 
 
;[esp+4] x
;[esp+8] y
;[esp+12] h
;[esp+16] color
 
;esi disp data
;edi dest
 
public _int_vline
align 4
_int_vline:
 
mov esi, [esp+4]
mov eax, [esp+8]
mov ecx, [esp+12]
 
mul [_screen_width]
add esi, [_display_data]
add esi, eax
 
mov edi, [esp+4]
mov eax, [esp+8]
mul [BytesPerScanLine]
 
cmp byte [ScreenBPP], 24
je .24
 
lea edi, [LFB_BASE+eax+edi*4]
 
mov eax, [esp+16]
 
.32_kernel:
mov edx, [CURRENT_TASK]
 
align 16
.draw32:
cmp dl, byte [esi]
jne @f
 
mov [edi], eax
@@:
add esi, [_screen_width]
add edi, [BytesPerScanLine]
dec ecx
jnz .draw32
 
ret
.24:
lea edi, [LFB_BASE+edi*3]
add edi, eax
 
mov eax, [esp+16]
 
.24_kernel:
mov edx, eax
shr edx, 8
mov dl, [CURRENT_TASK]
 
align 16
.draw24:
cmp dl, byte [esi]
jne @f
 
mov [edi], ax
mov [edi+2], dh
@@:
add esi, [_screen_width]
add edi, [BytesPerScanLine]
dec ecx
jnz .draw24
 
ret
 
;[esp] dst
;[esp+4] mask
 
;[esp+12] x
;[esp+16] y
;[esp+20] w
;[esp+24] h
;[esp+32] color
 
public _int_rectangle
align 4
_int_rectangle:
 
.dst equ (esp)
.mask equ (esp+4)
 
.x equ (esp+12)
.y equ (esp+16)
.w equ (esp+20)
.h equ (esp+24)
.color equ (esp+28)
 
sub esp, 8
 
mov esi, [.x]
mov eax, [.y]
mul [_screen_width]
add esi, [_display_data]
add esi, eax
mov [.mask], esi
 
mov edi, [.x]
mov eax, [.y]
mul [BytesPerScanLine]
 
cmp byte [ScreenBPP], 24
je .24
 
lea edi, [LFB_BASE+eax+edi*4]
 
mov [.dst], edi
 
mov ecx, [.w]
mov eax, [.color]
call _int_hline.32_kernel
 
sub edi, 4
dec esi
 
mov ecx, [.h]
call _int_vline.32_kernel
 
mov edi, [.dst]
mov esi, [.mask]
mov ecx, [.h]
call _int_vline.32_kernel
 
mov ecx, [.w]
sub esi, [_screen_width]
sub edi, [BytesPerScanLine]
call _int_hline.32_kernel
 
add esp, 8
ret
.24:
lea edi, [LFB_BASE+edi*3]
add edi, eax
 
mov [.dst], edi
 
mov ecx, [.w]
mov eax, [.color]
call _int_hline.24_kernel
 
sub edi, 3
dec esi
 
mov ecx, [.h]
call _int_vline.24_kernel
 
mov edi, [.dst]
mov esi, [.mask]
mov ecx, [.h]
call _int_vline.24_kernel
 
mov ecx, [.w]
sub esi, [_screen_width]
sub edi, [BytesPerScanLine]
call _int_hline.24_kernel
 
restore .dst
restore .mask
 
restore .x
restore .y
restore .w
restore .h
restore .color
 
add esp, 8
ret