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

	Surface	*surface = GetDrawSurface();
	Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());
	Window	*window	 = container->GetContainerWindow();

	CalculateHeight();

	switch (message)
	{
		case SP_PAINT:
			surface->StartPaint(GetVisibleArea());

			if (!IsMarked()) list.Hide();

			if (window->IsMouseOn(Rect(Point(frame.left, frame.top), Size(frame.GetWidth(),  Math::Round(16 * surface->GetSurfaceDPI() / 96.0))))) PaintText(Setup::GradientTextColor, True);
			else																       PaintText(active ? font.GetColor() : Setup::InactiveTextColor, False);

			if (IsMarked())
			{
				list.SetVisibleDirect(False);
				list.SetMetrics(Point(12, 16), GetSize() - Size(12, 15));

				Rect	 visibleArea	   = list.GetVisibleArea() - list.GetRealPosition();

				Point	 entryPosition	   = Point(0, 0);
				Point	 entryRealPosition = Point(0, 0);

				for (Int i = 0; i < Length(); i++)
				{
					ListEntry	*entry	       = GetNthEntry(i);
					Size		 entryRealSize = entry->GetRealSize();

					entry->SetVisibleDirect(False);

					if (entryRealPosition.y + entryRealSize.cy >= visibleArea.top && entryRealPosition.y <= visibleArea.bottom)
					{
						entry->SetMetrics(entryPosition, Size(list.GetWidth(), entry->GetHeight()));
						entry->SetVisibleDirect(True);

						/* Draw horizontal branch line.
						 */
						Point	 startPos = GetRealPosition() + Point(Math::Round(6 * surface->GetSurfaceDPI() / 96.0) + (IsRightToLeft() ? 1 : 0), entryRealPosition.y + Math::Round(8 * surface->GetSurfaceDPI() / 96.0) + Math::Round(16 * surface->GetSurfaceDPI() / 96.0));

						for (Int x = 0; x < Math::Round(5 * surface->GetSurfaceDPI() / 96.0); x += 2)
						{
							surface->SetPixel(startPos + Point(x, 0), Setup::InactiveTextColor);
						}
					}

					/* Compute next entry position.
					 */
					if (i < Length() - 1)
					{
						entryPosition.y	    += entry->GetHeight();
						entryRealPosition.y  = Math::Round(entryPosition.y * surface->GetSurfaceDPI() / 96.0);
					}
				}

				list.SetVisibleDirect(True);
				list.Paint(SP_PAINT);

				/* Draw vertical dotted line.
				 */
				Point	 startPos = frame.GetPosition() + Point(Math::Round(6 * surface->GetSurfaceDPI() / 96.0) + (IsRightToLeft() ? 1 : 0), Math::Round(16 * surface->GetSurfaceDPI() / 96.0));

				for (Int i = visibleArea.top - visibleArea.top % 2; i < Math::Min(entryRealPosition.y, visibleArea.bottom) + Math::Round(9 * surface->GetSurfaceDPI() / 96.0); i += 2)
				{
					surface->SetPixel(startPos + Point(0, i), Setup::InactiveTextColor);
				}
			}

			surface->EndPaint();

			break;
		case SP_MOUSEIN:
			if (window->IsMouseOn(Rect(Point(frame.left, frame.top), Size(frame.GetWidth(), Math::Round(16 * surface->GetSurfaceDPI() / 96.0))))) PaintText(Setup::GradientTextColor, True);

			break;
		case SP_MOUSEOUT:
			PaintText(font.GetColor(), False);

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, %r13
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x8bb59
movq (%r13), %rax
movq %r13, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x8c0f0
movq (%r13), %rax
movq %r13, %rdi
callq *0x40(%rax)
movq %rax, %r14
movq (%r13), %rax
movq %r13, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq (%r13), %rax
movq %r13, %rdi
callq *0x50(%rax)
movq %rax, %r12
movq 0x190(%r13), %rdi
callq 0x56a50
movq %rax, %rbx
movq %r13, %rdi
callq 0x59b40
cmpl $0x3, %ebp
je 0x8bbde
addl %r15d, %r12d
cmpl $0x2, %ebp
movq %r15, %rax
je 0x8bb61
testl %ebp, %ebp
jne 0x8c0ee
movq %rax, 0x28(%rsp)
movq (%r13), %rax
movq %r13, %rdi
callq *0x130(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r14, %rdi
callq 0x56160
cmpb $0x0, 0x5b8(%r13)
jne 0x8bae1
leaq 0x630(%r13), %rdi
callq 0x56640
movq 0x28(%rsp), %r15
movq %r15, %rbp
shrq $0x20, %rbp
movq %r14, %rdi
callq 0x59c60
cwtl
shll $0x4, %eax
cvtsi2sd %eax, %xmm0
divsd 0x57a0b(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x57e57(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
leaq 0x10(%rsp), %rsi
movl %r15d, (%rsi)
movl %ebp, 0x4(%rsi)
movl %r12d, 0x8(%rsi)
addl %ebp, %eax
movl %eax, 0xc(%rsi)
movq %rbx, %rdi
callq 0x58ae0
testb %al, %al
je 0x8bbfe
movq 0xd5fe2(%rip), %rsi     # 0x161b30
pushq $0x1
popq %rdx
movq %r13, %rdi
jmp 0x8bc25
pushq $-0x1
popq %rbx
jmp 0x8c0f0
movq %rax, %r15
shrq $0x20, %r15
movq %r14, %rdi
movq %rax, %r14
callq 0x59c60
cwtl
shll $0x4, %eax
cvtsi2sd %eax, %xmm0
divsd 0x5798d(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x57dd9(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
leaq 0x10(%rsp), %rsi
movl %r14d, (%rsi)
movl %r15d, 0x4(%rsi)
movl %r12d, 0x8(%rsi)
addl %r15d, %eax
movl %eax, 0xc(%rsi)
movq %rbx, %rdi
callq 0x58ae0
testb %al, %al
je 0x8c0ee
movq 0xd5f62(%rip), %rsi     # 0x161b30
pushq $0x1
popq %rdx
movq %r13, %rdi
callq 0x592a0
jmp 0x8c0ee
leaq 0x140(%r13), %rdi
callq 0x58750
xorl %ebx, %ebx
movq %r13, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x592a0
jmp 0x8c0f0
cmpb $0x1, 0xcc(%r13)
jne 0x8bc19
leaq 0x140(%r13), %rdi
callq 0x58750
movq %rax, %rsi
jmp 0x8bc20
movq 0xd5d30(%rip), %rsi     # 0x161950
movq %r13, %rdi
xorl %edx, %edx
callq 0x592a0
cmpb $0x1, 0x5b8(%r13)
jne 0x8c0e6
movq %rbp, 0x50(%rsp)
leaq 0x630(%r13), %rbx
movb $0x0, 0x6fb(%r13)
movabsq $0x100000000c, %rax     # imm = 0x100000000C
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
movl 0xb0(%r13), %eax
movl 0xb4(%r13), %ecx
addl $-0xc, %eax
addl $-0xf, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rsp, %r12
movq %rax, (%r12)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x58250
movq %rbx, %rdi
callq 0x5a410
movq %rax, (%r15)
movq %rdx, 0x8(%r15)
movq %rbx, 0x38(%rsp)
movq %rbx, %rdi
callq 0x58600
movq %rax, (%r12)
leaq 0x10(%rsp), %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x58180
andq $0x0, (%rbx)
shrq $0x20, %rax
movq %rax, 0x40(%rsp)
shrq $0x20, %rdx
movq %rdx, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
movq 0xd5c6c(%rip), %rbx     # 0x161950
xorl %r15d, %r15d
movq %r13, 0x48(%rsp)
cmpl 0xc48(%r13), %r15d
jge 0x8bf7b
movq 0x38(%rsp), %rdi
movl %r15d, 0x24(%rsp)
movl %r15d, %esi
callq 0x59ef0
movq %rax, %r12
movq (%rax), %rax
movq %r12, %rdi
callq *0x50(%rax)
shrq $0x20, %rax
movb $0x0, 0xcb(%r12)
addl 0x8(%rsp), %eax
cmpl 0x40(%rsp), %eax
jl 0x8bf10
movq 0x8(%rsp), %rax
cmpl 0x30(%rsp), %eax
jg 0x8bf10
movq 0x48(%rsp), %r15
movl 0x6e0(%r15), %eax
movl 0xb4(%r12), %ecx
movl %eax, (%rsp)
movl %ecx, 0x4(%rsp)
movq (%r12), %rax
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
movq %rsp, %rdx
callq *0x150(%rax)
movb $0x1, 0xcb(%r12)
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, 0x60(%rsp)
movq %r14, %rdi
callq 0x59c60
cwtl
imull $0x6, %eax, %eax
cvtsi2sd %eax, %xmm0
movsd 0x57770(%rip), %xmm1    # 0xe3510
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
xorpd %xmm2, %xmm2
cmpltsd %xmm2, %xmm1
movapd %xmm1, %xmm2
movsd 0x575bb(%rip), %xmm3    # 0xe3378
andpd %xmm3, %xmm2
movsd 0x575b7(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, 0x58(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
movzbl %al, %r13d
movq %r14, %rdi
callq 0x59c60
cwtl
shll $0x3, %eax
cvtsi2sd %eax, %xmm0
divsd 0x57709(%rip), %xmm0    # 0xe3510
movapd %xmm0, %xmm1
cmpltsd 0x57994(%rip), %xmm1    # 0xe37a8
movapd %xmm1, %xmm2
movsd 0x57558(%rip), %xmm3    # 0xe3378
andpd %xmm3, %xmm2
movsd 0x57554(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rbp
addl 0x8(%rsp), %ebp
movq %r14, %rdi
callq 0x59c60
cwtl
shll $0x4, %eax
cvtsi2sd %eax, %xmm0
divsd 0x576b7(%rip), %xmm0    # 0xe3510
movapd %xmm0, %xmm1
cmpltsd 0x57942(%rip), %xmm1    # 0xe37a8
movapd %xmm1, %xmm2
movsd 0x57506(%rip), %xmm3    # 0xe3378
andpd %xmm3, %xmm2
movsd 0x57502(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15
addl %ebp, %r15d
movq 0x60(%rsp), %rax
addq %rax, %r13
addq 0x58(%rsp), %r13
shlq $0x20, %r15
addq %rax, %r15
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %r15
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,4), %eax
cvtsi2sd %eax, %xmm0
divsd 0x57643(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x57a8f(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
cmpq %rax, %rbp
jge 0x8bf10
leal (%r13,%rbp), %eax
orq %r15, %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq %rsp, %rsi
movq %rbx, %rdx
callq 0x56120
addq $0x2, %rbp
jmp 0x8beb5
movq 0x48(%rsp), %r13
movl 0xc48(%r13), %eax
decl %eax
movl 0x24(%rsp), %r15d
cmpl %eax, %r15d
jge 0x8bf73
movl 0x14(%rsp), %ebp
addl 0xb4(%r12), %ebp
movl %ebp, 0x14(%rsp)
movq %r14, %rdi
callq 0x59c60
cwtl
imull %ebp, %eax
cvtsi2sd %eax, %xmm0
divsd 0x575c0(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x57a0c(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x8(%rsp)
incl %r15d
jmp 0x8bcec
movb $0x1, 0x6fb(%r13)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x57910
movq %r14, %rdi
callq 0x59c60
cwtl
imull $0x6, %eax, %eax
cvtsi2sd %eax, %xmm0
movsd 0x57569(%rip), %xmm1    # 0xe3510
divsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm1
cmpltsd %xmm2, %xmm1
movapd %xmm1, %xmm2
movsd 0x573b4(%rip), %xmm3    # 0xe3378
andpd %xmm3, %xmm2
movsd 0x573b0(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rbx
movq (%r13), %rax
movq %r13, %rdi
callq *0x160(%rax)
movl %eax, %ebp
movq %r14, %rdi
callq 0x59c60
cwtl
shll $0x4, %eax
cvtsi2sd %eax, %xmm0
divsd 0x57508(%rip), %xmm0    # 0xe3510
movapd %xmm0, %xmm1
cmpltsd 0x57793(%rip), %xmm1    # 0xe37a8
movsd 0x5735b(%rip), %xmm2    # 0xe3378
andpd %xmm1, %xmm2
movsd 0x57357(%rip), %xmm3    # 0xe3380
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r12
movzbl %bpl, %eax
movq 0x28(%rsp), %rcx
addl %eax, %ecx
addl %ecx, %ebx
pushq $0x2
popq %rcx
movq 0x40(%rsp), %rsi
movl %esi, %eax
cltd
idivl %ecx
subl %edx, %esi
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
cmpl %eax, %ecx
cmovll %ecx, %eax
movslq %eax, %r13
movslq %esi, %rbp
movq 0x50(%rsp), %rax
addl %ebp, %eax
addl %eax, %r12d
shlq $0x20, %r12
orq %rbx, %r12
movq %rsp, %r15
movabsq $0x200000000, %rbx      # imm = 0x200000000
movq %r14, %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,8), %eax
cvtsi2sd %eax, %xmm0
divsd 0x5746f(%rip), %xmm0    # 0xe3510
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
seta %al
leaq 0x578bb(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
addq %r13, %rax
cmpq %rbp, %rax
jle 0x8c0e6
movq %r12, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq 0xd5878(%rip), %rdx     # 0x161950
callq 0x56120
addq $0x2, %rbp
addq %rbx, %r12
jmp 0x8c089
movq %r14, %rdi
callq 0x59a80
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop