// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x750a3
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x750a3
movl %r14d, 0x1c(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r14
movq %rax, %r15
shrq $0x20, %r15
leal 0x2(%r15), %r12d
leal 0x2(%rax), %r13d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
leal (%r14,%rax), %ecx
decl %ecx
shrq $0x20, %rax
movl %r13d, (%rsp)
movl %r12d, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
addl %r15d, %eax
decl %eax
movl %eax, 0xc(%rsp)
callq 0x575e0
testl %eax, %eax
jle 0x74fa3
movl %eax, %r12d
movq 0xf7d1a(%rip), %rax     # 0x16cae8
incl %r12d
movswl (%rax), %r13d
leal -0x2(%r12), %edi
callq 0x58800
testq %rax, %rax
je 0x74e07
movq %rax, %r14
leaq 0x20(%rax), %rdi
movl %r13d, %esi
callq 0x57520
testb %al, %al
je 0x74e07
movq 0x190(%r14), %rax
cmpq 0x190(%rbx), %rax
je 0x74e15
decl %r12d
cmpl $0x1, %r12d
jg 0x74dd5
jmp 0x74fa3
movl 0x30(%r14), %edi
movl $0x2, %esi
callq 0x583f0
testb %al, %al
je 0x74ed0
movl 0xa8(%r14), %r15d
movq 0x10(%rsp), %rdi
callq 0x58930
cwtl
imull %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7f6a0(%rip), %xmm0    # 0xf44f0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7f92c(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
movl $0x10, %esi
callq 0x583f0
testb %al, %al
je 0x74e8f
movl (%rsp), %eax
addl $-0x3, %eax
cmpl %r15d, %eax
jle 0x74f88
movl 0x30(%r14), %edi
movl $0x10, %esi
callq 0x583f0
testb %al, %al
jne 0x74e07
movl 0x8(%rsp), %eax
incl %eax
cmpl %r15d, %eax
jl 0x74e07
movq 0x190(%rbx), %rax
movl 0xb0(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movl %eax, 0x8(%rsp)
jmp 0x74e07
movl 0x30(%r14), %edi
movl $0x1, %esi
callq 0x583f0
testb %al, %al
je 0x74e07
movl 0xac(%r14), %r15d
movq 0x10(%rsp), %rdi
callq 0x58930
cwtl
imull %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7f5e5(%rip), %xmm0    # 0xf44f0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7f871(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
movl 0x30(%r14), %edi
movl $0x4, %esi
callq 0x583f0
testb %al, %al
je 0x74f47
movl 0x4(%rsp), %eax
addl $-0x2, %eax
cmpl %r15d, %eax
jle 0x74f95
movl 0x30(%r14), %edi
movl $0x4, %esi
callq 0x583f0
testb %al, %al
jne 0x74e07
movl 0xc(%rsp), %eax
incl %eax
cmpl %r15d, %eax
jl 0x74e07
movq 0x190(%rbx), %rax
movl 0xb4(%rax), %eax
subl %r15d, %eax
addl $-0x2, %eax
movl %eax, 0xc(%rsp)
jmp 0x74e07
addl $0x4, %r15d
movl %r15d, (%rsp)
jmp 0x74e07
addl $0x4, %r15d
movl %r15d, 0x4(%rsp)
jmp 0x74e07
movq 0x190(%rbx), %rdi
callq 0x559e0
movups 0x5ec(%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
cmpl $0x0, 0x1c(%rsp)
jne 0x750a3
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x55970
testb %al, %al
jne 0x75003
cmpl $0x0, 0x20(%rsp)
jne 0x750a3
cmpl $0x0, 0x24(%rsp)
jne 0x750a3
cmpl $0x0, 0x28(%rsp)
jne 0x750a3
cmpl $0x0, 0x2c(%rsp)
jne 0x750a3
leaq 0x20(%rsp), %rdi
addl $0x5, 0x8(%rdi)
addl $0x5, 0xc(%rdi)
movq %rsp, %r14
movq %r14, %rsi
callq 0x58af0
leaq 0x48(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq 0xf7f7a(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
xorl %r12d, %r12d
leaq 0x30(%rsp), %r15
movq %r12, (%r15)
movq 0xf762e(%rip), %rdx     # 0x16c670
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %r8
callq 0x57930
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
decl %eax
decl %ecx
movq (%r14), %rdx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rdx, (%r15)
movq %rax, 0x8(%r15)
movq 0xf77aa(%rip), %rax     # 0x16c820
movl (%rax), %ecx
leaq 0x40(%rsp), %r8
movq %r12, (%r8)
movq 0xf7801(%rip), %rdx     # 0x16c888
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x57930
addq $0x5b8, %rbx            # imm = 0x5B8
movq %rbx, %rdi
callq 0x70488
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq