// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/widgets/basic/client.cpp
// Function: smooth::GUI::Client::Paint(int)
S::Int S::GUI::Client::Paint(Int message)
{
	if (!IsRegistered()) return Error();
	if (!IsVisible())    return Success();

	Surface	*surface = GetDrawSurface();
	Rect	 client	 = Rect(GetRealPosition() + Point(2, 2), GetRealSize() - Size(3, 3));

	for (Int i = Object::GetNOfObjects() - 1; i >= 0; i--)
	{
		Object	*object = Object::GetNthObject(i);

		if (object == NIL || object->GetObjectType() != Divider::classID || ((Widget *) object)->GetContainer() != container) continue;

		/* Restrict size to area limited by dividers.
		 */
		Divider	*divider = (Divider *) object;

		if (Binary::IsFlagSet(divider->GetFlags(), OR_VERT))
		{
			Int	 dbPos = Math::Round(divider->GetX() * surface->GetSurfaceDPI() / 96.0);

			if	( Binary::IsFlagSet(divider->GetFlags(), OR_LEFT) && dbPos >= client.left   - 3) client.left   = 			  dbPos + 4;
			else if (!Binary::IsFlagSet(divider->GetFlags(), OR_LEFT) && dbPos <= client.right  + 1) client.right  = container->GetWidth()  - dbPos - 2;
		}
		else if (Binary::IsFlagSet(divider->GetFlags(), OR_HORZ))
		{
			Int	 dbPos = Math::Round(divider->GetY() * surface->GetSurfaceDPI() / 96.0);

			if	( Binary::IsFlagSet(divider->GetFlags(), OR_TOP)  && dbPos >= client.top    - 2) client.top    = 			  dbPos + 4;
			else if (!Binary::IsFlagSet(divider->GetFlags(), OR_TOP)  && dbPos <= client.bottom + 1) client.bottom = container->GetHeight() - dbPos - 2;
		}
	}

	Rect	 updateRect = container->GetContainerWindow()->GetUpdateRect();

	switch (message)
	{
		case SP_PAINT:
			if (Rect::DoRectsOverlap(updateRect, client) || (updateRect.left == 0 && updateRect.top == 0 && updateRect.right == 0 && updateRect.bottom == 0))
			{
				updateRect.right  += 5;
				updateRect.bottom += 5;

				Rect	 intersectRect = Rect::OverlapRect(updateRect, client);

				surface->Box(intersectRect, Setup::ClientColor, Rect::Filled);
				surface->Box(client - Size(1, 1), Setup::DividerDarkColor, Rect::Outlined);

				onPaint.Emit();
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x74da9
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x74da9
movl %r14d, 0x2c(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, 0x18(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq %rax, %r15
shrq $0x20, %r15
leal 0x2(%r15), %eax
movq %rax, 0x10(%rsp)
leal 0x2(%r14), %eax
movq %rax, 0x20(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
leal (%r14,%rax), %ecx
decl %ecx
movq %rcx, 0x8(%rsp)
shrq $0x20, %rax
addl %r15d, %eax
decl %eax
movq %rax, (%rsp)
callq 0x575e0
testl %eax, %eax
jle 0x74c81
movl %eax, %r12d
movq 0xf7042(%rip), %rax     # 0x16bae8
incl %r12d
movswl (%rax), %r13d
leal -0x2(%r12), %edi
callq 0x58800
testq %rax, %rax
je 0x74adf
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %r13d, %esi
callq 0x57520
testb %al, %al
je 0x74adf
movq 0x190(%r14), %rax
cmpq 0x190(%rbx), %rax
je 0x74aed
decl %r12d
cmpl $0x1, %r12d
ja 0x74aad
jmp 0x74c81
movl 0x30(%r14), %edi
movl $0x2, %esi
callq 0x583f0
testb %al, %al
je 0x74b77
movl 0xa8(%r14), %r15d
movq 0x18(%rsp), %rdi
callq 0x58930
cwtl
imull %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7eb94(%rip), %xmm0    # 0xf36b8
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7ecb8(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
movl $0x10, %esi
callq 0x583f0
testb %al, %al
je 0x74bfd
movq 0x20(%rsp), %rax
addl $-0x3, %eax
cmpl %r15d, %eax
jg 0x74bfd
addl $0x4, %r15d
movq %r15, 0x20(%rsp)
jmp 0x74adf
movl 0x30(%r14), %edi
movl $0x1, %esi
callq 0x583f0
testb %al, %al
je 0x74adf
movl 0xac(%r14), %r15d
movq 0x18(%rsp), %rdi
callq 0x58930
cwtl
imull %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7eb06(%rip), %xmm0    # 0xf36b8
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7ec2a(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
movl $0x4, %esi
callq 0x583f0
testb %al, %al
je 0x74c40
movq 0x10(%rsp), %rax
addl $-0x2, %eax
cmpl %r15d, %eax
jg 0x74c40
addl $0x4, %r15d
movq %r15, 0x10(%rsp)
jmp 0x74adf
movl 0x30(%r14), %edi
movl $0x10, %esi
callq 0x583f0
testb %al, %al
jne 0x74adf
movq 0x8(%rsp), %rax
incl %eax
cmpl %r15d, %eax
jl 0x74adf
movq 0x190(%rbx), %rax
movl 0xb0(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movq %rax, 0x8(%rsp)
jmp 0x74adf
movl 0x30(%r14), %edi
movl $0x4, %esi
callq 0x583f0
testb %al, %al
jne 0x74adf
movq (%rsp), %rax
incl %eax
cmpl %r15d, %eax
jl 0x74adf
movq 0x190(%rbx), %rax
movl 0xb4(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movq %rax, (%rsp)
jmp 0x74adf
movq 0x10(%rsp), %rax
movl %eax, 0x34(%rsp)
movq (%rsp), %rax
movl %eax, 0x3c(%rsp)
movq 0x20(%rsp), %rax
movl %eax, 0x30(%rsp)
movq 0x8(%rsp), %rax
movl %eax, 0x38(%rsp)
movq 0x190(%rbx), %rdi
callq 0x559e0
movdqu 0x5ec(%rax), %xmm0
movdqa %xmm0, 0x40(%rsp)
cmpl $0x0, 0x2c(%rsp)
jne 0x74da9
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x55970
testb %al, %al
je 0x74cec
movq 0x48(%rsp), %xmm0
paddd 0x80fe6(%rip), %xmm0    # 0xf5cd0
jmp 0x74d0a
pxor %xmm0, %xmm0
pcmpeqd 0x40(%rsp), %xmm0
movmskps %xmm0, %eax
xorl $0xf, %eax
jne 0x74da9
movdqa 0x80fc6(%rip), %xmm0    # 0xf5cd0
leaq 0x40(%rsp), %rdi
movq %xmm0, 0x8(%rdi)
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x58af0
leaq 0x68(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0xf7274(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
xorl %r12d, %r12d
leaq 0x50(%rsp), %r15
movq %r12, (%r15)
movq 0xf6928(%rip), %rdx     # 0x16b670
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r15, %r8
callq 0x57930
movq (%r14), %rax
movl 0x8(%r14), %ecx
movl 0xc(%r14), %edx
decl %ecx
decl %edx
shlq $0x20, %rdx
orq %rdx, %rcx
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
movq 0xf6aa4(%rip), %rax     # 0x16b820
movl (%rax), %ecx
leaq 0x60(%rsp), %r8
movq %r12, (%r8)
movq 0xf6afb(%rip), %rdx     # 0x16b888
leaq 0x50(%rsp), %rsi
movq %r13, %rdi
callq 0x57930
addq $0x5b8, %rbx            # imm = 0x5B8
movq %rbx, %rdi
callq 0x701aa
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop