// File: /workspace/github_c_makefile_star2_O2/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)
testb %al, %al
je 0x742e9
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x74418
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 0x587f0
movl %eax, %r12d
movq 0xed9c1(%rip), %rax     # 0x161ae8
movswl (%rax), %r13d
testl %r12d, %r12d
jle 0x742f1
decl %r12d
movl %r12d, %edi
callq 0x59b10
testq %rax, %rax
je 0x7412b
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %r13d, %esi
callq 0x5a150
testb %al, %al
jne 0x7412b
movq 0x190(%r14), %rax
cmpq 0x190(%rbx), %rax
jne 0x7412b
movl 0x30(%r14), %edi
pushq $0x2
popq %rsi
callq 0x596b0
testb %al, %al
je 0x741ea
movl 0xa8(%r14), %r15d
movq 0x18(%rsp), %rdi
callq 0x59c60
cwtl
imull %r15d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x6f377(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6f603(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
pushq $0x10
popq %rsi
callq 0x596b0
testb %al, %al
je 0x74269
movq 0x20(%rsp), %rax
addl $-0x3, %eax
cmpl %r15d, %eax
jg 0x74269
addl $0x4, %r15d
movq %r15, 0x20(%rsp)
jmp 0x7412b
movl 0x30(%r14), %edi
pushq $0x1
popq %rsi
callq 0x596b0
testb %al, %al
je 0x7412b
movl 0xac(%r14), %r15d
movq 0x18(%rsp), %rdi
callq 0x59c60
cwtl
imull %r15d, %eax
cvtsi2sd %eax, %xmm0
divsd 0x6f2f0(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6f57c(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
pushq $0x4
popq %rsi
callq 0x596b0
testb %al, %al
je 0x742aa
movq 0x10(%rsp), %rax
addl $-0x2, %eax
cmpl %r15d, %eax
jg 0x742aa
addl $0x4, %r15d
movq %r15, 0x10(%rsp)
jmp 0x7412b
movl 0x30(%r14), %edi
pushq $0x10
popq %rsi
callq 0x596b0
testb %al, %al
jne 0x7412b
movq 0x8(%rsp), %rax
incl %eax
cmpl %r15d, %eax
jl 0x7412b
movq 0x190(%rbx), %rax
movl 0xb0(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movq %rax, 0x8(%rsp)
jmp 0x7412b
movl 0x30(%r14), %edi
pushq $0x4
popq %rsi
callq 0x596b0
testb %al, %al
jne 0x7412b
movq (%rsp), %rax
incl %eax
cmpl %r15d, %eax
jl 0x7412b
movq 0x190(%rbx), %rax
movl 0xb4(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movq %rax, (%rsp)
jmp 0x7412b
pushq $-0x1
popq %rbp
jmp 0x74418
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 0x56a50
movdqu 0x5ec(%rax), %xmm0
movdqa %xmm0, 0x40(%rsp)
cmpl $0x0, 0x2c(%rsp)
jne 0x74418
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x569d0
testb %al, %al
je 0x7435c
movq 0x48(%rsp), %xmm0
paddd 0x71926(%rip), %xmm0    # 0xe5c80
jmp 0x7437a
pxor %xmm0, %xmm0
pcmpeqd 0x40(%rsp), %xmm0
movmskps %xmm0, %eax
xorl $0xf, %eax
jne 0x74418
movdqa 0x71906(%rip), %xmm0    # 0xe5c80
leaq 0x40(%rsp), %rdi
movq %xmm0, 0x8(%rdi)
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x59e30
leaq 0x68(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0xedc04(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x50(%rsp), %r15
andq $0x0, (%r15)
movq 0xed2ba(%rip), %rdx     # 0x161670
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r15, %r8
callq 0x58b80
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 0xed436(%rip), %rax     # 0x161820
movl (%rax), %ecx
leaq 0x60(%rsp), %r8
andq $0x0, (%r8)
movq 0xed48c(%rip), %rdx     # 0x161888
leaq 0x50(%rsp), %rsi
movq %r12, %rdi
callq 0x58b80
addq $0x5b8, %rbx            # imm = 0x5B8
movq %rbx, %rdi
callq 0x70196
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)