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

	if (GetSelectedEntry() == NIL && !(flags & CB_HOTSPOTONLY))
	{
		if (GetNthEntry(0) != NIL) ((ListEntry *) GetNthEntry(0))->Select();
	}

	if (flags & CB_HOTSPOTONLY) hotspot->Deactivate();
	else			    hotspot->Activate();

	Surface		*surface = GetDrawSurface();
	Rect		 frame	 = Rect(GetRealPosition(), GetRealSize());

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

			if (!(flags & CB_HOTSPOTONLY))
			{
				if (IsActive())	surface->Box(frame, Setup::ClientColor, Rect::Filled);
				else		surface->Box(frame, Setup::BackgroundColor, Rect::Filled);

				surface->Frame(frame, FRAME_DOWN);
			}

			surface->Box(frame + Point(frame.GetWidth() - frame.GetHeight() + 1, 1) - Size(frame.GetWidth() - frame.GetHeight() + 2, 2), Setup::BackgroundColor, Rect::Filled);
			surface->Frame(frame + Point(frame.GetWidth() - frame.GetHeight() + 1, 1) - Size(frame.GetWidth() - frame.GetHeight() + 2, 2), FRAME_UP);

			{
				Int	 height	   = Math::Round(3 * surface->GetSurfaceDPI() / 96.0);

				Point	 lineStart = Point(frame.right - (frame.GetHeight() - 1) / 2 - height + (IsRightToLeft() ? 1 : 0), frame.top + (frame.GetHeight() - height) / 2);
				Point	 lineEnd   = lineStart + Point(height * 2 - 1, 0);

				for (Int i = 0; i < height; i++)
				{
					if (IsActive())	surface->Line(lineStart, lineEnd, Setup::TextColor);
					else		surface->Line(lineStart, lineEnd, Setup::InactiveTextColor);

					lineStart += Point(1, 1);
					lineEnd	  += Point(-1, 1);
				}
			}

			if (!(flags & CB_HOTSPOTONLY))
			{
				for (Int i = 0; i < Length(); i++)
				{
					ListEntry	*entry = GetNthEntry(i);

					if (entry->IsSelected())
					{
						String	 entryText = entry->GetText();

						if (entryText.Contains(ListEntry::tabDelimiter)) entryText = entryText.Head(entryText.Find(ListEntry::tabDelimiter));

						surface->SetText(entryText, frame + Point(3 * surface->GetSurfaceDPI() / 96.0, Math::Ceil(Float(frame.GetHeight() - entry->GetFont().GetScaledTextSizeY()) / 2) - 1) - Size(frame.GetHeight() + 2, 0), entry->GetFont());

						if (entry->GetUnscaledTextWidth() >= GetWidth() - 22) SetTooltipText(entryText);
						else						      SetTooltipText(NIL);
					}
				}
			}

			surface->EndPaint();

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %r15d
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x82cd3
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x82cd3
movq %rbx, %rdi
callq 0x55f90
testq %rax, %rax
jne 0x82852
testb $0x1, 0x30(%rbx)
jne 0x82852
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x180(%rax)
testq %rax, %rax
je 0x82852
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x180(%rax)
movq %rax, %rdi
callq 0x57fb0
movl 0x30(%rbx), %eax
movq 0x6e8(%rbx), %rdi
movq (%rdi), %rcx
andl $0x1, %eax
callq *0x68(%rcx,%rax,8)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r12
movq %rax, %r14
shrq $0x20, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
leal (%rax,%r12), %ecx
shrq $0x20, %rax
movl %r12d, 0x8(%rsp)
movl %r14d, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
addl %r14d, %eax
movl %eax, 0x14(%rsp)
testl %r15d, %r15d
jne 0x82cd3
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x55160
testb $0x1, 0x30(%rbx)
jne 0x82922
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq 0xe96ce(%rip), %rcx     # 0x16bfa8
movl (%rcx), %ecx
leaq 0x38(%rsp), %r8
testb %al, %al
je 0x828f5
movq $0x0, (%r8)
movq 0xe8d7d(%rip), %rdx     # 0x16b670
jmp 0x82903
movq $0x0, (%r8)
movq 0xe8bcd(%rip), %rdx     # 0x16b4d0
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x57930
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57890
movl 0x10(%rsp), %eax
movl 0x8(%rsp), %ecx
movl 0xc(%rsp), %edx
movl %eax, %esi
subl %ecx, %esi
movl 0x14(%rsp), %edi
movl %edx, %r8d
subl %edi, %r8d
addl %esi, %r8d
addl %r8d, %ecx
incl %ecx
incl %edx
shlq $0x20, %rdx
decl %eax
decl %edi
orq %rdx, %rcx
shlq $0x20, %rdi
orq %rdi, %rax
leaq 0x38(%rsp), %r12
movq %rcx, (%r12)
movq %rax, 0x8(%r12)
movq 0xe963b(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
leaq 0x20(%rsp), %r15
movq $0x0, (%r15)
movq 0xe8b4e(%rip), %rdx     # 0x16b4d0
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %r8
callq 0x57930
movl 0x10(%rsp), %eax
movl 0x8(%rsp), %ecx
movl 0xc(%rsp), %edx
movl %eax, %esi
subl %ecx, %esi
movl 0x14(%rsp), %edi
movl %edx, %r8d
subl %edi, %r8d
addl %esi, %r8d
addl %r8d, %ecx
incl %ecx
incl %edx
shlq $0x20, %rdx
decl %eax
decl %edi
orq %rdx, %rcx
shlq $0x20, %rdi
orq %rdi, %rax
movq %rcx, (%r12)
movq %rax, 0x8(%r12)
leaq 0x38(%rsp), %r12
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x57890
movq %r13, 0x18(%rsp)
movq %r13, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x70cba(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x70dde(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r13
movl 0xc(%rsp), %eax
movl 0x10(%rsp), %ebp
notl %eax
addl 0x14(%rsp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
subl %ecx, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %ebp, %eax
subl %r13d, %eax
movl 0xc(%rsp), %ecx
movl 0x14(%rsp), %edx
subl %ecx, %edx
subl %r13d, %edx
movl %edx, %esi
shrl $0x1f, %esi
addl %edx, %esi
sarl %esi
addl %ecx, %esi
movl %eax, (%r12)
movl %esi, 0x4(%r12)
leal (%rax,%r13,2), %eax
decl %eax
shlq $0x20, %rsi
orq %rsi, %rax
movq %rax, (%r15)
testl %r13d, %r13d
jle 0x82aea
movq 0xe8eca(%rip), %rbp     # 0x16b950
movq 0xe8f5b(%rip), %r14     # 0x16b9e8
leaq 0x38(%rsp), %r15
leaq 0x20(%rsp), %r12
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq %rbp, %rcx
testb %al, %al
je 0x82aad
movq %r14, %rcx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x58300
movq 0x38(%rsp), %xmm0
psubd 0x73ae5(%rip), %xmm0    # 0xf65b0
movq %xmm0, 0x38(%rsp)
movq 0x20(%rsp), %xmm0
paddd 0x73551(%rip), %xmm0    # 0xf6030
movq %xmm0, 0x20(%rsp)
decl %r13d
jne 0x82a97
testb $0x1, 0x30(%rbx)
jne 0x82cc7
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x82cc7
xorl %r15d, %r15d
leaq 0x38(%rsp), %r12
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
cmpb $0x1, 0x5b9(%rax)
jne 0x82caf
movq %rax, %r13
movq (%rax), %rax
movq %r13, %rdi
callq *0xa8(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x570b0
movq %r12, %rdi
movq 0xe9060(%rip), %rsi     # 0x16bbb0
callq 0x55180
testb %al, %al
je 0x82b8d
movq %r12, %rdi
movq 0xe904d(%rip), %rsi     # 0x16bbb0
callq 0x57610
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x58b00
movq %r12, %rdi
movq %r14, %rsi
callq 0x555f0
movq %r14, %rdi
callq 0x59200
movq 0x18(%rsp), %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x70b0e(%rip), %xmm0    # 0xf36b8
movsd %xmm0, 0x50(%rsp)
movl 0xc(%rsp), %ebp
movl 0x14(%rsp), %r14d
movq (%r13), %rax
movq %r13, %rdi
callq *0xe8(%rax)
movq %rax, %rdi
movq 0xe91e8(%rip), %rsi     # 0x16bdb8
callq 0x57680
addl %eax, %ebp
subl %ebp, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x707ae(%rip), %xmm0    # 0xf3398
callq 0x56cb0
cvttsd2si 0x50(%rsp), %ecx
movl 0x8(%rsp), %edx
addl %ecx, %edx
movl 0xc(%rsp), %esi
movl 0x14(%rsp), %edi
leal (%rsi,%rax), %r8d
decl %r8d
shlq $0x20, %r8
addl %edi, %eax
decl %eax
addl %esi, %ecx
addl 0x10(%rsp), %ecx
shlq $0x20, %rax
subl %edi, %ecx
addl $-0x2, %ecx
orq %r8, %rdx
orq %rax, %rcx
movq %rdx, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movq (%r13), %rax
movq %r13, %rdi
callq *0xe8(%rax)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
leaq 0x20(%rsp), %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x57b80
movq (%r13), %rax
movq %r13, %rdi
callq *0xf0(%rax)
movl 0xb0(%rbx), %ecx
addl $-0x16, %ecx
cmpl %ecx, %eax
jge 0x82c98
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x58e20
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0xb0(%rax)
movq %r14, %rdi
callq 0x59200
jmp 0x82ca7
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xb0(%rax)
movq %r12, %rdi
callq 0x59200
incl %r15d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jl 0x82b10
movq 0x18(%rsp), %rdi
callq 0x58780
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82ce8
jmp 0x82cfd
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59200
jmp 0x82d00
jmp 0x82cfd
jmp 0x82cfd
jmp 0x82cfd
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090