// File: /workspace/github_c_makefile_star2_O1/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 0x8319c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x8319c
movq %rbx, %rdi
callq 0x55f90
testq %rax, %rax
jne 0x82d36
testb $0x1, 0x30(%rbx)
jne 0x82d36
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x180(%rax)
testq %rax, %rax
je 0x82d36
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 0x8319c
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x55160
testb $0x1, 0x30(%rbx)
jne 0x82e06
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq 0xea1ea(%rip), %rcx     # 0x16cfa8
movl (%rcx), %ecx
leaq 0x38(%rsp), %r8
testb %al, %al
je 0x82dd9
movq $0x0, (%r8)
movq 0xe9899(%rip), %rdx     # 0x16c670
jmp 0x82de7
movq $0x0, (%r8)
movq 0xe96e9(%rip), %rdx     # 0x16c4d0
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 0xea157(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
leaq 0x20(%rsp), %r15
movq $0x0, (%r15)
movq 0xe966a(%rip), %rdx     # 0x16c4d0
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 0x7160e(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7189a(%rip), %rcx     # 0xf4790
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 0x82fb6
movq 0xe99e6(%rip), %rbp     # 0x16c950
movq 0xe9a77(%rip), %r14     # 0x16c9e8
leaq 0x38(%rsp), %r15
leaq 0x20(%rsp), %r12
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq %rbp, %rcx
testb %al, %al
je 0x82f91
movq %r14, %rcx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x58300
incl 0x38(%rsp)
incl 0x3c(%rsp)
decl 0x20(%rsp)
incl 0x24(%rsp)
decl %r13d
jne 0x82f7b
testb $0x1, 0x30(%rbx)
jne 0x83190
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
testl %eax, %eax
jle 0x83190
xorl %r15d, %r15d
leaq 0x38(%rsp), %r12
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
cmpb $0x1, 0x5b9(%rax)
jne 0x83178
movq %rax, %r13
movq (%rax), %rax
movq %r13, %rdi
callq *0xa8(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x570b0
movq %r12, %rdi
movq 0xe9b94(%rip), %rsi     # 0x16cbb0
callq 0x55180
testb %al, %al
je 0x83059
movq %r12, %rdi
movq 0xe9b81(%rip), %rsi     # 0x16cbb0
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
cvtsi2sd %eax, %xmm0
divsd 0x7147d(%rip), %xmm0    # 0xf44f0
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 0xe9d1f(%rip), %rsi     # 0x16cdb8
callq 0x57680
addl %eax, %ebp
subl %ebp, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x712e5(%rip), %xmm0    # 0xf4398
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 0x83161
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 0x83170
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 0x82fdc
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 0x831b1
jmp 0x831c6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59200
jmp 0x831c9
jmp 0x831c6
jmp 0x831c6
jmp 0x831c6
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090
nop