LOCALS

.MODEL	SMALL


PUBLIC	CreateWindow2
PUBLIC	CreateWindow
PUBLIC	OutText3D
PUBLIC	Rectangle3D


INCLUDE	GRAPHHI.INC


.CODE

EXTRN	FillRectangle12:PROC
EXTRN	Rectangle12:PROC
EXTRN	Line12:PROC
EXTRN	WriteStr12:PROC
EXTRN	WriteStr12x:PROC

;*******************************************************************************
;CreateWindow2
;*******************************************************************************
;Использует:	CreateWindow, FillRectangle12, WriteStr12x
;
;Вызов:		x1,y1 - координаты левого верхнего угла окна
;		x2,y2 - координаты правого нижнего угла окна
;		color - цвет окна
;		pszCaption - смещение строки заголовка
;
;Возврат:	нет
;
;Изменяемые
;  регистры:	AX,BX,CX,DX,Flags
;*******************************************************************************
CreateWindow2	PROC
		ARG	@@x1:WORD, @@y1:WORD, @@x2:WORD, @@y2:WORD, \
			@@color:BYTE, @@pszCaption:WORD = ARG_SIZE

		push	bp
		mov	bp,sp
		push	si

;формируем поверхность окна

		push	WORD PTR [@@color]
		push	[@@y2]
		push	[@@x2]
		push	[@@y1]
		push	[@@x1]
		call	CreateWindow

;формируем заголовок окна

		mov	al,COLOR_ACTIVECAPTION
		push	ax
		mov	ax,[@@y1]
		add	ax,BORDER_THICKNESS+CAPTION_HEIGHT-1
		push	ax
		mov	ax,[@@x2]
		sub	ax,BORDER_THICKNESS
		push	ax
		mov	ax,[@@y1]
		add	ax,BORDER_THICKNESS
		push	ax
		mov	ax,[@@x1]
		add	ax,BORDER_THICKNESS
		push	ax
		call	FillRectangle12

;выводим текст заголовка окна

		mov	cx,[@@x1]
		add	cx,BORDER_THICKNESS+4
		mov	dx,[@@y1]
		add	dx,BORDER_THICKNESS+1
		mov	bl,COLOR_WHITE
		mov	si,[@@pszCaption]
		call	WriteStr12x

		pop	si
		pop	bp

		ret	ARG_SIZE

CreateWindow2	ENDP

;*******************************************************************************
;CreateWindow
;*******************************************************************************
;Использует:	FillRectangle12, Rectangle12
;
;Вызов:		x1,y1 - координаты левого верхнего угла окна
;		x2,y2 - координаты правого нижнего угла окна
;		color - цвет окна
;
;Возврат:	нет
;
;Изменяемые
;  регистры:	AX,BX,CX,DX,Flags
;*******************************************************************************
CreateWindow	PROC
		ARG	@@x1:WORD, @@y1:WORD, @@x2:WORD, @@y2:WORD, \
			@@color:BYTE = ARG_SIZE

		push	bp
		mov	bp,sp

;строим рамку окна

		push	[@@y2]
		push	[@@x2]
		push	[@@y1]
		push	[@@x1]
		call	Border3D

;заполняем содержимое окна заданным цветом

		push	WORD PTR [@@color]
		mov	ax,[@@y2]
		sub	ax,BORDER_THICKNESS
		push	ax
		mov	ax,[@@x2]
		sub	ax,BORDER_THICKNESS
		push	ax
		mov	ax,[@@y1]
		add	ax,BORDER_THICKNESS
		push	ax
		mov	ax,[@@x1]
		add	ax,BORDER_THICKNESS
		push	ax
		call	FillRectangle12

		pop	bp

		ret	ARG_SIZE

CreateWindow	ENDP

;*******************************************************************************
;OutText3D
;*******************************************************************************
;Использует:	
;
;Вызов:		DS:SI -> адрес ASCIIZ-строки
;		BL = значение пиксела символа
;		BH = значение пиксела фона
;		CX = координата x
;		DX = координата y
;
;Возврат:	нет
;
;Изменяемые
;  регистры:	AX,CX,Flags
;*******************************************************************************
OutText3D	PROC

		push	bx
		push	cx

		mov	bl,COLOR_WHITE
		inc	cx
		inc	dx
		call	WriteStr12

		pop	cx
		pop	bx

		dec	dx
		call	WriteStr12x

		ret

OutText3D	ENDP

;*******************************************************************************
;Rectangle3D
;*******************************************************************************
;Использует:	Rectangle12, Line12
;
;Вызов:		x1,y1 - координаты левого верхнего угла окна
;		x2,y2 - координаты правого нижнего угла окна
;		color - цвет тени
;
;Возврат:	нет
;
;Изменяемые
;  регистры:	AX,BX,CX,DX,Flags
;*******************************************************************************
Rectangle3D	PROC
		ARG	@@x1:WORD, @@y1:WORD, @@x2:WORD, @@y2:WORD = ARG_SIZE

		push	bp
		mov	bp,sp

		mov	al,COLOR_DARKGRAY
		push	ax
		mov	ax,[@@y2]
		dec	ax
		push	ax
		mov	ax,[@@x2]
		dec	ax
		push	ax
		push	[@@y1]
		push	[@@x1]
		call	Rectangle12

		mov	al,COLOR_WHITE
		push	ax
		mov	bx,[@@y1]
		inc	bx
		push	bx
		mov	ax,[@@x2]
		dec	ax
		dec	ax
		push	ax
		push	bx
		mov	ax,[@@x1]
		inc	ax
		push	ax
		call	Line12

		mov	al,COLOR_WHITE
		push	ax
		mov	ax,[@@y2]
		dec	ax
		dec	ax
		push	ax
		mov	bx,[@@x1]
		inc	bx
		push	bx
		mov	ax,[@@y1]
		inc	ax
		push	ax
		push	bx
		call	Line12

		mov	al,COLOR_WHITE
		push	ax
		push	[@@y2]
		push	[@@x2]
		push	[@@y1]
		push	[@@x2]
		call	Line12

		mov	al,COLOR_WHITE
		push	ax
		push	[@@y2]
		push	[@@x2]
		push	[@@y2]
		push	[@@x1]
		call	Line12

		pop	bp

		ret	ARG_SIZE

Rectangle3D	ENDP

;*******************************************************************************
;Border3D
;*******************************************************************************
;Использует:	Line12
;
;Вызов:		x1,y1 - координаты левого верхнего угла окна
;		x2,y2 - координаты правого нижнего угла окна
;		color - цвет тени
;
;Возврат:	нет
;
;Изменяемые
;  регистры:	AX,BX,CX,DX,Flags
;*******************************************************************************
Border3D	PROC
		ARG	@@x1:WORD, @@y1:WORD, @@x2:WORD, @@y2:WORD = ARG_SIZE

		push	bp
		mov	bp,sp

		mov	al,COLOR_BLACK
		push	ax
		push	[@@y2]
		push	[@@x2]
		push	[@@y1]
		push	[@@x2]
		call	Line12

		mov	al,COLOR_BLACK
		push	ax
		push	[@@y2]
		push	[@@x2]
		push	[@@y2]
		push	[@@x1]
		call	Line12

		mov	al,COLOR_GRAY
		push	ax
		push	[@@y1]
		push	[@@x2]
		push	[@@y1]
		push	[@@x1]
		call	Line12

		mov	al,COLOR_GRAY
		push	ax
		push	[@@y2]
		push	[@@x1]
		push	[@@y1]
		push	[@@x1]
		call	Line12

		mov	al,COLOR_DARKGRAY
		push	ax
		mov	ax,[@@y2]
		dec	ax
		push	ax
		mov	bx,[@@x2]
		dec	bx
		push	bx
		mov	ax,[@@y1]
		inc	ax
		push	ax
		push	bx
		call	Line12

		mov	al,COLOR_DARKGRAY
		push	ax
		mov	bx,[@@y2]
		dec	bx
		push	bx
		mov	ax,[@@x2]
		dec	ax
		push	ax
		push	bx
		mov	ax,[@@x1]
		inc	ax
		push	ax
		call	Line12

		mov	al,COLOR_WHITE
		push	ax
		mov	bx,[@@y1]
		inc	bx
		push	bx
		mov	ax,[@@x2]
		dec	ax
		push	ax
		push	bx
		mov	ax,[@@x1]
		inc	ax
		push	ax
		call	Line12

		mov	al,COLOR_WHITE
		push	ax
		mov	ax,[@@y2]
		dec	ax
		push	ax
		mov	bx,[@@x1]
		inc	bx
		push	bx
		mov	ax,[@@y1]
		inc	ax
		push	ax
		push	bx
		call	Line12

		mov	al,COLOR_GRAY
		push	ax
		mov	ax,[@@y2]
		dec	ax
		dec	ax
		push	ax
		mov	ax,[@@x2]
		dec	ax
		dec	ax
		push	ax
		mov	ax,[@@y1]
		inc	ax
		inc	ax
		push	ax
		mov	ax,[@@x1]
		inc	ax
		inc	ax
		push	ax
		call	Rectangle12

		pop	bp

		ret	ARG_SIZE

Border3D	ENDP


END
