
; SOL OS include version 0.2
; for using with FASM

include '../../include/macro/export.inc'
include '../../include/macro/import32.inc'
include '../../include/macro/proc32.inc'
include '../../include/macro/struct.inc'

macro call proc,[arg]
{
	if ~ arg eq
		reverse
		push arg
	end if
	common
	call proc
}

;---------------------------------------------------------
; Window Types
;---------------------------------------------------------
WND_TYPE_TOP		=	0		; MDI child also
WND_TYPE_ICON		=	1

WND_TYPE_BUTTON 	=	10
WND_TYPE_CHECKBOX	=	11

WND_TYPE_EDIT		=	20

WND_TYPE_SCROLL_VERT	=	30
WND_TYPE_SCROLL_HORIZ	=	31

WND_TYPE_LIST_BOX	=	40
WND_TYPE_TREE		=	41

;-------------------------------------
; not exactly happy about them
;-------------------------------------
WND_TYPE_MENU_PAD	=	50
WND_TYPE_MENU_POP	=	51
WND_TYPE_MENU_ITEM_PAD	=	52
WND_TYPE_MENU_ITEM_POP	=	53

;---------------------------------------
; those controls are semi implemented
;---------------------------------------
WND_TYPE_GRID		=	60
WND_TYPE_LIST_VIEW	=	61
WND_TYPE_SLIDER_HORIZ	=	62

;--------------------------------------------
; those controls are not yet implemented
;--------------------------------------------
WND_TYPE_BIG_EDIT	=	70
WND_TYPE_STATIC_TEXT	=	71	
WND_TYPE_STATIC_SHAPE	=	72	

;--------------------------------------------
; Window Flags
;--------------------------------------------
FLAG_WND_NONE		=	0h
FLAG_WND_ALPHA			=	1h
FLAG_WND_HIDDEN 		=	2h
FLAG_WND_NO_MOVE		=	4h
FLAG_WND_NO_RESIZE		=	8h

FLAG_WND_LEFT			=	10h
FLAG_WND_RIGHT			=	20h
FLAG_WND_NO_CAPTION		=	40h	;not used
FLAG_WND_MINI			=	80h

FLAG_WND_NO_CLOSE		=	100h	;not used
FLAG_WND_NO_EDGE		=	200h	;not used
FLAG_WND_NO_CLIENT_EDGE 	=	400h	;not used
FLAG_WND_DISABLED		=	800h

FLAG_WND_NO_MOVE_X		=	1000h
FLAG_WND_NO_MOVE_Y		=	2000h

FLAG_WND_KEEP_RIGHT		=	4000h
FLAG_WND_KEEP_BOTTOM		=	8000h
FLAG_WND_KEEP_DX		=	10000h
FLAG_WND_KEEP_DY		=	20000h

FLAG_WND_ROLL_UP		=	40000h	

;-----------------------------------------
; EVENTS Defined
;-----------------------------------------
ACT_LEFT_DOWN_DESK	=	1
ACT_LEFT_DOWN_CHILD	=	2
ACT_LEFT_DOWN_CAPTURE	=	3

ACT_LEFT_UP_DESK	=	4
ACT_LEFT_UP_CHILD	=	5
ACT_LEFT_UP_CAPTURE	=	6

ACT_LEFT_CLICK		=	7
ACT_LEFT_DCLICK 	=	8

ACT_LEFT_DRAG_DESK	=	9
ACT_LEFT_DRAG_CHILD	=	10

ACT_LEFT_DROP_DESK	=	11
ACT_LEFT_DROP_CHILD	=	12

ACT_MOUSE_MOVE_DESK	=	13
ACT_MOUSE_MOVE_CHILD	=	14

ACT_PAINT_DESK		=	15
ACT_PAINT_CHILD 	=	16

ACT_KEY_DESK		=	17
ACT_KEY_CHILD		=	18

ACT_CLOSE_DESK		=	19	;unlikely to exist?
ACT_CLOSE_CHILD 	=	20

ACT_PULSE		=	21	;not used
ACT_OS_CREATE		=	22

ACT_SCROLL_UP		=	30
ACT_SCROLL_DOWN 	=	31
ACT_SCROLL_LEFT 	=	32
ACT_SCROLL_RIGHT	=	33
ACT_SCROLL_TRACK	=	34
ACT_SCROLL_SET_CRT	=	35
ACT_SCROLL_SET_MIN	=	36
ACT_SCROLL_SET_MAX	=	37

;ACT_LIST_ADD_STRING    =       40
;ACT_LIST_DEL_STRING    =       41
;ACT_LIST_CLEAR         =       42
ACT_LIST_SEL_ITEM	=	43

ACT_GRID_ADD_ROW	=	51
ACT_GRID_ADD_COL	=	52
ACT_GRID_DEL_ROW	=	53
ACT_GRID_DEL_COL	=	54
ACT_GRID_SET_CEL	=	55
ACT_GRID_GET_CEL	=	56

ACT_PAINT_ROLL_UP	=	60

;----------------------------------
;Known callbacks
;----------------------------------
OS_CALL_BEFORE		=     1
OS_CALL_DEFAULT 	=     2
OS_CALL_AFTER		=     3
OS_CALL_NOTIFY		=     4

;----------------------------------
;window structure
;----------------------------------
struc sol_window
{
	.window_alive		dd	?	;"dead" windows are free for "reuse"
	.window_parent		dd	?	;my belowed parent ;)
	.window_level		dd	?	;depth counting down from desktop
	
	;-----------------------------
	;handle of cursor
	;------------------------------
	.window_cursor		dd	?	;window specific mouse cursor handle

	;-----------------------------------
	;callbacks/methods ;)
	;-----------------------------------
	.window_callback_usr1	dd	?	;Before  os callback
	.window_callback	dd	?	;Default os callback
	.window_callback_usr2	dd	?	;After os callback

	;--------------------------------
	; window dimensions
	;--------------------------------
	.window_x		dd	?
	.window_y		dd	?
	.window_dx		dd	?
	.window_dy		dd	?
		
	;----------------------------------
	; move limits
	;----------------------------------
	.window_min_left	dd	?
	.window_min_right	dd	?
	.window_min_top 	dd	?
	.window_min_bottom	dd	?
	
	;--------------------------------
	;resize limits
	;--------------------------------
	.window_dx_min		dd	?
	.window_dy_min		dd	?
	.window_dx_max		dd	?
	.window_dy_max		dd	?
	
	;--------------------------------
	; for auto moveable windows     
	;--------------------------------
	.window_keep_x		dd	?
	.window_keep_y		dd	?
	.window_keep_dx 	dd	?
	.window_keep_dy 	dd	?
		
	;-----------------------------------            
	; location of drag
	; used internally by OS
	;------------------------------------
	.window_drag_dx 	dd	?
	.window_drag_dy 	dd	?

	.window_roll_dy_orig	dd	?
	.window_roll_dy_crt	dd	?

	;-----------------------------------
	;close/min/max/see/etc btn status
	;flags used internaly by OS
	;-----------------------------------
	.window_sysbtn_flags	dd	?	
	
	;-------------------------------------
	; avoid holding a child for this ;)
	;-------------------------------------
	.window_close_x 	dd	?
	.window_close_y 	dd	?
	.window_close_dx	dd	?
	.window_close_dy	dd	?

	;--------------------------------------
	; avoid holding a child for this ;)
	;--------------------------------------
	.window_mini_x		dd	?
	.window_mini_y		dd	?
	.window_mini_dx 	dd	?
	.window_mini_dy 	dd	?
	
	.window_focus		dd	?	;only focused windows receive keys
	
	.window_flags		dd	?	;alpha/resize/move/etc
	.window_flags2		dd	?	;extra flags ..not used for now
	
	;----------------------------------------
	; type id = top/button/edit/check/etc
	; determines how OS will deal with 
	; this kind of window
	;----------------------------------------
	.window_type		dd	?	
	

	;----------------------------------------
	; private variables
	; if you need more space then alloc memory
	; and store pointers/handles here
	;----------------------------------------
	.window_data01		dd	?	
	.window_data02		dd	?
	.window_data03		dd	?
	.window_data04		dd	?
	.window_data05		dd	?
	.window_data06		dd	?
	.window_data07		dd	?
	.window_data08		dd	?
	.window_data_rest	dd	32 dup(?)
	
	;-------------------------------------------------
	;text buff used for edit or caption
	;-------------------------------------------------
	.window_text		db	128 dup (?)
	
	;---------------------------------------------------
	; below vars are for internal OS use only !!!
	;---------------------------------------------------
	.window_childs_zcrt	dd	?	;current number of childs
	.window_childs_focus	dd	?	;handle of the child that has focus
	.window_childs_membuff	dd	?	;lp to memory buffer that holds hndles of child windows handles

}


;----------------------------------------------------
; SOL virtual keys values
;----------------------------------------------------
KEY_EX_UNKNOWN		=	000000h
;--------------------------------------
;Extended keys that are on keyboard
; but are not in ASCII charts
;--------------------------------------
KEY_EX_ARROW_LEFT		=	010000h
KEY_EX_ARROW_RIGHT	=	020000h
KEY_EX_ARROW_UP		=	030000h
KEY_EX_ARROW_DOWN		=	040000h

KEY_EX_HOME		=	050000h
KEY_EX_END		=	060000h
KEY_EX_PAGE_UP	=	070000h
KEY_EX_PAGE_DOWN	=	080000h
KEY_EX_INSERT	=	090000h
KEY_EX_DELETE	=	0A0000h


KEY_EX_F1		=	100000h
KEY_EX_F2		=	110000h
KEY_EX_F3		=	120000h
KEY_EX_F4		=	130000h
KEY_EX_F5		=	140000h
KEY_EX_F6		=	150000h
KEY_EX_F7		=	160000h
KEY_EX_F8		=	170000h
KEY_EX_F9		=	180000h
KEY_EX_F10		=	190000h
KEY_EX_F11		=	1A0000h
KEY_EX_F12		=	1B0000h

KEY_EX_SHIFT_LEFT		=	200000h
KEY_EX_SHIFT_RIGHT	=	210000h

KEY_EX_ALT_LEFT	=	220000h
KEY_EX_ALT_RIGHT	=	230000h

KEY_EX_CTRL_LEFT	=	240000h
KEY_EX_CTRL_RIGHT	=	250000h

KEY_EX_WIN_LEFT	=	260000h
KEY_EX_WIN_RIGHT	=	270000h

KEY_EX_MENU		=	280000h

KEY_EX_CAPS_LOCK		=	300000h
;KEY_EX_NUM_LOCK		=	310000h
KEY_EX_SCROLL_LOCK	=	320000h
KEY_EX_BREAK_PAUSE	=	330000h
KEY_EX_PRINT_SCREEN	=	340000h

;--------------------------------------------
; quick hack = low word is ASCII CODE
;--------------------------------------------
KEY_EX_NUM_0	=	350030h
KEY_EX_NUM_1	=	360031h
KEY_EX_NUM_2	=	370032h
KEY_EX_NUM_3	=	380033h
KEY_EX_NUM_4	=	390034h
KEY_EX_NUM_5	=	400035h
KEY_EX_NUM_6	=	410036h
KEY_EX_NUM_7	=	420037h
KEY_EX_NUM_8	=	430038h
KEY_EX_NUM_9	=	440039h

KEY_EX_NUM_DOT	=	45002Eh
KEY_EX_NUM_PLUS	=	46002Bh
KEY_EX_NUM_MINUS	=	47002Dh
KEY_EX_NUM_SLASH	=	48002Fh
KEY_EX_NUM_STAR	=	49002Ah
KEY_EX_NUM_ENTER	=	50000Dh
KEY_EX_NUM_LOCK	=	510000h

	
;--------------------------------------
; "Simple" Keys that are in ASCII
;--------------------------------------
KEY_ASCII_BS		=	000008h
KEY_ASCII_TAB		=	000009h
KEY_ASCII_CR		=	00000Dh
KEY_ASCII_ESC		=	00001Bh
