// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x8085c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
xorl %ecx, %ecx
testb %al, %al
je 0x80c83
movq %rbx, %rdi
callq 0x57060
testq %rax, %rax
jne 0x807c0
testb $0x1, 0x30(%rbx)
jne 0x807c0
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x180(%rax)
testq %rax, %rax
je 0x807c0
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x180(%rax)
movq %rax, %rdi
callq 0x59240
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, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %r12
shrq $0x20, %r12
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
movl %r15d, (%rsp)
movl %r12d, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
addl %r12d, %eax
movl %eax, 0xc(%rsp)
testl %ebp, %ebp
jne 0x80c81
movq %rsp, %rsi
movq %r14, %rdi
callq 0x56160
testb $0x1, 0x30(%rbx)
jne 0x80888
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq 0xe1764(%rip), %rcx     # 0x161fa8
movl (%rcx), %ecx
leaq 0x38(%rsp), %r8
testb %al, %al
je 0x80864
andq $0x0, (%r8)
movq 0xe0e16(%rip), %rdx     # 0x161670
jmp 0x8086f
pushq $-0x1
popq %rcx
jmp 0x80c83
andq $0x0, (%r8)
movq 0xe0c61(%rip), %rdx     # 0x1614d0
movq %rsp, %rsi
movq %r14, %rdi
callq 0x58b80
movq %rsp, %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x58ad0
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
movq %rsp, %r15
movl 0x8(%r15), %eax
movl (%r15), %ecx
movl 0x4(%r15), %edx
addl 0xc(%r15), %ecx
subl %ecx, %eax
addl %edx, %eax
incl %eax
leaq 0x18(%rsp), %r13
movl %eax, (%r13)
pushq $0x1
popq %rbp
movl %ebp, 0x4(%r13)
movq %r15, %rdi
movq %r13, %rsi
callq 0x58930
movl (%r15), %ecx
subl 0x8(%r15), %ecx
addl %edx, %ecx
addl 0xc(%r15), %ecx
subl 0x4(%r15), %ecx
addl $-0x2, %ecx
andq %r12, %rdx
orq %rdx, %rcx
movabsq $-0x200000000, %rdx     # imm = 0xFFFFFFFE00000000
addq %rdx, %rcx
leaq 0x38(%rsp), %r12
movq %rax, (%r12)
movq %rcx, 0x8(%r12)
movq 0xe16a7(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x30(%rsp), %r8
andq $0x0, (%r8)
movq 0xe0bbd(%rip), %rdx     # 0x1614d0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58b80
movl 0x8(%r15), %eax
movl (%r15), %ecx
movl 0x4(%r15), %edx
addl 0xc(%r15), %ecx
subl %ecx, %eax
addl %edx, %eax
incl %eax
movl %eax, (%r13)
movl %ebp, 0x4(%r13)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x58930
movl (%r15), %ecx
subl 0x8(%r15), %ecx
addl %edx, %ecx
addl 0xc(%r15), %ecx
subl 0x4(%r15), %ecx
addl $-0x2, %ecx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rsi, %rdx
orq %rdx, %rcx
movabsq $-0x200000000, %rdx     # imm = 0xFFFFFFFE00000000
addq %rdx, %rcx
movq %rax, (%r12)
movq %rcx, 0x8(%r12)
leaq 0x38(%rsp), %rsi
xorl %r13d, %r13d
movq %r14, %rdi
xorl %edx, %edx
callq 0x58ad0
movq %r14, %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x62b64(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x62df0(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x10(%rsp)
movl 0x4(%r15), %eax
notl %eax
addl 0xc(%r15), %eax
pushq $-0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %ebp
addl 0x8(%r15), %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x160(%rax)
movzbl %al, %ecx
addl %ebp, %ecx
movq 0x10(%rsp), %rdi
subl %edi, %ecx
movl 0x4(%r15), %esi
movl 0xc(%r15), %eax
movq %rdi, %r8
subl %esi, %eax
subl %edi, %eax
pushq $0x2
popq %rdi
cltd
idivl %edi
addl %esi, %eax
leaq 0x38(%rsp), %rdx
movl %ecx, (%rdx)
movl %eax, 0x4(%rdx)
leal (%rcx,%r8,2), %ecx
decl %ecx
shlq $0x20, %rax
orq %rax, %rcx
leaq 0x18(%rsp), %rax
movq %rcx, (%rax)
testl %r8d, %r8d
cmovgl %r8d, %r13d
movq 0xe0f0f(%rip), %rbp     # 0x161950
movq 0xe0fa0(%rip), %r15     # 0x1619e8
subl $0x1, %r13d
jb 0x80a9e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
movq %rbp, %rcx
testb %al, %al
je 0x80a64
movq %r15, %rcx
movq %r14, %rdi
movq %r12, %rsi
leaq 0x18(%rsp), %rdx
callq 0x595b0
movq 0x38(%rsp), %xmm0
psubd 0x65a6e(%rip), %xmm0    # 0xe64f0
movq %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %xmm0
paddd 0x6553a(%rip), %xmm0    # 0xe5fd0
movq %xmm0, 0x18(%rsp)
jmp 0x80a48
movq %r14, 0x10(%rsp)
testb $0x1, 0x30(%rbx)
jne 0x80c77
xorl %r15d, %r15d
leaq 0x38(%rsp), %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x178(%rax)
cmpl %eax, %r15d
jge 0x80c77
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x180(%rax)
cmpb $0x1, 0x5b9(%rax)
jne 0x80c6f
movq %rax, %rbp
movq (%rax), %rax
movq %rbp, %rdi
callq *0xa8(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x58280
movq %r14, %rdi
movq 0xe10a6(%rip), %rsi     # 0x161bb0
callq 0x56180
testb %al, %al
je 0x80b4a
movq %r14, %r12
movq %r14, %rdi
movq 0xe1090(%rip), %rsi     # 0x161bb0
callq 0x58830
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x59e40
movq %r12, %rdi
movq %r13, %rsi
callq 0x56630
movq %r13, %rdi
callq 0x5a588
movq 0x10(%rsp), %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x629ac(%rip), %xmm0    # 0xe3510
movsd %xmm0, 0x50(%rsp)
movl 0x4(%rsp), %r13d
movl 0xc(%rsp), %r12d
movq (%rbp), %rax
movq %rbp, %rdi
callq *0xe8(%rax)
movq %rax, %rdi
movq 0xe122d(%rip), %rsi     # 0x161db8
callq 0x588a0
addl %eax, %r13d
subl %r13d, %r12d
cvtsi2sd %r12d, %xmm0
mulsd 0x627dd(%rip), %xmm0    # 0xe3380
callq 0x57e30
cvttsd2si 0x50(%rsp), %ecx
decl %eax
movl %ecx, 0x30(%rsp)
movl %eax, 0x34(%rsp)
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x58930
movl 0x4(%rsp), %ecx
movq %rdx, %rsi
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
andq %rdi, %rsi
movl 0xc(%rsp), %edi
subl %edi, %edx
addl %edx, %ecx
addl $-0x2, %ecx
orq %rsi, %rcx
movq %rax, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0xe8(%rax)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
leaq 0x18(%rsp), %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x58df0
movq (%rbp), %rax
movq %rbp, %rdi
callq *0xf0(%rax)
movl 0xb0(%rbx), %ecx
addl $-0x16, %ecx
cmpl %ecx, %eax
jge 0x80c58
leaq 0x18(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x5a180
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xb0(%rax)
movq %r12, %rdi
callq 0x5a588
jmp 0x80c67
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0xb0(%rax)
movq %r14, %rdi
callq 0x5a588
incl %r15d
jmp 0x80ab5
movq 0x10(%rsp), %rdi
callq 0x59a80
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x80c96
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5a588
jmp 0x80cb0
jmp 0x80cad
jmp 0x80cad
jmp 0x80cad
jmp 0x80cad
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260